Skip to main content

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::{Action, Reporter, Runner, ffi};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
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            unsafe {
224                let f: &F = &*(f as *const F);
225                f(
226                    Scenario::from_glib_borrow(this).unsafe_cast_ref(),
227                    &from_glib_borrow(action),
228                )
229            }
230        }
231        unsafe {
232            let f: Box_<F> = Box_::new(f);
233            connect_raw(
234                self.as_ptr() as *mut _,
235                c"action-done".as_ptr(),
236                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
237                    action_done_trampoline::<Self, F> as *const (),
238                )),
239                Box_::into_raw(f),
240            )
241        }
242    }
243
244    /// Emitted once all actions have been executed
245    #[doc(alias = "done")]
246    fn connect_done<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
247        unsafe extern "C" fn done_trampoline<
248            P: IsA<Scenario>,
249            F: Fn(&P) + Send + Sync + 'static,
250        >(
251            this: *mut ffi::GstValidateScenario,
252            f: glib::ffi::gpointer,
253        ) {
254            unsafe {
255                let f: &F = &*(f as *const F);
256                f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
257            }
258        }
259        unsafe {
260            let f: Box_<F> = Box_::new(f);
261            connect_raw(
262                self.as_ptr() as *mut _,
263                c"done".as_ptr(),
264                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
265                    done_trampoline::<Self, F> as *const (),
266                )),
267                Box_::into_raw(f),
268            )
269        }
270    }
271
272    /// Emitted when the 'stop' action is fired
273    #[cfg(feature = "v1_26")]
274    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
275    #[doc(alias = "stopping")]
276    fn connect_stopping<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
277        unsafe extern "C" fn stopping_trampoline<
278            P: IsA<Scenario>,
279            F: Fn(&P) + Send + Sync + 'static,
280        >(
281            this: *mut ffi::GstValidateScenario,
282            f: glib::ffi::gpointer,
283        ) {
284            unsafe {
285                let f: &F = &*(f as *const F);
286                f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
287            }
288        }
289        unsafe {
290            let f: Box_<F> = Box_::new(f);
291            connect_raw(
292                self.as_ptr() as *mut _,
293                c"stopping".as_ptr(),
294                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
295                    stopping_trampoline::<Self, F> as *const (),
296                )),
297                Box_::into_raw(f),
298            )
299        }
300    }
301
302    #[doc(alias = "execute-on-idle")]
303    fn connect_execute_on_idle_notify<F: Fn(&Self) + Send + Sync + 'static>(
304        &self,
305        f: F,
306    ) -> SignalHandlerId {
307        unsafe extern "C" fn notify_execute_on_idle_trampoline<
308            P: IsA<Scenario>,
309            F: Fn(&P) + Send + Sync + 'static,
310        >(
311            this: *mut ffi::GstValidateScenario,
312            _param_spec: glib::ffi::gpointer,
313            f: glib::ffi::gpointer,
314        ) {
315            unsafe {
316                let f: &F = &*(f as *const F);
317                f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
318            }
319        }
320        unsafe {
321            let f: Box_<F> = Box_::new(f);
322            connect_raw(
323                self.as_ptr() as *mut _,
324                c"notify::execute-on-idle".as_ptr(),
325                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
326                    notify_execute_on_idle_trampoline::<Self, F> as *const (),
327                )),
328                Box_::into_raw(f),
329            )
330        }
331    }
332
333    #[doc(alias = "handles-states")]
334    fn connect_handles_states_notify<F: Fn(&Self) + Send + Sync + 'static>(
335        &self,
336        f: F,
337    ) -> SignalHandlerId {
338        unsafe extern "C" fn notify_handles_states_trampoline<
339            P: IsA<Scenario>,
340            F: Fn(&P) + Send + Sync + 'static,
341        >(
342            this: *mut ffi::GstValidateScenario,
343            _param_spec: glib::ffi::gpointer,
344            f: glib::ffi::gpointer,
345        ) {
346            unsafe {
347                let f: &F = &*(f as *const F);
348                f(Scenario::from_glib_borrow(this).unsafe_cast_ref())
349            }
350        }
351        unsafe {
352            let f: Box_<F> = Box_::new(f);
353            connect_raw(
354                self.as_ptr() as *mut _,
355                c"notify::handles-states".as_ptr(),
356                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
357                    notify_handles_states_trampoline::<Self, F> as *const (),
358                )),
359                Box_::into_raw(f),
360            )
361        }
362    }
363}
364
365impl<O: IsA<Scenario>> ScenarioExt for O {}