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
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            let f: &F = &*(f as *const F);
230            f(Track::from_glib_borrow(this).unsafe_cast_ref())
231        }
232        unsafe {
233            let f: Box_<F> = Box_::new(f);
234            connect_raw(
235                self.as_ptr() as *mut _,
236                c"commited".as_ptr() as *const _,
237                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
238                    commited_trampoline::<Self, F> as *const (),
239                )),
240                Box_::into_raw(f),
241            )
242        }
243    }
244
245    #[doc(alias = "track-element-added")]
246    fn connect_track_element_added<F: Fn(&Self, &TrackElement) + 'static>(
247        &self,
248        f: F,
249    ) -> SignalHandlerId {
250        unsafe extern "C" fn track_element_added_trampoline<
251            P: IsA<Track>,
252            F: Fn(&P, &TrackElement) + 'static,
253        >(
254            this: *mut ffi::GESTrack,
255            effect: *mut ffi::GESTrackElement,
256            f: glib::ffi::gpointer,
257        ) {
258            let f: &F = &*(f as *const F);
259            f(
260                Track::from_glib_borrow(this).unsafe_cast_ref(),
261                &from_glib_borrow(effect),
262            )
263        }
264        unsafe {
265            let f: Box_<F> = Box_::new(f);
266            connect_raw(
267                self.as_ptr() as *mut _,
268                c"track-element-added".as_ptr() as *const _,
269                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
270                    track_element_added_trampoline::<Self, F> as *const (),
271                )),
272                Box_::into_raw(f),
273            )
274        }
275    }
276
277    #[doc(alias = "track-element-removed")]
278    fn connect_track_element_removed<F: Fn(&Self, &TrackElement) + 'static>(
279        &self,
280        f: F,
281    ) -> SignalHandlerId {
282        unsafe extern "C" fn track_element_removed_trampoline<
283            P: IsA<Track>,
284            F: Fn(&P, &TrackElement) + 'static,
285        >(
286            this: *mut ffi::GESTrack,
287            effect: *mut ffi::GESTrackElement,
288            f: glib::ffi::gpointer,
289        ) {
290            let f: &F = &*(f as *const F);
291            f(
292                Track::from_glib_borrow(this).unsafe_cast_ref(),
293                &from_glib_borrow(effect),
294            )
295        }
296        unsafe {
297            let f: Box_<F> = Box_::new(f);
298            connect_raw(
299                self.as_ptr() as *mut _,
300                c"track-element-removed".as_ptr() as *const _,
301                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
302                    track_element_removed_trampoline::<Self, F> as *const (),
303                )),
304                Box_::into_raw(f),
305            )
306        }
307    }
308
309    #[doc(alias = "duration")]
310    fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
311        unsafe extern "C" fn notify_duration_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
312            this: *mut ffi::GESTrack,
313            _param_spec: glib::ffi::gpointer,
314            f: glib::ffi::gpointer,
315        ) {
316            let f: &F = &*(f as *const F);
317            f(Track::from_glib_borrow(this).unsafe_cast_ref())
318        }
319        unsafe {
320            let f: Box_<F> = Box_::new(f);
321            connect_raw(
322                self.as_ptr() as *mut _,
323                c"notify::duration".as_ptr() as *const _,
324                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
325                    notify_duration_trampoline::<Self, F> as *const (),
326                )),
327                Box_::into_raw(f),
328            )
329        }
330    }
331
332    #[cfg(feature = "v1_18")]
333    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
334    #[doc(alias = "id")]
335    fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
336        unsafe extern "C" fn notify_id_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
337            this: *mut ffi::GESTrack,
338            _param_spec: glib::ffi::gpointer,
339            f: glib::ffi::gpointer,
340        ) {
341            let f: &F = &*(f as *const F);
342            f(Track::from_glib_borrow(this).unsafe_cast_ref())
343        }
344        unsafe {
345            let f: Box_<F> = Box_::new(f);
346            connect_raw(
347                self.as_ptr() as *mut _,
348                c"notify::id".as_ptr() as *const _,
349                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
350                    notify_id_trampoline::<Self, F> as *const (),
351                )),
352                Box_::into_raw(f),
353            )
354        }
355    }
356
357    #[doc(alias = "mixing")]
358    fn connect_mixing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
359        unsafe extern "C" fn notify_mixing_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
360            this: *mut ffi::GESTrack,
361            _param_spec: glib::ffi::gpointer,
362            f: glib::ffi::gpointer,
363        ) {
364            let f: &F = &*(f as *const F);
365            f(Track::from_glib_borrow(this).unsafe_cast_ref())
366        }
367        unsafe {
368            let f: Box_<F> = Box_::new(f);
369            connect_raw(
370                self.as_ptr() as *mut _,
371                c"notify::mixing".as_ptr() as *const _,
372                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
373                    notify_mixing_trampoline::<Self, F> as *const (),
374                )),
375                Box_::into_raw(f),
376            )
377        }
378    }
379
380    #[doc(alias = "restriction-caps")]
381    fn connect_restriction_caps_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
382        unsafe extern "C" fn notify_restriction_caps_trampoline<
383            P: IsA<Track>,
384            F: Fn(&P) + 'static,
385        >(
386            this: *mut ffi::GESTrack,
387            _param_spec: glib::ffi::gpointer,
388            f: glib::ffi::gpointer,
389        ) {
390            let f: &F = &*(f as *const F);
391            f(Track::from_glib_borrow(this).unsafe_cast_ref())
392        }
393        unsafe {
394            let f: Box_<F> = Box_::new(f);
395            connect_raw(
396                self.as_ptr() as *mut _,
397                c"notify::restriction-caps".as_ptr() as *const _,
398                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
399                    notify_restriction_caps_trampoline::<Self, F> as *const (),
400                )),
401                Box_::into_raw(f),
402            )
403        }
404    }
405}
406
407impl<O: IsA<Track>> GESTrackExt for O {}