gstreamer_editing_services/auto/uri_clip.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
6use crate::{ffi, Clip, Container, Extractable, MetaContainer, SourceClip, TimelineElement};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// Represents all the output streams from a particular uri. It is assumed that
16 /// the URI points to a file of some type.
17 ///
18 /// ## Properties
19 ///
20 ///
21 /// #### `is-image`
22 /// Whether this uri clip represents a still image or not. This must be set
23 /// before create_track_elements is called.
24 ///
25 /// Readable | Writeable | Construct
26 ///
27 ///
28 /// #### `mute`
29 /// Whether the sound will be played or not.
30 ///
31 /// Readable | Writeable | Construct
32 ///
33 ///
34 /// #### `supported-formats`
35 /// Readable | Writeable | Construct
36 ///
37 ///
38 /// #### `uri`
39 /// The location of the file/resource to use.
40 ///
41 /// Readable | Writeable | Construct Only
42 /// <details><summary><h4>Clip</h4></summary>
43 ///
44 ///
45 /// #### `duration-limit`
46 /// The maximum [`duration`][struct@crate::TimelineElement#duration] that can be *currently* set
47 /// for the clip, taking into account the [`in-point`][struct@crate::TimelineElement#in-point],
48 /// [`max-duration`][struct@crate::TimelineElement#max-duration], [`active`][struct@crate::TrackElement#active], and
49 /// [`track`][struct@crate::TrackElement#track] properties of its children, as well as any
50 /// time effects. If there is no limit, this will be set to
51 /// `GST_CLOCK_TIME_NONE`.
52 ///
53 /// Note that whilst a clip has no children in any tracks, the limit will
54 /// be unknown, and similarly set to `GST_CLOCK_TIME_NONE`.
55 ///
56 /// If the duration-limit would ever go below the current
57 /// [`duration`][struct@crate::TimelineElement#duration] of the clip due to a change in the above
58 /// variables, its [`duration`][struct@crate::TimelineElement#duration] will be set to the new
59 /// limit.
60 ///
61 /// Readable
62 ///
63 ///
64 /// #### `layer`
65 /// The layer this clip lies in.
66 ///
67 /// If you want to connect to this property's [`notify`][struct@crate::glib::Object#notify] signal,
68 /// you should connect to it with `g_signal_connect_after()` since the
69 /// signal emission may be stopped internally.
70 ///
71 /// Readable
72 ///
73 ///
74 /// #### `supported-formats`
75 /// The [`TrackType`][crate::TrackType]-s that the clip supports, which it can create
76 /// [`TrackElement`][crate::TrackElement]-s for. Note that this can be a combination of
77 /// [`TrackType`][crate::TrackType] flags to indicate support for several
78 /// [`track-type`][struct@crate::TrackElement#track-type] elements.
79 ///
80 /// Readable | Writeable | Construct
81 /// </details>
82 /// <details><summary><h4>Container</h4></summary>
83 ///
84 ///
85 /// #### `height`
86 /// The span of the container's children's [`priority`][struct@crate::TimelineElement#priority]
87 /// values, which is the number of integers that lie between (inclusive)
88 /// the minimum and maximum priorities found amongst the container's
89 /// children (maximum - minimum + 1).
90 ///
91 /// Readable
92 /// </details>
93 /// <details><summary><h4>TimelineElement</h4></summary>
94 ///
95 ///
96 /// #### `duration`
97 /// The duration that the element is in effect for in the timeline (a
98 /// time difference in nanoseconds using the time coordinates of the
99 /// timeline). For example, for a source element, this would determine
100 /// for how long it should output its internal content for. For an
101 /// operation element, this would determine for how long its effect
102 /// should be applied to any source content.
103 ///
104 /// Readable | Writeable
105 ///
106 ///
107 /// #### `in-point`
108 /// The initial offset to use internally when outputting content (in
109 /// nanoseconds, but in the time coordinates of the internal content).
110 ///
111 /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
112 /// file, the "internal content" is the media file data, and the
113 /// in-point would correspond to some timestamp in the media file.
114 /// When playing the timeline, and when the element is first reached at
115 /// timeline-time [`start`][struct@crate::TimelineElement#start], it will begin outputting the
116 /// data from the timestamp in-point **onwards**, until it reaches the
117 /// end of its [`duration`][struct@crate::TimelineElement#duration] in the timeline.
118 ///
119 /// For elements that have no internal content, this should be kept
120 /// as 0.
121 ///
122 /// Readable | Writeable
123 ///
124 ///
125 /// #### `max-duration`
126 /// The full duration of internal content that is available (a time
127 /// difference in nanoseconds using the time coordinates of the internal
128 /// content).
129 ///
130 /// This will act as a cap on the [`in-point`][struct@crate::TimelineElement#in-point] of the
131 /// element (which is in the same time coordinates), and will sometimes
132 /// be used to limit the [`duration`][struct@crate::TimelineElement#duration] of the element in
133 /// the timeline.
134 ///
135 /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
136 /// file, this would be the length of the media file.
137 ///
138 /// For elements that have no internal content, or whose content is
139 /// indefinite, this should be kept as `GST_CLOCK_TIME_NONE`.
140 ///
141 /// Readable | Writeable | Construct
142 ///
143 ///
144 /// #### `name`
145 /// The name of the element. This should be unique within its timeline.
146 ///
147 /// Readable | Writeable | Construct
148 ///
149 ///
150 /// #### `parent`
151 /// The parent container of the element.
152 ///
153 /// Readable | Writeable
154 ///
155 ///
156 /// #### `priority`
157 /// The priority of the element.
158 ///
159 /// Readable | Writeable
160 ///
161 ///
162 /// #### `serialize`
163 /// Whether the element should be serialized.
164 ///
165 /// Readable | Writeable
166 ///
167 ///
168 /// #### `start`
169 /// The starting position of the element in the timeline (in nanoseconds
170 /// and in the time coordinates of the timeline). For example, for a
171 /// source element, this would determine the time at which it should
172 /// start outputting its internal content. For an operation element, this
173 /// would determine the time at which it should start applying its effect
174 /// to any source content.
175 ///
176 /// Readable | Writeable
177 ///
178 ///
179 /// #### `timeline`
180 /// The timeline that the element lies within.
181 ///
182 /// Readable | Writeable
183 /// </details>
184 ///
185 /// # Implements
186 ///
187 /// [`UriClipExt`][trait@crate::prelude::UriClipExt], [`SourceClipExt`][trait@crate::prelude::SourceClipExt], [`ClipExt`][trait@crate::prelude::ClipExt], [`GESContainerExt`][trait@crate::prelude::GESContainerExt], [`TimelineElementExt`][trait@crate::prelude::TimelineElementExt], [`trait@glib::ObjectExt`], [`ExtractableExt`][trait@crate::prelude::ExtractableExt], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt], [`TimelineElementExtManual`][trait@crate::prelude::TimelineElementExtManual]
188 #[doc(alias = "GESUriClip")]
189 pub struct UriClip(Object<ffi::GESUriClip, ffi::GESUriClipClass>) @extends SourceClip, Clip, Container, TimelineElement, @implements Extractable, MetaContainer;
190
191 match fn {
192 type_ => || ffi::ges_uri_clip_get_type(),
193 }
194}
195
196impl UriClip {
197 pub const NONE: Option<&'static UriClip> = None;
198
199 /// Creates a new [`UriClip`][crate::UriClip] for the provided `uri`.
200 ///
201 /// > **WARNING**: This function might 'discover` `uri` **synchrounously**, it is
202 /// > an IO and processing intensive task that you probably don't want to run in
203 /// > an application mainloop. Have a look at `ges_asset_request_async` to see how
204 /// > to make that operation happen **asynchronously**.
205 /// ## `uri`
206 /// the URI the source should control
207 ///
208 /// # Returns
209 ///
210 /// The newly created [`UriClip`][crate::UriClip], or
211 /// [`None`] if there was an error.
212 #[doc(alias = "ges_uri_clip_new")]
213 pub fn new(uri: &str) -> Result<UriClip, glib::BoolError> {
214 assert_initialized_main_thread!();
215 unsafe {
216 Option::<_>::from_glib_none(ffi::ges_uri_clip_new(uri.to_glib_none().0))
217 .ok_or_else(|| glib::bool_error!("Failed to create Uri clip from Uri"))
218 }
219 }
220}
221
222/// Trait containing all [`struct@UriClip`] methods.
223///
224/// # Implementors
225///
226/// [`UriClip`][struct@crate::UriClip]
227pub trait UriClipExt: IsA<UriClip> + 'static {
228 /// Get the location of the resource.
229 ///
230 /// # Returns
231 ///
232 /// The location of the resource.
233 #[doc(alias = "ges_uri_clip_get_uri")]
234 #[doc(alias = "get_uri")]
235 fn uri(&self) -> glib::GString {
236 unsafe { from_glib_none(ffi::ges_uri_clip_get_uri(self.as_ref().to_glib_none().0)) }
237 }
238
239 /// Lets you know if `self` is an image or not.
240 ///
241 /// # Returns
242 ///
243 /// [`true`] if `self` is a still image [`false`] otherwise.
244 #[doc(alias = "ges_uri_clip_is_image")]
245 fn is_image(&self) -> bool {
246 unsafe { from_glib(ffi::ges_uri_clip_is_image(self.as_ref().to_glib_none().0)) }
247 }
248
249 /// Lets you know if the audio track of `self` is muted or not.
250 ///
251 /// # Returns
252 ///
253 /// [`true`] if the audio track of `self` is muted, [`false`] otherwise.
254 #[doc(alias = "ges_uri_clip_is_muted")]
255 fn is_muted(&self) -> bool {
256 unsafe { from_glib(ffi::ges_uri_clip_is_muted(self.as_ref().to_glib_none().0)) }
257 }
258
259 /// Sets whether the clip is a still image or not.
260 /// ## `is_image`
261 /// [`true`] if `self` is a still image, [`false`] otherwise
262 #[doc(alias = "ges_uri_clip_set_is_image")]
263 #[doc(alias = "is-image")]
264 fn set_is_image(&self, is_image: bool) {
265 unsafe {
266 ffi::ges_uri_clip_set_is_image(self.as_ref().to_glib_none().0, is_image.into_glib());
267 }
268 }
269
270 /// Sets whether the audio track of this clip is muted or not.
271 /// ## `mute`
272 /// [`true`] to mute `self` audio track, [`false`] to unmute it
273 #[doc(alias = "ges_uri_clip_set_mute")]
274 #[doc(alias = "mute")]
275 fn set_mute(&self, mute: bool) {
276 unsafe {
277 ffi::ges_uri_clip_set_mute(self.as_ref().to_glib_none().0, mute.into_glib());
278 }
279 }
280
281 #[doc(alias = "is-image")]
282 fn connect_is_image_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
283 unsafe extern "C" fn notify_is_image_trampoline<P: IsA<UriClip>, F: Fn(&P) + 'static>(
284 this: *mut ffi::GESUriClip,
285 _param_spec: glib::ffi::gpointer,
286 f: glib::ffi::gpointer,
287 ) {
288 let f: &F = &*(f as *const F);
289 f(UriClip::from_glib_borrow(this).unsafe_cast_ref())
290 }
291 unsafe {
292 let f: Box_<F> = Box_::new(f);
293 connect_raw(
294 self.as_ptr() as *mut _,
295 c"notify::is-image".as_ptr() as *const _,
296 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
297 notify_is_image_trampoline::<Self, F> as *const (),
298 )),
299 Box_::into_raw(f),
300 )
301 }
302 }
303
304 #[doc(alias = "mute")]
305 fn connect_mute_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
306 unsafe extern "C" fn notify_mute_trampoline<P: IsA<UriClip>, F: Fn(&P) + 'static>(
307 this: *mut ffi::GESUriClip,
308 _param_spec: glib::ffi::gpointer,
309 f: glib::ffi::gpointer,
310 ) {
311 let f: &F = &*(f as *const F);
312 f(UriClip::from_glib_borrow(this).unsafe_cast_ref())
313 }
314 unsafe {
315 let f: Box_<F> = Box_::new(f);
316 connect_raw(
317 self.as_ptr() as *mut _,
318 c"notify::mute".as_ptr() as *const _,
319 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
320 notify_mute_trampoline::<Self, F> as *const (),
321 )),
322 Box_::into_raw(f),
323 )
324 }
325 }
326}
327
328impl<O: IsA<UriClip>> UriClipExt for O {}