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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use RTSPAddress;
use RTSPAddressPool;
use RTSPPublishClockMode;
use RTSPStreamTransport;
use ffi;
use gio;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use gst_rtsp;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;

glib_wrapper! {
    /// The definition of a media stream.
    ///
    /// # Implements
    ///
    /// [`RTSPStreamExt`](trait.RTSPStreamExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html)
    pub struct RTSPStream(Object<ffi::GstRTSPStream, ffi::GstRTSPStreamClass>);

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

impl RTSPStream {
    /// 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`
    /// ## `pad`
    /// a `gst::Pad`
    ///
    /// # Returns
    ///
    /// a new `RTSPStream`
    pub fn new<P: IsA<gst::Element>, Q: IsA<gst::Pad>>(idx: u32, payloader: &P, pad: &Q) -> RTSPStream {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_new(idx, payloader.to_glib_none().0, pad.to_glib_none().0))
        }
    }
}

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

/// Trait containing all `RTSPStream` methods.
///
/// # Implementors
///
/// [`RTSPStream`](struct.RTSPStream.html)
pub trait RTSPStreamExt {
    /// Add the transport in `trans` to `self`. The media of `self` will
    /// then also be send to the values configured in `trans`.
    ///
    /// `self` must be joined to a bin.
    ///
    /// `trans` must contain a valid `gst_rtsp::RTSPTransport`.
    /// ## `trans`
    /// a `RTSPStreamTransport`
    ///
    /// # Returns
    ///
    /// `true` if `trans` was added
    fn add_transport(&self, trans: &RTSPStreamTransport) -> Result<(), glib::error::BoolError>;

    //fn allocate_udp_sockets(&self, family: gio::SocketFamily, transport: /*Ignored*/&mut gst_rtsp::RTSPTransport, use_client_settings: bool) -> bool;

    //fn complete_stream(&self, transport: /*Ignored*/&gst_rtsp::RTSPTransport) -> bool;

    /// Get the `RTSPAddressPool` used as the address pool of `self`.
    ///
    /// # Returns
    ///
    /// the `RTSPAddressPool` of `self`.
    /// `gobject::ObjectExt::unref` after usage.
    fn get_address_pool(&self) -> Option<RTSPAddressPool>;

    /// Get the size of the UDP transmission buffer (in bytes)
    ///
    /// # Returns
    ///
    /// the size of the UDP TX buffer
    fn get_buffer_size(&self) -> u32;

    /// Retrieve the current caps of `self`.
    ///
    /// # Returns
    ///
    /// the `gst::Caps` of `self`.
    /// use `gst_caps_unref` after usage.
    fn get_caps(&self) -> Option<gst::Caps>;

    /// Get the control string to identify this stream.
    ///
    /// # Returns
    ///
    /// the control string. `g_free` after usage.
    fn get_control(&self) -> Option<String>;

    fn get_current_seqnum(&self) -> u16;

    /// Get the configured DSCP QoS in of the outgoing sockets.
    ///
    /// # Returns
    ///
    /// the DSCP QoS value of the outgoing sockets, or -1 if disbled.
    fn get_dscp_qos(&self) -> i32;

    /// Get the stream index.
    ///
    /// # Returns
    ///
    /// the stream index.
    fn get_index(&self) -> u32;

    /// Get the previous joined bin with `RTSPStreamExt::join_bin` or NULL.
    ///
    /// # Returns
    ///
    /// the joined bin or NULL.
    fn get_joined_bin(&self) -> Option<gst::Bin>;

    /// Get the configured MTU in the payloader of `self`.
    ///
    /// # Returns
    ///
    /// the MTU of the payloader.
    fn get_mtu(&self) -> u32;

    /// Get the multicast address of `self` for `family`. The original
    /// `RTSPAddress` is cached and copy is returned, so freeing the return value
    /// won't release the address from the pool.
    /// ## `family`
    /// the `gio::SocketFamily`
    ///
    /// # Returns
    ///
    /// the `RTSPAddress` of `self`
    /// or `None` when no address could be allocated. `RTSPAddress::free`
    /// after usage.
    fn get_multicast_address(&self, family: gio::SocketFamily) -> Option<RTSPAddress>;

