Skip to main content

gstreamer_editing_services/auto/
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#![allow(deprecated)]
6
7use crate::{Extractable, MetaContainer, ffi};
8use glib::{
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::{boxed::Box as Box_, pin::Pin};
14
15glib::wrapper! {
16    /// A [`Asset`][crate::Asset] in the GStreamer Editing Services represents a resources
17    /// that can be used. In particular, any class that implements the
18    /// [`Extractable`][crate::Extractable] interface may have some associated assets with a
19    /// corresponding [`extractable-type`][struct@crate::Asset#extractable-type], from which its objects can be
20    /// extracted using [`AssetExt::extract()`][crate::prelude::AssetExt::extract()]. Some examples would be
21    /// [`Clip`][crate::Clip], [`Formatter`][crate::Formatter] and [`TrackElement`][crate::TrackElement].
22    ///
23    /// All assets that are created within GES are stored in a cache; one per
24    /// each [`id`][struct@crate::Asset#id] and [`extractable-type`][struct@crate::Asset#extractable-type] pair. These assets can
25    /// be fetched, and initialized if they do not yet exist in the cache,
26    /// using [`request_with_type()`][Self::request_with_type()].
27    ///
28    /// **⚠️ The following code is in  c ⚠️**
29    ///
30    /// ``` c
31    /// GESAsset *effect_asset;
32    /// GESEffect *effect;
33    ///
34    /// // You create an asset for an effect
35    /// effect_asset = ges_asset_request (GES_TYPE_EFFECT, "agingtv", NULL);
36    ///
37    /// // And now you can extract an instance of GESEffect from that asset
38    /// effect = GES_EFFECT (ges_asset_extract (effect_asset));
39    ///
40    /// ```
41    ///
42    /// The advantage of using assets, rather than simply creating the object
43    /// directly, is that the currently loaded resources can be listed with
44    /// `ges_list_assets()` and displayed to an end user. For example, to show
45    /// which media files have been loaded, and a standard list of effects. In
46    /// fact, the GES library already creates assets for [`TransitionClip`][crate::TransitionClip] and
47    /// [`Formatter`][crate::Formatter], which you can use to list all the available transition
48    /// types and supported formats.
49    ///
50    /// The other advantage is that [`Asset`][crate::Asset] implements [`MetaContainer`][crate::MetaContainer], so
51    /// metadata can be set on the asset, with some subclasses automatically
52    /// creating this metadata on initiation.
53    ///
54    /// For example, to display information about the supported formats, you
55    /// could do the following:
56    ///
57    /// ```text
58    ///    GList *formatter_assets, *tmp;
59    ///
60    ///    //  List all  the transitions
61    ///    formatter_assets = ges_list_assets (GES_TYPE_FORMATTER);
62    ///
63    ///    // Print some infos about the formatter GESAsset
64    ///    for (tmp = formatter_assets; tmp; tmp = tmp->next) {
65    ///      gst_print ("Name of the formatter: %s, file extension it produces: %s",
66    ///        ges_meta_container_get_string (
67    ///          GES_META_CONTAINER (tmp->data), GES_META_FORMATTER_NAME),
68    ///        ges_meta_container_get_string (
69    ///          GES_META_CONTAINER (tmp->data), GES_META_FORMATTER_EXTENSION));
70    ///    }
71    ///
72    ///    g_list_free (transition_assets);
73    ///
74    /// ```
75    ///
76    /// ## ID
77    ///
78    /// Each asset is uniquely defined in the cache by its
79    /// [`extractable-type`][struct@crate::Asset#extractable-type] and [`id`][struct@crate::Asset#id]. Depending on the
80    /// [`extractable-type`][struct@crate::Asset#extractable-type], the [`id`][struct@crate::Asset#id] can be used to parametrise
81    /// the creation of the object upon extraction. By default, a class that
82    /// implements [`Extractable`][crate::Extractable] will only have a single associated asset,
83    /// with an [`id`][struct@crate::Asset#id] set to the type name of its objects. However, this
84    /// is overwritten by some implementations, which allow a class to have
85    /// multiple associated assets. For example, for [`TransitionClip`][crate::TransitionClip] the
86    /// [`id`][struct@crate::Asset#id] will be a nickname of the [`vtype`][struct@crate::TransitionClip#vtype]. You
87    /// should check the documentation for each extractable type to see if they
88    /// differ from the default.
89    ///
90    /// Moreover, each [`extractable-type`][struct@crate::Asset#extractable-type] may also associate itself
91    /// with a specific asset subclass. In such cases, when their asset is
92    /// requested, an asset of this subclass will be returned instead.
93    ///
94    /// ## Managing
95    ///
96    /// You can use a [`Project`][crate::Project] to easily manage the assets of a
97    /// [`Timeline`][crate::Timeline].
98    ///
99    /// ## Proxies
100    ///
101    /// Some assets can (temporarily) act as the [`proxy`][struct@crate::Asset#proxy] of another
102    /// asset. When the original asset is requested from the cache, the proxy
103    /// will be returned in its place. This can be useful if, say, you want
104    /// to substitute a [`UriClipAsset`][crate::UriClipAsset] corresponding to a high resolution
105    /// media file with the asset of a lower resolution stand in.
106    ///
107    /// An asset may even have several proxies, the first of which will act as
108    /// its default and be returned on requests, but the others will be ordered
109    /// to take its place once it is removed. You can add a proxy to an asset,
110    /// or set its default, using [`AssetExt::set_proxy()`][crate::prelude::AssetExt::set_proxy()], and you can remove
111    /// them with [`AssetExt::unproxy()`][crate::prelude::AssetExt::unproxy()].
112    ///
113    /// ## Properties
114    ///
115    ///
116    /// #### `extractable-type`
117    ///  The [`Extractable`][crate::Extractable] object type that can be extracted from the asset.
118    ///
119    /// Readable | Writeable | Construct Only
120    ///
121    ///
122    /// #### `id`
123    ///  The ID of the asset. This should be unique amongst all assets with
124    /// the same [`extractable-type`][struct@crate::Asset#extractable-type]. Depending on the associated
125    /// [`Extractable`][crate::Extractable] implementation, this id may convey some information
126    /// about the [`glib::Object`][crate::glib::Object] that should be extracted. Note that, as such, the
127    /// ID will have an expected format, and you can not choose this value
128    /// arbitrarily. By default, this will be set to the type name of the
129    /// [`extractable-type`][struct@crate::Asset#extractable-type], but you should check the documentation
130    /// of the extractable type to see whether they differ from the
131    /// default behaviour.
132    ///
133    /// Readable | Writeable | Construct Only
134    ///
135    ///
136    /// #### `proxy`
137    ///  The default proxy for this asset, or [`None`] if it has no proxy. A
138    /// proxy will act as a substitute for the original asset when the
139    /// original is requested (see [`Asset::request_with_type()`][crate::Asset::request_with_type()]).
140    ///
141    /// Setting this property will not usually remove the existing proxy, but
142    /// will replace it as the default (see [`AssetExt::set_proxy()`][crate::prelude::AssetExt::set_proxy()]).
143    ///
144    /// Readable | Writeable
145    ///
146    ///
147    /// #### `proxy-target`
148    ///  The asset that this asset is a proxy for, or [`None`] if it is not a
149    /// proxy for another asset.
150    ///
151    /// Note that even if this asset is acting as a proxy for another asset,
152    /// but this asset is not the default [`proxy`][struct@crate::Asset#proxy], then `proxy`-target
153    /// will *still* point to this other asset. So you should check the
154    /// [`proxy`][struct@crate::Asset#proxy] property of `target`-proxy before assuming it is the
155    /// current default proxy for the target.
156    ///
157    /// Note that the [`notify`][struct@crate::glib::Object#notify] for this property is emitted after
158    /// the [`proxy`][struct@crate::Asset#proxy] [`notify`][struct@crate::glib::Object#notify] for the corresponding (if any)
159    /// asset it is now the proxy of/no longer the proxy of.
160    ///
161    /// Readable
162    ///
163    /// # Implements
164    ///
165    /// [`AssetExt`][trait@crate::prelude::AssetExt], [`trait@glib::ObjectExt`], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt]
166    #[doc(alias = "GESAsset")]
167    pub struct Asset(Object<ffi::GESAsset, ffi::GESAssetClass>) @implements MetaContainer;
168
169    match fn {
170        type_ => || ffi::ges_asset_get_type(),
171    }
172}
173
174impl Asset {
175    pub const NONE: Option<&'static Asset> = None;
176
177    /// Indicate that an existing [`Asset`][crate::Asset] in the cache should be reloaded
178    /// upon the next request. This can be used when some condition has
179    /// changed, which may require that an existing asset should be updated.
180    /// For example, if an external resource has changed or now become
181    /// available.
182    ///
183    /// Note, the asset is not immediately changed, but will only actually
184    /// reload on the next call to [`request_with_type()`][Self::request_with_type()] or
185    /// [`request_async_with_type()`][Self::request_async_with_type()].
186    /// ## `extractable_type`
187    /// The [`extractable-type`][struct@crate::Asset#extractable-type] of the asset that
188    /// needs reloading
189    /// ## `id`
190    /// The [`id`][struct@crate::Asset#id] of the asset asset that needs
191    /// reloading
192    ///
193    /// # Returns
194    ///
195    /// [`true`] if the specified asset exists in the cache and could be
196    /// marked for reloading.
197    #[doc(alias = "ges_asset_needs_reload")]
198    #[doc(alias = "needs_reload")]
199    pub fn needs_reload_with_type(extractable_type: glib::types::Type, id: Option<&str>) -> bool {
200        assert_initialized_main_thread!();
201        unsafe {
202            from_glib(ffi::ges_asset_needs_reload(
203                extractable_type.into_glib(),
204                id.to_glib_none().0,
205            ))
206        }
207    }
208
209    /// Returns an asset with the given properties. If such an asset already
210    /// exists in the cache (it has been previously created in GES), then a
211    /// reference to the existing asset is returned. Otherwise, a newly created
212    /// asset is returned, and also added to the cache.
213    ///
214    /// If the requested asset has been loaded with an error, then `error` is
215    /// set, if given, and [`None`] will be returned instead.
216    ///
217    /// Note that the given `id` may not be exactly the [`id`][struct@crate::Asset#id] that is
218    /// set on the returned asset. For instance, it may be adjusted into a
219    /// standard format. Or, if a [`Extractable`][crate::Extractable] type does not have its
220    /// extraction parametrised, as is the case by default, then the given `id`
221    /// may be ignored entirely and the [`id`][struct@crate::Asset#id] set to some standard, in
222    /// which case a [`None`] `id` can be given.
223    ///
224    /// Similarly, the given `extractable_type` may not be exactly the
225    /// [`extractable-type`][struct@crate::Asset#extractable-type] that is set on the returned asset. Instead,
226    /// the actual extractable type may correspond to a subclass of the given
227    /// `extractable_type`, depending on the given `id`.
228    ///
229    /// Moreover, depending on the given `extractable_type`, the returned asset
230    /// may belong to a subclass of [`Asset`][crate::Asset].
231    ///
232    /// Finally, if the requested asset has a [`proxy`][struct@crate::Asset#proxy], then the proxy
233    /// that is found at the end of the chain of proxies is returned (a proxy's
234    /// proxy will take its place, and so on, unless it has no proxy).
235    ///
236    /// Some asset subclasses only support asynchronous construction of its
237    /// assets, such as [`UriClip`][crate::UriClip]. For such assets this method will fail, and
238    /// you should use [`request_async_with_type()`][Self::request_async_with_type()] instead. In the case of
239    /// [`UriClip`][crate::UriClip], you can use [`UriClipAsset::request_sync()`][crate::UriClipAsset::request_sync()] if you only
240    /// want to wait for the request to finish.
241    /// ## `extractable_type`
242    /// The [`extractable-type`][struct@crate::Asset#extractable-type] of the asset
243    /// ## `id`
244    /// The [`id`][struct@crate::Asset#id] of the asset
245    ///
246    /// # Returns
247    ///
248    /// A reference to the requested
249    /// asset, or [`None`] if an error occurred.
250    #[doc(alias = "ges_asset_request")]
251    #[doc(alias = "request")]
252    pub fn request_with_type(
253        extractable_type: glib::types::Type,
254        id: Option<&str>,
255    ) -> Result<Option<Asset>, glib::Error> {
256        assert_initialized_main_thread!();
257        unsafe {
258            let mut error = std::ptr::null_mut();
259            let ret = ffi::ges_asset_request(
260                extractable_type.into_glib(),
261                id.to_glib_none().0,
262                &mut error,
263            );
264            if error.is_null() {
265                Ok(from_glib_full(ret))
266            } else {
267                Err(from_glib_full(error))
268            }
269        }
270    }
271
272    /// Requests an asset with the given properties asynchronously (see
273    /// [`request_with_type()`][Self::request_with_type()]). When the asset has been initialized or fetched
274    /// from the cache, the given callback function will be called. The
275    /// asset can then be retrieved in the callback using the
276    /// `ges_asset_request_finish()` method on the given `GAsyncResult`.
277    ///
278    /// Note that the source object passed to the callback will be the
279    /// [`Asset`][crate::Asset] corresponding to the request, but it may not have loaded
280    /// correctly and therefore can not be used as is. Instead,
281    /// `ges_asset_request_finish()` should be used to fetch a usable asset, or
282    /// indicate that an error occurred in the asset's creation.
283    ///
284    /// Note that the callback will be called in the `GMainLoop` running under
285    /// the same `GMainContext` that `ges_init()` was called in. So, if you wish
286    /// the callback to be invoked outside the default `GMainContext`, you can
287    /// call `g_main_context_push_thread_default()` in a new thread before
288    /// calling `ges_init()`.
289    ///
290    /// Example of an asynchronous asset request:
291    /// **⚠️ The following code is in  c ⚠️**
292    ///
293    /// ``` c
294    /// // The request callback
295    /// static void
296    /// asset_loaded_cb (GESAsset * source, GAsyncResult * res, gpointer user_data)
297    /// {
298    ///   GESAsset *asset;
299    ///   GError *error = NULL;
300    ///
301    ///   asset = ges_asset_request_finish (res, &error);
302    ///   if (asset) {
303    ///    gst_print ("The file: %s is usable as a GESUriClip",
304    ///        ges_asset_get_id (asset));
305    ///   } else {
306    ///    gst_print ("The file: %s is *not* usable as a GESUriClip because: %s",
307    ///        ges_asset_get_id (source), error->message);
308    ///   }
309    ///
310    ///   gst_object_unref (asset);
311    /// }
312    ///
313    /// // The request:
314    /// ges_asset_request_async (GES_TYPE_URI_CLIP, some_uri, NULL,
315    ///    (GAsyncReadyCallback) asset_loaded_cb, user_data);
316    /// ```
317    /// ## `extractable_type`
318    /// The [`extractable-type`][struct@crate::Asset#extractable-type] of the asset
319    /// ## `id`
320    /// The [`id`][struct@crate::Asset#id] of the asset
321    /// ## `cancellable`
322    /// An object to allow cancellation of the
323    /// asset request, or [`None`] to ignore
324    /// ## `callback`
325    /// A function to call when the initialization is finished
326    #[doc(alias = "ges_asset_request_async")]
327    #[doc(alias = "request_async")]
328    pub fn request_async_with_type<P: FnOnce(Result<Asset, glib::Error>) + 'static>(
329        extractable_type: glib::types::Type,
330        id: Option<&str>,
331        cancellable: Option<&impl IsA<gio::Cancellable>>,
332        callback: P,
333    ) {
334        assert_initialized_main_thread!();
335
336        let main_context = glib::MainContext::ref_thread_default();
337        let is_main_context_owner = main_context.is_owner();
338        let has_acquired_main_context = (!is_main_context_owner)
339            .then(|| main_context.acquire().ok())
340            .flatten();
341        assert!(
342            is_main_context_owner || has_acquired_main_context.is_some(),
343            "Async operations only allowed if the thread is owning the MainContext"
344        );
345
346        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
347            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
348        unsafe extern "C" fn request_async_with_type_trampoline<
349            P: FnOnce(Result<Asset, glib::Error>) + 'static,
350        >(
351            _source_object: *mut glib::gobject_ffi::GObject,
352            res: *mut gio::ffi::GAsyncResult,
353            user_data: glib::ffi::gpointer,
354        ) {
355            unsafe {
356                let mut error = std::ptr::null_mut();
357                let ret = ffi::ges_asset_request_finish(res, &mut error);
358                let result = if error.is_null() {
359                    Ok(from_glib_full(ret))
360                } else {
361                    Err(from_glib_full(error))
362                };
363                let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
364                    Box_::from_raw(user_data as *mut _);
365                let callback: P = callback.into_inner();
366                callback(result);
367            }
368        }
369        let callback = request_async_with_type_trampoline::<P>;
370        unsafe {
371            ffi::ges_asset_request_async(
372                extractable_type.into_glib(),
373                id.to_glib_none().0,
374                cancellable.map(|p| p.as_ref()).to_glib_none().0,
375                Some(callback),
376                Box_::into_raw(user_data) as *mut _,
377            );
378        }
379    }
380
381    pub fn request_async_with_type_future(
382        extractable_type: glib::types::Type,
383        id: Option<&str>,
384    ) -> Pin<Box_<dyn std::future::Future<Output = Result<Asset, glib::Error>> + 'static>> {
385        skip_assert_initialized!();
386        let id = id.map(ToOwned::to_owned);
387        Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| {
388            Self::request_async_with_type(
389                extractable_type,
390                id.as_ref().map(::std::borrow::Borrow::borrow),
391                Some(cancellable),
392                move |res| {
393                    send.resolve(res);
394                },
395            );
396        }))
397    }
398}
399
400unsafe impl Send for Asset {}
401unsafe impl Sync for Asset {}
402
403/// Trait containing all [`struct@Asset`] methods.
404///
405/// # Implementors
406///
407/// [`Asset`][struct@crate::Asset], [`ClipAsset`][struct@crate::ClipAsset], [`Project`][struct@crate::Project], [`TrackElementAsset`][struct@crate::TrackElementAsset]
408pub trait AssetExt: IsA<Asset> + 'static {
409    /// Extracts a new [`extractable-type`][struct@crate::Asset#extractable-type] object from the asset. The
410    /// [`id`][struct@crate::Asset#id] of the asset may determine the properties and state of the
411    /// newly created object.
412    ///
413    /// # Returns
414    ///
415    /// A newly created object, or [`None`] if an
416    /// error occurred.
417    #[doc(alias = "ges_asset_extract")]
418    fn extract(&self) -> Result<Extractable, glib::Error> {
419        unsafe {
420            let mut error = std::ptr::null_mut();
421            let ret = ffi::ges_asset_extract(self.as_ref().to_glib_none().0, &mut error);
422            if error.is_null() {
423                Ok(from_glib_none(ret))
424            } else {
425                Err(from_glib_full(error))
426            }
427        }
428    }
429
430    /// Retrieve the error that was set on the asset when it was loaded.
431    ///
432    /// # Deprecated since 1.30
433    ///
434    /// Use [`error_full()`][Self::error_full()] instead for MT-safety.
435    ///
436    /// # Returns
437    ///
438    /// The error set on `asset`, or
439    /// [`None`] if no error occurred when `asset` was loaded.
440    #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
441    #[allow(deprecated)]
442    #[doc(alias = "ges_asset_get_error")]
443    #[doc(alias = "get_error")]
444    fn error(&self) -> Option<glib::Error> {
445        unsafe { from_glib_none(ffi::ges_asset_get_error(self.as_ref().to_glib_none().0)) }
446    }
447
448    /// Retrieve the error that was set on the asset when it was loaded.
449    ///
450    /// # Returns
451    ///
452    /// A copy of the error set on `asset`,
453    /// or [`None`] if no error occurred when `asset` was loaded. Free with
454    /// `g_error_free()` when no longer needed.
455    #[cfg(feature = "v1_30")]
456    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
457    #[doc(alias = "ges_asset_get_error_full")]
458    #[doc(alias = "get_error_full")]
459    fn error_full(&self) -> Option<glib::Error> {
460        unsafe {
461            from_glib_full(ffi::ges_asset_get_error_full(
462                self.as_ref().to_glib_none().0,
463            ))
464        }
465    }
466
467    /// Gets the [`extractable-type`][struct@crate::Asset#extractable-type] of the asset.
468    ///
469    /// # Returns
470    ///
471    /// The extractable type of `self`.
472    #[doc(alias = "ges_asset_get_extractable_type")]
473    #[doc(alias = "get_extractable_type")]
474    #[doc(alias = "extractable-type")]
475    fn extractable_type(&self) -> glib::types::Type {
476        unsafe {
477            from_glib(ffi::ges_asset_get_extractable_type(
478                self.as_ref().to_glib_none().0,
479            ))
480        }
481    }
482
483    /// Gets the [`id`][struct@crate::Asset#id] of the asset.
484    ///
485    /// # Returns
486    ///
487    /// The ID of `self`.
488    #[doc(alias = "ges_asset_get_id")]
489    #[doc(alias = "get_id")]
490    fn id(&self) -> glib::GString {
491        unsafe { from_glib_none(ffi::ges_asset_get_id(self.as_ref().to_glib_none().0)) }
492    }
493
494    /// Gets the default [`proxy`][struct@crate::Asset#proxy] of the asset.
495    ///
496    /// # Deprecated since 1.30
497    ///
498    /// Use [`proxy_full()`][Self::proxy_full()] instead for MT-safety.
499    ///
500    /// # Returns
501    ///
502    /// The default proxy of `self`.
503    #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
504    #[allow(deprecated)]
505    #[doc(alias = "ges_asset_get_proxy")]
506    #[doc(alias = "get_proxy")]
507    #[must_use]
508    fn proxy(&self) -> Option<Asset> {
509        unsafe { from_glib_none(ffi::ges_asset_get_proxy(self.as_ref().to_glib_none().0)) }
510    }
511
512    /// Gets the default [`proxy`][struct@crate::Asset#proxy] of the asset.
513    ///
514    /// # Returns
515    ///
516    /// The default proxy of `self`,
517    /// or [`None`] if `self` has no proxy.
518    #[cfg(feature = "v1_30")]
519    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
520    #[doc(alias = "ges_asset_get_proxy_full")]
521    #[doc(alias = "get_proxy_full")]
522    #[must_use]
523    fn proxy_full(&self) -> Option<Asset> {
524        unsafe {
525            from_glib_full(ffi::ges_asset_get_proxy_full(
526                self.as_ref().to_glib_none().0,
527            ))
528        }
529    }
530
531    /// Gets the [`proxy-target`][struct@crate::Asset#proxy-target] of the asset.
532    ///
533    /// Note that the proxy target may have loaded with an error, so you should
534    /// call [`error()`][Self::error()] on the returned target.
535    ///
536    /// # Deprecated since 1.30
537    ///
538    /// Use [`proxy_target_full()`][Self::proxy_target_full()] instead for MT-safety.
539    ///
540    /// # Returns
541    ///
542    /// The asset that `self` is a proxy
543    /// of.
544    #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
545    #[allow(deprecated)]
546    #[doc(alias = "ges_asset_get_proxy_target")]
547    #[doc(alias = "get_proxy_target")]
548    #[doc(alias = "proxy-target")]
549    #[must_use]
550    fn proxy_target(&self) -> Option<Asset> {
551        unsafe {
552            from_glib_none(ffi::ges_asset_get_proxy_target(
553                self.as_ref().to_glib_none().0,
554            ))
555        }
556    }
557
558    /// Gets the [`proxy-target`][struct@crate::Asset#proxy-target] of the asset.
559    ///
560    /// Note that the proxy target may have loaded with an error, so you should
561    /// call [`error()`][Self::error()] on the returned target.
562    ///
563    /// # Returns
564    ///
565    /// The asset that `self` is a proxy
566    /// of, or [`None`] if `self` is not a proxy for another asset.
567    #[cfg(feature = "v1_30")]
568    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
569    #[doc(alias = "ges_asset_get_proxy_target_full")]
570    #[doc(alias = "get_proxy_target_full")]
571    #[must_use]
572    fn proxy_target_full(&self) -> Option<Asset> {
573        unsafe {
574            from_glib_full(ffi::ges_asset_get_proxy_target_full(
575                self.as_ref().to_glib_none().0,
576            ))
577        }
578    }
579
580    /// Get all the proxies that the asset has. The first item of the list will
581    /// be the default [`proxy`][struct@crate::Asset#proxy]. The second will be the proxy that is
582    /// 'next in line' to be default, and so on.
583    ///
584    /// # Deprecated since 1.30
585    ///
586    /// Use [`list_proxies_full()`][Self::list_proxies_full()] instead for MT-safety.
587    ///
588    /// # Returns
589    ///
590    /// The list of proxies
591    /// that `self` has.
592    #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
593    #[allow(deprecated)]
594    #[doc(alias = "ges_asset_list_proxies")]
595    fn list_proxies(&self) -> Vec<Asset> {
596        unsafe {
597            FromGlibPtrContainer::from_glib_none(ffi::ges_asset_list_proxies(
598                self.as_ref().to_glib_none().0,
599            ))
600        }
601    }
602
603    /// Get all the proxies that the asset has. The first item of the list will
604    /// be the default [`proxy`][struct@crate::Asset#proxy]. The second will be the proxy that is
605    /// 'next in line' to be default, and so on.
606    ///
607    /// # Returns
608    ///
609    /// The list of proxies
610    /// that `self` has.
611    #[cfg(feature = "v1_30")]
612    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
613    #[doc(alias = "ges_asset_list_proxies_full")]
614    fn list_proxies_full(&self) -> Vec<Asset> {
615        unsafe {
616            FromGlibPtrContainer::from_glib_full(ffi::ges_asset_list_proxies_full(
617                self.as_ref().to_glib_none().0,
618            ))
619        }
620    }
621
622    /// Sets the [`proxy`][struct@crate::Asset#proxy] for the asset.
623    ///
624    /// If `proxy` is among the existing proxies of the asset (see
625    /// [`list_proxies()`][Self::list_proxies()]) it will be moved to become the default
626    /// proxy. Otherwise, if `proxy` is not [`None`], it will be added to the list
627    /// of proxies, as the new default. The previous default proxy will become
628    /// 'next in line' for if the new one is removed, and so on. As such, this
629    /// will **not** actually remove the previous default proxy (use
630    /// [`unproxy()`][Self::unproxy()] for that).
631    ///
632    /// Note that an asset can only act as a proxy for one other asset.
633    ///
634    /// As a special case, if `proxy` is [`None`], then this method will actually
635    /// remove **all** proxies from the asset.
636    /// ## `proxy`
637    /// A new default proxy for `self`
638    ///
639    /// # Returns
640    ///
641    /// [`true`] if `proxy` was successfully set as the default for
642    /// `self`.
643    #[doc(alias = "ges_asset_set_proxy")]
644    #[doc(alias = "proxy")]
645    fn set_proxy(&self, proxy: Option<&impl IsA<Asset>>) -> Result<(), glib::error::BoolError> {
646        unsafe {
647            glib::result_from_gboolean!(
648                ffi::ges_asset_set_proxy(
649                    self.as_ref().to_glib_none().0,
650                    proxy.map(|p| p.as_ref()).to_glib_none().0
651                ),
652                "Failed to set proxy"
653            )
654        }
655    }
656
657    /// Removes the proxy from the available list of proxies for the asset. If
658    /// the given proxy is the default proxy of the list, then the next proxy
659    /// in the available list (see [`list_proxies()`][Self::list_proxies()]) will become the
660    /// default. If there are no other proxies, then the asset will no longer
661    /// have a default [`proxy`][struct@crate::Asset#proxy].
662    /// ## `proxy`
663    /// An existing proxy of `self`
664    ///
665    /// # Returns
666    ///
667    /// [`true`] if `proxy` was successfully removed from `self`'s proxy
668    /// list.
669    #[doc(alias = "ges_asset_unproxy")]
670    fn unproxy(&self, proxy: &impl IsA<Asset>) -> Result<(), glib::error::BoolError> {
671        unsafe {
672            glib::result_from_gboolean!(
673                ffi::ges_asset_unproxy(
674                    self.as_ref().to_glib_none().0,
675                    proxy.as_ref().to_glib_none().0
676                ),
677                "Failed to unproxy asset"
678            )
679        }
680    }
681
682    #[doc(alias = "proxy")]
683    fn connect_proxy_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
684        unsafe extern "C" fn notify_proxy_trampoline<
685            P: IsA<Asset>,
686            F: Fn(&P) + Send + Sync + 'static,
687        >(
688            this: *mut ffi::GESAsset,
689            _param_spec: glib::ffi::gpointer,
690            f: glib::ffi::gpointer,
691        ) {
692            unsafe {
693                let f: &F = &*(f as *const F);
694                f(Asset::from_glib_borrow(this).unsafe_cast_ref())
695            }
696        }
697        unsafe {
698            let f: Box_<F> = Box_::new(f);
699            connect_raw(
700                self.as_ptr() as *mut _,
701                c"notify::proxy".as_ptr(),
702                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
703                    notify_proxy_trampoline::<Self, F> as *const (),
704                )),
705                Box_::into_raw(f),
706            )
707        }
708    }
709
710    #[doc(alias = "proxy-target")]
711    fn connect_proxy_target_notify<F: Fn(&Self) + Send + Sync + 'static>(
712        &self,
713        f: F,
714    ) -> SignalHandlerId {
715        unsafe extern "C" fn notify_proxy_target_trampoline<
716            P: IsA<Asset>,
717            F: Fn(&P) + Send + Sync + 'static,
718        >(
719            this: *mut ffi::GESAsset,
720            _param_spec: glib::ffi::gpointer,
721            f: glib::ffi::gpointer,
722        ) {
723            unsafe {
724                let f: &F = &*(f as *const F);
725                f(Asset::from_glib_borrow(this).unsafe_cast_ref())
726            }
727        }
728        unsafe {
729            let f: Box_<F> = Box_::new(f);
730            connect_raw(
731                self.as_ptr() as *mut _,
732                c"notify::proxy-target".as_ptr(),
733                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
734                    notify_proxy_target_trampoline::<Self, F> as *const (),
735                )),
736                Box_::into_raw(f),
737            )
738        }
739    }
740}
741
742impl<O: IsA<Asset>> AssetExt for O {}