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