    /// Get the multicast interface used for `self`.
    ///
    /// # Returns
    ///
    /// the multicast interface for `self`.
    /// `g_free` after usage.
    fn get_multicast_iface(&self) -> Option<String>;

    /// Get the allowed profiles of `self`.
    ///
    /// # Returns
    ///
    /// a `gst_rtsp::RTSPProfile`
    fn get_profiles(&self) -> gst_rtsp::RTSPProfile;

    /// Get the allowed protocols of `self`.
    ///
    /// # Returns
    ///
    /// a `gst_rtsp::RTSPLowerTrans`
    fn get_protocols(&self) -> gst_rtsp::RTSPLowerTrans;

    /// Get the stream payload type.
    ///
    /// # Returns
    ///
    /// the stream payload type.
    fn get_pt(&self) -> u32;

    /// Gets if and how the stream clock should be published according to RFC7273.
    ///
    /// # Returns
    ///
    /// The GstRTSPPublishClockMode
    fn get_publish_clock_mode(&self) -> RTSPPublishClockMode;

    /// Get the payload-type used for retransmission of this stream
    ///
    /// # Returns
    ///
    /// The retransmission PT.
    fn get_retransmission_pt(&self) -> u32;

    /// Get the amount of time to store retransmission data.
    ///
    /// # Returns
    ///
    /// the amount of time to store retransmission data.
    fn get_retransmission_time(&self) -> gst::ClockTime;

    /// 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
    fn get_rtcp_multicast_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket>;

    /// 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
    fn get_rtcp_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket>;

    /// 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
    fn get_rtp_multicast_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket>;

    /// 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
    fn get_rtp_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket>;

    /// Retrieve the current rtptime, seq and running-time. This is used to
    /// construct a RTPInfo reply header.
    /// ## `rtptime`
    /// result RTP timestamp
    /// ## `seq`
    /// result RTP seqnum
    /// ## `clock_rate`
    /// the clock rate
    /// ## `running_time`
    /// result running-time
    ///
    /// # Returns
    ///
    /// `true` when rtptime, seq and running-time could be determined.
    fn get_rtpinfo(&self) -> Option<(u32, u32, u32, gst::ClockTime)>;

    /// Get the RTP session of this stream.
    ///
    /// # Returns
    ///
    /// The RTP session of this stream. Unref after usage.
    fn get_rtpsession(&self) -> Option<glib::Object>;

    //fn get_server_port(&self, server_port: /*Ignored*/gst_rtsp::RTSPRange, family: gio::SocketFamily);

    /// Get the sinkpad associated with `self`.
    ///
    /// # Returns
    ///
    /// the sinkpad. Unref after usage.
    fn get_sinkpad(&self) -> Option<gst::Pad>;

    /// Get the srcpad associated with `self`.
    ///
    /// # Returns
    ///
    /// the srcpad. Unref after usage.
    fn get_srcpad(&self) -> Option<gst::Pad>;

    /// Get the SRTP encoder for this stream.
    ///
    /// # Returns
    ///
    /// The SRTP encoder for this stream. Unref after usage.
    fn get_srtp_encoder(&self) -> Option<gst::Element>;

    /// Get the SSRC used by the RTP session of this stream. This function can only
    /// be called when `self` has been joined.
    /// ## `ssrc`
    /// result ssrc
    fn get_ssrc(&self) -> u32;

    /// Check if `self` has the control string `control`.
    /// ## `control`
    /// a control string
    ///
    /// # Returns
    ///
    /// `true` is `self` has `control` as the control string
    fn has_control<'a, P: Into<Option<&'a str>>>(&self, control: P) -> bool;

    /// Check if `self` is blocking on a `gst::Buffer`.
    ///
    /// # Returns
    ///
    /// `true` if `self` is blocking
    fn is_blocking(&self) -> bool;

    /// See `RTSPStreamExt::set_client_side`
    ///
    /// # Returns
    ///
    /// TRUE if this `RTSPStream` is client-side.
    fn is_client_side(&self) -> bool;

