gstreamer_editing_services/auto/
uri_clip_asset.rs1#[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 #[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
66mod sealed {
67 pub trait Sealed {}
68 impl<T: super::IsA<super::UriClipAsset>> Sealed for T {}
69}
70
71pub trait UriClipAssetExt: IsA<UriClipAsset> + sealed::Sealed + 'static {
72 #[doc(alias = "ges_uri_clip_asset_get_duration")]
73 #[doc(alias = "get_duration")]
74 fn duration(&self) -> Option<gst::ClockTime> {
75 unsafe {
76 from_glib(ffi::ges_uri_clip_asset_get_duration(
77 self.as_ref().to_glib_none().0,
78 ))
79 }
80 }
81
82 #[doc(alias = "ges_uri_clip_asset_get_info")]
83 #[doc(alias = "get_info")]
84 fn info(&self) -> gst_pbutils::DiscovererInfo {
85 unsafe {
86 from_glib_none(ffi::ges_uri_clip_asset_get_info(const_override(
87 self.as_ref().to_glib_none().0,
88 )))
89 }
90 }
91
92 #[cfg(feature = "v1_18")]
93 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
94 #[doc(alias = "ges_uri_clip_asset_get_max_duration")]
95 #[doc(alias = "get_max_duration")]
96 fn max_duration(&self) -> Option<gst::ClockTime> {
97 unsafe {
98 from_glib(ffi::ges_uri_clip_asset_get_max_duration(
99 self.as_ref().to_glib_none().0,
100 ))
101 }
102 }
103
104 #[doc(alias = "ges_uri_clip_asset_get_stream_assets")]
105 #[doc(alias = "get_stream_assets")]
106 fn stream_assets(&self) -> Vec<UriSourceAsset> {
107 unsafe {
108 FromGlibPtrContainer::from_glib_none(ffi::ges_uri_clip_asset_get_stream_assets(
109 self.as_ref().to_glib_none().0,
110 ))
111 }
112 }
113
114 #[cfg(feature = "v1_18")]
115 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
116 #[doc(alias = "ges_uri_clip_asset_is_image")]
117 fn is_image(&self) -> bool {
118 unsafe {
119 from_glib(ffi::ges_uri_clip_asset_is_image(
120 self.as_ref().to_glib_none().0,
121 ))
122 }
123 }
124
125 fn set_duration(&self, duration: u64) {
126 ObjectExt::set_property(self.as_ref(), "duration", duration)
127 }
128
129 #[cfg(feature = "v1_18")]
130 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
131 #[doc(alias = "is-nested-timeline")]
132 fn is_nested_timeline(&self) -> bool {
133 ObjectExt::property(self.as_ref(), "is-nested-timeline")
134 }
135
136 #[doc(alias = "duration")]
137 fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
138 &self,
139 f: F,
140 ) -> SignalHandlerId {
141 unsafe extern "C" fn notify_duration_trampoline<
142 P: IsA<UriClipAsset>,
143 F: Fn(&P) + Send + Sync + 'static,
144 >(
145 this: *mut ffi::GESUriClipAsset,
146 _param_spec: glib::ffi::gpointer,
147 f: glib::ffi::gpointer,
148 ) {
149 let f: &F = &*(f as *const F);
150 f(UriClipAsset::from_glib_borrow(this).unsafe_cast_ref())
151 }
152 unsafe {
153 let f: Box_<F> = Box_::new(f);
154 connect_raw(
155 self.as_ptr() as *mut _,
156 b"notify::duration\0".as_ptr() as *const _,
157 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
158 notify_duration_trampoline::<Self, F> as *const (),
159 )),
160 Box_::into_raw(f),
161 )
162 }
163 }
164
165 #[cfg(feature = "v1_18")]
166 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
167 #[doc(alias = "is-nested-timeline")]
168 fn connect_is_nested_timeline_notify<F: Fn(&Self) + Send + Sync + 'static>(
169 &self,
170 f: F,
171 ) -> SignalHandlerId {
172 unsafe extern "C" fn notify_is_nested_timeline_trampoline<
173 P: IsA<UriClipAsset>,
174 F: Fn(&P) + Send + Sync + 'static,
175 >(
176 this: *mut ffi::GESUriClipAsset,
177 _param_spec: glib::ffi::gpointer,
178 f: glib::ffi::gpointer,
179 ) {
180 let f: &F = &*(f as *const F);
181 f(UriClipAsset::from_glib_borrow(this).unsafe_cast_ref())
182 }
183 unsafe {
184 let f: Box_<F> = Box_::new(f);
185 connect_raw(
186 self.as_ptr() as *mut _,
187 b"notify::is-nested-timeline\0".as_ptr() as *const _,
188 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
189 notify_is_nested_timeline_trampoline::<Self, F> as *const (),
190 )),
191 Box_::into_raw(f),
192 )
193 }
194 }
195}
196
197impl<O: IsA<UriClipAsset>> UriClipAssetExt for O {}