gstreamer_editing_services/auto/
clip.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
6#[cfg(feature = "v1_18")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
8use crate::FrameNumber;
9use crate::{
10    ffi, Asset, BaseEffect, Container, Extractable, Layer, MetaContainer, TimelineElement, Track,
11    TrackElement, TrackType,
12};
13use glib::{
14    prelude::*,
15    signal::{connect_raw, SignalHandlerId},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21    #[doc(alias = "GESClip")]
22    pub struct Clip(Object<ffi::GESClip, ffi::GESClipClass>) @extends Container, TimelineElement, @implements Extractable, MetaContainer;
23
24    match fn {
25        type_ => || ffi::ges_clip_get_type(),
26    }
27}
28
29impl Clip {
30    pub const NONE: Option<&'static Clip> = None;
31}
32
33pub trait ClipExt: IsA<Clip> + 'static {
34    #[doc(alias = "ges_clip_add_asset")]
35    fn add_asset(&self, asset: &impl IsA<Asset>) -> Result<TrackElement, glib::BoolError> {
36        unsafe {
37            Option::<_>::from_glib_none(ffi::ges_clip_add_asset(
38                self.as_ref().to_glib_none().0,
39                asset.as_ref().to_glib_none().0,
40            ))
41            .ok_or_else(|| glib::bool_error!("Failed to add asset"))
42        }
43    }
44
45    #[cfg(feature = "v1_18")]
46    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
47    #[doc(alias = "ges_clip_add_child_to_track")]
48    fn add_child_to_track(
49        &self,
50        child: &impl IsA<TrackElement>,
51        track: &impl IsA<Track>,
52    ) -> Result<TrackElement, glib::Error> {
53        unsafe {
54            let mut error = std::ptr::null_mut();
55            let ret = ffi::ges_clip_add_child_to_track(
56                self.as_ref().to_glib_none().0,
57                child.as_ref().to_glib_none().0,
58                track.as_ref().to_glib_none().0,
59                &mut error,
60            );
61            if error.is_null() {
62                Ok(from_glib_none(ret))
63            } else {
64                Err(from_glib_full(error))
65            }
66        }
67    }
68
69    #[cfg(feature = "v1_18")]
70    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
71    #[doc(alias = "ges_clip_add_top_effect")]
72    fn add_top_effect(&self, effect: &impl IsA<BaseEffect>, index: i32) -> Result<(), glib::Error> {
73        unsafe {
74            let mut error = std::ptr::null_mut();
75            let is_ok = ffi::ges_clip_add_top_effect(
76                self.as_ref().to_glib_none().0,
77                effect.as_ref().to_glib_none().0,
78                index,
79                &mut error,
80            );
81            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
82            if error.is_null() {
83                Ok(())
84            } else {
85                Err(from_glib_full(error))
86            }
87        }
88    }
89
90    #[doc(alias = "ges_clip_find_track_element")]
91    fn find_track_element(
92        &self,
93        track: Option<&impl IsA<Track>>,
94        type_: glib::types::Type,
95    ) -> Option<TrackElement> {
96        unsafe {
97            from_glib_full(ffi::ges_clip_find_track_element(
98                self.as_ref().to_glib_none().0,
99                track.map(|p| p.as_ref()).to_glib_none().0,
100                type_.into_glib(),
101            ))
102        }
103    }
104
105    #[doc(alias = "ges_clip_find_track_elements")]
106    fn find_track_elements(
107        &self,
108        track: Option<&impl IsA<Track>>,
109        track_type: TrackType,
110        type_: glib::types::Type,
111    ) -> Vec<TrackElement> {
112        unsafe {
113            FromGlibPtrContainer::from_glib_full(ffi::ges_clip_find_track_elements(
114                self.as_ref().to_glib_none().0,
115                track.map(|p| p.as_ref()).to_glib_none().0,
116                track_type.into_glib(),
117                type_.into_glib(),
118            ))
119        }
120    }
121
122    #[cfg(feature = "v1_18")]
123    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
124    #[doc(alias = "ges_clip_get_duration_limit")]
125    #[doc(alias = "get_duration_limit")]
126    #[doc(alias = "duration-limit")]
127    fn duration_limit(&self) -> gst::ClockTime {
128        unsafe {
129            try_from_glib(ffi::ges_clip_get_duration_limit(
130                self.as_ref().to_glib_none().0,
131            ))
132            .expect("mandatory glib value is None")
133        }
134    }
135
136    #[cfg(feature = "v1_18")]
137    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
138    #[doc(alias = "ges_clip_get_internal_time_from_timeline_time")]
139    #[doc(alias = "get_internal_time_from_timeline_time")]
140    fn internal_time_from_timeline_time(
141        &self,
142        child: &impl IsA<TrackElement>,
143        timeline_time: impl Into<Option<gst::ClockTime>>,
144    ) -> Result<Option<gst::ClockTime>, glib::Error> {
145        unsafe {
146            let mut error = std::ptr::null_mut();
147            let ret = ffi::ges_clip_get_internal_time_from_timeline_time(
148                self.as_ref().to_glib_none().0,
149                child.as_ref().to_glib_none().0,
150                timeline_time.into().into_glib(),
151                &mut error,
152            );
153            if error.is_null() {
154                Ok(from_glib(ret))
155            } else {
156                Err(from_glib_full(error))
157            }
158        }
159    }
160
161    #[doc(alias = "ges_clip_get_layer")]
162    #[doc(alias = "get_layer")]
163    fn layer(&self) -> Option<Layer> {
164        unsafe { from_glib_full(ffi::ges_clip_get_layer(self.as_ref().to_glib_none().0)) }
165    }
166
167    #[doc(alias = "ges_clip_get_supported_formats")]
168    #[doc(alias = "get_supported_formats")]
169    #[doc(alias = "supported-formats")]
170    fn supported_formats(&self) -> TrackType {
171        unsafe {
172            from_glib(ffi::ges_clip_get_supported_formats(
173                self.as_ref().to_glib_none().0,
174            ))
175        }
176    }
177
178    #[cfg(feature = "v1_18")]
179    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
180    #[doc(alias = "ges_clip_get_timeline_time_from_internal_time")]
181    #[doc(alias = "get_timeline_time_from_internal_time")]
182    fn timeline_time_from_internal_time(
183        &self,
184        child: &impl IsA<TrackElement>,
185        internal_time: impl Into<Option<gst::ClockTime>>,
186    ) -> Result<Option<gst::ClockTime>, glib::Error> {
187        unsafe {
188            let mut error = std::ptr::null_mut();
189            let ret = ffi::ges_clip_get_timeline_time_from_internal_time(
190                self.as_ref().to_glib_none().0,
191                child.as_ref().to_glib_none().0,
192                internal_time.into().into_glib(),
193                &mut error,
194            );
195            if error.is_null() {
196                Ok(from_glib(ret))
197            } else {
198                Err(from_glib_full(error))
199            }
200        }
201    }
202
203    #[cfg(feature = "v1_18")]
204    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
205    #[doc(alias = "ges_clip_get_timeline_time_from_source_frame")]
206    #[doc(alias = "get_timeline_time_from_source_frame")]
207    fn timeline_time_from_source_frame(
208        &self,
209        frame_number: FrameNumber,
210    ) -> Result<Option<gst::ClockTime>, glib::Error> {
211        unsafe {
212            let mut error = std::ptr::null_mut();
213            let ret = ffi::ges_clip_get_timeline_time_from_source_frame(
214                self.as_ref().to_glib_none().0,
215                frame_number,
216                &mut error,
217            );
218            if error.is_null() {
219                Ok(from_glib(ret))
220            } else {
221                Err(from_glib_full(error))
222            }
223        }
224    }
225
226    #[doc(alias = "ges_clip_get_top_effect_index")]
227    #[doc(alias = "get_top_effect_index")]
228    fn top_effect_index(&self, effect: &impl IsA<BaseEffect>) -> i32 {
229        unsafe {
230            ffi::ges_clip_get_top_effect_index(
231                self.as_ref().to_glib_none().0,
232                effect.as_ref().to_glib_none().0,
233            )
234        }
235    }
236
237    #[doc(alias = "ges_clip_get_top_effect_position")]
238    #[doc(alias = "get_top_effect_position")]
239    fn top_effect_position(&self, effect: &impl IsA<BaseEffect>) -> i32 {
240        unsafe {
241            ffi::ges_clip_get_top_effect_position(
242                self.as_ref().to_glib_none().0,
243                effect.as_ref().to_glib_none().0,
244            )
245        }
246    }
247
248    #[doc(alias = "ges_clip_get_top_effects")]
249    #[doc(alias = "get_top_effects")]
250    fn top_effects(&self) -> Vec<TrackElement> {
251        unsafe {
252            FromGlibPtrContainer::from_glib_full(ffi::ges_clip_get_top_effects(
253                self.as_ref().to_glib_none().0,
254            ))
255        }
256    }
257
258    #[doc(alias = "ges_clip_move_to_layer")]
259    fn move_to_layer(&self, layer: &impl IsA<Layer>) -> Result<(), glib::error::BoolError> {
260        unsafe {
261            glib::result_from_gboolean!(
262                ffi::ges_clip_move_to_layer(
263                    self.as_ref().to_glib_none().0,
264                    layer.as_ref().to_glib_none().0
265                ),
266                "Failed to move clip to specified layer"
267            )
268        }
269    }
270
271    #[cfg(feature = "v1_18")]
272    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
273    #[doc(alias = "ges_clip_move_to_layer_full")]
274    fn move_to_layer_full(&self, layer: &impl IsA<Layer>) -> Result<(), glib::Error> {
275        unsafe {
276            let mut error = std::ptr::null_mut();
277            let is_ok = ffi::ges_clip_move_to_layer_full(
278                self.as_ref().to_glib_none().0,
279                layer.as_ref().to_glib_none().0,
280                &mut error,
281            );
282            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
283            if error.is_null() {
284                Ok(())
285            } else {
286                Err(from_glib_full(error))
287            }
288        }
289    }
290
291    #[cfg(feature = "v1_18")]
292    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
293    #[doc(alias = "ges_clip_remove_top_effect")]
294    fn remove_top_effect(&self, effect: &impl IsA<BaseEffect>) -> Result<(), glib::Error> {
295        unsafe {
296            let mut error = std::ptr::null_mut();
297            let is_ok = ffi::ges_clip_remove_top_effect(
298                self.as_ref().to_glib_none().0,
299                effect.as_ref().to_glib_none().0,
300                &mut error,
301            );
302            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
303            if error.is_null() {
304                Ok(())
305            } else {
306                Err(from_glib_full(error))
307            }
308        }
309    }
310
311    #[doc(alias = "ges_clip_set_supported_formats")]
312    #[doc(alias = "supported-formats")]
313    fn set_supported_formats(&self, supportedformats: TrackType) {
314        unsafe {
315            ffi::ges_clip_set_supported_formats(
316                self.as_ref().to_glib_none().0,
317                supportedformats.into_glib(),
318            );
319        }
320    }
321
322    #[doc(alias = "ges_clip_set_top_effect_index")]
323    fn set_top_effect_index(
324        &self,
325        effect: &impl IsA<BaseEffect>,
326        newindex: u32,
327    ) -> Result<(), glib::error::BoolError> {
328        unsafe {
329            glib::result_from_gboolean!(
330                ffi::ges_clip_set_top_effect_index(
331                    self.as_ref().to_glib_none().0,
332                    effect.as_ref().to_glib_none().0,
333                    newindex
334                ),
335                "Failed to move effect"
336            )
337        }
338    }
339
340    #[cfg(feature = "v1_18")]
341    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
342    #[doc(alias = "ges_clip_set_top_effect_index_full")]
343    fn set_top_effect_index_full(
344        &self,
345        effect: &impl IsA<BaseEffect>,
346        newindex: u32,
347    ) -> Result<(), glib::Error> {
348        unsafe {
349            let mut error = std::ptr::null_mut();
350            let is_ok = ffi::ges_clip_set_top_effect_index_full(
351                self.as_ref().to_glib_none().0,
352                effect.as_ref().to_glib_none().0,
353                newindex,
354                &mut error,
355            );
356            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
357            if error.is_null() {
358                Ok(())
359            } else {
360                Err(from_glib_full(error))
361            }
362        }
363    }
364
365    #[doc(alias = "ges_clip_set_top_effect_priority")]
366    fn set_top_effect_priority(
367        &self,
368        effect: &impl IsA<BaseEffect>,
369        newpriority: u32,
370    ) -> Result<(), glib::error::BoolError> {
371        unsafe {
372            glib::result_from_gboolean!(
373                ffi::ges_clip_set_top_effect_priority(
374                    self.as_ref().to_glib_none().0,
375                    effect.as_ref().to_glib_none().0,
376                    newpriority
377                ),
378                "Failed to the set top effect priority"
379            )
380        }
381    }
382
383    #[doc(alias = "ges_clip_split")]
384    fn split(&self, position: u64) -> Result<Clip, glib::BoolError> {
385        unsafe {
386            Option::<_>::from_glib_none(ffi::ges_clip_split(
387                self.as_ref().to_glib_none().0,
388                position,
389            ))
390            .ok_or_else(|| glib::bool_error!("Failed to split clip"))
391        }
392    }
393
394    #[cfg(feature = "v1_18")]
395    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
396    #[doc(alias = "ges_clip_split_full")]
397    fn split_full(&self, position: u64) -> Result<Option<Clip>, glib::Error> {
398        unsafe {
399            let mut error = std::ptr::null_mut();
400            let ret =
401                ffi::ges_clip_split_full(self.as_ref().to_glib_none().0, position, &mut error);
402            if error.is_null() {
403                Ok(from_glib_none(ret))
404            } else {
405                Err(from_glib_full(error))
406            }
407        }
408    }
409
410    #[cfg(feature = "v1_18")]
411    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
412    #[doc(alias = "duration-limit")]
413    fn connect_duration_limit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
414        unsafe extern "C" fn notify_duration_limit_trampoline<P: IsA<Clip>, F: Fn(&P) + 'static>(
415            this: *mut ffi::GESClip,
416            _param_spec: glib::ffi::gpointer,
417            f: glib::ffi::gpointer,
418        ) {
419            let f: &F = &*(f as *const F);
420            f(Clip::from_glib_borrow(this).unsafe_cast_ref())
421        }
422        unsafe {
423            let f: Box_<F> = Box_::new(f);
424            connect_raw(
425                self.as_ptr() as *mut _,
426                c"notify::duration-limit".as_ptr() as *const _,
427                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
428                    notify_duration_limit_trampoline::<Self, F> as *const (),
429                )),
430                Box_::into_raw(f),
431            )
432        }
433    }
434
435    #[doc(alias = "layer")]
436    fn connect_layer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
437        unsafe extern "C" fn notify_layer_trampoline<P: IsA<Clip>, F: Fn(&P) + 'static>(
438            this: *mut ffi::GESClip,
439            _param_spec: glib::ffi::gpointer,
440            f: glib::ffi::gpointer,
441        ) {
442            let f: &F = &*(f as *const F);
443            f(Clip::from_glib_borrow(this).unsafe_cast_ref())
444        }
445        unsafe {
446            let f: Box_<F> = Box_::new(f);
447            connect_raw(
448                self.as_ptr() as *mut _,
449                c"notify::layer".as_ptr() as *const _,
450                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
451                    notify_layer_trampoline::<Self, F> as *const (),
452                )),
453                Box_::into_raw(f),
454            )
455        }
456    }
457
458    #[doc(alias = "supported-formats")]
459    fn connect_supported_formats_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
460        unsafe extern "C" fn notify_supported_formats_trampoline<
461            P: IsA<Clip>,
462            F: Fn(&P) + 'static,
463        >(
464            this: *mut ffi::GESClip,
465            _param_spec: glib::ffi::gpointer,
466            f: glib::ffi::gpointer,
467        ) {
468            let f: &F = &*(f as *const F);
469            f(Clip::from_glib_borrow(this).unsafe_cast_ref())
470        }
471        unsafe {
472            let f: Box_<F> = Box_::new(f);
473            connect_raw(
474                self.as_ptr() as *mut _,
475                c"notify::supported-formats".as_ptr() as *const _,
476                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
477                    notify_supported_formats_trampoline::<Self, F> as *const (),
478                )),
479                Box_::into_raw(f),
480            )
481        }
482    }
483}
484
485impl<O: IsA<Clip>> ClipExt for O {}