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")]
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 unsafe {
119 let sess = from_glib_borrow(sess);
120 let media = from_glib_borrow(media);
121 let callback = user_data
122 as *mut Option<
123 &mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult,
124 >;
125 if let Some(ref mut callback) = *callback {
126 callback(&sess, &media)
127 } else {
128 panic!("cannot get closure...")
129 }
130 .into_glib()
131 }
132 }
133 let func = if func_data.is_some() {
134 Some(func_func as _)
135 } else {
136 None
137 };
138 let super_callback0: &mut Option<
139 &mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult,
140 > = &mut func_data;
141 unsafe {
142 FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_filter(
143 self.as_ref().to_glib_none().0,
144 func,
145 super_callback0 as *mut _ as *mut _,
146 ))
147 }
148 }
149
150 #[doc(alias = "gst_rtsp_session_get_header")]
157 #[doc(alias = "get_header")]
158 fn header(&self) -> Option<glib::GString> {
159 unsafe {
160 from_glib_full(ffi::gst_rtsp_session_get_header(
161 self.as_ref().to_glib_none().0,
162 ))
163 }
164 }
165
166 #[doc(alias = "gst_rtsp_session_get_sessionid")]
173 #[doc(alias = "get_sessionid")]
174 fn sessionid(&self) -> Option<glib::GString> {
175 unsafe {
176 from_glib_none(ffi::gst_rtsp_session_get_sessionid(
177 self.as_ref().to_glib_none().0,
178 ))
179 }
180 }
181
182 #[doc(alias = "gst_rtsp_session_get_timeout")]
188 #[doc(alias = "get_timeout")]
189 fn timeout(&self) -> u32 {
190 unsafe { ffi::gst_rtsp_session_get_timeout(self.as_ref().to_glib_none().0) }
191 }
192
193 #[doc(alias = "gst_rtsp_session_is_expired_usec")]
206 fn is_expired_usec(&self, now: i64) -> bool {
207 unsafe {
208 from_glib(ffi::gst_rtsp_session_is_expired_usec(
209 self.as_ref().to_glib_none().0,
210 now,
211 ))
212 }
213 }
214
215 #[doc(alias = "gst_rtsp_session_manage_media")]
228 fn manage_media(&self, path: &str, media: impl IsA<RTSPMedia>) -> RTSPSessionMedia {
229 unsafe {
230 from_glib_none(ffi::gst_rtsp_session_manage_media(
231 self.as_ref().to_glib_none().0,
232 path.to_glib_none().0,
233 media.upcast().into_glib_ptr(),
234 ))
235 }
236 }
237
238 #[doc(alias = "gst_rtsp_session_next_timeout_usec")]
251 fn next_timeout_usec(&self, now: i64) -> i32 {
252 unsafe { ffi::gst_rtsp_session_next_timeout_usec(self.as_ref().to_glib_none().0, now) }
253 }
254
255 #[doc(alias = "gst_rtsp_session_prevent_expire")]
257 fn prevent_expire(&self) {
258 unsafe {
259 ffi::gst_rtsp_session_prevent_expire(self.as_ref().to_glib_none().0);
260 }
261 }
262
263 #[doc(alias = "gst_rtsp_session_release_media")]
271 fn release_media(&self, media: &impl IsA<RTSPSessionMedia>) -> bool {
272 unsafe {
273 from_glib(ffi::gst_rtsp_session_release_media(
274 self.as_ref().to_glib_none().0,
275 media.as_ref().to_glib_none().0,
276 ))
277 }
278 }
279
280 #[doc(alias = "gst_rtsp_session_set_timeout")]
285 #[doc(alias = "timeout")]
286 fn set_timeout(&self, timeout: u32) {
287 unsafe {
288 ffi::gst_rtsp_session_set_timeout(self.as_ref().to_glib_none().0, timeout);
289 }
290 }
291
292 #[doc(alias = "gst_rtsp_session_touch")]
294 fn touch(&self) {
295 unsafe {
296 ffi::gst_rtsp_session_touch(self.as_ref().to_glib_none().0);
297 }
298 }
299
300 #[doc(alias = "extra-timeout")]
301 fn extra_timeout(&self) -> u32 {
302 ObjectExt::property(self.as_ref(), "extra-timeout")
303 }
304
305 #[doc(alias = "extra-timeout")]
306 fn set_extra_timeout(&self, extra_timeout: u32) {
307 ObjectExt::set_property(self.as_ref(), "extra-timeout", extra_timeout)
308 }
309
310 #[doc(alias = "timeout-always-visible")]
311 fn is_timeout_always_visible(&self) -> bool {
312 ObjectExt::property(self.as_ref(), "timeout-always-visible")
313 }
314
315 #[doc(alias = "timeout-always-visible")]
316 fn set_timeout_always_visible(&self, timeout_always_visible: bool) {
317 ObjectExt::set_property(
318 self.as_ref(),
319 "timeout-always-visible",
320 timeout_always_visible,
321 )
322 }
323
324 #[doc(alias = "extra-timeout")]
325 fn connect_extra_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
326 &self,
327 f: F,
328 ) -> SignalHandlerId {
329 unsafe extern "C" fn notify_extra_timeout_trampoline<
330 P: IsA<RTSPSession>,
331 F: Fn(&P) + Send + Sync + 'static,
332 >(
333 this: *mut ffi::GstRTSPSession,
334 _param_spec: glib::ffi::gpointer,
335 f: glib::ffi::gpointer,
336 ) {
337 unsafe {
338 let f: &F = &*(f as *const F);
339 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
340 }
341 }
342 unsafe {
343 let f: Box_<F> = Box_::new(f);
344 connect_raw(
345 self.as_ptr() as *mut _,
346 c"notify::extra-timeout".as_ptr(),
347 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
348 notify_extra_timeout_trampoline::<Self, F> as *const (),
349 )),
350 Box_::into_raw(f),
351 )
352 }
353 }
354
355 #[doc(alias = "timeout")]
356 fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
357 &self,
358 f: F,
359 ) -> SignalHandlerId {
360 unsafe extern "C" fn notify_timeout_trampoline<
361 P: IsA<RTSPSession>,
362 F: Fn(&P) + Send + Sync + 'static,
363 >(
364 this: *mut ffi::GstRTSPSession,
365 _param_spec: glib::ffi::gpointer,
366 f: glib::ffi::gpointer,
367 ) {
368 unsafe {
369 let f: &F = &*(f as *const F);
370 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
371 }
372 }
373 unsafe {
374 let f: Box_<F> = Box_::new(f);
375 connect_raw(
376 self.as_ptr() as *mut _,
377 c"notify::timeout".as_ptr(),
378 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
379 notify_timeout_trampoline::<Self, F> as *const (),
380 )),
381 Box_::into_raw(f),
382 )
383 }
384 }
385
386 #[doc(alias = "timeout-always-visible")]
387 fn connect_timeout_always_visible_notify<F: Fn(&Self) + Send + Sync + 'static>(
388 &self,
389 f: F,
390 ) -> SignalHandlerId {
391 unsafe extern "C" fn notify_timeout_always_visible_trampoline<
392 P: IsA<RTSPSession>,
393 F: Fn(&P) + Send + Sync + 'static,
394 >(
395 this: *mut ffi::GstRTSPSession,
396 _param_spec: glib::ffi::gpointer,
397 f: glib::ffi::gpointer,
398 ) {
399 unsafe {
400 let f: &F = &*(f as *const F);
401 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
402 }
403 }
404 unsafe {
405 let f: Box_<F> = Box_::new(f);
406 connect_raw(
407 self.as_ptr() as *mut _,
408 c"notify::timeout-always-visible".as_ptr(),
409 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
410 notify_timeout_always_visible_trampoline::<Self, F> as *const (),
411 )),
412 Box_::into_raw(f),
413 )
414 }
415 }
416}
417
418impl<O: IsA<RTSPSession>> RTSPSessionExt for O {}