    /// 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.
    fn is_complete(&self) -> bool;

    /// Checks whether the stream is a receiver.
    ///
    /// # Returns
    ///
    /// `true` if the stream is a receiver and `false` otherwise.
    fn is_receiver(&self) -> bool;

    /// Checks whether the stream is a sender.
    ///
    /// # Returns
    ///
    /// `true` if the stream is a sender and `false` otherwise.
    fn is_sender(&self) -> bool;

    //fn is_transport_supported(&self, transport: /*Ignored*/&mut gst_rtsp::RTSPTransport) -> bool;

    /// Join the `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` to join
    /// ## `rtpbin`
    /// a rtpbin element in `bin`
    /// ## `state`
    /// the target state of the new elements
    ///
    /// # Returns
    ///
    /// `true` on success.
    fn join_bin<P: IsA<gst::Bin>, Q: IsA<gst::Element>>(&self, bin: &P, rtpbin: &Q, state: gst::State) -> Result<(), glib::error::BoolError>;

    /// Remove the elements of `self` from `bin`.
    /// ## `bin`
    /// a `gst::Bin`
    /// ## `rtpbin`
    /// a rtpbin `gst::Element`
    ///
    /// # Returns
    ///
    /// `true` on success.
    fn leave_bin<P: IsA<gst::Bin>, Q: IsA<gst::Element>>(&self, bin: &P, rtpbin: &Q) -> Result<(), glib::error::BoolError>;

    /// 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`
    ///
    /// # Returns
    ///
    /// a GstFlowReturn.
    fn recv_rtcp(&self, buffer: &gst::Buffer) -> gst::FlowReturn;

    /// 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`
    ///
    /// # Returns
    ///
    /// a GstFlowReturn.
    fn recv_rtp(&self, buffer: &gst::Buffer) -> gst::FlowReturn;

    /// 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 `gst_rtsp::RTSPTransport`.
    /// ## `trans`
    /// a `RTSPStreamTransport`
    ///
    /// # Returns
    ///
    /// `true` if `trans` was removed
    fn remove_transport(&self, trans: &RTSPStreamTransport) -> Result<(), glib::error::BoolError>;

    /// Creating a rtxsend bin
    /// ## `sessid`
    /// the session id
    ///
    /// # Returns
    ///
    /// a `gst::Element`.
    fn request_aux_sender(&self, sessid: u32) -> Option<gst::Element>;

    /// Reserve `address` and `port` as the address and port of `self`. The original
    /// `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` of `self` or `None` when
    /// the address could be reserved. `RTSPAddress::free` after usage.
    fn reserve_address(&self, address: &str, port: u32, n_ports: u32, ttl: u32) -> Option<RTSPAddress>;

    /// Checks whether the individual `self` is seekable.
    ///
    /// # Returns
    ///
    /// `true` if `self` is seekable, else `false`.
    fn seekable(&self) -> bool;

    /// configure `pool` to be used as the address pool of `self`.
    /// ## `pool`
    /// a `RTSPAddressPool`
    fn set_address_pool<'a, P: Into<Option<&'a RTSPAddressPool>>>(&self, pool: P);

    /// Blocks or unblocks the dataflow on `self`.
    /// ## `blocked`
    /// boolean indicating we should block or unblock
    ///
    /// # Returns
    ///
    /// `true` on success
    fn set_blocked(&self, blocked: bool) -> bool;

    /// 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
    fn set_buffer_size(&self, size: u32);

    /// Sets the `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` is running on the 'client' side of
    /// an RTSP connection.
    fn set_client_side(&self, client_side: bool);

    /// Set the control string in `self`.
    /// ## `control`
    /// a control string
    fn set_control<'a, P: Into<Option<&'a str>>>(&self, control: P);

    /// Configure the dscp qos of the outgoing sockets to `dscp_qos`.
    /// ## `dscp_qos`
    /// a new dscp qos value (0-63, or -1 to disable)
    fn set_dscp_qos(&self, dscp_qos: i32);

