Skip to main content

gstreamer_editing_services/auto/
project.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#![allow(deprecated)]
6
7#[cfg(feature = "v1_18")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
9use crate::Formatter;
10use crate::{Asset, MetaContainer, Timeline, ffi};
11use glib::{
12    object::ObjectType as _,
13    prelude::*,
14    signal::{SignalHandlerId, connect_raw},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20    #[doc(alias = "GESProject")]
21    pub struct Project(Object<ffi::GESProject, ffi::GESProjectClass>) @extends Asset, @implements MetaContainer;
22
23    match fn {
24        type_ => || ffi::ges_project_get_type(),
25    }
26}
27
28impl Project {
29    pub const NONE: Option<&'static Project> = None;
30
31    #[doc(alias = "ges_project_new")]
32    pub fn new(uri: Option<&str>) -> Project {
33        assert_initialized_main_thread!();
34        unsafe { from_glib_full(ffi::ges_project_new(uri.to_glib_none().0)) }
35    }
36}
37
38pub trait ProjectExt: IsA<Project> + 'static {
39    #[doc(alias = "ges_project_add_asset")]
40    fn add_asset(&self, asset: &impl IsA<Asset>) -> bool {
41        unsafe {
42            from_glib(ffi::ges_project_add_asset(
43                self.as_ref().to_glib_none().0,
44                asset.as_ref().to_glib_none().0,
45            ))
46        }
47    }
48
49    #[doc(alias = "ges_project_add_encoding_profile")]
50    fn add_encoding_profile(
51        &self,
52        profile: &impl IsA<gst_pbutils::EncodingProfile>,
53    ) -> Result<(), glib::error::BoolError> {
54        unsafe {
55            glib::result_from_gboolean!(
56                ffi::ges_project_add_encoding_profile(
57                    self.as_ref().to_glib_none().0,
58                    profile.as_ref().to_glib_none().0
59                ),
60                "Failed to add profile"
61            )
62        }
63    }
64
65    #[cfg(feature = "v1_18")]
66    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
67    #[doc(alias = "ges_project_add_formatter")]
68    fn add_formatter(&self, formatter: &impl IsA<Formatter>) {
69        unsafe {
70            ffi::ges_project_add_formatter(
71                self.as_ref().to_glib_none().0,
72                formatter.as_ref().to_glib_none().0,
73            );
74        }
75    }
76
77    #[doc(alias = "ges_project_create_asset")]
78    fn create_asset(&self, id: Option<&str>, extractable_type: glib::types::Type) -> bool {
79        unsafe {
80            from_glib(ffi::ges_project_create_asset(
81                self.as_ref().to_glib_none().0,
82                id.to_glib_none().0,
83                extractable_type.into_glib(),
84            ))
85        }
86    }
87
88    #[doc(alias = "ges_project_create_asset_sync")]
89    fn create_asset_sync(
90        &self,
91        id: Option<&str>,
92        extractable_type: glib::types::Type,
93    ) -> Result<Option<Asset>, glib::Error> {
94        unsafe {
95            let mut error = std::ptr::null_mut();
96            let ret = ffi::ges_project_create_asset_sync(
97                self.as_ref().to_glib_none().0,
98                id.to_glib_none().0,
99                extractable_type.into_glib(),
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    #[doc(alias = "ges_project_get_asset")]
111    #[doc(alias = "get_asset")]
112    fn asset(&self, id: &str, extractable_type: glib::types::Type) -> Option<Asset> {
113        unsafe {
114            from_glib_full(ffi::ges_project_get_asset(
115                self.as_ref().to_glib_none().0,
116                id.to_glib_none().0,
117                extractable_type.into_glib(),
118            ))
119        }
120    }
121
122    #[doc(alias = "ges_project_get_loading_assets")]
123    #[doc(alias = "get_loading_assets")]
124    fn loading_assets(&self) -> Vec<Asset> {
125        unsafe {
126            FromGlibPtrContainer::from_glib_full(ffi::ges_project_get_loading_assets(
127                self.as_ref().to_glib_none().0,
128            ))
129        }
130    }
131
132    #[doc(alias = "ges_project_get_uri")]
133    #[doc(alias = "get_uri")]
134    fn uri(&self) -> Option<glib::GString> {
135        unsafe { from_glib_full(ffi::ges_project_get_uri(self.as_ref().to_glib_none().0)) }
136    }
137
138    #[doc(alias = "ges_project_list_assets")]
139    fn list_assets(&self, filter: glib::types::Type) -> Vec<Asset> {
140        unsafe {
141            FromGlibPtrContainer::from_glib_full(ffi::ges_project_list_assets(
142                self.as_ref().to_glib_none().0,
143                filter.into_glib(),
144            ))
145        }
146    }
147
148    #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
149    #[allow(deprecated)]
150    #[doc(alias = "ges_project_list_encoding_profiles")]
151    fn list_encoding_profiles(&self) -> Vec<gst_pbutils::EncodingProfile> {
152        unsafe {
153            FromGlibPtrContainer::from_glib_none(ffi::ges_project_list_encoding_profiles(
154                self.as_ref().to_glib_none().0,
155            ))
156        }
157    }
158
159    #[cfg(feature = "v1_30")]
160    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
161    #[doc(alias = "ges_project_list_encoding_profiles_full")]
162    fn list_encoding_profiles_full(&self) -> Vec<gst_pbutils::EncodingProfile> {
163        unsafe {
164            FromGlibPtrContainer::from_glib_full(ffi::ges_project_list_encoding_profiles_full(
165                self.as_ref().to_glib_none().0,
166            ))
167        }
168    }
169
170    #[doc(alias = "ges_project_load")]
171    fn load(&self, timeline: &impl IsA<Timeline>) -> Result<(), glib::Error> {
172        unsafe {
173            let mut error = std::ptr::null_mut();
174            let is_ok = ffi::ges_project_load(
175                self.as_ref().to_glib_none().0,
176                timeline.as_ref().to_glib_none().0,
177                &mut error,
178            );
179            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
180            if error.is_null() {
181                Ok(())
182            } else {
183                Err(from_glib_full(error))
184            }
185        }
186    }
187
188    #[doc(alias = "ges_project_remove_asset")]
189    fn remove_asset(&self, asset: &impl IsA<Asset>) -> Result<(), glib::error::BoolError> {
190        unsafe {
191            glib::result_from_gboolean!(
192                ffi::ges_project_remove_asset(
193                    self.as_ref().to_glib_none().0,
194                    asset.as_ref().to_glib_none().0
195                ),
196                "Failed to remove asset"
197            )
198        }
199    }
200
201    #[doc(alias = "ges_project_save")]
202    fn save(
203        &self,
204        timeline: &impl IsA<Timeline>,
205        uri: &str,
206        formatter_asset: Option<impl IsA<Asset>>,
207        overwrite: bool,
208    ) -> Result<(), glib::Error> {
209        unsafe {
210            let mut error = std::ptr::null_mut();
211            let is_ok = ffi::ges_project_save(
212                self.as_ref().to_glib_none().0,
213                timeline.as_ref().to_glib_none().0,
214                uri.to_glib_none().0,
215                formatter_asset.map(|p| p.upcast()).into_glib_ptr(),
216                overwrite.into_glib(),
217                &mut error,
218            );
219            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
220            if error.is_null() {
221                Ok(())
222            } else {
223                Err(from_glib_full(error))
224            }
225        }
226    }
227
228    #[doc(alias = "asset-added")]
229    fn connect_asset_added<F: Fn(&Self, &Asset) + 'static>(&self, f: F) -> SignalHandlerId {
230        unsafe extern "C" fn asset_added_trampoline<
231            P: IsA<Project>,
232            F: Fn(&P, &Asset) + 'static,
233        >(
234            this: *mut ffi::GESProject,
235            asset: *mut ffi::GESAsset,
236            f: glib::ffi::gpointer,
237        ) {
238            unsafe {
239                let f: &F = &*(f as *const F);
240                f(
241                    Project::from_glib_borrow(this).unsafe_cast_ref(),
242                    &from_glib_borrow(asset),
243                )
244            }
245        }
246        unsafe {
247            let f: Box_<F> = Box_::new(f);
248            connect_raw(
249                self.as_ptr() as *mut _,
250                c"asset-added".as_ptr(),
251                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
252                    asset_added_trampoline::<Self, F> as *const (),
253                )),
254                Box_::into_raw(f),
255            )
256        }
257    }
258
259    #[doc(alias = "asset-loading")]
260    fn connect_asset_loading<F: Fn(&Self, &Asset) + 'static>(&self, f: F) -> SignalHandlerId {
261        unsafe extern "C" fn asset_loading_trampoline<
262            P: IsA<Project>,
263            F: Fn(&P, &Asset) + 'static,
264        >(
265            this: *mut ffi::GESProject,
266            asset: *mut ffi::GESAsset,
267            f: glib::ffi::gpointer,
268        ) {
269            unsafe {
270                let f: &F = &*(f as *const F);
271                f(
272                    Project::from_glib_borrow(this).unsafe_cast_ref(),
273                    &from_glib_borrow(asset),
274                )
275            }
276        }
277        unsafe {
278            let f: Box_<F> = Box_::new(f);
279            connect_raw(
280                self.as_ptr() as *mut _,
281                c"asset-loading".as_ptr(),
282                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
283                    asset_loading_trampoline::<Self, F> as *const (),
284                )),
285                Box_::into_raw(f),
286            )
287        }
288    }
289
290    #[doc(alias = "asset-removed")]
291    fn connect_asset_removed<F: Fn(&Self, &Asset) + 'static>(&self, f: F) -> SignalHandlerId {
292        unsafe extern "C" fn asset_removed_trampoline<
293            P: IsA<Project>,
294            F: Fn(&P, &Asset) + 'static,
295        >(
296            this: *mut ffi::GESProject,
297            asset: *mut ffi::GESAsset,
298            f: glib::ffi::gpointer,
299        ) {
300            unsafe {
301                let f: &F = &*(f as *const F);
302                f(
303                    Project::from_glib_borrow(this).unsafe_cast_ref(),
304                    &from_glib_borrow(asset),
305                )
306            }
307        }
308        unsafe {
309            let f: Box_<F> = Box_::new(f);
310            connect_raw(
311                self.as_ptr() as *mut _,
312                c"asset-removed".as_ptr(),
313                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
314                    asset_removed_trampoline::<Self, F> as *const (),
315                )),
316                Box_::into_raw(f),
317            )
318        }
319    }
320
321    #[cfg(feature = "v1_18")]
322    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
323    #[doc(alias = "error-loading")]
324    fn connect_error_loading<F: Fn(&Self, &Timeline, &glib::Error) + 'static>(
325        &self,
326        f: F,
327    ) -> SignalHandlerId {
328        unsafe extern "C" fn error_loading_trampoline<
329            P: IsA<Project>,
330            F: Fn(&P, &Timeline, &glib::Error) + 'static,
331        >(
332            this: *mut ffi::GESProject,
333            timeline: *mut ffi::GESTimeline,
334            error: *mut glib::ffi::GError,
335            f: glib::ffi::gpointer,
336        ) {
337            unsafe {
338                let f: &F = &*(f as *const F);
339                f(
340                    Project::from_glib_borrow(this).unsafe_cast_ref(),
341                    &from_glib_borrow(timeline),
342                    &from_glib_borrow(error),
343                )
344            }
345        }
346        unsafe {
347            let f: Box_<F> = Box_::new(f);
348            connect_raw(
349                self.as_ptr() as *mut _,
350                c"error-loading".as_ptr(),
351                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
352                    error_loading_trampoline::<Self, F> as *const (),
353                )),
354                Box_::into_raw(f),
355            )
356        }
357    }
358
359    #[doc(alias = "error-loading-asset")]
360    fn connect_error_loading_asset<
361        F: Fn(&Self, &glib::Error, &str, glib::types::Type) + 'static,
362    >(
363        &self,
364        f: F,
365    ) -> SignalHandlerId {
366        unsafe extern "C" fn error_loading_asset_trampoline<
367            P: IsA<Project>,
368            F: Fn(&P, &glib::Error, &str, glib::types::Type) + 'static,
369        >(
370            this: *mut ffi::GESProject,
371            error: *mut glib::ffi::GError,
372            id: *mut std::ffi::c_char,
373            extractable_type: glib::ffi::GType,
374            f: glib::ffi::gpointer,
375        ) {
376            unsafe {
377                let f: &F = &*(f as *const F);
378                f(
379                    Project::from_glib_borrow(this).unsafe_cast_ref(),
380                    &from_glib_borrow(error),
381                    &glib::GString::from_glib_borrow(id),
382                    from_glib(extractable_type),
383                )
384            }
385        }
386        unsafe {
387            let f: Box_<F> = Box_::new(f);
388            connect_raw(
389                self.as_ptr() as *mut _,
390                c"error-loading-asset".as_ptr(),
391                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
392                    error_loading_asset_trampoline::<Self, F> as *const (),
393                )),
394                Box_::into_raw(f),
395            )
396        }
397    }
398
399    #[doc(alias = "loaded")]
400    fn connect_loaded<F: Fn(&Self, &Timeline) + 'static>(&self, f: F) -> SignalHandlerId {
401        unsafe extern "C" fn loaded_trampoline<P: IsA<Project>, F: Fn(&P, &Timeline) + 'static>(
402            this: *mut ffi::GESProject,
403            timeline: *mut ffi::GESTimeline,
404            f: glib::ffi::gpointer,
405        ) {
406            unsafe {
407                let f: &F = &*(f as *const F);
408                f(
409                    Project::from_glib_borrow(this).unsafe_cast_ref(),
410                    &from_glib_borrow(timeline),
411                )
412            }
413        }
414        unsafe {
415            let f: Box_<F> = Box_::new(f);
416            connect_raw(
417                self.as_ptr() as *mut _,
418                c"loaded".as_ptr(),
419                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
420                    loaded_trampoline::<Self, F> as *const (),
421                )),
422                Box_::into_raw(f),
423            )
424        }
425    }
426
427    #[cfg(feature = "v1_18")]
428    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
429    #[doc(alias = "loading")]
430    fn connect_loading<F: Fn(&Self, &Timeline) + 'static>(&self, f: F) -> SignalHandlerId {
431        unsafe extern "C" fn loading_trampoline<P: IsA<Project>, F: Fn(&P, &Timeline) + 'static>(
432            this: *mut ffi::GESProject,
433            timeline: *mut ffi::GESTimeline,
434            f: glib::ffi::gpointer,
435        ) {
436            unsafe {
437                let f: &F = &*(f as *const F);
438                f(
439                    Project::from_glib_borrow(this).unsafe_cast_ref(),
440                    &from_glib_borrow(timeline),
441                )
442            }
443        }
444        unsafe {
445            let f: Box_<F> = Box_::new(f);
446            connect_raw(
447                self.as_ptr() as *mut _,
448                c"loading".as_ptr(),
449                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
450                    loading_trampoline::<Self, F> as *const (),
451                )),
452                Box_::into_raw(f),
453            )
454        }
455    }
456
457    #[doc(alias = "missing-uri")]
458    fn connect_missing_uri<
459        F: Fn(&Self, &glib::Error, &Asset) -> Option<glib::GString> + 'static,
460    >(
461        &self,
462        f: F,
463    ) -> SignalHandlerId {
464        unsafe extern "C" fn missing_uri_trampoline<
465            P: IsA<Project>,
466            F: Fn(&P, &glib::Error, &Asset) -> Option<glib::GString> + 'static,
467        >(
468            this: *mut ffi::GESProject,
469            error: *mut glib::ffi::GError,
470            wrong_asset: *mut ffi::GESAsset,
471            f: glib::ffi::gpointer,
472        ) -> *mut std::ffi::c_char {
473            unsafe {
474                let f: &F = &*(f as *const F);
475                f(
476                    Project::from_glib_borrow(this).unsafe_cast_ref(),
477                    &from_glib_borrow(error),
478                    &from_glib_borrow(wrong_asset),
479                )
480                .to_glib_full()
481            }
482        }
483        unsafe {
484            let f: Box_<F> = Box_::new(f);
485            connect_raw(
486                self.as_ptr() as *mut _,
487                c"missing-uri".as_ptr(),
488                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
489                    missing_uri_trampoline::<Self, F> as *const (),
490                )),
491                Box_::into_raw(f),
492            )
493        }
494    }
495}
496
497impl<O: IsA<Project>> ProjectExt for O {}