Skip to main content

gstreamer_editing_services/auto/
track.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
6use crate::{MetaContainer, Timeline, TrackElement, TrackType, ffi};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GESTrack")]
17    pub struct Track(Object<ffi::GESTrack, ffi::GESTrackClass>) @extends gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, MetaContainer;
18
19    match fn {
20        type_ => || ffi::ges_track_get_type(),
21    }
22}
23
24impl Track {
25    pub const NONE: Option<&'static Track> = None;
26
27    #[doc(alias = "ges_track_new")]
28    pub fn new(type_: TrackType, caps: gst::Caps) -> Track {
29        assert_initialized_main_thread!();
30        unsafe { from_glib_none(ffi::ges_track_new(type_.into_glib(), caps.into_glib_ptr())) }
31    }
32}
33
34pub trait GESTrackExt: IsA<Track> + 'static {
35    #[doc(alias = "ges_track_add_element")]
36    fn add_element(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::error::BoolError> {
37        unsafe {
38            glib::result_from_gboolean!(
39                ffi::ges_track_add_element(
40                    self.as_ref().to_glib_none().0,
41                    object.as_ref().to_glib_none().0
42                ),
43                "Failed to add element"
44            )
45        }
46    }
47
48    #[cfg(feature = "v1_18")]
49    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
50    #[doc(alias = "ges_track_add_element_full")]
51    fn add_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
52        unsafe {
53            let mut error = std::ptr::null_mut();
54            let is_ok = ffi::ges_track_add_element_full(
55                self.as_ref().to_glib_none().0,
56                object.as_ref().to_glib_none().0,
57                &mut error,
58            );
59            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
60            if error.is_null() {
61                Ok(())
62            } else {
63                Err(from_glib_full(error))
64            }
65        }
66    }
67
68    #[doc(alias = "ges_track_commit")]
69    fn commit(&self) -> bool {
70        unsafe { from_glib(ffi::ges_track_commit(self.as_ref().to_glib_none().0)) }
71    }
72
73    #[doc(alias = "ges_track_get_caps")]
74    #[doc(alias = "get_caps")]
75    fn caps(&self) -> Option<gst::Caps> {
76        unsafe { from_glib_none(ffi::ges_track_get_caps(self.as_ref().to_glib_none().0)) }
77    }
78
79    #[doc(alias = "ges_track_get_elements")]
80    #[doc(alias = "get_elements")]
81    fn elements(&self) -> Vec<TrackElement> {
82        unsafe {
83            FromGlibPtrContainer::from_glib_full(ffi::ges_track_get_elements(
84                self.as_ref().to_glib_none().0,
85            ))
86        }
87    }
88
89    #[doc(alias = "ges_track_get_mixing")]
90    #[doc(alias = "get_mixing")]
91    #[doc(alias = "mixing")]
92    fn is_mixing(&self) -> bool {
93        unsafe { from_glib(ffi::ges_track_get_mixing(self.as_ref().to_glib_none().0)) }
94    }
95
96    #[cfg(feature = "v1_18")]
97    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
98    #[doc(alias = "ges_track_get_restriction_caps")]
99    #[doc(alias = "get_restriction_caps")]
100    #[doc(alias = "restriction-caps")]
101    fn restriction_caps(&self) -> Option<gst::Caps> {
102        unsafe {
103            from_glib_full(ffi::ges_track_get_restriction_caps(
104                self.as_ref().to_glib_none().0,
105            ))
106        }
107    }
108
109    #[doc(alias = "ges_track_get_timeline")]
110    #[doc(alias = "get_timeline")]
111    fn timeline(&self) -> Option<Timeline> {
112        unsafe { from_glib_none(ffi::ges_track_get_timeline(self.as_ref().to_glib_none().0)) }
113    }
114
115    #[doc(alias = "ges_track_remove_element")]
116    fn remove_element(
117        &self,
118        object: &impl IsA<TrackElement>,
119    ) -> Result<(), glib::error::BoolError> {
120        unsafe {
121            glib::result_from_gboolean!(
122                ffi::ges_track_remove_element(
123                    self.as_ref().to_glib_none().0,
124                    object.as_ref().to_glib_none().0
125                ),
126                "Failed to remove element"
127            )
128        }
129    }
130
131    #[cfg(feature = "v1_18")]
132    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
133    #[doc(alias = "ges_track_remove_element_full")]
134    fn remove_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
135        unsafe {
136            let mut error = std::ptr::null_mut();
137            let is_ok = ffi::ges_track_remove_element_full(
138                self.as_ref().to_glib_none().0,
139                object.as_ref().to_glib_none().0,
140                &mut error,
141            );
142            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
143            if error.is_null() {
144                Ok(())
145            } else {
146                Err(from_glib_full(error))
147            }
148        }
149    }
150
151    //#[doc(alias = "ges_track_set_create_element_for_gap_func")]
152    //fn set_create_element_for_gap_func<P: Fn() -> gst::Element + 'static>(&self, func: P) {
153    //    unsafe { TODO: call ffi:ges_track_set_create_element_for_gap_func() }
154    //}
155
156    #[doc(alias = "ges_track_set_mixing")]
157    #[doc(alias = "mixing")]
158    fn set_mixing(&self, mixing: bool) {
159        unsafe {
160            ffi::ges_track_set_mixing(self.as_ref().to_glib_none().0, mixing.into_glib());
161        }
162    }
163
164    #[doc(alias = "ges_track_set_restriction_caps")]
165    #[doc(alias = "restriction-caps")]
166    fn set_restriction_caps(&self, caps: &gst::Caps) {
167        unsafe {
168            ffi::ges_track_set_restriction_caps(
169                self.as_ref().to_glib_none().0,
170                caps.to_glib_none().0,
171            );
172        }
173    }
174
175    #[doc(alias = "ges_track_set_timeline")]
176    fn set_timeline(&self, timeline: &impl IsA<Timeline>) {
177        unsafe {
178            ffi::ges_track_set_timeline(
179                self.as_ref().to_glib_none().0,
180                timeline.as_ref().to_glib_none().0,
181            );
182        }
183    }
184
185    #[doc(alias = "ges_track_update_restriction_caps")]
186    fn update_restriction_caps(&self, caps: &gst::Caps) {
187        unsafe {
188            ffi::ges_track_update_restriction_caps(
189                self.as_ref().to_glib_none().0,
190                caps.to_glib_none().0,
191            );
192        }
193    }
194
195    fn duration(&self) -> u64 {
196        ObjectExt::property(self.as_ref(), "duration")
197    }
198
199    #[cfg(feature = "v1_18")]
200    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
201    fn id(&self) -> Option<glib::GString> {
202        ObjectExt::property(self.as_ref(), "id")
203    }
204
205    #[cfg(feature = "v1_18")]
206    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
207    fn set_id(&self, id: Option<&str>) {
208        ObjectExt::set_property(self.as_ref(), "id", id)
209    }
210
211    #[cfg(not(feature = "v1_18"))]
212    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_18"))))]
213    #[doc(alias = "restriction-caps")]
214    fn restriction_caps(&self) -> Option<gst::Caps> {
215        ObjectExt::property(self.as_ref(), "restriction-caps")
216    }
217
218    #[doc(alias = "track-type")]
219    fn track_type(&self) -> TrackType {
220        ObjectExt::property(self.as_ref(), "track-type")
221    }
222
223    #[doc(alias = "commited")]
224    fn connect_commited<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
225        unsafe extern "C" fn commited_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
226            this: *mut ffi::GESTrack,
227            f: glib::ffi::gpointer,
228        ) {
229            unsafe {
230                let f: &F = &*(f as *const F);
231                f(Track::from_glib_borrow(this).unsafe_cast_ref())
232            }
233        }
234        unsafe {
235            let f: Box_<F> = Box_::new(f);
236            connect_raw(
237                self.as_ptr() as *mut _,
238                c"commited".as_ptr(),
239                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
240                    commited_trampoline::<Self, F> as *const (),
241                )),
242                Box_::into_raw(f),
243            )
244        }
245    }
246
247    #[doc(alias = "track-element-added")]
248    fn connect_track_element_added<F: Fn(&Self, &TrackElement) + 'static>(
249        &self,
250        f: F,
251    ) -> SignalHandlerId {
252        unsafe extern "C" fn track_element_added_trampoline<
253            P: IsA<Track>,
254            F: Fn(&P, &TrackElement) + 'static,
255        >(
256            this: *mut ffi::GESTrack,
257            effect: *mut ffi::GESTrackElement,
258            f: glib::ffi::gpointer,
259        ) {
260            unsafe {
261                let f: &F = &*(f as *const F);
262                f(
263                    Track::from_glib_borrow(this).unsafe_cast_ref(),
264                    &from_glib_borrow(effect),
265                )
266            }
267        }
268        unsafe {
269            let f: Box_<F> = Box_::new(f);
270            connect_raw(
271                self.as_ptr() as *mut _,
272                c"track-element-added".as_ptr(),
273                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
274                    track_element_added_trampoline::<Self, F> as *const (),
275                )),
276                Box_::into_raw(f),
277            )
278        }
279    }
280
281    #[doc(alias = "track-element-removed")]
282    fn connect_track_element_removed<F: Fn(&Self, &TrackElement) + 'static>(
283        &self,
284        f: F,
285    ) -> SignalHandlerId {
286        unsafe extern "C" fn track_element_removed_trampoline<
287            P: IsA<Track>,
288            F: Fn(&P, &TrackElement) + 'static,
289        >(
290            this: *mut ffi::GESTrack,
291            effect: *mut ffi::GESTrackElement,
292            f: glib::ffi::gpointer,
293        ) {
294            unsafe {
295                let f: &F = &*(f as *const F);
296                f(
297                    Track::from_glib_borrow(this).unsafe_cast_ref(),
298                    &from_glib_borrow(effect),
299                )
300            }
301        }
302        unsafe {
303            let f: Box_<F> = Box_::new(f);
304            connect_raw(
305                self.as_ptr() as *mut _,
306                c"track-element-removed".as_ptr(),
307                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
308                    track_element_removed_trampoline::<Self, F> as *const (),
309                )),
310                Box_::into_raw(f),
311            )
312        }
313    }
314
315    #[doc(alias = "duration")]
316    fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
317        unsafe extern "C" fn notify_duration_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
318            this: *mut ffi::GESTrack,
319            _param_spec: glib::ffi::gpointer,
320            f: glib::ffi::gpointer,
321        ) {
322            unsafe {
323                let f: &F = &*(f as *const F);
324                f(Track::from_glib_borrow(this).unsafe_cast_ref())
325            }
326        }
327        unsafe {
328            let f: Box_<F> = Box_::new(f);
329            connect_raw(
330                self.as_ptr() as *mut _,
331                c"notify::duration".as_ptr(),
332                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
333                    notify_duration_trampoline::<Self, F> as *const (),
334                )),
335                Box_::into_raw(f),
336            )
337        }
338    }
339
340    #[cfg(feature = "v1_18")]
341    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
342    #[doc(alias = "id")]
343    fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
344        unsafe extern "C" fn notify_id_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
345            this: *mut ffi::GESTrack,
346            _param_spec: glib::ffi::gpointer,
347            f: glib::ffi::gpointer,
348        ) {
349            unsafe {
350                let f: &F = &*(f as *const F);
351                f(Track::from_glib_borrow(this).unsafe_cast_ref())
352            }
353        }
354        unsafe {
355            let f: Box_<F> = Box_::new(f);
356            connect_raw(
357                self.as_ptr() as *mut _,
358                c"notify::id".as_ptr(),
359                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
360                    notify_id_trampoline::<Self, F> as *const (),
361                )),
362                Box_::into_raw(f),
363            )
364        }
365    }
366
367    #[doc(alias = "mixing")]
368    fn connect_mixing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
369        unsafe extern "C" fn notify_mixing_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
370            this: *mut ffi::GESTrack,
371            _param_spec: glib::ffi::gpointer,
372            f: glib::ffi::gpointer,
373        ) {
374            unsafe {
375                let f: &F = &*(f as *const F);
376                f(Track::from_glib_borrow(this).unsafe_cast_ref())
377            }
378        }
379        unsafe {
380            let f: Box_<F> = Box_::new(f);
381            connect_raw(
382                self.as_ptr() as *mut _,
383                c"notify::mixing".as_ptr(),
384                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
385                    notify_mixing_trampoline::<Self, F> as *const (),
386                )),
387                Box_::into_raw(f),
388            )
389        }
390    }
391
392    #[doc(alias = "restriction-caps")]
393    fn connect_restriction_caps_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
394        unsafe extern "C" fn notify_restriction_caps_trampoline<
395            P: IsA<Track>,
396            F: Fn(&P) + 'static,
397        >(
398            this: *mut ffi::GESTrack,
399            _param_spec: glib::ffi::gpointer,
400            f: glib::ffi::gpointer,
401        ) {
402            unsafe {
403                let f: &F = &*(f as *const F);
404                f(Track::from_glib_borrow(this).unsafe_cast_ref())
405            }
406        }
407        unsafe {
408            let f: Box_<F> = Box_::new(f);
409            connect_raw(
410                self.as_ptr() as *mut _,
411                c"notify::restriction-caps".as_ptr(),
412                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
413                    notify_restriction_caps_trampoline::<Self, F> as *const (),
414                )),
415                Box_::into_raw(f),
416            )
417        }
418    }
419}
420
421impl<O: IsA<Track>> GESTrackExt for O {}