1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::{
    ffi, RTSPAuth, RTSPClient, RTSPFilterResult, RTSPMountPoints, RTSPSessionPool, RTSPThreadPool,
};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// This object listens on a port, creates and manages the clients connected to
    /// it.
    ///
    /// ## Properties
    ///
    ///
    /// #### `address`
    ///  Readable | Writeable
    ///
    ///
    /// #### `backlog`
    ///  Readable | Writeable
    ///
    ///
    /// #### `bound-port`
    ///  Readable
    ///
    ///
    /// #### `content-length-limit`
    ///  Readable | Writeable
    ///
    ///
    /// #### `mount-points`
    ///  Readable | Writeable
    ///
    ///
    /// #### `service`
    ///  Readable | Writeable
    ///
    ///
    /// #### `session-pool`
    ///  Readable | Writeable
    ///
    /// ## Signals
    ///
    ///
    /// #### `client-connected`
    ///
    ///
    /// # Implements
    ///
    /// [`RTSPServerExt`][trait@crate::prelude::RTSPServerExt], [`trait@glib::ObjectExt`], [`RTSPServerExtManual`][trait@crate::prelude::RTSPServerExtManual]
    #[doc(alias = "GstRTSPServer")]
    pub struct RTSPServer(Object<ffi::GstRTSPServer, ffi::GstRTSPServerClass>);

    match fn {
        type_ => || ffi::gst_rtsp_server_get_type(),
    }
}

impl RTSPServer {
    pub const NONE: Option<&'static RTSPServer> = None;

    /// Create a new [`RTSPServer`][crate::RTSPServer] instance.
    ///
    /// # Returns
    ///
    /// a new [`RTSPServer`][crate::RTSPServer]
    #[doc(alias = "gst_rtsp_server_new")]
    pub fn new() -> RTSPServer {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gst_rtsp_server_new()) }
    }

    /// A default `GSocketSourceFunc` that creates a new [`RTSPClient`][crate::RTSPClient] to accept and handle a
    /// new connection on `socket` or `server`.
    /// ## `socket`
    /// a [`gio::Socket`][crate::gio::Socket]
    /// ## `condition`
    /// the condition on `source`
    /// ## `server`
    /// a [`RTSPServer`][crate::RTSPServer]
    ///
    /// # Returns
    ///
    /// TRUE if the source could be connected, FALSE if an error occurred.
    #[doc(alias = "gst_rtsp_server_io_func")]
    pub fn io_func(
        socket: &impl IsA<gio::Socket>,
        condition: glib::IOCondition,
        server: &impl IsA<RTSPServer>,
    ) -> Result<(), glib::error::BoolError> {
        skip_assert_initialized!();
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_rtsp_server_io_func(
                    socket.as_ref().to_glib_none().0,
                    condition.into_glib(),
                    server.as_ref().to_glib_none().0
                ),
                "Failed to connect the source"
            )
        }
    }
}

impl Default for RTSPServer {
    fn default() -> Self {
        Self::new()
    }
}

unsafe impl Send for RTSPServer {}
unsafe impl Sync for RTSPServer {}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::RTSPServer>> Sealed for T {}
}

