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 /// The [`UriClipAsset`][crate::UriClipAsset] is a special [`Asset`][crate::Asset] specilized in [`Clip`][crate::Clip].
19 /// it is mostly used to get information about the [`TrackType`][crate::TrackType]-s the objects extracted
20 /// from it can potentialy create [`TrackElement`][crate::TrackElement] for.
21 ///
22 /// ## Properties
23 ///
24 ///
25 /// #### `supported-formats`
26 /// The formats supported by the asset.
27 ///
28 /// Readable | Writeable | Construct
29 /// <details><summary><h4>Asset</h4></summary>
30 ///
31 ///
32 /// #### `extractable-type`
33 /// The [`Extractable`][crate::Extractable] object type that can be extracted from the asset.
34 ///
35 /// Readable | Writeable | Construct Only
36 ///
37 ///
38 /// #### `id`
39 /// The ID of the asset. This should be unique amongst all assets with
40 /// the same [`extractable-type`][struct@crate::Asset#extractable-type]. Depending on the associated
41 /// [`Extractable`][crate::Extractable] implementation, this id may convey some information
42 /// about the [`glib::Object`][crate::glib::Object] that should be extracted. Note that, as such, the
43 /// ID will have an expected format, and you can not choose this value
44 /// arbitrarily. By default, this will be set to the type name of the
45 /// [`extractable-type`][struct@crate::Asset#extractable-type], but you should check the documentation
46 /// of the extractable type to see whether they differ from the
47 /// default behaviour.
48 ///
49 /// Readable | Writeable | Construct Only
50 ///
51 ///
52 /// #### `proxy`
53 /// The default proxy for this asset, or [`None`] if it has no proxy. A
54 /// proxy will act as a substitute for the original asset when the
55 /// original is requested (see [`Asset::request()`][crate::Asset::request()]).
56 ///
57 /// Setting this property will not usually remove the existing proxy, but
58 /// will replace it as the default (see [`AssetExt::set_proxy()`][crate::prelude::AssetExt::set_proxy()]).
59 ///
60 /// Readable | Writeable
61 ///
62 ///
63 /// #### `proxy-target`
64 /// The asset that this asset is a proxy for, or [`None`] if it is not a
65 /// proxy for another asset.
66 ///
67 /// Note that even if this asset is acting as a proxy for another asset,
68 /// but this asset is not the default [`proxy`][struct@crate::Asset#proxy], then `proxy`-target
69 /// will *still* point to this other asset. So you should check the
70 /// [`proxy`][struct@crate::Asset#proxy] property of `target`-proxy before assuming it is the
71 /// current default proxy for the target.
72 ///
73 /// Note that the [`notify`][struct@crate::glib::Object#notify] for this property is emitted after
74 /// the [`proxy`][struct@crate::Asset#proxy] [`notify`][struct@crate::glib::Object#notify] for the corresponding (if any)
75 /// asset it is now the proxy of/no longer the proxy of.
76 ///
77 /// Readable
78 /// </details>
79 ///
80 /// # Implements
81 ///
82 /// [`ClipAssetExt`][trait@crate::prelude::ClipAssetExt], [`AssetExt`][trait@crate::prelude::AssetExt], [`trait@glib::ObjectExt`], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt]
83 #[doc(alias = "GESClipAsset")]
84 pub struct ClipAsset(Object<ffi::GESClipAsset, ffi::GESClipAssetClass>) @extends Asset, @implements MetaContainer;
85
86 match fn {
87 type_ => || ffi::ges_clip_asset_get_type(),
88 }
89}
90
91impl ClipAsset {
92 pub const NONE: Option<&'static ClipAsset> = None;
93}
94
95unsafe impl Send for ClipAsset {}
96unsafe impl Sync for ClipAsset {}
97
98mod sealed {
99 pub trait Sealed {}
100 impl<T: super::IsA<super::ClipAsset>> Sealed for T {}
101}
102
103/// Trait containing all [`struct@ClipAsset`] methods.
104///
105/// # Implementors
106///
107/// [`ClipAsset`][struct@crate::ClipAsset], [`SourceClipAsset`][struct@crate::SourceClipAsset]
108pub trait ClipAssetExt: IsA<ClipAsset> + sealed::Sealed + 'static {
109 /// Converts the given frame number into a timestamp, using the "natural" frame
110 /// rate of the asset.
111 ///
112 /// You can use this to reference a specific frame in a media file and use this
113 /// as, for example, the `in-point` or `max-duration` of a [`Clip`][crate::Clip].
114 /// ## `frame_number`
115 /// The frame number we want the internal time coordinate timestamp of
116 ///
117 /// # Returns
118 ///
119 /// The timestamp corresponding to `frame_number` in the element source, given
120 /// in internal time coordinates, or `GST_CLOCK_TIME_NONE` if the clip asset does not have a
121 /// natural frame rate.
122 #[cfg(feature = "v1_18")]
123 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
124 #[doc(alias = "ges_clip_asset_get_frame_time")]
125 #[doc(alias = "get_frame_time")]
126 fn frame_time(&self, frame_number: FrameNumber) -> Option<gst::ClockTime> {
127 unsafe {
128 from_glib(ffi::ges_clip_asset_get_frame_time(
129 self.as_ref().to_glib_none().0,
130 frame_number,
131 ))
132 }
133 }
134
135 /// Result: [`true`] if `self` has a natural framerate [`false`] otherwise
136 ///
137 /// # Returns
138 ///
139 ///
140 /// ## `framerate_n`
141 /// The framerate numerator
142 ///
143 /// ## `framerate_d`
144 /// The framerate denominator
145 #[cfg(feature = "v1_18")]
146 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
147 #[doc(alias = "ges_clip_asset_get_natural_framerate")]
148 #[doc(alias = "get_natural_framerate")]
149 fn natural_framerate(&self) -> Option<(i32, i32)> {
150 unsafe {
151 let mut framerate_n = std::mem::MaybeUninit::uninit();
152 let mut framerate_d = std::mem::MaybeUninit::uninit();
153 let ret = from_glib(ffi::ges_clip_asset_get_natural_framerate(
154 self.as_ref().to_glib_none().0,
155 framerate_n.as_mut_ptr(),
156 framerate_d.as_mut_ptr(),
157 ));
158 if ret {
159 Some((framerate_n.assume_init(), framerate_d.assume_init()))
160 } else {
161 None
162 }
163 }
164 }
165
166 /// Gets track types for which objects extracted from `self` can create [`TrackElement`][crate::TrackElement]
167 ///
168 /// # Returns
169 ///
170 /// The track types on which `self` will create TrackElement when added to
171 /// a layer
172 #[doc(alias = "ges_clip_asset_get_supported_formats")]
173 #[doc(alias = "get_supported_formats")]
174 #[doc(alias = "supported-formats")]
175 fn supported_formats(&self) -> TrackType {
176 unsafe {
177 from_glib(ffi::ges_clip_asset_get_supported_formats(
178 self.as_ref().to_glib_none().0,
179 ))
180 }
181 }
182
183 /// Sets track types for which objects extracted from `self` can create [`TrackElement`][crate::TrackElement]
184 /// ## `supportedformats`
185 /// The track types supported by the GESClipAsset
186 #[doc(alias = "ges_clip_asset_set_supported_formats")]
187 #[doc(alias = "supported-formats")]
188 fn set_supported_formats(&self, supportedformats: TrackType) {
189 unsafe {
190 ffi::ges_clip_asset_set_supported_formats(
191 self.as_ref().to_glib_none().0,
192 supportedformats.into_glib(),
193 );
194 }
195 }
196
197 #[doc(alias = "supported-formats")]
198 fn connect_supported_formats_notify<F: Fn(&Self) + Send + Sync + 'static>(
199 &self,
200 f: F,
201 ) -> SignalHandlerId {
202 unsafe extern "C" fn notify_supported_formats_trampoline<
203 P: IsA<ClipAsset>,
204 F: Fn(&P) + Send + Sync + 'static,
205 >(
206 this: *mut ffi::GESClipAsset,
207 _param_spec: glib::ffi::gpointer,
208 f: glib::ffi::gpointer,
209 ) {
210 let f: &F = &*(f as *const F);
211 f(ClipAsset::from_glib_borrow(this).unsafe_cast_ref())
212 }
213 unsafe {
214 let f: Box_<F> = Box_::new(f);
215 connect_raw(
216 self.as_ptr() as *mut _,
217 b"notify::supported-formats\0".as_ptr() as *const _,
218 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
219 notify_supported_formats_trampoline::<Self, F> as *const (),
220 )),
221 Box_::into_raw(f),
222 )
223 }
224 }
225}
226
227impl<O: IsA<ClipAsset>> ClipAssetExt for O {}