gstreamer_editing_services/auto/
pipeline.rs1use crate::{ffi, PipelineFlags, Timeline};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GESPipeline")]
16 pub struct Pipeline(Object<ffi::GESPipeline, ffi::GESPipelineClass>) @extends gst::Pipeline, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy;
17
18 match fn {
19 type_ => || ffi::ges_pipeline_get_type(),
20 }
21}
22
23impl Pipeline {
24 pub const NONE: Option<&'static Pipeline> = None;
25
26 #[doc(alias = "ges_pipeline_new")]
27 pub fn new() -> Pipeline {
28 assert_initialized_main_thread!();
29 unsafe { from_glib_none(ffi::ges_pipeline_new()) }
30 }
31}
32
33impl Default for Pipeline {
34 fn default() -> Self {
35 Self::new()
36 }
37}
38
39mod sealed {
40 pub trait Sealed {}
41 impl<T: super::IsA<super::Pipeline>> Sealed for T {}
42}
43
44pub trait GESPipelineExt: IsA<Pipeline> + sealed::Sealed + 'static {
45 #[doc(alias = "ges_pipeline_get_mode")]
46 #[doc(alias = "get_mode")]
47 fn mode(&self) -> PipelineFlags {
48 unsafe { from_glib(ffi::ges_pipeline_get_mode(self.as_ref().to_glib_none().0)) }
49 }
50
51 #[doc(alias = "ges_pipeline_get_thumbnail")]
52 #[doc(alias = "get_thumbnail")]
53 fn thumbnail(&self, caps: &gst::Caps) -> Option<gst::Sample> {
54 unsafe {
55 from_glib_full(ffi::ges_pipeline_get_thumbnail(
56 self.as_ref().to_glib_none().0,
57 caps.to_glib_none().0,
58 ))
59 }
60 }
61
62 #[doc(alias = "ges_pipeline_get_thumbnail_rgb24")]
63 #[doc(alias = "get_thumbnail_rgb24")]
64 fn thumbnail_rgb24(&self, width: i32, height: i32) -> Option<gst::Sample> {
65 unsafe {
66 from_glib_full(ffi::ges_pipeline_get_thumbnail_rgb24(
67 self.as_ref().to_glib_none().0,
68 width,
69 height,
70 ))
71 }
72 }
73
74 #[doc(alias = "ges_pipeline_preview_get_audio_sink")]
75 fn preview_get_audio_sink(&self) -> Option<gst::Element> {
76 unsafe {
77 from_glib_full(ffi::ges_pipeline_preview_get_audio_sink(
78 self.as_ref().to_glib_none().0,
79 ))
80 }
81 }
82
83 #[doc(alias = "ges_pipeline_preview_get_video_sink")]
84 fn preview_get_video_sink(&self) -> Option<gst::Element> {
85 unsafe {
86 from_glib_full(ffi::ges_pipeline_preview_get_video_sink(
87 self.as_ref().to_glib_none().0,
88 ))
89 }
90 }
91
92 #[doc(alias = "ges_pipeline_preview_set_audio_sink")]
93 fn preview_set_audio_sink(&self, sink: Option<&impl IsA<gst::Element>>) {
94 unsafe {
95 ffi::ges_pipeline_preview_set_audio_sink(
96 self.as_ref().to_glib_none().0,
97 sink.map(|p| p.as_ref()).to_glib_none().0,
98 );
99 }
100 }
101
102 #[doc(alias = "ges_pipeline_preview_set_video_sink")]
103 fn preview_set_video_sink(&self, sink: Option<&impl IsA<gst::Element>>) {
104 unsafe {
105 ffi::ges_pipeline_preview_set_video_sink(
106 self.as_ref().to_glib_none().0,
107 sink.map(|p| p.as_ref()).to_glib_none().0,
108 );
109 }
110 }
111
112 #[doc(alias = "ges_pipeline_save_thumbnail")]
113 fn save_thumbnail(
114 &self,
115 width: i32,
116 height: i32,
117 format: &str,
118 location: &str,
119 ) -> Result<(), glib::Error> {
120 unsafe {
121 let mut error = std::ptr::null_mut();
122 let is_ok = ffi::ges_pipeline_save_thumbnail(
123 self.as_ref().to_glib_none().0,
124 width,
125 height,
126 format.to_glib_none().0,
127 location.to_glib_none().0,
128 &mut error,
129 );
130 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
131 if error.is_null() {
132 Ok(())
133 } else {
134 Err(from_glib_full(error))
135 }
136 }
137 }
138
139 #[doc(alias = "ges_pipeline_set_mode")]
140 #[doc(alias = "mode")]
141 fn set_mode(&self, mode: PipelineFlags) -> Result<(), glib::error::BoolError> {
142 unsafe {
143 glib::result_from_gboolean!(
144 ffi::ges_pipeline_set_mode(self.as_ref().to_glib_none().0, mode.into_glib()),
145 "Failed to set mode"
146 )
147 }
148 }
149
150 #[doc(alias = "ges_pipeline_set_render_settings")]
151 fn set_render_settings(
152 &self,
153 output_uri: &str,
154 profile: &impl IsA<gst_pbutils::EncodingProfile>,
155 ) -> Result<(), glib::error::BoolError> {
156 unsafe {
157 glib::result_from_gboolean!(
158 ffi::ges_pipeline_set_render_settings(
159 self.as_ref().to_glib_none().0,
160 output_uri.to_glib_none().0,
161 profile.as_ref().to_glib_none().0
162 ),
163 "Failed to set render settings"
164 )
165 }
166 }
167
168 #[doc(alias = "ges_pipeline_set_timeline")]
169 #[doc(alias = "timeline")]
170 fn set_timeline(&self, timeline: &impl IsA<Timeline>) -> Result<(), glib::error::BoolError> {
171 unsafe {
172 glib::result_from_gboolean!(
173 ffi::ges_pipeline_set_timeline(
174 self.as_ref().to_glib_none().0,
175 timeline.as_ref().to_glib_none().0
176 ),
177 "Failed to set timeline"
178 )
179 }
180 }
181
182 #[doc(alias = "audio-filter")]
183 fn audio_filter(&self) -> Option<gst::Element> {
184 ObjectExt::property(self.as_ref(), "audio-filter")
185 }
186
187 #[doc(alias = "audio-filter")]
188 fn set_audio_filter<P: IsA<gst::Element>>(&self, audio_filter: Option<&P>) {
189 ObjectExt::set_property(self.as_ref(), "audio-filter", audio_filter)
190 }
191
192 #[doc(alias = "audio-sink")]
193 fn audio_sink(&self) -> Option<gst::Element> {
194 ObjectExt::property(self.as_ref(), "audio-sink")
195 }
196
197 #[doc(alias = "audio-sink")]
198 fn set_audio_sink<P: IsA<gst::Element>>(&self, audio_sink: Option<&P>) {
199 ObjectExt::set_property(self.as_ref(), "audio-sink", audio_sink)
200 }
201
202 fn timeline(&self) -> Option<Timeline> {
203 ObjectExt::property(self.as_ref(), "timeline")
204 }
205
206 #[doc(alias = "video-filter")]
207 fn video_filter(&self) -> Option<gst::Element> {
208 ObjectExt::property(self.as_ref(), "video-filter")
209 }
210
211 #[doc(alias = "video-filter")]
212 fn set_video_filter<P: IsA<gst::Element>>(&self, video_filter: Option<&P>) {
213 ObjectExt::set_property(self.as_ref(), "video-filter", video_filter)
214 }
215
216 #[doc(alias = "video-sink")]
217 fn video_sink(&self) -> Option<gst::Element> {
218 ObjectExt::property(self.as_ref(), "video-sink")
219 }
220
221 #[doc(alias = "video-sink")]
222 fn set_video_sink<P: IsA<gst::Element>>(&self, video_sink: Option<&P>) {
223 ObjectExt::set_property(self.as_ref(), "video-sink", video_sink)
224 }
225
226 #[doc(alias = "audio-filter")]
227 fn connect_audio_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
228 unsafe extern "C" fn notify_audio_filter_trampoline<
229 P: IsA<Pipeline>,
230 F: Fn(&P) + 'static,
231 >(
232 this: *mut ffi::GESPipeline,
233 _param_spec: glib::ffi::gpointer,
234 f: glib::ffi::gpointer,
235 ) {
236 let f: &F = &*(f as *const F);
237 f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
238 }
239 unsafe {
240 let f: Box_<F> = Box_::new(f);
241 connect_raw(
242 self.as_ptr() as *mut _,
243 b"notify::audio-filter\0".as_ptr() as *const _,
244 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
245 notify_audio_filter_trampoline::<Self, F> as *const (),
246 )),
247 Box_::into_raw(f),
248 )
249 }
250 }
251
252 #[doc(alias = "audio-sink")]
253 fn connect_audio_sink_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
254 unsafe extern "C" fn notify_audio_sink_trampoline<P: IsA<Pipeline>, F: Fn(&P) + 'static>(
255 this: *mut ffi::GESPipeline,
256 _param_spec: glib::ffi::gpointer,
257 f: glib::ffi::gpointer,
258 ) {
259 let f: &F = &*(f as *const F);
260 f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
261 }
262 unsafe {
263 let f: Box_<F> = Box_::new(f);
264 connect_raw(
265 self.as_ptr() as *mut _,
266 b"notify::audio-sink\0".as_ptr() as *const _,
267 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
268 notify_audio_sink_trampoline::<Self, F> as *const (),
269 )),
270 Box_::into_raw(f),
271 )
272 }
273 }
274
275 #[doc(alias = "mode")]
276 fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
277 unsafe extern "C" fn notify_mode_trampoline<P: IsA<Pipeline>, F: Fn(&P) + 'static>(
278 this: *mut ffi::GESPipeline,
279 _param_spec: glib::ffi::gpointer,
280 f: glib::ffi::gpointer,
281 ) {
282 let f: &F = &*(f as *const F);
283 f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
284 }
285 unsafe {
286 let f: Box_<F> = Box_::new(f);
287 connect_raw(
288 self.as_ptr() as *mut _,
289 b"notify::mode\0".as_ptr() as *const _,
290 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
291 notify_mode_trampoline::<Self, F> as *const (),
292 )),
293 Box_::into_raw(f),
294 )
295 }
296 }
297
298 #[doc(alias = "timeline")]
299 fn connect_timeline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
300 unsafe extern "C" fn notify_timeline_trampoline<P: IsA<Pipeline>, F: Fn(&P) + 'static>(
301 this: *mut ffi::GESPipeline,
302 _param_spec: glib::ffi::gpointer,
303 f: glib::ffi::gpointer,
304 ) {
305 let f: &F = &*(f as *const F);
306 f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
307 }
308 unsafe {
309 let f: Box_<F> = Box_::new(f);
310 connect_raw(
311 self.as_ptr() as *mut _,
312 b"notify::timeline\0".as_ptr() as *const _,
313 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
314 notify_timeline_trampoline::<Self, F> as *const (),
315 )),
316 Box_::into_raw(f),
317 )
318 }
319 }
320
321 #[doc(alias = "video-filter")]
322 fn connect_video_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
323 unsafe extern "C" fn notify_video_filter_trampoline<
324 P: IsA<Pipeline>,
325 F: Fn(&P) + 'static,
326 >(
327 this: *mut ffi::GESPipeline,
328 _param_spec: glib::ffi::gpointer,
329 f: glib::ffi::gpointer,
330 ) {
331 let f: &F = &*(f as *const F);
332 f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
333 }
334 unsafe {
335 let f: Box_<F> = Box_::new(f);
336 connect_raw(
337 self.as_ptr() as *mut _,
338 b"notify::video-filter\0".as_ptr() as *const _,
339 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
340 notify_video_filter_trampoline::<Self, F> as *const (),
341 )),
342 Box_::into_raw(f),
343 )
344 }
345 }
346
347 #[doc(alias = "video-sink")]
348 fn connect_video_sink_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
349 unsafe extern "C" fn notify_video_sink_trampoline<P: IsA<Pipeline>, F: Fn(&P) + 'static>(
350 this: *mut ffi::GESPipeline,
351 _param_spec: glib::ffi::gpointer,
352 f: glib::ffi::gpointer,
353 ) {
354 let f: &F = &*(f as *const F);
355 f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
356 }
357 unsafe {
358 let f: Box_<F> = Box_::new(f);
359 connect_raw(
360 self.as_ptr() as *mut _,
361 b"notify::video-sink\0".as_ptr() as *const _,
362 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
363 notify_video_sink_trampoline::<Self, F> as *const (),
364 )),
365 Box_::into_raw(f),
366 )
367 }
368 }
369}
370
371impl<O: IsA<Pipeline>> GESPipelineExt for O {}