Skip to main content

gstreamer_editing_services/auto/
track.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::{MetaContainer, Timeline, TrackElement, TrackType, ffi};
8use glib::{
9    object::ObjectType as _,
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// A [`Track`][crate::Track] acts an output source for a [`Timeline`][crate::Timeline]. Each one
18    /// essentially provides an additional [`gst::Pad`][crate::gst::Pad] for the timeline, with
19    /// [`restriction-caps`][struct@crate::Track#restriction-caps] capabilities. Internally, a track
20    /// wraps an `nlecomposition` filtered by a `capsfilter`.
21    ///
22    /// A track will contain a number of [`TrackElement`][crate::TrackElement]-s, and its role is
23    /// to select and activate these elements according to their timings when
24    /// the timeline in played. For example, a track would activate a
25    /// [`Source`][crate::Source] when its [`start`][struct@crate::TimelineElement#start] is reached by outputting
26    /// its data for its [`duration`][struct@crate::TimelineElement#duration]. Similarly, a
27    /// [`Operation`][crate::Operation] would be activated by applying its effect to the source
28    /// data, starting from its [`start`][struct@crate::TimelineElement#start] time and lasting for
29    /// its [`duration`][struct@crate::TimelineElement#duration].
30    ///
31    /// For most users, it will usually be sufficient to add newly created
32    /// tracks to a timeline, but never directly add an element to a track.
33    /// Whenever a [`Clip`][crate::Clip] is added to a timeline, the clip adds its
34    /// elements to the timeline's tracks and assumes responsibility for
35    /// updating them.
36    ///
37    /// ## Properties
38    ///
39    ///
40    /// #### `caps`
41    ///  The capabilities used to choose the output of the [`Track`][crate::Track]'s
42    /// elements. Internally, this is used to select output streams when
43    /// several may be available, by determining whether its [`gst::Pad`][crate::gst::Pad] is
44    /// compatible (see `NleObject:caps` for `nlecomposition`). As such,
45    /// this is used as a weaker indication of the desired output type of the
46    /// track, **before** the [`restriction-caps`][struct@crate::Track#restriction-caps] is applied.
47    /// Therefore, this should be set to a *generic* superset of the
48    /// [`restriction-caps`][struct@crate::Track#restriction-caps], such as "video/x-raw(ANY)". In addition,
49    /// it should match with the track's [`track-type`][struct@crate::Track#track-type].
50    ///
51    /// Note that when you set this property, the `GstCapsFeatures` of all its
52    /// [`gst::Structure`][crate::gst::Structure]-s will be automatically set to `GST_CAPS_FEATURES_ANY`.
53    ///
54    /// Once a track has been added to a [`Timeline`][crate::Timeline], you should not change
55    /// this.
56    ///
57    /// Default value: `GST_CAPS_ANY`.
58    ///
59    /// Readable | Writeable | Construct Only
60    ///
61    ///
62    /// #### `duration`
63    ///  Current duration of the track
64    ///
65    /// Default value: O
66    ///
67    /// Readable
68    ///
69    ///
70    /// #### `id`
71    ///  The `nlecomposition:id` of the underlying `nlecomposition`.
72    ///
73    /// Readable | Writeable
74    ///
75    ///
76    /// #### `mixing`
77    ///  Whether the track should support the mixing of [`Layer`][crate::Layer] data, such
78    /// as composing the video data of each layer (when part of the video
79    /// data is transparent, the next layer will become visible) or adding
80    /// together the audio data. As such, for audio and video tracks, you'll
81    /// likely want to keep this set to [`true`].
82    ///
83    /// Readable | Writeable | Construct
84    ///
85    ///
86    /// #### `restriction-caps`
87    ///  The capabilities that specifies the final output format of the
88    /// [`Track`][crate::Track]. For example, for a video track, it would specify the
89    /// height, width, framerate and other properties of the stream.
90    ///
91    /// You may change this property after the track has been added to a
92    /// [`Timeline`][crate::Timeline], but it must remain compatible with the track's
93    /// [`caps`][struct@crate::Track#caps].
94    ///
95    /// Default value: `GST_CAPS_ANY`.
96    ///
97    /// Readable | Writeable
98    ///
99    ///
100    /// #### `track-type`
101    ///  The track type of the track. This controls the type of
102    /// [`TrackElement`][crate::TrackElement]-s that can be added to the track. This should
103    /// match with the track's [`caps`][struct@crate::Track#caps].
104    ///
105    /// Once a track has been added to a [`Timeline`][crate::Timeline], you should not change
106    /// this.
107    ///
108    /// Readable | Writeable | Construct Only
109    /// <details><summary><h4>Bin</h4></summary>
110    ///
111    ///
112    /// #### `async-handling`
113    ///  If set to [`true`], the bin will handle asynchronous state changes.
114    /// This should be used only if the bin subclass is modifying the state
115    /// of its children on its own.
116    ///
117    /// Readable | Writeable
118    ///
119    ///
120    /// #### `message-forward`
121    ///  Forward all children messages, even those that would normally be filtered by
122    /// the bin. This can be interesting when one wants to be notified of the EOS
123    /// state of individual elements, for example.
124    ///
125    /// The messages are converted to an ELEMENT message with the bin as the
126    /// source. The structure of the message is named `GstBinForwarded` and contains
127    /// a field named `message` that contains the original forwarded `GstMessage`.
128    ///
129    /// Readable | Writeable
130    /// </details>
131    /// <details><summary><h4>Object</h4></summary>
132    ///
133    ///
134    /// #### `name`
135    ///  Readable | Writeable | Construct
136    ///
137    ///
138    /// #### `parent`
139    ///  The parent of the object. Please note, that when changing the 'parent'
140    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
141    /// signals due to locking issues. In some cases one can use
142    /// [`element-added`][struct@crate::gst::Bin#element-added] or [`element-removed`][struct@crate::gst::Bin#element-removed] signals on the parent to
143    /// achieve a similar effect.
144    ///
145    /// Readable | Writeable
146    /// </details>
147    ///
148    /// ## Signals
149    ///
150    ///
151    /// #### `commited`
152    ///  This signal will be emitted once the changes initiated by
153    /// [`GESTrackExt::commit()`][crate::prelude::GESTrackExt::commit()] have been executed in the backend. In particular,
154    /// this will be emitted whenever the underlying `nlecomposition` has been
155    /// committed (see `nlecomposition::commited`).
156    ///
157    ///
158    ///
159    ///
160    /// #### `track-element-added`
161    ///  Will be emitted after a track element is added to the track.
162    ///
163    ///
164    ///
165    ///
166    /// #### `track-element-removed`
167    ///  Will be emitted after a track element is removed from the track.
168    ///
169    ///
170    /// <details><summary><h4>Bin</h4></summary>
171    ///
172    ///
173    /// #### `deep-element-added`
174    ///  Will be emitted after the element was added to `sub_bin`.
175    ///
176    ///
177    ///
178    ///
179    /// #### `deep-element-removed`
180    ///  Will be emitted after the element was removed from `sub_bin`.
181    ///
182    ///
183    ///
184    ///
185    /// #### `do-latency`
186    ///  Will be emitted when the bin needs to perform latency calculations. This
187    /// signal is only emitted for toplevel bins or when [`async-handling`][struct@crate::gst::Bin#async-handling] is
188    /// enabled.
189    ///
190    /// Only one signal handler is invoked. If no signals are connected, the
191    /// default handler is invoked, which will query and distribute the lowest
192    /// possible latency to all sinks.
193    ///
194    /// Connect to this signal if the default latency calculations are not
195    /// sufficient, like when you need different latencies for different sinks in
196    /// the same pipeline.
197    ///
198    ///
199    ///
200    ///
201    /// #### `element-added`
202    ///  Will be emitted after the element was added to the bin.
203    ///
204    ///
205    ///
206    ///
207    /// #### `element-removed`
208    ///  Will be emitted after the element was removed from the bin.
209    ///
210    ///
211    /// </details>
212    /// <details><summary><h4>Element</h4></summary>
213    ///
214    ///
215    /// #### `no-more-pads`
216    ///  This signals that the element will not generate more dynamic pads.
217    /// Note that this signal will usually be emitted from the context of
218    /// the streaming thread.
219    ///
220    ///
221    ///
222    ///
223    /// #### `pad-added`
224    ///  a new [`gst::Pad`][crate::gst::Pad] has been added to the element. Note that this signal will
225    /// usually be emitted from the context of the streaming thread. Also keep in
226    /// mind that if you add new elements to the pipeline in the signal handler
227    /// you will need to set them to the desired target state with
228    /// [`ElementExtManual::set_state()`][crate::gst::prelude::ElementExtManual::set_state()] or [`ElementExtManual::sync_state_with_parent()`][crate::gst::prelude::ElementExtManual::sync_state_with_parent()].
229    ///
230    ///
231    ///
232    ///
233    /// #### `pad-removed`
234    ///  a [`gst::Pad`][crate::gst::Pad] has been removed from the element
235    ///
236    ///
237    /// </details>
238    /// <details><summary><h4>Object</h4></summary>
239    ///
240    ///
241    /// #### `deep-notify`
242    ///  The deep notify signal is used to be notified of property changes. It is
243    /// typically attached to the toplevel bin to receive notifications from all
244    /// the elements contained in that bin.
245    ///
246    /// Detailed
247    /// </details>
248    /// <details><summary><h4>ChildProxy</h4></summary>
249    ///
250    ///
251    /// #### `child-added`
252    ///  Will be emitted after the `object` was added to the `child_proxy`.
253    ///
254    ///
255    ///
256    ///
257    /// #### `child-removed`
258    ///  Will be emitted after the `object` was removed from the `child_proxy`.
259    ///
260    ///
261    /// </details>
262    /// <details><summary><h4>MetaContainer</h4></summary>
263    ///
264    ///
265    /// #### `notify-meta`
266    ///  This is emitted for a meta container whenever the metadata under one
267    /// of its fields changes, is set for the first time, or is removed. In
268    /// the latter case, `value` will be [`None`].
269    ///
270    /// Detailed
271    /// </details>
272    ///
273    /// # Implements
274    ///
275    /// [`GESTrackExt`][trait@crate::prelude::GESTrackExt], [`trait@gst::prelude::BinExt`], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::GstObjectExt`], [`trait@glib::ObjectExt`], [`trait@gst::prelude::ChildProxyExt`], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt]
276    #[doc(alias = "GESTrack")]
277    pub struct Track(Object<ffi::GESTrack, ffi::GESTrackClass>) @extends gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, MetaContainer;
278
279    match fn {
280        type_ => || ffi::ges_track_get_type(),
281    }
282}
283
284impl Track {
285    pub const NONE: Option<&'static Track> = None;
286
287    /// Creates a new track with the given track-type and caps.
288    ///
289    /// If `type_` is [`TrackType::VIDEO`][crate::TrackType::VIDEO], and `caps` is a subset of
290    /// "video/x-raw(ANY)", then a [`VideoTrack`][crate::VideoTrack] is created. This will
291    /// automatically choose a gap creation method suitable for video data. You
292    /// will likely want to set [`restriction-caps`][struct@crate::Track#restriction-caps] separately. You may
293    /// prefer to use the [`VideoTrack::new()`][crate::VideoTrack::new()] method instead.
294    ///
295    /// If `type_` is [`TrackType::AUDIO`][crate::TrackType::AUDIO], and `caps` is a subset of
296    /// "audio/x-raw(ANY)", then a [`AudioTrack`][crate::AudioTrack] is created. This will
297    /// automatically choose a gap creation method suitable for audio data, and
298    /// will set the [`restriction-caps`][struct@crate::Track#restriction-caps] to the default for
299    /// [`AudioTrack`][crate::AudioTrack]. You may prefer to use the [`AudioTrack::new()`][crate::AudioTrack::new()] method
300    /// instead.
301    ///
302    /// Otherwise, a plain [`Track`][crate::Track] is returned. You will likely want to set
303    /// the [`restriction-caps`][struct@crate::Track#restriction-caps] and call
304    /// `ges_track_set_create_element_for_gap_func()` on the returned track.
305    /// ## `type_`
306    /// The [`track-type`][struct@crate::Track#track-type] for the track
307    /// ## `caps`
308    /// The [`caps`][struct@crate::Track#caps] for the track
309    ///
310    /// # Returns
311    ///
312    /// A new track.
313    #[doc(alias = "ges_track_new")]
314    pub fn new(type_: TrackType, caps: gst::Caps) -> Track {
315        assert_initialized_main_thread!();
316        unsafe { from_glib_none(ffi::ges_track_new(type_.into_glib(), caps.into_glib_ptr())) }
317    }
318}
319
320/// Trait containing all [`struct@Track`] methods.
321///
322/// # Implementors
323///
324/// [`AudioTrack`][struct@crate::AudioTrack], [`Track`][struct@crate::Track], [`VideoTrack`][struct@crate::VideoTrack]
325pub trait GESTrackExt: IsA<Track> + 'static {
326    /// See [`add_element()`][Self::add_element()], which also gives an error.
327    /// ## `object`
328    /// The element to add
329    ///
330    /// # Returns
331    ///
332    /// [`true`] if `object` was successfully added to `self`.
333    #[doc(alias = "ges_track_add_element")]
334    fn add_element(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::error::BoolError> {
335        unsafe {
336            glib::result_from_gboolean!(
337                ffi::ges_track_add_element(
338                    self.as_ref().to_glib_none().0,
339                    object.as_ref().to_glib_none().0
340                ),
341                "Failed to add element"
342            )
343        }
344    }
345
346    /// Adds the given track element to the track, which takes ownership of the
347    /// element.
348    ///
349    /// Note that this can fail if it would break a configuration rule of the
350    /// track's [`Timeline`][crate::Timeline].
351    ///
352    /// Note that a [`TrackElement`][crate::TrackElement] can only be added to one track.
353    /// ## `object`
354    /// The element to add
355    ///
356    /// # Returns
357    ///
358    /// [`true`] if `object` was successfully added to `self`.
359    #[cfg(feature = "v1_18")]
360    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
361    #[doc(alias = "ges_track_add_element_full")]
362    fn add_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
363        unsafe {
364            let mut error = std::ptr::null_mut();
365            let is_ok = ffi::ges_track_add_element_full(
366                self.as_ref().to_glib_none().0,
367                object.as_ref().to_glib_none().0,
368                &mut error,
369            );
370            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
371            if error.is_null() {
372                Ok(())
373            } else {
374                Err(from_glib_full(error))
375            }
376        }
377    }
378
379    /// Commits all the pending changes for the elements contained in the
380    /// track.
381    ///
382    /// When changes are made to the timing or priority of elements within a
383    /// track, they are not directly executed for the underlying
384    /// `nlecomposition` and its children. This method will finally execute
385    /// these changes so they are reflected in the data output of the track.
386    ///
387    /// Any pending changes will be executed in the backend. The
388    /// [`commited`][struct@crate::Timeline#commited] signal will be emitted once this has completed.
389    ///
390    /// Note that [`TimelineExt::commit()`][crate::prelude::TimelineExt::commit()] will call this method on all of its
391    /// tracks, so you are unlikely to need to use this directly.
392    ///
393    /// # Returns
394    ///
395    /// [`true`] if pending changes were committed, or [`false`] if nothing
396    /// needed to be committed.
397    #[doc(alias = "ges_track_commit")]
398    fn commit(&self) -> bool {
399        unsafe { from_glib(ffi::ges_track_commit(self.as_ref().to_glib_none().0)) }
400    }
401
402    /// Get the [`caps`][struct@crate::Track#caps] of the track.
403    ///
404    /// # Deprecated since 1.30
405    ///
406    /// Use [`caps_full()`][Self::caps_full()] instead for MT-safety.
407    ///
408    /// # Returns
409    ///
410    /// The caps of `self`.
411    #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
412    #[allow(deprecated)]
413    #[doc(alias = "ges_track_get_caps")]
414    #[doc(alias = "get_caps")]
415    fn caps(&self) -> Option<gst::Caps> {
416        unsafe { from_glib_none(ffi::ges_track_get_caps(self.as_ref().to_glib_none().0)) }
417    }
418
419    /// Get the [`caps`][struct@crate::Track#caps] of the track.
420    ///
421    /// # Returns
422    ///
423    /// The caps of `self`.
424    #[cfg(feature = "v1_30")]
425    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
426    #[doc(alias = "ges_track_get_caps_full")]
427    #[doc(alias = "get_caps_full")]
428    fn caps_full(&self) -> Option<gst::Caps> {
429        unsafe { from_glib_full(ffi::ges_track_get_caps_full(self.as_ref().to_glib_none().0)) }
430    }
431
432    /// Gets the track elements contained in the track. The returned list is
433    /// sorted by the element's [`priority`][struct@crate::TimelineElement#priority] and
434    /// [`start`][struct@crate::TimelineElement#start].
435    ///
436    /// # Returns
437    ///
438    /// A list of
439    /// all the [`TrackElement`][crate::TrackElement]-s in `self`.
440    #[doc(alias = "ges_track_get_elements")]
441    #[doc(alias = "get_elements")]
442    fn elements(&self) -> Vec<TrackElement> {
443        unsafe {
444            FromGlibPtrContainer::from_glib_full(ffi::ges_track_get_elements(
445                self.as_ref().to_glib_none().0,
446            ))
447        }
448    }
449
450    /// Gets the [`mixing`][struct@crate::Track#mixing] of the track.
451    ///
452    /// # Returns
453    ///
454    /// Whether `self` is mixing.
455    #[doc(alias = "ges_track_get_mixing")]
456    #[doc(alias = "get_mixing")]
457    #[doc(alias = "mixing")]
458    fn is_mixing(&self) -> bool {
459        unsafe { from_glib(ffi::ges_track_get_mixing(self.as_ref().to_glib_none().0)) }
460    }
461
462    /// Gets the [`restriction-caps`][struct@crate::Track#restriction-caps] of the track.
463    ///
464    /// # Returns
465    ///
466    /// The restriction-caps of `self`.
467    #[cfg(feature = "v1_18")]
468    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
469    #[doc(alias = "ges_track_get_restriction_caps")]
470    #[doc(alias = "get_restriction_caps")]
471    #[doc(alias = "restriction-caps")]
472    fn restriction_caps(&self) -> Option<gst::Caps> {
473        unsafe {
474            from_glib_full(ffi::ges_track_get_restriction_caps(
475                self.as_ref().to_glib_none().0,
476            ))
477        }
478    }
479
480    /// Get the timeline this track belongs to.
481    ///
482    /// # Deprecated since 1.30
483    ///
484    /// Use [`timeline_full()`][Self::timeline_full()] instead for MT-safety.
485    ///
486    /// # Returns
487    ///
488    /// The timeline that `self` belongs to, or [`None`] if
489    /// it does not belong to a timeline.
490    #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
491    #[allow(deprecated)]
492    #[doc(alias = "ges_track_get_timeline")]
493    #[doc(alias = "get_timeline")]
494    fn timeline(&self) -> Option<Timeline> {
495        unsafe { from_glib_none(ffi::ges_track_get_timeline(self.as_ref().to_glib_none().0)) }
496    }
497
498    /// Get the timeline this track belongs to.
499    ///
500    /// # Returns
501    ///
502    /// The timeline that `self` belongs to,
503    /// or [`None`] if it does not belong to a timeline.
504    #[cfg(feature = "v1_30")]
505    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
506    #[doc(alias = "ges_track_get_timeline_full")]
507    #[doc(alias = "get_timeline_full")]
508    fn timeline_full(&self) -> Option<Timeline> {
509        unsafe {
510            from_glib_full(ffi::ges_track_get_timeline_full(
511                self.as_ref().to_glib_none().0,
512            ))
513        }
514    }
515
516    /// See [`remove_element_full()`][Self::remove_element_full()], which also returns an error.
517    /// ## `object`
518    /// The element to remove
519    ///
520    /// # Returns
521    ///
522    /// [`true`] if `object` was successfully removed from `self`.
523    #[doc(alias = "ges_track_remove_element")]
524    fn remove_element(
525        &self,
526        object: &impl IsA<TrackElement>,
527    ) -> Result<(), glib::error::BoolError> {
528        unsafe {
529            glib::result_from_gboolean!(
530                ffi::ges_track_remove_element(
531                    self.as_ref().to_glib_none().0,
532                    object.as_ref().to_glib_none().0
533                ),
534                "Failed to remove element"
535            )
536        }
537    }
538
539    /// Removes the given track element from the track, which revokes
540    /// ownership of the element.
541    /// ## `object`
542    /// The element to remove
543    ///
544    /// # Returns
545    ///
546    /// [`true`] if `object` was successfully removed from `self`.
547    #[cfg(feature = "v1_18")]
548    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
549    #[doc(alias = "ges_track_remove_element_full")]
550    fn remove_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
551        unsafe {
552            let mut error = std::ptr::null_mut();
553            let is_ok = ffi::ges_track_remove_element_full(
554                self.as_ref().to_glib_none().0,
555                object.as_ref().to_glib_none().0,
556                &mut error,
557            );
558            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
559            if error.is_null() {
560                Ok(())
561            } else {
562                Err(from_glib_full(error))
563            }
564        }
565    }
566
567    //#[doc(alias = "ges_track_set_create_element_for_gap_func")]
568    //fn set_create_element_for_gap_func<P: Fn() -> gst::Element + 'static>(&self, func: P) {
569    //    unsafe { TODO: call ffi:ges_track_set_create_element_for_gap_func() }
570    //}
571
572    /// Sets the [`mixing`][struct@crate::Track#mixing] for the track.
573    /// ## `mixing`
574    /// Whether `self` should be mixing
575    #[doc(alias = "ges_track_set_mixing")]
576    #[doc(alias = "mixing")]
577    fn set_mixing(&self, mixing: bool) {
578        unsafe {
579            ffi::ges_track_set_mixing(self.as_ref().to_glib_none().0, mixing.into_glib());
580        }
581    }
582
583    /// Sets the [`restriction-caps`][struct@crate::Track#restriction-caps] for the track.
584    ///
585    /// > **NOTE**: Restriction caps are **not** taken into account when
586    /// > using [`mode`][struct@crate::Pipeline#mode]=[`PipelineFlags::SMART_RENDER`][crate::PipelineFlags::SMART_RENDER].
587    /// ## `caps`
588    /// The new restriction-caps for `self`
589    #[doc(alias = "ges_track_set_restriction_caps")]
590    #[doc(alias = "restriction-caps")]
591    fn set_restriction_caps(&self, caps: &gst::Caps) {
592        unsafe {
593            ffi::ges_track_set_restriction_caps(
594                self.as_ref().to_glib_none().0,
595                caps.to_glib_none().0,
596            );
597        }
598    }
599
600    /// Informs the track that it belongs to the given timeline. Calling this
601    /// does not actually add the track to the timeline. For that, you should
602    /// use [`TimelineExt::add_track()`][crate::prelude::TimelineExt::add_track()], which will also take care of informing
603    /// the track that it belongs to the timeline. As such, there is no need
604    /// for you to call this method.
605    #[doc(alias = "ges_track_set_timeline")]
606    fn set_timeline(&self, timeline: &impl IsA<Timeline>) {
607        unsafe {
608            ffi::ges_track_set_timeline(
609                self.as_ref().to_glib_none().0,
610                timeline.as_ref().to_glib_none().0,
611            );
612        }
613    }
614
615    /// Updates the [`restriction-caps`][struct@crate::Track#restriction-caps] of the track using the fields
616    /// found in the given caps. Each of the [`gst::Structure`][crate::gst::Structure]-s in `caps` is
617    /// compared against the existing structure with the same index in the
618    /// current [`restriction-caps`][struct@crate::Track#restriction-caps]. If there is no corresponding
619    /// existing structure at that index, then the new structure is simply
620    /// copied to that index. Otherwise, any fields in the new structure are
621    /// copied into the existing structure. This will replace existing values,
622    /// and may introduce new ones, but any fields 'missing' in the new
623    /// structure are left unchanged in the existing structure.
624    ///
625    /// For example, if the existing [`restriction-caps`][struct@crate::Track#restriction-caps] are
626    /// "video/x-raw, width=480, height=360", and the updating caps is
627    /// "video/x-raw, format=I420, width=500; video/x-bayer, width=400", then
628    /// the new [`restriction-caps`][struct@crate::Track#restriction-caps] after calling this will be
629    /// "video/x-raw, width=500, height=360, format=I420; video/x-bayer,
630    /// width=400".
631    /// ## `caps`
632    /// The caps to update the restriction-caps with
633    #[doc(alias = "ges_track_update_restriction_caps")]
634    fn update_restriction_caps(&self, caps: &gst::Caps) {
635        unsafe {
636            ffi::ges_track_update_restriction_caps(
637                self.as_ref().to_glib_none().0,
638                caps.to_glib_none().0,
639            );
640        }
641    }
642
643    /// Current duration of the track
644    ///
645    /// Default value: O
646    fn duration(&self) -> u64 {
647        ObjectExt::property(self.as_ref(), "duration")
648    }
649
650    /// The `nlecomposition:id` of the underlying `nlecomposition`.
651    #[cfg(feature = "v1_18")]
652    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
653    fn id(&self) -> Option<glib::GString> {
654        ObjectExt::property(self.as_ref(), "id")
655    }
656
657    /// The `nlecomposition:id` of the underlying `nlecomposition`.
658    #[cfg(feature = "v1_18")]
659    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
660    fn set_id(&self, id: Option<&str>) {
661        ObjectExt::set_property(self.as_ref(), "id", id)
662    }
663
664    #[cfg(not(feature = "v1_18"))]
665    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_18"))))]
666    #[doc(alias = "restriction-caps")]
667    fn restriction_caps(&self) -> Option<gst::Caps> {
668        ObjectExt::property(self.as_ref(), "restriction-caps")
669    }
670
671    /// The track type of the track. This controls the type of
672    /// [`TrackElement`][crate::TrackElement]-s that can be added to the track. This should
673    /// match with the track's [`caps`][struct@crate::Track#caps].
674    ///
675    /// Once a track has been added to a [`Timeline`][crate::Timeline], you should not change
676    /// this.
677    #[doc(alias = "track-type")]
678    fn track_type(&self) -> TrackType {
679        ObjectExt::property(self.as_ref(), "track-type")
680    }
681
682    /// This signal will be emitted once the changes initiated by
683    /// [`commit()`][Self::commit()] have been executed in the backend. In particular,
684    /// this will be emitted whenever the underlying `nlecomposition` has been
685    /// committed (see `nlecomposition::commited`).
686    #[doc(alias = "commited")]
687    fn connect_commited<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
688        unsafe extern "C" fn commited_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
689            this: *mut ffi::GESTrack,
690            f: glib::ffi::gpointer,
691        ) {
692            unsafe {
693                let f: &F = &*(f as *const F);
694                f(Track::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"commited".as_ptr(),
702                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
703                    commited_trampoline::<Self, F> as *const (),
704                )),
705                Box_::into_raw(f),
706            )
707        }
708    }
709
710    /// Will be emitted after a track element is added to the track.
711    /// ## `effect`
712    /// The element that was added
713    #[doc(alias = "track-element-added")]
714    fn connect_track_element_added<F: Fn(&Self, &TrackElement) + 'static>(
715        &self,
716        f: F,
717    ) -> SignalHandlerId {
718        unsafe extern "C" fn track_element_added_trampoline<
719            P: IsA<Track>,
720            F: Fn(&P, &TrackElement) + 'static,
721        >(
722            this: *mut ffi::GESTrack,
723            effect: *mut ffi::GESTrackElement,
724            f: glib::ffi::gpointer,
725        ) {
726            unsafe {
727                let f: &F = &*(f as *const F);
728                f(
729                    Track::from_glib_borrow(this).unsafe_cast_ref(),
730                    &from_glib_borrow(effect),
731                )
732            }
733        }
734        unsafe {
735            let f: Box_<F> = Box_::new(f);
736            connect_raw(
737                self.as_ptr() as *mut _,
738                c"track-element-added".as_ptr(),
739                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
740                    track_element_added_trampoline::<Self, F> as *const (),
741                )),
742                Box_::into_raw(f),
743            )
744        }
745    }
746
747    /// Will be emitted after a track element is removed from the track.
748    /// ## `effect`
749    /// The element that was removed
750    #[doc(alias = "track-element-removed")]
751    fn connect_track_element_removed<F: Fn(&Self, &TrackElement) + 'static>(
752        &self,
753        f: F,
754    ) -> SignalHandlerId {
755        unsafe extern "C" fn track_element_removed_trampoline<
756            P: IsA<Track>,
757            F: Fn(&P, &TrackElement) + 'static,
758        >(
759            this: *mut ffi::GESTrack,
760            effect: *mut ffi::GESTrackElement,
761            f: glib::ffi::gpointer,
762        ) {
763            unsafe {
764                let f: &F = &*(f as *const F);
765                f(
766                    Track::from_glib_borrow(this).unsafe_cast_ref(),
767                    &from_glib_borrow(effect),
768                )
769            }
770        }
771        unsafe {
772            let f: Box_<F> = Box_::new(f);
773            connect_raw(
774                self.as_ptr() as *mut _,
775                c"track-element-removed".as_ptr(),
776                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
777                    track_element_removed_trampoline::<Self, F> as *const (),
778                )),
779                Box_::into_raw(f),
780            )
781        }
782    }
783
784    #[doc(alias = "duration")]
785    fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
786        unsafe extern "C" fn notify_duration_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
787            this: *mut ffi::GESTrack,
788            _param_spec: glib::ffi::gpointer,
789            f: glib::ffi::gpointer,
790        ) {
791            unsafe {
792                let f: &F = &*(f as *const F);
793                f(Track::from_glib_borrow(this).unsafe_cast_ref())
794            }
795        }
796        unsafe {
797            let f: Box_<F> = Box_::new(f);
798            connect_raw(
799                self.as_ptr() as *mut _,
800                c"notify::duration".as_ptr(),
801                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
802                    notify_duration_trampoline::<Self, F> as *const (),
803                )),
804                Box_::into_raw(f),
805            )
806        }
807    }
808
809    #[cfg(feature = "v1_18")]
810    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
811    #[doc(alias = "id")]
812    fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
813        unsafe extern "C" fn notify_id_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
814            this: *mut ffi::GESTrack,
815            _param_spec: glib::ffi::gpointer,
816            f: glib::ffi::gpointer,
817        ) {
818            unsafe {
819                let f: &F = &*(f as *const F);
820                f(Track::from_glib_borrow(this).unsafe_cast_ref())
821            }
822        }
823        unsafe {
824            let f: Box_<F> = Box_::new(f);
825            connect_raw(
826                self.as_ptr() as *mut _,
827                c"notify::id".as_ptr(),
828                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
829                    notify_id_trampoline::<Self, F> as *const (),
830                )),
831                Box_::into_raw(f),
832            )
833        }
834    }
835
836    #[doc(alias = "mixing")]
837    fn connect_mixing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
838        unsafe extern "C" fn notify_mixing_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
839            this: *mut ffi::GESTrack,
840            _param_spec: glib::ffi::gpointer,
841            f: glib::ffi::gpointer,
842        ) {
843            unsafe {
844                let f: &F = &*(f as *const F);
845                f(Track::from_glib_borrow(this).unsafe_cast_ref())
846            }
847        }
848        unsafe {
849            let f: Box_<F> = Box_::new(f);
850            connect_raw(
851                self.as_ptr() as *mut _,
852                c"notify::mixing".as_ptr(),
853                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
854                    notify_mixing_trampoline::<Self, F> as *const (),
855                )),
856                Box_::into_raw(f),
857            )
858        }
859    }
860
861    #[doc(alias = "restriction-caps")]
862    fn connect_restriction_caps_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
863        unsafe extern "C" fn notify_restriction_caps_trampoline<
864            P: IsA<Track>,
865            F: Fn(&P) + 'static,
866        >(
867            this: *mut ffi::GESTrack,
868            _param_spec: glib::ffi::gpointer,
869            f: glib::ffi::gpointer,
870        ) {
871            unsafe {
872                let f: &F = &*(f as *const F);
873                f(Track::from_glib_borrow(this).unsafe_cast_ref())
874            }
875        }
876        unsafe {
877            let f: Box_<F> = Box_::new(f);
878            connect_raw(
879                self.as_ptr() as *mut _,
880                c"notify::restriction-caps".as_ptr(),
881                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
882                    notify_restriction_caps_trampoline::<Self, F> as *const (),
883                )),
884                Box_::into_raw(f),
885            )
886        }
887    }
888}
889
890impl<O: IsA<Track>> GESTrackExt for O {}