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