gstreamer_editing_services/auto/
uri_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::SourceClipAsset;
9use crate::{ffi, Asset, ClipAsset, MetaContainer, UriSourceAsset};
10use glib::{
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17#[cfg(feature = "v1_18")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
19glib::wrapper! {
20    ///
21    ///
22    /// ## Properties
23    ///
24    ///
25    /// #### `duration`
26    ///  The duration (in nanoseconds) of the media file
27    ///
28    /// Readable | Writeable
29    ///
30    ///
31    /// #### `is-nested-timeline`
32    ///  The duration (in nanoseconds) of the media file
33    ///
34    /// Readable
35    /// <details><summary><h4>ClipAsset</h4></summary>
36    ///
37    ///
38    /// #### `supported-formats`
39    ///  The formats supported by the asset.
40    ///
41    /// Readable | Writeable | Construct
42    /// </details>
43    /// <details><summary><h4>Asset</h4></summary>
44    ///
45    ///
46    /// #### `extractable-type`
47    ///  The [`Extractable`][crate::Extractable] object type that can be extracted from the asset.
48    ///
49    /// Readable | Writeable | Construct Only
50    ///
51    ///
52    /// #### `id`
53    ///  The ID of the asset. This should be unique amongst all assets with
54    /// the same [`extractable-type`][struct@crate::Asset#extractable-type]. Depending on the associated
55    /// [`Extractable`][crate::Extractable] implementation, this id may convey some information
56    /// about the [`glib::Object`][crate::glib::Object] that should be extracted. Note that, as such, the
57    /// ID will have an expected format, and you can not choose this value
58    /// arbitrarily. By default, this will be set to the type name of the
59    /// [`extractable-type`][struct@crate::Asset#extractable-type], but you should check the documentation
60    /// of the extractable type to see whether they differ from the
61    /// default behaviour.
62    ///
63    /// Readable | Writeable | Construct Only
64    ///
65    ///
66    /// #### `proxy`
67    ///  The default proxy for this asset, or [`None`] if it has no proxy. A
68    /// proxy will act as a substitute for the original asset when the
69    /// original is requested (see [`Asset::request()`][crate::Asset::request()]).
70    ///
71    /// Setting this property will not usually remove the existing proxy, but
72    /// will replace it as the default (see [`AssetExt::set_proxy()`][crate::prelude::AssetExt::set_proxy()]).
73    ///
74    /// Readable | Writeable
75    ///
76    ///
77    /// #### `proxy-target`
78    ///  The asset that this asset is a proxy for, or [`None`] if it is not a
79    /// proxy for another asset.
80    ///
81    /// Note that even if this asset is acting as a proxy for another asset,
82    /// but this asset is not the default [`proxy`][struct@crate::Asset#proxy], then `proxy`-target
83    /// will *still* point to this other asset. So you should check the
84    /// [`proxy`][struct@crate::Asset#proxy] property of `target`-proxy before assuming it is the
85    /// current default proxy for the target.
86    ///
87    /// Note that the [`notify`][struct@crate::glib::Object#notify] for this property is emitted after
88    /// the [`proxy`][struct@crate::Asset#proxy] [`notify`][struct@crate::glib::Object#notify] for the corresponding (if any)
89    /// asset it is now the proxy of/no longer the proxy of.
90    ///
91    /// Readable
92    /// </details>
93    ///
94    /// # Implements
95    ///
96    /// [`UriClipAssetExt`][trait@crate::prelude::UriClipAssetExt], [`SourceClipAssetExt`][trait@crate::prelude::SourceClipAssetExt], [`ClipAssetExt`][trait@crate::prelude::ClipAssetExt], [`AssetExt`][trait@crate::prelude::AssetExt], [`trait@glib::ObjectExt`], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt]
97    #[doc(alias = "GESUriClipAsset")]
98    pub struct UriClipAsset(Object<ffi::GESUriClipAsset, ffi::GESUriClipAssetClass>) @extends SourceClipAsset, ClipAsset, Asset, @implements MetaContainer;
99
100    match fn {
101        type_ => || ffi::ges_uri_clip_asset_get_type(),
102    }
103}
104
105#[cfg(not(any(feature = "v1_18")))]
106glib::wrapper! {
107    #[doc(alias = "GESUriClipAsset")]
108    pub struct UriClipAsset(Object<ffi::GESUriClipAsset, ffi::GESUriClipAssetClass>) @extends ClipAsset, Asset, @implements MetaContainer;
109
110    match fn {
111        type_ => || ffi::ges_uri_clip_asset_get_type(),
112    }
113}
114
115impl UriClipAsset {
116    pub const NONE: Option<&'static UriClipAsset> = None;
117
118    //#[cfg(feature = "v1_16")]
119    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
120    //#[doc(alias = "ges_uri_clip_asset_finish")]
121    //pub fn finish(res: /*Ignored*/&gio::AsyncResult) -> Result<UriClipAsset, glib::Error> {
122    //    unsafe { TODO: call ffi:ges_uri_clip_asset_finish() }
123    //}
124
125    /// Creates a [`UriClipAsset`][crate::UriClipAsset] for `uri` synchonously. You should avoid
126    /// to use it in application, and rather create [`UriClipAsset`][crate::UriClipAsset] asynchronously
127    /// ## `uri`
128    /// The URI of the file for which to create a [`UriClipAsset`][crate::UriClipAsset].
129    /// You can also use multi file uris for [`MultiFileSource`][crate::MultiFileSource].
130    ///
131    /// # Returns
132    ///
133    /// A reference to the requested asset or [`None`] if
134    /// an error happened
135    #[doc(alias = "ges_uri_clip_asset_request_sync")]
136    pub fn request_sync(uri: &str) -> Result<UriClipAsset, glib::Error> {
137        assert_initialized_main_thread!();
138        unsafe {
139            let mut error = std::ptr::null_mut();
140            let ret = ffi::ges_uri_clip_asset_request_sync(uri.to_glib_none().0, &mut error);
141            if error.is_null() {
142                Ok(from_glib_full(ret))
143            } else {
144                Err(from_glib_full(error))
145            }
146        }
147    }
148}
149
150unsafe impl Send for UriClipAsset {}
151unsafe impl Sync for UriClipAsset {}
152
153/// Trait containing all [`struct@UriClipAsset`] methods.
154///
155/// # Implementors
156///
157/// [`UriClipAsset`][struct@crate::UriClipAsset]
158pub trait UriClipAssetExt: IsA<UriClipAsset> + 'static {
159    /// Gets duration of the file represented by `self`
160    ///
161    /// # Returns
162    ///
163    /// The duration of `self`
164    #[doc(alias = "ges_uri_clip_asset_get_duration")]
165    #[doc(alias = "get_duration")]
166    fn duration(&self) -> Option<gst::ClockTime> {
167        unsafe {
168            from_glib(ffi::ges_uri_clip_asset_get_duration(
169                self.as_ref().to_glib_none().0,
170            ))
171        }
172    }
173
174    /// Gets [`gst_pbutils::DiscovererInfo`][crate::gst_pbutils::DiscovererInfo] about the file
175    ///
176    /// # Returns
177    ///
178    /// [`gst_pbutils::DiscovererInfo`][crate::gst_pbutils::DiscovererInfo] of specified asset
179    #[doc(alias = "ges_uri_clip_asset_get_info")]
180    #[doc(alias = "get_info")]
181    fn info(&self) -> gst_pbutils::DiscovererInfo {
182        unsafe {
183            from_glib_none(ffi::ges_uri_clip_asset_get_info(const_override(
184                self.as_ref().to_glib_none().0,
185            )))
186        }
187    }
188
189    /// Gets maximum duration of the file represented by `self`,
190    /// it is usually the same as GESUriClipAsset::duration,
191    /// but in the case of nested timelines, for example, they
192    /// are different as those can be extended 'infinitely'.
193    ///
194    /// # Returns
195    ///
196    /// The maximum duration of `self`
197    #[cfg(feature = "v1_18")]
198    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
199    #[doc(alias = "ges_uri_clip_asset_get_max_duration")]
200    #[doc(alias = "get_max_duration")]
201    fn max_duration(&self) -> Option<gst::ClockTime> {
202        unsafe {
203            from_glib(ffi::ges_uri_clip_asset_get_max_duration(
204                self.as_ref().to_glib_none().0,
205            ))
206        }
207    }
208
209    /// Get the GESUriSourceAsset `self` containes
210    ///
211    /// # Returns
212    ///
213    /// a
214    /// `GList` of [`UriSourceAsset`][crate::UriSourceAsset]
215    #[doc(alias = "ges_uri_clip_asset_get_stream_assets")]
216    #[doc(alias = "get_stream_assets")]
217    fn stream_assets(&self) -> Vec<UriSourceAsset> {
218        unsafe {
219            FromGlibPtrContainer::from_glib_none(ffi::ges_uri_clip_asset_get_stream_assets(
220                self.as_ref().to_glib_none().0,
221            ))
222        }
223    }
224
225    /// Gets Whether the file represented by `self` is an image or not
226    ///
227    /// # Returns
228    ///
229    /// Whether the file represented by `self` is an image or not
230    #[cfg(feature = "v1_18")]
231    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
232    #[doc(alias = "ges_uri_clip_asset_is_image")]
233    fn is_image(&self) -> bool {
234        unsafe {
235            from_glib(ffi::ges_uri_clip_asset_is_image(
236                self.as_ref().to_glib_none().0,
237            ))
238        }
239    }
240
241    /// The duration (in nanoseconds) of the media file
242    fn set_duration(&self, duration: u64) {
243        ObjectExt::set_property(self.as_ref(), "duration", duration)
244    }
245
246    /// The duration (in nanoseconds) of the media file
247    #[cfg(feature = "v1_18")]
248    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
249    #[doc(alias = "is-nested-timeline")]
250    fn is_nested_timeline(&self) -> bool {
251        ObjectExt::property(self.as_ref(), "is-nested-timeline")
252    }
253
254    #[doc(alias = "duration")]
255    fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
256        &self,
257        f: F,
258    ) -> SignalHandlerId {
259        unsafe extern "C" fn notify_duration_trampoline<
260            P: IsA<UriClipAsset>,
261            F: Fn(&P) + Send + Sync + 'static,
262        >(
263            this: *mut ffi::GESUriClipAsset,
264            _param_spec: glib::ffi::gpointer,
265            f: glib::ffi::gpointer,
266        ) {
267            let f: &F = &*(f as *const F);
268            f(UriClipAsset::from_glib_borrow(this).unsafe_cast_ref())
269        }
270        unsafe {
271            let f: Box_<F> = Box_::new(f);
272            connect_raw(
273                self.as_ptr() as *mut _,
274                c"notify::duration".as_ptr() as *const _,
275                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
276                    notify_duration_trampoline::<Self, F> as *const (),
277                )),
278                Box_::into_raw(f),
279            )
280        }
281    }
282
283    #[cfg(feature = "v1_18")]
284    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
285    #[doc(alias = "is-nested-timeline")]
286    fn connect_is_nested_timeline_notify<F: Fn(&Self) + Send + Sync + 'static>(
287        &self,
288        f: F,
289    ) -> SignalHandlerId {
290        unsafe extern "C" fn notify_is_nested_timeline_trampoline<
291            P: IsA<UriClipAsset>,
292            F: Fn(&P) + Send + Sync + 'static,
293        >(
294            this: *mut ffi::GESUriClipAsset,
295            _param_spec: glib::ffi::gpointer,
296            f: glib::ffi::gpointer,
297        ) {
298            let f: &F = &*(f as *const F);
299            f(UriClipAsset::from_glib_borrow(this).unsafe_cast_ref())
300        }
301        unsafe {
302            let f: Box_<F> = Box_::new(f);
303            connect_raw(
304                self.as_ptr() as *mut _,
305                c"notify::is-nested-timeline".as_ptr() as *const _,
306                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
307                    notify_is_nested_timeline_trampoline::<Self, F> as *const (),
308                )),
309                Box_::into_raw(f),
310            )
311        }
312    }
313}
314
315impl<O: IsA<UriClipAsset>> UriClipAssetExt for O {}