1#![allow(deprecated)]
6
7use crate::{
8 Edge, EditMode, Extractable, Layer, MetaContainer, TimelineElement, Track, TrackType, ffi,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{SignalHandlerId, connect_raw},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 #[doc(alias = "GESTrackElement")]
20 pub struct TrackElement(Object<ffi::GESTrackElement, ffi::GESTrackElementClass>) @extends TimelineElement, @implements Extractable, MetaContainer;
21
22 match fn {
23 type_ => || ffi::ges_track_element_get_type(),
24 }
25}
26
27impl TrackElement {
28 pub const NONE: Option<&'static TrackElement> = None;
29}
30
31pub trait TrackElementExt: IsA<TrackElement> + 'static {
32 #[doc(alias = "ges_track_element_add_children_props")]
33 fn add_children_props(
34 &self,
35 element: &impl IsA<gst::Element>,
36 wanted_categories: &[&str],
37 blacklist: &[&str],
38 whitelist: &[&str],
39 ) {
40 unsafe {
41 ffi::ges_track_element_add_children_props(
42 self.as_ref().to_glib_none().0,
43 element.as_ref().to_glib_none().0,
44 wanted_categories.to_glib_none().0,
45 blacklist.to_glib_none().0,
46 whitelist.to_glib_none().0,
47 );
48 }
49 }
50
51 #[cfg(feature = "v1_18")]
52 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
53 #[doc(alias = "ges_track_element_clamp_control_source")]
54 fn clamp_control_source(&self, property_name: &str) {
55 unsafe {
56 ffi::ges_track_element_clamp_control_source(
57 self.as_ref().to_glib_none().0,
58 property_name.to_glib_none().0,
59 );
60 }
61 }
62
63 #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
64 #[allow(deprecated)]
65 #[doc(alias = "ges_track_element_edit")]
66 fn edit(
67 &self,
68 layers: &[Layer],
69 mode: EditMode,
70 edge: Edge,
71 position: u64,
72 ) -> Result<(), glib::error::BoolError> {
73 unsafe {
74 glib::result_from_gboolean!(
75 ffi::ges_track_element_edit(
76 self.as_ref().to_glib_none().0,
77 layers.to_glib_none().0,
78 mode.into_glib(),
79 edge.into_glib(),
80 position
81 ),
82 "Failed to edit"
83 )
84 }
85 }
86
87 #[cfg(feature = "v1_18")]
104 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
105 #[doc(alias = "ges_track_element_get_auto_clamp_control_sources")]
106 #[doc(alias = "get_auto_clamp_control_sources")]
107 #[doc(alias = "auto-clamp-control-sources")]
108 fn is_auto_clamp_control_sources(&self) -> bool {
109 unsafe {
110 from_glib(ffi::ges_track_element_get_auto_clamp_control_sources(
111 self.as_ref().to_glib_none().0,
112 ))
113 }
114 }
115
116 #[doc(alias = "ges_track_element_get_child_property")]
123 #[doc(alias = "get_child_property")]
124 fn child_property(&self, property_name: &str) -> Option<glib::Value> {
125 unsafe {
126 let mut value = glib::Value::uninitialized();
127 let ret = from_glib(ffi::ges_track_element_get_child_property(
128 self.as_ref().to_glib_none().0,
129 property_name.to_glib_none().0,
130 value.to_glib_none_mut().0,
131 ));
132 if ret { Some(value) } else { None }
133 }
134 }
135
136 #[doc(alias = "ges_track_element_get_child_property_by_pspec")]
137 #[doc(alias = "get_child_property_by_pspec")]
138 fn child_property_by_pspec(&self, pspec: impl AsRef<glib::ParamSpec>) -> glib::Value {
139 unsafe {
140 let mut value = glib::Value::uninitialized();
141 ffi::ges_track_element_get_child_property_by_pspec(
142 self.as_ref().to_glib_none().0,
143 pspec.as_ref().to_glib_none().0,
144 value.to_glib_none_mut().0,
145 );
146 value
147 }
148 }
149
150 #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
157 #[allow(deprecated)]
158 #[doc(alias = "ges_track_element_get_control_binding")]
159 #[doc(alias = "get_control_binding")]
160 fn control_binding(&self, property_name: &str) -> Option<gst::ControlBinding> {
161 unsafe {
162 from_glib_none(ffi::ges_track_element_get_control_binding(
163 self.as_ref().to_glib_none().0,
164 property_name.to_glib_none().0,
165 ))
166 }
167 }
168
169 #[cfg(feature = "v1_30")]
170 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
171 #[doc(alias = "ges_track_element_get_control_binding_full")]
172 #[doc(alias = "get_control_binding_full")]
173 fn control_binding_full(&self, property_name: &str) -> Option<gst::ControlBinding> {
174 unsafe {
175 from_glib_full(ffi::ges_track_element_get_control_binding_full(
176 self.as_ref().to_glib_none().0,
177 property_name.to_glib_none().0,
178 ))
179 }
180 }
181
182 #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
183 #[allow(deprecated)]
184 #[doc(alias = "ges_track_element_get_element")]
185 #[doc(alias = "get_element")]
186 fn element(&self) -> Option<gst::Element> {
187 unsafe {
188 from_glib_none(ffi::ges_track_element_get_element(
189 self.as_ref().to_glib_none().0,
190 ))
191 }
192 }
193
194 #[cfg(feature = "v1_30")]
195 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
196 #[doc(alias = "ges_track_element_get_element_full")]
197 #[doc(alias = "get_element_full")]
198 fn element_full(&self) -> Option<gst::Element> {
199 unsafe {
200 from_glib_full(ffi::ges_track_element_get_element_full(
201 self.as_ref().to_glib_none().0,
202 ))
203 }
204 }
205
206 #[doc(alias = "ges_track_element_get_gnlobject")]
207 #[doc(alias = "get_gnlobject")]
208 fn gnlobject(&self) -> gst::Element {
209 unsafe {
210 from_glib_none(ffi::ges_track_element_get_gnlobject(
211 self.as_ref().to_glib_none().0,
212 ))
213 }
214 }
215
216 #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
217 #[allow(deprecated)]
218 #[doc(alias = "ges_track_element_get_nleobject")]
219 #[doc(alias = "get_nleobject")]
220 fn nleobject(&self) -> gst::Element {
221 unsafe {
222 from_glib_none(ffi::ges_track_element_get_nleobject(
223 self.as_ref().to_glib_none().0,
224 ))
225 }
226 }
227
228 #[cfg(feature = "v1_30")]
229 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
230 #[doc(alias = "ges_track_element_get_nleobject_full")]
231 #[doc(alias = "get_nleobject_full")]
232 fn nleobject_full(&self) -> Option<gst::Element> {
233 unsafe {
234 from_glib_full(ffi::ges_track_element_get_nleobject_full(
235 self.as_ref().to_glib_none().0,
236 ))
237 }
238 }
239
240 #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
241 #[allow(deprecated)]
242 #[doc(alias = "ges_track_element_get_track")]
243 #[doc(alias = "get_track")]
244 fn track(&self) -> Option<Track> {
245 unsafe {
246 from_glib_none(ffi::ges_track_element_get_track(
247 self.as_ref().to_glib_none().0,
248 ))
249 }
250 }
251
252 #[cfg(feature = "v1_30")]
253 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
254 #[doc(alias = "ges_track_element_get_track_full")]
255 #[doc(alias = "get_track_full")]
256 fn track_full(&self) -> Option<Track> {
257 unsafe {
258 from_glib_full(ffi::ges_track_element_get_track_full(
259 self.as_ref().to_glib_none().0,
260 ))
261 }
262 }
263
264 #[doc(alias = "ges_track_element_get_track_type")]
265 #[doc(alias = "get_track_type")]
266 #[doc(alias = "track-type")]
267 fn track_type(&self) -> TrackType {
268 unsafe {
269 from_glib(ffi::ges_track_element_get_track_type(
270 self.as_ref().to_glib_none().0,
271 ))
272 }
273 }
274
275 #[cfg(feature = "v1_18")]
276 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
277 #[doc(alias = "ges_track_element_has_internal_source")]
278 fn has_internal_source(&self) -> bool {
279 unsafe {
280 from_glib(ffi::ges_track_element_has_internal_source(
281 self.as_ref().to_glib_none().0,
282 ))
283 }
284 }
285
286 #[doc(alias = "ges_track_element_is_active")]
287 #[doc(alias = "active")]
288 fn is_active(&self) -> bool {
289 unsafe {
290 from_glib(ffi::ges_track_element_is_active(
291 self.as_ref().to_glib_none().0,
292 ))
293 }
294 }
295
296 #[cfg(feature = "v1_18")]
297 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
298 #[doc(alias = "ges_track_element_is_core")]
299 fn is_core(&self) -> bool {
300 unsafe {
301 from_glib(ffi::ges_track_element_is_core(
302 self.as_ref().to_glib_none().0,
303 ))
304 }
305 }
306
307 #[doc(alias = "ges_track_element_list_children_properties")]
308 fn list_children_properties(&self) -> Vec<glib::ParamSpec> {
309 unsafe {
310 let mut n_properties = std::mem::MaybeUninit::uninit();
311 let ret = FromGlibContainer::from_glib_full_num(
312 ffi::ges_track_element_list_children_properties(
313 self.as_ref().to_glib_none().0,
314 n_properties.as_mut_ptr(),
315 ),
316 n_properties.assume_init() as _,
317 );
318 ret
319 }
320 }
321
322 #[doc(alias = "ges_track_element_lookup_child")]
323 fn lookup_child(&self, prop_name: &str) -> Option<(gst::Element, glib::ParamSpec)> {
324 unsafe {
325 let mut element = std::ptr::null_mut();
326 let mut pspec = std::ptr::null_mut();
327 let ret = from_glib(ffi::ges_track_element_lookup_child(
328 self.as_ref().to_glib_none().0,
329 prop_name.to_glib_none().0,
330 &mut element,
331 &mut pspec,
332 ));
333 if ret {
334 Some((from_glib_full(element), from_glib_full(pspec)))
335 } else {
336 None
337 }
338 }
339 }
340
341 #[doc(alias = "ges_track_element_remove_control_binding")]
342 fn remove_control_binding(&self, property_name: &str) -> Result<(), glib::error::BoolError> {
343 unsafe {
344 glib::result_from_gboolean!(
345 ffi::ges_track_element_remove_control_binding(
346 self.as_ref().to_glib_none().0,
347 property_name.to_glib_none().0
348 ),
349 "Failed to remove control binding"
350 )
351 }
352 }
353
354 #[doc(alias = "ges_track_element_set_active")]
355 #[doc(alias = "active")]
356 fn set_active(&self, active: bool) -> bool {
357 unsafe {
358 from_glib(ffi::ges_track_element_set_active(
359 self.as_ref().to_glib_none().0,
360 active.into_glib(),
361 ))
362 }
363 }
364
365 #[cfg(feature = "v1_18")]
366 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
367 #[doc(alias = "ges_track_element_set_auto_clamp_control_sources")]
368 #[doc(alias = "auto-clamp-control-sources")]
369 fn set_auto_clamp_control_sources(&self, auto_clamp: bool) {
370 unsafe {
371 ffi::ges_track_element_set_auto_clamp_control_sources(
372 self.as_ref().to_glib_none().0,
373 auto_clamp.into_glib(),
374 );
375 }
376 }
377
378 #[doc(alias = "ges_track_element_set_child_property")]
384 fn set_child_property(
385 &self,
386 property_name: &str,
387 value: &glib::Value,
388 ) -> Result<(), glib::error::BoolError> {
389 unsafe {
390 glib::result_from_gboolean!(
391 ffi::ges_track_element_set_child_property(
392 self.as_ref().to_glib_none().0,
393 property_name.to_glib_none().0,
394 mut_override(value.to_glib_none().0)
395 ),
396 "Failed to set child property"
397 )
398 }
399 }
400
401 #[doc(alias = "ges_track_element_set_child_property_by_pspec")]
402 fn set_child_property_by_pspec(&self, pspec: impl AsRef<glib::ParamSpec>, value: &glib::Value) {
403 unsafe {
404 ffi::ges_track_element_set_child_property_by_pspec(
405 self.as_ref().to_glib_none().0,
406 pspec.as_ref().to_glib_none().0,
407 mut_override(value.to_glib_none().0),
408 );
409 }
410 }
411
412 #[doc(alias = "ges_track_element_set_control_source")]
418 fn set_control_source(
419 &self,
420 source: &impl IsA<gst::ControlSource>,
421 property_name: &str,
422 binding_type: &str,
423 ) -> bool {
424 unsafe {
425 from_glib(ffi::ges_track_element_set_control_source(
426 self.as_ref().to_glib_none().0,
427 source.as_ref().to_glib_none().0,
428 property_name.to_glib_none().0,
429 binding_type.to_glib_none().0,
430 ))
431 }
432 }
433
434 #[cfg(feature = "v1_18")]
435 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
436 #[doc(alias = "ges_track_element_set_has_internal_source")]
437 #[doc(alias = "has-internal-source")]
438 fn set_has_internal_source(&self, has_internal_source: bool) -> bool {
439 unsafe {
440 from_glib(ffi::ges_track_element_set_has_internal_source(
441 self.as_ref().to_glib_none().0,
442 has_internal_source.into_glib(),
443 ))
444 }
445 }
446
447 #[doc(alias = "ges_track_element_set_track_type")]
448 #[doc(alias = "track-type")]
449 fn set_track_type(&self, type_: TrackType) {
450 unsafe {
451 ffi::ges_track_element_set_track_type(
452 self.as_ref().to_glib_none().0,
453 type_.into_glib(),
454 );
455 }
456 }
457
458 #[doc(alias = "control-binding-added")]
459 fn connect_control_binding_added<F: Fn(&Self, &gst::ControlBinding) + 'static>(
460 &self,
461 f: F,
462 ) -> SignalHandlerId {
463 unsafe extern "C" fn control_binding_added_trampoline<
464 P: IsA<TrackElement>,
465 F: Fn(&P, &gst::ControlBinding) + 'static,
466 >(
467 this: *mut ffi::GESTrackElement,
468 control_binding: *mut gst::ffi::GstControlBinding,
469 f: glib::ffi::gpointer,
470 ) {
471 unsafe {
472 let f: &F = &*(f as *const F);
473 f(
474 TrackElement::from_glib_borrow(this).unsafe_cast_ref(),
475 &from_glib_borrow(control_binding),
476 )
477 }
478 }
479 unsafe {
480 let f: Box_<F> = Box_::new(f);
481 connect_raw(
482 self.as_ptr() as *mut _,
483 c"control-binding-added".as_ptr(),
484 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
485 control_binding_added_trampoline::<Self, F> as *const (),
486 )),
487 Box_::into_raw(f),
488 )
489 }
490 }
491
492 #[doc(alias = "control-binding-removed")]
493 fn connect_control_binding_removed<F: Fn(&Self, &gst::ControlBinding) + 'static>(
494 &self,
495 f: F,
496 ) -> SignalHandlerId {
497 unsafe extern "C" fn control_binding_removed_trampoline<
498 P: IsA<TrackElement>,
499 F: Fn(&P, &gst::ControlBinding) + 'static,
500 >(
501 this: *mut ffi::GESTrackElement,
502 control_binding: *mut gst::ffi::GstControlBinding,
503 f: glib::ffi::gpointer,
504 ) {
505 unsafe {
506 let f: &F = &*(f as *const F);
507 f(
508 TrackElement::from_glib_borrow(this).unsafe_cast_ref(),
509 &from_glib_borrow(control_binding),
510 )
511 }
512 }
513 unsafe {
514 let f: Box_<F> = Box_::new(f);
515 connect_raw(
516 self.as_ptr() as *mut _,
517 c"control-binding-removed".as_ptr(),
518 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
519 control_binding_removed_trampoline::<Self, F> as *const (),
520 )),
521 Box_::into_raw(f),
522 )
523 }
524 }
525
526 #[doc(alias = "active")]
527 fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
528 unsafe extern "C" fn notify_active_trampoline<P: IsA<TrackElement>, F: Fn(&P) + 'static>(
529 this: *mut ffi::GESTrackElement,
530 _param_spec: glib::ffi::gpointer,
531 f: glib::ffi::gpointer,
532 ) {
533 unsafe {
534 let f: &F = &*(f as *const F);
535 f(TrackElement::from_glib_borrow(this).unsafe_cast_ref())
536 }
537 }
538 unsafe {
539 let f: Box_<F> = Box_::new(f);
540 connect_raw(
541 self.as_ptr() as *mut _,
542 c"notify::active".as_ptr(),
543 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
544 notify_active_trampoline::<Self, F> as *const (),
545 )),
546 Box_::into_raw(f),
547 )
548 }
549 }
550
551 #[cfg(feature = "v1_18")]
552 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
553 #[doc(alias = "auto-clamp-control-sources")]
554 fn connect_auto_clamp_control_sources_notify<F: Fn(&Self) + 'static>(
555 &self,
556 f: F,
557 ) -> SignalHandlerId {
558 unsafe extern "C" fn notify_auto_clamp_control_sources_trampoline<
559 P: IsA<TrackElement>,
560 F: Fn(&P) + 'static,
561 >(
562 this: *mut ffi::GESTrackElement,
563 _param_spec: glib::ffi::gpointer,
564 f: glib::ffi::gpointer,
565 ) {
566 unsafe {
567 let f: &F = &*(f as *const F);
568 f(TrackElement::from_glib_borrow(this).unsafe_cast_ref())
569 }
570 }
571 unsafe {
572 let f: Box_<F> = Box_::new(f);
573 connect_raw(
574 self.as_ptr() as *mut _,
575 c"notify::auto-clamp-control-sources".as_ptr(),
576 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
577 notify_auto_clamp_control_sources_trampoline::<Self, F> as *const (),
578 )),
579 Box_::into_raw(f),
580 )
581 }
582 }
583
584 #[cfg(feature = "v1_18")]
585 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
586 #[doc(alias = "has-internal-source")]
587 fn connect_has_internal_source_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
588 unsafe extern "C" fn notify_has_internal_source_trampoline<
589 P: IsA<TrackElement>,
590 F: Fn(&P) + 'static,
591 >(
592 this: *mut ffi::GESTrackElement,
593 _param_spec: glib::ffi::gpointer,
594 f: glib::ffi::gpointer,
595 ) {
596 unsafe {
597 let f: &F = &*(f as *const F);
598 f(TrackElement::from_glib_borrow(this).unsafe_cast_ref())
599 }
600 }
601 unsafe {
602 let f: Box_<F> = Box_::new(f);
603 connect_raw(
604 self.as_ptr() as *mut _,
605 c"notify::has-internal-source".as_ptr(),
606 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
607 notify_has_internal_source_trampoline::<Self, F> as *const (),
608 )),
609 Box_::into_raw(f),
610 )
611 }
612 }
613
614 #[doc(alias = "track")]
615 fn connect_track_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
616 unsafe extern "C" fn notify_track_trampoline<P: IsA<TrackElement>, F: Fn(&P) + 'static>(
617 this: *mut ffi::GESTrackElement,
618 _param_spec: glib::ffi::gpointer,
619 f: glib::ffi::gpointer,
620 ) {
621 unsafe {
622 let f: &F = &*(f as *const F);
623 f(TrackElement::from_glib_borrow(this).unsafe_cast_ref())
624 }
625 }
626 unsafe {
627 let f: Box_<F> = Box_::new(f);
628 connect_raw(
629 self.as_ptr() as *mut _,
630 c"notify::track".as_ptr(),
631 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
632 notify_track_trampoline::<Self, F> as *const (),
633 )),
634 Box_::into_raw(f),
635 )
636 }
637 }
638
639 #[doc(alias = "track-type")]
640 fn connect_track_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
641 unsafe extern "C" fn notify_track_type_trampoline<
642 P: IsA<TrackElement>,
643 F: Fn(&P) + 'static,
644 >(
645 this: *mut ffi::GESTrackElement,
646 _param_spec: glib::ffi::gpointer,
647 f: glib::ffi::gpointer,
648 ) {
649 unsafe {
650 let f: &F = &*(f as *const F);
651 f(TrackElement::from_glib_borrow(this).unsafe_cast_ref())
652 }
653 }
654 unsafe {
655 let f: Box_<F> = Box_::new(f);
656 connect_raw(
657 self.as_ptr() as *mut _,
658 c"notify::track-type".as_ptr(),
659 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
660 notify_track_type_trampoline::<Self, F> as *const (),
661 )),
662 Box_::into_raw(f),
663 )
664 }
665 }
666}
667
668impl<O: IsA<TrackElement>> TrackElementExt for O {}