gstreamer_rtsp_server/auto/
rtsp_mount_points.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, RTSPMediaFactory};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// Creates a [`RTSPMediaFactory`][crate::RTSPMediaFactory] object for a given url.
11    ///
12    /// # Implements
13    ///
14    /// [`RTSPMountPointsExt`][trait@crate::prelude::RTSPMountPointsExt], [`trait@glib::ObjectExt`]
15    #[doc(alias = "GstRTSPMountPoints")]
16    pub struct RTSPMountPoints(Object<ffi::GstRTSPMountPoints, ffi::GstRTSPMountPointsClass>);
17
18    match fn {
19        type_ => || ffi::gst_rtsp_mount_points_get_type(),
20    }
21}
22
23impl RTSPMountPoints {
24    pub const NONE: Option<&'static RTSPMountPoints> = None;
25
26    /// Make a new mount points object.
27    ///
28    /// # Returns
29    ///
30    /// a new [`RTSPMountPoints`][crate::RTSPMountPoints]
31    #[doc(alias = "gst_rtsp_mount_points_new")]
32    pub fn new() -> RTSPMountPoints {
33        assert_initialized_main_thread!();
34        unsafe { from_glib_full(ffi::gst_rtsp_mount_points_new()) }
35    }
36}
37
38impl Default for RTSPMountPoints {
39    fn default() -> Self {
40        Self::new()
41    }
42}
43
44unsafe impl Send for RTSPMountPoints {}
45unsafe impl Sync for RTSPMountPoints {}
46
47mod sealed {
48    pub trait Sealed {}
49    impl<T: super::IsA<super::RTSPMountPoints>> Sealed for T {}
50}
51
52/// Trait containing all [`struct@RTSPMountPoints`] methods.
53///
54/// # Implementors
55///
56/// [`RTSPMountPoints`][struct@crate::RTSPMountPoints]
57pub trait RTSPMountPointsExt: IsA<RTSPMountPoints> + sealed::Sealed + 'static {
58    /// Attach `factory` to the mount point `path` in `self`.
59    ///
60    /// `path` is either of the form (/node)+ or the root path '/'. (An empty path is
61    /// not allowed.) Any previous mount point will be freed.
62    ///
63    /// Ownership is taken of the reference on `factory` so that `factory` should not be
64    /// used after calling this function.
65    /// ## `path`
66    /// a mount point
67    /// ## `factory`
68    /// a [`RTSPMediaFactory`][crate::RTSPMediaFactory]
69    #[doc(alias = "gst_rtsp_mount_points_add_factory")]
70    fn add_factory(&self, path: &str, factory: impl IsA<RTSPMediaFactory>) {
71        unsafe {
72            ffi::gst_rtsp_mount_points_add_factory(
73                self.as_ref().to_glib_none().0,
74                path.to_glib_none().0,
75                factory.upcast().into_glib_ptr(),
76            );
77        }
78    }
79
80    /// Make a path string from `url`.
81    /// ## `url`
82    /// a [`gst_rtsp::RTSPUrl`][crate::gst_rtsp::RTSPUrl]
83    ///
84    /// # Returns
85    ///
86    /// a path string for `url`, `g_free()` after usage.
87    #[doc(alias = "gst_rtsp_mount_points_make_path")]
88    fn make_path(&self, url: &gst_rtsp::RTSPUrl) -> Result<glib::GString, glib::BoolError> {
89        unsafe {
90            Option::<_>::from_glib_full(ffi::gst_rtsp_mount_points_make_path(
91                self.as_ref().to_glib_none().0,
92                url.to_glib_none().0,
93            ))
94            .ok_or_else(|| glib::bool_error!("Failed to make path"))
95        }
96    }
97
98    /// Find the factory in `self` that has the longest match with `path`.
99    ///
100    /// If `matched` is [`None`], `path` will match the factory exactly otherwise
101    /// the amount of characters that matched is returned in `matched`.
102    /// ## `path`
103    /// a mount point
104    ///
105    /// # Returns
106    ///
107    /// the [`RTSPMediaFactory`][crate::RTSPMediaFactory] for `path`.
108    /// `g_object_unref()` after usage.
109    ///
110    /// ## `matched`
111    /// the amount of `path` matched
112    #[doc(alias = "gst_rtsp_mount_points_match")]
113    #[doc(alias = "match")]
114    fn match_(&self, path: &str) -> (RTSPMediaFactory, i32) {
115        unsafe {
116            let mut matched = std::mem::MaybeUninit::uninit();
117            let ret = from_glib_full(ffi::gst_rtsp_mount_points_match(
118                self.as_ref().to_glib_none().0,
119                path.to_glib_none().0,
120                matched.as_mut_ptr(),
121            ));
122            (ret, matched.assume_init())
123        }
124    }
125
126    /// Remove the [`RTSPMediaFactory`][crate::RTSPMediaFactory] associated with `path` in `self`.
127    /// ## `path`
128    /// a mount point
129    #[doc(alias = "gst_rtsp_mount_points_remove_factory")]
130    fn remove_factory(&self, path: &str) {
131        unsafe {
132            ffi::gst_rtsp_mount_points_remove_factory(
133                self.as_ref().to_glib_none().0,
134                path.to_glib_none().0,
135            );
136        }
137    }
138}
139
140impl<O: IsA<RTSPMountPoints>> RTSPMountPointsExt for O {}