gstreamer_editing_services/auto/
track_element_asset.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{ffi, Asset, MetaContainer, TrackType};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
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            let f: &F = &*(f as *const F);
88            f(TrackElementAsset::from_glib_borrow(this).unsafe_cast_ref())
89        }
90        unsafe {
91            let f: Box_<F> = Box_::new(f);
92            connect_raw(
93                self.as_ptr() as *mut _,
94                c"notify::track-type".as_ptr() as *const _,
95                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
96                    notify_track_type_trampoline::<Self, F> as *const (),
97                )),
98                Box_::into_raw(f),
99            )
100        }
101    }
102}
103
104impl<O: IsA<TrackElementAsset>> TrackElementAssetExt for O {}