gstreamer_check/
test_clock.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::ptr;
4
5use glib::translate::*;
6
7use crate::{ffi, TestClock};
8
9impl TestClock {
10    #[doc(alias = "gst_test_clock_has_id")]
11    pub fn has_id(&self, id: &gst::ClockId) -> bool {
12        unsafe {
13            from_glib(ffi::gst_test_clock_has_id(
14                self.to_glib_none().0,
15                id.to_glib_none().0,
16            ))
17        }
18    }
19
20    #[doc(alias = "gst_test_clock_peek_next_pending_id")]
21    pub fn peek_next_pending_id(&self) -> Option<gst::ClockId> {
22        unsafe {
23            let mut id = ptr::null_mut();
24            let ret: bool = from_glib(ffi::gst_test_clock_peek_next_pending_id(
25                self.to_glib_none().0,
26                &mut id,
27            ));
28            if ret {
29                from_glib_full(id)
30            } else {
31                None
32            }
33        }
34    }
35
36    #[cfg(feature = "v1_18")]
37    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
38    #[doc(alias = "gst_test_clock_process_id")]
39    pub fn process_id(&self, pending_id: &gst::ClockId) -> bool {
40        unsafe {
41            from_glib(ffi::gst_test_clock_process_id(
42                self.to_glib_none().0,
43                pending_id.to_glib_none().0,
44            ))
45        }
46    }
47
48    #[doc(alias = "gst_test_clock_process_id_list")]
49    pub fn process_id_list(&self, pending_list: &[&gst::ClockId]) -> u32 {
50        unsafe {
51            ffi::gst_test_clock_process_id_list(
52                self.to_glib_none().0,
53                pending_list.to_glib_none().0,
54            )
55        }
56    }
57
58    #[doc(alias = "gst_test_clock_process_next_clock_id")]
59    pub fn process_next_clock_id(&self) -> Option<gst::ClockId> {
60        unsafe {
61            from_glib_full(ffi::gst_test_clock_process_next_clock_id(
62                self.to_glib_none().0,
63            ))
64        }
65    }
66
67    #[doc(alias = "gst_test_clock_wait_for_multiple_pending_ids")]
68    pub fn wait_for_multiple_pending_ids(&self, count: u32) -> Vec<gst::ClockId> {
69        unsafe {
70            let mut pending_list = ptr::null_mut();
71            ffi::gst_test_clock_wait_for_multiple_pending_ids(
72                self.to_glib_none().0,
73                count,
74                &mut pending_list,
75            );
76            FromGlibPtrContainer::from_glib_full(pending_list)
77        }
78    }
79
80    #[doc(alias = "gst_test_clock_wait_for_next_pending_id")]
81    pub fn wait_for_next_pending_id(&self) -> gst::ClockId {
82        unsafe {
83            let mut id = ptr::null_mut();
84            ffi::gst_test_clock_wait_for_next_pending_id(self.to_glib_none().0, &mut id);
85            from_glib_full(id)
86        }
87    }
88
89    #[cfg(feature = "v1_16")]
90    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
91    #[doc(alias = "gst_test_clock_timed_wait_for_multiple_pending_ids")]
92    pub fn timed_wait_for_multiple_pending_ids(
93        &self,
94        count: u32,
95        timeout_ms: u32,
96    ) -> (bool, Vec<gst::ClockId>) {
97        unsafe {
98            let mut pending_list = ptr::null_mut();
99            let res = ffi::gst_test_clock_timed_wait_for_multiple_pending_ids(
100                self.to_glib_none().0,
101                count,
102                timeout_ms,
103                &mut pending_list,
104            );
105            (
106                from_glib(res),
107                FromGlibPtrContainer::from_glib_full(pending_list),
108            )
109        }
110    }
111}