gstreamer_editing_services/auto/
clip.rs1#[cfg(feature = "v1_18")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
8use crate::FrameNumber;
9use crate::{
10 Asset, BaseEffect, Container, Extractable, Layer, MetaContainer, TimelineElement, Track,
11 TrackElement, TrackType, ffi,
12};
13use glib::{
14 prelude::*,
15 signal::{SignalHandlerId, connect_raw},
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 #[cfg(feature = "v1_28")]
259 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
260 #[doc(alias = "ges_clip_is_moving_between_layers")]
261 fn is_moving_between_layers(&self) -> bool {
262 unsafe {
263 from_glib(ffi::ges_clip_is_moving_between_layers(
264 self.as_ref().to_glib_none().0,
265 ))
266 }
267 }
268
269 #[doc(alias = "ges_clip_move_to_layer")]
270 fn move_to_layer(&self, layer: &impl IsA<Layer>) -> Result<(), glib::error::BoolError> {
271 unsafe {
272 glib::result_from_gboolean!(
273 ffi::ges_clip_move_to_layer(
274 self.as_ref().to_glib_none().0,
275 layer.as_ref().to_glib_none().0
276 ),
277 "Failed to move clip to specified layer"
278 )
279 }
280 }
281
282 #[cfg(feature = "v1_18")]
283 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
284 #[doc(alias = "ges_clip_move_to_layer_full")]
285 fn move_to_layer_full(&self, layer: &impl IsA<Layer>) -> Result<(), glib::Error> {
286 unsafe {
287 let mut error = std::ptr::null_mut();
288 let is_ok = ffi::ges_clip_move_to_layer_full(
289 self.as_ref().to_glib_none().0,
290 layer.as_ref().to_glib_none().0,
291 &mut error,
292 );
293 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
294 if error.is_null() {
295 Ok(())
296 } else {
297 Err(from_glib_full(error))
298 }
299 }
300 }
301
302 #[cfg(feature = "v1_18")]
303 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
304 #[doc(alias = "ges_clip_remove_top_effect")]
305 fn remove_top_effect(&self, effect: &impl IsA<BaseEffect>) -> Result<(), glib::Error> {
306 unsafe {
307 let mut error = std::ptr::null_mut();
308 let is_ok = ffi::ges_clip_remove_top_effect(
309 self.as_ref().to_glib_none().0,
310 effect.as_ref().to_glib_none().0,
311 &mut error,
312 );
313 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
314 if error.is_null() {
315 Ok(())
316 } else {
317 Err(from_glib_full(error))
318 }
319 }
320 }
321
322 #[doc(alias = "ges_clip_set_supported_formats")]
323 #[doc(alias = "supported-formats")]
324 fn set_supported_formats(&self, supportedformats: TrackType) {
325 unsafe {
326 ffi::ges_clip_set_supported_formats(
327 self.as_ref().to_glib_none().0,
328 supportedformats.into_glib(),
329 );
330 }
331 }
332
333 #[doc(alias = "ges_clip_set_top_effect_index")]
334 fn set_top_effect_index(
335 &self,
336 effect: &impl IsA<BaseEffect>,
337 newindex: u32,
338 ) -> Result<(), glib::error::BoolError> {
339 unsafe {
340 glib::result_from_gboolean!(
341 ffi::ges_clip_set_top_effect_index(
342 self.as_ref().to_glib_none().0,
343 effect.as_ref().to_glib_none().0,
344 newindex
345 ),
346 "Failed to move effect"
347 )
348 }
349 }
350
351 #[cfg(feature = "v1_18")]
352 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
353 #[doc(alias = "ges_clip_set_top_effect_index_full")]
354 fn set_top_effect_index_full(
355 &self,
356 effect: &impl IsA<BaseEffect>,
357 newindex: u32,
358 ) -> Result<(), glib::Error> {
359 unsafe {
360 let mut error = std::ptr::null_mut();
361 let is_ok = ffi::ges_clip_set_top_effect_index_full(
362 self.as_ref().to_glib_none().0,
363 effect.as_ref().to_glib_none().0,
364 newindex,
365 &mut error,
366 );
367 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
368 if error.is_null() {
369 Ok(())
370 } else {
371 Err(from_glib_full(error))
372 }
373 }
374 }
375
376 #[doc(alias = "ges_clip_set_top_effect_priority")]
377 fn set_top_effect_priority(
378 &self,
379 effect: &impl IsA<BaseEffect>,
380 newpriority: u32,
381 ) -> Result<(), glib::error::BoolError> {
382 unsafe {
383 glib::result_from_gboolean!(
384 ffi::ges_clip_set_top_effect_priority(
385 self.as_ref().to_glib_none().0,
386 effect.as_ref().to_glib_none().0,
387 newpriority
388 ),
389 "Failed to the set top effect priority"
390 )
391 }
392 }
393
394 #[doc(alias = "ges_clip_split")]
395 fn split(&self, position: u64) -> Result<Clip, glib::BoolError> {
396 unsafe {
397 Option::<_>::from_glib_none(ffi::ges_clip_split(
398 self.as_ref().to_glib_none().0,
399 position,
400 ))
401 .ok_or_else(|| glib::bool_error!("Failed to split clip"))
402 }
403 }
404
405 #[cfg(feature = "v1_18")]
406 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
407 #[doc(alias = "ges_clip_split_full")]
408 fn split_full(&self, position: u64) -> Result<Option<Clip>, glib::Error> {
409 unsafe {
410 let mut error = std::ptr::null_mut();
411 let ret =
412 ffi::ges_clip_split_full(self.as_ref().to_glib_none().0, position, &mut error);
413 if error.is_null() {
414 Ok(from_glib_none(ret))
415 } else {
416 Err(from_glib_full(error))
417 }
418 }
419 }
420
421 #[cfg(feature = "v1_18")]
422 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
423 #[doc(alias = "duration-limit")]
424 fn connect_duration_limit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
425 unsafe extern "C" fn notify_duration_limit_trampoline<P: IsA<Clip>, F: Fn(&P) + 'static>(
426 this: *mut ffi::GESClip,
427 _param_spec: glib::ffi::gpointer,
428 f: glib::ffi::gpointer,
429 ) {
430 unsafe {
431 let f: &F = &*(f as *const F);
432 f(Clip::from_glib_borrow(this).unsafe_cast_ref())
433 }
434 }
435 unsafe {
436 let f: Box_<F> = Box_::new(f);
437 connect_raw(
438 self.as_ptr() as *mut _,
439 c"notify::duration-limit".as_ptr(),
440 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
441 notify_duration_limit_trampoline::<Self, F> as *const (),
442 )),
443 Box_::into_raw(f),
444 )
445 }
446 }
447
448 #[doc(alias = "layer")]
449 fn connect_layer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
450 unsafe extern "C" fn notify_layer_trampoline<P: IsA<Clip>, F: Fn(&P) + 'static>(
451 this: *mut ffi::GESClip,
452 _param_spec: glib::ffi::gpointer,
453 f: glib::ffi::gpointer,
454 ) {
455 unsafe {
456 let f: &F = &*(f as *const F);
457 f(Clip::from_glib_borrow(this).unsafe_cast_ref())
458 }
459 }
460 unsafe {
461 let f: Box_<F> = Box_::new(f);
462 connect_raw(
463 self.as_ptr() as *mut _,
464 c"notify::layer".as_ptr(),
465 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
466 notify_layer_trampoline::<Self, F> as *const (),
467 )),
468 Box_::into_raw(f),
469 )
470 }
471 }
472
473 #[doc(alias = "supported-formats")]
474 fn connect_supported_formats_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
475 unsafe extern "C" fn notify_supported_formats_trampoline<
476 P: IsA<Clip>,
477 F: Fn(&P) + 'static,
478 >(
479 this: *mut ffi::GESClip,
480 _param_spec: glib::ffi::gpointer,
481 f: glib::ffi::gpointer,
482 ) {
483 unsafe {
484 let f: &F = &*(f as *const F);
485 f(Clip::from_glib_borrow(this).unsafe_cast_ref())
486 }
487 }
488 unsafe {
489 let f: Box_<F> = Box_::new(f);
490 connect_raw(
491 self.as_ptr() as *mut _,
492 c"notify::supported-formats".as_ptr(),
493 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
494 notify_supported_formats_trampoline::<Self, F> as *const (),
495 )),
496 Box_::into_raw(f),
497 )
498 }
499 }
500}
501
502impl<O: IsA<Clip>> ClipExt for O {}