gstreamer_editing_services/auto/
track_element_asset.rs1use crate::{Asset, MetaContainer, TrackType, ffi};
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GESTrackElementAsset")]
16 pub struct TrackElementAsset(Object<ffi::GESTrackElementAsset, ffi::GESTrackElementAssetClass>) @extends Asset, @implements MetaContainer;
17
18 match fn {
19 type_ => || ffi::ges_track_element_asset_get_type(),
20 }
21}
22
23impl TrackElementAsset {
24 pub const NONE: Option<&'static TrackElementAsset> = None;
25}
26
27unsafe impl Send for TrackElementAsset {}
28unsafe impl Sync for TrackElementAsset {}
29
30pub trait TrackElementAssetExt: IsA<TrackElementAsset> + 'static {
31 #[cfg(feature = "v1_18")]
32 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
33 #[doc(alias = "ges_track_element_asset_get_natural_framerate")]
34 #[doc(alias = "get_natural_framerate")]
35 fn natural_framerate(&self) -> Option<(i32, i32)> {
36 unsafe {
37 let mut framerate_n = std::mem::MaybeUninit::uninit();
38 let mut framerate_d = std::mem::MaybeUninit::uninit();
39 let ret = from_glib(ffi::ges_track_element_asset_get_natural_framerate(
40 self.as_ref().to_glib_none().0,
41 framerate_n.as_mut_ptr(),
42 framerate_d.as_mut_ptr(),
43 ));
44 if ret {
45 Some((framerate_n.assume_init(), framerate_d.assume_init()))
46 } else {
47 None
48 }
49 }
50 }
51
52 #[doc(alias = "ges_track_element_asset_get_track_type")]
53 #[doc(alias = "get_track_type")]
54 #[doc(alias = "track-type")]
55 fn track_type(&self) -> TrackType {
56 unsafe {
57 from_glib(ffi::ges_track_element_asset_get_track_type(
58 self.as_ref().to_glib_none().0,
59 ))
60 }
61 }
62
63 #[doc(alias = "ges_track_element_asset_set_track_type")]
64 #[doc(alias = "track-type")]
65 fn set_track_type(&self, type_: TrackType) {
66 unsafe {
67 ffi::ges_track_element_asset_set_track_type(
68 self.as_ref().to_glib_none().0,
69 type_.into_glib(),
70 );
71 }
72 }
73
74 #[doc(alias = "track-type")]
75 fn connect_track_type_notify<F: Fn(&Self) + Send + Sync + 'static>(
76 &self,
77 f: F,
78 ) -> SignalHandlerId {
79 unsafe extern "C" fn notify_track_type_trampoline<
80 P: IsA<TrackElementAsset>,
81 F: Fn(&P) + Send + Sync + 'static,
82 >(
83 this: *mut ffi::GESTrackElementAsset,
84 _param_spec: glib::ffi::gpointer,
85 f: glib::ffi::gpointer,
86 ) {
87 unsafe {
88 let f: &F = &*(f as *const F);
89 f(TrackElementAsset::from_glib_borrow(this).unsafe_cast_ref())
90 }
91 }
92 unsafe {
93 let f: Box_<F> = Box_::new(f);
94 connect_raw(
95 self.as_ptr() as *mut _,
96 c"notify::track-type".as_ptr(),
97 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
98 notify_track_type_trampoline::<Self, F> as *const (),
99 )),
100 Box_::into_raw(f),
101 )
102 }
103 }
104}
105
106impl<O: IsA<TrackElementAsset>> TrackElementAssetExt for O {}