    /// Configure the mtu in the payloader of `self` to `mtu`.
    /// ## `mtu`
    /// a new MTU
    fn set_mtu(&self, mtu: u32);

    /// configure `multicast_iface` to be used for `self`.
    /// ## `multicast_iface`
    /// a multicast interface name
    fn set_multicast_iface<'a, P: Into<Option<&'a str>>>(&self, multicast_iface: P);

    /// Configure the allowed profiles for `self`.
    /// ## `profiles`
    /// the new profiles
    fn set_profiles(&self, profiles: gst_rtsp::RTSPProfile);

    /// Configure the allowed lower transport for `self`.
    /// ## `protocols`
    /// the new flags
    fn set_protocols(&self, protocols: gst_rtsp::RTSPLowerTrans);

    /// Configure a pt map between `pt` and `caps`.
    /// ## `pt`
    /// the pt
    /// ## `caps`
    /// a `gst::Caps`
    fn set_pt_map(&self, pt: u32, caps: &gst::Caps);

    /// Sets if and how the stream clock should be published according to RFC7273.
    /// ## `mode`
    /// the clock publish mode
    fn set_publish_clock_mode(&self, mode: RTSPPublishClockMode);

    /// Set the payload type (pt) for retransmission of this stream.
    /// ## `rtx_pt`
    /// a `guint`
    fn set_retransmission_pt(&self, rtx_pt: u32);

    /// Set the amount of time to store retransmission packets.
    /// ## `time`
    /// a `gst::ClockTime`
    fn set_retransmission_time(&self, time: gst::ClockTime);

    fn set_seqnum_offset(&self, seqnum: u16);

    //fn transport_filter<'a, P: Into<Option<&'a /*Unimplemented*/RTSPStreamTransportFilterFunc>>, Q: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, func: P, user_data: Q) -> Vec<RTSPStreamTransport>;

    fn unblock_linked(&self) -> bool;

    /// 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` with crypto info
    ///
    /// # Returns
    ///
    /// `true` if `crypto` could be updated
    fn update_crypto<'a, P: Into<Option<&'a gst::Caps>>>(&self, ssrc: u32, crypto: P) -> bool;

