1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use glib;
use glib::translate::*;

use gst_rtsp_server_sys;

gst_define_mini_object_wrapper!(
    RTSPThread,
    RTSPThreadRef,
    gst_rtsp_server_sys::GstRTSPThread,
    || gst_rtsp_server_sys::gst_rtsp_thread_get_type()
);

impl RTSPThread {
    /// Create a new thread object that can run a mainloop.
    /// ## `type_`
    /// the thread type
    ///
    /// # Returns
    ///
    /// a `RTSPThread`.
    pub fn new(type_: ::RTSPThreadType) -> Option<Self> {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(gst_rtsp_server_sys::gst_rtsp_thread_new(type_.to_glib())) }
    }
}

impl RTSPThreadRef {
    pub fn reuse(&self) -> bool {
        unsafe {
            from_glib(gst_rtsp_server_sys::gst_rtsp_thread_reuse(
                self.as_mut_ptr(),
            ))
        }
    }

    pub fn stop(&self) {
        unsafe {
            gst_rtsp_server_sys::gst_rtsp_thread_stop(self.as_mut_ptr());
        }
    }

    pub fn type_(&self) -> ::RTSPThreadType {
        unsafe { from_glib((*self.as_ptr()).type_) }
    }

    pub fn context(&self) -> glib::MainContext {
        unsafe { from_glib_none((*self.as_ptr()).context) }
    }

    pub fn loop_(&self) -> glib::MainLoop {
        unsafe { from_glib_none((*self.as_ptr()).loop_) }
    }
}