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
7#[cfg(feature = "v1_18")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
9use crate::{Edge, EditMode, Layer};
10use crate::{Extractable, MetaContainer, Timeline, TrackType, ffi};
11use glib::{
12 object::ObjectType as _,
13 prelude::*,
14 signal::{SignalHandlerId, connect_raw},
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 { Some(value) } else { None }
451 }
452 }
453
454 /// Gets the property of a child of the element. Specifically, the property
455 /// corresponding to the `pspec` used in
456 /// [`add_child_property()`][Self::add_child_property()] is copied into `value`.
457 /// ## `pspec`
458 /// The specification of a registered child property to get
459 ///
460 /// # Returns
461 ///
462 ///
463 /// ## `value`
464 /// The return location for the value
465 #[doc(alias = "ges_timeline_element_get_child_property_by_pspec")]
466 #[doc(alias = "get_child_property_by_pspec")]
467 fn child_property_by_pspec(&self, pspec: impl AsRef<glib::ParamSpec>) -> glib::Value {
468 unsafe {
469 let mut value = glib::Value::uninitialized();
470 ffi::ges_timeline_element_get_child_property_by_pspec(
471 self.as_ref().to_glib_none().0,
472 pspec.as_ref().to_glib_none().0,
473 value.to_glib_none_mut().0,
474 );
475 value
476 }
477 }
478
479 //#[doc(alias = "ges_timeline_element_get_child_property_valist")]
480 //#[doc(alias = "get_child_property_valist")]
481 //fn child_property_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
482 // unsafe { TODO: call ffi:ges_timeline_element_get_child_property_valist() }
483 //}
484
485 /// Gets the [`duration`][struct@crate::TimelineElement#duration] for the element.
486 ///
487 /// # Returns
488 ///
489 /// The duration of `self` (in nanoseconds).
490 #[doc(alias = "ges_timeline_element_get_duration")]
491 #[doc(alias = "get_duration")]
492 fn duration(&self) -> gst::ClockTime {
493 unsafe {
494 try_from_glib(ffi::ges_timeline_element_get_duration(
495 self.as_ref().to_glib_none().0,
496 ))
497 .expect("mandatory glib value is None")
498 }
499 }
500
501 /// Gets the [`in-point`][struct@crate::TimelineElement#in-point] for the element.
502 ///
503 /// # Returns
504 ///
505 /// The in-point of `self` (in nanoseconds).
506 #[doc(alias = "ges_timeline_element_get_inpoint")]
507 #[doc(alias = "get_inpoint")]
508 #[doc(alias = "in-point")]
509 fn inpoint(&self) -> gst::ClockTime {
510 unsafe {
511 try_from_glib(ffi::ges_timeline_element_get_inpoint(
512 self.as_ref().to_glib_none().0,
513 ))
514 .expect("mandatory glib value is None")
515 }
516 }
517
518 /// Gets the priority of the layer the element is in. A [`Group`][crate::Group] may span
519 /// several layers, so this would return the highest priority (numerically,
520 /// the smallest) amongst them.
521 ///
522 /// # Returns
523 ///
524 /// The priority of the layer `self` is in, or
525 /// `GES_TIMELINE_ELEMENT_NO_LAYER_PRIORITY` if `self` does not exist in a
526 /// layer.
527 #[cfg(feature = "v1_16")]
528 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
529 #[doc(alias = "ges_timeline_element_get_layer_priority")]
530 #[doc(alias = "get_layer_priority")]
531 fn layer_priority(&self) -> u32 {
532 unsafe { ffi::ges_timeline_element_get_layer_priority(self.as_ref().to_glib_none().0) }
533 }
534
535 /// Gets the [`max-duration`][struct@crate::TimelineElement#max-duration] for the element.
536 ///
537 /// # Returns
538 ///
539 /// The max-duration of `self` (in nanoseconds).
540 #[doc(alias = "ges_timeline_element_get_max_duration")]
541 #[doc(alias = "get_max_duration")]
542 #[doc(alias = "max-duration")]
543 fn max_duration(&self) -> Option<gst::ClockTime> {
544 unsafe {
545 from_glib(ffi::ges_timeline_element_get_max_duration(
546 self.as_ref().to_glib_none().0,
547 ))
548 }
549 }
550
551 /// Gets the [`name`][struct@crate::TimelineElement#name] for the element.
552 ///
553 /// # Returns
554 ///
555 /// The name of `self`.
556 #[doc(alias = "ges_timeline_element_get_name")]
557 #[doc(alias = "get_name")]
558 fn name(&self) -> Option<glib::GString> {
559 unsafe {
560 from_glib_full(ffi::ges_timeline_element_get_name(
561 self.as_ref().to_glib_none().0,
562 ))
563 }
564 }
565
566 /// Get the "natural" framerate of `self`. This is to say, for example
567 /// for a [`VideoUriSource`][crate::VideoUriSource] the framerate of the source.
568 ///
569 /// Note that a [`AudioSource`][crate::AudioSource] may also have a natural framerate if it derives
570 /// from the same [`SourceClip`][crate::SourceClip] asset as a [`VideoSource`][crate::VideoSource], and its value will
571 /// be that of the video source. For example, if the uri of a [`UriClip`][crate::UriClip] points
572 /// to a file that contains both a video and audio stream, then the corresponding
573 /// [`AudioUriSource`][crate::AudioUriSource] will share the natural framerate of the corresponding
574 /// [`VideoUriSource`][crate::VideoUriSource].
575 ///
576 /// # Returns
577 ///
578 /// Whether `self` has a natural framerate or not, `framerate_n`
579 /// and `framerate_d` will be set to, respectively, 0 and -1 if it is
580 /// not the case.
581 ///
582 /// ## `framerate_n`
583 /// The framerate numerator
584 ///
585 /// ## `framerate_d`
586 /// The framerate denominator
587 #[cfg(feature = "v1_18")]
588 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
589 #[doc(alias = "ges_timeline_element_get_natural_framerate")]
590 #[doc(alias = "get_natural_framerate")]
591 fn natural_framerate(&self) -> Option<(i32, i32)> {
592 unsafe {
593 let mut framerate_n = std::mem::MaybeUninit::uninit();
594 let mut framerate_d = std::mem::MaybeUninit::uninit();
595 let ret = from_glib(ffi::ges_timeline_element_get_natural_framerate(
596 self.as_ref().to_glib_none().0,
597 framerate_n.as_mut_ptr(),
598 framerate_d.as_mut_ptr(),
599 ));
600 if ret {
601 Some((framerate_n.assume_init(), framerate_d.assume_init()))
602 } else {
603 None
604 }
605 }
606 }
607
608 /// Gets the [`parent`][struct@crate::TimelineElement#parent] for the element.
609 ///
610 /// # Returns
611 ///
612 /// The parent of `self`, or [`None`] if
613 /// `self` has no parent.
614 #[doc(alias = "ges_timeline_element_get_parent")]
615 #[doc(alias = "get_parent")]
616 #[must_use]
617 fn parent(&self) -> Option<TimelineElement> {
618 unsafe {
619 from_glib_full(ffi::ges_timeline_element_get_parent(
620 self.as_ref().to_glib_none().0,
621 ))
622 }
623 }
624
625 /// Gets the [`priority`][struct@crate::TimelineElement#priority] for the element.
626 ///
627 /// # Returns
628 ///
629 /// The priority of `self`.
630 #[doc(alias = "ges_timeline_element_get_priority")]
631 #[doc(alias = "get_priority")]
632 fn priority(&self) -> u32 {
633 unsafe { ffi::ges_timeline_element_get_priority(self.as_ref().to_glib_none().0) }
634 }
635
636 /// Gets the [`start`][struct@crate::TimelineElement#start] for the element.
637 ///
638 /// # Returns
639 ///
640 /// The start of `self` (in nanoseconds).
641 #[doc(alias = "ges_timeline_element_get_start")]
642 #[doc(alias = "get_start")]
643 fn start(&self) -> gst::ClockTime {
644 unsafe {
645 try_from_glib(ffi::ges_timeline_element_get_start(
646 self.as_ref().to_glib_none().0,
647 ))
648 .expect("mandatory glib value is None")
649 }
650 }
651
652 /// Gets the [`timeline`][struct@crate::TimelineElement#timeline] for the element.
653 ///
654 /// # Returns
655 ///
656 /// The timeline of `self`, or [`None`]
657 /// if `self` has no timeline.
658 #[doc(alias = "ges_timeline_element_get_timeline")]
659 #[doc(alias = "get_timeline")]
660 fn timeline(&self) -> Option<Timeline> {
661 unsafe {
662 from_glib_full(ffi::ges_timeline_element_get_timeline(
663 self.as_ref().to_glib_none().0,
664 ))
665 }
666 }
667
668 /// Gets the toplevel [`parent`][struct@crate::TimelineElement#parent] of the element.
669 ///
670 /// # Returns
671 ///
672 /// The toplevel parent of `self`.
673 #[doc(alias = "ges_timeline_element_get_toplevel_parent")]
674 #[doc(alias = "get_toplevel_parent")]
675 #[must_use]
676 fn toplevel_parent(&self) -> TimelineElement {
677 unsafe {
678 from_glib_full(ffi::ges_timeline_element_get_toplevel_parent(
679 self.as_ref().to_glib_none().0,
680 ))
681 }
682 }
683
684 /// Gets the track types that the element can interact with, i.e. the type
685 /// of [`Track`][crate::Track] it can exist in, or will create [`TrackElement`][crate::TrackElement]-s for.
686 ///
687 /// # Returns
688 ///
689 /// The track types that `self` supports.
690 #[doc(alias = "ges_timeline_element_get_track_types")]
691 #[doc(alias = "get_track_types")]
692 fn track_types(&self) -> TrackType {
693 unsafe {
694 from_glib(ffi::ges_timeline_element_get_track_types(
695 self.as_ref().to_glib_none().0,
696 ))
697 }
698 }
699
700 /// Get a list of children properties of the element, which is a list of
701 /// all the specifications passed to
702 /// [`add_child_property()`][Self::add_child_property()].
703 ///
704 /// # Returns
705 ///
706 /// An array of
707 /// [`glib::ParamSpec`][crate::glib::ParamSpec] corresponding to the child properties of `self`, or [`None`] if
708 /// something went wrong.
709 #[doc(alias = "ges_timeline_element_list_children_properties")]
710 fn list_children_properties(&self) -> Vec<glib::ParamSpec> {
711 unsafe {
712 let mut n_properties = std::mem::MaybeUninit::uninit();
713 let ret = FromGlibContainer::from_glib_full_num(
714 ffi::ges_timeline_element_list_children_properties(
715 self.as_ref().to_glib_none().0,
716 n_properties.as_mut_ptr(),
717 ),
718 n_properties.assume_init() as _,
719 );
720 ret
721 }
722 }
723
724 /// Looks up a child property of the element.
725 ///
726 /// `prop_name` can either be in the format "prop-name" or
727 /// "TypeName::prop-name", where "prop-name" is the name of the property
728 /// to look up (as used in [`ObjectExt::get()`][crate::glib::prelude::ObjectExt::get()]), and "TypeName" is the type name
729 /// of the child (as returned by G_OBJECT_TYPE_NAME()). The latter format is
730 /// useful when two children of different types share the same property
731 /// name.
732 ///
733 /// The first child found with the given "prop-name" property that was
734 /// registered with [`add_child_property()`][Self::add_child_property()] (and of the
735 /// type "TypeName", if it was given) will be passed to `child`, and the
736 /// registered specification of this property will be passed to `pspec`.
737 /// ## `prop_name`
738 /// The name of a child property
739 ///
740 /// # Returns
741 ///
742 /// [`true`] if a child corresponding to the property was found, in
743 /// which case `child` and `pspec` are set.
744 ///
745 /// ## `child`
746 /// The return location for the
747 /// found child
748 ///
749 /// ## `pspec`
750 /// The return location for the
751 /// specification of the child property
752 #[doc(alias = "ges_timeline_element_lookup_child")]
753 fn lookup_child(&self, prop_name: &str) -> Option<(glib::Object, glib::ParamSpec)> {
754 unsafe {
755 let mut child = std::ptr::null_mut();
756 let mut pspec = std::ptr::null_mut();
757 let ret = from_glib(ffi::ges_timeline_element_lookup_child(
758 self.as_ref().to_glib_none().0,
759 prop_name.to_glib_none().0,
760 &mut child,
761 &mut pspec,
762 ));
763 if ret {
764 Some((from_glib_full(child), from_glib_full(pspec)))
765 } else {
766 None
767 }
768 }
769 }
770
771 /// Paste an element inside the same timeline and layer as `self`. `self`
772 /// **must** be the return of `ges_timeline_element_copy()` with `deep=TRUE`,
773 /// and it should not be changed before pasting.
774 /// `self` is not placed in the timeline, instead a new element is created,
775 /// alike to the originally copied element. Note that the originally
776 /// copied element must stay within the same timeline and layer, at both
777 /// the point of copying and pasting.
778 ///
779 /// Pasting may fail if it would place the timeline in an unsupported
780 /// configuration.
781 ///
782 /// After calling this function `element` should not be used. In particular,
783 /// `element` can **not** be pasted again. Instead, you can copy the
784 /// returned element and paste that copy (although, this is only possible
785 /// if the paste was successful).
786 ///
787 /// See also [`TimelineExt::paste_element()`][crate::prelude::TimelineExt::paste_element()].
788 /// ## `paste_position`
789 /// The position in the timeline `element` should be pasted
790 /// to, i.e. the [`start`][struct@crate::TimelineElement#start] value for the pasted element.
791 ///
792 /// # Returns
793 ///
794 /// The newly created element, or
795 /// [`None`] if pasting fails.
796 #[doc(alias = "ges_timeline_element_paste")]
797 fn paste(&self, paste_position: gst::ClockTime) -> Result<TimelineElement, glib::BoolError> {
798 unsafe {
799 Option::<_>::from_glib_full(ffi::ges_timeline_element_paste(
800 self.as_ref().to_glib_none().0,
801 paste_position.into_glib(),
802 ))
803 .ok_or_else(|| glib::bool_error!("Failed to paste timeline element"))
804 }
805 }
806
807 /// Remove a child property from the element. `pspec` should be a
808 /// specification that was passed to
809 /// [`add_child_property()`][Self::add_child_property()]. The corresponding property
810 /// will no longer be registered as a child property for the element.
811 /// ## `pspec`
812 /// The specification for the property to remove
813 ///
814 /// # Returns
815 ///
816 /// [`true`] if the property was successfully un-registered for `self`.
817 #[doc(alias = "ges_timeline_element_remove_child_property")]
818 fn remove_child_property(
819 &self,
820 pspec: impl AsRef<glib::ParamSpec>,
821 ) -> Result<(), glib::error::BoolError> {
822 unsafe {
823 glib::result_from_gboolean!(
824 ffi::ges_timeline_element_remove_child_property(
825 self.as_ref().to_glib_none().0,
826 pspec.as_ref().to_glib_none().0
827 ),
828 "Failed to remove child property"
829 )
830 }
831 }
832
833 /// Edits the start time of an element within its timeline in ripple mode.
834 /// See [`edit()`][Self::edit()] with [`EditMode::Ripple`][crate::EditMode::Ripple] and
835 /// [`Edge::None`][crate::Edge::None].
836 /// ## `start`
837 /// The new start time of `self` in ripple mode
838 ///
839 /// # Returns
840 ///
841 /// [`true`] if the ripple edit of `self` completed, [`false`] on
842 /// failure.
843 #[doc(alias = "ges_timeline_element_ripple")]
844 fn ripple(&self, start: gst::ClockTime) -> Result<(), glib::error::BoolError> {
845 unsafe {
846 glib::result_from_gboolean!(
847 ffi::ges_timeline_element_ripple(self.as_ref().to_glib_none().0, start.into_glib()),
848 "Failed to ripple"
849 )
850 }
851 }
852
853 /// Edits the end time of an element within its timeline in ripple mode.
854 /// See [`edit()`][Self::edit()] with [`EditMode::Ripple`][crate::EditMode::Ripple] and
855 /// [`Edge::End`][crate::Edge::End].
856 /// ## `end`
857 /// The new end time of `self` in ripple mode
858 ///
859 /// # Returns
860 ///
861 /// [`true`] if the ripple edit of `self` completed, [`false`] on
862 /// failure.
863 #[doc(alias = "ges_timeline_element_ripple_end")]
864 fn ripple_end(&self, end: gst::ClockTime) -> Result<(), glib::error::BoolError> {
865 unsafe {
866 glib::result_from_gboolean!(
867 ffi::ges_timeline_element_ripple_end(
868 self.as_ref().to_glib_none().0,
869 end.into_glib()
870 ),
871 "Failed to ripple"
872 )
873 }
874 }
875
876 /// Edits the end time of an element within its timeline in roll mode.
877 /// See [`edit()`][Self::edit()] with [`EditMode::Roll`][crate::EditMode::Roll] and
878 /// [`Edge::End`][crate::Edge::End].
879 /// ## `end`
880 /// The new end time of `self` in roll mode
881 ///
882 /// # Returns
883 ///
884 /// [`true`] if the roll edit of `self` completed, [`false`] on failure.
885 #[doc(alias = "ges_timeline_element_roll_end")]
886 fn roll_end(&self, end: gst::ClockTime) -> Result<(), glib::error::BoolError> {
887 unsafe {
888 glib::result_from_gboolean!(
889 ffi::ges_timeline_element_roll_end(self.as_ref().to_glib_none().0, end.into_glib()),
890 "Failed to roll"
891 )
892 }
893 }
894
895 /// Edits the start time of an element within its timeline in roll mode.
896 /// See [`edit()`][Self::edit()] with [`EditMode::Roll`][crate::EditMode::Roll] and
897 /// [`Edge::Start`][crate::Edge::Start].
898 /// ## `start`
899 /// The new start time of `self` in roll mode
900 ///
901 /// # Returns
902 ///
903 /// [`true`] if the roll edit of `self` completed, [`false`] on failure.
904 #[doc(alias = "ges_timeline_element_roll_start")]
905 fn roll_start(&self, start: gst::ClockTime) -> Result<(), glib::error::BoolError> {
906 unsafe {
907 glib::result_from_gboolean!(
908 ffi::ges_timeline_element_roll_start(
909 self.as_ref().to_glib_none().0,
910 start.into_glib()
911 ),
912 "Failed to roll"
913 )
914 }
915 }
916
917 //#[doc(alias = "ges_timeline_element_set_child_properties")]
918 //fn set_child_properties(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
919 // unsafe { TODO: call ffi:ges_timeline_element_set_child_properties() }
920 //}
921
922 /// Sets the property of a child of the element.
923 ///
924 /// `property_name` can either be in the format "prop-name" or
925 /// "TypeName::prop-name", where "prop-name" is the name of the property
926 /// to set (as used in [`ObjectExt::set()`][crate::glib::prelude::ObjectExt::set()]), and "TypeName" is the type name of
927 /// the child (as returned by G_OBJECT_TYPE_NAME()). The latter format is
928 /// useful when two children of different types share the same property
929 /// name.
930 ///
931 /// The first child found with the given "prop-name" property that was
932 /// registered with [`add_child_property()`][Self::add_child_property()] (and of the
933 /// type "TypeName", if it was given) will have the corresponding
934 /// property set to `value`. Other children that may have also matched the
935 /// property name (and type name) are left unchanged!
936 /// ## `property_name`
937 /// The name of the child property to set
938 /// ## `value`
939 /// The value to set the property to
940 ///
941 /// # Returns
942 ///
943 /// [`true`] if the property was found and set.
944 #[cfg(feature = "v1_18")]
945 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
946 #[doc(alias = "ges_timeline_element_set_child_property_full")]
947 fn set_child_property_full(
948 &self,
949 property_name: &str,
950 value: &glib::Value,
951 ) -> Result<(), glib::Error> {
952 unsafe {
953 let mut error = std::ptr::null_mut();
954 let is_ok = ffi::ges_timeline_element_set_child_property_full(
955 self.as_ref().to_glib_none().0,
956 property_name.to_glib_none().0,
957 value.to_glib_none().0,
958 &mut error,
959 );
960 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
961 if error.is_null() {
962 Ok(())
963 } else {
964 Err(from_glib_full(error))
965 }
966 }
967 }
968
969 //#[doc(alias = "ges_timeline_element_set_child_property_valist")]
970 //fn set_child_property_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
971 // unsafe { TODO: call ffi:ges_timeline_element_set_child_property_valist() }
972 //}
973
974 /// Sets [`duration`][struct@crate::TimelineElement#duration] for the element.
975 ///
976 /// Whilst the element is part of a [`Timeline`][crate::Timeline], this is the same as
977 /// editing the element with [`edit()`][Self::edit()] under
978 /// [`EditMode::Trim`][crate::EditMode::Trim] with [`Edge::End`][crate::Edge::End]. In particular, the
979 /// [`duration`][struct@crate::TimelineElement#duration] of the element may be snapped to a
980 /// different timeline time difference from the one given. In addition,
981 /// setting may fail if it would place the timeline in an unsupported
982 /// configuration, or the element does not have enough internal content to
983 /// last the desired duration.
984 /// ## `duration`
985 /// The desired duration in its timeline
986 ///
987 /// # Returns
988 ///
989 /// [`true`] if `duration` could be set for `self`.
990 #[doc(alias = "ges_timeline_element_set_duration")]
991 #[doc(alias = "duration")]
992 fn set_duration(&self, duration: impl Into<Option<gst::ClockTime>>) -> bool {
993 unsafe {
994 from_glib(ffi::ges_timeline_element_set_duration(
995 self.as_ref().to_glib_none().0,
996 duration.into().into_glib(),
997 ))
998 }
999 }
1000
1001 /// Sets [`in-point`][struct@crate::TimelineElement#in-point] for the element. If the new in-point
1002 /// is above the current [`max-duration`][struct@crate::TimelineElement#max-duration] of the element,
1003 /// this method will fail.
1004 /// ## `inpoint`
1005 /// The in-point, in internal time coordinates
1006 ///
1007 /// # Returns
1008 ///
1009 /// [`true`] if `inpoint` could be set for `self`.
1010 #[doc(alias = "ges_timeline_element_set_inpoint")]
1011 #[doc(alias = "in-point")]
1012 fn set_inpoint(&self, inpoint: gst::ClockTime) -> bool {
1013 unsafe {
1014 from_glib(ffi::ges_timeline_element_set_inpoint(
1015 self.as_ref().to_glib_none().0,
1016 inpoint.into_glib(),
1017 ))
1018 }
1019 }
1020
1021 /// Sets [`max-duration`][struct@crate::TimelineElement#max-duration] for the element. If the new
1022 /// maximum duration is below the current [`in-point`][struct@crate::TimelineElement#in-point] of
1023 /// the element, this method will fail.
1024 /// ## `maxduration`
1025 /// The maximum duration, in internal time coordinates
1026 ///
1027 /// # Returns
1028 ///
1029 /// [`true`] if `maxduration` could be set for `self`.
1030 #[doc(alias = "ges_timeline_element_set_max_duration")]
1031 #[doc(alias = "max-duration")]
1032 fn set_max_duration(&self, maxduration: impl Into<Option<gst::ClockTime>>) -> bool {
1033 unsafe {
1034 from_glib(ffi::ges_timeline_element_set_max_duration(
1035 self.as_ref().to_glib_none().0,
1036 maxduration.into().into_glib(),
1037 ))
1038 }
1039 }
1040
1041 /// Sets the [`name`][struct@crate::TimelineElement#name] for the element. If [`None`] is given
1042 /// for `name`, then the library will instead generate a new name based on
1043 /// the type name of the element, such as the name "uriclip3" for a
1044 /// [`UriClip`][crate::UriClip], and will set that name instead.
1045 ///
1046 /// If `self` already has a [`timeline`][struct@crate::TimelineElement#timeline], you should not
1047 /// call this function with `name` set to [`None`].
1048 ///
1049 /// You should ensure that, within each [`Timeline`][crate::Timeline], every element has a
1050 /// unique name. If you call this function with `name` as [`None`], then
1051 /// the library should ensure that the set generated name is unique from
1052 /// previously **generated** names. However, if you choose a `name` that
1053 /// interferes with the naming conventions of the library, the library will
1054 /// attempt to ensure that the generated names will not conflict with the
1055 /// chosen name, which may lead to a different name being set instead, but
1056 /// the uniqueness between generated and user-chosen names is not
1057 /// guaranteed.
1058 /// ## `name`
1059 /// The name `self` should take
1060 ///
1061 /// # Returns
1062 ///
1063 /// [`true`] if `name` or a generated name for `self` could be set.
1064 #[doc(alias = "ges_timeline_element_set_name")]
1065 #[doc(alias = "name")]
1066 fn set_name(&self, name: Option<&str>) -> Result<(), glib::error::BoolError> {
1067 unsafe {
1068 glib::result_from_gboolean!(
1069 ffi::ges_timeline_element_set_name(
1070 self.as_ref().to_glib_none().0,
1071 name.to_glib_none().0
1072 ),
1073 "Failed to set name"
1074 )
1075 }
1076 }
1077
1078 /// Sets the [`parent`][struct@crate::TimelineElement#parent] for the element.
1079 ///
1080 /// This is used internally and you should normally not call this. A
1081 /// [`Container`][crate::Container] will set the [`parent`][struct@crate::TimelineElement#parent] of its children
1082 /// in [`GESContainerExt::add()`][crate::prelude::GESContainerExt::add()] and [`GESContainerExt::remove()`][crate::prelude::GESContainerExt::remove()].
1083 ///
1084 /// Note, if `parent` is not [`None`], `self` must not already have a parent
1085 /// set. Therefore, if you wish to switch parents, you will need to call
1086 /// this function twice: first to set the parent to [`None`], and then to the
1087 /// new parent.
1088 ///
1089 /// If `parent` is not [`None`], you must ensure it already has a
1090 /// (non-floating) reference to `self` before calling this.
1091 ///
1092 /// # Returns
1093 ///
1094 /// [`true`] if `parent` could be set for `self`.
1095 #[doc(alias = "ges_timeline_element_set_parent")]
1096 #[doc(alias = "parent")]
1097 fn set_parent(&self, parent: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
1098 unsafe {
1099 glib::result_from_gboolean!(
1100 ffi::ges_timeline_element_set_parent(
1101 self.as_ref().to_glib_none().0,
1102 parent.as_ref().to_glib_none().0
1103 ),
1104 "`TimelineElement` already had a parent or its parent was the same as specified"
1105 )
1106 }
1107 }
1108
1109 /// Sets the priority of the element within the containing layer.
1110 ///
1111 /// # Deprecated since 1.10
1112 ///
1113 /// All priority management is done by GES itself now.
1114 /// To set [`Effect`][crate::Effect] priorities `ges_clip_set_top_effect_index` should
1115 /// be used.
1116 /// ## `priority`
1117 /// The priority
1118 ///
1119 /// # Returns
1120 ///
1121 /// [`true`] if `priority` could be set for `self`.
1122 #[deprecated = "Since 1.10"]
1123 #[allow(deprecated)]
1124 #[doc(alias = "ges_timeline_element_set_priority")]
1125 #[doc(alias = "priority")]
1126 fn set_priority(&self, priority: u32) -> bool {
1127 unsafe {
1128 from_glib(ffi::ges_timeline_element_set_priority(
1129 self.as_ref().to_glib_none().0,
1130 priority,
1131 ))
1132 }
1133 }
1134
1135 /// Sets [`start`][struct@crate::TimelineElement#start] for the element. If the element has a
1136 /// parent, this will also move its siblings with the same shift.
1137 ///
1138 /// Whilst the element is part of a [`Timeline`][crate::Timeline], this is the same as
1139 /// editing the element with [`edit()`][Self::edit()] under
1140 /// [`EditMode::Normal`][crate::EditMode::Normal] with [`Edge::None`][crate::Edge::None]. In particular, the
1141 /// [`start`][struct@crate::TimelineElement#start] of the element may be snapped to a different
1142 /// timeline time from the one given. In addition, setting may fail if it
1143 /// would place the timeline in an unsupported configuration.
1144 /// ## `start`
1145 /// The desired start position of the element in its timeline
1146 ///
1147 /// # Returns
1148 ///
1149 /// [`true`] if `start` could be set for `self`.
1150 #[doc(alias = "ges_timeline_element_set_start")]
1151 #[doc(alias = "start")]
1152 fn set_start(&self, start: gst::ClockTime) -> bool {
1153 unsafe {
1154 from_glib(ffi::ges_timeline_element_set_start(
1155 self.as_ref().to_glib_none().0,
1156 start.into_glib(),
1157 ))
1158 }
1159 }
1160
1161 /// Sets the [`timeline`][struct@crate::TimelineElement#timeline] of the element.
1162 ///
1163 /// This is used internally and you should normally not call this. A
1164 /// [`Clip`][crate::Clip] will have its [`timeline`][struct@crate::TimelineElement#timeline] set through its
1165 /// [`Layer`][crate::Layer]. A [`Track`][crate::Track] will similarly take care of setting the
1166 /// [`timeline`][struct@crate::TimelineElement#timeline] of its [`TrackElement`][crate::TrackElement]-s. A [`Group`][crate::Group]
1167 /// will adopt the same [`timeline`][struct@crate::TimelineElement#timeline] as its children.
1168 ///
1169 /// If `timeline` is [`None`], this will stop its current
1170 /// [`timeline`][struct@crate::TimelineElement#timeline] from tracking it, otherwise `timeline` will
1171 /// start tracking `self`. Note, in the latter case, `self` must not already
1172 /// have a timeline set. Therefore, if you wish to switch timelines, you
1173 /// will need to call this function twice: first to set the timeline to
1174 /// [`None`], and then to the new timeline.
1175 ///
1176 /// # Returns
1177 ///
1178 /// [`true`] if `timeline` could be set for `self`.
1179 #[doc(alias = "ges_timeline_element_set_timeline")]
1180 #[doc(alias = "timeline")]
1181 fn set_timeline(&self, timeline: &impl IsA<Timeline>) -> Result<(), glib::error::BoolError> {
1182 unsafe {
1183 glib::result_from_gboolean!(
1184 ffi::ges_timeline_element_set_timeline(
1185 self.as_ref().to_glib_none().0,
1186 timeline.as_ref().to_glib_none().0
1187 ),
1188 "`Failed to set timeline"
1189 )
1190 }
1191 }
1192
1193 /// Edits the start time of an element within its timeline in trim mode.
1194 /// See [`edit()`][Self::edit()] with [`EditMode::Trim`][crate::EditMode::Trim] and
1195 /// [`Edge::Start`][crate::Edge::Start].
1196 /// ## `start`
1197 /// The new start time of `self` in trim mode
1198 ///
1199 /// # Returns
1200 ///
1201 /// [`true`] if the trim edit of `self` completed, [`false`] on failure.
1202 #[doc(alias = "ges_timeline_element_trim")]
1203 fn trim(&self, start: gst::ClockTime) -> Result<(), glib::error::BoolError> {
1204 unsafe {
1205 glib::result_from_gboolean!(
1206 ffi::ges_timeline_element_trim(self.as_ref().to_glib_none().0, start.into_glib()),
1207 "Failed to trim"
1208 )
1209 }
1210 }
1211
1212 /// Whether the element should be serialized.
1213 fn is_serialize(&self) -> bool {
1214 ObjectExt::property(self.as_ref(), "serialize")
1215 }
1216
1217 /// Whether the element should be serialized.
1218 fn set_serialize(&self, serialize: bool) {
1219 ObjectExt::set_property(self.as_ref(), "serialize", serialize)
1220 }
1221
1222 /// Emitted when the element has a new child property registered. See
1223 /// [`add_child_property()`][Self::add_child_property()].
1224 ///
1225 /// Note that some GES elements will be automatically created with
1226 /// pre-registered children properties. You can use
1227 /// [`list_children_properties()`][Self::list_children_properties()] to list these.
1228 /// ## `prop_object`
1229 /// The child whose property has been registered
1230 /// ## `prop`
1231 /// The specification for the property that has been registered
1232 #[cfg(feature = "v1_18")]
1233 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1234 #[doc(alias = "child-property-added")]
1235 fn connect_child_property_added<F: Fn(&Self, &glib::Object, &glib::ParamSpec) + 'static>(
1236 &self,
1237 f: F,
1238 ) -> SignalHandlerId {
1239 unsafe extern "C" fn child_property_added_trampoline<
1240 P: IsA<TimelineElement>,
1241 F: Fn(&P, &glib::Object, &glib::ParamSpec) + 'static,
1242 >(
1243 this: *mut ffi::GESTimelineElement,
1244 prop_object: *mut glib::gobject_ffi::GObject,
1245 prop: *mut glib::gobject_ffi::GParamSpec,
1246 f: glib::ffi::gpointer,
1247 ) {
1248 unsafe {
1249 let f: &F = &*(f as *const F);
1250 f(
1251 TimelineElement::from_glib_borrow(this).unsafe_cast_ref(),
1252 &from_glib_borrow(prop_object),
1253 &from_glib_borrow(prop),
1254 )
1255 }
1256 }
1257 unsafe {
1258 let f: Box_<F> = Box_::new(f);
1259 connect_raw(
1260 self.as_ptr() as *mut _,
1261 c"child-property-added".as_ptr(),
1262 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1263 child_property_added_trampoline::<Self, F> as *const (),
1264 )),
1265 Box_::into_raw(f),
1266 )
1267 }
1268 }
1269
1270 /// Emitted when the element has a child property unregistered. See
1271 /// [`remove_child_property()`][Self::remove_child_property()].
1272 /// ## `prop_object`
1273 /// The child whose property has been unregistered
1274 /// ## `prop`
1275 /// The specification for the property that has been unregistered
1276 #[cfg(feature = "v1_18")]
1277 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1278 #[doc(alias = "child-property-removed")]
1279 fn connect_child_property_removed<F: Fn(&Self, &glib::Object, &glib::ParamSpec) + 'static>(
1280 &self,
1281 f: F,
1282 ) -> SignalHandlerId {
1283 unsafe extern "C" fn child_property_removed_trampoline<
1284 P: IsA<TimelineElement>,
1285 F: Fn(&P, &glib::Object, &glib::ParamSpec) + 'static,
1286 >(
1287 this: *mut ffi::GESTimelineElement,
1288 prop_object: *mut glib::gobject_ffi::GObject,
1289 prop: *mut glib::gobject_ffi::GParamSpec,
1290 f: glib::ffi::gpointer,
1291 ) {
1292 unsafe {
1293 let f: &F = &*(f as *const F);
1294 f(
1295 TimelineElement::from_glib_borrow(this).unsafe_cast_ref(),
1296 &from_glib_borrow(prop_object),
1297 &from_glib_borrow(prop),
1298 )
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(),
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 unsafe {
1338 let f: &F = &*(f as *const F);
1339 f(
1340 TimelineElement::from_glib_borrow(this).unsafe_cast_ref(),
1341 &from_glib_borrow(prop_object),
1342 &from_glib_borrow(prop),
1343 )
1344 }
1345 }
1346 unsafe {
1347 let f: Box_<F> = Box_::new(f);
1348 let detailed_signal_name = detail.map(|name| format!("deep-notify::{name}\0"));
1349 let signal_name = detailed_signal_name.as_ref().map_or(c"deep-notify", |n| {
1350 std::ffi::CStr::from_bytes_with_nul_unchecked(n.as_bytes())
1351 });
1352 connect_raw(
1353 self.as_ptr() as *mut _,
1354 signal_name.as_ptr(),
1355 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1356 deep_notify_trampoline::<Self, F> as *const (),
1357 )),
1358 Box_::into_raw(f),
1359 )
1360 }
1361 }
1362
1363 #[doc(alias = "duration")]
1364 fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1365 unsafe extern "C" fn notify_duration_trampoline<
1366 P: IsA<TimelineElement>,
1367 F: Fn(&P) + 'static,
1368 >(
1369 this: *mut ffi::GESTimelineElement,
1370 _param_spec: glib::ffi::gpointer,
1371 f: glib::ffi::gpointer,
1372 ) {
1373 unsafe {
1374 let f: &F = &*(f as *const F);
1375 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1376 }
1377 }
1378 unsafe {
1379 let f: Box_<F> = Box_::new(f);
1380 connect_raw(
1381 self.as_ptr() as *mut _,
1382 c"notify::duration".as_ptr(),
1383 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1384 notify_duration_trampoline::<Self, F> as *const (),
1385 )),
1386 Box_::into_raw(f),
1387 )
1388 }
1389 }
1390
1391 #[doc(alias = "in-point")]
1392 fn connect_in_point_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1393 unsafe extern "C" fn notify_in_point_trampoline<
1394 P: IsA<TimelineElement>,
1395 F: Fn(&P) + 'static,
1396 >(
1397 this: *mut ffi::GESTimelineElement,
1398 _param_spec: glib::ffi::gpointer,
1399 f: glib::ffi::gpointer,
1400 ) {
1401 unsafe {
1402 let f: &F = &*(f as *const F);
1403 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1404 }
1405 }
1406 unsafe {
1407 let f: Box_<F> = Box_::new(f);
1408 connect_raw(
1409 self.as_ptr() as *mut _,
1410 c"notify::in-point".as_ptr(),
1411 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1412 notify_in_point_trampoline::<Self, F> as *const (),
1413 )),
1414 Box_::into_raw(f),
1415 )
1416 }
1417 }
1418
1419 #[doc(alias = "max-duration")]
1420 fn connect_max_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1421 unsafe extern "C" fn notify_max_duration_trampoline<
1422 P: IsA<TimelineElement>,
1423 F: Fn(&P) + 'static,
1424 >(
1425 this: *mut ffi::GESTimelineElement,
1426 _param_spec: glib::ffi::gpointer,
1427 f: glib::ffi::gpointer,
1428 ) {
1429 unsafe {
1430 let f: &F = &*(f as *const F);
1431 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1432 }
1433 }
1434 unsafe {
1435 let f: Box_<F> = Box_::new(f);
1436 connect_raw(
1437 self.as_ptr() as *mut _,
1438 c"notify::max-duration".as_ptr(),
1439 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1440 notify_max_duration_trampoline::<Self, F> as *const (),
1441 )),
1442 Box_::into_raw(f),
1443 )
1444 }
1445 }
1446
1447 #[doc(alias = "name")]
1448 fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1449 unsafe extern "C" fn notify_name_trampoline<
1450 P: IsA<TimelineElement>,
1451 F: Fn(&P) + 'static,
1452 >(
1453 this: *mut ffi::GESTimelineElement,
1454 _param_spec: glib::ffi::gpointer,
1455 f: glib::ffi::gpointer,
1456 ) {
1457 unsafe {
1458 let f: &F = &*(f as *const F);
1459 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1460 }
1461 }
1462 unsafe {
1463 let f: Box_<F> = Box_::new(f);
1464 connect_raw(
1465 self.as_ptr() as *mut _,
1466 c"notify::name".as_ptr(),
1467 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1468 notify_name_trampoline::<Self, F> as *const (),
1469 )),
1470 Box_::into_raw(f),
1471 )
1472 }
1473 }
1474
1475 #[doc(alias = "parent")]
1476 fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1477 unsafe extern "C" fn notify_parent_trampoline<
1478 P: IsA<TimelineElement>,
1479 F: Fn(&P) + 'static,
1480 >(
1481 this: *mut ffi::GESTimelineElement,
1482 _param_spec: glib::ffi::gpointer,
1483 f: glib::ffi::gpointer,
1484 ) {
1485 unsafe {
1486 let f: &F = &*(f as *const F);
1487 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1488 }
1489 }
1490 unsafe {
1491 let f: Box_<F> = Box_::new(f);
1492 connect_raw(
1493 self.as_ptr() as *mut _,
1494 c"notify::parent".as_ptr(),
1495 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1496 notify_parent_trampoline::<Self, F> as *const (),
1497 )),
1498 Box_::into_raw(f),
1499 )
1500 }
1501 }
1502
1503 #[deprecated = "Since 1.10"]
1504 #[doc(alias = "priority")]
1505 fn connect_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1506 unsafe extern "C" fn notify_priority_trampoline<
1507 P: IsA<TimelineElement>,
1508 F: Fn(&P) + 'static,
1509 >(
1510 this: *mut ffi::GESTimelineElement,
1511 _param_spec: glib::ffi::gpointer,
1512 f: glib::ffi::gpointer,
1513 ) {
1514 unsafe {
1515 let f: &F = &*(f as *const F);
1516 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1517 }
1518 }
1519 unsafe {
1520 let f: Box_<F> = Box_::new(f);
1521 connect_raw(
1522 self.as_ptr() as *mut _,
1523 c"notify::priority".as_ptr(),
1524 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1525 notify_priority_trampoline::<Self, F> as *const (),
1526 )),
1527 Box_::into_raw(f),
1528 )
1529 }
1530 }
1531
1532 #[doc(alias = "serialize")]
1533 fn connect_serialize_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1534 unsafe extern "C" fn notify_serialize_trampoline<
1535 P: IsA<TimelineElement>,
1536 F: Fn(&P) + 'static,
1537 >(
1538 this: *mut ffi::GESTimelineElement,
1539 _param_spec: glib::ffi::gpointer,
1540 f: glib::ffi::gpointer,
1541 ) {
1542 unsafe {
1543 let f: &F = &*(f as *const F);
1544 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1545 }
1546 }
1547 unsafe {
1548 let f: Box_<F> = Box_::new(f);
1549 connect_raw(
1550 self.as_ptr() as *mut _,
1551 c"notify::serialize".as_ptr(),
1552 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1553 notify_serialize_trampoline::<Self, F> as *const (),
1554 )),
1555 Box_::into_raw(f),
1556 )
1557 }
1558 }
1559
1560 #[doc(alias = "start")]
1561 fn connect_start_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1562 unsafe extern "C" fn notify_start_trampoline<
1563 P: IsA<TimelineElement>,
1564 F: Fn(&P) + 'static,
1565 >(
1566 this: *mut ffi::GESTimelineElement,
1567 _param_spec: glib::ffi::gpointer,
1568 f: glib::ffi::gpointer,
1569 ) {
1570 unsafe {
1571 let f: &F = &*(f as *const F);
1572 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1573 }
1574 }
1575 unsafe {
1576 let f: Box_<F> = Box_::new(f);
1577 connect_raw(
1578 self.as_ptr() as *mut _,
1579 c"notify::start".as_ptr(),
1580 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1581 notify_start_trampoline::<Self, F> as *const (),
1582 )),
1583 Box_::into_raw(f),
1584 )
1585 }
1586 }
1587
1588 #[doc(alias = "timeline")]
1589 fn connect_timeline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1590 unsafe extern "C" fn notify_timeline_trampoline<
1591 P: IsA<TimelineElement>,
1592 F: Fn(&P) + 'static,
1593 >(
1594 this: *mut ffi::GESTimelineElement,
1595 _param_spec: glib::ffi::gpointer,
1596 f: glib::ffi::gpointer,
1597 ) {
1598 unsafe {
1599 let f: &F = &*(f as *const F);
1600 f(TimelineElement::from_glib_borrow(this).unsafe_cast_ref())
1601 }
1602 }
1603 unsafe {
1604 let f: Box_<F> = Box_::new(f);
1605 connect_raw(
1606 self.as_ptr() as *mut _,
1607 c"notify::timeline".as_ptr(),
1608 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1609 notify_timeline_trampoline::<Self, F> as *const (),
1610 )),
1611 Box_::into_raw(f),
1612 )
1613 }
1614 }
1615}
1616
1617impl<O: IsA<TimelineElement>> TimelineElementExt for O {}