gstreamer_editing_services/auto/
container.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::{ffi, Edge, EditMode, Extractable, Layer, MetaContainer, TimelineElement};
8use glib::{
9    object::ObjectType as _,
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// A [`Container`][crate::Container] is a timeline element that controls other
18    /// [`TimelineElement`][crate::TimelineElement]-s, which are its children. In particular, it is
19    /// responsible for maintaining the relative [`start`][struct@crate::TimelineElement#start] and
20    /// [`duration`][struct@crate::TimelineElement#duration] times of its children. Therefore, if a
21    /// container is temporally adjusted or moved to a new layer, it may
22    /// accordingly adjust and move its children. Similarly, a change in one of
23    /// its children may prompt the parent to correspondingly change its
24    /// siblings.
25    ///
26    /// This is an Abstract Base Class, you cannot instantiate it.
27    ///
28    /// ## Properties
29    ///
30    ///
31    /// #### `height`
32    ///  The span of the container's children's [`priority`][struct@crate::TimelineElement#priority]
33    /// values, which is the number of integers that lie between (inclusive)
34    /// the minimum and maximum priorities found amongst the container's
35    /// children (maximum - minimum + 1).
36    ///
37    /// Readable
38    /// <details><summary><h4>TimelineElement</h4></summary>
39    ///
40    ///
41    /// #### `duration`
42    ///  The duration that the element is in effect for in the timeline (a
43    /// time difference in nanoseconds using the time coordinates of the
44    /// timeline). For example, for a source element, this would determine
45    /// for how long it should output its internal content for. For an
46    /// operation element, this would determine for how long its effect
47    /// should be applied to any source content.
48    ///
49    /// Readable | Writeable
50    ///
51    ///
52    /// #### `in-point`
53    ///  The initial offset to use internally when outputting content (in
54    /// nanoseconds, but in the time coordinates of the internal content).
55    ///
56    /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
57    /// file, the "internal content" is the media file data, and the
58    /// in-point would correspond to some timestamp in the media file.
59    /// When playing the timeline, and when the element is first reached at
60    /// timeline-time [`start`][struct@crate::TimelineElement#start], it will begin outputting the
61    /// data from the timestamp in-point **onwards**, until it reaches the
62    /// end of its [`duration`][struct@crate::TimelineElement#duration] in the timeline.
63    ///
64    /// For elements that have no internal content, this should be kept
65    /// as 0.
66    ///
67    /// Readable | Writeable
68    ///
69    ///
70    /// #### `max-duration`
71    ///  The full duration of internal content that is available (a time
72    /// difference in nanoseconds using the time coordinates of the internal
73    /// content).
74    ///
75    /// This will act as a cap on the [`in-point`][struct@crate::TimelineElement#in-point] of the
76    /// element (which is in the same time coordinates), and will sometimes
77    /// be used to limit the [`duration`][struct@crate::TimelineElement#duration] of the element in
78    /// the timeline.
79    ///
80    /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
81    /// file, this would be the length of the media file.
82    ///
83    /// For elements that have no internal content, or whose content is
84    /// indefinite, this should be kept as `GST_CLOCK_TIME_NONE`.
85    ///
86    /// Readable | Writeable | Construct
87    ///
88    ///
89    /// #### `name`
90    ///  The name of the element. This should be unique within its timeline.
91    ///
92    /// Readable | Writeable | Construct
93    ///
94    ///
95    /// #### `parent`
96    ///  The parent container of the element.
97    ///
98    /// Readable | Writeable
99    ///
100    ///
101    /// #### `priority`
102    ///  The priority of the element.
103    ///
104    /// Readable | Writeable
105    ///
106    ///
107    /// #### `serialize`
108    ///  Whether the element should be serialized.
109    ///
110    /// Readable | Writeable
111    ///
112    ///
113    /// #### `start`
114    ///  The starting position of the element in the timeline (in nanoseconds
115    /// and in the time coordinates of the timeline). For example, for a
116    /// source element, this would determine the time at which it should
117    /// start outputting its internal content. For an operation element, this
118    /// would determine the time at which it should start applying its effect
119    /// to any source content.
120    ///
121    /// Readable | Writeable
122    ///
123    ///
124    /// #### `timeline`
125    ///  The timeline that the element lies within.
126    ///
127    /// Readable | Writeable
128    /// </details>
129    ///
130    /// ## Signals
131    ///
132    ///
133    /// #### `child-added`
134    ///  Will be emitted after a child is added to the container. Usually,
135    /// you should connect with `g_signal_connect_after()` since the signal
136    /// may be stopped internally.
137    ///
138    ///
139    ///
140    ///
141    /// #### `child-removed`
142    ///  Will be emitted after a child is removed from the container.
143    ///
144    ///
145    /// <details><summary><h4>TimelineElement</h4></summary>
146    ///
147    ///
148    /// #### `child-property-added`
149    ///  Emitted when the element has a new child property registered. See
150    /// [`TimelineElementExt::add_child_property()`][crate::prelude::TimelineElementExt::add_child_property()].
151    ///
152    /// Note that some GES elements will be automatically created with
153    /// pre-registered children properties. You can use
154    /// [`TimelineElementExt::list_children_properties()`][crate::prelude::TimelineElementExt::list_children_properties()] to list these.
155    ///
156    ///
157    ///
158    ///
159    /// #### `child-property-removed`
160    ///  Emitted when the element has a child property unregistered. See
161    /// [`TimelineElementExt::remove_child_property()`][crate::prelude::TimelineElementExt::remove_child_property()].
162    ///
163    ///
164    ///
165    ///
166    /// #### `deep-notify`
167    ///  Emitted when a child of the element has one of its registered
168    /// properties set. See [`TimelineElementExt::add_child_property()`][crate::prelude::TimelineElementExt::add_child_property()].
169    /// Note that unlike [`notify`][struct@crate::glib::Object#notify], a child property name can not be
170    /// used as a signal detail.
171    ///
172    /// Detailed
173    /// </details>
174    /// <details><summary><h4>MetaContainer</h4></summary>
175    ///
176    ///
177    /// #### `notify-meta`
178    ///  This is emitted for a meta container whenever the metadata under one
179    /// of its fields changes, is set for the first time, or is removed. In
180    /// the latter case, `value` will be [`None`].
181    ///
182    /// Detailed
183    /// </details>
184    ///
185    /// # Implements
186    ///
187    /// [`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 = "GESContainer")]
189    pub struct Container(Object<ffi::GESContainer, ffi::GESContainerClass>) @extends TimelineElement, @implements Extractable, MetaContainer;
190
191    match fn {
192        type_ => || ffi::ges_container_get_type(),
193    }
194}
195
196impl Container {
197    pub const NONE: Option<&'static Container> = None;
198
199    /// Groups the containers into a single container by merging them. The
200    /// containers must all belong to the same [`timeline`][struct@crate::TimelineElement#timeline].
201    ///
202    /// If the elements are all [`Clip`][crate::Clip]-s then this method will attempt to
203    /// combine them all into a single [`Clip`][crate::Clip]. This should succeed if they:
204    /// share the same [`start`][struct@crate::TimelineElement#start], [`duration`][struct@crate::TimelineElement#duration]
205    /// and [`in-point`][struct@crate::TimelineElement#in-point]; exist in the same layer; and all of
206    /// the sources share the same [`Asset`][crate::Asset]. If this fails, or one of the
207    /// elements is not a [`Clip`][crate::Clip], this method will try to create a [`Group`][crate::Group]
208    /// instead.
209    /// ## `containers`
210    ///
211    /// The [`Container`][crate::Container]-s to group
212    ///
213    /// # Returns
214    ///
215    /// The container created by merging
216    /// `containers`, or [`None`] if they could not be merged into a single
217    /// container.
218    #[doc(alias = "ges_container_group")]
219    pub fn group(containers: &[Container]) -> Option<Container> {
220        assert_initialized_main_thread!();
221        unsafe { from_glib_none(ffi::ges_container_group(containers.to_glib_none().0)) }
222    }
223}
224
225/// Trait containing all [`struct@Container`] methods.
226///
227/// # Implementors
228///
229/// [`Clip`][struct@crate::Clip], [`Container`][struct@crate::Container], [`Group`][struct@crate::Group]
230pub trait GESContainerExt: IsA<Container> + 'static {
231    /// Adds a timeline element to the container. The element will now be a
232    /// child of the container (and the container will be the
233    /// [`parent`][struct@crate::TimelineElement#parent] of the added element), which means that it
234    /// is now controlled by the container. This may change the properties of
235    /// the child or the container, depending on the subclass.
236    ///
237    /// Additionally, the children properties of the newly added element will
238    /// be shared with the container, meaning they can also be read and set
239    /// using [`TimelineElementExt::child_property()`][crate::prelude::TimelineElementExt::child_property()] and
240    /// [`TimelineElementExt::set_child_property()`][crate::prelude::TimelineElementExt::set_child_property()] on the container.
241    /// ## `child`
242    /// The element to add as a child
243    ///
244    /// # Returns
245    ///
246    /// [`true`] if `child` was successfully added to `self`.
247    #[doc(alias = "ges_container_add")]
248    fn add(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
249        unsafe {
250            glib::result_from_gboolean!(
251                ffi::ges_container_add(
252                    self.as_ref().to_glib_none().0,
253                    child.as_ref().to_glib_none().0
254                ),
255                "Failed to add element"
256            )
257        }
258    }
259
260    /// Edits the container within its timeline.
261    ///
262    /// # Deprecated since 1.18
263    ///
264    /// use `ges_timeline_element_edit` instead.
265    /// ## `layers`
266    /// A whitelist of layers
267    /// where the edit can be performed, [`None`] allows all layers in the
268    /// timeline
269    /// ## `new_layer_priority`
270    /// The priority/index of the layer `self` should
271    /// be moved to. -1 means no move
272    /// ## `mode`
273    /// The edit mode
274    /// ## `edge`
275    /// The edge of `self` where the edit should occur
276    /// ## `position`
277    /// The edit position: a new location for the edge of `self`
278    /// (in nanoseconds)
279    ///
280    /// # Returns
281    ///
282    /// [`true`] if the edit of `self` completed, [`false`] on failure.
283    #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
284    #[allow(deprecated)]
285    #[doc(alias = "ges_container_edit")]
286    fn edit(
287        &self,
288        layers: &[Layer],
289        new_layer_priority: i32,
290        mode: EditMode,
291        edge: Edge,
292        position: u64,
293    ) -> Result<(), glib::error::BoolError> {
294        unsafe {
295            glib::result_from_gboolean!(
296                ffi::ges_container_edit(
297                    self.as_ref().to_glib_none().0,
298                    layers.to_glib_none().0,
299                    new_layer_priority,
300                    mode.into_glib(),
301                    edge.into_glib(),
302                    position
303                ),
304                "Failed to edit container"
305            )
306        }
307    }
308
309    /// Get the list of timeline elements contained in the container. If
310    /// `recursive` is [`true`], and the container contains other containers as
311    /// children, then their children will be added to the list, in addition to
312    /// themselves, and so on.
313    /// ## `recursive`
314    /// Whether to recursively get children in `self`
315    ///
316    /// # Returns
317    ///
318    /// The list of
319    /// [`TimelineElement`][crate::TimelineElement]-s contained in `self`.
320    #[doc(alias = "ges_container_get_children")]
321    #[doc(alias = "get_children")]
322    fn children(&self, recursive: bool) -> Vec<TimelineElement> {
323        unsafe {
324            FromGlibPtrContainer::from_glib_full(ffi::ges_container_get_children(
325                self.as_ref().to_glib_none().0,
326                recursive.into_glib(),
327            ))
328        }
329    }
330
331    /// Removes a timeline element from the container. The element will no
332    /// longer be controlled by the container.
333    /// ## `child`
334    /// The child to remove
335    ///
336    /// # Returns
337    ///
338    /// [`true`] if `child` was successfully removed from `self`.
339    #[doc(alias = "ges_container_remove")]
340    fn remove(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
341        unsafe {
342            glib::result_from_gboolean!(
343                ffi::ges_container_remove(
344                    self.as_ref().to_glib_none().0,
345                    child.as_ref().to_glib_none().0
346                ),
347                "Failed to remove element"
348            )
349        }
350    }
351
352    /// Ungroups the container by splitting it into several containers
353    /// containing various children of the original. The rules for how the
354    /// container splits depends on the subclass. A [`Group`][crate::Group] will simply split
355    /// into its children. A [`Clip`][crate::Clip] will split into one [`Clip`][crate::Clip] per
356    /// [`TrackType`][crate::TrackType] it overlaps with (so an audio-video clip will split into
357    /// an audio clip and a video clip), where each clip contains all the
358    /// [`TrackElement`][crate::TrackElement]-s from the original clip with a matching
359    /// [`track-type`][struct@crate::TrackElement#track-type].
360    ///
361    /// If `recursive` is [`true`], and the container contains other containers as
362    /// children, then they will also be ungrouped, and so on.
363    /// ## `recursive`
364    /// Whether to recursively ungroup `self`
365    ///
366    /// # Returns
367    ///
368    /// The list of
369    /// new [`Container`][crate::Container]-s created from the splitting of `self`.
370    #[doc(alias = "ges_container_ungroup")]
371    fn ungroup(self, recursive: bool) -> Vec<Container> {
372        unsafe {
373            FromGlibPtrContainer::from_glib_full(ffi::ges_container_ungroup(
374                self.upcast().into_glib_ptr(),
375                recursive.into_glib(),
376            ))
377        }
378    }
379
380    /// The span of the container's children's [`priority`][struct@crate::TimelineElement#priority]
381    /// values, which is the number of integers that lie between (inclusive)
382    /// the minimum and maximum priorities found amongst the container's
383    /// children (maximum - minimum + 1).
384    fn height(&self) -> u32 {
385        ObjectExt::property(self.as_ref(), "height")
386    }
387
388    /// Will be emitted after a child is added to the container. Usually,
389    /// you should connect with `g_signal_connect_after()` since the signal
390    /// may be stopped internally.
391    /// ## `element`
392    /// The child that was added
393    #[doc(alias = "child-added")]
394    fn connect_child_added<F: Fn(&Self, &TimelineElement) + 'static>(
395        &self,
396        f: F,
397    ) -> SignalHandlerId {
398        unsafe extern "C" fn child_added_trampoline<
399            P: IsA<Container>,
400            F: Fn(&P, &TimelineElement) + 'static,
401        >(
402            this: *mut ffi::GESContainer,
403            element: *mut ffi::GESTimelineElement,
404            f: glib::ffi::gpointer,
405        ) {
406            let f: &F = &*(f as *const F);
407            f(
408                Container::from_glib_borrow(this).unsafe_cast_ref(),
409                &from_glib_borrow(element),
410            )
411        }
412        unsafe {
413            let f: Box_<F> = Box_::new(f);
414            connect_raw(
415                self.as_ptr() as *mut _,
416                c"child-added".as_ptr() as *const _,
417                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
418                    child_added_trampoline::<Self, F> as *const (),
419                )),
420                Box_::into_raw(f),
421            )
422        }
423    }
424
425    /// Will be emitted after a child is removed from the container.
426    /// ## `element`
427    /// The child that was removed
428    #[doc(alias = "child-removed")]
429    fn connect_child_removed<F: Fn(&Self, &TimelineElement) + 'static>(
430        &self,
431        f: F,
432    ) -> SignalHandlerId {
433        unsafe extern "C" fn child_removed_trampoline<
434            P: IsA<Container>,
435            F: Fn(&P, &TimelineElement) + 'static,
436        >(
437            this: *mut ffi::GESContainer,
438            element: *mut ffi::GESTimelineElement,
439            f: glib::ffi::gpointer,
440        ) {
441            let f: &F = &*(f as *const F);
442            f(
443                Container::from_glib_borrow(this).unsafe_cast_ref(),
444                &from_glib_borrow(element),
445            )
446        }
447        unsafe {
448            let f: Box_<F> = Box_::new(f);
449            connect_raw(
450                self.as_ptr() as *mut _,
451                c"child-removed".as_ptr() as *const _,
452                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
453                    child_removed_trampoline::<Self, F> as *const (),
454                )),
455                Box_::into_raw(f),
456            )
457        }
458    }
459
460    #[doc(alias = "height")]
461    fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
462        unsafe extern "C" fn notify_height_trampoline<P: IsA<Container>, F: Fn(&P) + 'static>(
463            this: *mut ffi::GESContainer,
464            _param_spec: glib::ffi::gpointer,
465            f: glib::ffi::gpointer,
466        ) {
467            let f: &F = &*(f as *const F);
468            f(Container::from_glib_borrow(this).unsafe_cast_ref())
469        }
470        unsafe {
471            let f: Box_<F> = Box_::new(f);
472            connect_raw(
473                self.as_ptr() as *mut _,
474                c"notify::height".as_ptr() as *const _,
475                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
476                    notify_height_trampoline::<Self, F> as *const (),
477                )),
478                Box_::into_raw(f),
479            )
480        }
481    }
482}
483
484impl<O: IsA<Container>> GESContainerExt for O {}