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
use glib::object::IsA;
use glib::translate::*;
use gst;
use gst_rtsp_server_sys;
use RTSPStream;

pub trait RTSPStreamExtManual: 'static {
    fn recv_rtcp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>;

    fn recv_rtp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>;
}

impl<O: IsA<RTSPStream>> RTSPStreamExtManual for O {
    fn recv_rtcp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
        let ret: gst::FlowReturn = unsafe {
            from_glib(gst_rtsp_server_sys::gst_rtsp_stream_recv_rtcp(
                self.as_ref().to_glib_none().0,
                buffer.to_glib_full(),
            ))
        };
        ret.into_result()
    }

    fn recv_rtp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
        let ret: gst::FlowReturn = unsafe {
            from_glib(gst_rtsp_server_sys::gst_rtsp_stream_recv_rtp(
                self.as_ref().to_glib_none().0,
                buffer.to_glib_full(),
            ))
        };
        ret.into_result()
    }
}