gstreamer_rtsp_server/auto/
rtsp_auth.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, RTSPToken};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GstRTSPAuth")]
17    pub struct RTSPAuth(Object<ffi::GstRTSPAuth, ffi::GstRTSPAuthClass>);
18
19    match fn {
20        type_ => || ffi::gst_rtsp_auth_get_type(),
21    }
22}
23
24impl RTSPAuth {
25    pub const NONE: Option<&'static RTSPAuth> = None;
26
27    #[doc(alias = "gst_rtsp_auth_new")]
28    pub fn new() -> RTSPAuth {
29        assert_initialized_main_thread!();
30        unsafe { from_glib_full(ffi::gst_rtsp_auth_new()) }
31    }
32
33    #[doc(alias = "gst_rtsp_auth_check")]
34    pub fn check(check: &str) -> Result<(), glib::error::BoolError> {
35        assert_initialized_main_thread!();
36        unsafe {
37            glib::result_from_gboolean!(
38                ffi::gst_rtsp_auth_check(check.to_glib_none().0),
39                "Check failed"
40            )
41        }
42    }
43
44    #[doc(alias = "gst_rtsp_auth_make_basic")]
45    pub fn make_basic(user: &str, pass: &str) -> glib::GString {
46        assert_initialized_main_thread!();
47        unsafe {
48            from_glib_full(ffi::gst_rtsp_auth_make_basic(
49                user.to_glib_none().0,
50                pass.to_glib_none().0,
51            ))
52        }
53    }
54}
55
56impl Default for RTSPAuth {
57    fn default() -> Self {
58        Self::new()
59    }
60}
61
62unsafe impl Send for RTSPAuth {}
63unsafe impl Sync for RTSPAuth {}
64
65pub trait RTSPAuthExt: IsA<RTSPAuth> + 'static {
66    #[doc(alias = "gst_rtsp_auth_add_basic")]
67    fn add_basic(&self, basic: &str, token: &RTSPToken) {
68        unsafe {
69            ffi::gst_rtsp_auth_add_basic(
70                self.as_ref().to_glib_none().0,
71                basic.to_glib_none().0,
72                token.to_glib_none().0,
73            );
74        }
75    }
76
77    #[doc(alias = "gst_rtsp_auth_add_digest")]
78    fn add_digest(&self, user: &str, pass: &str, token: &RTSPToken) {
79        unsafe {
80            ffi::gst_rtsp_auth_add_digest(
81                self.as_ref().to_glib_none().0,
82                user.to_glib_none().0,
83                pass.to_glib_none().0,
84                token.to_glib_none().0,
85            );
86        }
87    }
88
89    #[doc(alias = "gst_rtsp_auth_get_default_token")]
90    #[doc(alias = "get_default_token")]
91    fn default_token(&self) -> Option<RTSPToken> {
92        unsafe {
93            from_glib_full(ffi::gst_rtsp_auth_get_default_token(
94                self.as_ref().to_glib_none().0,
95            ))
96        }
97    }
98
99    #[cfg(feature = "v1_16")]
100    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
101    #[doc(alias = "gst_rtsp_auth_get_realm")]
102    #[doc(alias = "get_realm")]
103    fn realm(&self) -> Option<glib::GString> {
104        unsafe { from_glib_full(ffi::gst_rtsp_auth_get_realm(self.as_ref().to_glib_none().0)) }
105    }
106
107    #[doc(alias = "gst_rtsp_auth_get_supported_methods")]
108    #[doc(alias = "get_supported_methods")]
109    fn supported_methods(&self) -> gst_rtsp::RTSPAuthMethod {
110        unsafe {
111            from_glib(ffi::gst_rtsp_auth_get_supported_methods(
112                self.as_ref().to_glib_none().0,
113            ))
114        }
115    }
116
117    #[doc(alias = "gst_rtsp_auth_get_tls_authentication_mode")]
118    #[doc(alias = "get_tls_authentication_mode")]
119    fn tls_authentication_mode(&self) -> gio::TlsAuthenticationMode {
120        unsafe {
121            from_glib(ffi::gst_rtsp_auth_get_tls_authentication_mode(
122                self.as_ref().to_glib_none().0,
123            ))
124        }
125    }
126
127    #[doc(alias = "gst_rtsp_auth_get_tls_certificate")]
128    #[doc(alias = "get_tls_certificate")]
129    fn tls_certificate(&self) -> Option<gio::TlsCertificate> {
130        unsafe {
131            from_glib_full(ffi::gst_rtsp_auth_get_tls_certificate(
132                self.as_ref().to_glib_none().0,
133            ))
134        }
135    }
136
137    #[doc(alias = "gst_rtsp_auth_get_tls_database")]
138    #[doc(alias = "get_tls_database")]
139    fn tls_database(&self) -> Option<gio::TlsDatabase> {
140        unsafe {
141            from_glib_full(ffi::gst_rtsp_auth_get_tls_database(
142                self.as_ref().to_glib_none().0,
143            ))
144        }
145    }
146
147    #[cfg(feature = "v1_16")]
148    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
149    #[doc(alias = "gst_rtsp_auth_parse_htdigest")]
150    fn parse_htdigest(&self, path: impl AsRef<std::path::Path>, token: &RTSPToken) -> bool {
151        unsafe {
152            from_glib(ffi::gst_rtsp_auth_parse_htdigest(
153                self.as_ref().to_glib_none().0,
154                path.as_ref().to_glib_none().0,
155                token.to_glib_none().0,
156            ))
157        }
158    }
159
160    #[doc(alias = "gst_rtsp_auth_remove_basic")]
161    fn remove_basic(&self, basic: &str) {
162        unsafe {
163            ffi::gst_rtsp_auth_remove_basic(self.as_ref().to_glib_none().0, basic.to_glib_none().0);
164        }
165    }
166
167    #[doc(alias = "gst_rtsp_auth_remove_digest")]
168    fn remove_digest(&self, user: &str) {
169        unsafe {
170            ffi::gst_rtsp_auth_remove_digest(self.as_ref().to_glib_none().0, user.to_glib_none().0);
171        }
172    }
173
174    #[cfg(feature = "v1_16")]
175    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
176    #[doc(alias = "gst_rtsp_auth_set_realm")]
177    fn set_realm(&self, realm: Option<&str>) {
178        unsafe {
179            ffi::gst_rtsp_auth_set_realm(self.as_ref().to_glib_none().0, realm.to_glib_none().0);
180        }
181    }
182
183    #[doc(alias = "gst_rtsp_auth_set_supported_methods")]
184    fn set_supported_methods(&self, methods: gst_rtsp::RTSPAuthMethod) {
185        unsafe {
186            ffi::gst_rtsp_auth_set_supported_methods(
187                self.as_ref().to_glib_none().0,
188                methods.into_glib(),
189            );
190        }
191    }
192
193    #[doc(alias = "gst_rtsp_auth_set_tls_authentication_mode")]
194    fn set_tls_authentication_mode(&self, mode: gio::TlsAuthenticationMode) {
195        unsafe {
196            ffi::gst_rtsp_auth_set_tls_authentication_mode(
197                self.as_ref().to_glib_none().0,
198                mode.into_glib(),
199            );
200        }
201    }
202
203    #[doc(alias = "gst_rtsp_auth_set_tls_certificate")]
204    fn set_tls_certificate(&self, cert: Option<&impl IsA<gio::TlsCertificate>>) {
205        unsafe {
206            ffi::gst_rtsp_auth_set_tls_certificate(
207                self.as_ref().to_glib_none().0,
208                cert.map(|p| p.as_ref()).to_glib_none().0,
209            );
210        }
211    }
212
213    #[doc(alias = "gst_rtsp_auth_set_tls_database")]
214    fn set_tls_database(&self, database: Option<&impl IsA<gio::TlsDatabase>>) {
215        unsafe {
216            ffi::gst_rtsp_auth_set_tls_database(
217                self.as_ref().to_glib_none().0,
218                database.map(|p| p.as_ref()).to_glib_none().0,
219            );
220        }
221    }
222
223    #[doc(alias = "accept-certificate")]
224    fn connect_accept_certificate<
225        F: Fn(&Self, &gio::TlsConnection, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool
226            + Send
227            + Sync
228            + 'static,
229    >(
230        &self,
231        f: F,
232    ) -> SignalHandlerId {
233        unsafe extern "C" fn accept_certificate_trampoline<
234            P: IsA<RTSPAuth>,
235            F: Fn(&P, &gio::TlsConnection, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool
236                + Send
237                + Sync
238                + 'static,
239        >(
240            this: *mut ffi::GstRTSPAuth,
241            connection: *mut gio::ffi::GTlsConnection,
242            peer_cert: *mut gio::ffi::GTlsCertificate,
243            errors: gio::ffi::GTlsCertificateFlags,
244            f: glib::ffi::gpointer,
245        ) -> glib::ffi::gboolean {
246            let f: &F = &*(f as *const F);
247            f(
248                RTSPAuth::from_glib_borrow(this).unsafe_cast_ref(),
249                &from_glib_borrow(connection),
250                &from_glib_borrow(peer_cert),
251                from_glib(errors),
252            )
253            .into_glib()
254        }
255        unsafe {
256            let f: Box_<F> = Box_::new(f);
257            connect_raw(
258                self.as_ptr() as *mut _,
259                c"accept-certificate".as_ptr() as *const _,
260                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
261                    accept_certificate_trampoline::<Self, F> as *const (),
262                )),
263                Box_::into_raw(f),
264            )
265        }
266    }
267}
268
269impl<O: IsA<RTSPAuth>> RTSPAuthExt for O {}