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    #[doc(alias = "GESUriClipAsset")]
21    pub struct UriClipAsset(Object<ffi::GESUriClipAsset, ffi::GESUriClipAssetClass>) @extends SourceClipAsset, ClipAsset, Asset, @implements MetaContainer;
22
23    match fn {
24        type_ => || ffi::ges_uri_clip_asset_get_type(),
25    }
26}
27
28#[cfg(not(any(feature = "v1_18")))]
29glib::wrapper! {
30    #[doc(alias = "GESUriClipAsset")]
31    pub struct UriClipAsset(Object<ffi::GESUriClipAsset, ffi::GESUriClipAssetClass>) @extends ClipAsset, Asset, @implements MetaContainer;
32
33    match fn {
34        type_ => || ffi::ges_uri_clip_asset_get_type(),
35    }
36}
37
38impl UriClipAsset {
39    pub const NONE: Option<&'static UriClipAsset> = None;
40
41    //#[cfg(feature = "v1_16")]
42    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
43    //#[doc(alias = "ges_uri_clip_asset_finish")]
44    //pub fn finish(res: /*Ignored*/&gio::AsyncResult) -> Result<UriClipAsset, glib::Error> {
45    //    unsafe { TODO: call ffi:ges_uri_clip_asset_finish() }
46    //}
47
48    #[doc(alias = "ges_uri_clip_asset_request_sync")]
49    pub fn request_sync(uri: &str) -> Result<UriClipAsset, glib::Error> {
50        assert_initialized_main_thread!();
51        unsafe {
52            let mut error = std::ptr::null_mut();
53            let ret = ffi::ges_uri_clip_asset_request_sync(uri.to_glib_none().0, &mut error);
54            if error.is_null() {
55                Ok(from_glib_full(ret))
56            } else {
57                Err(from_glib_full(error))
58            }
59        }
60    }
61}
62
63unsafe impl Send for UriClipAsset {}
64unsafe impl Sync for UriClipAsset {}
65
66pub trait UriClipAssetExt: IsA<UriClipAsset> + 'static {
67    #[doc(alias = "ges_uri_clip_asset_get_duration")]
68    #[doc(alias = "get_duration")]
69    fn duration(&self) -> Option<gst::ClockTime> {
70        unsafe {
71            from_glib(ffi::ges_uri_clip_asset_get_duration(
72                self.as_ref().to_glib_none().0,
73            ))
74        }
75    }
76
77    #[doc(alias = "ges_uri_clip_asset_get_info")]
78    #[doc(alias = "get_info")]
79    fn info(&self) -> gst_pbutils::DiscovererInfo {
80        unsafe {
81            from_glib_none(ffi::ges_uri_clip_asset_get_info(const_override(
82                self.as_ref().to_glib_none().0,
83            )))
84        }
85    }
86
87    #[cfg(feature = "v1_18")]
88    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
89    #[doc(alias = "ges_uri_clip_asset_get_max_duration")]
90    #[doc(alias = "get_max_duration")]
91    fn max_duration(&self) -> Option<gst::ClockTime> {
92        unsafe {
93            from_glib(ffi::ges_uri_clip_asset_get_max_duration(
94                self.as_ref().to_glib_none().0,
95            ))
96        }
97    }
98
99    #[doc(alias = "ges_uri_clip_asset_get_stream_assets")]
100    #[doc(alias = "get_stream_assets")]
101    fn stream_assets(&self) -> Vec<UriSourceAsset> {
102        unsafe {
103            FromGlibPtrContainer::from_glib_none(ffi::ges_uri_clip_asset_get_stream_assets(
104                self.as_ref().to_glib_none().0,
105            ))
106        }
107    }
108
109    #[cfg(feature = "v1_18")]
110    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
111    #[doc(alias = "ges_uri_clip_asset_is_image")]
112    fn is_image(&self) -> bool {
113        unsafe {
114            from_glib(ffi::ges_uri_clip_asset_is_image(
115                self.as_ref().to_glib_none().0,
116            ))
117        }
118    }
119
120    fn set_duration(&self, duration: u64) {
121        ObjectExt::set_property(self.as_ref(), "duration", duration)
122    }
123
124    #[cfg(feature = "v1_18")]
125    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
126    #[doc(alias = "is-nested-timeline")]
127    fn is_nested_timeline(&self) -> bool {
128        ObjectExt::property(self.as_ref(), "is-nested-timeline")
129    }
130
131    #[doc(alias = "duration")]
132    fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
133        &self,
134        f: F,
135    ) -> SignalHandlerId {
136        unsafe extern "C" fn notify_duration_trampoline<
137            P: IsA<UriClipAsset>,
138            F: Fn(&P) + Send + Sync + 'static,
139        >(
140            this: *mut ffi::GESUriClipAsset,
141            _param_spec: glib::ffi::gpointer,
142            f: glib::ffi::gpointer,
143        ) {
144            let f: &F = &*(f as *const F);
145            f(UriClipAsset::from_glib_borrow(this).unsafe_cast_ref())
146        }
147        unsafe {
148            let f: Box_<F> = Box_::new(f);
149            connect_raw(
150                self.as_ptr() as *mut _,
151                c"notify::duration".as_ptr() as *const _,
152                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
153                    notify_duration_trampoline::<Self, F> as *const (),
154                )),
155                Box_::into_raw(f),
156            )
157        }
158    }
159
160    #[cfg(feature = "v1_18")]
161    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
162    #[doc(alias = "is-nested-timeline")]
163    fn connect_is_nested_timeline_notify<F: Fn(&Self) + Send + Sync + 'static>(
164        &self,
165        f: F,
166    ) -> SignalHandlerId {
167        unsafe extern "C" fn notify_is_nested_timeline_trampoline<
168            P: IsA<UriClipAsset>,
169            F: Fn(&P) + Send + Sync + 'static,
170        >(
171            this: *mut ffi::GESUriClipAsset,
172            _param_spec: glib::ffi::gpointer,
173            f: glib::ffi::gpointer,
174        ) {
175            let f: &F = &*(f as *const F);
176            f(UriClipAsset::from_glib_borrow(this).unsafe_cast_ref())
177        }
178        unsafe {
179            let f: Box_<F> = Box_::new(f);
180            connect_raw(
181                self.as_ptr() as *mut _,
182                c"notify::is-nested-timeline".as_ptr() as *const _,
183                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
184                    notify_is_nested_timeline_trampoline::<Self, F> as *const (),
185                )),
186                Box_::into_raw(f),
187            )
188        }
189    }
190}
191
192impl<O: IsA<UriClipAsset>> UriClipAssetExt for O {}