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
153mod sealed {
154 pub trait Sealed {}
155 impl<T: super::IsA<super::UriClipAsset>> Sealed for T {}
156}
157
158/// Trait containing all [`struct@UriClipAsset`] methods.
159///
160/// # Implementors
161///
162/// [`UriClipAsset`][struct@crate::UriClipAsset]
163pub trait UriClipAssetExt: IsA<UriClipAsset> + sealed::Sealed + 'static {
164 /// Gets duration of the file represented by `self`
165 ///
166 /// # Returns
167 ///
168 /// The duration of `self`
169 #[doc(alias = "ges_uri_clip_asset_get_duration")]
170 #[doc(alias = "get_duration")]
171 fn duration(&self) -> Option<gst::ClockTime> {
172 unsafe {
173 from_glib(ffi::ges_uri_clip_asset_get_duration(
174 self.as_ref().to_glib_none().0,
175 ))
176 }
177 }
178
179 /// Gets [`gst_pbutils::DiscovererInfo`][crate::gst_pbutils::DiscovererInfo] about the file
180 ///
181 /// # Returns
182 ///
183 /// [`gst_pbutils::DiscovererInfo`][crate::gst_pbutils::DiscovererInfo] of specified asset
184 #[doc(alias = "ges_uri_clip_asset_get_info")]
185 #[doc(alias = "get_info")]
186 fn info(&self) -> gst_pbutils::DiscovererInfo {
187 unsafe {
188 from_glib_none(ffi::ges_uri_clip_asset_get_info(const_override(
189 self.as_ref().to_glib_none().0,
190 )))
191 }
192 }
193
194 /// Gets maximum duration of the file represented by `self`,
195 /// it is usually the same as GESUriClipAsset::duration,
196 /// but in the case of nested timelines, for example, they
197 /// are different as those can be extended 'infinitely'.
198 ///
199 /// # Returns
200 ///
201 /// The maximum duration of `self`
202 #[cfg(feature = "v1_18")]
203 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
204 #[doc(alias = "ges_uri_clip_asset_get_max_duration")]
205 #[doc(alias = "get_max_duration")]
206 fn max_duration(&self) -> Option<gst::ClockTime> {
207 unsafe {
208 from_glib(ffi::ges_uri_clip_asset_get_max_duration(
209 self.as_ref().to_glib_none().0,
210 ))
211 }
212 }
213
214 /// Get the GESUriSourceAsset `self` containes
215 ///
216 /// # Returns
217 ///
218 /// a
219 /// `GList` of [`UriSourceAsset`][crate::UriSourceAsset]
220 #[doc(alias = "ges_uri_clip_asset_get_stream_assets")]
221 #[doc(alias = "get_stream_assets")]
222 fn stream_assets(&self) -> Vec<UriSourceAsset> {
223 unsafe {
224 FromGlibPtrContainer::from_glib_none(ffi::ges_uri_clip_asset_get_stream_assets(
225 self.as_ref().to_glib_none().0,
226 ))
227 }
228 }
229
230 /// Gets Whether the file represented by `self` is an image or not
231 ///
232 /// # Returns
233 ///
234 /// Whether the file represented by `self` is an image or not
235 #[cfg(feature = "v1_18")]
236 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
237 #[doc(alias = "ges_uri_clip_asset_is_image")]
238 fn is_image(&self) -> bool {
239 unsafe {
240 from_glib(ffi::ges_uri_clip_asset_is_image(
241 self.as_ref().to_glib_none().0,
242 ))
243 }
244 }
245
246 /// The duration (in nanoseconds) of the media file
247 fn set_duration(&self, duration: u64) {
248 ObjectExt::set_property(self.as_ref(), "duration", duration)
249 }
250
251 /// The duration (in nanoseconds) of the media file
252 #[cfg(feature = "v1_18")]
253 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
254 #[doc(alias = "is-nested-timeline")]
255 fn is_nested_timeline(&self) -> bool {
256 ObjectExt::property(self.as_ref(), "is-nested-timeline")
257 }
258
259 #[doc(alias = "duration")]
260 fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
261 &self,
262 f: F,
263 ) -> SignalHandlerId {
264 unsafe extern "C" fn notify_duration_trampoline<
265 P: IsA<UriClipAsset>,
266 F: Fn(&P) + Send + Sync + 'static,
267 >(
268 this: *mut ffi::GESUriClipAsset,
269 _param_spec: glib::ffi::gpointer,
270 f: glib::ffi::gpointer,
271 ) {
272 let f: &F = &*(f as *const F);
273 f(UriClipAsset::from_glib_borrow(this).unsafe_cast_ref())
274 }
275 unsafe {
276 let f: Box_<F> = Box_::new(f);
277 connect_raw(
278 self.as_ptr() as *mut _,
279 b"notify::duration\0".as_ptr() as *const _,
280 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
281 notify_duration_trampoline::<Self, F> as *const (),
282 )),
283 Box_::into_raw(f),
284 )
285 }
286 }
287
288 #[cfg(feature = "v1_18")]
289 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
290 #[doc(alias = "is-nested-timeline")]
291 fn connect_is_nested_timeline_notify<F: Fn(&Self) + Send + Sync + 'static>(
292 &self,
293 f: F,
294 ) -> SignalHandlerId {
295 unsafe extern "C" fn notify_is_nested_timeline_trampoline<
296 P: IsA<UriClipAsset>,
297 F: Fn(&P) + Send + Sync + 'static,
298 >(
299 this: *mut ffi::GESUriClipAsset,
300 _param_spec: glib::ffi::gpointer,
301 f: glib::ffi::gpointer,
302 ) {
303 let f: &F = &*(f as *const F);
304 f(UriClipAsset::from_glib_borrow(this).unsafe_cast_ref())
305 }
306 unsafe {
307 let f: Box_<F> = Box_::new(f);
308 connect_raw(
309 self.as_ptr() as *mut _,
310 b"notify::is-nested-timeline\0".as_ptr() as *const _,
311 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
312 notify_is_nested_timeline_trampoline::<Self, F> as *const (),
313 )),
314 Box_::into_raw(f),
315 )
316 }
317 }
318}
319
320impl<O: IsA<UriClipAsset>> UriClipAssetExt for O {}