From 25860f7701199b302f29572378544567f6bb6984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 14 Sep 2019 11:05:55 +0300 Subject: [PATCH] audio/video: proxy_getcaps() can't return None and get_caps() vfuncs must not return None Other than in git master / 0.15, proxy_getcaps() on the video base classes still returns an Option to preserve API compatibility. --- Gir_GstAudio.toml | 10 ++++++++++ gstreamer-audio/src/auto/audio_decoder.rs | 12 ++---------- gstreamer-audio/src/auto/audio_encoder.rs | 12 ++---------- gstreamer-audio/src/subclass/audio_decoder.rs | 16 ++++------------ gstreamer-audio/src/subclass/audio_encoder.rs | 16 ++++------------ gstreamer-video/src/subclass/video_decoder.rs | 18 +++++------------- gstreamer-video/src/subclass/video_encoder.rs | 18 +++++------------- 7 files changed, 32 insertions(+), 70 deletions(-) diff --git a/Gir_GstAudio.toml b/Gir_GstAudio.toml index c18f6a029..607e2c572 100644 --- a/Gir_GstAudio.toml +++ b/Gir_GstAudio.toml @@ -163,6 +163,11 @@ status = "generate" name = "get_allocator" ignore = true + [[object.function]] + name = "proxy_getcaps" + [object.function.return] + nullable = false + [[object]] name = "GstAudio.AudioEncoder" status = "generate" @@ -186,3 +191,8 @@ status = "generate" [[object.function]] name = "get_latency" ignore = true + + [[object.function]] + name = "proxy_getcaps" + [object.function.return] + nullable = false diff --git a/gstreamer-audio/src/auto/audio_decoder.rs b/gstreamer-audio/src/auto/audio_decoder.rs index 745fd8f59..70ae508f9 100644 --- a/gstreamer-audio/src/auto/audio_decoder.rs +++ b/gstreamer-audio/src/auto/audio_decoder.rs @@ -57,11 +57,7 @@ pub trait AudioDecoderExt: 'static { fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode); - fn proxy_getcaps( - &self, - caps: Option<&gst::Caps>, - filter: Option<&gst::Caps>, - ) -> Option; + fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps; #[cfg(any(feature = "v1_10", feature = "dox"))] fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>); @@ -214,11 +210,7 @@ impl> AudioDecoderExt for O { } } - fn proxy_getcaps( - &self, - caps: Option<&gst::Caps>, - filter: Option<&gst::Caps>, - ) -> Option { + fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps { unsafe { from_glib_full(gst_audio_sys::gst_audio_decoder_proxy_getcaps( self.as_ref().to_glib_none().0, diff --git a/gstreamer-audio/src/auto/audio_encoder.rs b/gstreamer-audio/src/auto/audio_encoder.rs index 082c3d7d9..7b4b0c098 100644 --- a/gstreamer-audio/src/auto/audio_encoder.rs +++ b/gstreamer-audio/src/auto/audio_encoder.rs @@ -54,11 +54,7 @@ pub trait AudioEncoderExt: 'static { fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode); - fn proxy_getcaps( - &self, - caps: Option<&gst::Caps>, - filter: Option<&gst::Caps>, - ) -> Option; + fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps; #[cfg(any(feature = "v1_10", feature = "dox"))] fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>); @@ -204,11 +200,7 @@ impl> AudioEncoderExt for O { } } - fn proxy_getcaps( - &self, - caps: Option<&gst::Caps>, - filter: Option<&gst::Caps>, - ) -> Option { + fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps { unsafe { from_glib_full(gst_audio_sys::gst_audio_encoder_proxy_getcaps( self.as_ref().to_glib_none().0, diff --git a/gstreamer-audio/src/subclass/audio_decoder.rs b/gstreamer-audio/src/subclass/audio_decoder.rs index 042ae3400..1de59da1d 100644 --- a/gstreamer-audio/src/subclass/audio_decoder.rs +++ b/gstreamer-audio/src/subclass/audio_decoder.rs @@ -83,7 +83,7 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl + Send + Sync + 's self.parent_negotiate(element) } - fn get_caps(&self, element: &AudioDecoder, filter: Option<&gst::Caps>) -> Option { + fn get_caps(&self, element: &AudioDecoder, filter: Option<&gst::Caps>) -> gst::Caps { self.parent_get_caps(element, filter) } @@ -157,11 +157,7 @@ pub trait AudioDecoderImplExt { fn parent_negotiate(&self, element: &AudioDecoder) -> Result<(), gst::LoggableError>; - fn parent_get_caps( - &self, - element: &AudioDecoder, - filter: Option<&gst::Caps>, - ) -> Option; + fn parent_get_caps(&self, element: &AudioDecoder, filter: Option<&gst::Caps>) -> gst::Caps; fn parent_sink_event(&self, element: &AudioDecoder, event: gst::Event) -> bool; @@ -402,11 +398,7 @@ impl AudioDecoderImplExt for T { } } - fn parent_get_caps( - &self, - element: &AudioDecoder, - filter: Option<&gst::Caps>, - ) -> Option { + fn parent_get_caps(&self, element: &AudioDecoder, filter: Option<&gst::Caps>) -> gst::Caps { unsafe { let data = self.get_type_data(); let parent_class = @@ -807,7 +799,7 @@ where let imp = instance.get_impl(); let wrap: AudioDecoder = from_glib_borrow(ptr); - gst_panic_to_error!(&wrap, &instance.panicked(), None, { + gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { AudioDecoderImpl::get_caps( imp, &wrap, diff --git a/gstreamer-audio/src/subclass/audio_encoder.rs b/gstreamer-audio/src/subclass/audio_encoder.rs index 056a46e2f..ebe24bc89 100644 --- a/gstreamer-audio/src/subclass/audio_encoder.rs +++ b/gstreamer-audio/src/subclass/audio_encoder.rs @@ -74,7 +74,7 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl + Send + Sync + 's self.parent_negotiate(element) } - fn get_caps(&self, element: &AudioEncoder, filter: Option<&gst::Caps>) -> Option { + fn get_caps(&self, element: &AudioEncoder, filter: Option<&gst::Caps>) -> gst::Caps { self.parent_get_caps(element, filter) } @@ -142,11 +142,7 @@ pub trait AudioEncoderImplExt { fn parent_negotiate(&self, element: &AudioEncoder) -> Result<(), gst::LoggableError>; - fn parent_get_caps( - &self, - element: &AudioEncoder, - filter: Option<&gst::Caps>, - ) -> Option; + fn parent_get_caps(&self, element: &AudioEncoder, filter: Option<&gst::Caps>) -> gst::Caps; fn parent_sink_event(&self, element: &AudioEncoder, event: gst::Event) -> bool; @@ -353,11 +349,7 @@ impl AudioEncoderImplExt for T { } } - fn parent_get_caps( - &self, - element: &AudioEncoder, - filter: Option<&gst::Caps>, - ) -> Option { + fn parent_get_caps(&self, element: &AudioEncoder, filter: Option<&gst::Caps>) -> gst::Caps { unsafe { let data = self.get_type_data(); let parent_class = @@ -725,7 +717,7 @@ where let imp = instance.get_impl(); let wrap: AudioEncoder = from_glib_borrow(ptr); - gst_panic_to_error!(&wrap, &instance.panicked(), None, { + gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { AudioEncoderImpl::get_caps( imp, &wrap, diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index c23b62e72..c0314e008 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -84,7 +84,7 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl + Send + Sync + 's self.parent_negotiate(element) } - fn get_caps(&self, element: &VideoDecoder, filter: Option<&gst::Caps>) -> Option { + fn get_caps(&self, element: &VideoDecoder, filter: Option<&gst::Caps>) -> gst::Caps { self.parent_get_caps(element, filter) } @@ -158,11 +158,7 @@ pub trait VideoDecoderImplExt { fn parent_negotiate(&self, element: &VideoDecoder) -> Result<(), gst::LoggableError>; - fn parent_get_caps( - &self, - element: &VideoDecoder, - filter: Option<&gst::Caps>, - ) -> Option; + fn parent_get_caps(&self, element: &VideoDecoder, filter: Option<&gst::Caps>) -> gst::Caps; fn parent_sink_event(&self, element: &VideoDecoder, event: gst::Event) -> bool; @@ -393,11 +389,7 @@ impl VideoDecoderImplExt for T { } } - fn parent_get_caps( - &self, - element: &VideoDecoder, - filter: Option<&gst::Caps>, - ) -> Option { + fn parent_get_caps(&self, element: &VideoDecoder, filter: Option<&gst::Caps>) -> gst::Caps { unsafe { let data = self.get_type_data(); let parent_class = @@ -405,7 +397,7 @@ impl VideoDecoderImplExt for T { (*parent_class) .getcaps .map(|f| from_glib_full(f(element.to_glib_none().0, filter.to_glib_none().0))) - .unwrap_or(element.proxy_getcaps(None, filter)) + .unwrap_or(element.proxy_getcaps(None, filter).unwrap()) } } @@ -798,7 +790,7 @@ where let imp = instance.get_impl(); let wrap: VideoDecoder = from_glib_borrow(ptr); - gst_panic_to_error!(&wrap, &instance.panicked(), None, { + gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { VideoDecoderImpl::get_caps( imp, &wrap, diff --git a/gstreamer-video/src/subclass/video_encoder.rs b/gstreamer-video/src/subclass/video_encoder.rs index b4cec4d7b..fa7773f9f 100644 --- a/gstreamer-video/src/subclass/video_encoder.rs +++ b/gstreamer-video/src/subclass/video_encoder.rs @@ -69,7 +69,7 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl + Send + Sync + 's self.parent_negotiate(element) } - fn get_caps(&self, element: &VideoEncoder, filter: Option<&gst::Caps>) -> Option { + fn get_caps(&self, element: &VideoEncoder, filter: Option<&gst::Caps>) -> gst::Caps { self.parent_get_caps(element, filter) } @@ -133,11 +133,7 @@ pub trait VideoEncoderImplExt { fn parent_negotiate(&self, element: &VideoEncoder) -> Result<(), gst::LoggableError>; - fn parent_get_caps( - &self, - element: &VideoEncoder, - filter: Option<&gst::Caps>, - ) -> Option; + fn parent_get_caps(&self, element: &VideoEncoder, filter: Option<&gst::Caps>) -> gst::Caps; fn parent_sink_event(&self, element: &VideoEncoder, event: gst::Event) -> bool; @@ -329,11 +325,7 @@ impl VideoEncoderImplExt for T { } } - fn parent_get_caps( - &self, - element: &VideoEncoder, - filter: Option<&gst::Caps>, - ) -> Option { + fn parent_get_caps(&self, element: &VideoEncoder, filter: Option<&gst::Caps>) -> gst::Caps { unsafe { let data = self.get_type_data(); let parent_class = @@ -341,7 +333,7 @@ impl VideoEncoderImplExt for T { (*parent_class) .getcaps .map(|f| from_glib_full(f(element.to_glib_none().0, filter.to_glib_none().0))) - .unwrap_or(element.proxy_getcaps(None, filter)) + .unwrap_or(element.proxy_getcaps(None, filter).unwrap()) } } @@ -688,7 +680,7 @@ where let imp = instance.get_impl(); let wrap: VideoEncoder = from_glib_borrow(ptr); - gst_panic_to_error!(&wrap, &instance.panicked(), None, { + gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), { VideoEncoderImpl::get_caps( imp, &wrap,