gstreamer_rtsp_server/auto/
rtsp_session.rs1use crate::{ffi, RTSPFilterResult, RTSPMedia, RTSPSessionMedia};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GstRTSPSession")]
41 pub struct RTSPSession(Object<ffi::GstRTSPSession, ffi::GstRTSPSessionClass>);
42
43 match fn {
44 type_ => || ffi::gst_rtsp_session_get_type(),
45 }
46}
47
48impl RTSPSession {
49 pub const NONE: Option<&'static RTSPSession> = None;
50
51 #[doc(alias = "gst_rtsp_session_new")]
59 pub fn new(sessionid: &str) -> RTSPSession {
60 assert_initialized_main_thread!();
61 unsafe { from_glib_full(ffi::gst_rtsp_session_new(sessionid.to_glib_none().0)) }
62 }
63}
64
65unsafe impl Send for RTSPSession {}
66unsafe impl Sync for RTSPSession {}
67
68pub trait RTSPSessionExt: IsA<RTSPSession> + 'static {
74 #[doc(alias = "gst_rtsp_session_allow_expire")]
77 fn allow_expire(&self) {
78 unsafe {
79 ffi::gst_rtsp_session_allow_expire(self.as_ref().to_glib_none().0);
80 }
81 }
82
83 #[doc(alias = "gst_rtsp_session_filter")]
106 fn filter(
107 &self,
108 func: Option<&mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult>,
109 ) -> Vec<RTSPSessionMedia> {
110 let mut func_data: Option<
111 &mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult,
112 > = func;
113 unsafe extern "C" fn func_func(
114 sess: *mut ffi::GstRTSPSession,
115 media: *mut ffi::GstRTSPSessionMedia,
116 user_data: glib::ffi::gpointer,
117 ) -> ffi::GstRTSPFilterResult {
118 let sess = from_glib_borrow(sess);
119 let media = from_glib_borrow(media);
120 let callback = user_data
121 as *mut Option<&mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult>;
122 if let Some(ref mut callback) = *callback {
123 callback(&sess, &media)
124 } else {
125 panic!("cannot get closure...")
126 }
127 .into_glib()
128 }
129 let func = if func_data.is_some() {
130 Some(func_func as _)
131 } else {
132 None
133 };
134 let super_callback0: &mut Option<
135 &mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult,
136 > = &mut func_data;
137 unsafe {
138 FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_filter(
139 self.as_ref().to_glib_none().0,
140 func,
141 super_callback0 as *mut _ as *mut _,
142 ))
143 }
144 }
145
146 #[doc(alias = "gst_rtsp_session_get_header")]
153 #[doc(alias = "get_header")]
154 fn header(&self) -> Option<glib::GString> {
155 unsafe {
156 from_glib_full(ffi::gst_rtsp_session_get_header(
157 self.as_ref().to_glib_none().0,
158 ))
159 }
160 }
161
162 #[doc(alias = "gst_rtsp_session_get_sessionid")]
169 #[doc(alias = "get_sessionid")]
170 fn sessionid(&self) -> Option<glib::GString> {
171 unsafe {
172 from_glib_none(ffi::gst_rtsp_session_get_sessionid(
173 self.as_ref().to_glib_none().0,
174 ))
175 }
176 }
177
178 #[doc(alias = "gst_rtsp_session_get_timeout")]
184 #[doc(alias = "get_timeout")]
185 fn timeout(&self) -> u32 {
186 unsafe { ffi::gst_rtsp_session_get_timeout(self.as_ref().to_glib_none().0) }
187 }
188
189 #[doc(alias = "gst_rtsp_session_is_expired_usec")]
202 fn is_expired_usec(&self, now: i64) -> bool {
203 unsafe {
204 from_glib(ffi::gst_rtsp_session_is_expired_usec(
205 self.as_ref().to_glib_none().0,
206 now,
207 ))
208 }
209 }
210
211 #[doc(alias = "gst_rtsp_session_manage_media")]
224 fn manage_media(&self, path: &str, media: impl IsA<RTSPMedia>) -> RTSPSessionMedia {
225 unsafe {
226 from_glib_none(ffi::gst_rtsp_session_manage_media(
227 self.as_ref().to_glib_none().0,
228 path.to_glib_none().0,
229 media.upcast().into_glib_ptr(),
230 ))
231 }
232 }
233
234 #[doc(alias = "gst_rtsp_session_next_timeout_usec")]
247 fn next_timeout_usec(&self, now: i64) -> i32 {
248 unsafe { ffi::gst_rtsp_session_next_timeout_usec(self.as_ref().to_glib_none().0, now) }
249 }
250
251 #[doc(alias = "gst_rtsp_session_prevent_expire")]
253 fn prevent_expire(&self) {
254 unsafe {
255 ffi::gst_rtsp_session_prevent_expire(self.as_ref().to_glib_none().0);
256 }
257 }
258
259 #[doc(alias = "gst_rtsp_session_release_media")]
267 fn release_media(&self, media: &impl IsA<RTSPSessionMedia>) -> bool {
268 unsafe {
269 from_glib(ffi::gst_rtsp_session_release_media(
270 self.as_ref().to_glib_none().0,
271 media.as_ref().to_glib_none().0,
272 ))
273 }
274 }
275
276 #[doc(alias = "gst_rtsp_session_set_timeout")]
281 #[doc(alias = "timeout")]
282 fn set_timeout(&self, timeout: u32) {
283 unsafe {
284 ffi::gst_rtsp_session_set_timeout(self.as_ref().to_glib_none().0, timeout);
285 }
286 }
287
288 #[doc(alias = "gst_rtsp_session_touch")]
290 fn touch(&self) {
291 unsafe {
292 ffi::gst_rtsp_session_touch(self.as_ref().to_glib_none().0);
293 }
294 }
295
296 #[doc(alias = "extra-timeout")]
297 fn extra_timeout(&self) -> u32 {
298 ObjectExt::property(self.as_ref(), "extra-timeout")
299 }
300
301 #[doc(alias = "extra-timeout")]
302 fn set_extra_timeout(&self, extra_timeout: u32) {
303 ObjectExt::set_property(self.as_ref(), "extra-timeout", extra_timeout)
304 }
305
306 #[doc(alias = "timeout-always-visible")]
307 fn is_timeout_always_visible(&self) -> bool {
308 ObjectExt::property(self.as_ref(), "timeout-always-visible")
309 }
310
311 #[doc(alias = "timeout-always-visible")]
312 fn set_timeout_always_visible(&self, timeout_always_visible: bool) {
313 ObjectExt::set_property(
314 self.as_ref(),
315 "timeout-always-visible",
316 timeout_always_visible,
317 )
318 }
319
320 #[doc(alias = "extra-timeout")]
321 fn connect_extra_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
322 &self,
323 f: F,
324 ) -> SignalHandlerId {
325 unsafe extern "C" fn notify_extra_timeout_trampoline<
326 P: IsA<RTSPSession>,
327 F: Fn(&P) + Send + Sync + 'static,
328 >(
329 this: *mut ffi::GstRTSPSession,
330 _param_spec: glib::ffi::gpointer,
331 f: glib::ffi::gpointer,
332 ) {
333 let f: &F = &*(f as *const F);
334 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
335 }
336 unsafe {
337 let f: Box_<F> = Box_::new(f);
338 connect_raw(
339 self.as_ptr() as *mut _,
340 c"notify::extra-timeout".as_ptr() as *const _,
341 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
342 notify_extra_timeout_trampoline::<Self, F> as *const (),
343 )),
344 Box_::into_raw(f),
345 )
346 }
347 }
348
349 #[doc(alias = "timeout")]
350 fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
351 &self,
352 f: F,
353 ) -> SignalHandlerId {
354 unsafe extern "C" fn notify_timeout_trampoline<
355 P: IsA<RTSPSession>,
356 F: Fn(&P) + Send + Sync + 'static,
357 >(
358 this: *mut ffi::GstRTSPSession,
359 _param_spec: glib::ffi::gpointer,
360 f: glib::ffi::gpointer,
361 ) {
362 let f: &F = &*(f as *const F);
363 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
364 }
365 unsafe {
366 let f: Box_<F> = Box_::new(f);
367 connect_raw(
368 self.as_ptr() as *mut _,
369 c"notify::timeout".as_ptr() as *const _,
370 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
371 notify_timeout_trampoline::<Self, F> as *const (),
372 )),
373 Box_::into_raw(f),
374 )
375 }
376 }
377
378 #[doc(alias = "timeout-always-visible")]
379 fn connect_timeout_always_visible_notify<F: Fn(&Self) + Send + Sync + 'static>(
380 &self,
381 f: F,
382 ) -> SignalHandlerId {
383 unsafe extern "C" fn notify_timeout_always_visible_trampoline<
384 P: IsA<RTSPSession>,
385 F: Fn(&P) + Send + Sync + 'static,
386 >(
387 this: *mut ffi::GstRTSPSession,
388 _param_spec: glib::ffi::gpointer,
389 f: glib::ffi::gpointer,
390 ) {
391 let f: &F = &*(f as *const F);
392 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
393 }
394 unsafe {
395 let f: Box_<F> = Box_::new(f);
396 connect_raw(
397 self.as_ptr() as *mut _,
398 c"notify::timeout-always-visible".as_ptr() as *const _,
399 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
400 notify_timeout_always_visible_trampoline::<Self, F> as *const (),
401 )),
402 Box_::into_raw(f),
403 )
404 }
405 }
406}
407
408impl<O: IsA<RTSPSession>> RTSPSessionExt for O {}