    fn connect_new_rtcp_encoder<F: Fn(&Self, &gst::Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_new_rtp_encoder<F: Fn(&Self, &gst::Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_control_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_profiles_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_protocols_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<RTSPStream> + IsA<glib::object::Object>> RTSPStreamExt for O {
    fn add_transport(&self, trans: &RTSPStreamTransport) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::error::BoolError::from_glib(ffi::gst_rtsp_stream_add_transport(self.to_glib_none().0, trans.to_glib_none().0), "Failed to add transport")
        }
    }

    //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() }
    //}

    //fn complete_stream(&self, transport: /*Ignored*/&gst_rtsp::RTSPTransport) -> bool {
    //    unsafe { TODO: call ffi::gst_rtsp_stream_complete_stream() }
    //}

    fn get_address_pool(&self) -> Option<RTSPAddressPool> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_address_pool(self.to_glib_none().0))
        }
    }

    fn get_buffer_size(&self) -> u32 {
        unsafe {
            ffi::gst_rtsp_stream_get_buffer_size(self.to_glib_none().0)
        }
    }

    fn get_caps(&self) -> Option<gst::Caps> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_caps(self.to_glib_none().0))
        }
    }

    fn get_control(&self) -> Option<String> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_control(self.to_glib_none().0))
        }
    }

    fn get_current_seqnum(&self) -> u16 {
        unsafe {
            ffi::gst_rtsp_stream_get_current_seqnum(self.to_glib_none().0)
        }
    }

    fn get_dscp_qos(&self) -> i32 {
        unsafe {
            ffi::gst_rtsp_stream_get_dscp_qos(self.to_glib_none().0)
        }
    }

    fn get_index(&self) -> u32 {
        unsafe {
            ffi::gst_rtsp_stream_get_index(self.to_glib_none().0)
        }
    }

    fn get_joined_bin(&self) -> Option<gst::Bin> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_joined_bin(self.to_glib_none().0))
        }
    }

    fn get_mtu(&self) -> u32 {
        unsafe {
            ffi::gst_rtsp_stream_get_mtu(self.to_glib_none().0)
        }
    }

    fn get_multicast_address(&self, family: gio::SocketFamily) -> Option<RTSPAddress> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_multicast_address(self.to_glib_none().0, family.to_glib()))
        }
    }

    fn get_multicast_iface(&self) -> Option<String> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_multicast_iface(self.to_glib_none().0))
        }
    }

    fn get_profiles(&self) -> gst_rtsp::RTSPProfile {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_profiles(self.to_glib_none().0))
        }
    }

    fn get_protocols(&self) -> gst_rtsp::RTSPLowerTrans {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_protocols(self.to_glib_none().0))
        }
    }

    fn get_pt(&self) -> u32 {
        unsafe {
            ffi::gst_rtsp_stream_get_pt(self.to_glib_none().0)
        }
    }

    fn get_publish_clock_mode(&self) -> RTSPPublishClockMode {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_publish_clock_mode(self.to_glib_none().0))
        }
    }

    fn get_retransmission_pt(&self) -> u32 {
        unsafe {
            ffi::gst_rtsp_stream_get_retransmission_pt(self.to_glib_none().0)
        }
    }

    fn get_retransmission_time(&self) -> gst::ClockTime {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_get_retransmission_time(self.to_glib_none().0))
        }
    }

    fn get_rtcp_multicast_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtcp_multicast_socket(self.to_glib_none().0, family.to_glib()))
        }
    }

    fn get_rtcp_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtcp_socket(self.to_glib_none().0, family.to_glib()))
        }
    }

    fn get_rtp_multicast_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtp_multicast_socket(self.to_glib_none().0, family.to_glib()))
        }
    }

    fn get_rtp_socket(&self, family: gio::SocketFamily) -> Option<gio::Socket> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtp_socket(self.to_glib_none().0, family.to_glib()))
        }
    }

    fn get_rtpinfo(&self) -> Option<(u32, u32, u32, gst::ClockTime)> {
        unsafe {
            let mut rtptime = mem::uninitialized();
            let mut seq = mem::uninitialized();
            let mut clock_rate = mem::uninitialized();
            let mut running_time = mem::uninitialized();
            let ret = from_glib(ffi::gst_rtsp_stream_get_rtpinfo(self.to_glib_none().0, &mut rtptime, &mut seq, &mut clock_rate, &mut running_time));
            if ret { Some((rtptime, seq, clock_rate, from_glib(running_time))) } else { None }
        }
    }

    fn get_rtpsession(&self) -> Option<glib::Object> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_rtpsession(self.to_glib_none().0))
        }
    }

    //fn get_server_port(&self, server_port: /*Ignored*/gst_rtsp::RTSPRange, family: gio::SocketFamily) {
    //    unsafe { TODO: call ffi::gst_rtsp_stream_get_server_port() }
    //}

    fn get_sinkpad(&self) -> Option<gst::Pad> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_sinkpad(self.to_glib_none().0))
        }
    }

    fn get_srcpad(&self) -> Option<gst::Pad> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_srcpad(self.to_glib_none().0))
        }
    }

    fn get_srtp_encoder(&self) -> Option<gst::Element> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_get_srtp_encoder(self.to_glib_none().0))
        }
    }

    fn get_ssrc(&self) -> u32 {
        unsafe {
            let mut ssrc = mem::uninitialized();
            ffi::gst_rtsp_stream_get_ssrc(self.to_glib_none().0, &mut ssrc);
            ssrc
        }
    }

    fn has_control<'a, P: Into<Option<&'a str>>>(&self, control: P) -> bool {
        let control = control.into();
        let control = control.to_glib_none();
        unsafe {
            from_glib(ffi::gst_rtsp_stream_has_control(self.to_glib_none().0, control.0))
        }
    }

    fn is_blocking(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_blocking(self.to_glib_none().0))
        }
    }

    fn is_client_side(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_client_side(self.to_glib_none().0))
        }
    }

    fn is_complete(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_complete(self.to_glib_none().0))
        }
    }

    fn is_receiver(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_receiver(self.to_glib_none().0))
        }
    }

    fn is_sender(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_is_sender(self.to_glib_none().0))
        }
    }

    //fn is_transport_supported(&self, transport: /*Ignored*/&mut gst_rtsp::RTSPTransport) -> bool {
    //    unsafe { TODO: call ffi::gst_rtsp_stream_is_transport_supported() }
    //}

    fn join_bin<P: IsA<gst::Bin>, Q: IsA<gst::Element>>(&self, bin: &P, rtpbin: &Q, state: gst::State) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::error::BoolError::from_glib(ffi::gst_rtsp_stream_join_bin(self.to_glib_none().0, bin.to_glib_none().0, rtpbin.to_glib_none().0, state.to_glib()), "Failed to join bin")
        }
    }

    fn leave_bin<P: IsA<gst::Bin>, Q: IsA<gst::Element>>(&self, bin: &P, rtpbin: &Q) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::error::BoolError::from_glib(ffi::gst_rtsp_stream_leave_bin(self.to_glib_none().0, bin.to_glib_none().0, rtpbin.to_glib_none().0), "Failed to leave bin")
        }
    }

    fn recv_rtcp(&self, buffer: &gst::Buffer) -> gst::FlowReturn {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_recv_rtcp(self.to_glib_none().0, buffer.to_glib_full()))
        }
    }

    fn recv_rtp(&self, buffer: &gst::Buffer) -> gst::FlowReturn {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_recv_rtp(self.to_glib_none().0, buffer.to_glib_full()))
        }
    }

    fn remove_transport(&self, trans: &RTSPStreamTransport) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::error::BoolError::from_glib(ffi::gst_rtsp_stream_remove_transport(self.to_glib_none().0, trans.to_glib_none().0), "Failed to remove transport")
        }
    }

    fn request_aux_sender(&self, sessid: u32) -> Option<gst::Element> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_request_aux_sender(self.to_glib_none().0, sessid))
        }
    }

    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.to_glib_none().0, address.to_glib_none().0, port, n_ports, ttl))
        }
    }

    fn seekable(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_seekable(self.to_glib_none().0))
        }
    }

    fn set_address_pool<'a, P: Into<Option<&'a RTSPAddressPool>>>(&self, pool: P) {
        let pool = pool.into();
        let pool = pool.to_glib_none();
        unsafe {
            ffi::gst_rtsp_stream_set_address_pool(self.to_glib_none().0, pool.0);
        }
    }

    fn set_blocked(&self, blocked: bool) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_set_blocked(self.to_glib_none().0, blocked.to_glib()))
        }
    }

    fn set_buffer_size(&self, size: u32) {
        unsafe {
            ffi::gst_rtsp_stream_set_buffer_size(self.to_glib_none().0, size);
        }
    }

    fn set_client_side(&self, client_side: bool) {
        unsafe {
            ffi::gst_rtsp_stream_set_client_side(self.to_glib_none().0, client_side.to_glib());
        }
    }

    fn set_control<'a, P: Into<Option<&'a str>>>(&self, control: P) {
        let control = control.into();
        let control = control.to_glib_none();
        unsafe {
            ffi::gst_rtsp_stream_set_control(self.to_glib_none().0, control.0);
        }
    }

    fn set_dscp_qos(&self, dscp_qos: i32) {
        unsafe {
            ffi::gst_rtsp_stream_set_dscp_qos(self.to_glib_none().0, dscp_qos);
        }
    }

    fn set_mtu(&self, mtu: u32) {
        unsafe {
            ffi::gst_rtsp_stream_set_mtu(self.to_glib_none().0, mtu);
        }
    }

    fn set_multicast_iface<'a, P: Into<Option<&'a str>>>(&self, multicast_iface: P) {
        let multicast_iface = multicast_iface.into();
        let multicast_iface = multicast_iface.to_glib_none();
        unsafe {
            ffi::gst_rtsp_stream_set_multicast_iface(self.to_glib_none().0, multicast_iface.0);
        }
    }

    fn set_profiles(&self, profiles: gst_rtsp::RTSPProfile) {
        unsafe {
            ffi::gst_rtsp_stream_set_profiles(self.to_glib_none().0, profiles.to_glib());
        }
    }

    fn set_protocols(&self, protocols: gst_rtsp::RTSPLowerTrans) {
        unsafe {
            ffi::gst_rtsp_stream_set_protocols(self.to_glib_none().0, protocols.to_glib());
        }
    }

    fn set_pt_map(&self, pt: u32, caps: &gst::Caps) {
        unsafe {
            ffi::gst_rtsp_stream_set_pt_map(self.to_glib_none().0, pt, caps.to_glib_none().0);
        }
    }

    fn set_publish_clock_mode(&self, mode: RTSPPublishClockMode) {
        unsafe {
            ffi::gst_rtsp_stream_set_publish_clock_mode(self.to_glib_none().0, mode.to_glib());
        }
    }

    fn set_retransmission_pt(&self, rtx_pt: u32) {
        unsafe {
            ffi::gst_rtsp_stream_set_retransmission_pt(self.to_glib_none().0, rtx_pt);
        }
    }

    fn set_retransmission_time(&self, time: gst::ClockTime) {
        unsafe {
            ffi::gst_rtsp_stream_set_retransmission_time(self.to_glib_none().0, time.to_glib());
        }
    }

    fn set_seqnum_offset(&self, seqnum: u16) {
        unsafe {
            ffi::gst_rtsp_stream_set_seqnum_offset(self.to_glib_none().0, seqnum);
        }
    }

    //fn transport_filter<'a, P: Into<Option<&'a /*Unimplemented*/RTSPStreamTransportFilterFunc>>, Q: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, func: P, user_data: Q) -> Vec<RTSPStreamTransport> {
    //    unsafe { TODO: call ffi::gst_rtsp_stream_transport_filter() }
    //}

    fn unblock_linked(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_unblock_linked(self.to_glib_none().0))
        }
    }

    fn update_crypto<'a, P: Into<Option<&'a gst::Caps>>>(&self, ssrc: u32, crypto: P) -> bool {
        let crypto = crypto.into();
        let crypto = crypto.to_glib_none();
        unsafe {
            from_glib(ffi::gst_rtsp_stream_update_crypto(self.to_glib_none().0, ssrc, crypto.0))
        }
    }

    fn connect_new_rtcp_encoder<F: Fn(&Self, &gst::Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &gst::Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "new-rtcp-encoder",
                transmute(new_rtcp_encoder_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_new_rtp_encoder<F: Fn(&Self, &gst::Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &gst::Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "new-rtp-encoder",
                transmute(new_rtp_encoder_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_control_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::control",
                transmute(notify_control_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_profiles_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::profiles",
                transmute(notify_profiles_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_protocols_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::protocols",
                transmute(notify_protocols_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe extern "C" fn new_rtcp_encoder_trampoline<P>(this: *mut ffi::GstRTSPStream, object: *mut gst_ffi::GstElement, f: glib_ffi::gpointer)
where P: IsA<RTSPStream> {
    let f: &&(Fn(&P, &gst::Element) + Send + Sync + 'static) = transmute(f);
    f(&RTSPStream::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(object))
}

unsafe extern "C" fn new_rtp_encoder_trampoline<P>(this: *mut ffi::GstRTSPStream, object: *mut gst_ffi::GstElement, f: glib_ffi::gpointer)
where P: IsA<RTSPStream> {
    let f: &&(Fn(&P, &gst::Element) + Send + Sync + 'static) = transmute(f);
    f(&RTSPStream::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(object))
}

unsafe extern "C" fn notify_control_trampoline<P>(this: *mut ffi::GstRTSPStream, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<RTSPStream> {
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
    f(&RTSPStream::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_profiles_trampoline<P>(this: *mut ffi::GstRTSPStream, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<RTSPStream> {
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
    f(&RTSPStream::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_protocols_trampoline<P>(this: *mut ffi::GstRTSPStream, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<RTSPStream> {
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
    f(&RTSPStream::from_glib_borrow(this).downcast_unchecked())
}