gstreamer_editing_services/auto/
track.rs1#![allow(deprecated)]
6
7use crate::{MetaContainer, Timeline, TrackElement, TrackType, ffi};
8use glib::{
9 object::ObjectType as _,
10 prelude::*,
11 signal::{SignalHandlerId, connect_raw},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17 #[doc(alias = "GESTrack")]
18 pub struct Track(Object<ffi::GESTrack, ffi::GESTrackClass>) @extends gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, MetaContainer;
19
20 match fn {
21 type_ => || ffi::ges_track_get_type(),
22 }
23}
24
25impl Track {
26 pub const NONE: Option<&'static Track> = None;
27
28 #[doc(alias = "ges_track_new")]
29 pub fn new(type_: TrackType, caps: gst::Caps) -> Track {
30 assert_initialized_main_thread!();
31 unsafe { from_glib_none(ffi::ges_track_new(type_.into_glib(), caps.into_glib_ptr())) }
32 }
33}
34
35pub trait GESTrackExt: IsA<Track> + 'static {
36 #[doc(alias = "ges_track_add_element")]
37 fn add_element(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::error::BoolError> {
38 unsafe {
39 glib::result_from_gboolean!(
40 ffi::ges_track_add_element(
41 self.as_ref().to_glib_none().0,
42 object.as_ref().to_glib_none().0
43 ),
44 "Failed to add element"
45 )
46 }
47 }
48
49 #[cfg(feature = "v1_18")]
50 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
51 #[doc(alias = "ges_track_add_element_full")]
52 fn add_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
53 unsafe {
54 let mut error = std::ptr::null_mut();
55 let is_ok = ffi::ges_track_add_element_full(
56 self.as_ref().to_glib_none().0,
57 object.as_ref().to_glib_none().0,
58 &mut error,
59 );
60 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
61 if error.is_null() {
62 Ok(())
63 } else {
64 Err(from_glib_full(error))
65 }
66 }
67 }
68
69 #[doc(alias = "ges_track_commit")]
70 fn commit(&self) -> bool {
71 unsafe { from_glib(ffi::ges_track_commit(self.as_ref().to_glib_none().0)) }
72 }
73
74 #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
75 #[allow(deprecated)]
76 #[doc(alias = "ges_track_get_caps")]
77 #[doc(alias = "get_caps")]
78 fn caps(&self) -> Option<gst::Caps> {
79 unsafe { from_glib_none(ffi::ges_track_get_caps(self.as_ref().to_glib_none().0)) }
80 }
81
82 #[cfg(feature = "v1_30")]
83 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
84 #[doc(alias = "ges_track_get_caps_full")]
85 #[doc(alias = "get_caps_full")]
86 fn caps_full(&self) -> Option<gst::Caps> {
87 unsafe { from_glib_full(ffi::ges_track_get_caps_full(self.as_ref().to_glib_none().0)) }
88 }
89
90 #[doc(alias = "ges_track_get_elements")]
91 #[doc(alias = "get_elements")]
92 fn elements(&self) -> Vec<TrackElement> {
93 unsafe {
94 FromGlibPtrContainer::from_glib_full(ffi::ges_track_get_elements(
95 self.as_ref().to_glib_none().0,
96 ))
97 }
98 }
99
100 #[doc(alias = "ges_track_get_mixing")]
101 #[doc(alias = "get_mixing")]
102 #[doc(alias = "mixing")]
103 fn is_mixing(&self) -> bool {
104 unsafe { from_glib(ffi::ges_track_get_mixing(self.as_ref().to_glib_none().0)) }
105 }
106
107 #[cfg(feature = "v1_18")]
108 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
109 #[doc(alias = "ges_track_get_restriction_caps")]
110 #[doc(alias = "get_restriction_caps")]
111 #[doc(alias = "restriction-caps")]
112 fn restriction_caps(&self) -> Option<gst::Caps> {
113 unsafe {
114 from_glib_full(ffi::ges_track_get_restriction_caps(
115 self.as_ref().to_glib_none().0,
116 ))
117 }
118 }
119
120 #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
121 #[allow(deprecated)]
122 #[doc(alias = "ges_track_get_timeline")]
123 #[doc(alias = "get_timeline")]
124 fn timeline(&self) -> Option<Timeline> {
125 unsafe { from_glib_none(ffi::ges_track_get_timeline(self.as_ref().to_glib_none().0)) }
126 }
127
128 #[cfg(feature = "v1_30")]
129 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
130 #[doc(alias = "ges_track_get_timeline_full")]
131 #[doc(alias = "get_timeline_full")]
132 fn timeline_full(&self) -> Option<Timeline> {
133 unsafe {
134 from_glib_full(ffi::ges_track_get_timeline_full(
135 self.as_ref().to_glib_none().0,
136 ))
137 }
138 }
139
140 #[doc(alias = "ges_track_remove_element")]
141 fn remove_element(
142 &self,
143 object: &impl IsA<TrackElement>,
144 ) -> Result<(), glib::error::BoolError> {
145 unsafe {
146 glib::result_from_gboolean!(
147 ffi::ges_track_remove_element(
148 self.as_ref().to_glib_none().0,
149 object.as_ref().to_glib_none().0
150 ),
151 "Failed to remove element"
152 )
153 }
154 }
155
156 #[cfg(feature = "v1_18")]
157 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
158 #[doc(alias = "ges_track_remove_element_full")]
159 fn remove_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
160 unsafe {
161 let mut error = std::ptr::null_mut();
162 let is_ok = ffi::ges_track_remove_element_full(
163 self.as_ref().to_glib_none().0,
164 object.as_ref().to_glib_none().0,
165 &mut error,
166 );
167 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
168 if error.is_null() {
169 Ok(())
170 } else {
171 Err(from_glib_full(error))
172 }
173 }
174 }
175
176 #[doc(alias = "ges_track_set_mixing")]
182 #[doc(alias = "mixing")]
183 fn set_mixing(&self, mixing: bool) {
184 unsafe {
185 ffi::ges_track_set_mixing(self.as_ref().to_glib_none().0, mixing.into_glib());
186 }
187 }
188
189 #[doc(alias = "ges_track_set_restriction_caps")]
190 #[doc(alias = "restriction-caps")]
191 fn set_restriction_caps(&self, caps: &gst::Caps) {
192 unsafe {
193 ffi::ges_track_set_restriction_caps(
194 self.as_ref().to_glib_none().0,
195 caps.to_glib_none().0,
196 );
197 }
198 }
199
200 #[doc(alias = "ges_track_set_timeline")]
201 fn set_timeline(&self, timeline: &impl IsA<Timeline>) {
202 unsafe {
203 ffi::ges_track_set_timeline(
204 self.as_ref().to_glib_none().0,
205 timeline.as_ref().to_glib_none().0,
206 );
207 }
208 }
209
210 #[doc(alias = "ges_track_update_restriction_caps")]
211 fn update_restriction_caps(&self, caps: &gst::Caps) {
212 unsafe {
213 ffi::ges_track_update_restriction_caps(
214 self.as_ref().to_glib_none().0,
215 caps.to_glib_none().0,
216 );
217 }
218 }
219
220 fn duration(&self) -> u64 {
221 ObjectExt::property(self.as_ref(), "duration")
222 }
223
224 #[cfg(feature = "v1_18")]
225 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
226 fn id(&self) -> Option<glib::GString> {
227 ObjectExt::property(self.as_ref(), "id")
228 }
229
230 #[cfg(feature = "v1_18")]
231 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
232 fn set_id(&self, id: Option<&str>) {
233 ObjectExt::set_property(self.as_ref(), "id", id)
234 }
235
236 #[cfg(not(feature = "v1_18"))]
237 #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_18"))))]
238 #[doc(alias = "restriction-caps")]
239 fn restriction_caps(&self) -> Option<gst::Caps> {
240 ObjectExt::property(self.as_ref(), "restriction-caps")
241 }
242
243 #[doc(alias = "track-type")]
244 fn track_type(&self) -> TrackType {
245 ObjectExt::property(self.as_ref(), "track-type")
246 }
247
248 #[doc(alias = "commited")]
249 fn connect_commited<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
250 unsafe extern "C" fn commited_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
251 this: *mut ffi::GESTrack,
252 f: glib::ffi::gpointer,
253 ) {
254 unsafe {
255 let f: &F = &*(f as *const F);
256 f(Track::from_glib_borrow(this).unsafe_cast_ref())
257 }
258 }
259 unsafe {
260 let f: Box_<F> = Box_::new(f);
261 connect_raw(
262 self.as_ptr() as *mut _,
263 c"commited".as_ptr(),
264 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
265 commited_trampoline::<Self, F> as *const (),
266 )),
267 Box_::into_raw(f),
268 )
269 }
270 }
271
272 #[doc(alias = "track-element-added")]
273 fn connect_track_element_added<F: Fn(&Self, &TrackElement) + 'static>(
274 &self,
275 f: F,
276 ) -> SignalHandlerId {
277 unsafe extern "C" fn track_element_added_trampoline<
278 P: IsA<Track>,
279 F: Fn(&P, &TrackElement) + 'static,
280 >(
281 this: *mut ffi::GESTrack,
282 effect: *mut ffi::GESTrackElement,
283 f: glib::ffi::gpointer,
284 ) {
285 unsafe {
286 let f: &F = &*(f as *const F);
287 f(
288 Track::from_glib_borrow(this).unsafe_cast_ref(),
289 &from_glib_borrow(effect),
290 )
291 }
292 }
293 unsafe {
294 let f: Box_<F> = Box_::new(f);
295 connect_raw(
296 self.as_ptr() as *mut _,
297 c"track-element-added".as_ptr(),
298 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
299 track_element_added_trampoline::<Self, F> as *const (),
300 )),
301 Box_::into_raw(f),
302 )
303 }
304 }
305
306 #[doc(alias = "track-element-removed")]
307 fn connect_track_element_removed<F: Fn(&Self, &TrackElement) + 'static>(
308 &self,
309 f: F,
310 ) -> SignalHandlerId {
311 unsafe extern "C" fn track_element_removed_trampoline<
312 P: IsA<Track>,
313 F: Fn(&P, &TrackElement) + 'static,
314 >(
315 this: *mut ffi::GESTrack,
316 effect: *mut ffi::GESTrackElement,
317 f: glib::ffi::gpointer,
318 ) {
319 unsafe {
320 let f: &F = &*(f as *const F);
321 f(
322 Track::from_glib_borrow(this).unsafe_cast_ref(),
323 &from_glib_borrow(effect),
324 )
325 }
326 }
327 unsafe {
328 let f: Box_<F> = Box_::new(f);
329 connect_raw(
330 self.as_ptr() as *mut _,
331 c"track-element-removed".as_ptr(),
332 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
333 track_element_removed_trampoline::<Self, F> as *const (),
334 )),
335 Box_::into_raw(f),
336 )
337 }
338 }
339
340 #[doc(alias = "duration")]
341 fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
342 unsafe extern "C" fn notify_duration_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
343 this: *mut ffi::GESTrack,
344 _param_spec: glib::ffi::gpointer,
345 f: glib::ffi::gpointer,
346 ) {
347 unsafe {
348 let f: &F = &*(f as *const F);
349 f(Track::from_glib_borrow(this).unsafe_cast_ref())
350 }
351 }
352 unsafe {
353 let f: Box_<F> = Box_::new(f);
354 connect_raw(
355 self.as_ptr() as *mut _,
356 c"notify::duration".as_ptr(),
357 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
358 notify_duration_trampoline::<Self, F> as *const (),
359 )),
360 Box_::into_raw(f),
361 )
362 }
363 }
364
365 #[cfg(feature = "v1_18")]
366 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
367 #[doc(alias = "id")]
368 fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
369 unsafe extern "C" fn notify_id_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
370 this: *mut ffi::GESTrack,
371 _param_spec: glib::ffi::gpointer,
372 f: glib::ffi::gpointer,
373 ) {
374 unsafe {
375 let f: &F = &*(f as *const F);
376 f(Track::from_glib_borrow(this).unsafe_cast_ref())
377 }
378 }
379 unsafe {
380 let f: Box_<F> = Box_::new(f);
381 connect_raw(
382 self.as_ptr() as *mut _,
383 c"notify::id".as_ptr(),
384 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
385 notify_id_trampoline::<Self, F> as *const (),
386 )),
387 Box_::into_raw(f),
388 )
389 }
390 }
391
392 #[doc(alias = "mixing")]
393 fn connect_mixing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
394 unsafe extern "C" fn notify_mixing_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
395 this: *mut ffi::GESTrack,
396 _param_spec: glib::ffi::gpointer,
397 f: glib::ffi::gpointer,
398 ) {
399 unsafe {
400 let f: &F = &*(f as *const F);
401 f(Track::from_glib_borrow(this).unsafe_cast_ref())
402 }
403 }
404 unsafe {
405 let f: Box_<F> = Box_::new(f);
406 connect_raw(
407 self.as_ptr() as *mut _,
408 c"notify::mixing".as_ptr(),
409 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
410 notify_mixing_trampoline::<Self, F> as *const (),
411 )),
412 Box_::into_raw(f),
413 )
414 }
415 }
416
417 #[doc(alias = "restriction-caps")]
418 fn connect_restriction_caps_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
419 unsafe extern "C" fn notify_restriction_caps_trampoline<
420 P: IsA<Track>,
421 F: Fn(&P) + 'static,
422 >(
423 this: *mut ffi::GESTrack,
424 _param_spec: glib::ffi::gpointer,
425 f: glib::ffi::gpointer,
426 ) {
427 unsafe {
428 let f: &F = &*(f as *const F);
429 f(Track::from_glib_borrow(this).unsafe_cast_ref())
430 }
431 }
432 unsafe {
433 let f: Box_<F> = Box_::new(f);
434 connect_raw(
435 self.as_ptr() as *mut _,
436 c"notify::restriction-caps".as_ptr(),
437 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
438 notify_restriction_caps_trampoline::<Self, F> as *const (),
439 )),
440 Box_::into_raw(f),
441 )
442 }
443 }
444}
445
446impl<O: IsA<Track>> GESTrackExt for O {}