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