gstreamer_rtsp_server/
rtsp_thread.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::ffi;
4use glib::translate::*;
5
6gst::mini_object_wrapper!(RTSPThread, RTSPThreadRef, ffi::GstRTSPThread, || {
7    ffi::gst_rtsp_thread_get_type()
8});
9
10impl RTSPThread {
11    /// Create a new thread object that can run a mainloop.
12    /// ## `type_`
13    /// the thread type
14    ///
15    /// # Returns
16    ///
17    /// a [`RTSPThread`][crate::RTSPThread].
18    #[doc(alias = "gst_rtsp_thread_new")]
19    pub fn new(type_: crate::RTSPThreadType) -> Option<Self> {
20        assert_initialized_main_thread!();
21        unsafe { from_glib_full(ffi::gst_rtsp_thread_new(type_.into_glib())) }
22    }
23}
24
25impl RTSPThreadRef {
26    #[doc(alias = "gst_rtsp_thread_reuse")]
27    pub fn reuse(&self) -> bool {
28        unsafe { from_glib(ffi::gst_rtsp_thread_reuse(self.as_mut_ptr())) }
29    }
30
31    #[doc(alias = "gst_rtsp_thread_stop")]
32    pub fn stop(&self) {
33        unsafe {
34            ffi::gst_rtsp_thread_stop(self.as_mut_ptr());
35        }
36    }
37
38    pub fn type_(&self) -> crate::RTSPThreadType {
39        unsafe { from_glib((*self.as_ptr()).type_) }
40    }
41
42    pub fn context(&self) -> glib::MainContext {
43        unsafe { from_glib_none((*self.as_ptr()).context) }
44    }
45
46    pub fn loop_(&self) -> glib::MainLoop {
47        unsafe { from_glib_none((*self.as_ptr()).loop_) }
48    }
49}