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