gstreamer_validate/auto/
scenario.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, Action, Reporter, Runner};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    ///
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `execute-on-idle`
22    ///  Readable | Writeable
23    ///
24    ///
25    /// #### `handles-states`
26    ///  Readable
27    ///
28    ///
29    /// #### `validate-runner`
30    ///  Readable | Writeable | Construct Only
31    /// <details><summary><h4>Object</h4></summary>
32    ///
33    ///
34    /// #### `name`
35    ///  Readable | Writeable | Construct
36    ///
37    ///
38    /// #### `parent`
39    ///  The parent of the object. Please note, that when changing the 'parent'
40    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
41    /// signals due to locking issues. In some cases one can use
42    /// [`element-added`][struct@crate::gst::Bin#element-added] or [`element-removed`][struct@crate::gst::Bin#element-removed] signals on the parent to
43    /// achieve a similar effect.
44    ///
45    /// Readable | Writeable
46    /// </details>
47    /// <details><summary><h4>Reporter</h4></summary>
48    ///
49    ///
50    /// #### `validate-runner`
51    ///  Readable | Writeable | Construct Only
52    /// </details>
53    ///
54    /// ## Signals
55    ///
56    ///
57    /// #### `action-done`
58    ///  Emitted when an action is done.
59    ///
60    ///
61    ///
62    ///
63    /// #### `done`
64    ///  Emitted once all actions have been executed
65    ///
66    ///
67    ///
68    ///
69    /// #### `stopping`
70    ///  Emitted when the 'stop' action is fired
71    ///
72    ///
73    /// <details><summary><h4>Object</h4></summary>
74    ///
75    ///
76    /// #### `deep-notify`
77    ///  The deep notify signal is used to be notified of property changes. It is
78    /// typically attached to the toplevel bin to receive notifications from all
79    /// the elements contained in that bin.
80    ///
81    /// Detailed
82    /// </details>
83    ///
84    /// # Implements
85    ///
86    /// [`ScenarioExt`][trait@crate::prelude::ScenarioExt], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`ReporterExt`][trait@crate::prelude::ReporterExt]
87    #[doc(alias = "GstValidateScenario")]
88    pub struct Scenario(Object<ffi::GstValidateScenario, ffi::GstValidateScenarioClass>) @extends gst::Object, @implements Reporter;
89
90    match fn {
91        type_ => || ffi::gst_validate_scenario_get_type(),
92    }
93}
94
95impl Scenario {
96    pub const NONE: Option<&'static Scenario> = None;
97
98    #[doc(alias = "gst_validate_scenario_deinit")]
99    pub fn deinit() {
100        assert_initialized_main_thread!();
101        unsafe {
102            ffi::gst_validate_scenario_deinit();
103        }
104    }
105
106    /// ## `runner`
107    /// The [`Runner`][crate::Runner] to use to report issues
108    /// ## `pipeline`
109    /// The pipeline to run the scenario on
110    /// ## `scenario_name`
111    /// The name (or path) of the scenario to run
112    ///
113    /// # Returns
114    ///
115    /// A [`Scenario`][crate::Scenario] or NULL
116    #[doc(alias = "gst_validate_scenario_factory_create")]
117    pub fn factory_create(
118        runner: &impl IsA<Runner>,
119        pipeline: &impl IsA<gst::Element>,
120        scenario_name: &str,
121    ) -> Option<Scenario> {
122        skip_assert_initialized!();
123        unsafe {
124            from_glib_full(ffi::gst_validate_scenario_factory_create(
125                runner.as_ref().to_glib_none().0,
126                pipeline.as_ref().to_glib_none().0,
127                scenario_name.to_glib_none().0,
128            ))
129        }
130    }
131}
132
133mod sealed {
134    pub trait Sealed {}
135    impl<T: super::IsA<super::Scenario>> Sealed for T {}
136}
137
138/// Trait containing all [`struct@Scenario`] methods.
139///
140/// # Implementors
141///
142/// [`Scenario`][struct@crate::Scenario]
143pub trait ScenarioExt: IsA<Scenario> + sealed::Sealed + 'static {
144    //#[doc(alias = "gst_validate_scenario_execute_seek")]
145    //fn execute_seek(&self, action: &Action, rate: f64, format: gst::Format, flags: gst::SeekFlags, start_type: gst::SeekType, start: /*Ignored*/gst::ClockTime, stop_type: gst::SeekType, stop: /*Ignored*/gst::ClockTime) -> i32 {
146    //    unsafe { TODO: call ffi:gst_validate_scenario_execute_seek() }
147    //}
148
149    /// Get remaining actions from `self`.
150    ///
151    /// # Returns
152    ///
153    /// A list of [`Action`][crate::Action].
154    #[doc(alias = "gst_validate_scenario_get_actions")]
155    #[doc(alias = "get_actions")]
156    fn actions(&self) -> Vec<Action> {
157        unsafe {
158            FromGlibPtrContainer::from_glib_full(ffi::gst_validate_scenario_get_actions(
159                self.as_ref().to_glib_none().0,
160            ))
161        }
162    }
163
164    ///
165    /// # Returns
166    ///
167    /// The [`gst::Pipeline`][crate::gst::Pipeline] the scenario is running
168    /// against
169    #[doc(alias = "gst_validate_scenario_get_pipeline")]
170    #[doc(alias = "get_pipeline")]
171    fn pipeline(&self) -> Option<gst::Element> {
172        unsafe {
173            from_glib_full(ffi::gst_validate_scenario_get_pipeline(
174                self.as_ref().to_glib_none().0,
175            ))
176        }
177    }
178
179    /// Get current target state from `self`.
180    ///
181    /// # Returns
182    ///
183    /// Current target state.
184    #[doc(alias = "gst_validate_scenario_get_target_state")]
185    #[doc(alias = "get_target_state")]
186    fn target_state(&self) -> gst::State {
187        unsafe {
188            from_glib(ffi::gst_validate_scenario_get_target_state(
189                self.as_ref().to_glib_none().0,
190            ))
191        }
192    }
193
194    #[doc(alias = "execute-on-idle")]
195    fn is_execute_on_idle(&self) -> bool {
196        ObjectExt::property(self.as_ref(), "execute-on-idle")
197    }
198
199    #[doc(alias = "execute-on-idle")]
200    fn set_execute_on_idle(&self, execute_on_idle: bool) {
201        ObjectExt::set_property(self.as_ref(), "execute-on-idle", execute_on_idle)
202    }
203
204    #[doc(alias = "handles-states")]
205    fn is_handles_states(&self) -> bool {
206        ObjectExt::property(self.as_ref(), "handles-states")
207    }
208
209    /// Emitted when an action is done.
210    /// ## `action`
211    /// The [`Action`][crate::Action] that is done running
212    #[doc(alias = "action-done")]
213    fn connect_action_done<F: Fn(&Self, &Action) + 'static>(&self, f: F) -> SignalHandlerId {
214        unsafe extern "C" fn action_done_trampoline<
215            P: IsA<Scenario>,
216            F: Fn(&P, &Action) + 'static,
217        >(
218            this: *mut ffi::GstValidateScenario,
219            action: *mut ffi::GstValidateAction,
220            f: glib::ffi::gpointer,
221        ) {
222            let f: &F = &*(f as *const F);
223            f(
224                Scenario::from_glib_borrow(this).unsafe_cast_ref(),
225                &from_glib_borrow(action),
226            )
227        }
228        unsafe {
229            let f: Box_<F> = Box_::new(f);
230            connect_raw(
231                self.as_ptr() as *mut _,
232                b"action-done\0".as_ptr() as *const _,
233                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
234                    action_done_trampoline::<Self, F> as *const (),
235                )),
236                Box_::into_raw(f),
237            )
238        }
239    }
240
241    /// Emitted once all actions have been executed
242    #[doc(alias = "done")]
243    fn connect_done<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
244        unsafe extern "C" fn done_trampoline<P: IsA<Scenario>, F: Fn(&P) + 'static>(
245            this: *mut ffi::GstValidateScenario,
246            f: glib::ffi::gpointer,
247        ) {
248            let f: &F = &*(f as *const F);
249            f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
250        }
251        unsafe {
252            let f: Box_<F> = Box_::new(f);
253            connect_raw(
254                self.as_ptr() as *mut _,
255                b"done\0".as_ptr() as *const _,
256                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
257                    done_trampoline::<Self, F> as *const (),
258                )),
259                Box_::into_raw(f),
260            )
261        }
262    }
263
264    /// Emitted when the 'stop' action is fired
265    #[cfg(feature = "v1_26")]
266    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
267    #[doc(alias = "stopping")]
268    fn connect_stopping<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
269        unsafe extern "C" fn stopping_trampoline<P: IsA<Scenario>, F: Fn(&P) + 'static>(
270            this: *mut ffi::GstValidateScenario,
271            f: glib::ffi::gpointer,
272        ) {
273            let f: &F = &*(f as *const F);
274            f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
275        }
276        unsafe {
277            let f: Box_<F> = Box_::new(f);
278            connect_raw(
279                self.as_ptr() as *mut _,
280                b"stopping\0".as_ptr() as *const _,
281                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
282                    stopping_trampoline::<Self, F> as *const (),
283                )),
284                Box_::into_raw(f),
285            )
286        }
287    }
288
289    #[doc(alias = "execute-on-idle")]
290    fn connect_execute_on_idle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
291        unsafe extern "C" fn notify_execute_on_idle_trampoline<
292            P: IsA<Scenario>,
293            F: Fn(&P) + 'static,
294        >(
295            this: *mut ffi::GstValidateScenario,
296            _param_spec: glib::ffi::gpointer,
297            f: glib::ffi::gpointer,
298        ) {
299            let f: &F = &*(f as *const F);
300            f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
301        }
302        unsafe {
303            let f: Box_<F> = Box_::new(f);
304            connect_raw(
305                self.as_ptr() as *mut _,
306                b"notify::execute-on-idle\0".as_ptr() as *const _,
307                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
308                    notify_execute_on_idle_trampoline::<Self, F> as *const (),
309                )),
310                Box_::into_raw(f),
311            )
312        }
313    }
314
315    #[doc(alias = "handles-states")]
316    fn connect_handles_states_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
317        unsafe extern "C" fn notify_handles_states_trampoline<
318            P: IsA<Scenario>,
319            F: Fn(&P) + 'static,
320        >(
321            this: *mut ffi::GstValidateScenario,
322            _param_spec: glib::ffi::gpointer,
323            f: glib::ffi::gpointer,
324        ) {
325            let f: &F = &*(f as *const F);
326            f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
327        }
328        unsafe {
329            let f: Box_<F> = Box_::new(f);
330            connect_raw(
331                self.as_ptr() as *mut _,
332                b"notify::handles-states\0".as_ptr() as *const _,
333                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
334                    notify_handles_states_trampoline::<Self, F> as *const (),
335                )),
336                Box_::into_raw(f),
337            )
338        }
339    }
340}
341
342impl<O: IsA<Scenario>> ScenarioExt for O {}