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
69mod sealed {
70 pub trait Sealed {}
71 impl<T: super::IsA<super::RTSPThreadPool>> Sealed for T {}
72}
73
74pub trait RTSPThreadPoolExt: IsA<RTSPThreadPool> + sealed::Sealed + 'static {
80 #[doc(alias = "gst_rtsp_thread_pool_get_max_threads")]
87 #[doc(alias = "get_max_threads")]
88 #[doc(alias = "max-threads")]
89 fn max_threads(&self) -> i32 {
90 unsafe { ffi::gst_rtsp_thread_pool_get_max_threads(self.as_ref().to_glib_none().0) }
91 }
92
93 #[doc(alias = "gst_rtsp_thread_pool_get_thread")]
104 #[doc(alias = "get_thread")]
105 fn thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> Option<RTSPThread> {
106 unsafe {
107 from_glib_full(ffi::gst_rtsp_thread_pool_get_thread(
108 self.as_ref().to_glib_none().0,
109 type_.into_glib(),
110 ctx.to_glib_none().0,
111 ))
112 }
113 }
114
115 #[doc(alias = "gst_rtsp_thread_pool_set_max_threads")]
121 #[doc(alias = "max-threads")]
122 fn set_max_threads(&self, max_threads: i32) {
123 unsafe {
124 ffi::gst_rtsp_thread_pool_set_max_threads(self.as_ref().to_glib_none().0, max_threads);
125 }
126 }
127
128 #[doc(alias = "max-threads")]
129 fn connect_max_threads_notify<F: Fn(&Self) + Send + Sync + 'static>(
130 &self,
131 f: F,
132 ) -> SignalHandlerId {
133 unsafe extern "C" fn notify_max_threads_trampoline<
134 P: IsA<RTSPThreadPool>,
135 F: Fn(&P) + Send + Sync + 'static,
136 >(
137 this: *mut ffi::GstRTSPThreadPool,
138 _param_spec: glib::ffi::gpointer,
139 f: glib::ffi::gpointer,
140 ) {
141 let f: &F = &*(f as *const F);
142 f(RTSPThreadPool::from_glib_borrow(this).unsafe_cast_ref())
143 }
144 unsafe {
145 let f: Box_<F> = Box_::new(f);
146 connect_raw(
147 self.as_ptr() as *mut _,
148 b"notify::max-threads\0".as_ptr() as *const _,
149 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
150 notify_max_threads_trampoline::<Self, F> as *const (),
151 )),
152 Box_::into_raw(f),
153 )
154 }
155 }
156}
157
158impl<O: IsA<RTSPThreadPool>> RTSPThreadPoolExt for O {}