gstreamer_rtsp_server/auto/
rtsp_thread_pool.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::{ffi, RTSPContext, RTSPThread, RTSPThreadType};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GstRTSPThreadPool")]
16    pub struct RTSPThreadPool(Object<ffi::GstRTSPThreadPool, ffi::GstRTSPThreadPoolClass>);
17
18    match fn {
19        type_ => || ffi::gst_rtsp_thread_pool_get_type(),
20    }
21}
22
23impl RTSPThreadPool {
24    pub const NONE: Option<&'static RTSPThreadPool> = None;
25
26    #[doc(alias = "gst_rtsp_thread_pool_new")]
27    pub fn new() -> RTSPThreadPool {
28        assert_initialized_main_thread!();
29        unsafe { from_glib_full(ffi::gst_rtsp_thread_pool_new()) }
30    }
31
32    #[doc(alias = "gst_rtsp_thread_pool_cleanup")]
33    pub fn cleanup() {
34        assert_initialized_main_thread!();
35        unsafe {
36            ffi::gst_rtsp_thread_pool_cleanup();
37        }
38    }
39}
40
41impl Default for RTSPThreadPool {
42    fn default() -> Self {
43        Self::new()
44    }
45}
46
47unsafe impl Send for RTSPThreadPool {}
48unsafe impl Sync for RTSPThreadPool {}
49
50pub trait RTSPThreadPoolExt: IsA<RTSPThreadPool> + 'static {
51    #[doc(alias = "gst_rtsp_thread_pool_get_max_threads")]
52    #[doc(alias = "get_max_threads")]
53    #[doc(alias = "max-threads")]
54    fn max_threads(&self) -> i32 {
55        unsafe { ffi::gst_rtsp_thread_pool_get_max_threads(self.as_ref().to_glib_none().0) }
56    }
57
58    #[doc(alias = "gst_rtsp_thread_pool_get_thread")]
59    #[doc(alias = "get_thread")]
60    fn thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> Option<RTSPThread> {
61        unsafe {
62            from_glib_full(ffi::gst_rtsp_thread_pool_get_thread(
63                self.as_ref().to_glib_none().0,
64                type_.into_glib(),
65                ctx.to_glib_none().0,
66            ))
67        }
68    }
69
70    #[doc(alias = "gst_rtsp_thread_pool_set_max_threads")]
71    #[doc(alias = "max-threads")]
72    fn set_max_threads(&self, max_threads: i32) {
73        unsafe {
74            ffi::gst_rtsp_thread_pool_set_max_threads(self.as_ref().to_glib_none().0, max_threads);
75        }
76    }
77
78    #[doc(alias = "max-threads")]
79    fn connect_max_threads_notify<F: Fn(&Self) + Send + Sync + 'static>(
80        &self,
81        f: F,
82    ) -> SignalHandlerId {
83        unsafe extern "C" fn notify_max_threads_trampoline<
84            P: IsA<RTSPThreadPool>,
85            F: Fn(&P) + Send + Sync + 'static,
86        >(
87            this: *mut ffi::GstRTSPThreadPool,
88            _param_spec: glib::ffi::gpointer,
89            f: glib::ffi::gpointer,
90        ) {
91            let f: &F = &*(f as *const F);
92            f(RTSPThreadPool::from_glib_borrow(this).unsafe_cast_ref())
93        }
94        unsafe {
95            let f: Box_<F> = Box_::new(f);
96            connect_raw(
97                self.as_ptr() as *mut _,
98                c"notify::max-threads".as_ptr() as *const _,
99                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
100                    notify_max_threads_trampoline::<Self, F> as *const (),
101                )),
102                Box_::into_raw(f),
103            )
104        }
105    }
106}
107
108impl<O: IsA<RTSPThreadPool>> RTSPThreadPoolExt for O {}