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