gstreamer_rtsp_server/
rtsp_client.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::{ffi, RTSPClient, RTSPSession};
4use glib::{prelude::*, source::SourceId, translate::*};
5use gst_rtsp::rtsp_message::RTSPMessage;
6
7mod sealed {
8    pub trait Sealed {}
9    impl<T: super::IsA<super::RTSPClient>> Sealed for T {}
10}
11
12pub trait RTSPClientExtManual: sealed::Sealed + IsA<RTSPClient> + 'static {
13    /// Attaches `self` to `context`. When the mainloop for `context` is run, the
14    /// client will be dispatched. When `context` is [`None`], the default context will be
15    /// used).
16    ///
17    /// This function should be called when the client properties and urls are fully
18    /// configured and the client is ready to start.
19    /// ## `context`
20    /// a [`glib::MainContext`][crate::glib::MainContext]
21    ///
22    /// # Returns
23    ///
24    /// the ID (greater than 0) for the source within the GMainContext.
25    #[doc(alias = "gst_rtsp_client_attach")]
26    fn attach(&self, context: Option<&glib::MainContext>) -> SourceId {
27        unsafe {
28            from_glib(ffi::gst_rtsp_client_attach(
29                self.as_ref().to_glib_none().0,
30                context.to_glib_none().0,
31            ))
32        }
33    }
34
35    #[doc(alias = "gst_rtsp_client_send_message")]
36    fn send_message(
37        &self,
38        message: &RTSPMessage,
39        session: Option<&RTSPSession>,
40    ) -> gst_rtsp::RTSPResult {
41        unsafe {
42            from_glib(ffi::gst_rtsp_client_send_message(
43                self.as_ref().to_glib_none().0,
44                session.to_glib_none().0,
45                message.to_glib_none().0,
46            ))
47        }
48    }
49}
50
51impl<O: IsA<RTSPClient>> RTSPClientExtManual for O {}