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::{Bin, ChildProxy, Clock, ClockTime, Element, Object, ffi};
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
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            unsafe {
151                let f: &F = &*(f as *const F);
152                f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
153            }
154        }
155        unsafe {
156            let f: Box_<F> = Box_::new(f);
157            connect_raw(
158                self.as_ptr() as *mut _,
159                c"notify::auto-flush-bus".as_ptr(),
160                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
161                    notify_auto_flush_bus_trampoline::<Self, F> as *const (),
162                )),
163                Box_::into_raw(f),
164            )
165        }
166    }
167
168    #[doc(alias = "delay")]
169    fn connect_delay_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
170        unsafe extern "C" fn notify_delay_trampoline<
171            P: IsA<Pipeline>,
172            F: Fn(&P) + Send + Sync + 'static,
173        >(
174            this: *mut ffi::GstPipeline,
175            _param_spec: glib::ffi::gpointer,
176            f: glib::ffi::gpointer,
177        ) {
178            unsafe {
179                let f: &F = &*(f as *const F);
180                f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
181            }
182        }
183        unsafe {
184            let f: Box_<F> = Box_::new(f);
185            connect_raw(
186                self.as_ptr() as *mut _,
187                c"notify::delay".as_ptr(),
188                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
189                    notify_delay_trampoline::<Self, F> as *const (),
190                )),
191                Box_::into_raw(f),
192            )
193        }
194    }
195
196    #[doc(alias = "latency")]
197    fn connect_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
198        &self,
199        f: F,
200    ) -> SignalHandlerId {
201        unsafe extern "C" fn notify_latency_trampoline<
202            P: IsA<Pipeline>,
203            F: Fn(&P) + Send + Sync + 'static,
204        >(
205            this: *mut ffi::GstPipeline,
206            _param_spec: glib::ffi::gpointer,
207            f: glib::ffi::gpointer,
208        ) {
209            unsafe {
210                let f: &F = &*(f as *const F);
211                f(Pipeline::from_glib_borrow(this).unsafe_cast_ref())
212            }
213        }
214        unsafe {
215            let f: Box_<F> = Box_::new(f);
216            connect_raw(
217                self.as_ptr() as *mut _,
218                c"notify::latency".as_ptr(),
219                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
220                    notify_latency_trampoline::<Self, F> as *const (),
221                )),
222                Box_::into_raw(f),
223            )
224        }
225    }
226}
227
228impl<O: IsA<Pipeline>> PipelineExt for O {}