gstreamer_editing_services/auto/
clip_asset.rs1#[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
33pub trait ClipAssetExt: IsA<ClipAsset> + 'static {
34 #[cfg(feature = "v1_18")]
35 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
36 #[doc(alias = "ges_clip_asset_get_frame_time")]
37 #[doc(alias = "get_frame_time")]
38 fn frame_time(&self, frame_number: FrameNumber) -> Option<gst::ClockTime> {
39 unsafe {
40 from_glib(ffi::ges_clip_asset_get_frame_time(
41 self.as_ref().to_glib_none().0,
42 frame_number,
43 ))
44 }
45 }
46
47 #[cfg(feature = "v1_18")]
48 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
49 #[doc(alias = "ges_clip_asset_get_natural_framerate")]
50 #[doc(alias = "get_natural_framerate")]
51 fn natural_framerate(&self) -> Option<(i32, i32)> {
52 unsafe {
53 let mut framerate_n = std::mem::MaybeUninit::uninit();
54 let mut framerate_d = std::mem::MaybeUninit::uninit();
55 let ret = from_glib(ffi::ges_clip_asset_get_natural_framerate(
56 self.as_ref().to_glib_none().0,
57 framerate_n.as_mut_ptr(),
58 framerate_d.as_mut_ptr(),
59 ));
60 if ret {
61 Some((framerate_n.assume_init(), framerate_d.assume_init()))
62 } else {
63 None
64 }
65 }
66 }
67
68 #[doc(alias = "ges_clip_asset_get_supported_formats")]
69 #[doc(alias = "get_supported_formats")]
70 #[doc(alias = "supported-formats")]
71 fn supported_formats(&self) -> TrackType {
72 unsafe {
73 from_glib(ffi::ges_clip_asset_get_supported_formats(
74 self.as_ref().to_glib_none().0,
75 ))
76 }
77 }
78
79 #[doc(alias = "ges_clip_asset_set_supported_formats")]
80 #[doc(alias = "supported-formats")]
81 fn set_supported_formats(&self, supportedformats: TrackType) {
82 unsafe {
83 ffi::ges_clip_asset_set_supported_formats(
84 self.as_ref().to_glib_none().0,
85 supportedformats.into_glib(),
86 );
87 }
88 }
89
90 #[doc(alias = "supported-formats")]
91 fn connect_supported_formats_notify<F: Fn(&Self) + Send + Sync + 'static>(
92 &self,
93 f: F,
94 ) -> SignalHandlerId {
95 unsafe extern "C" fn notify_supported_formats_trampoline<
96 P: IsA<ClipAsset>,
97 F: Fn(&P) + Send + Sync + 'static,
98 >(
99 this: *mut ffi::GESClipAsset,
100 _param_spec: glib::ffi::gpointer,
101 f: glib::ffi::gpointer,
102 ) {
103 let f: &F = &*(f as *const F);
104 f(ClipAsset::from_glib_borrow(this).unsafe_cast_ref())
105 }
106 unsafe {
107 let f: Box_<F> = Box_::new(f);
108 connect_raw(
109 self.as_ptr() as *mut _,
110 c"notify::supported-formats".as_ptr() as *const _,
111 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
112 notify_supported_formats_trampoline::<Self, F> as *const (),
113 )),
114 Box_::into_raw(f),
115 )
116 }
117 }
118}
119
120impl<O: IsA<ClipAsset>> ClipAssetExt for O {}