gstreamer_rtsp_server/auto/
rtsp_session.rs1use crate::{RTSPFilterResult, RTSPMedia, RTSPSessionMedia, ffi};
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GstRTSPSession")]
16 pub struct RTSPSession(Object<ffi::GstRTSPSession, ffi::GstRTSPSessionClass>);
17
18 match fn {
19 type_ => || ffi::gst_rtsp_session_get_type(),
20 }
21}
22
23impl RTSPSession {
24 pub const NONE: Option<&'static RTSPSession> = None;
25
26 #[doc(alias = "gst_rtsp_session_new")]
27 pub fn new(sessionid: &str) -> RTSPSession {
28 assert_initialized_main_thread!();
29 unsafe { from_glib_full(ffi::gst_rtsp_session_new(sessionid.to_glib_none().0)) }
30 }
31}
32
33unsafe impl Send for RTSPSession {}
34unsafe impl Sync for RTSPSession {}
35
36pub trait RTSPSessionExt: IsA<RTSPSession> + 'static {
37 #[doc(alias = "gst_rtsp_session_allow_expire")]
38 fn allow_expire(&self) {
39 unsafe {
40 ffi::gst_rtsp_session_allow_expire(self.as_ref().to_glib_none().0);
41 }
42 }
43
44 #[doc(alias = "gst_rtsp_session_filter")]
45 fn filter(
46 &self,
47 func: Option<&mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult>,
48 ) -> Vec<RTSPSessionMedia> {
49 let mut func_data: Option<
50 &mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult,
51 > = func;
52 unsafe extern "C" fn func_func(
53 sess: *mut ffi::GstRTSPSession,
54 media: *mut ffi::GstRTSPSessionMedia,
55 user_data: glib::ffi::gpointer,
56 ) -> ffi::GstRTSPFilterResult {
57 unsafe {
58 let sess = from_glib_borrow(sess);
59 let media = from_glib_borrow(media);
60 let callback = user_data
61 as *mut Option<
62 &mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult,
63 >;
64 if let Some(ref mut callback) = *callback {
65 callback(&sess, &media)
66 } else {
67 panic!("cannot get closure...")
68 }
69 .into_glib()
70 }
71 }
72 let func = if func_data.is_some() {
73 Some(func_func as _)
74 } else {
75 None
76 };
77 let super_callback0: &mut Option<
78 &mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult,
79 > = &mut func_data;
80 unsafe {
81 FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_filter(
82 self.as_ref().to_glib_none().0,
83 func,
84 super_callback0 as *mut _ as *mut _,
85 ))
86 }
87 }
88
89 #[doc(alias = "gst_rtsp_session_get_header")]
90 #[doc(alias = "get_header")]
91 fn header(&self) -> Option<glib::GString> {
92 unsafe {
93 from_glib_full(ffi::gst_rtsp_session_get_header(
94 self.as_ref().to_glib_none().0,
95 ))
96 }
97 }
98
99 #[doc(alias = "gst_rtsp_session_get_sessionid")]
100 #[doc(alias = "get_sessionid")]
101 fn sessionid(&self) -> Option<glib::GString> {
102 unsafe {
103 from_glib_none(ffi::gst_rtsp_session_get_sessionid(
104 self.as_ref().to_glib_none().0,
105 ))
106 }
107 }
108
109 #[doc(alias = "gst_rtsp_session_get_timeout")]
110 #[doc(alias = "get_timeout")]
111 fn timeout(&self) -> u32 {
112 unsafe { ffi::gst_rtsp_session_get_timeout(self.as_ref().to_glib_none().0) }
113 }
114
115 #[doc(alias = "gst_rtsp_session_is_expired_usec")]
121 fn is_expired_usec(&self, now: i64) -> bool {
122 unsafe {
123 from_glib(ffi::gst_rtsp_session_is_expired_usec(
124 self.as_ref().to_glib_none().0,
125 now,
126 ))
127 }
128 }
129
130 #[doc(alias = "gst_rtsp_session_manage_media")]
131 fn manage_media(&self, path: &str, media: impl IsA<RTSPMedia>) -> RTSPSessionMedia {
132 unsafe {
133 from_glib_none(ffi::gst_rtsp_session_manage_media(
134 self.as_ref().to_glib_none().0,
135 path.to_glib_none().0,
136 media.upcast().into_glib_ptr(),
137 ))
138 }
139 }
140
141 #[doc(alias = "gst_rtsp_session_next_timeout_usec")]
147 fn next_timeout_usec(&self, now: i64) -> i32 {
148 unsafe { ffi::gst_rtsp_session_next_timeout_usec(self.as_ref().to_glib_none().0, now) }
149 }
150
151 #[doc(alias = "gst_rtsp_session_prevent_expire")]
152 fn prevent_expire(&self) {
153 unsafe {
154 ffi::gst_rtsp_session_prevent_expire(self.as_ref().to_glib_none().0);
155 }
156 }
157
158 #[doc(alias = "gst_rtsp_session_release_media")]
159 fn release_media(&self, media: &impl IsA<RTSPSessionMedia>) -> bool {
160 unsafe {
161 from_glib(ffi::gst_rtsp_session_release_media(
162 self.as_ref().to_glib_none().0,
163 media.as_ref().to_glib_none().0,
164 ))
165 }
166 }
167
168 #[doc(alias = "gst_rtsp_session_set_timeout")]
169 #[doc(alias = "timeout")]
170 fn set_timeout(&self, timeout: u32) {
171 unsafe {
172 ffi::gst_rtsp_session_set_timeout(self.as_ref().to_glib_none().0, timeout);
173 }
174 }
175
176 #[doc(alias = "gst_rtsp_session_touch")]
177 fn touch(&self) {
178 unsafe {
179 ffi::gst_rtsp_session_touch(self.as_ref().to_glib_none().0);
180 }
181 }
182
183 #[doc(alias = "extra-timeout")]
184 fn extra_timeout(&self) -> u32 {
185 ObjectExt::property(self.as_ref(), "extra-timeout")
186 }
187
188 #[doc(alias = "extra-timeout")]
189 fn set_extra_timeout(&self, extra_timeout: u32) {
190 ObjectExt::set_property(self.as_ref(), "extra-timeout", extra_timeout)
191 }
192
193 #[doc(alias = "timeout-always-visible")]
194 fn is_timeout_always_visible(&self) -> bool {
195 ObjectExt::property(self.as_ref(), "timeout-always-visible")
196 }
197
198 #[doc(alias = "timeout-always-visible")]
199 fn set_timeout_always_visible(&self, timeout_always_visible: bool) {
200 ObjectExt::set_property(
201 self.as_ref(),
202 "timeout-always-visible",
203 timeout_always_visible,
204 )
205 }
206
207 #[doc(alias = "extra-timeout")]
208 fn connect_extra_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
209 &self,
210 f: F,
211 ) -> SignalHandlerId {
212 unsafe extern "C" fn notify_extra_timeout_trampoline<
213 P: IsA<RTSPSession>,
214 F: Fn(&P) + Send + Sync + 'static,
215 >(
216 this: *mut ffi::GstRTSPSession,
217 _param_spec: glib::ffi::gpointer,
218 f: glib::ffi::gpointer,
219 ) {
220 unsafe {
221 let f: &F = &*(f as *const F);
222 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
223 }
224 }
225 unsafe {
226 let f: Box_<F> = Box_::new(f);
227 connect_raw(
228 self.as_ptr() as *mut _,
229 c"notify::extra-timeout".as_ptr(),
230 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
231 notify_extra_timeout_trampoline::<Self, F> as *const (),
232 )),
233 Box_::into_raw(f),
234 )
235 }
236 }
237
238 #[doc(alias = "timeout")]
239 fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
240 &self,
241 f: F,
242 ) -> SignalHandlerId {
243 unsafe extern "C" fn notify_timeout_trampoline<
244 P: IsA<RTSPSession>,
245 F: Fn(&P) + Send + Sync + 'static,
246 >(
247 this: *mut ffi::GstRTSPSession,
248 _param_spec: glib::ffi::gpointer,
249 f: glib::ffi::gpointer,
250 ) {
251 unsafe {
252 let f: &F = &*(f as *const F);
253 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
254 }
255 }
256 unsafe {
257 let f: Box_<F> = Box_::new(f);
258 connect_raw(
259 self.as_ptr() as *mut _,
260 c"notify::timeout".as_ptr(),
261 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
262 notify_timeout_trampoline::<Self, F> as *const (),
263 )),
264 Box_::into_raw(f),
265 )
266 }
267 }
268
269 #[doc(alias = "timeout-always-visible")]
270 fn connect_timeout_always_visible_notify<F: Fn(&Self) + Send + Sync + 'static>(
271 &self,
272 f: F,
273 ) -> SignalHandlerId {
274 unsafe extern "C" fn notify_timeout_always_visible_trampoline<
275 P: IsA<RTSPSession>,
276 F: Fn(&P) + Send + Sync + 'static,
277 >(
278 this: *mut ffi::GstRTSPSession,
279 _param_spec: glib::ffi::gpointer,
280 f: glib::ffi::gpointer,
281 ) {
282 unsafe {
283 let f: &F = &*(f as *const F);
284 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
285 }
286 }
287 unsafe {
288 let f: Box_<F> = Box_::new(f);
289 connect_raw(
290 self.as_ptr() as *mut _,
291 c"notify::timeout-always-visible".as_ptr(),
292 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
293 notify_timeout_always_visible_trampoline::<Self, F> as *const (),
294 )),
295 Box_::into_raw(f),
296 )
297 }
298 }
299}
300
301impl<O: IsA<RTSPSession>> RTSPSessionExt for O {}