gstreamer_editing_services/auto/timeline_element.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, Extractable, MetaContainer, Timeline, TrackType};
8#[cfg(feature = "v1_18")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
10use crate::{Edge, EditMode, Layer};
11use glib::{
12 object::ObjectType as _,
13 prelude::*,
14 signal::{connect_raw, SignalHandlerId},
15 translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20 /// A [`TimelineElement`][crate::TimelineElement] will have some temporal extent in its
21 /// corresponding [`timeline`][struct@crate::TimelineElement#timeline], controlled by its
22 /// [`start`][struct@crate::TimelineElement#start] and [`duration`][struct@crate::TimelineElement#duration]. This
23 /// determines when its content will be displayed, or its effect applied,
24 /// in the timeline. Several objects may overlap within a given
25 /// [`Timeline`][crate::Timeline], in which case their [`priority`][struct@crate::TimelineElement#priority] is used
26 /// to determine their ordering in the timeline. Priority is mostly handled
27 /// internally by [`Layer`][crate::Layer]-s and [`Clip`][crate::Clip]-s.
28 ///
29 /// A timeline element can have a [`parent`][struct@crate::TimelineElement#parent],
30 /// such as a [`Clip`][crate::Clip], which is responsible for controlling its timing.
31 ///
32 /// ## Editing
33 ///
34 /// Elements can be moved around in their [`timeline`][struct@crate::TimelineElement#timeline] by
35 /// setting their [`start`][struct@crate::TimelineElement#start] and
36 /// [`duration`][struct@crate::TimelineElement#duration] using [`TimelineElementExt::set_start()`][crate::prelude::TimelineElementExt::set_start()]
37 /// and [`TimelineElementExt::set_duration()`][crate::prelude::TimelineElementExt::set_duration()]. Additionally, which parts of
38 /// the underlying content are played in the timeline can be adjusted by
39 /// setting the [`in-point`][struct@crate::TimelineElement#in-point] using
40 /// [`TimelineElementExt::set_inpoint()`][crate::prelude::TimelineElementExt::set_inpoint()]. The library also provides
41 /// [`TimelineElementExt::edit()`][crate::prelude::TimelineElementExt::edit()], with various [`EditMode`][crate::EditMode]-s, which can
42 /// adjust these properties in a convenient way, as well as introduce
43 /// similar changes in neighbouring or later elements in the timeline.
44 ///
45 /// However, a timeline may refuse a change in these properties if they
46 /// would place the timeline in an unsupported configuration. See
47 /// [`Timeline`][crate::Timeline] for its overlap rules.
48 ///
49 /// Additionally, an edit may be refused if it would place one of the
50 /// timing properties out of bounds (such as a negative time value for
51 /// [`start`][struct@crate::TimelineElement#start], or having insufficient internal
52 /// content to last for the desired [`duration`][struct@crate::TimelineElement#duration]).
53 ///
54 /// ## Time Coordinates
55 ///
56 /// There are three main sets of time coordinates to consider when using
57 /// timeline elements:
58 ///
59 /// + Timeline coordinates: these are the time coordinates used in the
60 /// output of the timeline in its [`Track`][crate::Track]-s. Each track share the same
61 /// coordinates, so there is only one set of coordinates for the
62 /// timeline. These extend indefinitely from 0. The times used for
63 /// editing (including setting [`start`][struct@crate::TimelineElement#start] and
64 /// [`duration`][struct@crate::TimelineElement#duration]) use these coordinates, since these
65 /// define when an element is present and for how long the element lasts
66 /// for in the timeline.
67 /// + Internal source coordinates: these are the time coordinates used
68 /// internally at the element's output. This is only really defined for
69 /// [`TrackElement`][crate::TrackElement]-s, where it refers to time coordinates used at the
70 /// final source pad of the wrapped [`gst::Element`][crate::gst::Element]-s. However, these
71 /// coordinates may also be used in a [`Clip`][crate::Clip] in reference to its
72 /// children. In particular, these are the coordinates used for
73 /// [`in-point`][struct@crate::TimelineElement#in-point] and [`max-duration`][struct@crate::TimelineElement#max-duration].
74 /// + Internal sink coordinates: these are the time coordinates used
75 /// internally at the element's input. A [`Source`][crate::Source] has no input, so
76 /// these would be undefined. Otherwise, for most [`TrackElement`][crate::TrackElement]-s
77 /// these will be the same set of coordinates as the internal source
78 /// coordinates because the element does not change the timing
79 /// internally. Only [`BaseEffect`][crate::BaseEffect] can support elements where these
80 /// are different. See [`BaseEffect`][crate::BaseEffect] for more information.
81 ///
82 /// You can determine the timeline time for a given internal source time
83 /// in a [`Track`][crate::Track] in a [`Clip`][crate::Clip] using
84 /// [`ClipExt::timeline_time_from_internal_time()`][crate::prelude::ClipExt::timeline_time_from_internal_time()], and vice versa using
85 /// [`ClipExt::internal_time_from_timeline_time()`][crate::prelude::ClipExt::internal_time_from_timeline_time()], for the purposes of
86 /// editing and setting timings properties.
87 ///
88 /// ## Children Properties
89 ///
90 /// If a timeline element owns another [`gst::Object`][crate::gst::Object] and wishes to expose
91 /// some of its properties, it can do so by registering the property as one
92 /// of the timeline element's children properties using
93 /// [`TimelineElementExt::add_child_property()`][crate::prelude::TimelineElementExt::add_child_property()]. The registered property of
94 /// the child can then be read and set using the
95 /// [`TimelineElementExt::child_property()`][crate::prelude::TimelineElementExt::child_property()] and
96 /// [`TimelineElementExtManual::set_child_property()`][crate::prelude::TimelineElementExtManual::set_child_property()] methods, respectively. Some
97 /// sub-classed objects will be created with pre-registered children
98 /// properties; for example, to expose part of an underlying [`gst::Element`][crate::gst::Element]
99 /// that is used internally. The registered properties can be listed with
100 /// [`TimelineElementExt::list_children_properties()`][crate::prelude::TimelineElementExt::list_children_properties()].
101 ///
102 /// This is an Abstract Base Class, you cannot instantiate it.
103 ///
104 /// ## Properties
105 ///
106 ///
107 /// #### `duration`
108 /// The duration that the element is in effect for in the timeline (a
109 /// time difference in nanoseconds using the time coordinates of the
110 /// timeline). For example, for a source element, this would determine
111 /// for how long it should output its internal content for. For an
112 /// operation element, this would determine for how long its effect
113 /// should be applied to any source content.
114 ///
115 /// Readable | Writeable
116 ///
117 ///
118 /// #### `in-point`
119 /// The initial offset to use internally when outputting content (in
120 /// nanoseconds, but in the time coordinates of the internal content).
121 ///
122 /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
123 /// file, the "internal content" is the media file data, and the
124 /// in-point would correspond to some timestamp in the media file.
125 /// When playing the timeline, and when the element is first reached at
126 /// timeline-time [`start`][struct@crate::TimelineElement#start], it will begin outputting the
127 /// data from the timestamp in-point **onwards**, until it reaches the
128 /// end of its [`duration`][struct@crate::TimelineElement#duration] in the timeline.
129 ///
130 /// For elements that have no internal content, this should be kept
131 /// as 0.
132 ///
133 /// Readable | Writeable
134 ///
135 ///
136 /// #### `max-duration`
137 /// The full duration of internal content that is available (a time
138 /// difference in nanoseconds using the time coordinates of the internal
139 /// content).
140 ///
141 /// This will act as a cap on the [`in-point`][struct@crate::TimelineElement#in-point] of the
142 /// element (which is in the same time coordinates), and will sometimes
143 /// be used to limit the [`duration`][struct@crate::TimelineElement#duration] of the element in
144 /// the timeline.
145 ///
146 /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
147 /// file, this would be the length of the media file.
148 ///
149 /// For elements that have no internal content, or whose content is
150 /// indefinite, this should be kept as `GST_CLOCK_TIME_NONE`.
151 ///
152 /// Readable | Writeable | Construct
153 ///
154 ///
155 /// #### `name`
156 /// The name of the element. This should be unique within its timeline.
157 ///
158 /// Readable | Writeable | Construct
159 ///
160 ///
161 /// #### `parent`
162 /// The parent container of the element.
163 ///
164 /// Readable | Writeable
165 ///
166 ///
167 /// #### `priority`
168 /// The priority of the element.
169 ///
170 /// Readable | Writeable
171 ///
172 ///
173 /// #### `serialize`
174 /// Whether the element should be serialized.
175 ///
176 /// Readable | Writeable
177 ///
178 ///
179 /// #### `start`
180 /// The starting position of the element in the timeline (in nanoseconds
181 /// and in the time coordinates of the timeline). For example, for a
182 /// source element, this would determine the time at which it should
183 /// start outputting its internal content. For an operation element, this
184 /// would determine the time at which it should start applying its effect
185 /// to any source content.
186 ///
187 /// Readable | Writeable
188 ///
189 ///
190 /// #### `timeline`
191 /// The timeline that the element lies within.
192 ///
193 /// Readable | Writeable
194 ///
195 /// ## Signals
196 ///
197 ///
198 /// #### `child-property-added`
199 /// Emitted when the element has a new child property registered. See
200 /// [`TimelineElementExt::add_child_property()`][crate::prelude::TimelineElementExt::add_child_property()].
201 ///
202 /// Note that some GES elements will be automatically created with
203 /// pre-registered children properties. You can use
204 /// [`TimelineElementExt::list_children_properties()`][crate::prelude::TimelineElementExt::list_children_properties()] to list these.
205 ///
206 ///
207 ///
208 ///
209 /// #### `child-property-removed`
210 /// Emitted when the element has a child property unregistered. See
211 /// [`TimelineElementExt::remove_child_property()`][crate::prelude::TimelineElementExt::remove_child_property()].
212 ///
213 ///
214 ///
215 ///
216 /// #### `deep-notify`
217 /// Emitted when a child of the element has one of its registered
218 /// properties set. See [`TimelineElementExt::add_child_property()`][crate::prelude::TimelineElementExt::add_child_property()].
219 /// Note that unlike [`notify`][struct@crate::glib::Object#notify], a child property name can not be
220 /// used as a signal detail.
221 ///
222 /// Detailed
223 /// <details><summary><h4>MetaContainer</h4></summary>
224 ///
225 ///
226 /// #### `notify-meta`
227 /// This is emitted for a meta container whenever the metadata under one
228 /// of its fields changes, is set for the first time, or is removed. In
229 /// the latter case, `value` will be [`None`].
230 ///
231 /// Detailed
232 /// </details>
233 ///
234 /// # Implements
235 ///
236 /// [`TimelineElementExt`][trait@crate::prelude::TimelineElementExt], [`trait@glib::ObjectExt`], [`ExtractableExt`][trait@crate::prelude::ExtractableExt], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt], [`TimelineElementExtManual`][trait@crate::prelude::TimelineElementExtManual]
237 #[doc(alias = "GESTimelineElement")]
238 pub struct TimelineElement(Object<ffi::GESTimelineElement, ffi::GESTimelineElementClass>) @implements Extractable, MetaContainer;
239
240 match fn {
241 type_ => || ffi::ges_timeline_element_get_type(),
242 }
243}
244
245impl TimelineElement {
246 pub const NONE: Option<&'static TimelineElement> = None;
247}
248
249/// Trait containing all [`struct@TimelineElement`] methods.
250///
251/// # Implementors
252///
253/// [`Container`][struct@crate::Container], [`TimelineElement`][struct@crate::TimelineElement], [`TrackElement`][struct@crate::TrackElement]
254pub trait TimelineElementExt: IsA<TimelineElement> + 'static {
255 /// Register a property of a child of the element to allow it to be
256 /// written with [`TimelineElementExtManual::set_child_property()`][crate::prelude::TimelineElementExtManual::set_child_property()] and read with
257 /// [`child_property()`][Self::child_property()]. A change in the property
258 /// will also appear in the [`deep-notify`][struct@crate::TimelineElement#deep-notify] signal.
259 ///
260 /// `pspec` should be unique from other children properties that have been
261 /// registered on `self`.
262 /// ## `pspec`
263 /// The specification for the property to add
264 /// ## `child`
265 /// The [`gst::Object`][crate::gst::Object] who the property belongs to
266 ///
267 /// # Returns
268 ///
269 /// [`true`] if the property was successfully registered.
270 #[doc(alias = "ges_timeline_element_add_child_property")]
271 fn add_child_property(
272 &self,
273 pspec: impl AsRef<glib::ParamSpec>,
274 child: &impl IsA<glib::Object>,
275 ) -> Result<(), glib::error::BoolError> {
276 unsafe {
277 glib::result_from_gboolean!(
278 ffi::ges_timeline_element_add_child_property(
279 self.as_ref().to_glib_none().0,
280 pspec.as_ref().to_glib_none().0,
281 child.as_ref().to_glib_none().0
282 ),
283 "Failed to add child property"
284 )
285 }
286 }
287
288 #[doc(alias = "ges_timeline_element_copy")]
289 #[must_use]
290 fn copy(&self, deep: bool) -> TimelineElement {
291 unsafe {
292 from_glib_none(ffi::ges_timeline_element_copy(
293 self.as_ref().to_glib_none().0,
294 deep.into_glib(),
295 ))
296 }
297 }
298
299 /// See [`edit_full()`][Self::edit_full()], which also gives an error.
300 ///
301 /// Note that the `layers` argument is currently ignored, so you should
302 /// just pass [`None`].
303 /// ## `layers`
304 /// A whitelist of layers
305 /// where the edit can be performed, [`None`] allows all layers in the
306 /// timeline.
307 /// ## `new_layer_priority`
308 /// The priority/index of the layer `self` should be
309 /// moved to. -1 means no move
310 /// ## `mode`
311 /// The edit mode
312 /// ## `edge`
313 /// The edge of `self` where the edit should occur
314 /// ## `position`
315 /// The edit position: a new location for the edge of `self`
316 /// (in nanoseconds) in the timeline coordinates
317 ///
318 /// # Returns
319 ///
320 /// [`true`] if the edit of `self` completed, [`false`] on failure.
321 #[cfg(feature = "v1_18")]
322 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
323 #[doc(alias = "ges_timeline_element_edit")]
324 fn edit(
325 &self,
326 layers: &[Layer],
327 new_layer_priority: i64,
328 mode: EditMode,
329 edge: Edge,
330 position: u64,
331 ) -> bool {
332 unsafe {
333 from_glib(ffi::ges_timeline_element_edit(
334 self.as_ref().to_glib_none().0,
335 layers.to_glib_none().0,
336 new_layer_priority,
337 mode.into_glib(),
338 edge.into_glib(),
339 position,
340 ))
341 }
342 }
343
344 /// Edits the element within its timeline by adjusting its
345 /// [`start`][struct@crate::TimelineElement#start], [`duration`][struct@crate::TimelineElement#duration] or
346 /// [`in-point`][struct@crate::TimelineElement#in-point], and potentially doing the same for
347 /// other elements in the timeline. See [`EditMode`][crate::EditMode] for details about each
348 /// edit mode. An edit may fail if it would place one of these properties
349 /// out of bounds, or if it would place the timeline in an unsupported
350 /// configuration.
351 ///
352 /// Note that if you act on a [`TrackElement`][crate::TrackElement], this will edit its parent
353 /// [`Clip`][crate::Clip] instead. Moreover, for any [`TimelineElement`][crate::TimelineElement], if you select
354 /// [`Edge::None`][crate::Edge::None] for [`EditMode::Normal`][crate::EditMode::Normal] or [`EditMode::Ripple`][crate::EditMode::Ripple], this
355 /// will edit the toplevel instead, but still in such a way as to make the
356 /// [`start`][struct@crate::TimelineElement#start] of `self` reach the edit `position`.
357 ///
358 /// Note that if the element's timeline has a
359 /// [`snapping-distance`][struct@crate::Timeline#snapping-distance] set, then the edit position may be
360 /// snapped to the edge of some element under the edited element.
361 ///
362 /// `new_layer_priority` can be used to switch `self`, and other elements
363 /// moved by the edit, to a new layer. New layers may be be created if the
364 /// the corresponding layer priority/index does not yet exist for the
365 /// timeline.
366 /// ## `new_layer_priority`
367 /// The priority/index of the layer `self` should be
368 /// moved to. -1 means no move
369 /// ## `mode`
370 /// The edit mode
371 /// ## `edge`
372 /// The edge of `self` where the edit should occur
373 /// ## `position`
374 /// The edit position: a new location for the edge of `self`
375 /// (in nanoseconds) in the timeline coordinates
376 ///
377 /// # Returns
378 ///
379 /// [`true`] if the edit of `self` completed, [`false`] on failure.
380 #[cfg(feature = "v1_18")]
381 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
382 #[doc(alias = "ges_timeline_element_edit_full")]
383 fn edit_full(
384 &self,
385 new_layer_priority: i64,
386 mode: EditMode,
387 edge: Edge,
388 position: u64,
389 ) -> Result<(), glib::Error> {
390 unsafe {
391 let mut error = std::ptr::null_mut();
392 let is_ok = ffi::ges_timeline_element_edit_full(
393 self.as_ref().to_glib_none().0,
394 new_layer_priority,
395 mode.into_glib(),
396 edge.into_glib(),
397 position,
398 &mut error,
399 );
400 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
401 if error.is_null() {
402 Ok(())
403 } else {
404 Err(from_glib_full(error))
405 }
406 }
407 }
408
409 //#[doc(alias = "ges_timeline_element_get_child_properties")]
410 //#[doc(alias = "get_child_properties")]
411 //fn child_properties(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
412 // unsafe { TODO: call ffi:ges_timeline_element_get_child_properties() }
413 //}
414
415 /// Gets the property of a child of the element.
416 ///
417 /// `property_name` can either be in the format "prop-name" or
418 /// "TypeName::prop-name", where "prop-name" is the name of the property
419 /// to get (as used in [`ObjectExt::get()`][crate::glib::prelude::ObjectExt::get()]), and "TypeName" is the type name of
420 /// the child (as returned by G_OBJECT_TYPE_NAME()). The latter format is
421 /// useful when two children of different types share the same property
422 /// name.
423 ///
424 /// The first child found with the given "prop-name" property that was
425 /// registered with [`add_child_property()`][Self::add_child_property()] (and of the
426 /// type "TypeName", if it was given) will have the corresponding
427 /// property copied into `value`.
428 ///
429 /// Note that `ges_timeline_element_get_child_properties()` may be more
430 /// convenient for C programming.
431 /// ## `property_name`
432 /// The name of the child property to get
433 ///
434 /// # Returns
435 ///
436 /// [`true`] if the property was found and copied to `value`.
437 ///
438 /// ## `value`
439 /// The return location for the value
440 #[doc(alias = "ges_timeline_element_get_child_property")]
441 #[doc(alias = "get_child_property")]
442 fn child_property(&self, property_name: &str) -> Option<glib::Value> {
443 unsafe {
444 let mut value = glib::Value::uninitialized();
445 let ret = from_glib(ffi::ges_timeline_element_get_child_property(
446 self.as_ref().to_glib_none().0,
447 property_name.to_glib_none().0,
448 value.to_glib_none_mut().0,
449 ));
450 if ret {
451 Some(value)
452 } else {
453 None
454 }
455 }
456 }
457
458 /// Gets the property of a child of the element. Specifically, the property
459 /// corresponding to the `pspec` used in
460 /// [`add_child_property()`][Self::add_child_property()] is copied into `value`.
461 /// ## `pspec`
462 /// The specification of a registered child property to get
463 ///
464 /// # Returns
465 ///
466 ///
467 /// ## `value`
468 /// The return location for the value
469 #[doc(alias = "ges_timeline_element_get_child_property_by_pspec")]
470 #[doc(alias = "get_child_property_by_pspec")]
471 fn child_property_by_pspec(&self, pspec: impl AsRef<glib::ParamSpec>) -> glib::Value {
472 unsafe {
473 let mut value = glib::Value::uninitialized();
474 ffi::ges_timeline_element_get_child_property_by_pspec(
475 self.as_ref().to_glib_none().0,
476 pspec.as_ref().to_glib_none().0,
477 value.to_glib_none_mut().0,
478 );
479 value
480 }
481 }
482
483 //#[doc(alias = "ges_timeline_element_get_child_property_valist")]
484 //#[doc(alias = "get_child_property_valist")]
485 //fn child_property_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
486 // unsafe { TODO: call ffi:ges_timeline_element_get_child_property_valist() }
487 //}
488
489 /// Gets the [`duration`][struct@crate::TimelineElement#duration] for the element.
490 ///
491 /// # Returns
492 ///
493 /// The duration of `self` (in nanoseconds).
494 #[doc(alias = "ges_timeline_element_get_duration")]
495 #[doc(alias = "get_duration")]
496 fn duration(&self) -> gst::ClockTime {
497 unsafe {
498 try_from_glib(ffi::ges_timeline_element_get_duration(
499 self.as_ref().to_glib_none().0,
500 ))
501 .expect("mandatory glib value is None")
502 }
503 }
504
505 /// Gets the [`in-point`][struct@crate::TimelineElement#in-point] for the element.
506 ///
507 /// # Returns
508 ///
509 /// The in-point of `self` (in nanoseconds).
510 #[doc(alias = "ges_timeline_element_get_inpoint")]
511 #[doc(alias = "get_inpoint")]
512 #[doc(alias = "in-point")]
513 fn inpoint(&self) -> gst::ClockTime {
514 unsafe {
515 try_from_glib(ffi::ges_timeline_element_get_inpoint(
516 self.as_ref().to_glib_none().0,
517 ))
518 .expect("mandatory glib value is None")
519 }
520 }
521
522 /// Gets the priority of the layer the element is in. A [`Group`][crate::Group] may span
523 /// several layers, so this would return the highest priority (numerically,
524 /// the smallest) amongst them.
525 ///
526 /// # Returns
527 ///
528 /// The priority of the layer `self` is in, or
529 /// `GES_TIMELINE_ELEMENT_NO_LAYER_PRIORITY` if `self` does not exist in a
530 /// layer.
531 #[cfg(feature = "v1_16")]
532 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
533 #[doc(alias = "ges_timeline_element_get_layer_priority")]
534 #[doc(alias = "get_layer_priority")]
535 fn layer_priority(&self) -> u32 {
536 unsafe { ffi::ges_timeline_element_get_layer_priority(self.as_ref().to_glib_none().0) }
537 }
538
539 /// Gets the [`max-duration`][struct@crate::TimelineElement#max-duration] for the element.
540 ///
541 /// # Returns
542 ///
543 /// The max-duration of `self` (in nanoseconds).
544 #[doc(alias = "ges_timeline_element_get_max_duration")]
545 #[doc(alias = "get_max_duration")]
546 #[doc(alias = "max-duration")]
547 fn max_duration(&self) -> Option<gst::ClockTime> {
548 unsafe {
549 from_glib(ffi::ges_timeline_element_get_max_duration(
550 self.as_ref().to_glib_none().0,
551 ))
552 }
553 }
554
555 /// Gets the [`name`][struct@crate::TimelineElement#name] for the element.
556 ///
557 /// # Returns
558 ///
559 /// The name of `self`.
560 #[doc(alias = "ges_timeline_element_get_name")]
561 #[doc(alias = "get_name")]
562 fn name(&self) -> Option<glib::GString> {
563 unsafe {
564 from_glib_full(ffi::ges_timeline_element_get_name(
565 self.as_ref().to_glib_none().0,
566 ))
567 }
568 }
569
570 /// Get the "natural" framerate of `self`. This is to say, for example
571 /// for a [`VideoUriSource`][crate::VideoUriSource] the framerate of the source.
572 ///
573 /// Note that a [`AudioSource`][crate::AudioSource] may also have a natural framerate if it derives
574 /// from the same [`SourceClip`][crate::SourceClip] asset as a [`VideoSource`][crate::VideoSource], and its value will
575 /// be that of the video source. For example, if the uri of a [`UriClip`][crate::UriClip] points
576 /// to a file that contains both a video and audio stream, then the corresponding
577 /// [`AudioUriSource`][crate::AudioUriSource] will share the natural framerate of the corresponding
578 /// [`VideoUriSource`][crate::VideoUriSource].
579 ///
580 /// # Returns
581 ///
582 /// Whether `self` has a natural framerate or not, `framerate_n`
583 /// and `framerate_d` will be set to, respectively, 0 and -1 if it is
584 /// not the case.
585 ///
586 /// ## `framerate_n`
587 /// The framerate numerator
588 ///
589 /// ## `framerate_d`
590 /// The framerate denominator
591 #[cfg(feature = "v1_18")]
592 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
593 #[doc(alias = "ges_timeline_element_get_natural_framerate")]
594 #[doc(alias = "get_natural_framerate")]
595 fn natural_framerate(&self) -> Option<(i32, i32)> {
596 unsafe {
597 let mut framerate_n = std::mem::MaybeUninit::uninit();
598 let mut framerate_d = std::mem::MaybeUninit::uninit();
599 let ret = from_glib(ffi::ges_timeline_element_get_natural_framerate(
600 self.as_ref().to_glib_none().0,
601 framerate_n.as_mut_ptr(),
602 framerate_d.as_mut_ptr(),
603 ));
604 if ret {
605 Some((framerate_n.assume_init(), framerate_d.assume_init()))
606 } else {
607 None
608 }
609 }
610 }
611
612 /// Gets the [`parent`][struct@crate::TimelineElement#parent] for the element.
613 ///
614 /// # Returns
615 ///
616 /// The parent of `self`, or [`None`] if
617 /// `self` has no parent.
618 #[doc(alias = "ges_timeline_element_get_parent")]
619 #[doc(alias = "get_parent")]
620 #[must_use]
621 fn parent(&self) -> Option<TimelineElement> {
622 unsafe {
623 from_glib_full(ffi::ges_timeline_element_get_parent(
624 self.as_ref().to_glib_none().0,
625 ))
626 }
627 }
628
629 /// Gets the [`priority`][struct@crate::TimelineElement#priority] for the element.
630 ///
631 /// # Returns
632 ///
633 /// The priority of `self`.
634 #[doc(alias = "ges_timeline_element_get_priority")]
635 #[doc(alias = "get_priority")]
636 fn priority(&self) -> u32 {
637 unsafe { ffi::ges_timeline_element_get_priority(self.as_ref().to_glib_none().0) }
638 }
639
640 /// Gets the [`start`][struct@crate::TimelineElement#start] for the element.
641 ///
642 /// # Returns
643 ///
644 /// The start of `self` (in nanoseconds).
645 #[doc(alias = "ges_timeline_element_get_start")]
646 #[doc(alias = "get_start")]
647 fn start(&self) -> gst::ClockTime {
648 unsafe {
649 try_from_glib(ffi::ges_timeline_element_get_start(
650 self.as_ref().to_glib_none().0,
651 ))
652 .expect("mandatory glib value is None")
653 }
654 }
655
656 /// Gets the [`timeline`][struct@crate::TimelineElement#timeline] for the element.
657 ///
658 /// # Returns
659 ///
660 /// The timeline of `self`, or [`None`]
661 /// if `self` has no timeline.
662 #[doc(alias = "ges_timeline_element_get_timeline")]
663 #[doc(alias = "get_timeline")]
664 fn timeline(&self) -> Option<Timeline> {
665 unsafe {
666 from_glib_full(ffi::ges_timeline_element_get_timeline(
667 self.as_ref().to_glib_none().0,
668 ))
669 }
670 }
671
672 /// Gets the toplevel [`parent`][struct@crate::TimelineElement#parent] of the element.
673 ///
674 /// # Returns
675 ///
676 /// The toplevel parent of `self`.
677 #[doc(alias = "ges_timeline_element_get_toplevel_parent")]
678 #[doc(alias = "get_toplevel_parent")]
679 #[must_use]
680 fn toplevel_parent(&self) -> TimelineElement {
681 unsafe {
682 from_glib_full(ffi::ges_timeline_element_get_toplevel_parent(
683 self.as_ref().to_glib_none().0,
684 ))
685 }
686 }
687
688 /// Gets the track types that the element can interact with, i.e. the type
689 /// of [`Track`][crate::Track] it can exist in, or will create [`TrackElement`][crate::TrackElement]-s for.
690 ///
691 /// # Returns
692 ///
693 /// The track types that `self` supports.
694 #[doc(alias = "ges_timeline_element_get_track_types")]
695 #[doc(alias = "get_track_types")]
696 fn track_types(&self) -> TrackType {
697 unsafe {
698 from_glib(ffi::ges_timeline_element_get_track_types(
699 self.as_ref().to_glib_none().0,
700 ))
701 }
702 }
703
704 /// Get a list of children properties of the element, which is a list of
705 /// all the specifications passed to
706 /// [`add_child_property()`][Self::add_child_property()].
707 ///
708 /// # Returns
709 ///
710 /// An array of
711 /// [`glib::ParamSpec`][crate::glib::ParamSpec] corresponding to the child properties of `self`, or [`None`] if
712 /// something went wrong.
713 #[doc(alias = "ges_timeline_element_list_children_properties")]
714 fn list_children_properties(&self) -> Vec<glib::ParamSpec> {
715 unsafe {
716 let mut n_properties = std::mem::MaybeUninit::uninit();
717 let ret = FromGlibContainer::from_glib_full_num(
718 ffi::ges_timeline_element_list_children_properties(
719 self.as_ref().to_glib_none().0,
720 n_properties.as_mut_ptr(),
721 ),
722 n_properties.assume_init() as _,
723 );
724 ret
725 }
726 }
727
728 /// Looks up a child property of the element.
729 ///
730 /// `prop_name` can either be in the format "prop-name" or
731 /// "TypeName::prop-name", where "prop-name" is the name of the property
732 /// to look up (as used in [`ObjectExt::get()`][crate::glib::prelude::ObjectExt::get()]), and "TypeName" is the type name
733 /// of the child (as returned by G_OBJECT_TYPE_NAME()). The latter format is
734 /// useful when two children of different types share the same property
735 /// name.
736 ///
737 /// The first child found with the given "prop-name" property that was
738 /// registered with [`add_child_property()`][Self::add_child_property()] (and of the
739 /// type "TypeName", if it was given) will be passed to `child`, and the
740 /// registered specification of this property will be passed to `pspec`.
741 /// ## `prop_name`
742 /// The name of a child property
743 ///
744 /// # Returns
745 ///
746 /// [`true`] if a child corresponding to the property was found, in
747 /// which case `child` and `pspec` are set.
748 ///
749 /// ## `child`
750 /// The return location for the
751 /// found child
752 ///
753 /// ## `pspec`
754 /// The return location for the
755 /// specification of the child property
756 #[doc(alias = "ges_timeline_element_lookup_child")]
757 fn lookup_child(&self, prop_name: &str) -> Option<(glib::Object, glib::ParamSpec)> {
758 unsafe {
759 let mut child = std::ptr::null_mut();
760 let mut pspec = std::ptr::null_mut();
761 let ret = from_glib(ffi::ges_timeline_element_lookup_child(
762 self.as_ref().to_glib_none().0,
763 prop_name.to_glib_none().0,
764 &mut child,
765 &mut pspec,
766 ));
767 if ret {
768 Some((from_glib_full(child), from_glib_full(pspec)))
769 } else {
770 None
771 }
772 }
773 }
774
775 /// Paste an element inside the same timeline and layer as `self`. `self`
776 /// **must** be the return of `ges_timeline_element_copy()` with `deep=TRUE`,
777 /// and it should not be changed before pasting.
778 /// `self` is not placed in the timeline, instead a new element is created,
779 /// alike to the originally copied element. Note that the originally
780 /// copied element must stay within the same timeline and layer, at both
781 /// the point of copying and pasting.
782 ///
783 /// Pasting may fail if it would place the timeline in an unsupported
784 /// configuration.
785 ///
786 /// After calling this function `element` should not be used. In particular,
787 /// `element` can **not** be pasted again. Instead, you can copy the
788 /// returned element and paste that copy (although, this is only possible
789 /// if the paste was successful).
790 ///
791 /// See also [`TimelineExt::paste_element()`][crate::prelude::TimelineExt::paste_element()].
792 /// ## `paste_position`
793 /// The position in the timeline `element` should be pasted
794 /// to, i.e. the [`start`][struct@crate::TimelineElement#start] value for the pasted element.
795 ///
796 /// # Returns
797 ///
798 /// The newly created element, or
799 /// [`None`] if pasting fails.
800 #[doc(alias = "ges_timeline_element_paste")]
801 fn paste(&self, paste_position: gst::ClockTime) -> Result<TimelineElement, glib::BoolError> {
802 unsafe {
803 Option::<_>::from_glib_full(ffi::ges_timeline_element_paste(
804 self.as_ref().to_glib_none().0,
805 paste_position.into_glib(),
806 ))
807 .ok_or_else(|| glib::bool_error!("Failed to paste timeline element"))
808 }
809 }
810
811 /// Remove a child property from the element. `pspec` should be a
812 /// specification that was passed to
813 /// [`add_child_property()`][Self::add_child_property()]. The corresponding property
814 /// will no longer be registered as a child property for the element.
815 /// ## `pspec`
816 /// The specification for the property to remove
817 ///
818 /// # Returns
819 ///
820 /// [`true`] if the property was successfully un-registered for `self`.
821 #[doc(alias = "ges_timeline_element_remove_child_property")]
822 fn remove_child_property(
823 &self,
824 pspec: impl AsRef<glib::ParamSpec>,
825 ) -> Result<(), glib::error::BoolError> {
826 unsafe {
827 glib::result_from_gboolean!(
828 ffi::ges_timeline_element_remove_child_property(
829 self.as_ref().to_glib_none().0,
830 pspec.as_ref().to_glib_none().0
831 ),
832 "Failed to remove child property"
833 )
834 }
835 }
836
837 /// Edits the start time of an element within its timeline in ripple mode.
838 /// See [`edit()`][Self::edit()] with [`EditMode::Ripple`][crate::EditMode::Ripple] and
839 /// [`Edge::None`][crate::Edge::None].
840 /// ## `start`
841 /// The new start time of `self` in ripple mode
842 ///
843 /// # Returns
844 ///
845 /// [`true`] if the ripple edit of `self` completed, [`false`] on
846 /// failure.
847 #[doc(alias = "ges_timeline_element_ripple")]
848 fn ripple(&self, start: gst::ClockTime) -> Result<(), glib::error::BoolError> {
849 unsafe {
850 glib::result_from_gboolean!(
851 ffi::ges_timeline_element_ripple(self.as_ref().to_glib_none().0, start.into_glib()),
852 "Failed to ripple"
853 )
854 }
855 }
856
857 /// Edits the end time of an element within its timeline in ripple mode.
858 /// See [`edit()`][Self::edit()] with [`EditMode::Ripple`][crate::EditMode::Ripple] and
859 /// [`Edge::End`][crate::Edge::End].
860 /// ## `end`
861 /// The new end time of `self` in ripple mode
862 ///
863 /// # Returns
864 ///
865 /// [`true`] if the ripple edit of `self` completed, [`false`] on
866 /// failure.
867 #[doc(alias = "ges_timeline_element_ripple_end")]
868 fn ripple_end(&self, end: gst::ClockTime) -> Result<(), glib::error::BoolError> {
869 unsafe {
870 glib::result_from_gboolean!(
871 ffi::ges_timeline_element_ripple_end(
872 self.as_ref().to_glib_none().0,
873 end.into_glib()
874 ),
875 "Failed to ripple"
876 )
877 }
878 }
879
880 /// Edits the end time of an element within its timeline in roll mode.
881 /// See [`edit()`][Self::edit()] with [`EditMode::Roll`][crate::EditMode::Roll] and
882 /// [`Edge::End`][crate::Edge::End].
883 /// ## `end`
884 /// The new end time of `self` in roll mode
885 ///
886 /// # Returns
887 ///
888 /// [`true`] if the roll edit of `self` completed, [`false`] on failure.
889 #[doc(alias = "ges_timeline_element_roll_end")]
890 fn roll_end(&self, end: gst::ClockTime) -> Result<(), glib::error::BoolError> {
891 unsafe {
892 glib::result_from_gboolean!(
893 ffi::ges_timeline_element_roll_end(self.as_ref().to_glib_none().0, end.into_glib()),
894 "Failed to roll"
895 )
896 }
897 }
898
899 /// Edits the start time of an element within its timeline in roll mode.
900 /// See [`edit()`][Self::edit()] with [`EditMode::Roll`][crate::EditMode::Roll] and
901 /// [`Edge::Start`][crate::Edge::Start].
902 /// ## `start`
903 /// The new start time of `self` in roll mode
904 ///
905 /// # Returns
906 ///
907 /// [`true`] if the roll edit of `self` completed, [`false`] on failure.
908 #[doc(alias = "ges_timeline_element_roll_start")]
909 fn roll_start(&self, start: gst::ClockTime) -> Result<(), glib::error::BoolError> {
910 unsafe {
911 glib::result_from_gboolean!(
912 ffi::ges_timeline_element_roll_start(
913 self.as_ref().to_glib_none().0,
914 start.into_glib()
915 ),
916 "Failed to roll"
917 )
918 }
919 }
920
921 //#[doc(alias = "ges_timeline_element_set_child_properties")]
922 //fn set_child_properties(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
923 // unsafe { TODO: call ffi:ges_timeline_element_set_child_properties() }
924 //}
925
926 /// Sets the property of a child of the element.
927 ///
928 /// `property_name` can either be in the format "prop-name" or
929 /// "TypeName::prop-name", where "prop-name" is the name of the property
930 /// to set (as used in [`ObjectExt::set()`][crate::glib::prelude::ObjectExt::set()]), and "TypeName" is the type name of
931 /// the child (as returned by G_OBJECT_TYPE_NAME()). The latter format is
932 /// useful when two children of different types share the same property
933 /// name.
934 ///
935 /// The first child found with the given "prop-name" property that was
936 /// registered with [`add_child_property()`][Self::add_child_property()] (and of the
937 /// type "TypeName", if it was given) will have the corresponding
938 /// property set to `value`. Other children that may have also matched the
939 /// property name (and type name) are left unchanged!
940 /// ## `property_name`
941 /// The name of the child property to set
942 /// ## `value`
943 /// The value to set the property to
944 ///
945 /// # Returns
946 ///
947 /// [`true`] if the property was found and set.
948 #[cfg(feature = "v1_18")]
949 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
950 #[doc(alias = "ges_timeline_element_set_child_property_full")]
951 fn set_child_property_full(
952 &self,
953 property_name: &str,
954 value: &glib::Value,
955 ) -> Result<(), glib::Error> {
956 unsafe {
957 let mut error = std::ptr::null_mut();
958 let is_ok = ffi::ges_timeline_element_set_child_property_full(
959 self.as_ref().to_glib_none().0,
960 property_name.to_glib_none().0,
961 value.to_glib_none().0,
962 &mut error,
963 );
964 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
965 if error.is_null() {
966 Ok(())
967 } else {
968 Err(from_glib_full(error))
969 }
970 }
971 }
972
973 //#[doc(alias = "ges_timeline_element_set_child_property_valist")]
974 //fn set_child_property_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
975 // unsafe { TODO: call ffi:ges_timeline_element_set_child_property_valist() }
976 //}
977
978 /// Sets [`duration`][struct@crate::TimelineElement#duration] for the element.
979 ///
980 /// Whilst the element is part of a [`Timeline`][crate::Timeline], this is the same as
981 /// editing the element with [`edit()`][Self::edit()] under
982 /// [`EditMode::Trim`][crate::EditMode::Trim] with [`Edge::End`][crate::Edge::End]. In particular, the
983 /// [`duration`][struct@crate::TimelineElement#duration] of the element may be snapped to a
984 /// different timeline time difference from the one given. In addition,
985 /// setting may fail if it would place the timeline in an unsupported
986 /// configuration, or the element does not have enough internal content to
987 /// last the desired duration.
988 /// ## `duration`
989 /// The desired duration in its timeline
990 ///
991 /// # Returns
992 ///
993 /// [`true`] if `duration` could be set for `self`.
994 #[doc(alias = "ges_timeline_element_set_duration")]
995 #[doc(alias = "duration")]
996 fn set_duration(&self, duration: impl Into<Option<gst::ClockTime>>) -> bool {
997 unsafe {
998 from_glib(ffi::ges_timeline_element_set_duration(
999 self.as_ref().to_glib_none().0,
1000 duration.into().into_glib(),
1001 ))
1002 }
1003 }
1004
1005 /// Sets [`in-point`][struct@crate::TimelineElement#in-point] for the element. If the new in-point
1006 /// is above the current [`max-duration`][struct@crate::TimelineElement#max-duration] of the element,
1007 /// this method will fail.
1008 /// ## `inpoint`
1009 /// The in-point, in internal time coordinates
1010 ///
1011 /// # Returns
1012 ///
1013 /// [`true`] if `inpoint` could be set for `self`.
1014 #[doc(alias = "ges_timeline_element_set_inpoint")]
1015 #[doc(alias = "in-point")]
1016 fn set_inpoint(&self, inpoint: gst::ClockTime) -> bool {
1017 unsafe {
1018 from_glib(ffi::ges_timeline_element_set_inpoint(
1019 self.as_ref().to_glib_none().0,
1020 inpoint.into_glib(),
1021 ))
1022 }
1023 }
1024
1025 /// Sets [`max-duration`][struct@crate::TimelineElement#max-duration] for the element. If the new
1026 /// maximum duration is below the current [`in-point`][struct@crate::TimelineElement#in-point] of
1027 /// the element, this method will fail.
1028 /// ## `maxduration`
1029 /// The maximum duration, in internal time coordinates
1030 ///
1031 /// # Returns
1032 ///
1033 /// [`true`] if `maxduration` could be set for `self`.
1034 #[doc(alias = "ges_timeline_element_set_max_duration")]
1035 #[doc(alias = "max-duration")]
1036 fn set_max_duration(&self, maxduration: impl Into<Option<gst::ClockTime>>) -> bool {
1037 unsafe {
1038 from_glib(ffi::ges_timeline_element_set_max_duration(
1039 self.as_ref().to_glib_none().0,
1040 maxduration.into().into_glib(),
1041 ))
1042 }
1043 }
1044
1045 /// Sets the [`name`][struct@crate::TimelineElement#name] for the element. If [`None`] is given
1046 /// for `name`, then the library will instead generate a new name based on
1047 /// the type name of the element, such as the name "uriclip3" for a
1048 /// [`UriClip`][crate::UriClip], and will set that name instead.
1049 ///
1050 /// If `self` already has a [`timeline`][struct@crate::TimelineElement#timeline], you should not
1051 /// call this function with `name` set to [`None`].
1052 ///
1053 /// You should ensure that, within each [`Timeline`][crate::Timeline], every element has a
1054 /// unique name. If you call this function with `name` as [`None`], then
1055 /// the library should ensure that the set generated name is unique from
1056 /// previously **generated** names. However, if you choose a `name` that
1057 /// interferes with the naming conventions of the library, the library will
1058 /// attempt to ensure that the generated names will not conflict with the
1059 /// chosen name, which may lead to a different name being set instead, but
1060 /// the uniqueness between generated and user-chosen names is not
1061 /// guaranteed.
1062 /// ## `name`
1063 /// The name `self` should take
1064 ///
1065 /// # Returns
1066 ///
1067 /// [`true`] if `name` or a generated name for `self` could be set.
1068 #[doc(alias = "ges_timeline_element_set_name")]
1069 #[doc(alias = "name")]
1070 fn set_name(&self, name: Option<&str>) -> Result<(), glib::error::BoolError> {
1071 unsafe {
1072 glib::result_from_gboolean!(
1073 ffi::ges_timeline_element_set_name(
1074 self.as_ref().to_glib_none().0,
1075 name.to_glib_none().0
1076 ),
1077 "Failed to set name"
1078 )
1079 }
1080 }
1081
1082 /// Sets the [`parent`][struct@crate::TimelineElement#parent] for the element.
1083 ///
1084 /// This is used internally and you should normally not call this. A
1085 /// [`Container`][crate::Container] will set the [`parent`][struct@crate::TimelineElement#parent] of its children
1086 /// in [`GESContainerExt::add()`][crate::prelude::GESContainerExt::add()] and [`GESContainerExt::remove()`][crate::prelude::GESContainerExt::remove()].
1087 ///
1088 /// Note, if `parent` is not [`None`], `self` must not already have a parent
1089 /// set. Therefore, if you wish to switch parents, you will need to call
1090 /// this function twice: first to set the parent to [`None`], and then to the
1091 /// new parent.
1092 ///
1093 /// If `parent` is not [`None`], you must ensure it already has a
1094 /// (non-floating) reference to `self` before calling this.
1095 ///
1096 /// # Returns
1097 ///
1098 /// [`true`] if `parent` could be set for `self`.
1099 #[doc(alias = "ges_timeline_element_set_parent")]
1100 #[doc(alias = "parent")]
1101 fn set_parent(&self, parent: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
1102 unsafe {
1103 glib::result_from_gboolean!(
1104 ffi::ges_timeline_element_set_parent(
1105 self.as_ref().to_glib_none().0,
1106 parent.as_ref().to_glib_none().0
1107 ),
1108 "`TimelineElement` already had a parent or its parent was the same as specified"
1109 )
1110 }
1111 }
1112
1113 /// Sets the priority of the element within the containing layer.
1114 ///
1115 /// # Deprecated since 1.10
1116 ///
1117 /// All priority management is done by GES itself now.
1118 /// To set [`Effect`][crate::Effect] priorities `ges_clip_set_top_effect_index` should
1119 /// be used.
1120 /// ## `priority`
1121 /// The priority
1122 ///
1123 /// # Returns
1124 ///
1125 /// [`true`] if `priority` could be set for `self`.
1126 #[deprecated = "Since 1.10"]
1127 #[allow(deprecated)]
1128 #[doc(alias = "ges_timeline_element_set_priority")]
1129 #[doc(alias = "priority")]
1130 fn set_priority(&self, priority: u32) -> bool {
1131 unsafe {
1132 from_glib(ffi::ges_timeline_element_set_priority(
1133 self.as_ref().to_glib_none().0,
1134 priority,
1135 ))
1136 }
1137 }
1138
1139 /// Sets [`start`][struct@crate::TimelineElement#start] for the element. If the element has a
1140 /// parent, this will also move its siblings with the same shift.
1141 ///
1142 /// Whilst the element is part of a [`Timeline`][crate::Timeline], this is the same as
1143 /// editing the element with [`edit()`][Self::edit()] under
1144 /// [`EditMode::Normal`][crate::EditMode::Normal] with [`Edge::None`][crate::Edge::None]. In particular, the
1145 /// [`start`][struct@crate::TimelineElement#start] of the element may be snapped to a different
1146 /// timeline time from the one given. In addition, setting may fail if it
1147 /// would place the timeline in an unsupported configuration.
1148 /// ## `start`
1149 /// The desired start position of the element in its timeline
1150 ///
1151 /// # Returns
1152 ///
1153 /// [`true`] if `start` could be set for `self`.
1154 #[doc(alias = "ges_timeline_element_set_start")]
1155 #[doc(alias = "start")]
1156 fn set_start(&self, start: gst::ClockTime) -> bool {
1157 unsafe {
1158 from_glib(ffi::ges_timeline_element_set_start(
1159 self.as_ref().to_glib_none().0,
1160 start.into_glib(),
1161 ))
1162 }
1163 }
1164
1165 /// Sets the [`timeline`][struct@crate::TimelineElement#timeline] of the element.
1166 ///
1167 /// This is used internally and you should normally not call this. A
1168 /// [`Clip`][crate::Clip] will have its [`timeline`][struct@crate::TimelineElement#timeline] set through its
1169 /// [`Layer`][crate::Layer]. A [`Track`][crate::Track] will similarly take care of setting the
1170 /// [`timeline`][struct@crate::TimelineElement#timeline] of its [`TrackElement`][crate::TrackElement]-s. A [`Group`][crate::Group]
1171 /// will adopt the same [`timeline`][struct@crate::TimelineElement#timeline] as its children.
1172 ///
1173 /// If `timeline` is [`None`], this will stop its current
1174 /// [`timeline`][struct@crate::TimelineElement#timeline] from tracking it, otherwise `timeline` will
1175 /// start tracking `self`. Note, in the latter case, `self` must not already
1176 /// have a timeline set. Therefore, if you wish to switch timelines, you
1177 /// will need to call this function twice: first to set the timeline to
1178 /// [`None`], and then to the new timeline.
1179 ///
1180 /// # Returns
1181 ///
1182 /// [`true`] if `timeline` could be set for `self`.
1183 #[doc(alias = "ges_timeline_element_set_timeline")]
1184 #[doc(alias = "timeline")]
1185 fn set_timeline(&self, timeline: &impl IsA<Timeline>) -> Result<(), glib::error::BoolError> {
1186 unsafe {
1187 glib::result_from_gboolean!(
1188 ffi::ges_timeline_element_set_timeline(
1189 self.as_ref().to_glib_none().0,
1190 timeline.as_ref().to_glib_none().0
1191 ),
1192 "`Failed to set timeline"
1193 )
1194 }
1195 }
1196
1197 /// Edits the start time of an element within its timeline in trim mode.
1198 /// See [`edit()`][Self::edit()] with [`EditMode::Trim`][crate::EditMode::Trim] and
1199 /// [`Edge::Start`][crate::Edge::Start].
1200 /// ## `start`
1201 /// The new start time of `self` in trim mode
1202 ///
1203 /// # Returns
1204 ///
1205 /// [`true`] if the trim edit of `self` completed, [`false`] on failure.
1206 #[doc(alias = "ges_timeline_element_trim")]
1207 fn trim(&self, start: gst::ClockTime) -> Result<(), glib::error::BoolError> {
1208 unsafe {
1209 glib::result_from_gboolean!(
1210 ffi::ges_timeline_element_trim(self.as_ref().to_glib_none().0, start.into_glib()),
1211 "Failed to trim"
1212 )
1213 }
1214 }
1215
1216 /// Whether the element should be serialized.
1217 fn is_serialize(&self) -> bool {
1218 ObjectExt::property(self.as_ref(), "serialize")
1219 }
1220
1221 /// Whether the element should be serialized.
1222 fn set_serialize(&self, serialize: bool) {
1223 ObjectExt::set_property(self.as_ref(), "serialize", serialize)
1224 }
1225
1226 /// Emitted when the element has a new child property registered. See
1227 /// [`add_child_property()`][Self::add_child_property()].
1228 ///
1229 /// Note that some GES elements will be automatically created with
1230 /// pre-registered children properties. You can use
1231 /// [`list_children_properties()`][Self::list_children_properties()] to list these.
1232 /// ## `prop_object`
1233 /// The child whose property has been registered
1234 /// ## `prop`
1235 /// The specification for the property that has been registered
1236 #[cfg(feature = "v1_18")]
1237 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1238 #[doc(alias = "child-property-added")]
1239 fn connect_child_property_added<F: Fn(&Self, &glib::Object, &glib::ParamSpec) + 'static>(
1240 &self,
1241 f: F,
1242 ) -> SignalHandlerId {
1243 unsafe extern "C" fn child_property_added_trampoline<
1244 P: IsA<TimelineElement>,
1245 F: Fn(&P, &glib::Object, &glib::ParamSpec) + 'static,
1246 >(
1247 this: *mut ffi::GESTimelineElement,
1248 prop_object: *mut glib::gobject_ffi::GObject,
1249 prop: *mut glib::gobject_ffi::GParamSpec,
1250 f: glib::ffi::gpointer,
1251 ) {
1252 let f: &F = &*(f as *const F);
1253 f(
1254 TimelineElement::from_glib_borrow(this).unsafe_cast_ref(),
1255 &from_glib_borrow(prop_object),
1256 &from_glib_borrow(prop),
1257 )
1258 }
1259 unsafe {
1260 let f: Box_<F> = Box_::new(f);
1261 connect_raw(
1262 self.as_ptr() as *mut _,
1263 c"child-property-added".as_ptr() as *const _,
1264 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1265 child_property_added_trampoline::<Self, F> as *const (),
1266 )),
1267 Box_::into_raw(f),
1268 )
1269 }
1270 }
1271
1272 /// Emitted when the element has a child property unregistered. See
1273 /// [`remove_child_property()`][Self::remove_child_property()].
1274 /// ## `prop_object`
1275 /// The child whose property has been unregistered
1276 /// ## `prop`
1277 /// The specification for the property that has been unregistered
1278 #[cfg(feature = "v1_18")]
1279 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1280 #[doc(alias = "child-property-removed")]
1281 fn connect_child_property_removed<F: Fn(&Self, &glib::Object, &glib::ParamSpec) + 'static>(
1282 &self,
1283 f: F,
1284 ) -> SignalHandlerId {
1285 unsafe extern "C" fn child_property_removed_trampoline<
1286 P: IsA<TimelineElement>,
1287 F: Fn(&P, &glib::Object, &glib::ParamSpec) + 'static,
1288 >(
1289 this: *mut ffi::GESTimelineElement,
1290 prop_object: *mut glib::gobject_ffi::GObject,
1291 prop: *mut glib::gobject_ffi::GParamSpec,
1292 f: glib::ffi::gpointer,
1293 ) {
1294 let f: &F = &*(f as *const F);
1295 f(
1296 TimelineElement::from_glib_borrow(this).unsafe_cast_ref(),
1297 &from_glib_borrow(prop_object),
1298 &from_glib_borrow(prop),
1299 )
1300 }
1301 unsafe {
1302 let f: Box_<F> = Box_::new(f);
1303 connect_raw(
1304 self.as_ptr() as *mut _,
1305 c"child-property-removed".as_ptr() as *const _,
1306 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1307 child_property_removed_trampoline::<Self, F> as *const (),
1308 )),
1309 Box_::into_raw(f),
1310 )
1311 }
1312 }
1313
1314 /// Emitted when a child of the element has one of its registered
1315 /// properties set. See [`add_child_property()`][Self::add_child_property()].
1316 /// Note that unlike [`notify`][struct@crate::glib::Object#notify], a child property name can not be
1317 /// used as a signal detail.
1318 /// ## `prop_object`
1319 /// The child whose property has been set
1320 /// ## `prop`
1321 /// The specification for the property that been set
1322 #[doc(alias = "deep-notify")]
1323 fn connect_deep_notify<F: Fn(&Self, &glib::Object, &glib::ParamSpec) + 'static>(
1324 &self,
1325 detail: Option<&str>,
1326 f: F,
1327 ) -> SignalHandlerId {
1328 unsafe extern "C" fn deep_notify_trampoline<
1329 P: IsA<TimelineElement>,
1330 F: Fn(&P, &glib::Object, &glib::ParamSpec) + 'static,
1331 >(
1332 this: *mut ffi::GESTimelineElement,
1333 prop_object: *mut glib::gobject_ffi::GObject,
1334 prop: *mut glib::gobject_ffi::GParamSpec,
1335 f: glib::ffi::gpointer,
1336 ) {
1337 let f: &F = &*(f as *const F);
1338 f(
1339 TimelineElement::from_glib_borrow(this).unsafe_cast_ref(),
1340 &from_glib_borrow(prop_object),
1341 &from_glib_borrow(prop),
1342 )
1343 }
1344 unsafe {
1345 let f: Box_<F> = Box_::new(f);
1346 let detailed_signal_name = detail.map(|name| format!("deep-notify::{name}\0"));
1347 let signal_name: &[u8] = detailed_signal_name
1348 .as_ref()
1349 .map_or(c"deep-notify".to_bytes(), |n| n.as_bytes());
1350 connect_raw(
1351 self.as_ptr() as *mut _,
1352 signal_name.as_ptr() as *const _,
1353 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1354 deep_notify_trampoline::<Self, F> as *const (),
1355 )),
1356 Box_::into_raw(f),
1357 )
1358 }
1359 }
1360
1361 #[doc(alias = "duration")]
1362 fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1363 unsafe extern "C" fn notify_duration_trampoline<
1364 P: IsA<TimelineElement>,
1365 F: Fn(&P) + 'static,
1366 >(
1367 this: *mut ffi::GESTimelineElement,
1368 _param_spec: glib::ffi::gpointer,
1369 f: glib::ffi::gpointer,
1370 ) {
1371 let f: &F = &*(f as *const F);
1372 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1373 }
1374 unsafe {
1375 let f: Box_<F> = Box_::new(f);
1376 connect_raw(
1377 self.as_ptr() as *mut _,
1378 c"notify::duration".as_ptr() as *const _,
1379 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1380 notify_duration_trampoline::<Self, F> as *const (),
1381 )),
1382 Box_::into_raw(f),
1383 )
1384 }
1385 }
1386
1387 #[doc(alias = "in-point")]
1388 fn connect_in_point_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1389 unsafe extern "C" fn notify_in_point_trampoline<
1390 P: IsA<TimelineElement>,
1391 F: Fn(&P) + 'static,
1392 >(
1393 this: *mut ffi::GESTimelineElement,
1394 _param_spec: glib::ffi::gpointer,
1395 f: glib::ffi::gpointer,
1396 ) {
1397 let f: &F = &*(f as *const F);
1398 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1399 }
1400 unsafe {
1401 let f: Box_<F> = Box_::new(f);
1402 connect_raw(
1403 self.as_ptr() as *mut _,
1404 c"notify::in-point".as_ptr() as *const _,
1405 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1406 notify_in_point_trampoline::<Self, F> as *const (),
1407 )),
1408 Box_::into_raw(f),
1409 )
1410 }
1411 }
1412
1413 #[doc(alias = "max-duration")]
1414 fn connect_max_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1415 unsafe extern "C" fn notify_max_duration_trampoline<
1416 P: IsA<TimelineElement>,
1417 F: Fn(&P) + 'static,
1418 >(
1419 this: *mut ffi::GESTimelineElement,
1420 _param_spec: glib::ffi::gpointer,
1421 f: glib::ffi::gpointer,
1422 ) {
1423 let f: &F = &*(f as *const F);
1424 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1425 }
1426 unsafe {
1427 let f: Box_<F> = Box_::new(f);
1428 connect_raw(
1429 self.as_ptr() as *mut _,
1430 c"notify::max-duration".as_ptr() as *const _,
1431 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1432 notify_max_duration_trampoline::<Self, F> as *const (),
1433 )),
1434 Box_::into_raw(f),
1435 )
1436 }
1437 }
1438
1439 #[doc(alias = "name")]
1440 fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1441 unsafe extern "C" fn notify_name_trampoline<
1442 P: IsA<TimelineElement>,
1443 F: Fn(&P) + 'static,
1444 >(
1445 this: *mut ffi::GESTimelineElement,
1446 _param_spec: glib::ffi::gpointer,
1447 f: glib::ffi::gpointer,
1448 ) {
1449 let f: &F = &*(f as *const F);
1450 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1451 }
1452 unsafe {
1453 let f: Box_<F> = Box_::new(f);
1454 connect_raw(
1455 self.as_ptr() as *mut _,
1456 c"notify::name".as_ptr() as *const _,
1457 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1458 notify_name_trampoline::<Self, F> as *const (),
1459 )),
1460 Box_::into_raw(f),
1461 )
1462 }
1463 }
1464
1465 #[doc(alias = "parent")]
1466 fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1467 unsafe extern "C" fn notify_parent_trampoline<
1468 P: IsA<TimelineElement>,
1469 F: Fn(&P) + 'static,
1470 >(
1471 this: *mut ffi::GESTimelineElement,
1472 _param_spec: glib::ffi::gpointer,
1473 f: glib::ffi::gpointer,
1474 ) {
1475 let f: &F = &*(f as *const F);
1476 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1477 }
1478 unsafe {
1479 let f: Box_<F> = Box_::new(f);
1480 connect_raw(
1481 self.as_ptr() as *mut _,
1482 c"notify::parent".as_ptr() as *const _,
1483 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1484 notify_parent_trampoline::<Self, F> as *const (),
1485 )),
1486 Box_::into_raw(f),
1487 )
1488 }
1489 }
1490
1491 #[deprecated = "Since 1.10"]
1492 #[doc(alias = "priority")]
1493 fn connect_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1494 unsafe extern "C" fn notify_priority_trampoline<
1495 P: IsA<TimelineElement>,
1496 F: Fn(&P) + 'static,
1497 >(
1498 this: *mut ffi::GESTimelineElement,
1499 _param_spec: glib::ffi::gpointer,
1500 f: glib::ffi::gpointer,
1501 ) {
1502 let f: &F = &*(f as *const F);
1503 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1504 }
1505 unsafe {
1506 let f: Box_<F> = Box_::new(f);
1507 connect_raw(
1508 self.as_ptr() as *mut _,
1509 c"notify::priority".as_ptr() as *const _,
1510 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1511 notify_priority_trampoline::<Self, F> as *const (),
1512 )),
1513 Box_::into_raw(f),
1514 )
1515 }
1516 }
1517
1518 #[doc(alias = "serialize")]
1519 fn connect_serialize_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1520 unsafe extern "C" fn notify_serialize_trampoline<
1521 P: IsA<TimelineElement>,
1522 F: Fn(&P) + 'static,
1523 >(
1524 this: *mut ffi::GESTimelineElement,
1525 _param_spec: glib::ffi::gpointer,
1526 f: glib::ffi::gpointer,
1527 ) {
1528 let f: &F = &*(f as *const F);
1529 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1530 }
1531 unsafe {
1532 let f: Box_<F> = Box_::new(f);
1533 connect_raw(
1534 self.as_ptr() as *mut _,
1535 c"notify::serialize".as_ptr() as *const _,
1536 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1537 notify_serialize_trampoline::<Self, F> as *const (),
1538 )),
1539 Box_::into_raw(f),
1540 )
1541 }
1542 }
1543
1544 #[doc(alias = "start")]
1545 fn connect_start_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1546 unsafe extern "C" fn notify_start_trampoline<
1547 P: IsA<TimelineElement>,
1548 F: Fn(&P) + 'static,
1549 >(
1550 this: *mut ffi::GESTimelineElement,
1551 _param_spec: glib::ffi::gpointer,
1552 f: glib::ffi::gpointer,
1553 ) {
1554 let f: &F = &*(f as *const F);
1555 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1556 }
1557 unsafe {
1558 let f: Box_<F> = Box_::new(f);
1559 connect_raw(
1560 self.as_ptr() as *mut _,
1561 c"notify::start".as_ptr() as *const _,
1562 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1563 notify_start_trampoline::<Self, F> as *const (),
1564 )),
1565 Box_::into_raw(f),
1566 )
1567 }
1568 }
1569
1570 #[doc(alias = "timeline")]
1571 fn connect_timeline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1572 unsafe extern "C" fn notify_timeline_trampoline<
1573 P: IsA<TimelineElement>,
1574 F: Fn(&P) + 'static,
1575 >(
1576 this: *mut ffi::GESTimelineElement,
1577 _param_spec: glib::ffi::gpointer,
1578 f: glib::ffi::gpointer,
1579 ) {
1580 let f: &F = &*(f as *const F);
1581 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1582 }
1583 unsafe {
1584 let f: Box_<F> = Box_::new(f);
1585 connect_raw(
1586 self.as_ptr() as *mut _,
1587 c"notify::timeline".as_ptr() as *const _,
1588 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1589 notify_timeline_trampoline::<Self, F> as *const (),
1590 )),
1591 Box_::into_raw(f),
1592 )
1593 }
1594 }
1595}
1596
1597impl<O: IsA<TimelineElement>> TimelineElementExt for O {}