From fa5491e6b3aa22fb18bb8d5cb793994b74ddeeb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 21 Nov 2022 11:38:45 +0200 Subject: [PATCH] Use borrowed miniobject/structure types in more places When the function does not keep around an additional reference of the value this is correct and more flexible for callers. https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/420 Part-of: --- gstreamer-base/src/functions.rs | 8 +-- gstreamer-pbutils/Gir.toml | 15 +++-- gstreamer-pbutils/src/auto/functions.rs | 55 ------------------ gstreamer-pbutils/src/functions.rs | 58 ++++++++++++++++++- gstreamer-play/Gir.toml | 5 ++ gstreamer-play/src/auto/play.rs | 17 ------ gstreamer-play/src/play.rs | 16 +++++ gstreamer-player/Gir.toml | 5 ++ gstreamer-player/src/auto/player.rs | 17 ------ gstreamer-player/src/player.rs | 16 +++++ gstreamer-sdp/src/sdp_media.rs | 7 +-- gstreamer-video/Gir.toml | 14 ++++- gstreamer-video/src/auto/enums.rs | 6 -- gstreamer-video/src/auto/video_orientation.rs | 22 ------- gstreamer-video/src/enums.rs | 48 +++++++++++++++ gstreamer-video/src/lib.rs | 2 + gstreamer/Gir.toml | 20 +++++++ gstreamer/src/auto/element_factory.rs | 41 ------------- gstreamer/src/element_factory.rs | 41 +++++++++++++ tutorials/src/bin/basic-tutorial-6.rs | 2 +- 20 files changed, 239 insertions(+), 176 deletions(-) create mode 100644 gstreamer-video/src/enums.rs diff --git a/gstreamer-base/src/functions.rs b/gstreamer-base/src/functions.rs index ac3d7063f..7f5ddcec9 100644 --- a/gstreamer-base/src/functions.rs +++ b/gstreamer-base/src/functions.rs @@ -59,14 +59,14 @@ pub fn type_find_helper_for_data_with_extension( #[doc(alias = "gst_type_find_helper_for_buffer")] pub fn type_find_helper_for_buffer>( obj: Option<&P>, - buf: &gst::Buffer, + buf: &gst::BufferRef, ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { assert_initialized_main_thread!(); unsafe { let mut prob = mem::MaybeUninit::uninit(); let ret = ffi::gst_type_find_helper_for_buffer( obj.map(|p| p.as_ref()).to_glib_none().0, - buf.to_glib_none().0, + mut_override(buf.as_ptr()), prob.as_mut_ptr(), ); if ret.is_null() { @@ -82,7 +82,7 @@ pub fn type_find_helper_for_buffer>( #[doc(alias = "gst_type_find_helper_for_buffer_with_extension")] pub fn type_find_helper_for_buffer_with_extension>( obj: Option<&P>, - buf: &gst::Buffer, + buf: &gst::BufferRef, extension: Option<&str>, ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { assert_initialized_main_thread!(); @@ -90,7 +90,7 @@ pub fn type_find_helper_for_buffer_with_extension>( let mut prob = mem::MaybeUninit::uninit(); let ret = ffi::gst_type_find_helper_for_buffer_with_extension( obj.map(|p| p.as_ref()).to_glib_none().0, - buf.to_glib_none().0, + mut_override(buf.as_ptr()), extension.to_glib_none().0, prob.as_mut_ptr(), ); diff --git a/gstreamer-pbutils/Gir.toml b/gstreamer-pbutils/Gir.toml index 5e1661e10..bd5383d77 100644 --- a/gstreamer-pbutils/Gir.toml +++ b/gstreamer-pbutils/Gir.toml @@ -146,11 +146,6 @@ status = "generate" [object.function.return] nullable_return_is_error = "Unsupported caps" - [[object.function]] - name = "codec_utils_opus_create_caps_from_header" - [object.function.return] - nullable_return_is_error = "Failed to create caps from Opus headers" - [[object.function]] name = "codec_utils_opus_create_caps" # Manual checks @@ -171,6 +166,16 @@ status = "generate" # Manual checks manual = true + [[object.function]] + name = "codec_utils_opus_create_caps_from_header" + # Use &CapsRef + manual = true + + [[object.function]] + pattern = "(codec_utils_caps_get_mime_codec|pb_utils_get_caps_description_flags|pb_utils_get_file_extension_from_caps)" + # Use &CapsRef + manual = true + # Plugin installer API needs some manual impls [[object.function]] pattern = "install_plugins.*" diff --git a/gstreamer-pbutils/src/auto/functions.rs b/gstreamer-pbutils/src/auto/functions.rs index 19f5b6f32..a1a5f5465 100644 --- a/gstreamer-pbutils/src/auto/functions.rs +++ b/gstreamer-pbutils/src/auto/functions.rs @@ -4,9 +4,6 @@ // DO NOT EDIT use crate::EncodingTarget; -#[cfg(any(feature = "v1_20", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] -use crate::PbUtilsCapsDescriptionFlags; use glib::translate::*; use std::mem; @@ -74,19 +71,6 @@ pub fn codec_utils_caps_from_mime_codec(codecs_field: &str) -> Option } } -#[cfg(any(feature = "v1_20", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] -#[doc(alias = "gst_codec_utils_caps_get_mime_codec")] -pub fn codec_utils_caps_get_mime_codec(caps: &gst::Caps) -> Result { - assert_initialized_main_thread!(); - unsafe { - Option::<_>::from_glib_full(ffi::gst_codec_utils_caps_get_mime_codec( - caps.to_glib_none().0, - )) - .ok_or_else(|| glib::bool_error!("Unsupported caps")) - } -} - #[doc(alias = "gst_codec_utils_h264_get_level")] pub fn codec_utils_h264_get_level(sps: &[u8]) -> Result { assert_initialized_main_thread!(); @@ -200,21 +184,6 @@ pub fn codec_utils_mpeg4video_get_profile( } } -#[doc(alias = "gst_codec_utils_opus_create_caps_from_header")] -pub fn codec_utils_opus_create_caps_from_header( - header: &gst::Buffer, - comments: Option<&gst::Buffer>, -) -> Result { - assert_initialized_main_thread!(); - unsafe { - Option::<_>::from_glib_full(ffi::gst_codec_utils_opus_create_caps_from_header( - header.to_glib_none().0, - comments.to_glib_none().0, - )) - .ok_or_else(|| glib::bool_error!("Failed to create caps from Opus headers")) - } -} - #[doc(alias = "gst_encoding_list_all_targets")] pub fn encoding_list_all_targets(categoryname: Option<&str>) -> Vec { assert_initialized_main_thread!(); @@ -231,18 +200,6 @@ pub fn encoding_list_available_categories() -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_encoding_list_available_categories()) } } -#[cfg(any(feature = "v1_20", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] -#[doc(alias = "gst_pb_utils_get_caps_description_flags")] -pub fn pb_utils_get_caps_description_flags(caps: &gst::Caps) -> PbUtilsCapsDescriptionFlags { - assert_initialized_main_thread!(); - unsafe { - from_glib(ffi::gst_pb_utils_get_caps_description_flags( - caps.to_glib_none().0, - )) - } -} - #[doc(alias = "gst_pb_utils_get_element_description")] pub fn pb_utils_get_element_description(factory_name: &str) -> glib::GString { assert_initialized_main_thread!(); @@ -253,18 +210,6 @@ pub fn pb_utils_get_element_description(factory_name: &str) -> glib::GString { } } -#[cfg(any(feature = "v1_20", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] -#[doc(alias = "gst_pb_utils_get_file_extension_from_caps")] -pub fn pb_utils_get_file_extension_from_caps(caps: &gst::Caps) -> Option { - assert_initialized_main_thread!(); - unsafe { - from_glib_full(ffi::gst_pb_utils_get_file_extension_from_caps( - caps.to_glib_none().0, - )) - } -} - #[doc(alias = "gst_pb_utils_get_sink_description")] pub fn pb_utils_get_sink_description(protocol: &str) -> glib::GString { assert_initialized_main_thread!(); diff --git a/gstreamer-pbutils/src/functions.rs b/gstreamer-pbutils/src/functions.rs index 83dc53f60..6f8f20246 100644 --- a/gstreamer-pbutils/src/functions.rs +++ b/gstreamer-pbutils/src/functions.rs @@ -253,6 +253,23 @@ pub fn codec_utils_opus_create_caps( } } +#[doc(alias = "gst_codec_utils_opus_create_caps_from_header")] +pub fn codec_utils_opus_create_caps_from_header( + header: &gst::BufferRef, + comments: Option<&gst::BufferRef>, +) -> Result { + assert_initialized_main_thread!(); + unsafe { + Option::<_>::from_glib_full(ffi::gst_codec_utils_opus_create_caps_from_header( + mut_override(header.as_ptr()), + comments + .map(|b| mut_override(b.as_ptr())) + .unwrap_or(ptr::null_mut()), + )) + .ok_or_else(|| glib::bool_error!("Failed to create caps from Opus headers")) + } +} + #[doc(alias = "gst_codec_utils_opus_create_header")] #[allow(clippy::too_many_arguments)] pub fn codec_utils_opus_create_header( @@ -297,7 +314,7 @@ pub fn codec_utils_opus_create_header( #[doc(alias = "gst_codec_utils_opus_parse_caps")] pub fn codec_utils_opus_parse_caps( - caps: &gst::Caps, + caps: &gst::CapsRef, channel_mapping: Option<&mut [u8; 256]>, ) -> Result<(u32, u8, u8, u8, u8), glib::BoolError> { assert_initialized_main_thread!(); @@ -340,7 +357,7 @@ pub fn codec_utils_opus_parse_caps( #[doc(alias = "gst_codec_utils_opus_parse_header")] #[allow(clippy::type_complexity)] pub fn codec_utils_opus_parse_header( - header: &gst::Buffer, + header: &gst::BufferRef, channel_mapping: Option<&mut [u8; 256]>, ) -> Result<(u32, u8, u8, u8, u8, u16, i16), glib::BoolError> { assert_initialized_main_thread!(); @@ -385,3 +402,40 @@ pub fn codec_utils_opus_parse_header( } } } + +#[cfg(any(feature = "v1_20", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] +#[doc(alias = "gst_codec_utils_caps_get_mime_codec")] +pub fn codec_utils_caps_get_mime_codec( + caps: &gst::CapsRef, +) -> Result { + assert_initialized_main_thread!(); + unsafe { + Option::<_>::from_glib_full(ffi::gst_codec_utils_caps_get_mime_codec(mut_override( + caps.as_ptr(), + ))) + .ok_or_else(|| glib::bool_error!("Unsupported caps")) + } +} + +#[cfg(any(feature = "v1_20", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] +#[doc(alias = "gst_pb_utils_get_caps_description_flags")] +pub fn pb_utils_get_caps_description_flags( + caps: &gst::CapsRef, +) -> crate::PbUtilsCapsDescriptionFlags { + assert_initialized_main_thread!(); + unsafe { from_glib(ffi::gst_pb_utils_get_caps_description_flags(caps.as_ptr())) } +} + +#[cfg(any(feature = "v1_20", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] +#[doc(alias = "gst_pb_utils_get_file_extension_from_caps")] +pub fn pb_utils_get_file_extension_from_caps(caps: &gst::CapsRef) -> Option { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_pb_utils_get_file_extension_from_caps( + caps.as_ptr(), + )) + } +} diff --git a/gstreamer-play/Gir.toml b/gstreamer-play/Gir.toml index 8ce97ea73..d24b50ad9 100644 --- a/gstreamer-play/Gir.toml +++ b/gstreamer-play/Gir.toml @@ -123,6 +123,11 @@ final_type = true [object.function.return] bool_return_is_error = "Failed to set visualization" + [[object.function]] + name = "get_video_snapshot" + # &StructureRef + manual = true + [[object]] name = "GstPlay.PlayAudioInfo" status = "generate" diff --git a/gstreamer-play/src/auto/play.rs b/gstreamer-play/src/auto/play.rs index 6e0b5c36d..168af1be4 100644 --- a/gstreamer-play/src/auto/play.rs +++ b/gstreamer-play/src/auto/play.rs @@ -6,7 +6,6 @@ use crate::PlayAudioInfo; use crate::PlayColorBalanceType; use crate::PlayMediaInfo; -use crate::PlaySnapshotFormat; use crate::PlaySubtitleInfo; use crate::PlayVideoInfo; use crate::PlayVideoRenderer; @@ -157,22 +156,6 @@ impl Play { unsafe { from_glib_full(ffi::gst_play_get_uri(self.to_glib_none().0)) } } - #[doc(alias = "gst_play_get_video_snapshot")] - #[doc(alias = "get_video_snapshot")] - pub fn video_snapshot( - &self, - format: PlaySnapshotFormat, - config: Option<&gst::Structure>, - ) -> Option { - unsafe { - from_glib_full(ffi::gst_play_get_video_snapshot( - self.to_glib_none().0, - format.into_glib(), - config.to_glib_none().0, - )) - } - } - #[doc(alias = "gst_play_get_volume")] #[doc(alias = "get_volume")] pub fn volume(&self) -> f64 { diff --git a/gstreamer-play/src/play.rs b/gstreamer-play/src/play.rs index b2272337b..4aa57c258 100644 --- a/gstreamer-play/src/play.rs +++ b/gstreamer-play/src/play.rs @@ -19,4 +19,20 @@ impl Play { ) } } + + #[doc(alias = "gst_play_get_video_snapshot")] + #[doc(alias = "get_video_snapshot")] + pub fn video_snapshot( + &self, + format: crate::PlaySnapshotFormat, + config: Option<&gst::StructureRef>, + ) -> Option { + unsafe { + from_glib_full(ffi::gst_play_get_video_snapshot( + self.to_glib_none().0, + format.into_glib(), + mut_override(config.map(|c| c.as_ptr()).unwrap_or(std::ptr::null())), + )) + } + } } diff --git a/gstreamer-player/Gir.toml b/gstreamer-player/Gir.toml index 3bca8ebf5..04167472f 100644 --- a/gstreamer-player/Gir.toml +++ b/gstreamer-player/Gir.toml @@ -176,6 +176,11 @@ final_type = true name = "subtitle-video-offset" version = "1.16" + [[object.function]] + name = "get_video_snapshot" + # Use &StructureRef + manual = true + [[object]] name = "GstPlayer.PlayerAudioInfo" status = "generate" diff --git a/gstreamer-player/src/auto/player.rs b/gstreamer-player/src/auto/player.rs index 9f6c9188f..3300fd02c 100644 --- a/gstreamer-player/src/auto/player.rs +++ b/gstreamer-player/src/auto/player.rs @@ -7,7 +7,6 @@ use crate::PlayerAudioInfo; use crate::PlayerColorBalanceType; use crate::PlayerMediaInfo; use crate::PlayerSignalDispatcher; -use crate::PlayerSnapshotFormat; use crate::PlayerState; use crate::PlayerSubtitleInfo; use crate::PlayerVideoInfo; @@ -167,22 +166,6 @@ impl Player { unsafe { from_glib_full(ffi::gst_player_get_uri(self.to_glib_none().0)) } } - #[doc(alias = "gst_player_get_video_snapshot")] - #[doc(alias = "get_video_snapshot")] - pub fn video_snapshot( - &self, - format: PlayerSnapshotFormat, - config: Option<&gst::Structure>, - ) -> Option { - unsafe { - from_glib_full(ffi::gst_player_get_video_snapshot( - self.to_glib_none().0, - format.into_glib(), - config.to_glib_none().0, - )) - } - } - #[doc(alias = "gst_player_get_volume")] #[doc(alias = "get_volume")] pub fn volume(&self) -> f64 { diff --git a/gstreamer-player/src/player.rs b/gstreamer-player/src/player.rs index 1fdba1094..3872ad663 100644 --- a/gstreamer-player/src/player.rs +++ b/gstreamer-player/src/player.rs @@ -78,6 +78,22 @@ impl Player { ) } } + + #[doc(alias = "gst_player_get_video_snapshot")] + #[doc(alias = "get_video_snapshot")] + pub fn video_snapshot( + &self, + format: crate::PlayerSnapshotFormat, + config: Option<&gst::StructureRef>, + ) -> Option { + unsafe { + from_glib_full(ffi::gst_player_get_video_snapshot( + self.to_glib_none().0, + format.into_glib(), + mut_override(config.map(|c| c.as_ptr()).unwrap_or(std::ptr::null())), + )) + } + } } unsafe extern "C" fn duration_changed_trampoline< diff --git a/gstreamer-sdp/src/sdp_media.rs b/gstreamer-sdp/src/sdp_media.rs index 203feedbb..d9159d033 100644 --- a/gstreamer-sdp/src/sdp_media.rs +++ b/gstreamer-sdp/src/sdp_media.rs @@ -610,15 +610,12 @@ impl SDPMediaRef { #[doc(alias = "gst_sdp_media_set_media_from_caps")] pub fn set_media_from_caps( - caps: &gst::Caps, + caps: &gst::CapsRef, media: &mut SDPMedia, ) -> Result<(), glib::BoolError> { assert_initialized_main_thread!(); let result = unsafe { - ffi::gst_sdp_media_set_media_from_caps( - caps.to_glib_none().0, - media.to_glib_none_mut().0, - ) + ffi::gst_sdp_media_set_media_from_caps(caps.as_ptr(), media.to_glib_none_mut().0) }; match result { ffi::GST_SDP_OK => Ok(()), diff --git a/gstreamer-video/Gir.toml b/gstreamer-video/Gir.toml index eb6725243..e24be7d08 100644 --- a/gstreamer-video/Gir.toml +++ b/gstreamer-video/Gir.toml @@ -29,7 +29,6 @@ generate = [ "GstVideo.VideoAggregatorParallelConvertPad", "GstVideo.VideoAlphaMode", "GstVideo.VideoBufferPool", - "GstVideo.VideoCaptionType", "GstVideo.VideoChromaMode", "GstVideo.VideoDecoderRequestSyncPointFlags", "GstVideo.VideoDitherMethod", @@ -364,6 +363,14 @@ status = "generate" name = "last" ignore = true +[[object]] +name = "GstVideo.VideoCaptionType" +status = "generate" + [[object.function]] + name = "from_caps" + # Use &CapsRef + manual = true + [[object]] name = "GstVideo.VideoChromaSite" status = "generate" @@ -717,6 +724,11 @@ status = "generate" [object.function.return] bool_return_is_error = "Failed to set vertical flipping" + [[object.function]] + name = "from_tag" + # Use &TagListRef and move to the enum + manual = true + [[object]] name = "GstVideo.VideoOverlay" status = "generate" diff --git a/gstreamer-video/src/auto/enums.rs b/gstreamer-video/src/auto/enums.rs index 37c6ee010..23bd84023 100644 --- a/gstreamer-video/src/auto/enums.rs +++ b/gstreamer-video/src/auto/enums.rs @@ -803,12 +803,6 @@ pub enum VideoCaptionType { #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] impl VideoCaptionType { - #[doc(alias = "gst_video_caption_type_from_caps")] - pub fn from_caps(caps: &gst::Caps) -> VideoCaptionType { - assert_initialized_main_thread!(); - unsafe { from_glib(ffi::gst_video_caption_type_from_caps(caps.to_glib_none().0)) } - } - #[doc(alias = "gst_video_caption_type_to_caps")] pub fn to_caps(self) -> gst::Caps { assert_initialized_main_thread!(); diff --git a/gstreamer-video/src/auto/video_orientation.rs b/gstreamer-video/src/auto/video_orientation.rs index 66c84b579..917192bd7 100644 --- a/gstreamer-video/src/auto/video_orientation.rs +++ b/gstreamer-video/src/auto/video_orientation.rs @@ -3,9 +3,6 @@ // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT -#[cfg(any(feature = "v1_20", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] -use crate::VideoOrientationMethod; use glib::object::IsA; use glib::translate::*; use std::mem; @@ -21,25 +18,6 @@ glib::wrapper! { impl VideoOrientation { pub const NONE: Option<&'static VideoOrientation> = None; - - #[cfg(any(feature = "v1_20", feature = "dox"))] - #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] - #[doc(alias = "gst_video_orientation_from_tag")] - pub fn from_tag(taglist: &gst::TagList) -> Option { - assert_initialized_main_thread!(); - unsafe { - let mut method = mem::MaybeUninit::uninit(); - let ret = from_glib(ffi::gst_video_orientation_from_tag( - taglist.to_glib_none().0, - method.as_mut_ptr(), - )); - if ret { - Some(from_glib(method.assume_init())) - } else { - None - } - } - } } unsafe impl Send for VideoOrientation {} diff --git a/gstreamer-video/src/enums.rs b/gstreamer-video/src/enums.rs new file mode 100644 index 000000000..6e64fef48 --- /dev/null +++ b/gstreamer-video/src/enums.rs @@ -0,0 +1,48 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +#[cfg(any(feature = "v1_16", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] +use glib::translate::*; + +#[cfg(any(feature = "v1_16", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] +use crate::VideoCaptionType; +#[cfg(any(feature = "v1_20", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] +use crate::VideoOrientationMethod; + +#[cfg(any(feature = "v1_16", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] +impl VideoCaptionType { + #[doc(alias = "gst_video_caption_type_from_caps")] + pub fn from_caps(caps: &gst::CapsRef) -> VideoCaptionType { + assert_initialized_main_thread!(); + unsafe { from_glib(ffi::gst_video_caption_type_from_caps(caps.as_ptr())) } + } +} + +#[cfg(any(feature = "v1_20", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] +impl VideoOrientationMethod { + #[cfg(any(feature = "v1_20", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] + #[doc(alias = "gst_video_orientation_from_tag")] + pub fn from_tag(taglist: &gst::TagListRef) -> Option { + assert_initialized_main_thread!(); + + unsafe { + use std::mem; + + let mut method = mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gst_video_orientation_from_tag( + mut_override(taglist.as_ptr()), + method.as_mut_ptr(), + )); + if ret { + Some(from_glib(method.assume_init())) + } else { + None + } + } + } +} diff --git a/gstreamer-video/src/lib.rs b/gstreamer-video/src/lib.rs index dd9492cb9..53dbcaeef 100644 --- a/gstreamer-video/src/lib.rs +++ b/gstreamer-video/src/lib.rs @@ -36,6 +36,8 @@ macro_rules! skip_assert_initialized { mod auto; pub use crate::auto::*; +mod enums; + #[cfg(feature = "serde")] mod flag_serde; diff --git a/gstreamer/Gir.toml b/gstreamer/Gir.toml index eb46140d0..5dde1e0f0 100644 --- a/gstreamer/Gir.toml +++ b/gstreamer/Gir.toml @@ -1313,6 +1313,26 @@ final_type = true # Use str as return type manual = true + [[object.function]] + name = "can_sink_all_caps" + # Use &CapsRef + manual = true + + [[object.function]] + name = "can_src_all_caps" + # Use &CapsRef + manual = true + + [[object.function]] + name = "can_sink_any_caps" + # Use &CapsRef + manual = true + + [[object.function]] + name = "can_src_any_caps" + # Use &CapsRef + manual = true + [[object]] name = "Gst.ElementFactoryListType" status = "manual" diff --git a/gstreamer/src/auto/element_factory.rs b/gstreamer/src/auto/element_factory.rs index e8878291e..ad1725748 100644 --- a/gstreamer/src/auto/element_factory.rs +++ b/gstreamer/src/auto/element_factory.rs @@ -3,7 +3,6 @@ // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT -use crate::Caps; use crate::Object; use crate::PluginFeature; use crate::URIType; @@ -19,46 +18,6 @@ glib::wrapper! { } impl ElementFactory { - #[doc(alias = "gst_element_factory_can_sink_all_caps")] - pub fn can_sink_all_caps(&self, caps: &Caps) -> bool { - unsafe { - from_glib(ffi::gst_element_factory_can_sink_all_caps( - self.to_glib_none().0, - caps.to_glib_none().0, - )) - } - } - - #[doc(alias = "gst_element_factory_can_sink_any_caps")] - pub fn can_sink_any_caps(&self, caps: &Caps) -> bool { - unsafe { - from_glib(ffi::gst_element_factory_can_sink_any_caps( - self.to_glib_none().0, - caps.to_glib_none().0, - )) - } - } - - #[doc(alias = "gst_element_factory_can_src_all_caps")] - pub fn can_src_all_caps(&self, caps: &Caps) -> bool { - unsafe { - from_glib(ffi::gst_element_factory_can_src_all_caps( - self.to_glib_none().0, - caps.to_glib_none().0, - )) - } - } - - #[doc(alias = "gst_element_factory_can_src_any_caps")] - pub fn can_src_any_caps(&self, caps: &Caps) -> bool { - unsafe { - from_glib(ffi::gst_element_factory_can_src_any_caps( - self.to_glib_none().0, - caps.to_glib_none().0, - )) - } - } - #[doc(alias = "gst_element_factory_get_element_type")] #[doc(alias = "get_element_type")] pub fn element_type(&self) -> glib::types::Type { diff --git a/gstreamer/src/element_factory.rs b/gstreamer/src/element_factory.rs index 84ee8364d..f34a15417 100644 --- a/gstreamer/src/element_factory.rs +++ b/gstreamer/src/element_factory.rs @@ -8,6 +8,7 @@ use crate::ELEMENT_METADATA_KLASS; use crate::ELEMENT_METADATA_LONGNAME; use std::ffi::CStr; +use crate::CapsRef; use crate::Element; use crate::ElementFactory; use crate::Rank; @@ -180,6 +181,46 @@ impl ElementFactory { pub fn icon_name(&self) -> Option<&str> { self.metadata(&ELEMENT_METADATA_ICON_NAME) } + + #[doc(alias = "gst_element_factory_can_sink_all_caps")] + pub fn can_sink_all_caps(&self, caps: &CapsRef) -> bool { + unsafe { + from_glib(ffi::gst_element_factory_can_sink_all_caps( + self.to_glib_none().0, + caps.as_ptr(), + )) + } + } + + #[doc(alias = "gst_element_factory_can_sink_any_caps")] + pub fn can_sink_any_caps(&self, caps: &CapsRef) -> bool { + unsafe { + from_glib(ffi::gst_element_factory_can_sink_any_caps( + self.to_glib_none().0, + caps.as_ptr(), + )) + } + } + + #[doc(alias = "gst_element_factory_can_src_all_caps")] + pub fn can_src_all_caps(&self, caps: &CapsRef) -> bool { + unsafe { + from_glib(ffi::gst_element_factory_can_src_all_caps( + self.to_glib_none().0, + caps.as_ptr(), + )) + } + } + + #[doc(alias = "gst_element_factory_can_src_any_caps")] + pub fn can_src_any_caps(&self, caps: &CapsRef) -> bool { + unsafe { + from_glib(ffi::gst_element_factory_can_src_any_caps( + self.to_glib_none().0, + caps.as_ptr(), + )) + } + } } // rustdoc-stripper-ignore-next diff --git a/tutorials/src/bin/basic-tutorial-6.rs b/tutorials/src/bin/basic-tutorial-6.rs index 667d9309c..2d6b7e46f 100644 --- a/tutorials/src/bin/basic-tutorial-6.rs +++ b/tutorials/src/bin/basic-tutorial-6.rs @@ -3,7 +3,7 @@ use gst::prelude::*; #[path = "../tutorials-common.rs"] mod tutorials_common; -fn print_caps(caps: &gst::Caps, prefix: &str) { +fn print_caps(caps: &gst::CapsRef, prefix: &str) { if caps.is_any() { println!("{}ANY", prefix); return;