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
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
// 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::{
    RTSPAddress, RTSPAddressPool, RTSPFilterResult, RTSPPublishClockMode, RTSPStreamTransport,
};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// The definition of a media stream.
    ///
    /// ## Properties
    ///
    ///
    /// #### `control`
    ///  Readable | Writeable
    ///
    ///
    /// #### `profiles`
    ///  Readable | Writeable
    ///
    ///
    /// #### `protocols`
    ///  Readable | Writeable
    ///
    /// ## Signals
    ///
    ///
    /// #### `new-rtcp-encoder`
    ///
    ///
    ///
    /// #### `new-rtp-encoder`
    ///
    ///
    ///
    /// #### `new-rtp-rtcp-decoder`
    ///
    ///
    /// # Implements
    ///
    /// [`RTSPStreamExt`][trait@crate::prelude::RTSPStreamExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "GstRTSPStream")]
    pub struct RTSPStream(Object<ffi::GstRTSPStream, ffi::GstRTSPStreamClass>);

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

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

    /// Create a new media stream with index `idx` that handles RTP data on
    /// `pad` and has a payloader element `payloader` if `pad` is a source pad
    /// or a depayloader element `payloader` if `pad` is a sink pad.
    /// ## `idx`
    /// an index
    /// ## `payloader`
    /// a [`gst::Element`][crate::gst::Element]
    /// ## `pad`
    /// a [`gst::Pad`][crate::gst::Pad]
    ///
    /// # Returns
    ///
    /// a new [`RTSPStream`][crate::RTSPStream]
    #[doc(alias = "gst_rtsp_stream_new")]
    pub fn new(
        idx: u32,
        payloader: &impl IsA<gst::Element>,
        pad: &impl IsA<gst::Pad>,
    ) -> RTSPStream {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_new(
                idx,
                payloader.as_ref().to_glib_none().0,
                pad.as_ref().to_glib_none().0,
            ))
        }
    }
}

unsafe impl Send for RTSPStream {}
unsafe impl Sync for RTSPStream {}

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

