gstreamer_editing_services/auto/
project.rs1#[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
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 let f: &F = &*(f as *const F);
225 f(
226 Project::from_glib_borrow(this).unsafe_cast_ref(),
227 &from_glib_borrow(asset),
228 )
229 }
230 unsafe {
231 let f: Box_<F> = Box_::new(f);
232 connect_raw(
233 self.as_ptr() as *mut _,
234 c"asset-added".as_ptr() as *const _,
235 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
236 asset_added_trampoline::<Self, F> as *const (),
237 )),
238 Box_::into_raw(f),
239 )
240 }
241 }
242
243 #[doc(alias = "asset-loading")]
244 fn connect_asset_loading<F: Fn(&Self, &Asset) + 'static>(&self, f: F) -> SignalHandlerId {
245 unsafe extern "C" fn asset_loading_trampoline<
246 P: IsA<Project>,
247 F: Fn(&P, &Asset) + 'static,
248 >(
249 this: *mut ffi::GESProject,
250 asset: *mut ffi::GESAsset,
251 f: glib::ffi::gpointer,
252 ) {
253 let f: &F = &*(f as *const F);
254 f(
255 Project::from_glib_borrow(this).unsafe_cast_ref(),
256 &from_glib_borrow(asset),
257 )
258 }
259 unsafe {
260 let f: Box_<F> = Box_::new(f);
261 connect_raw(
262 self.as_ptr() as *mut _,
263 c"asset-loading".as_ptr() as *const _,
264 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
265 asset_loading_trampoline::<Self, F> as *const (),
266 )),
267 Box_::into_raw(f),
268 )
269 }
270 }
271
272 #[doc(alias = "asset-removed")]
273 fn connect_asset_removed<F: Fn(&Self, &Asset) + 'static>(&self, f: F) -> SignalHandlerId {
274 unsafe extern "C" fn asset_removed_trampoline<
275 P: IsA<Project>,
276 F: Fn(&P, &Asset) + 'static,
277 >(
278 this: *mut ffi::GESProject,
279 asset: *mut ffi::GESAsset,
280 f: glib::ffi::gpointer,
281 ) {
282 let f: &F = &*(f as *const F);
283 f(
284 Project::from_glib_borrow(this).unsafe_cast_ref(),
285 &from_glib_borrow(asset),
286 )
287 }
288 unsafe {
289 let f: Box_<F> = Box_::new(f);
290 connect_raw(
291 self.as_ptr() as *mut _,
292 c"asset-removed".as_ptr() as *const _,
293 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
294 asset_removed_trampoline::<Self, F> as *const (),
295 )),
296 Box_::into_raw(f),
297 )
298 }
299 }
300
301 #[cfg(feature = "v1_18")]
302 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
303 #[doc(alias = "error-loading")]
304 fn connect_error_loading<F: Fn(&Self, &Timeline, &glib::Error) + 'static>(
305 &self,
306 f: F,
307 ) -> SignalHandlerId {
308 unsafe extern "C" fn error_loading_trampoline<
309 P: IsA<Project>,
310 F: Fn(&P, &Timeline, &glib::Error) + 'static,
311 >(
312 this: *mut ffi::GESProject,
313 timeline: *mut ffi::GESTimeline,
314 error: *mut glib::ffi::GError,
315 f: glib::ffi::gpointer,
316 ) {
317 let f: &F = &*(f as *const F);
318 f(
319 Project::from_glib_borrow(this).unsafe_cast_ref(),
320 &from_glib_borrow(timeline),
321 &from_glib_borrow(error),
322 )
323 }
324 unsafe {
325 let f: Box_<F> = Box_::new(f);
326 connect_raw(
327 self.as_ptr() as *mut _,
328 c"error-loading".as_ptr() as *const _,
329 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
330 error_loading_trampoline::<Self, F> as *const (),
331 )),
332 Box_::into_raw(f),
333 )
334 }
335 }
336
337 #[doc(alias = "error-loading-asset")]
338 fn connect_error_loading_asset<
339 F: Fn(&Self, &glib::Error, &str, glib::types::Type) + 'static,
340 >(
341 &self,
342 f: F,
343 ) -> SignalHandlerId {
344 unsafe extern "C" fn error_loading_asset_trampoline<
345 P: IsA<Project>,
346 F: Fn(&P, &glib::Error, &str, glib::types::Type) + 'static,
347 >(
348 this: *mut ffi::GESProject,
349 error: *mut glib::ffi::GError,
350 id: *mut std::ffi::c_char,
351 extractable_type: glib::ffi::GType,
352 f: glib::ffi::gpointer,
353 ) {
354 let f: &F = &*(f as *const F);
355 f(
356 Project::from_glib_borrow(this).unsafe_cast_ref(),
357 &from_glib_borrow(error),
358 &glib::GString::from_glib_borrow(id),
359 from_glib(extractable_type),
360 )
361 }
362 unsafe {
363 let f: Box_<F> = Box_::new(f);
364 connect_raw(
365 self.as_ptr() as *mut _,
366 c"error-loading-asset".as_ptr() as *const _,
367 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
368 error_loading_asset_trampoline::<Self, F> as *const (),
369 )),
370 Box_::into_raw(f),
371 )
372 }
373 }
374
375 #[doc(alias = "loaded")]
376 fn connect_loaded<F: Fn(&Self, &Timeline) + 'static>(&self, f: F) -> SignalHandlerId {
377 unsafe extern "C" fn loaded_trampoline<P: IsA<Project>, F: Fn(&P, &Timeline) + 'static>(
378 this: *mut ffi::GESProject,
379 timeline: *mut ffi::GESTimeline,
380 f: glib::ffi::gpointer,
381 ) {
382 let f: &F = &*(f as *const F);
383 f(
384 Project::from_glib_borrow(this).unsafe_cast_ref(),
385 &from_glib_borrow(timeline),
386 )
387 }
388 unsafe {
389 let f: Box_<F> = Box_::new(f);
390 connect_raw(
391 self.as_ptr() as *mut _,
392 c"loaded".as_ptr() as *const _,
393 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
394 loaded_trampoline::<Self, F> as *const (),
395 )),
396 Box_::into_raw(f),
397 )
398 }
399 }
400
401 #[cfg(feature = "v1_18")]
402 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
403 #[doc(alias = "loading")]
404 fn connect_loading<F: Fn(&Self, &Timeline) + 'static>(&self, f: F) -> SignalHandlerId {
405 unsafe extern "C" fn loading_trampoline<P: IsA<Project>, F: Fn(&P, &Timeline) + 'static>(
406 this: *mut ffi::GESProject,
407 timeline: *mut ffi::GESTimeline,
408 f: glib::ffi::gpointer,
409 ) {
410 let f: &F = &*(f as *const F);
411 f(
412 Project::from_glib_borrow(this).unsafe_cast_ref(),
413 &from_glib_borrow(timeline),
414 )
415 }
416 unsafe {
417 let f: Box_<F> = Box_::new(f);
418 connect_raw(
419 self.as_ptr() as *mut _,
420 c"loading".as_ptr() as *const _,
421 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
422 loading_trampoline::<Self, F> as *const (),
423 )),
424 Box_::into_raw(f),
425 )
426 }
427 }
428
429 #[doc(alias = "missing-uri")]
430 fn connect_missing_uri<
431 F: Fn(&Self, &glib::Error, &Asset) -> Option<glib::GString> + 'static,
432 >(
433 &self,
434 f: F,
435 ) -> SignalHandlerId {
436 unsafe extern "C" fn missing_uri_trampoline<
437 P: IsA<Project>,
438 F: Fn(&P, &glib::Error, &Asset) -> Option<glib::GString> + 'static,
439 >(
440 this: *mut ffi::GESProject,
441 error: *mut glib::ffi::GError,
442 wrong_asset: *mut ffi::GESAsset,
443 f: glib::ffi::gpointer,
444 ) -> *mut std::ffi::c_char {
445 let f: &F = &*(f as *const F);
446 f(
447 Project::from_glib_borrow(this).unsafe_cast_ref(),
448 &from_glib_borrow(error),
449 &from_glib_borrow(wrong_asset),
450 )
451 .to_glib_full()
452 }
453 unsafe {
454 let f: Box_<F> = Box_::new(f);
455 connect_raw(
456 self.as_ptr() as *mut _,
457 c"missing-uri".as_ptr() as *const _,
458 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
459 missing_uri_trampoline::<Self, F> as *const (),
460 )),
461 Box_::into_raw(f),
462 )
463 }
464 }
465}
466
467impl<O: IsA<Project>> ProjectExt for O {}