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: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1152>
This commit is contained in:
Sebastian Dröge 2022-11-21 11:38:45 +02:00
parent 5a0152b469
commit fa5491e6b3
20 changed files with 239 additions and 176 deletions

View file

@ -59,14 +59,14 @@ pub fn type_find_helper_for_data_with_extension(
#[doc(alias = "gst_type_find_helper_for_buffer")] #[doc(alias = "gst_type_find_helper_for_buffer")]
pub fn type_find_helper_for_buffer<P: IsA<gst::Object>>( pub fn type_find_helper_for_buffer<P: IsA<gst::Object>>(
obj: Option<&P>, obj: Option<&P>,
buf: &gst::Buffer, buf: &gst::BufferRef,
) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut prob = mem::MaybeUninit::uninit(); let mut prob = mem::MaybeUninit::uninit();
let ret = ffi::gst_type_find_helper_for_buffer( let ret = ffi::gst_type_find_helper_for_buffer(
obj.map(|p| p.as_ref()).to_glib_none().0, obj.map(|p| p.as_ref()).to_glib_none().0,
buf.to_glib_none().0, mut_override(buf.as_ptr()),
prob.as_mut_ptr(), prob.as_mut_ptr(),
); );
if ret.is_null() { if ret.is_null() {
@ -82,7 +82,7 @@ pub fn type_find_helper_for_buffer<P: IsA<gst::Object>>(
#[doc(alias = "gst_type_find_helper_for_buffer_with_extension")] #[doc(alias = "gst_type_find_helper_for_buffer_with_extension")]
pub fn type_find_helper_for_buffer_with_extension<P: IsA<gst::Object>>( pub fn type_find_helper_for_buffer_with_extension<P: IsA<gst::Object>>(
obj: Option<&P>, obj: Option<&P>,
buf: &gst::Buffer, buf: &gst::BufferRef,
extension: Option<&str>, extension: Option<&str>,
) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
@ -90,7 +90,7 @@ pub fn type_find_helper_for_buffer_with_extension<P: IsA<gst::Object>>(
let mut prob = mem::MaybeUninit::uninit(); let mut prob = mem::MaybeUninit::uninit();
let ret = ffi::gst_type_find_helper_for_buffer_with_extension( let ret = ffi::gst_type_find_helper_for_buffer_with_extension(
obj.map(|p| p.as_ref()).to_glib_none().0, 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, extension.to_glib_none().0,
prob.as_mut_ptr(), prob.as_mut_ptr(),
); );

View file

@ -146,11 +146,6 @@ status = "generate"
[object.function.return] [object.function.return]
nullable_return_is_error = "Unsupported caps" 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]] [[object.function]]
name = "codec_utils_opus_create_caps" name = "codec_utils_opus_create_caps"
# Manual checks # Manual checks
@ -171,6 +166,16 @@ status = "generate"
# Manual checks # Manual checks
manual = true 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 # Plugin installer API needs some manual impls
[[object.function]] [[object.function]]
pattern = "install_plugins.*" pattern = "install_plugins.*"

View file

@ -4,9 +4,6 @@
// DO NOT EDIT // DO NOT EDIT
use crate::EncodingTarget; 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 glib::translate::*;
use std::mem; use std::mem;
@ -74,19 +71,6 @@ pub fn codec_utils_caps_from_mime_codec(codecs_field: &str) -> Option<gst::Caps>
} }
} }
#[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<glib::GString, glib::BoolError> {
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")] #[doc(alias = "gst_codec_utils_h264_get_level")]
pub fn codec_utils_h264_get_level(sps: &[u8]) -> Result<glib::GString, glib::BoolError> { pub fn codec_utils_h264_get_level(sps: &[u8]) -> Result<glib::GString, glib::BoolError> {
assert_initialized_main_thread!(); 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<gst::Caps, glib::BoolError> {
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")] #[doc(alias = "gst_encoding_list_all_targets")]
pub fn encoding_list_all_targets(categoryname: Option<&str>) -> Vec<EncodingTarget> { pub fn encoding_list_all_targets(categoryname: Option<&str>) -> Vec<EncodingTarget> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
@ -231,18 +200,6 @@ pub fn encoding_list_available_categories() -> Vec<glib::GString> {
unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_encoding_list_available_categories()) } 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")] #[doc(alias = "gst_pb_utils_get_element_description")]
pub fn pb_utils_get_element_description(factory_name: &str) -> glib::GString { pub fn pb_utils_get_element_description(factory_name: &str) -> glib::GString {
assert_initialized_main_thread!(); 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<glib::GString> {
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")] #[doc(alias = "gst_pb_utils_get_sink_description")]
pub fn pb_utils_get_sink_description(protocol: &str) -> glib::GString { pub fn pb_utils_get_sink_description(protocol: &str) -> glib::GString {
assert_initialized_main_thread!(); assert_initialized_main_thread!();

View file

@ -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<gst::Caps, glib::BoolError> {
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")] #[doc(alias = "gst_codec_utils_opus_create_header")]
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub fn codec_utils_opus_create_header( 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")] #[doc(alias = "gst_codec_utils_opus_parse_caps")]
pub fn codec_utils_opus_parse_caps( pub fn codec_utils_opus_parse_caps(
caps: &gst::Caps, caps: &gst::CapsRef,
channel_mapping: Option<&mut [u8; 256]>, channel_mapping: Option<&mut [u8; 256]>,
) -> Result<(u32, u8, u8, u8, u8), glib::BoolError> { ) -> Result<(u32, u8, u8, u8, u8), glib::BoolError> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
@ -340,7 +357,7 @@ pub fn codec_utils_opus_parse_caps(
#[doc(alias = "gst_codec_utils_opus_parse_header")] #[doc(alias = "gst_codec_utils_opus_parse_header")]
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
pub fn codec_utils_opus_parse_header( pub fn codec_utils_opus_parse_header(
header: &gst::Buffer, header: &gst::BufferRef,
channel_mapping: Option<&mut [u8; 256]>, channel_mapping: Option<&mut [u8; 256]>,
) -> Result<(u32, u8, u8, u8, u8, u16, i16), glib::BoolError> { ) -> Result<(u32, u8, u8, u8, u8, u16, i16), glib::BoolError> {
assert_initialized_main_thread!(); 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<glib::GString, glib::BoolError> {
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<glib::GString> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_pb_utils_get_file_extension_from_caps(
caps.as_ptr(),
))
}
}

View file

@ -123,6 +123,11 @@ final_type = true
[object.function.return] [object.function.return]
bool_return_is_error = "Failed to set visualization" bool_return_is_error = "Failed to set visualization"
[[object.function]]
name = "get_video_snapshot"
# &StructureRef
manual = true
[[object]] [[object]]
name = "GstPlay.PlayAudioInfo" name = "GstPlay.PlayAudioInfo"
status = "generate" status = "generate"

View file

@ -6,7 +6,6 @@
use crate::PlayAudioInfo; use crate::PlayAudioInfo;
use crate::PlayColorBalanceType; use crate::PlayColorBalanceType;
use crate::PlayMediaInfo; use crate::PlayMediaInfo;
use crate::PlaySnapshotFormat;
use crate::PlaySubtitleInfo; use crate::PlaySubtitleInfo;
use crate::PlayVideoInfo; use crate::PlayVideoInfo;
use crate::PlayVideoRenderer; use crate::PlayVideoRenderer;
@ -157,22 +156,6 @@ impl Play {
unsafe { from_glib_full(ffi::gst_play_get_uri(self.to_glib_none().0)) } 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<gst::Sample> {
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 = "gst_play_get_volume")]
#[doc(alias = "get_volume")] #[doc(alias = "get_volume")]
pub fn volume(&self) -> f64 { pub fn volume(&self) -> f64 {

View file

@ -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<gst::Sample> {
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())),
))
}
}
} }

View file

@ -176,6 +176,11 @@ final_type = true
name = "subtitle-video-offset" name = "subtitle-video-offset"
version = "1.16" version = "1.16"
[[object.function]]
name = "get_video_snapshot"
# Use &StructureRef
manual = true
[[object]] [[object]]
name = "GstPlayer.PlayerAudioInfo" name = "GstPlayer.PlayerAudioInfo"
status = "generate" status = "generate"

View file

@ -7,7 +7,6 @@ use crate::PlayerAudioInfo;
use crate::PlayerColorBalanceType; use crate::PlayerColorBalanceType;
use crate::PlayerMediaInfo; use crate::PlayerMediaInfo;
use crate::PlayerSignalDispatcher; use crate::PlayerSignalDispatcher;
use crate::PlayerSnapshotFormat;
use crate::PlayerState; use crate::PlayerState;
use crate::PlayerSubtitleInfo; use crate::PlayerSubtitleInfo;
use crate::PlayerVideoInfo; use crate::PlayerVideoInfo;
@ -167,22 +166,6 @@ impl Player {
unsafe { from_glib_full(ffi::gst_player_get_uri(self.to_glib_none().0)) } 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<gst::Sample> {
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 = "gst_player_get_volume")]
#[doc(alias = "get_volume")] #[doc(alias = "get_volume")]
pub fn volume(&self) -> f64 { pub fn volume(&self) -> f64 {

View file

@ -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<gst::Sample> {
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< unsafe extern "C" fn duration_changed_trampoline<

View file

@ -610,15 +610,12 @@ impl SDPMediaRef {
#[doc(alias = "gst_sdp_media_set_media_from_caps")] #[doc(alias = "gst_sdp_media_set_media_from_caps")]
pub fn set_media_from_caps( pub fn set_media_from_caps(
caps: &gst::Caps, caps: &gst::CapsRef,
media: &mut SDPMedia, media: &mut SDPMedia,
) -> Result<(), glib::BoolError> { ) -> Result<(), glib::BoolError> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
let result = unsafe { let result = unsafe {
ffi::gst_sdp_media_set_media_from_caps( ffi::gst_sdp_media_set_media_from_caps(caps.as_ptr(), media.to_glib_none_mut().0)
caps.to_glib_none().0,
media.to_glib_none_mut().0,
)
}; };
match result { match result {
ffi::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),

View file

@ -29,7 +29,6 @@ generate = [
"GstVideo.VideoAggregatorParallelConvertPad", "GstVideo.VideoAggregatorParallelConvertPad",
"GstVideo.VideoAlphaMode", "GstVideo.VideoAlphaMode",
"GstVideo.VideoBufferPool", "GstVideo.VideoBufferPool",
"GstVideo.VideoCaptionType",
"GstVideo.VideoChromaMode", "GstVideo.VideoChromaMode",
"GstVideo.VideoDecoderRequestSyncPointFlags", "GstVideo.VideoDecoderRequestSyncPointFlags",
"GstVideo.VideoDitherMethod", "GstVideo.VideoDitherMethod",
@ -364,6 +363,14 @@ status = "generate"
name = "last" name = "last"
ignore = true ignore = true
[[object]]
name = "GstVideo.VideoCaptionType"
status = "generate"
[[object.function]]
name = "from_caps"
# Use &CapsRef
manual = true
[[object]] [[object]]
name = "GstVideo.VideoChromaSite" name = "GstVideo.VideoChromaSite"
status = "generate" status = "generate"
@ -717,6 +724,11 @@ status = "generate"
[object.function.return] [object.function.return]
bool_return_is_error = "Failed to set vertical flipping" bool_return_is_error = "Failed to set vertical flipping"
[[object.function]]
name = "from_tag"
# Use &TagListRef and move to the enum
manual = true
[[object]] [[object]]
name = "GstVideo.VideoOverlay" name = "GstVideo.VideoOverlay"
status = "generate" status = "generate"

View file

@ -803,12 +803,6 @@ pub enum VideoCaptionType {
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
impl VideoCaptionType { 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")] #[doc(alias = "gst_video_caption_type_to_caps")]
pub fn to_caps(self) -> gst::Caps { pub fn to_caps(self) -> gst::Caps {
assert_initialized_main_thread!(); assert_initialized_main_thread!();

View file

@ -3,9 +3,6 @@
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT // 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::object::IsA;
use glib::translate::*; use glib::translate::*;
use std::mem; use std::mem;
@ -21,25 +18,6 @@ glib::wrapper! {
impl VideoOrientation { impl VideoOrientation {
pub const NONE: Option<&'static VideoOrientation> = None; 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<VideoOrientationMethod> {
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 {} unsafe impl Send for VideoOrientation {}

View file

@ -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<VideoOrientationMethod> {
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
}
}
}
}

View file

@ -36,6 +36,8 @@ macro_rules! skip_assert_initialized {
mod auto; mod auto;
pub use crate::auto::*; pub use crate::auto::*;
mod enums;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
mod flag_serde; mod flag_serde;

View file

@ -1313,6 +1313,26 @@ final_type = true
# Use str as return type # Use str as return type
manual = true 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]] [[object]]
name = "Gst.ElementFactoryListType" name = "Gst.ElementFactoryListType"
status = "manual" status = "manual"

View file

@ -3,7 +3,6 @@
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT // DO NOT EDIT
use crate::Caps;
use crate::Object; use crate::Object;
use crate::PluginFeature; use crate::PluginFeature;
use crate::URIType; use crate::URIType;
@ -19,46 +18,6 @@ glib::wrapper! {
} }
impl ElementFactory { 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 = "gst_element_factory_get_element_type")]
#[doc(alias = "get_element_type")] #[doc(alias = "get_element_type")]
pub fn element_type(&self) -> glib::types::Type { pub fn element_type(&self) -> glib::types::Type {

View file

@ -8,6 +8,7 @@ use crate::ELEMENT_METADATA_KLASS;
use crate::ELEMENT_METADATA_LONGNAME; use crate::ELEMENT_METADATA_LONGNAME;
use std::ffi::CStr; use std::ffi::CStr;
use crate::CapsRef;
use crate::Element; use crate::Element;
use crate::ElementFactory; use crate::ElementFactory;
use crate::Rank; use crate::Rank;
@ -180,6 +181,46 @@ impl ElementFactory {
pub fn icon_name(&self) -> Option<&str> { pub fn icon_name(&self) -> Option<&str> {
self.metadata(&ELEMENT_METADATA_ICON_NAME) 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 // rustdoc-stripper-ignore-next

View file

@ -3,7 +3,7 @@ use gst::prelude::*;
#[path = "../tutorials-common.rs"] #[path = "../tutorials-common.rs"]
mod tutorials_common; mod tutorials_common;
fn print_caps(caps: &gst::Caps, prefix: &str) { fn print_caps(caps: &gst::CapsRef, prefix: &str) {
if caps.is_any() { if caps.is_any() {
println!("{}ANY", prefix); println!("{}ANY", prefix);
return; return;