/// Trait containing all [`struct@RTSPStream`] methods.
///
/// # Implementors
///
/// [`RTSPStream`][struct@crate::RTSPStream]
pub trait RTSPStreamExt: IsA<RTSPStream> + sealed::Sealed + 'static {
    /// Add multicast client address to stream. At this point, the sockets that
    /// will stream RTP and RTCP data to `destination` are supposed to be
    /// allocated.
    /// ## `destination`
    /// a multicast address to add
    /// ## `rtp_port`
    /// RTP port
    /// ## `rtcp_port`
    /// RTCP port
    /// ## `family`
    /// socket family
    ///
    /// # Returns
    ///
    /// [`true`] if `destination` can be addedd and handled by `self`.
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_add_multicast_client_address")]
    fn add_multicast_client_address(
        &self,
        destination: &str,
        rtp_port: u32,
        rtcp_port: u32,
        family: gio::SocketFamily,
    ) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_add_multicast_client_address(
                self.as_ref().to_glib_none().0,
                destination.to_glib_none().0,
                rtp_port,
                rtcp_port,
                family.into_glib(),
            ))
        }
    }

    /// Add the transport in `trans` to `self`. The media of `self` will
    /// then also be send to the values configured in `trans`. Adding the
    /// same transport twice will not add it a second time.
    ///
    /// `self` must be joined to a bin.
    ///
    /// `trans` must contain a valid `GstRTSPTransport`.
    /// ## `trans`
    /// a [`RTSPStreamTransport`][crate::RTSPStreamTransport]
    ///
    /// # Returns
    ///
    /// [`true`] if `trans` was added
    #[doc(alias = "gst_rtsp_stream_add_transport")]
    fn add_transport(
        &self,
        trans: &impl IsA<RTSPStreamTransport>,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_rtsp_stream_add_transport(
                    self.as_ref().to_glib_none().0,
                    trans.as_ref().to_glib_none().0
                ),
                "Failed to add transport"
            )
        }
    }

    //#[doc(alias = "gst_rtsp_stream_allocate_udp_sockets")]
    //fn allocate_udp_sockets(&self, family: gio::SocketFamily, transport: /*Ignored*/&mut gst_rtsp::RTSPTransport, use_client_settings: bool) -> bool {
    //    unsafe { TODO: call ffi:gst_rtsp_stream_allocate_udp_sockets() }
    //}

    //#[doc(alias = "gst_rtsp_stream_complete_stream")]
    //fn complete_stream(&self, transport: /*Ignored*/&gst_rtsp::RTSPTransport) -> bool {
    //    unsafe { TODO: call ffi:gst_rtsp_stream_complete_stream() }
    //}

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

    /// Get the size of the UDP transmission buffer (in bytes)
    ///
    /// # Returns
    ///
    /// the size of the UDP TX buffer
    #[doc(alias = "gst_rtsp_stream_get_buffer_size")]
    #[doc(alias = "get_buffer_size")]
    fn buffer_size(&self) -> u32 {
        unsafe { ffi::gst_rtsp_stream_get_buffer_size(self.as_ref().to_glib_none().0) }
    }

    /// Retrieve the current caps of `self`.
    ///
    /// # Returns
    ///
    /// the [`gst::Caps`][crate::gst::Caps] of `self`.
    /// use `gst_caps_unref()` after usage.
    #[doc(alias = "gst_rtsp_stream_get_caps")]
    #[doc(alias = "get_caps")]
    fn caps(&self) -> Option<gst::Caps> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_caps(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the control string to identify this stream.
    ///
    /// # Returns
    ///
    /// the control string. `g_free()` after usage.
    #[doc(alias = "gst_rtsp_stream_get_control")]
    #[doc(alias = "get_control")]
    fn control(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_control(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gst_rtsp_stream_get_current_seqnum")]
    #[doc(alias = "get_current_seqnum")]
    fn current_seqnum(&self) -> u16 {
        unsafe { ffi::gst_rtsp_stream_get_current_seqnum(self.as_ref().to_glib_none().0) }
    }

    /// Get the configured DSCP QoS in of the outgoing sockets.
    ///
    /// # Returns
    ///
    /// the DSCP QoS value of the outgoing sockets, or -1 if disbled.
    #[doc(alias = "gst_rtsp_stream_get_dscp_qos")]
    #[doc(alias = "get_dscp_qos")]
    fn dscp_qos(&self) -> i32 {
        unsafe { ffi::gst_rtsp_stream_get_dscp_qos(self.as_ref().to_glib_none().0) }
    }

    /// Get the stream index.
    ///
    /// # Returns
    ///
    /// the stream index.
    #[doc(alias = "gst_rtsp_stream_get_index")]
    #[doc(alias = "get_index")]
    fn index(&self) -> u32 {
        unsafe { ffi::gst_rtsp_stream_get_index(self.as_ref().to_glib_none().0) }
    }

    /// Get the previous joined bin with [`join_bin()`][Self::join_bin()] or NULL.
    ///
    /// # Returns
    ///
    /// the joined bin or NULL.
    #[doc(alias = "gst_rtsp_stream_get_joined_bin")]
    #[doc(alias = "get_joined_bin")]
    fn joined_bin(&self) -> Option<gst::Bin> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_joined_bin(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the the maximum time-to-live value of outgoing multicast packets.
    ///
    /// # Returns
    ///
    /// the maximum time-to-live value of outgoing multicast packets.
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_get_max_mcast_ttl")]
    #[doc(alias = "get_max_mcast_ttl")]
    fn max_mcast_ttl(&self) -> u32 {
        unsafe { ffi::gst_rtsp_stream_get_max_mcast_ttl(self.as_ref().to_glib_none().0) }
    }

    /// Get the configured MTU in the payloader of `self`.
    ///
    /// # Returns
    ///
    /// the MTU of the payloader.
    #[doc(alias = "gst_rtsp_stream_get_mtu")]
    #[doc(alias = "get_mtu")]
    fn mtu(&self) -> u32 {
        unsafe { ffi::gst_rtsp_stream_get_mtu(self.as_ref().to_glib_none().0) }
    }

    /// Get the multicast address of `self` for `family`. The original
    /// [`RTSPAddress`][crate::RTSPAddress] is cached and copy is returned, so freeing the return value
    /// won't release the address from the pool.
    /// ## `family`
    /// the [`gio::SocketFamily`][crate::gio::SocketFamily]
    ///
    /// # Returns
    ///
    /// the [`RTSPAddress`][crate::RTSPAddress] of `self`
    /// or [`None`] when no address could be allocated. `gst_rtsp_address_free()`
    /// after usage.
    #[doc(alias = "gst_rtsp_stream_get_multicast_address")]
    #[doc(alias = "get_multicast_address")]
    fn multicast_address(&self, family: gio::SocketFamily) -> Option<RTSPAddress> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_multicast_address(
                self.as_ref().to_glib_none().0,
                family.into_glib(),
            ))
        }
    }

    /// Get all multicast client addresses that RTP data will be sent to
    ///
    /// # Returns
    ///
    /// A comma separated list of host:port pairs with destinations
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_get_multicast_client_addresses")]
    #[doc(alias = "get_multicast_client_addresses")]
    fn multicast_client_addresses(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_multicast_client_addresses(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the multicast interface used for `self`.
    ///
    /// # Returns
    ///
    /// the multicast interface for `self`.
    /// `g_free()` after usage.
    #[doc(alias = "gst_rtsp_stream_get_multicast_iface")]
    #[doc(alias = "get_multicast_iface")]
    fn multicast_iface(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_multicast_iface(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the allowed profiles of `self`.
    ///
    /// # Returns
    ///
    /// a [`gst_rtsp::RTSPProfile`][crate::gst_rtsp::RTSPProfile]
    #[doc(alias = "gst_rtsp_stream_get_profiles")]
    #[doc(alias = "get_profiles")]
    fn profiles(&self) -> gst_rtsp::RTSPProfile {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_profiles(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the allowed protocols of `self`.
    ///
    /// # Returns
    ///
    /// a [`gst_rtsp::RTSPLowerTrans`][crate::gst_rtsp::RTSPLowerTrans]
    #[doc(alias = "gst_rtsp_stream_get_protocols")]
    #[doc(alias = "get_protocols")]
    fn protocols(&self) -> gst_rtsp::RTSPLowerTrans {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_protocols(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the stream payload type.
    ///
    /// # Returns
    ///
    /// the stream payload type.
    #[doc(alias = "gst_rtsp_stream_get_pt")]
    #[doc(alias = "get_pt")]
    fn pt(&self) -> u32 {
        unsafe { ffi::gst_rtsp_stream_get_pt(self.as_ref().to_glib_none().0) }
    }

    /// Gets if and how the stream clock should be published according to RFC7273.
    ///
    /// # Returns
    ///
    /// The GstRTSPPublishClockMode
    #[doc(alias = "gst_rtsp_stream_get_publish_clock_mode")]
    #[doc(alias = "get_publish_clock_mode")]
    fn publish_clock_mode(&self) -> RTSPPublishClockMode {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_publish_clock_mode(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// whether `self` will follow the Rate-Control=no behaviour as specified
    /// in the ONVIF replay spec.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "gst_rtsp_stream_get_rate_control")]
    #[doc(alias = "get_rate_control")]
    fn is_rate_control(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_rate_control(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Retrieve the current rate and/or applied_rate.
    ///
    /// # Returns
    ///
    /// [`true`] if rate and/or applied_rate could be determined.
    ///
    /// ## `rate`
    /// the configured rate
    ///
    /// ## `applied_rate`
    /// the configured applied_rate
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "gst_rtsp_stream_get_rates")]
    #[doc(alias = "get_rates")]
    fn rates(&self) -> Option<(f64, f64)> {
        unsafe {
            let mut rate = std::mem::MaybeUninit::uninit();
            let mut applied_rate = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gst_rtsp_stream_get_rates(
                self.as_ref().to_glib_none().0,
                rate.as_mut_ptr(),
                applied_rate.as_mut_ptr(),
            ));
            if ret {
                Some((rate.assume_init(), applied_rate.assume_init()))
            } else {
                None
            }
        }
    }

    /// Get the payload-type used for retransmission of this stream
    ///
    /// # Returns
    ///
    /// The retransmission PT.
    #[doc(alias = "gst_rtsp_stream_get_retransmission_pt")]
    #[doc(alias = "get_retransmission_pt")]
    fn retransmission_pt(&self) -> u32 {
        unsafe { ffi::gst_rtsp_stream_get_retransmission_pt(self.as_ref().to_glib_none().0) }
    }

    /// Get the amount of time to store retransmission data.
    ///
    /// # Returns
    ///
    /// the amount of time to store retransmission data.
    #[doc(alias = "gst_rtsp_stream_get_retransmission_time")]
    #[doc(alias = "get_retransmission_time")]
    fn retransmission_time(&self) -> Option<gst::ClockTime> {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_retransmission_time(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the multicast RTCP socket from `self` for a `family`.
    /// ## `family`
    /// the socket family
    ///
    /// # Returns
    ///
    /// the multicast RTCP socket or [`None`] if no
    /// socket could be allocated for `family`. Unref after usage
    #[doc(alias = "gst_rtsp_stream_get_rtcp_multicast_socket")]
    #[doc(alias = "get_rtcp_multicast_socket")]
    fn rtcp_multicast_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtcp_multicast_socket(
                self.as_ref().to_glib_none().0,
                family.into_glib(),
            ))
        }
    }

    /// Get the RTCP socket from `self` for a `family`.
    ///
    /// `self` must be joined to a bin.
    /// ## `family`
    /// the socket family
    ///
    /// # Returns
    ///
    /// the RTCP socket or [`None`] if no
    /// socket could be allocated for `family`. Unref after usage
    #[doc(alias = "gst_rtsp_stream_get_rtcp_socket")]
    #[doc(alias = "get_rtcp_socket")]
    fn rtcp_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtcp_socket(
                self.as_ref().to_glib_none().0,
                family.into_glib(),
            ))
        }
    }

    /// Get the multicast RTP socket from `self` for a `family`.
    /// ## `family`
    /// the socket family
    ///
    /// # Returns
    ///
    /// the multicast RTP socket or [`None`] if no
    ///
    /// socket could be allocated for `family`. Unref after usage
    #[doc(alias = "gst_rtsp_stream_get_rtp_multicast_socket")]
    #[doc(alias = "get_rtp_multicast_socket")]
    fn rtp_multicast_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtp_multicast_socket(
                self.as_ref().to_glib_none().0,
                family.into_glib(),
            ))
        }
    }

    /// Get the RTP socket from `self` for a `family`.
    ///
    /// `self` must be joined to a bin.
    /// ## `family`
    /// the socket family
    ///
    /// # Returns
    ///
    /// the RTP socket or [`None`] if no
    /// socket could be allocated for `family`. Unref after usage
    #[doc(alias = "gst_rtsp_stream_get_rtp_socket")]
    #[doc(alias = "get_rtp_socket")]
    fn rtp_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtp_socket(
                self.as_ref().to_glib_none().0,
                family.into_glib(),
            ))
        }
    }

    /// Retrieve the current rtptime, seq and running-time. This is used to
    /// construct a RTPInfo reply header.
    ///
    /// # Returns
    ///
    /// [`true`] when rtptime, seq and running-time could be determined.
    ///
    /// ## `rtptime`
    /// result RTP timestamp
    ///
    /// ## `seq`
    /// result RTP seqnum
    ///
    /// ## `clock_rate`
    /// the clock rate
    ///
    /// ## `running_time`
    /// result running-time
    #[doc(alias = "gst_rtsp_stream_get_rtpinfo")]
    #[doc(alias = "get_rtpinfo")]
    fn rtpinfo(&self) -> Option<(u32, u32, u32, Option<gst::ClockTime>)> {
        unsafe {
            let mut rtptime = std::mem::MaybeUninit::uninit();
            let mut seq = std::mem::MaybeUninit::uninit();
            let mut clock_rate = std::mem::MaybeUninit::uninit();
            let mut running_time = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gst_rtsp_stream_get_rtpinfo(
                self.as_ref().to_glib_none().0,
                rtptime.as_mut_ptr(),
                seq.as_mut_ptr(),
                clock_rate.as_mut_ptr(),
                running_time.as_mut_ptr(),
            ));
            if ret {
                Some((
                    rtptime.assume_init(),
                    seq.assume_init(),
                    clock_rate.assume_init(),
                    from_glib(running_time.assume_init()),
                ))
            } else {
                None
            }
        }
    }

    /// Get the RTP session of this stream.
    ///
    /// # Returns
    ///
    /// The RTP session of this stream. Unref after usage.
    #[doc(alias = "gst_rtsp_stream_get_rtpsession")]
    #[doc(alias = "get_rtpsession")]
    fn rtpsession(&self) -> Option<glib::Object> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtpsession(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    //#[doc(alias = "gst_rtsp_stream_get_server_port")]
    //#[doc(alias = "get_server_port")]
    //fn server_port(&self, server_port: /*Ignored*/gst_rtsp::RTSPRange, family: gio::SocketFamily) {
    //    unsafe { TODO: call ffi:gst_rtsp_stream_get_server_port() }
    //}

    /// Get the sinkpad associated with `self`.
    ///
    /// # Returns
    ///
    /// the sinkpad. Unref after usage.
    #[doc(alias = "gst_rtsp_stream_get_sinkpad")]
    #[doc(alias = "get_sinkpad")]
    fn sinkpad(&self) -> Option<gst::Pad> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_sinkpad(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the srcpad associated with `self`.
    ///
    /// # Returns
    ///
    /// the srcpad. Unref after usage.
    #[doc(alias = "gst_rtsp_stream_get_srcpad")]
    #[doc(alias = "get_srcpad")]
    fn srcpad(&self) -> Option<gst::Pad> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_srcpad(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the SRTP encoder for this stream.
    ///
    /// # Returns
    ///
    /// The SRTP encoder for this stream. Unref after usage.
    #[doc(alias = "gst_rtsp_stream_get_srtp_encoder")]
    #[doc(alias = "get_srtp_encoder")]
    fn srtp_encoder(&self) -> Option<gst::Element> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_srtp_encoder(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the SSRC used by the RTP session of this stream. This function can only
    /// be called when `self` has been joined.
    ///
    /// # Returns
    ///
    ///
    /// ## `ssrc`
    /// result ssrc
    #[doc(alias = "gst_rtsp_stream_get_ssrc")]
    #[doc(alias = "get_ssrc")]
    fn ssrc(&self) -> u32 {
        unsafe {
            let mut ssrc = std::mem::MaybeUninit::uninit();
            ffi::gst_rtsp_stream_get_ssrc(self.as_ref().to_glib_none().0, ssrc.as_mut_ptr());
            ssrc.assume_init()
        }
    }

    #[doc(alias = "gst_rtsp_stream_get_ulpfec_enabled")]
    #[doc(alias = "get_ulpfec_enabled")]
    fn is_ulpfec_enabled(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_ulpfec_enabled(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// the amount of redundancy applied when creating ULPFEC
    /// protection packets.
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_get_ulpfec_percentage")]
    #[doc(alias = "get_ulpfec_percentage")]
    fn ulpfec_percentage(&self) -> u32 {
        unsafe { ffi::gst_rtsp_stream_get_ulpfec_percentage(self.as_ref().to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// the payload type used for ULPFEC protection packets
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_get_ulpfec_pt")]
    #[doc(alias = "get_ulpfec_pt")]
    fn ulpfec_pt(&self) -> u32 {
        unsafe { ffi::gst_rtsp_stream_get_ulpfec_pt(self.as_ref().to_glib_none().0) }
    }

    /// Parse and handle a KeyMgmt header.
    /// ## `keymgmt`
    /// a keymgmt header
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_handle_keymgmt")]
    fn handle_keymgmt(&self, keymgmt: &str) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_handle_keymgmt(
                self.as_ref().to_glib_none().0,
                keymgmt.to_glib_none().0,
            ))
        }
    }

    /// Check if `self` has the control string `control`.
    /// ## `control`
    /// a control string
    ///
    /// # Returns
    ///
    /// [`true`] is `self` has `control` as the control string
    #[doc(alias = "gst_rtsp_stream_has_control")]
    fn has_control(&self, control: Option<&str>) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_has_control(
                self.as_ref().to_glib_none().0,
                control.to_glib_none().0,
            ))
        }
    }

    /// Check if multicast sockets are configured to be bound to multicast addresses.
    ///
    /// # Returns
    ///
    /// [`true`] if multicast sockets are configured to be bound to multicast addresses.
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_is_bind_mcast_address")]
    fn is_bind_mcast_address(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_bind_mcast_address(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Check if `self` is blocking on a [`gst::Buffer`][crate::gst::Buffer].
    ///
    /// # Returns
    ///
    /// [`true`] if `self` is blocking
    #[doc(alias = "gst_rtsp_stream_is_blocking")]
    fn is_blocking(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_blocking(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// See [`set_client_side()`][Self::set_client_side()]
    ///
    /// # Returns
    ///
    /// TRUE if this [`RTSPStream`][crate::RTSPStream] is client-side.
    #[doc(alias = "gst_rtsp_stream_is_client_side")]
    fn is_client_side(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_client_side(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Checks whether the stream is complete, contains the receiver and the sender
    /// parts. As the stream contains sink(s) element(s), it's possible to perform
    /// seek operations on it.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream contains at least one sink element.
    #[doc(alias = "gst_rtsp_stream_is_complete")]
    fn is_complete(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_complete(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Checks whether the stream is a receiver.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream is a receiver and [`false`] otherwise.
    #[doc(alias = "gst_rtsp_stream_is_receiver")]
    fn is_receiver(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_receiver(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Checks whether the stream is a sender.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream is a sender and [`false`] otherwise.
    #[doc(alias = "gst_rtsp_stream_is_sender")]
    fn is_sender(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_sender(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    //#[doc(alias = "gst_rtsp_stream_is_transport_supported")]
    //fn is_transport_supported(&self, transport: /*Ignored*/&mut gst_rtsp::RTSPTransport) -> bool {
    //    unsafe { TODO: call ffi:gst_rtsp_stream_is_transport_supported() }
    //}

    /// Join the [`gst::Bin`][crate::gst::Bin] `bin` that contains the element `rtpbin`.
    ///
    /// `self` will link to `rtpbin`, which must be inside `bin`. The elements
    /// added to `bin` will be set to the state given in `state`.
    /// ## `bin`
    /// a [`gst::Bin`][crate::gst::Bin] to join
    /// ## `rtpbin`
    /// a rtpbin element in `bin`
    /// ## `state`
    /// the target state of the new elements
    ///
    /// # Returns
    ///
    /// [`true`] on success.
    #[doc(alias = "gst_rtsp_stream_join_bin")]
    fn join_bin(
        &self,
        bin: &impl IsA<gst::Bin>,
        rtpbin: &impl IsA<gst::Element>,
        state: gst::State,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_rtsp_stream_join_bin(
                    self.as_ref().to_glib_none().0,
                    bin.as_ref().to_glib_none().0,
                    rtpbin.as_ref().to_glib_none().0,
                    state.into_glib()
                ),
                "Failed to join bin"
            )
        }
    }

    /// Remove the elements of `self` from `bin`.
    /// ## `bin`
    /// a [`gst::Bin`][crate::gst::Bin]
    /// ## `rtpbin`
    /// a rtpbin [`gst::Element`][crate::gst::Element]
    ///
    /// # Returns
    ///
    /// [`true`] on success.
    #[doc(alias = "gst_rtsp_stream_leave_bin")]
    fn leave_bin(
        &self,
        bin: &impl IsA<gst::Bin>,
        rtpbin: &impl IsA<gst::Element>,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_rtsp_stream_leave_bin(
                    self.as_ref().to_glib_none().0,
                    bin.as_ref().to_glib_none().0,
                    rtpbin.as_ref().to_glib_none().0
                ),
                "Failed to leave bin"
            )
        }
    }

    /// Handle an RTCP buffer for the stream. This method is usually called when a
    /// message has been received from a client using the TCP transport.
    ///
    /// This function takes ownership of `buffer`.
    /// ## `buffer`
    /// a [`gst::Buffer`][crate::gst::Buffer]
    ///
    /// # Returns
    ///
    /// a GstFlowReturn.
    #[doc(alias = "gst_rtsp_stream_recv_rtcp")]
    fn recv_rtcp(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
        unsafe {
            try_from_glib(ffi::gst_rtsp_stream_recv_rtcp(
                self.as_ref().to_glib_none().0,
                buffer.into_glib_ptr(),
            ))
        }
    }

    /// Handle an RTP buffer for the stream. This method is usually called when a
    /// message has been received from a client using the TCP transport.
    ///
    /// This function takes ownership of `buffer`.
    /// ## `buffer`
    /// a [`gst::Buffer`][crate::gst::Buffer]
    ///
    /// # Returns
    ///
    /// a GstFlowReturn.
    #[doc(alias = "gst_rtsp_stream_recv_rtp")]
    fn recv_rtp(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
        unsafe {
            try_from_glib(ffi::gst_rtsp_stream_recv_rtp(
                self.as_ref().to_glib_none().0,
                buffer.into_glib_ptr(),
            ))
        }
    }

    /// Remove the transport in `trans` from `self`. The media of `self` will
    /// not be sent to the values configured in `trans`.
    ///
    /// `self` must be joined to a bin.
    ///
    /// `trans` must contain a valid `GstRTSPTransport`.
    /// ## `trans`
    /// a [`RTSPStreamTransport`][crate::RTSPStreamTransport]
    ///
    /// # Returns
    ///
    /// [`true`] if `trans` was removed
    #[doc(alias = "gst_rtsp_stream_remove_transport")]
    fn remove_transport(
        &self,
        trans: &impl IsA<RTSPStreamTransport>,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_rtsp_stream_remove_transport(
                    self.as_ref().to_glib_none().0,
                    trans.as_ref().to_glib_none().0
                ),
                "Failed to remove transport"
            )
        }
    }

    /// Creating a rtxreceive bin
    /// ## `sessid`
    /// the session id
    ///
    /// # Returns
    ///
    /// a [`gst::Element`][crate::gst::Element].
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_request_aux_receiver")]
    fn request_aux_receiver(&self, sessid: u32) -> Option<gst::Element> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_request_aux_receiver(
                self.as_ref().to_glib_none().0,
                sessid,
            ))
        }
    }

    /// Creating a rtxsend bin
    /// ## `sessid`
    /// the session id
    ///
    /// # Returns
    ///
    /// a [`gst::Element`][crate::gst::Element].
    #[doc(alias = "gst_rtsp_stream_request_aux_sender")]
    fn request_aux_sender(&self, sessid: u32) -> Option<gst::Element> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_request_aux_sender(
                self.as_ref().to_glib_none().0,
                sessid,
            ))
        }
    }

    /// Creating a rtpulpfecdec element
    ///
    /// # Returns
    ///
    /// a [`gst::Element`][crate::gst::Element].
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_request_ulpfec_decoder")]
    fn request_ulpfec_decoder(
        &self,
        rtpbin: &impl IsA<gst::Element>,
        sessid: u32,
    ) -> Option<gst::Element> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_request_ulpfec_decoder(
                self.as_ref().to_glib_none().0,
                rtpbin.as_ref().to_glib_none().0,
                sessid,
            ))
        }
    }

    /// Creating a rtpulpfecenc element
    ///
    /// # Returns
    ///
    /// a [`gst::Element`][crate::gst::Element].
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_request_ulpfec_encoder")]
    fn request_ulpfec_encoder(&self, sessid: u32) -> Option<gst::Element> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_request_ulpfec_encoder(
                self.as_ref().to_glib_none().0,
                sessid,
            ))
        }
    }

    /// Reserve `address` and `port` as the address and port of `self`. The original
    /// [`RTSPAddress`][crate::RTSPAddress] is cached and copy is returned, so freeing the return value
    /// won't release the address from the pool.
    /// ## `address`
    /// an address
    /// ## `port`
    /// a port
    /// ## `n_ports`
    /// n_ports
    /// ## `ttl`
    /// a TTL
    ///
    /// # Returns
    ///
    /// the [`RTSPAddress`][crate::RTSPAddress] of `self` or [`None`] when
    /// the address could not be reserved. `gst_rtsp_address_free()` after
    /// usage.
    #[doc(alias = "gst_rtsp_stream_reserve_address")]
    fn reserve_address(
        &self,
        address: &str,
        port: u32,
        n_ports: u32,
        ttl: u32,
    ) -> Option<RTSPAddress> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_reserve_address(
                self.as_ref().to_glib_none().0,
                address.to_glib_none().0,
                port,
                n_ports,
                ttl,
            ))
        }
    }

    /// Checks whether the individual `self` is seekable.
    ///
    /// # Returns
    ///
    /// [`true`] if `self` is seekable, else [`false`].
    #[doc(alias = "gst_rtsp_stream_seekable")]
    fn seekable(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_seekable(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

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

    /// Decide whether the multicast socket should be bound to a multicast address or
    /// INADDR_ANY.
    /// ## `bind_mcast_addr`
    /// the new value
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_set_bind_mcast_address")]
    fn set_bind_mcast_address(&self, bind_mcast_addr: bool) {
        unsafe {
            ffi::gst_rtsp_stream_set_bind_mcast_address(
                self.as_ref().to_glib_none().0,
                bind_mcast_addr.into_glib(),
            );
        }
    }

    /// Blocks or unblocks the dataflow on `self`.
    /// ## `blocked`
    /// boolean indicating we should block or unblock
    ///
    /// # Returns
    ///
    /// [`true`] on success
    #[doc(alias = "gst_rtsp_stream_set_blocked")]
    fn set_blocked(&self, blocked: bool) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_rtsp_stream_set_blocked(
                    self.as_ref().to_glib_none().0,
                    blocked.into_glib()
                ),
                "Failed to block/unblock the dataflow"
            )
        }
    }

    /// Set the size of the UDP transmission buffer (in bytes)
    /// Needs to be set before the stream is joined to a bin.
    /// ## `size`
    /// the buffer size
    #[doc(alias = "gst_rtsp_stream_set_buffer_size")]
    fn set_buffer_size(&self, size: u32) {
        unsafe {
            ffi::gst_rtsp_stream_set_buffer_size(self.as_ref().to_glib_none().0, size);
        }
    }

    /// Sets the [`RTSPStream`][crate::RTSPStream] as a 'client side' stream - used for sending
    /// streams to an RTSP server via RECORD. This has the practical effect
    /// of changing which UDP port numbers are used when setting up the local
    /// side of the stream sending to be either the 'server' or 'client' pair
    /// of a configured UDP transport.
    /// ## `client_side`
    /// TRUE if this [`RTSPStream`][crate::RTSPStream] is running on the 'client' side of
    /// an RTSP connection.
    #[doc(alias = "gst_rtsp_stream_set_client_side")]
    fn set_client_side(&self, client_side: bool) {
        unsafe {
            ffi::gst_rtsp_stream_set_client_side(
                self.as_ref().to_glib_none().0,
                client_side.into_glib(),
            );
        }
    }

    /// Set the control string in `self`.
    /// ## `control`
    /// a control string
    #[doc(alias = "gst_rtsp_stream_set_control")]
    fn set_control(&self, control: Option<&str>) {
        unsafe {
            ffi::gst_rtsp_stream_set_control(
                self.as_ref().to_glib_none().0,
                control.to_glib_none().0,
            );
        }
    }

    /// Configure the dscp qos of the outgoing sockets to `dscp_qos`.
    /// ## `dscp_qos`
    /// a new dscp qos value (0-63, or -1 to disable)
    #[doc(alias = "gst_rtsp_stream_set_dscp_qos")]
    fn set_dscp_qos(&self, dscp_qos: i32) {
        unsafe {
            ffi::gst_rtsp_stream_set_dscp_qos(self.as_ref().to_glib_none().0, dscp_qos);
        }
    }

    /// Set the maximum time-to-live value of outgoing multicast packets.
    /// ## `ttl`
    /// the new multicast ttl value
    ///
    /// # Returns
    ///
    /// [`true`] if the requested ttl has been set successfully.
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_set_max_mcast_ttl")]
    fn set_max_mcast_ttl(&self, ttl: u32) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_set_max_mcast_ttl(
                self.as_ref().to_glib_none().0,
                ttl,
            ))
        }
    }

    /// Configure the mtu in the payloader of `self` to `mtu`.
    /// ## `mtu`
    /// a new MTU
    #[doc(alias = "gst_rtsp_stream_set_mtu")]
    fn set_mtu(&self, mtu: u32) {
        unsafe {
            ffi::gst_rtsp_stream_set_mtu(self.as_ref().to_glib_none().0, mtu);
        }
    }

    /// configure `multicast_iface` to be used for `self`.
    /// ## `multicast_iface`
    /// a multicast interface name
    #[doc(alias = "gst_rtsp_stream_set_multicast_iface")]
    fn set_multicast_iface(&self, multicast_iface: Option<&str>) {
        unsafe {
            ffi::gst_rtsp_stream_set_multicast_iface(
                self.as_ref().to_glib_none().0,
                multicast_iface.to_glib_none().0,
            );
        }
    }

    /// Configure the allowed profiles for `self`.
    /// ## `profiles`
    /// the new profiles
    #[doc(alias = "gst_rtsp_stream_set_profiles")]
    fn set_profiles(&self, profiles: gst_rtsp::RTSPProfile) {
        unsafe {
            ffi::gst_rtsp_stream_set_profiles(self.as_ref().to_glib_none().0, profiles.into_glib());
        }
    }

    /// Configure the allowed lower transport for `self`.
    /// ## `protocols`
    /// the new flags
    #[doc(alias = "gst_rtsp_stream_set_protocols")]
    fn set_protocols(&self, protocols: gst_rtsp::RTSPLowerTrans) {
        unsafe {
            ffi::gst_rtsp_stream_set_protocols(
                self.as_ref().to_glib_none().0,
                protocols.into_glib(),
            );
        }
    }

    /// Configure a pt map between `pt` and `caps`.
    /// ## `pt`
    /// the pt
    /// ## `caps`
    /// a [`gst::Caps`][crate::gst::Caps]
    #[doc(alias = "gst_rtsp_stream_set_pt_map")]
    fn set_pt_map(&self, pt: u32, caps: &gst::Caps) {
        unsafe {
            ffi::gst_rtsp_stream_set_pt_map(
                self.as_ref().to_glib_none().0,
                pt,
                caps.to_glib_none().0,
            );
        }
    }

    /// Sets if and how the stream clock should be published according to RFC7273.
    /// ## `mode`
    /// the clock publish mode
    #[doc(alias = "gst_rtsp_stream_set_publish_clock_mode")]
    fn set_publish_clock_mode(&self, mode: RTSPPublishClockMode) {
        unsafe {
            ffi::gst_rtsp_stream_set_publish_clock_mode(
                self.as_ref().to_glib_none().0,
                mode.into_glib(),
            );
        }
    }

    /// Define whether `self` will follow the Rate-Control=no behaviour as specified
    /// in the ONVIF replay spec.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "gst_rtsp_stream_set_rate_control")]
    fn set_rate_control(&self, enabled: bool) {
        unsafe {
            ffi::gst_rtsp_stream_set_rate_control(
                self.as_ref().to_glib_none().0,
                enabled.into_glib(),
            );
        }
    }

    /// Set the payload type (pt) for retransmission of this stream.
    /// ## `rtx_pt`
    /// a `guint`
    #[doc(alias = "gst_rtsp_stream_set_retransmission_pt")]
    fn set_retransmission_pt(&self, rtx_pt: u32) {
        unsafe {
            ffi::gst_rtsp_stream_set_retransmission_pt(self.as_ref().to_glib_none().0, rtx_pt);
        }
    }

    /// Set the amount of time to store retransmission packets.
    /// ## `time`
    /// a `GstClockTime`
    #[doc(alias = "gst_rtsp_stream_set_retransmission_time")]
    fn set_retransmission_time(&self, time: impl Into<Option<gst::ClockTime>>) {
        unsafe {
            ffi::gst_rtsp_stream_set_retransmission_time(
                self.as_ref().to_glib_none().0,
                time.into().into_glib(),
            );
        }
    }

    #[doc(alias = "gst_rtsp_stream_set_seqnum_offset")]
    fn set_seqnum_offset(&self, seqnum: u16) {
        unsafe {
            ffi::gst_rtsp_stream_set_seqnum_offset(self.as_ref().to_glib_none().0, seqnum);
        }
    }

    /// Sets the amount of redundancy to apply when creating ULPFEC
    /// protection packets.
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_set_ulpfec_percentage")]
    fn set_ulpfec_percentage(&self, percentage: u32) {
        unsafe {
            ffi::gst_rtsp_stream_set_ulpfec_percentage(self.as_ref().to_glib_none().0, percentage);
        }
    }

    /// Set the payload type to be used for ULPFEC protection packets
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_set_ulpfec_pt")]
    fn set_ulpfec_pt(&self, pt: u32) {
        unsafe {
            ffi::gst_rtsp_stream_set_ulpfec_pt(self.as_ref().to_glib_none().0, pt);
        }
    }

    /// Call `func` for each transport managed by `self`. The result value of `func`
    /// determines what happens to the transport. `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 transport will be removed from
    /// `self`.
    ///
    /// If `func` returns [`RTSPFilterResult::Keep`][crate::RTSPFilterResult::Keep], the transport will remain in `self`.
    ///
    /// If `func` returns [`RTSPFilterResult::Ref`][crate::RTSPFilterResult::Ref], the transport 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 transport.
    /// ## `func`
    /// a callback
    ///
    /// # Returns
    ///
    /// a `GList` with all
    /// transports 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_stream_transport_filter")]
    fn transport_filter(
        &self,
        func: Option<&mut dyn (FnMut(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult)>,
    ) -> Vec<RTSPStreamTransport> {
        let func_data: Option<
            &mut dyn (FnMut(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult),
        > = func;
        unsafe extern "C" fn func_func(
            stream: *mut ffi::GstRTSPStream,
            trans: *mut ffi::GstRTSPStreamTransport,
            user_data: glib::ffi::gpointer,
        ) -> ffi::GstRTSPFilterResult {
            let stream = from_glib_borrow(stream);
            let trans = from_glib_borrow(trans);
            let callback = user_data
                as *mut Option<
                    &mut dyn (FnMut(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult),
                >;
            if let Some(ref mut callback) = *callback {
                callback(&stream, &trans)
            } 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(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult),
        > = &func_data;
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_stream_transport_filter(
                self.as_ref().to_glib_none().0,
                func,
                super_callback0 as *const _ as *mut _,
            ))
        }
    }

    #[doc(alias = "gst_rtsp_stream_unblock_linked")]
    fn unblock_linked(&self) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_rtsp_stream_unblock_linked(self.as_ref().to_glib_none().0),
                "Failed to unblock the dataflow"
            )
        }
    }

    /// Remove blocking probe from the RTCP source. When creating an UDP source for
    /// RTCP it is initially blocked until this function is called.
    /// This functions should be called once the pipeline is ready for handling RTCP
    /// packets.
    #[cfg(feature = "v1_20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
    #[doc(alias = "gst_rtsp_stream_unblock_rtcp")]
    fn unblock_rtcp(&self) {
        unsafe {
            ffi::gst_rtsp_stream_unblock_rtcp(self.as_ref().to_glib_none().0);
        }
    }

    /// Update the new crypto information for `ssrc` in `self`. If information
    /// for `ssrc` did not exist, it will be added. If information
    /// for `ssrc` existed, it will be replaced. If `crypto` is [`None`], it will
    /// be removed from `self`.
    /// ## `ssrc`
    /// the SSRC
    /// ## `crypto`
    /// a [`gst::Caps`][crate::gst::Caps] with crypto info
    ///
    /// # Returns
    ///
    /// [`true`] if `crypto` could be updated
    #[doc(alias = "gst_rtsp_stream_update_crypto")]
    fn update_crypto(
        &self,
        ssrc: u32,
        crypto: Option<&gst::Caps>,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_rtsp_stream_update_crypto(
                    self.as_ref().to_glib_none().0,
                    ssrc,
                    crypto.to_glib_none().0
                ),
                "Failed to update crypto"
            )
        }
    }

    /// Check if the requested multicast ttl value is allowed.
    /// ## `ttl`
    /// a requested multicast ttl
    ///
    /// # Returns
    ///
    /// TRUE if the requested ttl value is allowed.
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    #[doc(alias = "gst_rtsp_stream_verify_mcast_ttl")]
    fn verify_mcast_ttl(&self, ttl: u32) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_verify_mcast_ttl(
                self.as_ref().to_glib_none().0,
                ttl,
            ))
        }
    }

    #[doc(alias = "new-rtcp-encoder")]
    fn connect_new_rtcp_encoder<F: Fn(&Self, &gst::Element) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn new_rtcp_encoder_trampoline<
            P: IsA<RTSPStream>,
            F: Fn(&P, &gst::Element) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPStream,
            object: *mut gst::ffi::GstElement,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                RTSPStream::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"new-rtcp-encoder\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    new_rtcp_encoder_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "new-rtp-encoder")]
    fn connect_new_rtp_encoder<F: Fn(&Self, &gst::Element) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn new_rtp_encoder_trampoline<
            P: IsA<RTSPStream>,
            F: Fn(&P, &gst::Element) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPStream,
            object: *mut gst::ffi::GstElement,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                RTSPStream::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"new-rtp-encoder\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    new_rtp_encoder_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "new-rtp-rtcp-decoder")]
    fn connect_new_rtp_rtcp_decoder<F: Fn(&Self, &gst::Element) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn new_rtp_rtcp_decoder_trampoline<
            P: IsA<RTSPStream>,
            F: Fn(&P, &gst::Element) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstRTSPStream,
            object: *mut gst::ffi::GstElement,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                RTSPStream::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"new-rtp-rtcp-decoder\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    new_rtp_rtcp_decoder_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

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

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

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

impl<O: IsA<RTSPStream>> RTSPStreamExt for O {}