gstreamer_rtsp_server/auto/
rtsp_thread_pool.rs
1use 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")]
27 pub struct RTSPThreadPool(Object<ffi::GstRTSPThreadPool, ffi::GstRTSPThreadPoolClass>);
28
29 match fn {
30 type_ => || ffi::gst_rtsp_thread_pool_get_type(),
31 }
32}
33
34impl RTSPThreadPool {
35 pub const NONE: Option<&'static RTSPThreadPool> = None;
36
37 #[doc(alias = "gst_rtsp_thread_pool_new")]
43 pub fn new() -> RTSPThreadPool {
44 assert_initialized_main_thread!();
45 unsafe { from_glib_full(ffi::gst_rtsp_thread_pool_new()) }
46 }
47
48 #[doc(alias = "gst_rtsp_thread_pool_cleanup")]
52 pub fn cleanup() {
53 assert_initialized_main_thread!();
54 unsafe {
55 ffi::gst_rtsp_thread_pool_cleanup();
56 }
57 }
58}
59
60impl Default for RTSPThreadPool {
61 fn default() -> Self {
62 Self::new()
63 }
64}
65
66unsafe impl Send for RTSPThreadPool {}
67unsafe impl Sync for RTSPThreadPool {}
68
69pub trait RTSPThreadPoolExt: IsA<RTSPThreadPool> + 'static {
75 #[doc(alias = "gst_rtsp_thread_pool_get_max_threads")]
82 #[doc(alias = "get_max_threads")]
83 #[doc(alias = "max-threads")]
84 fn max_threads(&self) -> i32 {
85 unsafe { ffi::gst_rtsp_thread_pool_get_max_threads(self.as_ref().to_glib_none().0) }
86 }
87
88 #[doc(alias = "gst_rtsp_thread_pool_get_thread")]
99 #[doc(alias = "get_thread")]
100 fn thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> Option<RTSPThread> {
101 unsafe {
102 from_glib_full(ffi::gst_rtsp_thread_pool_get_thread(
103 self.as_ref().to_glib_none().0,
104 type_.into_glib(),
105 ctx.to_glib_none().0,
106 ))
107 }
108 }
109
110 #[doc(alias = "gst_rtsp_thread_pool_set_max_threads")]
116 #[doc(alias = "max-threads")]
117 fn set_max_threads(&self, max_threads: i32) {
118 unsafe {
119 ffi::gst_rtsp_thread_pool_set_max_threads(self.as_ref().to_glib_none().0, max_threads);
120 }
121 }
122
123 #[doc(alias = "max-threads")]
124 fn connect_max_threads_notify<F: Fn(&Self) + Send + Sync + 'static>(
125 &self,
126 f: F,
127 ) -> SignalHandlerId {
128 unsafe extern "C" fn notify_max_threads_trampoline<
129 P: IsA<RTSPThreadPool>,
130 F: Fn(&P) + Send + Sync + 'static,
131 >(
132 this: *mut ffi::GstRTSPThreadPool,
133 _param_spec: glib::ffi::gpointer,
134 f: glib::ffi::gpointer,
135 ) {
136 let f: &F = &*(f as *const F);
137 f(RTSPThreadPool::from_glib_borrow(this).unsafe_cast_ref())
138 }
139 unsafe {
140 let f: Box_<F> = Box_::new(f);
141 connect_raw(
142 self.as_ptr() as *mut _,
143 c"notify::max-threads".as_ptr() as *const _,
144 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
145 notify_max_threads_trampoline::<Self, F> as *const (),
146 )),
147 Box_::into_raw(f),
148 )
149 }
150 }
151}
152
153impl<O: IsA<RTSPThreadPool>> RTSPThreadPoolExt for O {}