Skip to main content

gstreamer/
system_clock.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3#[cfg(feature = "v1_30")]
4use glib::{prelude::*, translate::*};
5
6#[cfg(feature = "v1_30")]
7use crate::{Clock, ffi};
8use crate::{ClockType, SystemClock};
9
10impl SystemClock {
11    #[cfg(feature = "v1_30")]
12    #[doc(alias = "gst_system_clock_new")]
13    pub fn new(name: Option<&str>, clock_type: ClockType) -> SystemClock {
14        assert_initialized_main_thread!();
15        unsafe {
16            Clock::from_glib_full(ffi::gst_system_clock_new(
17                name.to_glib_none().0,
18                clock_type.into_glib(),
19            ))
20            .unsafe_cast()
21        }
22    }
23
24    #[cfg(not(feature = "v1_30"))]
25    #[doc(alias = "gst_system_clock_new")]
26    pub fn new(name: Option<&str>, clock_type: ClockType) -> SystemClock {
27        assert_initialized_main_thread!();
28        glib::Object::builder::<SystemClock>()
29            .property("name", name)
30            .property("clock-type", clock_type)
31            .build()
32    }
33}