gstreamer_rtsp/auto/
rtsp_url.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{ffi, RTSPResult};
7use glib::translate::*;
8
9glib::wrapper! {
10    /// Provides helper functions to handle RTSP urls.
11    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
12    pub struct RTSPUrl(Boxed<ffi::GstRTSPUrl>);
13
14    match fn {
15        copy => |ptr| ffi::gst_rtsp_url_copy(ptr),
16        free => |ptr| ffi::gst_rtsp_url_free(ptr),
17        type_ => || ffi::gst_rtsp_url_get_type(),
18    }
19}
20
21impl RTSPUrl {
22    /// Splits the path of `self` on '/' boundaries, decoding the resulting components,
23    ///
24    /// The decoding performed by this routine is "URI decoding", as defined in RFC
25    /// 3986, commonly known as percent-decoding. For example, a string "foo\`2fbar`"
26    /// will decode to "foo/bar" -- the \`2f` being replaced by the corresponding byte
27    /// with hex value 0x2f. Note that there is no guarantee that the resulting byte
28    /// sequence is valid in any given encoding. As a special case, \`00` is not
29    /// unescaped to NUL, as that would prematurely terminate the string.
30    ///
31    /// Also note that since paths usually start with a slash, the first component
32    /// will usually be the empty string.
33    ///
34    /// # Returns
35    ///
36    /// [`None`]-terminated array of URL components. Free with
37    /// `g_strfreev()` when no longer needed.
38    #[doc(alias = "gst_rtsp_url_decode_path_components")]
39    pub fn decode_path_components(&self) -> Vec<glib::GString> {
40        unsafe {
41            FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_url_decode_path_components(
42                self.to_glib_none().0,
43            ))
44        }
45    }
46
47    /// Get a newly allocated string describing the request URI for `self`.
48    ///
49    /// # Returns
50    ///
51    /// a string with the request URI. `g_free()` after usage.
52    #[doc(alias = "gst_rtsp_url_get_request_uri")]
53    #[doc(alias = "get_request_uri")]
54    pub fn request_uri(&self) -> glib::GString {
55        unsafe { from_glib_full(ffi::gst_rtsp_url_get_request_uri(self.to_glib_none().0)) }
56    }
57
58    /// Get a newly allocated string describing the request URI for `self`
59    /// combined with the control path for `control_path`
60    /// ## `control_path`
61    /// an RTSP aggregate control path
62    ///
63    /// # Returns
64    ///
65    /// a string with the request URI combined with the control path.
66    /// `g_free()` after usage.
67    #[cfg(feature = "v1_18")]
68    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
69    #[doc(alias = "gst_rtsp_url_get_request_uri_with_control")]
70    #[doc(alias = "get_request_uri_with_control")]
71    pub fn request_uri_with_control(&self, control_path: &str) -> glib::GString {
72        unsafe {
73            from_glib_full(ffi::gst_rtsp_url_get_request_uri_with_control(
74                self.to_glib_none().0,
75                control_path.to_glib_none().0,
76            ))
77        }
78    }
79
80    /// Set the port number in `self` to `port`.
81    /// ## `port`
82    /// the port
83    ///
84    /// # Returns
85    ///
86    /// [`RTSPResult::Ok`][crate::RTSPResult::Ok].
87    #[doc(alias = "gst_rtsp_url_set_port")]
88    pub fn set_port(&mut self, port: u16) -> RTSPResult {
89        unsafe { from_glib(ffi::gst_rtsp_url_set_port(self.to_glib_none_mut().0, port)) }
90    }
91
92    /// Parse the RTSP `urlstr` into a newly allocated [`RTSPUrl`][crate::RTSPUrl]. Free after usage
93    /// with `gst_rtsp_url_free()`.
94    /// ## `urlstr`
95    /// the url string to parse
96    ///
97    /// # Returns
98    ///
99    /// a [`RTSPResult`][crate::RTSPResult].
100    ///
101    /// ## `url`
102    /// location to hold the result.
103    #[doc(alias = "gst_rtsp_url_parse")]
104    pub fn parse(urlstr: &str) -> (RTSPResult, Option<RTSPUrl>) {
105        assert_initialized_main_thread!();
106        unsafe {
107            let mut url = std::ptr::null_mut();
108            let ret = from_glib(ffi::gst_rtsp_url_parse(urlstr.to_glib_none().0, &mut url));
109            (ret, from_glib_full(url))
110        }
111    }
112}
113
114unsafe impl Send for RTSPUrl {}