gstreamer/auto/
pipeline.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
6use crate::{ffi, Bin, ChildProxy, Clock, ClockTime, Element, Object};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GstPipeline")]
16    pub struct Pipeline(Object<ffi::GstPipeline, ffi::GstPipelineClass>) @extends Bin, Element, Object, @implements ChildProxy;
17
18    match fn {
19        type_ => || ffi::gst_pipeline_get_type(),
20    }
21}
22
23impl Pipeline {
24    pub const NONE: Option<&'static Pipeline> = None;
25}
26
27unsafe impl Send for Pipeline {}
28unsafe impl Sync for Pipeline {}
29
30pub trait PipelineExt: IsA<Pipeline> + 'static {
31    #[doc(alias = "gst_pipeline_auto_clock")]
32    fn auto_clock(&self) {
33        unsafe {
34            ffi::gst_pipeline_auto_clock(self.as_ref().to_glib_none().0);
35        }
36    }
37
38    #[doc(alias = "gst_pipeline_get_auto_flush_bus")]
39    #[doc(alias = "get_auto_flush_bus")]
40    #[doc(alias = "auto-flush-bus")]
41    fn is_auto_flush_bus(&self) -> bool {
42        unsafe {
43            from_glib(ffi::gst_pipeline_get_auto_flush_bus(
44                self.as_ref().to_glib_none().0,
45            ))
46        }
47    }
48
49    #[cfg(feature = "v1_24")]
50    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
51    #[doc(alias = "gst_pipeline_get_configured_latency")]
52    #[doc(alias = "get_configured_latency")]
53    fn configured_latency(&self) -> Option<ClockTime> {
54        unsafe {
55            from_glib(ffi::gst_pipeline_get_configured_latency(
56                self.as_ref().to_glib_none().0,
57            ))
58        }
59    }
60
61    #[doc(alias = "gst_pipeline_get_delay")]
62    #[doc(alias = "get_delay")]
63    fn delay(&self) -> ClockTime {
64        unsafe {
65            try_from_glib(ffi::gst_pipeline_get_delay(self.as_ref().to_glib_none().0))
66                .expect("mandatory glib value is None")
67        }
68    }
69
70    #[doc(alias = "gst_pipeline_get_latency")]
71    #[doc(alias = "get_latency")]
72    fn latency(&self) -> Option<ClockTime> {
73        unsafe {
74            from_glib(ffi::gst_pipeline_get_latency(
75                self.as_ref().to_glib_none().0,
76            ))
77        }
78    }
79
80    #[doc(alias = "gst_pipeline_get_pipeline_clock")]
81    #[doc(alias = "get_pipeline_clock")]
82    fn pipeline_clock(&self) -> Clock {
83        unsafe {
84            from_glib_full(ffi::gst_pipeline_get_pipeline_clock(
85                self.as_ref().to_glib_none().0,
86            ))
87        }
88    }
89
90    #[cfg(feature = "v1_24")]
91    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
92    #[doc(alias = "gst_pipeline_is_live")]
93    fn is_live(&self) -> bool {
94        unsafe { from_glib(ffi::gst_pipeline_is_live(self.as_ref().to_glib_none().0)) }
95    }
96
97    #[doc(alias = "gst_pipeline_set_auto_flush_bus")]
98    #[doc(alias = "auto-flush-bus")]
99    fn set_auto_flush_bus(&self, auto_flush: bool) {
100        unsafe {
101            ffi::gst_pipeline_set_auto_flush_bus(
102                self.as_ref().to_glib_none().0,
103                auto_flush.into_glib(),
104            );
105        }
106    }
107
108    #[doc(alias = "gst_pipeline_set_delay")]
109    #[doc(alias = "delay")]
110    fn set_delay(&self, delay: ClockTime) {
111        unsafe {
112            ffi::gst_pipeline_set_delay(self.as_ref().to_glib_none().0, delay.into_glib());
113        }
114    }
115
116    #[doc(alias = "gst_pipeline_set_latency")]
117    #[doc(alias = "latency")]
118    fn set_latency(&self, latency: impl Into<Option<ClockTime>>) {
119        unsafe {
120            ffi::gst_pipeline_set_latency(
121                self.as_ref().to_glib_none().0,
122                latency.into().into_glib(),
123            );
124        }
125    }
126
127    #[doc(alias = "gst_pipeline_use_clock")]
128    fn use_clock(&self, clock: Option<&impl IsA<Clock>>) {
129        unsafe {
130            ffi::gst_pipeline_use_clock(
131                self.as_ref().to_glib_none().0,
132                clock.map(|p| p.as_ref()).to_glib_none().0,
133            );
134        }
135    }
136
137    #[doc(alias = "auto-flush-bus")]
138    fn connect_auto_flush_bus_notify<F: Fn(&Self) + Send + Sync + 'static>(
139        &self,
140        f: F,
141    ) -> SignalHandlerId {
142        unsafe extern "C" fn notify_auto_flush_bus_trampoline<
143            P: IsA<Pipeline>,
144            F: Fn(&P) + Send + Sync + 'static,
145        >(
146            this: *mut ffi::GstPipeline,
147            _param_spec: glib::ffi::gpointer,
148            f: glib::ffi::gpointer,
149        ) {
150            let f: &F = &*(f as *const F);
151            f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
152        }
153        unsafe {
154            let f: Box_<F> = Box_::new(f);
155            connect_raw(
156                self.as_ptr() as *mut _,
157                c"notify::auto-flush-bus".as_ptr() as *const _,
158                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
159                    notify_auto_flush_bus_trampoline::<Self, F> as *const (),
160                )),
161                Box_::into_raw(f),
162            )
163        }
164    }
165
166    #[doc(alias = "delay")]
167    fn connect_delay_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
168        unsafe extern "C" fn notify_delay_trampoline<
169            P: IsA<Pipeline>,
170            F: Fn(&P) + Send + Sync + 'static,
171        >(
172            this: *mut ffi::GstPipeline,
173            _param_spec: glib::ffi::gpointer,
174            f: glib::ffi::gpointer,
175        ) {
176            let f: &F = &*(f as *const F);
177            f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
178        }
179        unsafe {
180            let f: Box_<F> = Box_::new(f);
181            connect_raw(
182                self.as_ptr() as *mut _,
183                c"notify::delay".as_ptr() as *const _,
184                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
185                    notify_delay_trampoline::<Self, F> as *const (),
186                )),
187                Box_::into_raw(f),
188            )
189        }
190    }
191
192    #[doc(alias = "latency")]
193    fn connect_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
194        &self,
195        f: F,
196    ) -> SignalHandlerId {
197        unsafe extern "C" fn notify_latency_trampoline<
198            P: IsA<Pipeline>,
199            F: Fn(&P) + Send + Sync + 'static,
200        >(
201            this: *mut ffi::GstPipeline,
202            _param_spec: glib::ffi::gpointer,
203            f: glib::ffi::gpointer,
204        ) {
205            let f: &F = &*(f as *const F);
206            f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
207        }
208        unsafe {
209            let f: Box_<F> = Box_::new(f);
210            connect_raw(
211                self.as_ptr() as *mut _,
212                c"notify::latency".as_ptr() as *const _,
213                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
214                    notify_latency_trampoline::<Self, F> as *const (),
215                )),
216                Box_::into_raw(f),
217            )
218        }
219    }
220}
221
222impl<O: IsA<Pipeline>> PipelineExt for O {}