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