gstreamer_editing_services/auto/
clip_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
6#[cfg(feature = "v1_18")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
8use crate::FrameNumber;
9use crate::{ffi, Asset, MetaContainer, TrackType};
10use glib::{
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    #[doc(alias = "GESClipAsset")]
19    pub struct ClipAsset(Object<ffi::GESClipAsset, ffi::GESClipAssetClass>) @extends Asset, @implements MetaContainer;
20
21    match fn {
22        type_ => || ffi::ges_clip_asset_get_type(),
23    }
24}
25
26impl ClipAsset {
27    pub const NONE: Option<&'static ClipAsset> = None;
28}
29
30unsafe impl Send for ClipAsset {}
31unsafe impl Sync for ClipAsset {}
32
33mod sealed {
34    pub trait Sealed {}
35    impl<T: super::IsA<super::ClipAsset>> Sealed for T {}
36}
37
38pub trait ClipAssetExt: IsA<ClipAsset> + sealed::Sealed + 'static {
39    #[cfg(feature = "v1_18")]
40    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
41    #[doc(alias = "ges_clip_asset_get_frame_time")]
42    #[doc(alias = "get_frame_time")]
43    fn frame_time(&self, frame_number: FrameNumber) -> Option<gst::ClockTime> {
44        unsafe {
45            from_glib(ffi::ges_clip_asset_get_frame_time(
46                self.as_ref().to_glib_none().0,
47                frame_number,
48            ))
49        }
50    }
51
52    #[cfg(feature = "v1_18")]
53    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
54    #[doc(alias = "ges_clip_asset_get_natural_framerate")]
55    #[doc(alias = "get_natural_framerate")]
56    fn natural_framerate(&self) -> Option<(i32, i32)> {
57        unsafe {
58            let mut framerate_n = std::mem::MaybeUninit::uninit();
59            let mut framerate_d = std::mem::MaybeUninit::uninit();
60            let ret = from_glib(ffi::ges_clip_asset_get_natural_framerate(
61                self.as_ref().to_glib_none().0,
62                framerate_n.as_mut_ptr(),
63                framerate_d.as_mut_ptr(),
64            ));
65            if ret {
66                Some((framerate_n.assume_init(), framerate_d.assume_init()))
67            } else {
68                None
69            }
70        }
71    }
72
73    #[doc(alias = "ges_clip_asset_get_supported_formats")]
74    #[doc(alias = "get_supported_formats")]
75    #[doc(alias = "supported-formats")]
76    fn supported_formats(&self) -> TrackType {
77        unsafe {
78            from_glib(ffi::ges_clip_asset_get_supported_formats(
79                self.as_ref().to_glib_none().0,
80            ))
81        }
82    }
83
84    #[doc(alias = "ges_clip_asset_set_supported_formats")]
85    #[doc(alias = "supported-formats")]
86    fn set_supported_formats(&self, supportedformats: TrackType) {
87        unsafe {
88            ffi::ges_clip_asset_set_supported_formats(
89                self.as_ref().to_glib_none().0,
90                supportedformats.into_glib(),
91            );
92        }
93    }
94
95    #[doc(alias = "supported-formats")]
96    fn connect_supported_formats_notify<F: Fn(&Self) + Send + Sync + 'static>(
97        &self,
98        f: F,
99    ) -> SignalHandlerId {
100        unsafe extern "C" fn notify_supported_formats_trampoline<
101            P: IsA<ClipAsset>,
102            F: Fn(&P) + Send + Sync + 'static,
103        >(
104            this: *mut ffi::GESClipAsset,
105            _param_spec: glib::ffi::gpointer,
106            f: glib::ffi::gpointer,
107        ) {
108            let f: &F = &*(f as *const F);
109            f(ClipAsset::from_glib_borrow(this).unsafe_cast_ref())
110        }
111        unsafe {
112            let f: Box_<F> = Box_::new(f);
113            connect_raw(
114                self.as_ptr() as *mut _,
115                b"notify::supported-formats\0".as_ptr() as *const _,
116                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
117                    notify_supported_formats_trampoline::<Self, F> as *const (),
118                )),
119                Box_::into_raw(f),
120            )
121        }
122    }
123}
124
125impl<O: IsA<ClipAsset>> ClipAssetExt for O {}