From 9b8ef9d65b9d08a3044c5f098bb3f988b9e44679 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Wed, 15 Jun 2022 15:06:24 +0900 Subject: [PATCH] crosvm: config: re-enable ffmpeg feature The ffmpeg feature flag handling code has been inadvertedly removed by http://crrev.com/c/3684144. Restore it. BUG=b:169295147 BUG=b:179756087 TEST=`cargo build --features "video-decoder,ffmpeg"` and decode a video from a guest. Change-Id: Id0d0f8c380353648e53602c6fa56ae9a0115cb8c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3706480 Reviewed-by: Keiichi Watanabe Tested-by: kokoro Commit-Queue: Alexandre Courbot --- src/crosvm/cmdline.rs | 2 +- src/crosvm/config.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/crosvm/cmdline.rs b/src/crosvm/cmdline.rs index e019f0d0a8..7eedee5bde 100644 --- a/src/crosvm/cmdline.rs +++ b/src/crosvm/cmdline.rs @@ -1049,7 +1049,7 @@ pub struct RunCommand { from_str_fn(parse_video_options) )] /// (EXPERIMENTAL) enable virtio-video decoder device - // Possible backend values: libvda + // Possible backend values: libvda, ffmpeg pub video_dec: Option, #[cfg(feature = "video-encoder")] #[argh( diff --git a/src/crosvm/config.rs b/src/crosvm/config.rs index 65183227c7..36db4e3c9c 100644 --- a/src/crosvm/config.rs +++ b/src/crosvm/config.rs @@ -703,6 +703,8 @@ pub fn parse_video_options(s: &str) -> Result { const VALID_VIDEO_BACKENDS: &[&str] = &[ #[cfg(feature = "libvda")] "libvda", + #[cfg(feature = "ffmpeg")] + "ffmpeg", ]; match s { @@ -710,6 +712,12 @@ pub fn parse_video_options(s: &str) -> Result { cfg_if::cfg_if! { if #[cfg(feature = "libvda")] { Ok(VideoBackendType::Libvda) + } else if #[cfg(feature = "ffmpeg")] { + Ok(VideoBackendType::Ffmpeg) + } else { + // Cannot be reached because at least one video backend needs to be enabled for + // the decoder to be compiled. + unreachable!() } } } @@ -717,6 +725,8 @@ pub fn parse_video_options(s: &str) -> Result { "libvda" => Ok(VideoBackendType::Libvda), #[cfg(feature = "libvda")] "libvda-vd" => Ok(VideoBackendType::LibvdaVd), + #[cfg(feature = "ffmpeg")] + "ffmpeg" => Ok(VideoBackendType::Ffmpeg), _ => Err(invalid_value_err( s, format!("should be one of ({})", VALID_VIDEO_BACKENDS.join("|")),