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
225mod sealed {
226 pub trait Sealed {}
227 impl<T: super::IsA<super::Container>> Sealed for T {}
228}
229
230/// Trait containing all [`struct@Container`] methods.
231///
232/// # Implementors
233///
234/// [`Clip`][struct@crate::Clip], [`Container`][struct@crate::Container], [`Group`][struct@crate::Group]
235pub trait GESContainerExt: IsA<Container> + sealed::Sealed + 'static {
236 /// Adds a timeline element to the container. The element will now be a
237 /// child of the container (and the container will be the
238 /// [`parent`][struct@crate::TimelineElement#parent] of the added element), which means that it
239 /// is now controlled by the container. This may change the properties of
240 /// the child or the container, depending on the subclass.
241 ///
242 /// Additionally, the children properties of the newly added element will
243 /// be shared with the container, meaning they can also be read and set
244 /// using [`TimelineElementExt::child_property()`][crate::prelude::TimelineElementExt::child_property()] and
245 /// [`TimelineElementExt::set_child_property()`][crate::prelude::TimelineElementExt::set_child_property()] on the container.
246 /// ## `child`
247 /// The element to add as a child
248 ///
249 /// # Returns
250 ///
251 /// [`true`] if `child` was successfully added to `self`.
252 #[doc(alias = "ges_container_add")]
253 fn add(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
254 unsafe {
255 glib::result_from_gboolean!(
256 ffi::ges_container_add(
257 self.as_ref().to_glib_none().0,
258 child.as_ref().to_glib_none().0
259 ),
260 "Failed to add element"
261 )
262 }
263 }
264
265 /// Edits the container within its timeline.
266 ///
267 /// # Deprecated since 1.18
268 ///
269 /// use `ges_timeline_element_edit` instead.
270 /// ## `layers`
271 /// A whitelist of layers
272 /// where the edit can be performed, [`None`] allows all layers in the
273 /// timeline
274 /// ## `new_layer_priority`
275 /// The priority/index of the layer `self` should
276 /// be moved to. -1 means no move
277 /// ## `mode`
278 /// The edit mode
279 /// ## `edge`
280 /// The edge of `self` where the edit should occur
281 /// ## `position`
282 /// The edit position: a new location for the edge of `self`
283 /// (in nanoseconds)
284 ///
285 /// # Returns
286 ///
287 /// [`true`] if the edit of `self` completed, [`false`] on failure.
288 #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
289 #[allow(deprecated)]
290 #[doc(alias = "ges_container_edit")]
291 fn edit(
292 &self,
293 layers: &[Layer],
294 new_layer_priority: i32,
295 mode: EditMode,
296 edge: Edge,
297 position: u64,
298 ) -> Result<(), glib::error::BoolError> {
299 unsafe {
300 glib::result_from_gboolean!(
301 ffi::ges_container_edit(
302 self.as_ref().to_glib_none().0,
303 layers.to_glib_none().0,
304 new_layer_priority,
305 mode.into_glib(),
306 edge.into_glib(),
307 position
308 ),
309 "Failed to edit container"
310 )
311 }
312 }
313
314 /// Get the list of timeline elements contained in the container. If
315 /// `recursive` is [`true`], and the container contains other containers as
316 /// children, then their children will be added to the list, in addition to
317 /// themselves, and so on.
318 /// ## `recursive`
319 /// Whether to recursively get children in `self`
320 ///
321 /// # Returns
322 ///
323 /// The list of
324 /// [`TimelineElement`][crate::TimelineElement]-s contained in `self`.
325 #[doc(alias = "ges_container_get_children")]
326 #[doc(alias = "get_children")]
327 fn children(&self, recursive: bool) -> Vec<TimelineElement> {
328 unsafe {
329 FromGlibPtrContainer::from_glib_full(ffi::ges_container_get_children(
330 self.as_ref().to_glib_none().0,
331 recursive.into_glib(),
332 ))
333 }
334 }
335
336 /// Removes a timeline element from the container. The element will no
337 /// longer be controlled by the container.
338 /// ## `child`
339 /// The child to remove
340 ///
341 /// # Returns
342 ///
343 /// [`true`] if `child` was successfully removed from `self`.
344 #[doc(alias = "ges_container_remove")]
345 fn remove(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
346 unsafe {
347 glib::result_from_gboolean!(
348 ffi::ges_container_remove(
349 self.as_ref().to_glib_none().0,
350 child.as_ref().to_glib_none().0
351 ),
352 "Failed to remove element"
353 )
354 }
355 }
356
357 /// Ungroups the container by splitting it into several containers
358 /// containing various children of the original. The rules for how the
359 /// container splits depends on the subclass. A [`Group`][crate::Group] will simply split
360 /// into its children. A [`Clip`][crate::Clip] will split into one [`Clip`][crate::Clip] per
361 /// [`TrackType`][crate::TrackType] it overlaps with (so an audio-video clip will split into
362 /// an audio clip and a video clip), where each clip contains all the
363 /// [`TrackElement`][crate::TrackElement]-s from the original clip with a matching
364 /// [`track-type`][struct@crate::TrackElement#track-type].
365 ///
366 /// If `recursive` is [`true`], and the container contains other containers as
367 /// children, then they will also be ungrouped, and so on.
368 /// ## `recursive`
369 /// Whether to recursively ungroup `self`
370 ///
371 /// # Returns
372 ///
373 /// The list of
374 /// new [`Container`][crate::Container]-s created from the splitting of `self`.
375 #[doc(alias = "ges_container_ungroup")]
376 fn ungroup(self, recursive: bool) -> Vec<Container> {
377 unsafe {
378 FromGlibPtrContainer::from_glib_full(ffi::ges_container_ungroup(
379 self.upcast().into_glib_ptr(),
380 recursive.into_glib(),
381 ))
382 }
383 }
384
385 /// The span of the container's children's [`priority`][struct@crate::TimelineElement#priority]
386 /// values, which is the number of integers that lie between (inclusive)
387 /// the minimum and maximum priorities found amongst the container's
388 /// children (maximum - minimum + 1).
389 fn height(&self) -> u32 {
390 ObjectExt::property(self.as_ref(), "height")
391 }
392
393 /// Will be emitted after a child is added to the container. Usually,
394 /// you should connect with `g_signal_connect_after()` since the signal
395 /// may be stopped internally.
396 /// ## `element`
397 /// The child that was added
398 #[doc(alias = "child-added")]
399 fn connect_child_added<F: Fn(&Self, &TimelineElement) + 'static>(
400 &self,
401 f: F,
402 ) -> SignalHandlerId {
403 unsafe extern "C" fn child_added_trampoline<
404 P: IsA<Container>,
405 F: Fn(&P, &TimelineElement) + 'static,
406 >(
407 this: *mut ffi::GESContainer,
408 element: *mut ffi::GESTimelineElement,
409 f: glib::ffi::gpointer,
410 ) {
411 let f: &F = &*(f as *const F);
412 f(
413 Container::from_glib_borrow(this).unsafe_cast_ref(),
414 &from_glib_borrow(element),
415 )
416 }
417 unsafe {
418 let f: Box_<F> = Box_::new(f);
419 connect_raw(
420 self.as_ptr() as *mut _,
421 b"child-added\0".as_ptr() as *const _,
422 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
423 child_added_trampoline::<Self, F> as *const (),
424 )),
425 Box_::into_raw(f),
426 )
427 }
428 }
429
430 /// Will be emitted after a child is removed from the container.
431 /// ## `element`
432 /// The child that was removed
433 #[doc(alias = "child-removed")]
434 fn connect_child_removed<F: Fn(&Self, &TimelineElement) + 'static>(
435 &self,
436 f: F,
437 ) -> SignalHandlerId {
438 unsafe extern "C" fn child_removed_trampoline<
439 P: IsA<Container>,
440 F: Fn(&P, &TimelineElement) + 'static,
441 >(
442 this: *mut ffi::GESContainer,
443 element: *mut ffi::GESTimelineElement,
444 f: glib::ffi::gpointer,
445 ) {
446 let f: &F = &*(f as *const F);
447 f(
448 Container::from_glib_borrow(this).unsafe_cast_ref(),
449 &from_glib_borrow(element),
450 )
451 }
452 unsafe {
453 let f: Box_<F> = Box_::new(f);
454 connect_raw(
455 self.as_ptr() as *mut _,
456 b"child-removed\0".as_ptr() as *const _,
457 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
458 child_removed_trampoline::<Self, F> as *const (),
459 )),
460 Box_::into_raw(f),
461 )
462 }
463 }
464
465 #[doc(alias = "height")]
466 fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
467 unsafe extern "C" fn notify_height_trampoline<P: IsA<Container>, F: Fn(&P) + 'static>(
468 this: *mut ffi::GESContainer,
469 _param_spec: glib::ffi::gpointer,
470 f: glib::ffi::gpointer,
471 ) {
472 let f: &F = &*(f as *const F);
473 f(Container::from_glib_borrow(this).unsafe_cast_ref())
474 }
475 unsafe {
476 let f: Box_<F> = Box_::new(f);
477 connect_raw(
478 self.as_ptr() as *mut _,
479 b"notify::height\0".as_ptr() as *const _,
480 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
481 notify_height_trampoline::<Self, F> as *const (),
482 )),
483 Box_::into_raw(f),
484 )
485 }
486 }
487}
488
489impl<O: IsA<Container>> GESContainerExt for O {}