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
133unsafe impl Send for Scenario {}
134unsafe impl Sync for Scenario {}
135
136/// Trait containing all [`struct@Scenario`] methods.
137///
138/// # Implementors
139///
140/// [`Scenario`][struct@crate::Scenario]
141pub trait ScenarioExt: IsA<Scenario> + 'static {
142    //#[doc(alias = "gst_validate_scenario_execute_seek")]
143    //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 {
144    //    unsafe { TODO: call ffi:gst_validate_scenario_execute_seek() }
145    //}
146
147    /// Get remaining actions from `self`.
148    ///
149    /// # Returns
150    ///
151    /// A list of [`Action`][crate::Action].
152    #[doc(alias = "gst_validate_scenario_get_actions")]
153    #[doc(alias = "get_actions")]
154    fn actions(&self) -> Vec<Action> {
155        unsafe {
156            FromGlibPtrContainer::from_glib_full(ffi::gst_validate_scenario_get_actions(
157                self.as_ref().to_glib_none().0,
158            ))
159        }
160    }
161
162    ///
163    /// # Returns
164    ///
165    /// The [`gst::Pipeline`][crate::gst::Pipeline] the scenario is running
166    /// against
167    #[doc(alias = "gst_validate_scenario_get_pipeline")]
168    #[doc(alias = "get_pipeline")]
169    fn pipeline(&self) -> Option<gst::Element> {
170        unsafe {
171            from_glib_full(ffi::gst_validate_scenario_get_pipeline(
172                self.as_ref().to_glib_none().0,
173            ))
174        }
175    }
176
177    /// Get current target state from `self`.
178    ///
179    /// # Returns
180    ///
181    /// Current target state.
182    #[doc(alias = "gst_validate_scenario_get_target_state")]
183    #[doc(alias = "get_target_state")]
184    fn target_state(&self) -> gst::State {
185        unsafe {
186            from_glib(ffi::gst_validate_scenario_get_target_state(
187                self.as_ref().to_glib_none().0,
188            ))
189        }
190    }
191
192    #[doc(alias = "execute-on-idle")]
193    fn is_execute_on_idle(&self) -> bool {
194        ObjectExt::property(self.as_ref(), "execute-on-idle")
195    }
196
197    #[doc(alias = "execute-on-idle")]
198    fn set_execute_on_idle(&self, execute_on_idle: bool) {
199        ObjectExt::set_property(self.as_ref(), "execute-on-idle", execute_on_idle)
200    }
201
202    #[doc(alias = "handles-states")]
203    fn is_handles_states(&self) -> bool {
204        ObjectExt::property(self.as_ref(), "handles-states")
205    }
206
207    /// Emitted when an action is done.
208    /// ## `action`
209    /// The [`Action`][crate::Action] that is done running
210    #[doc(alias = "action-done")]
211    fn connect_action_done<F: Fn(&Self, &Action) + Send + Sync + 'static>(
212        &self,
213        f: F,
214    ) -> SignalHandlerId {
215        unsafe extern "C" fn action_done_trampoline<
216            P: IsA<Scenario>,
217            F: Fn(&P, &Action) + Send + Sync + 'static,
218        >(
219            this: *mut ffi::GstValidateScenario,
220            action: *mut ffi::GstValidateAction,
221            f: glib::ffi::gpointer,
222        ) {
223            let f: &F = &*(f as *const F);
224            f(
225                Scenario::from_glib_borrow(this).unsafe_cast_ref(),
226                &from_glib_borrow(action),
227            )
228        }
229        unsafe {
230            let f: Box_<F> = Box_::new(f);
231            connect_raw(
232                self.as_ptr() as *mut _,
233                c"action-done".as_ptr() as *const _,
234                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
235                    action_done_trampoline::<Self, F> as *const (),
236                )),
237                Box_::into_raw(f),
238            )
239        }
240    }
241
242    /// Emitted once all actions have been executed
243    #[doc(alias = "done")]
244    fn connect_done<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
245        unsafe extern "C" fn done_trampoline<
246            P: IsA<Scenario>,
247            F: Fn(&P) + Send + Sync + 'static,
248        >(
249            this: *mut ffi::GstValidateScenario,
250            f: glib::ffi::gpointer,
251        ) {
252            let f: &F = &*(f as *const F);
253            f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
254        }
255        unsafe {
256            let f: Box_<F> = Box_::new(f);
257            connect_raw(
258                self.as_ptr() as *mut _,
259                c"done".as_ptr() as *const _,
260                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
261                    done_trampoline::<Self, F> as *const (),
262                )),
263                Box_::into_raw(f),
264            )
265        }
266    }
267
268    /// Emitted when the 'stop' action is fired
269    #[cfg(feature = "v1_26")]
270    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
271    #[doc(alias = "stopping")]
272    fn connect_stopping<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
273        unsafe extern "C" fn stopping_trampoline<
274            P: IsA<Scenario>,
275            F: Fn(&P) + Send + Sync + 'static,
276        >(
277            this: *mut ffi::GstValidateScenario,
278            f: glib::ffi::gpointer,
279        ) {
280            let f: &F = &*(f as *const F);
281            f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
282        }
283        unsafe {
284            let f: Box_<F> = Box_::new(f);
285            connect_raw(
286                self.as_ptr() as *mut _,
287                c"stopping".as_ptr() as *const _,
288                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
289                    stopping_trampoline::<Self, F> as *const (),
290                )),
291                Box_::into_raw(f),
292            )
293        }
294    }
295
296    #[doc(alias = "execute-on-idle")]
297    fn connect_execute_on_idle_notify<F: Fn(&Self) + Send + Sync + 'static>(
298        &self,
299        f: F,
300    ) -> SignalHandlerId {
301        unsafe extern "C" fn notify_execute_on_idle_trampoline<
302            P: IsA<Scenario>,
303            F: Fn(&P) + Send + Sync + 'static,
304        >(
305            this: *mut ffi::GstValidateScenario,
306            _param_spec: glib::ffi::gpointer,
307            f: glib::ffi::gpointer,
308        ) {
309            let f: &F = &*(f as *const F);
310            f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
311        }
312        unsafe {
313            let f: Box_<F> = Box_::new(f);
314            connect_raw(
315                self.as_ptr() as *mut _,
316                c"notify::execute-on-idle".as_ptr() as *const _,
317                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
318                    notify_execute_on_idle_trampoline::<Self, F> as *const (),
319                )),
320                Box_::into_raw(f),
321            )
322        }
323    }
324
325    #[doc(alias = "handles-states")]
326    fn connect_handles_states_notify<F: Fn(&Self) + Send + Sync + 'static>(
327        &self,
328        f: F,
329    ) -> SignalHandlerId {
330        unsafe extern "C" fn notify_handles_states_trampoline<
331            P: IsA<Scenario>,
332            F: Fn(&P) + Send + Sync + 'static,
333        >(
334            this: *mut ffi::GstValidateScenario,
335            _param_spec: glib::ffi::gpointer,
336            f: glib::ffi::gpointer,
337        ) {
338            let f: &F = &*(f as *const F);
339            f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
340        }
341        unsafe {
342            let f: Box_<F> = Box_::new(f);
343            connect_raw(
344                self.as_ptr() as *mut _,
345                c"notify::handles-states".as_ptr() as *const _,
346                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
347                    notify_handles_states_trampoline::<Self, F> as *const (),
348                )),
349                Box_::into_raw(f),
350            )
351        }
352    }
353}
354
355impl<O: IsA<Scenario>> ScenarioExt for O {}