/// Trait containing all [`struct@RTSPServer`] methods.
///
/// # Implementors
///
/// [`RTSPOnvifServer`][struct@crate::RTSPOnvifServer], [`RTSPServer`][struct@crate::RTSPServer]
pub trait RTSPServerExt: IsA<RTSPServer> + sealed::Sealed + 'static {
    /// Call `func` for each client managed by `self`. The result value of `func`
    /// determines what happens to the client. `func` will be called with `self`
    /// locked so no further actions on `self` can be performed from `func`.
    ///
    /// If `func` returns [`RTSPFilterResult::Remove`][crate::RTSPFilterResult::Remove], the client will be removed from
    /// `self`.
    ///
    /// If `func` returns [`RTSPFilterResult::Keep`][crate::RTSPFilterResult::Keep], the client will remain in `self`.
    ///
    /// If `func` returns [`RTSPFilterResult::Ref`][crate::RTSPFilterResult::Ref], the client will remain in `self` but
    /// will also be added with an additional ref to the result `GList` of this
    /// function..
    ///
    /// When `func` is [`None`], [`RTSPFilterResult::Ref`][crate::RTSPFilterResult::Ref] will be assumed for each client.
    /// ## `func`
    /// a callback
    ///
    /// # Returns
    ///
    /// a `GList` with all
    /// clients for which `func` returned [`RTSPFilterResult::Ref`][crate::RTSPFilterResult::Ref]. After usage, each
    /// element in the `GList` should be unreffed before the list is freed.
    #[doc(alias = "gst_rtsp_server_client_filter")]
    fn client_filter(
        &self,
        func: Option<&mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult)>,
    ) -> Vec<RTSPClient> {
        let func_data: Option<&mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult)> =
            func;
        unsafe extern "C" fn func_func(
            server: *mut ffi::GstRTSPServer,
            client: *mut ffi::GstRTSPClient,
            user_data: glib::ffi::gpointer,
        ) -> ffi::GstRTSPFilterResult {
            let server = from_glib_borrow(server);
            let client = from_glib_borrow(client);
            let callback = user_data
                as *mut Option<&mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult)>;
            if let Some(ref mut callback) = *callback {
                callback(&server, &client)
            } else {
                panic!("cannot get closure...")
            }
            .into_glib()
        }
        let func = if func_data.is_some() {
            Some(func_func as _)
        } else {
            None
        };
        let super_callback0: &Option<
            &mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult),
        > = &func_data;
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_server_client_filter(
                self.as_ref().to_glib_none().0,
                func,
                super_callback0 as *const _ as *mut _,
            ))
        }
    }

    /// Create a [`gio::Socket`][crate::gio::Socket] for `self`. The socket will listen on the
    /// configured service.
    /// ## `cancellable`
    /// a [`gio::Cancellable`][crate::gio::Cancellable]
    ///
    /// # Returns
    ///
    /// the [`gio::Socket`][crate::gio::Socket] for `self` or [`None`] when an error
    /// occurred.
    #[doc(alias = "gst_rtsp_server_create_socket")]
    fn create_socket(
        &self,
        cancellable: Option<&impl IsA<gio::Cancellable>>,
    ) -> Result<gio::Socket, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::gst_rtsp_server_create_socket(
                self.as_ref().to_glib_none().0,
                cancellable.map(|p| p.as_ref()).to_glib_none().0,
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib_full(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Create a [`glib::Source`][crate::glib::Source] for `self`. The new source will have a default
    /// `GSocketSourceFunc` of [`RTSPServer::io_func()`][crate::RTSPServer::io_func()].
    ///
    /// `cancellable` if not [`None`] can be used to cancel the source, which will cause
    /// the source to trigger, reporting the current condition (which is likely 0
    /// unless cancellation happened at the same time as a condition change). You can
    /// check for this in the callback using [`CancellableExtManual::is_cancelled()`][crate::gio::prelude::CancellableExtManual::is_cancelled()].
    ///
    /// This takes a reference on `self` until `source` is destroyed.
    /// ## `cancellable`
    /// a [`gio::Cancellable`][crate::gio::Cancellable] or [`None`].
    ///
    /// # Returns
    ///
    /// the [`glib::Source`][crate::glib::Source] for `self` or [`None`] when an error
    /// occurred. Free with g_source_unref ()
    #[doc(alias = "gst_rtsp_server_create_source")]
    fn create_source(
        &self,
        cancellable: Option<&impl IsA<gio::Cancellable>>,
    ) -> Result<glib::Source, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::gst_rtsp_server_create_source(
                self.as_ref().to_glib_none().0,
                cancellable.map(|p| p.as_ref()).to_glib_none().0,
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib_full(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Get the address on which the server will accept connections.
    ///
    /// # Returns
    ///
    /// the server address. `g_free()` after usage.
    #[doc(alias = "gst_rtsp_server_get_address")]
    #[doc(alias = "get_address")]
    fn address(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_server_get_address(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the [`RTSPAuth`][crate::RTSPAuth] used as the authentication manager of `self`.
    ///
    /// # Returns
    ///
    /// the [`RTSPAuth`][crate::RTSPAuth] of `self`. `g_object_unref()` after
    /// usage.
    #[doc(alias = "gst_rtsp_server_get_auth")]
    #[doc(alias = "get_auth")]
    fn auth(&self) -> Option<RTSPAuth> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_server_get_auth(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// The maximum amount of queued requests for the server.
    ///
    /// # Returns
    ///
    /// the server backlog.
    #[doc(alias = "gst_rtsp_server_get_backlog")]
    #[doc(alias = "get_backlog")]
    fn backlog(&self) -> i32 {
        unsafe { ffi::gst_rtsp_server_get_backlog(self.as_ref().to_glib_none().0) }
    }

    /// Get the port number where the server was bound to.
    ///
    /// # Returns
    ///
    /// the port number
    #[doc(alias = "gst_rtsp_server_get_bound_port")]
    #[doc(alias = "get_bound_port")]
    #[doc(alias = "bound-port")]
    fn bound_port(&self) -> i32 {
        unsafe { ffi::gst_rtsp_server_get_bound_port(self.as_ref().to_glib_none().0) }
    }

    /// Get the Content-Length limit of `self`.
    ///
    /// # Returns
    ///
    /// the Content-Length limit.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "gst_rtsp_server_get_content_length_limit")]
    #[doc(alias = "get_content_length_limit")]
    #[doc(alias = "content-length-limit")]
    fn content_length_limit(&self) -> u32 {
        unsafe { ffi::gst_rtsp_server_get_content_length_limit(self.as_ref().to_glib_none().0) }
    }

    /// Get the [`RTSPMountPoints`][crate::RTSPMountPoints] used as the mount points of `self`.
    ///
    /// # Returns
    ///
    /// the [`RTSPMountPoints`][crate::RTSPMountPoints] of `self`. `g_object_unref()` after
    /// usage.
    #[doc(alias = "gst_rtsp_server_get_mount_points")]
    #[doc(alias = "get_mount_points")]
    #[doc(alias = "mount-points")]
    fn mount_points(&self) -> Option<RTSPMountPoints> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_server_get_mount_points(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the service on which the server will accept connections.
    ///
    /// # Returns
    ///
    /// the service. use `g_free()` after usage.
    #[doc(alias = "gst_rtsp_server_get_service")]
    #[doc(alias = "get_service")]
    fn service(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gst_rtsp_server_get_service(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the [`RTSPSessionPool`][crate::RTSPSessionPool] used as the session pool of `self`.
    ///
    /// # Returns
    ///
    /// the [`RTSPSessionPool`][crate::RTSPSessionPool] used for sessions. `g_object_unref()` after
    /// usage.
    #[doc(alias = "gst_rtsp_server_get_session_pool")]
    #[doc(alias = "get_session_pool")]
    #[doc(alias = "session-pool")]
    fn session_pool(&self) -> Option<RTSPSessionPool> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_server_get_session_pool(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the [`RTSPThreadPool`][crate::RTSPThreadPool] used as the thread pool of `self`.
    ///
    /// # Returns
    ///
    /// the [`RTSPThreadPool`][crate::RTSPThreadPool] of `self`. `g_object_unref()` after
    /// usage.
    #[doc(alias = "gst_rtsp_server_get_thread_pool")]
    #[doc(alias = "get_thread_pool")]
    fn thread_pool(&self) -> Option<RTSPThreadPool> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_server_get_thread_pool(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Configure `self` to accept connections on the given address.
    ///
    /// This function must be called before the server is bound.
    /// ## `address`
    /// the address
    #[doc(alias = "gst_rtsp_server_set_address")]
    #[doc(alias = "address")]
    fn set_address(&self, address: &str) {
        unsafe {
            ffi::gst_rtsp_server_set_address(
                self.as_ref().to_glib_none().0,
                address.to_glib_none().0,
            );
        }
    }

    /// configure `auth` to be used as the authentication manager of `self`.
    /// ## `auth`
    /// a [`RTSPAuth`][crate::RTSPAuth]
    #[doc(alias = "gst_rtsp_server_set_auth")]
    fn set_auth(&self, auth: Option<&impl IsA<RTSPAuth>>) {
        unsafe {
            ffi::gst_rtsp_server_set_auth(
                self.as_ref().to_glib_none().0,
                auth.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

    /// configure the maximum amount of requests that may be queued for the
    /// server.
    ///
    /// This function must be called before the server is bound.
    /// ## `backlog`
    /// the backlog
    #[doc(alias = "gst_rtsp_server_set_backlog")]
    #[doc(alias = "backlog")]
    fn set_backlog(&self, backlog: i32) {
        unsafe {
            ffi::gst_rtsp_server_set_backlog(self.as_ref().to_glib_none().0, backlog);
        }
    }

    /// Define an appropriate request size limit and reject requests exceeding the
    /// limit.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "gst_rtsp_server_set_content_length_limit")]
    #[doc(alias = "content-length-limit")]
    fn set_content_length_limit(&self, limit: u32) {
        unsafe {
            ffi::gst_rtsp_server_set_content_length_limit(self.as_ref().to_glib_none().0, limit);
        }
    }

    /// configure `mounts` to be used as the mount points of `self`.
    /// ## `mounts`
    /// a [`RTSPMountPoints`][crate::RTSPMountPoints]
    #[doc(alias = "gst_rtsp_server_set_mount_points")]
    #[doc(alias = "mount-points")]
    fn set_mount_points(&self, mounts: Option<&impl IsA<RTSPMountPoints>>) {
        unsafe {
            ffi::gst_rtsp_server_set_mount_points(
                self.as_ref().to_glib_none().0,
                mounts.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

    /// Configure `self` to accept connections on the given service.
    /// `service` should be a string containing the service name (see services(5)) or
    /// a string containing a port number between 1 and 65535.
    ///
    /// When `service` is set to "0", the server will listen on a random free
    /// port. The actual used port can be retrieved with
    /// [`bound_port()`][Self::bound_port()].
    ///
    /// This function must be called before the server is bound.
    /// ## `service`
    /// the service
    #[doc(alias = "gst_rtsp_server_set_service")]
    #[doc(alias = "service")]
    fn set_service(&self, service: &str) {
        unsafe {
            ffi::gst_rtsp_server_set_service(
                self.as_ref().to_glib_none().0,
                service.to_glib_none().0,
            );
        }
    }

    /// configure `pool` to be used as the session pool of `self`.
    /// ## `pool`
    /// a [`RTSPSessionPool`][crate::RTSPSessionPool]
    #[doc(alias = "gst_rtsp_server_set_session_pool")]
    #[doc(alias = "session-pool")]
    fn set_session_pool(&self, pool: Option<&impl IsA<RTSPSessionPool>>) {
        unsafe {
            ffi::gst_rtsp_server_set_session_pool(
                self.as_ref().to_glib_none().0,
                pool.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

    /// configure `pool` to be used as the thread pool of `self`.
    /// ## `pool`
    /// a [`RTSPThreadPool`][crate::RTSPThreadPool]
    #[doc(alias = "gst_rtsp_server_set_thread_pool")]
    fn set_thread_pool(&self, pool: Option<&impl IsA<RTSPThreadPool>>) {
        unsafe {
            ffi::gst_rtsp_server_set_thread_pool(
                self.as_ref().to_glib_none().0,
                pool.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

    /// Take an existing network socket and use it for an RTSP connection. This
    /// is used when transferring a socket from an HTTP server which should be used
    /// as an RTSP over HTTP tunnel. The `initial_buffer` contains any remaining data
    /// that the HTTP server read from the socket while parsing the HTTP header.
    /// ## `socket`
    /// a network socket
    /// ## `ip`
    /// the IP address of the remote client
    /// ## `port`
    /// the port used by the other end
    /// ## `initial_buffer`
    /// any initial data that was already read from the socket
    ///
    /// # Returns
    ///
    /// TRUE if all was ok, FALSE if an error occurred.
    #[doc(alias = "gst_rtsp_server_transfer_connection")]
    fn transfer_connection(
        &self,
        socket: impl IsA<gio::Socket>,
        ip: &str,
        port: i32,
        initial_buffer: Option<&str>,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_rtsp_server_transfer_connection(
                    self.as_ref().to_glib_none().0,
                    socket.upcast().into_glib_ptr(),
                    ip.to_glib_none().0,
                    port,
                    initial_buffer.to_glib_none().0
                ),
                "Failed to transfer to the connection"
            )
        }
    }

    #[cfg(not(feature = "v1_18"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_18"))))]
    #[doc(alias = "content-length-limit")]
    fn content_length_limit(&self) -> u32 {
        ObjectExt::property(self.as_ref(), "content-length-limit")
    }

    #[cfg(not(feature = "v1_18"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_18"))))]
    #[doc(alias = "content-length-limit")]
    fn set_content_length_limit(&self, content_length_limit: u32) {
        ObjectExt::set_property(self.as_ref(), "content-length-limit", content_length_limit)
    }

    #[doc(alias = "client-connected")]
    fn connect_client_connected<F: Fn(&Self, &RTSPClient) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn client_connected_trampoline<
            P: IsA<RTSPServer>,
            F: Fn(&P, &RTSPClient) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPServer,
            object: *mut ffi::GstRTSPClient,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                RTSPServer::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(object),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"client-connected\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    client_connected_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "address")]
    fn connect_address_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_address_trampoline<
            P: IsA<RTSPServer>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPServer,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::address\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_address_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "backlog")]
    fn connect_backlog_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_backlog_trampoline<
            P: IsA<RTSPServer>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPServer,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::backlog\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_backlog_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "bound-port")]
    fn connect_bound_port_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_bound_port_trampoline<
            P: IsA<RTSPServer>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPServer,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::bound-port\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_bound_port_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "content-length-limit")]
    fn connect_content_length_limit_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_content_length_limit_trampoline<
            P: IsA<RTSPServer>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPServer,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::content-length-limit\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_content_length_limit_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "mount-points")]
    fn connect_mount_points_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_mount_points_trampoline<
            P: IsA<RTSPServer>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPServer,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::mount-points\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_mount_points_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "service")]
    fn connect_service_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_service_trampoline<
            P: IsA<RTSPServer>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPServer,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::service\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_service_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "session-pool")]
    fn connect_session_pool_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_session_pool_trampoline<
            P: IsA<RTSPServer>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPServer,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(RTSPServer::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::session-pool\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_session_pool_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<RTSPServer>> RTSPServerExt for O {}