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
98/// Trait containing all [`struct@ClipAsset`] methods.
99///
100/// # Implementors
101///
102/// [`ClipAsset`][struct@crate::ClipAsset], [`SourceClipAsset`][struct@crate::SourceClipAsset]
103pub trait ClipAssetExt: IsA<ClipAsset> + 'static {
104 /// Converts the given frame number into a timestamp, using the "natural" frame
105 /// rate of the asset.
106 ///
107 /// You can use this to reference a specific frame in a media file and use this
108 /// as, for example, the `in-point` or `max-duration` of a [`Clip`][crate::Clip].
109 /// ## `frame_number`
110 /// The frame number we want the internal time coordinate timestamp of
111 ///
112 /// # Returns
113 ///
114 /// The timestamp corresponding to `frame_number` in the element source, given
115 /// in internal time coordinates, or `GST_CLOCK_TIME_NONE` if the clip asset does not have a
116 /// natural frame rate.
117 #[cfg(feature = "v1_18")]
118 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
119 #[doc(alias = "ges_clip_asset_get_frame_time")]
120 #[doc(alias = "get_frame_time")]
121 fn frame_time(&self, frame_number: FrameNumber) -> Option<gst::ClockTime> {
122 unsafe {
123 from_glib(ffi::ges_clip_asset_get_frame_time(
124 self.as_ref().to_glib_none().0,
125 frame_number,
126 ))
127 }
128 }
129
130 /// Result: [`true`] if `self` has a natural framerate [`false`] otherwise
131 ///
132 /// # Returns
133 ///
134 ///
135 /// ## `framerate_n`
136 /// The framerate numerator
137 ///
138 /// ## `framerate_d`
139 /// The framerate denominator
140 #[cfg(feature = "v1_18")]
141 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
142 #[doc(alias = "ges_clip_asset_get_natural_framerate")]
143 #[doc(alias = "get_natural_framerate")]
144 fn natural_framerate(&self) -> Option<(i32, i32)> {
145 unsafe {
146 let mut framerate_n = std::mem::MaybeUninit::uninit();
147 let mut framerate_d = std::mem::MaybeUninit::uninit();
148 let ret = from_glib(ffi::ges_clip_asset_get_natural_framerate(
149 self.as_ref().to_glib_none().0,
150 framerate_n.as_mut_ptr(),
151 framerate_d.as_mut_ptr(),
152 ));
153 if ret {
154 Some((framerate_n.assume_init(), framerate_d.assume_init()))
155 } else {
156 None
157 }
158 }
159 }
160
161 /// Gets track types for which objects extracted from `self` can create [`TrackElement`][crate::TrackElement]
162 ///
163 /// # Returns
164 ///
165 /// The track types on which `self` will create TrackElement when added to
166 /// a layer
167 #[doc(alias = "ges_clip_asset_get_supported_formats")]
168 #[doc(alias = "get_supported_formats")]
169 #[doc(alias = "supported-formats")]
170 fn supported_formats(&self) -> TrackType {
171 unsafe {
172 from_glib(ffi::ges_clip_asset_get_supported_formats(
173 self.as_ref().to_glib_none().0,
174 ))
175 }
176 }
177
178 /// Sets track types for which objects extracted from `self` can create [`TrackElement`][crate::TrackElement]
179 /// ## `supportedformats`
180 /// The track types supported by the GESClipAsset
181 #[doc(alias = "ges_clip_asset_set_supported_formats")]
182 #[doc(alias = "supported-formats")]
183 fn set_supported_formats(&self, supportedformats: TrackType) {
184 unsafe {
185 ffi::ges_clip_asset_set_supported_formats(
186 self.as_ref().to_glib_none().0,
187 supportedformats.into_glib(),
188 );
189 }
190 }
191
192 #[doc(alias = "supported-formats")]
193 fn connect_supported_formats_notify<F: Fn(&Self) + Send + Sync + 'static>(
194 &self,
195 f: F,
196 ) -> SignalHandlerId {
197 unsafe extern "C" fn notify_supported_formats_trampoline<
198 P: IsA<ClipAsset>,
199 F: Fn(&P) + Send + Sync + 'static,
200 >(
201 this: *mut ffi::GESClipAsset,
202 _param_spec: glib::ffi::gpointer,
203 f: glib::ffi::gpointer,
204 ) {
205 let f: &F = &*(f as *const F);
206 f(ClipAsset::from_glib_borrow(this).unsafe_cast_ref())
207 }
208 unsafe {
209 let f: Box_<F> = Box_::new(f);
210 connect_raw(
211 self.as_ptr() as *mut _,
212 c"notify::supported-formats".as_ptr() as *const _,
213 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
214 notify_supported_formats_trampoline::<Self, F> as *const (),
215 )),
216 Box_::into_raw(f),
217 )
218 }
219 }
220}
221
222impl<O: IsA<ClipAsset>> ClipAssetExt for O {}