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