diff --git a/Gir_GstRtspServer.toml b/Gir_GstRtspServer.toml index 502a4075a..513bd5aa6 100644 --- a/Gir_GstRtspServer.toml +++ b/Gir_GstRtspServer.toml @@ -91,6 +91,11 @@ name = "GstRtspServer.RTSPContext" status = "manual" ref_mode = "ref" +[[object]] +name = "GstRtspServer.RTSPToken" +status = "manual" +ref_mode = "ref" + [[object]] name = "Gst.ClockTime" status = "manual" @@ -237,12 +242,3 @@ status="generate" name = "set_default_token" # gir forgets mut ignore = true - -[[object]] -name="GstRtspServer.RTSPToken" -status = "generate" -concurrency = "none" - [[object.function]] - name = "writable_structure" - # mutable ref - ignore = true diff --git a/gstreamer-rtsp-server/src/auto/mod.rs b/gstreamer-rtsp-server/src/auto/mod.rs index a2b953d5b..12368a4c8 100644 --- a/gstreamer-rtsp-server/src/auto/mod.rs +++ b/gstreamer-rtsp-server/src/auto/mod.rs @@ -61,9 +61,6 @@ pub use self::r_t_s_p_thread_pool::RTSPThreadPoolExt; mod r_t_s_p_address; pub use self::r_t_s_p_address::RTSPAddress; -mod r_t_s_p_token; -pub use self::r_t_s_p_token::RTSPToken; - mod enums; pub use self::enums::RTSPAddressPoolResult; pub use self::enums::RTSPMediaStatus; diff --git a/gstreamer-rtsp-server/src/auto/r_t_s_p_auth.rs b/gstreamer-rtsp-server/src/auto/r_t_s_p_auth.rs index e3081e459..bc06cd791 100644 --- a/gstreamer-rtsp-server/src/auto/r_t_s_p_auth.rs +++ b/gstreamer-rtsp-server/src/auto/r_t_s_p_auth.rs @@ -62,10 +62,10 @@ unsafe impl Send for RTSPAuth {} unsafe impl Sync for RTSPAuth {} pub trait RTSPAuthExt { - fn add_basic(&self, basic: &str, token: &mut RTSPToken); + fn add_basic(&self, basic: &str, token: &RTSPToken); #[cfg(any(feature = "v1_12", feature = "dox"))] - fn add_digest(&self, user: &str, pass: &str, token: &mut RTSPToken); + fn add_digest(&self, user: &str, pass: &str, token: &RTSPToken); fn get_default_token(&self) -> Option; @@ -96,16 +96,16 @@ pub trait RTSPAuthExt { } impl + IsA> RTSPAuthExt for O { - fn add_basic(&self, basic: &str, token: &mut RTSPToken) { + fn add_basic(&self, basic: &str, token: &RTSPToken) { unsafe { - ffi::gst_rtsp_auth_add_basic(self.to_glib_none().0, basic.to_glib_none().0, token.to_glib_none_mut().0); + ffi::gst_rtsp_auth_add_basic(self.to_glib_none().0, basic.to_glib_none().0, token.to_glib_none().0); } } #[cfg(any(feature = "v1_12", feature = "dox"))] - fn add_digest(&self, user: &str, pass: &str, token: &mut RTSPToken) { + fn add_digest(&self, user: &str, pass: &str, token: &RTSPToken) { unsafe { - ffi::gst_rtsp_auth_add_digest(self.to_glib_none().0, user.to_glib_none().0, pass.to_glib_none().0, token.to_glib_none_mut().0); + ffi::gst_rtsp_auth_add_digest(self.to_glib_none().0, user.to_glib_none().0, pass.to_glib_none().0, token.to_glib_none().0); } } diff --git a/gstreamer-rtsp-server/src/lib.rs b/gstreamer-rtsp-server/src/lib.rs index 32f2cc448..798221076 100644 --- a/gstreamer-rtsp-server/src/lib.rs +++ b/gstreamer-rtsp-server/src/lib.rs @@ -99,4 +99,5 @@ pub mod prelude { pub use r_t_s_p_client::RTSPClientExtManual; pub use r_t_s_p_session_pool::RTSPSessionPoolExtManual; pub use r_t_s_p_auth::RTSPAuthExtManual; + pub use r_t_s_p_token::GstRcRTSPTokenExt; } diff --git a/gstreamer-rtsp-server/src/r_t_s_p_token.rs b/gstreamer-rtsp-server/src/r_t_s_p_token.rs index 5463bb1a4..dab31097a 100644 --- a/gstreamer-rtsp-server/src/r_t_s_p_token.rs +++ b/gstreamer-rtsp-server/src/r_t_s_p_token.rs @@ -1,12 +1,33 @@ -use RTSPToken; -use glib::value::ToSendValue; -use gst; use ffi; +use gst_ffi; +use gst; +use glib; +use glib::StaticType; +use glib::value::ToSendValue; use glib::translate::*; -impl RTSPToken { - pub fn new(values: &[(&str, &ToSendValue)]) -> RTSPToken { - let mut token = RTSPToken::new_empty(); +use gst::miniobject::{MiniObject, GstRc}; + +pub trait GstRcRTSPTokenExt { + fn new_empty() -> Self; + fn new(values: &[(&str, &ToSendValue)]) -> Self; +} + +pub type RTSPToken = GstRc; +pub struct RTSPTokenRef(ffi::GstRTSPToken); + +unsafe impl MiniObject for RTSPTokenRef { + type GstType = ffi::GstRTSPToken; +} + +impl GstRcRTSPTokenExt for GstRc { + fn new_empty() -> Self { + assert_initialized_main_thread!(); + unsafe { from_glib_full(ffi::gst_rtsp_token_new_empty()) } + } + + fn new(values: &[(&str, &ToSendValue)]) -> Self { + let token = RTSPToken::new_empty(); { let structure = token.writable_structure().unwrap(); @@ -18,10 +39,30 @@ impl RTSPToken { token } +} - pub fn writable_structure(&mut self) -> Option<&mut gst::StructureRef> { +impl RTSPTokenRef { + pub fn get_string(&self, field: &str) -> Option { unsafe { - let structure = ffi::gst_rtsp_token_writable_structure(self.to_glib_none_mut().0); + from_glib_none(ffi::gst_rtsp_token_get_string(self.as_mut_ptr(), field.to_glib_none().0)) + } + } + + pub fn get_structure(&self) -> Option { + unsafe { + from_glib_none(ffi::gst_rtsp_token_get_structure(self.as_mut_ptr())) + } + } + + pub fn is_allowed(&self, field: &str) -> bool { + unsafe { + from_glib(ffi::gst_rtsp_token_is_allowed(self.as_mut_ptr(), field.to_glib_none().0)) + } + } + + pub fn writable_structure(&self) -> Option<&mut gst::StructureRef> { + unsafe { + let structure = ffi::gst_rtsp_token_writable_structure(self.as_mut_ptr()); if structure.is_null() { None } else { @@ -30,3 +71,17 @@ impl RTSPToken { } } } + +impl ToOwned for RTSPTokenRef { + type Owned = GstRc; + + fn to_owned(&self) -> GstRc { + unsafe { from_glib_full(gst_ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } + } +} + +impl StaticType for RTSPTokenRef { + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::gst_rtsp_token_get_type()) } + } +}