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
222mod sealed {
223    pub trait Sealed {}
224    impl<T: super::IsA<super::UriClip>> Sealed for T {}
225}
226
227/// Trait containing all [`struct@UriClip`] methods.
228///
229/// # Implementors
230///
231/// [`UriClip`][struct@crate::UriClip]
232pub trait UriClipExt: IsA<UriClip> + sealed::Sealed + 'static {
233    /// Get the location of the resource.
234    ///
235    /// # Returns
236    ///
237    /// The location of the resource.
238    #[doc(alias = "ges_uri_clip_get_uri")]
239    #[doc(alias = "get_uri")]
240    fn uri(&self) -> glib::GString {
241        unsafe { from_glib_none(ffi::ges_uri_clip_get_uri(self.as_ref().to_glib_none().0)) }
242    }
243
244    /// Lets you know if `self` is an image or not.
245    ///
246    /// # Returns
247    ///
248    /// [`true`] if `self` is a still image [`false`] otherwise.
249    #[doc(alias = "ges_uri_clip_is_image")]
250    fn is_image(&self) -> bool {
251        unsafe { from_glib(ffi::ges_uri_clip_is_image(self.as_ref().to_glib_none().0)) }
252    }
253
254    /// Lets you know if the audio track of `self` is muted or not.
255    ///
256    /// # Returns
257    ///
258    /// [`true`] if the audio track of `self` is muted, [`false`] otherwise.
259    #[doc(alias = "ges_uri_clip_is_muted")]
260    fn is_muted(&self) -> bool {
261        unsafe { from_glib(ffi::ges_uri_clip_is_muted(self.as_ref().to_glib_none().0)) }
262    }
263
264    /// Sets whether the clip is a still image or not.
265    /// ## `is_image`
266    /// [`true`] if `self` is a still image, [`false`] otherwise
267    #[doc(alias = "ges_uri_clip_set_is_image")]
268    #[doc(alias = "is-image")]
269    fn set_is_image(&self, is_image: bool) {
270        unsafe {
271            ffi::ges_uri_clip_set_is_image(self.as_ref().to_glib_none().0, is_image.into_glib());
272        }
273    }
274
275    /// Sets whether the audio track of this clip is muted or not.
276    /// ## `mute`
277    /// [`true`] to mute `self` audio track, [`false`] to unmute it
278    #[doc(alias = "ges_uri_clip_set_mute")]
279    #[doc(alias = "mute")]
280    fn set_mute(&self, mute: bool) {
281        unsafe {
282            ffi::ges_uri_clip_set_mute(self.as_ref().to_glib_none().0, mute.into_glib());
283        }
284    }
285
286    #[doc(alias = "is-image")]
287    fn connect_is_image_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
288        unsafe extern "C" fn notify_is_image_trampoline<P: IsA<UriClip>, F: Fn(&P) + 'static>(
289            this: *mut ffi::GESUriClip,
290            _param_spec: glib::ffi::gpointer,
291            f: glib::ffi::gpointer,
292        ) {
293            let f: &F = &*(f as *const F);
294            f(UriClip::from_glib_borrow(this).unsafe_cast_ref())
295        }
296        unsafe {
297            let f: Box_<F> = Box_::new(f);
298            connect_raw(
299                self.as_ptr() as *mut _,
300                b"notify::is-image\0".as_ptr() as *const _,
301                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
302                    notify_is_image_trampoline::<Self, F> as *const (),
303                )),
304                Box_::into_raw(f),
305            )
306        }
307    }
308
309    #[doc(alias = "mute")]
310    fn connect_mute_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
311        unsafe extern "C" fn notify_mute_trampoline<P: IsA<UriClip>, F: Fn(&P) + 'static>(
312            this: *mut ffi::GESUriClip,
313            _param_spec: glib::ffi::gpointer,
314            f: glib::ffi::gpointer,
315        ) {
316            let f: &F = &*(f as *const F);
317            f(UriClip::from_glib_borrow(this).unsafe_cast_ref())
318        }
319        unsafe {
320            let f: Box_<F> = Box_::new(f);
321            connect_raw(
322                self.as_ptr() as *mut _,
323                b"notify::mute\0".as_ptr() as *const _,
324                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
325                    notify_mute_trampoline::<Self, F> as *const (),
326                )),
327                Box_::into_raw(f),
328            )
329        }
330    }
331}
332
333impl<O: IsA<UriClip>> UriClipExt for O {}