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