gstreamer_rtsp_server/auto/
rtsp_server.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{
7    ffi, RTSPAuth, RTSPClient, RTSPFilterResult, RTSPMountPoints, RTSPSessionPool, RTSPThreadPool,
8};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    #[doc(alias = "GstRTSPServer")]
19    pub struct RTSPServer(Object<ffi::GstRTSPServer, ffi::GstRTSPServerClass>);
20
21    match fn {
22        type_ => || ffi::gst_rtsp_server_get_type(),
23    }
24}
25
26impl RTSPServer {
27    pub const NONE: Option<&'static RTSPServer> = None;
28
29    #[doc(alias = "gst_rtsp_server_new")]
30    pub fn new() -> RTSPServer {
31        assert_initialized_main_thread!();
32        unsafe { from_glib_full(ffi::gst_rtsp_server_new()) }
33    }
34
35    #[doc(alias = "gst_rtsp_server_io_func")]
36    pub fn io_func(
37        socket: &impl IsA<gio::Socket>,
38        condition: glib::IOCondition,
39        server: &impl IsA<RTSPServer>,
40    ) -> Result<(), glib::error::BoolError> {
41        skip_assert_initialized!();
42        unsafe {
43            glib::result_from_gboolean!(
44                ffi::gst_rtsp_server_io_func(
45                    socket.as_ref().to_glib_none().0,
46                    condition.into_glib(),
47                    server.as_ref().to_glib_none().0
48                ),
49                "Failed to connect the source"
50            )
51        }
52    }
53}
54
55impl Default for RTSPServer {
56    fn default() -> Self {
57        Self::new()
58    }
59}
60
61unsafe impl Send for RTSPServer {}
62unsafe impl Sync for RTSPServer {}
63
64pub trait RTSPServerExt: IsA<RTSPServer> + 'static {
65    #[doc(alias = "gst_rtsp_server_client_filter")]
66    fn client_filter(
67        &self,
68        func: Option<&mut dyn FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult>,
69    ) -> Vec<RTSPClient> {
70        let mut func_data: Option<&mut dyn FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult> =
71            func;
72        unsafe extern "C" fn func_func(
73            server: *mut ffi::GstRTSPServer,
74            client: *mut ffi::GstRTSPClient,
75            user_data: glib::ffi::gpointer,
76        ) -> ffi::GstRTSPFilterResult {
77            let server = from_glib_borrow(server);
78            let client = from_glib_borrow(client);
79            let callback = user_data
80                as *mut Option<&mut dyn FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult>;
81            if let Some(ref mut callback) = *callback {
82                callback(&server, &client)
83            } else {
84                panic!("cannot get closure...")
85            }
86            .into_glib()
87        }
88        let func = if func_data.is_some() {
89            Some(func_func as _)
90        } else {
91            None
92        };
93        let super_callback0: &mut Option<
94            &mut dyn FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult,
95        > = &mut func_data;
96        unsafe {
97            FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_server_client_filter(
98                self.as_ref().to_glib_none().0,
99                func,
100                super_callback0 as *mut _ as *mut _,
101            ))
102        }
103    }
104
105    #[doc(alias = "gst_rtsp_server_create_socket")]
106    fn create_socket(
107        &self,
108        cancellable: Option<&impl IsA<gio::Cancellable>>,
109    ) -> Result<gio::Socket, glib::Error> {
110        unsafe {
111            let mut error = std::ptr::null_mut();
112            let ret = ffi::gst_rtsp_server_create_socket(
113                self.as_ref().to_glib_none().0,
114                cancellable.map(|p| p.as_ref()).to_glib_none().0,
115                &mut error,
116            );
117            if error.is_null() {
118                Ok(from_glib_full(ret))
119            } else {
120                Err(from_glib_full(error))
121            }
122        }
123    }
124
125    #[doc(alias = "gst_rtsp_server_create_source")]
126    fn create_source(
127        &self,
128        cancellable: Option<&impl IsA<gio::Cancellable>>,
129    ) -> Result<glib::Source, glib::Error> {
130        unsafe {
131            let mut error = std::ptr::null_mut();
132            let ret = ffi::gst_rtsp_server_create_source(
133                self.as_ref().to_glib_none().0,
134                cancellable.map(|p| p.as_ref()).to_glib_none().0,
135                &mut error,
136            );
137            if error.is_null() {
138                Ok(from_glib_full(ret))
139            } else {
140                Err(from_glib_full(error))
141            }
142        }
143    }
144
145    #[doc(alias = "gst_rtsp_server_get_address")]
146    #[doc(alias = "get_address")]
147    fn address(&self) -> Option<glib::GString> {
148        unsafe {
149            from_glib_full(ffi::gst_rtsp_server_get_address(
150                self.as_ref().to_glib_none().0,
151            ))
152        }
153    }
154
155    #[doc(alias = "gst_rtsp_server_get_auth")]
156    #[doc(alias = "get_auth")]
157    fn auth(&self) -> Option<RTSPAuth> {
158        unsafe {
159            from_glib_full(ffi::gst_rtsp_server_get_auth(
160                self.as_ref().to_glib_none().0,
161            ))
162        }
163    }
164
165    #[doc(alias = "gst_rtsp_server_get_backlog")]
166    #[doc(alias = "get_backlog")]
167    fn backlog(&self) -> i32 {
168        unsafe { ffi::gst_rtsp_server_get_backlog(self.as_ref().to_glib_none().0) }
169    }
170
171    #[doc(alias = "gst_rtsp_server_get_bound_port")]
172    #[doc(alias = "get_bound_port")]
173    #[doc(alias = "bound-port")]
174    fn bound_port(&self) -> i32 {
175        unsafe { ffi::gst_rtsp_server_get_bound_port(self.as_ref().to_glib_none().0) }
176    }
177
178    #[cfg(feature = "v1_18")]
179    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
180    #[doc(alias = "gst_rtsp_server_get_content_length_limit")]
181    #[doc(alias = "get_content_length_limit")]
182    #[doc(alias = "content-length-limit")]
183    fn content_length_limit(&self) -> u32 {
184        unsafe { ffi::gst_rtsp_server_get_content_length_limit(self.as_ref().to_glib_none().0) }
185    }
186
187    #[doc(alias = "gst_rtsp_server_get_mount_points")]
188    #[doc(alias = "get_mount_points")]
189    #[doc(alias = "mount-points")]
190    fn mount_points(&self) -> Option<RTSPMountPoints> {
191        unsafe {
192            from_glib_full(ffi::gst_rtsp_server_get_mount_points(
193                self.as_ref().to_glib_none().0,
194            ))
195        }
196    }
197
198    #[doc(alias = "gst_rtsp_server_get_service")]
199    #[doc(alias = "get_service")]
200    fn service(&self) -> glib::GString {
201        unsafe {
202            from_glib_full(ffi::gst_rtsp_server_get_service(
203                self.as_ref().to_glib_none().0,
204            ))
205        }
206    }
207
208    #[doc(alias = "gst_rtsp_server_get_session_pool")]
209    #[doc(alias = "get_session_pool")]
210    #[doc(alias = "session-pool")]
211    fn session_pool(&self) -> Option<RTSPSessionPool> {
212        unsafe {
213            from_glib_full(ffi::gst_rtsp_server_get_session_pool(
214                self.as_ref().to_glib_none().0,
215            ))
216        }
217    }
218
219    #[doc(alias = "gst_rtsp_server_get_thread_pool")]
220    #[doc(alias = "get_thread_pool")]
221    fn thread_pool(&self) -> Option<RTSPThreadPool> {
222        unsafe {
223            from_glib_full(ffi::gst_rtsp_server_get_thread_pool(
224                self.as_ref().to_glib_none().0,
225            ))
226        }
227    }
228
229    #[doc(alias = "gst_rtsp_server_set_address")]
230    #[doc(alias = "address")]
231    fn set_address(&self, address: &str) {
232        unsafe {
233            ffi::gst_rtsp_server_set_address(
234                self.as_ref().to_glib_none().0,
235                address.to_glib_none().0,
236            );
237        }
238    }
239
240    #[doc(alias = "gst_rtsp_server_set_auth")]
241    fn set_auth(&self, auth: Option<&impl IsA<RTSPAuth>>) {
242        unsafe {
243            ffi::gst_rtsp_server_set_auth(
244                self.as_ref().to_glib_none().0,
245                auth.map(|p| p.as_ref()).to_glib_none().0,
246            );
247        }
248    }
249
250    #[doc(alias = "gst_rtsp_server_set_backlog")]
251    #[doc(alias = "backlog")]
252    fn set_backlog(&self, backlog: i32) {
253        unsafe {
254            ffi::gst_rtsp_server_set_backlog(self.as_ref().to_glib_none().0, backlog);
255        }
256    }
257
258    #[cfg(feature = "v1_18")]
259    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
260    #[doc(alias = "gst_rtsp_server_set_content_length_limit")]
261    #[doc(alias = "content-length-limit")]
262    fn set_content_length_limit(&self, limit: u32) {
263        unsafe {
264            ffi::gst_rtsp_server_set_content_length_limit(self.as_ref().to_glib_none().0, limit);
265        }
266    }
267
268    #[doc(alias = "gst_rtsp_server_set_mount_points")]
269    #[doc(alias = "mount-points")]
270    fn set_mount_points(&self, mounts: Option<&impl IsA<RTSPMountPoints>>) {
271        unsafe {
272            ffi::gst_rtsp_server_set_mount_points(
273                self.as_ref().to_glib_none().0,
274                mounts.map(|p| p.as_ref()).to_glib_none().0,
275            );
276        }
277    }
278
279    #[doc(alias = "gst_rtsp_server_set_service")]
280    #[doc(alias = "service")]
281    fn set_service(&self, service: &str) {
282        unsafe {
283            ffi::gst_rtsp_server_set_service(
284                self.as_ref().to_glib_none().0,
285                service.to_glib_none().0,
286            );
287        }
288    }
289
290    #[doc(alias = "gst_rtsp_server_set_session_pool")]
291    #[doc(alias = "session-pool")]
292    fn set_session_pool(&self, pool: Option<&impl IsA<RTSPSessionPool>>) {
293        unsafe {
294            ffi::gst_rtsp_server_set_session_pool(
295                self.as_ref().to_glib_none().0,
296                pool.map(|p| p.as_ref()).to_glib_none().0,
297            );
298        }
299    }
300
301    #[doc(alias = "gst_rtsp_server_set_thread_pool")]
302    fn set_thread_pool(&self, pool: Option<&impl IsA<RTSPThreadPool>>) {
303        unsafe {
304            ffi::gst_rtsp_server_set_thread_pool(
305                self.as_ref().to_glib_none().0,
306                pool.map(|p| p.as_ref()).to_glib_none().0,
307            );
308        }
309    }
310
311    #[doc(alias = "gst_rtsp_server_transfer_connection")]
312    fn transfer_connection(
313        &self,
314        socket: impl IsA<gio::Socket>,
315        ip: &str,
316        port: i32,
317        initial_buffer: Option<&str>,
318    ) -> Result<(), glib::error::BoolError> {
319        unsafe {
320            glib::result_from_gboolean!(
321                ffi::gst_rtsp_server_transfer_connection(
322                    self.as_ref().to_glib_none().0,
323                    socket.upcast().into_glib_ptr(),
324                    ip.to_glib_none().0,
325                    port,
326                    initial_buffer.to_glib_none().0
327                ),
328                "Failed to transfer to the connection"
329            )
330        }
331    }
332
333    #[cfg(not(feature = "v1_18"))]
334    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_18"))))]
335    #[doc(alias = "content-length-limit")]
336    fn content_length_limit(&self) -> u32 {
337        ObjectExt::property(self.as_ref(), "content-length-limit")
338    }
339
340    #[cfg(not(feature = "v1_18"))]
341    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_18"))))]
342    #[doc(alias = "content-length-limit")]
343    fn set_content_length_limit(&self, content_length_limit: u32) {
344        ObjectExt::set_property(self.as_ref(), "content-length-limit", content_length_limit)
345    }
346
347    #[doc(alias = "client-connected")]
348    fn connect_client_connected<F: Fn(&Self, &RTSPClient) + Send + Sync + 'static>(
349        &self,
350        f: F,
351    ) -> SignalHandlerId {
352        unsafe extern "C" fn client_connected_trampoline<
353            P: IsA<RTSPServer>,
354            F: Fn(&P, &RTSPClient) + Send + Sync + 'static,
355        >(
356            this: *mut ffi::GstRTSPServer,
357            object: *mut ffi::GstRTSPClient,
358            f: glib::ffi::gpointer,
359        ) {
360            let f: &F = &*(f as *const F);
361            f(
362                RTSPServer::from_glib_borrow(this).unsafe_cast_ref(),
363                &from_glib_borrow(object),
364            )
365        }
366        unsafe {
367            let f: Box_<F> = Box_::new(f);
368            connect_raw(
369                self.as_ptr() as *mut _,
370                c"client-connected".as_ptr() as *const _,
371                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
372                    client_connected_trampoline::<Self, F> as *const (),
373                )),
374                Box_::into_raw(f),
375            )
376        }
377    }
378
379    #[doc(alias = "address")]
380    fn connect_address_notify<F: Fn(&Self) + Send + Sync + 'static>(
381        &self,
382        f: F,
383    ) -> SignalHandlerId {
384        unsafe extern "C" fn notify_address_trampoline<
385            P: IsA<RTSPServer>,
386            F: Fn(&P) + Send + Sync + 'static,
387        >(
388            this: *mut ffi::GstRTSPServer,
389            _param_spec: glib::ffi::gpointer,
390            f: glib::ffi::gpointer,
391        ) {
392            let f: &F = &*(f as *const F);
393            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
394        }
395        unsafe {
396            let f: Box_<F> = Box_::new(f);
397            connect_raw(
398                self.as_ptr() as *mut _,
399                c"notify::address".as_ptr() as *const _,
400                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
401                    notify_address_trampoline::<Self, F> as *const (),
402                )),
403                Box_::into_raw(f),
404            )
405        }
406    }
407
408    #[doc(alias = "backlog")]
409    fn connect_backlog_notify<F: Fn(&Self) + Send + Sync + 'static>(
410        &self,
411        f: F,
412    ) -> SignalHandlerId {
413        unsafe extern "C" fn notify_backlog_trampoline<
414            P: IsA<RTSPServer>,
415            F: Fn(&P) + Send + Sync + 'static,
416        >(
417            this: *mut ffi::GstRTSPServer,
418            _param_spec: glib::ffi::gpointer,
419            f: glib::ffi::gpointer,
420        ) {
421            let f: &F = &*(f as *const F);
422            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
423        }
424        unsafe {
425            let f: Box_<F> = Box_::new(f);
426            connect_raw(
427                self.as_ptr() as *mut _,
428                c"notify::backlog".as_ptr() as *const _,
429                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
430                    notify_backlog_trampoline::<Self, F> as *const (),
431                )),
432                Box_::into_raw(f),
433            )
434        }
435    }
436
437    #[doc(alias = "bound-port")]
438    fn connect_bound_port_notify<F: Fn(&Self) + Send + Sync + 'static>(
439        &self,
440        f: F,
441    ) -> SignalHandlerId {
442        unsafe extern "C" fn notify_bound_port_trampoline<
443            P: IsA<RTSPServer>,
444            F: Fn(&P) + Send + Sync + 'static,
445        >(
446            this: *mut ffi::GstRTSPServer,
447            _param_spec: glib::ffi::gpointer,
448            f: glib::ffi::gpointer,
449        ) {
450            let f: &F = &*(f as *const F);
451            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
452        }
453        unsafe {
454            let f: Box_<F> = Box_::new(f);
455            connect_raw(
456                self.as_ptr() as *mut _,
457                c"notify::bound-port".as_ptr() as *const _,
458                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
459                    notify_bound_port_trampoline::<Self, F> as *const (),
460                )),
461                Box_::into_raw(f),
462            )
463        }
464    }
465
466    #[doc(alias = "content-length-limit")]
467    fn connect_content_length_limit_notify<F: Fn(&Self) + Send + Sync + 'static>(
468        &self,
469        f: F,
470    ) -> SignalHandlerId {
471        unsafe extern "C" fn notify_content_length_limit_trampoline<
472            P: IsA<RTSPServer>,
473            F: Fn(&P) + Send + Sync + 'static,
474        >(
475            this: *mut ffi::GstRTSPServer,
476            _param_spec: glib::ffi::gpointer,
477            f: glib::ffi::gpointer,
478        ) {
479            let f: &F = &*(f as *const F);
480            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
481        }
482        unsafe {
483            let f: Box_<F> = Box_::new(f);
484            connect_raw(
485                self.as_ptr() as *mut _,
486                c"notify::content-length-limit".as_ptr() as *const _,
487                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
488                    notify_content_length_limit_trampoline::<Self, F> as *const (),
489                )),
490                Box_::into_raw(f),
491            )
492        }
493    }
494
495    #[doc(alias = "mount-points")]
496    fn connect_mount_points_notify<F: Fn(&Self) + Send + Sync + 'static>(
497        &self,
498        f: F,
499    ) -> SignalHandlerId {
500        unsafe extern "C" fn notify_mount_points_trampoline<
501            P: IsA<RTSPServer>,
502            F: Fn(&P) + Send + Sync + 'static,
503        >(
504            this: *mut ffi::GstRTSPServer,
505            _param_spec: glib::ffi::gpointer,
506            f: glib::ffi::gpointer,
507        ) {
508            let f: &F = &*(f as *const F);
509            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
510        }
511        unsafe {
512            let f: Box_<F> = Box_::new(f);
513            connect_raw(
514                self.as_ptr() as *mut _,
515                c"notify::mount-points".as_ptr() as *const _,
516                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
517                    notify_mount_points_trampoline::<Self, F> as *const (),
518                )),
519                Box_::into_raw(f),
520            )
521        }
522    }
523
524    #[doc(alias = "service")]
525    fn connect_service_notify<F: Fn(&Self) + Send + Sync + 'static>(
526        &self,
527        f: F,
528    ) -> SignalHandlerId {
529        unsafe extern "C" fn notify_service_trampoline<
530            P: IsA<RTSPServer>,
531            F: Fn(&P) + Send + Sync + 'static,
532        >(
533            this: *mut ffi::GstRTSPServer,
534            _param_spec: glib::ffi::gpointer,
535            f: glib::ffi::gpointer,
536        ) {
537            let f: &F = &*(f as *const F);
538            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
539        }
540        unsafe {
541            let f: Box_<F> = Box_::new(f);
542            connect_raw(
543                self.as_ptr() as *mut _,
544                c"notify::service".as_ptr() as *const _,
545                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
546                    notify_service_trampoline::<Self, F> as *const (),
547                )),
548                Box_::into_raw(f),
549            )
550        }
551    }
552
553    #[doc(alias = "session-pool")]
554    fn connect_session_pool_notify<F: Fn(&Self) + Send + Sync + 'static>(
555        &self,
556        f: F,
557    ) -> SignalHandlerId {
558        unsafe extern "C" fn notify_session_pool_trampoline<
559            P: IsA<RTSPServer>,
560            F: Fn(&P) + Send + Sync + 'static,
561        >(
562            this: *mut ffi::GstRTSPServer,
563            _param_spec: glib::ffi::gpointer,
564            f: glib::ffi::gpointer,
565        ) {
566            let f: &F = &*(f as *const F);
567            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
568        }
569        unsafe {
570            let f: Box_<F> = Box_::new(f);
571            connect_raw(
572                self.as_ptr() as *mut _,
573                c"notify::session-pool".as_ptr() as *const _,
574                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
575                    notify_session_pool_trampoline::<Self, F> as *const (),
576                )),
577                Box_::into_raw(f),
578            )
579        }
580    }
581}
582
583impl<O: IsA<RTSPServer>> RTSPServerExt for O {}