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
// 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 RTSPStream;
use ffi;
use glib;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_rtsp;
use std::mem;
use std::ptr;

glib_wrapper! {
    /// A Transport description for a stream
    ///
    /// # Implements
    ///
    /// [`RTSPStreamTransportExt`](trait.RTSPStreamTransportExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html)
    pub struct RTSPStreamTransport(Object<ffi::GstRTSPStreamTransport, ffi::GstRTSPStreamTransportClass>);

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

impl RTSPStreamTransport {
    //pub fn new(stream: &RTSPStream, tr: /*Ignored*/&mut gst_rtsp::RTSPTransport) -> RTSPStreamTransport {
    //    unsafe { TODO: call ffi::gst_rtsp_stream_transport_new() }
    //}
}

/// Trait containing all `RTSPStreamTransport` methods.
///
/// # Implementors
///
/// [`RTSPStreamTransport`](struct.RTSPStreamTransport.html)
pub trait RTSPStreamTransportExt {
    /// Get the RTP-Info string for `self` and `start_time`.
    /// ## `start_time`
    /// a star time
    ///
    /// # Returns
    ///
    /// the RTPInfo string for `self`
    /// and `start_time` or `None` when the RTP-Info could not be
    /// determined. `g_free` after usage.
    fn get_rtpinfo(&self, start_time: gst::ClockTime) -> Option<String>;

    /// Get the `RTSPStream` used when constructing `self`.
    ///
    /// # Returns
    ///
    /// the stream used when constructing `self`.
    fn get_stream(&self) -> Option<RTSPStream>;

    //fn get_transport(&self) -> /*Ignored*/Option<gst_rtsp::RTSPTransport>;

    /// Get the url configured in `self`.
    ///
    /// # Returns
    ///
    /// the url configured in `self`.
    /// It remains valid for as long as `self` is valid.
    fn get_url(&self) -> Option<gst_rtsp::RTSPUrl>;

    /// Check if `self` is timed out.
    ///
    /// # Returns
    ///
    /// `true` if `self` timed out.
    fn is_timed_out(&self) -> bool;

    /// Signal the installed keep_alive callback for `self`.
    fn keep_alive(&self);

    /// Receive `buffer` on `channel` `self`.
    /// ## `channel`
    /// a channel
    /// ## `buffer`
    /// a `gst::Buffer`
    ///
    /// # Returns
    ///
    /// a `gst::FlowReturn`. Returns GST_FLOW_NOT_LINKED when `channel` is not
    ///  configured in the transport of `self`.
    fn recv_data(&self, channel: u32, buffer: &gst::Buffer) -> gst::FlowReturn;

    /// Send `buffer` to the installed RTCP callback for `self`.
    /// ## `buffer`
    /// a `gst::Buffer`
    ///
    /// # Returns
    ///
    /// `true` on success
    fn send_rtcp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError>;

    /// Send `buffer` to the installed RTP callback for `self`.
    /// ## `buffer`
    /// a `gst::Buffer`
    ///
    /// # Returns
    ///
    /// `true` on success
    fn send_rtp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError>;

    /// Activate or deactivate datatransfer configured in `self`.
    /// ## `active`
    /// new state of `self`
    ///
    /// # Returns
    ///
    /// `true` when the state was changed.
    fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError>;

    //fn set_callbacks<'a, P: Into<Option<&'a /*Ignored*/glib::DestroyNotify>>>(&self, send_rtp: /*Unknown conversion*//*Unimplemented*/RTSPSendFunc, send_rtcp: /*Unknown conversion*//*Unimplemented*/RTSPSendFunc, notify: P);

    //fn set_keepalive<'a, P: Into<Option<&'a /*Ignored*/glib::DestroyNotify>>>(&self, keep_alive: /*Unknown conversion*//*Unimplemented*/RTSPKeepAliveFunc, notify: P);

    /// Set the timed out state of `self` to `timedout`
    /// ## `timedout`
    /// timed out value
    fn set_timed_out(&self, timedout: bool);

    //fn set_transport(&self, tr: /*Ignored*/&mut gst_rtsp::RTSPTransport);

    /// Set `url` as the client url.
    /// ## `url`
    /// a client `gst_rtsp::RTSPUrl`
    fn set_url<'a, P: Into<Option<&'a gst_rtsp::RTSPUrl>>>(&self, url: P);
}

impl<O: IsA<RTSPStreamTransport>> RTSPStreamTransportExt for O {
    fn get_rtpinfo(&self, start_time: gst::ClockTime) -> Option<String> {
        unsafe {
            from_glib_full(ffi::gst_rtsp_stream_transport_get_rtpinfo(self.to_glib_none().0, start_time.to_glib()))
        }
    }

    fn get_stream(&self) -> Option<RTSPStream> {
        unsafe {
            from_glib_none(ffi::gst_rtsp_stream_transport_get_stream(self.to_glib_none().0))
        }
    }

    //fn get_transport(&self) -> /*Ignored*/Option<gst_rtsp::RTSPTransport> {
    //    unsafe { TODO: call ffi::gst_rtsp_stream_transport_get_transport() }
    //}

    fn get_url(&self) -> Option<gst_rtsp::RTSPUrl> {
        unsafe {
            from_glib_none(ffi::gst_rtsp_stream_transport_get_url(self.to_glib_none().0))
        }
    }

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

    fn keep_alive(&self) {
        unsafe {
            ffi::gst_rtsp_stream_transport_keep_alive(self.to_glib_none().0);
        }
    }

    fn recv_data(&self, channel: u32, buffer: &gst::Buffer) -> gst::FlowReturn {
        unsafe {
            from_glib(ffi::gst_rtsp_stream_transport_recv_data(self.to_glib_none().0, channel, buffer.to_glib_full()))
        }
    }

    fn send_rtcp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::error::BoolError::from_glib(ffi::gst_rtsp_stream_transport_send_rtcp(self.to_glib_none().0, buffer.to_glib_none().0), "Failed to send rtcp")
        }
    }

    fn send_rtp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::error::BoolError::from_glib(ffi::gst_rtsp_stream_transport_send_rtp(self.to_glib_none().0, buffer.to_glib_none().0), "Failed to send rtp")
        }
    }

    fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::error::BoolError::from_glib(ffi::gst_rtsp_stream_transport_set_active(self.to_glib_none().0, active.to_glib()), "Failed to set active")
        }
    }

    //fn set_callbacks<'a, P: Into<Option<&'a /*Ignored*/glib::DestroyNotify>>>(&self, send_rtp: /*Unknown conversion*//*Unimplemented*/RTSPSendFunc, send_rtcp: /*Unknown conversion*//*Unimplemented*/RTSPSendFunc, notify: P) {
    //    unsafe { TODO: call ffi::gst_rtsp_stream_transport_set_callbacks() }
    //}

    //fn set_keepalive<'a, P: Into<Option<&'a /*Ignored*/glib::DestroyNotify>>>(&self, keep_alive: /*Unknown conversion*//*Unimplemented*/RTSPKeepAliveFunc, notify: P) {
    //    unsafe { TODO: call ffi::gst_rtsp_stream_transport_set_keepalive() }
    //}

    fn set_timed_out(&self, timedout: bool) {
        unsafe {
            ffi::gst_rtsp_stream_transport_set_timed_out(self.to_glib_none().0, timedout.to_glib());
        }
    }

    //fn set_transport(&self, tr: /*Ignored*/&mut gst_rtsp::RTSPTransport) {
    //    unsafe { TODO: call ffi::gst_rtsp_stream_transport_set_transport() }
    //}

    fn set_url<'a, P: Into<Option<&'a gst_rtsp::RTSPUrl>>>(&self, url: P) {
        let url = url.into();
        let url = url.to_glib_none();
        unsafe {
            ffi::gst_rtsp_stream_transport_set_url(self.to_glib_none().0, url.0);
        }
    }
}