From 064cc827a31a5e1316df2b48a62e71281d159a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 15 Dec 2019 10:51:12 +0200 Subject: [PATCH] Fix video plugins build after gstreamer-rs!377 VideoInfo::from_caps() now returns a Result. --- gst-plugin-fallbackswitch/src/fallbackswitch.rs | 2 +- gst-plugin-togglerecord/src/togglerecord.rs | 2 +- gst-plugin-tutorial/src/rgb2gray.rs | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gst-plugin-fallbackswitch/src/fallbackswitch.rs b/gst-plugin-fallbackswitch/src/fallbackswitch.rs index 22e7f55b..738a438b 100644 --- a/gst-plugin-fallbackswitch/src/fallbackswitch.rs +++ b/gst-plugin-fallbackswitch/src/fallbackswitch.rs @@ -577,7 +577,7 @@ impl AggregatorImpl for FallbackSwitch { video_info = None; } else if caps.get_structure(0).unwrap().get_name() == "video/x-raw" { audio_info = None; - video_info = gst_video::VideoInfo::from_caps(&caps); + video_info = gst_video::VideoInfo::from_caps(&caps).ok(); } else { audio_info = None; video_info = None; diff --git a/gst-plugin-togglerecord/src/togglerecord.rs b/gst-plugin-togglerecord/src/togglerecord.rs index 15b16b90..f6937d0a 100644 --- a/gst-plugin-togglerecord/src/togglerecord.rs +++ b/gst-plugin-togglerecord/src/togglerecord.rs @@ -1166,7 +1166,7 @@ impl ToggleRecord { state.video_info = None; } else if s.get_name().starts_with("video/") { state.audio_info = None; - state.video_info = gst_video::VideoInfo::from_caps(caps); + state.video_info = gst_video::VideoInfo::from_caps(caps).ok(); gst_log!(CAT, obj: pad, "Got video caps {:?}", state.video_info); } else { state.audio_info = None; diff --git a/gst-plugin-tutorial/src/rgb2gray.rs b/gst-plugin-tutorial/src/rgb2gray.rs index 95b53f3d..3ec9dbf1 100644 --- a/gst-plugin-tutorial/src/rgb2gray.rs +++ b/gst-plugin-tutorial/src/rgb2gray.rs @@ -366,7 +366,9 @@ impl BaseTransformImpl for Rgb2Gray { // to the given caps. This is used for allocating a big enough output buffer and // sanity checking the input buffer size, among other things. fn get_unit_size(&self, _element: &gst_base::BaseTransform, caps: &gst::Caps) -> Option { - gst_video::VideoInfo::from_caps(caps).map(|info| info.size()) + gst_video::VideoInfo::from_caps(caps) + .map(|info| info.size()) + .ok() } // Called whenever the input/output caps are changing, i.e. in the very beginning before data @@ -382,12 +384,12 @@ impl BaseTransformImpl for Rgb2Gray { outcaps: &gst::Caps, ) -> Result<(), gst::LoggableError> { let in_info = match gst_video::VideoInfo::from_caps(incaps) { - None => return Err(gst_loggable_error!(CAT, "Failed to parse input caps")), - Some(info) => info, + Err(_) => return Err(gst_loggable_error!(CAT, "Failed to parse input caps")), + Ok(info) => info, }; let out_info = match gst_video::VideoInfo::from_caps(outcaps) { - None => return Err(gst_loggable_error!(CAT, "Failed to parse output caps")), - Some(info) => info, + Err(_) => return Err(gst_loggable_error!(CAT, "Failed to parse output caps")), + Ok(info) => info, }; gst_debug!(