Manual bindings for RTSPToken

This commit is contained in:
Mathieu Duponchelle 2018-03-02 00:46:12 +01:00 committed by Sebastian Dröge
parent a3b294f0f2
commit 9448f1cc3e
5 changed files with 75 additions and 26 deletions

View file

@ -91,6 +91,11 @@ name = "GstRtspServer.RTSPContext"
status = "manual" status = "manual"
ref_mode = "ref" ref_mode = "ref"
[[object]]
name = "GstRtspServer.RTSPToken"
status = "manual"
ref_mode = "ref"
[[object]] [[object]]
name = "Gst.ClockTime" name = "Gst.ClockTime"
status = "manual" status = "manual"
@ -237,12 +242,3 @@ status="generate"
name = "set_default_token" name = "set_default_token"
# gir forgets mut # gir forgets mut
ignore = true ignore = true
[[object]]
name="GstRtspServer.RTSPToken"
status = "generate"
concurrency = "none"
[[object.function]]
name = "writable_structure"
# mutable ref
ignore = true

View file

@ -61,9 +61,6 @@ pub use self::r_t_s_p_thread_pool::RTSPThreadPoolExt;
mod r_t_s_p_address; mod r_t_s_p_address;
pub use self::r_t_s_p_address::RTSPAddress; 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; mod enums;
pub use self::enums::RTSPAddressPoolResult; pub use self::enums::RTSPAddressPoolResult;
pub use self::enums::RTSPMediaStatus; pub use self::enums::RTSPMediaStatus;

View file

@ -62,10 +62,10 @@ unsafe impl Send for RTSPAuth {}
unsafe impl Sync for RTSPAuth {} unsafe impl Sync for RTSPAuth {}
pub trait RTSPAuthExt { 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"))] #[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<RTSPToken>; fn get_default_token(&self) -> Option<RTSPToken>;
@ -96,16 +96,16 @@ pub trait RTSPAuthExt {
} }
impl<O: IsA<RTSPAuth> + IsA<glib::object::Object>> RTSPAuthExt for O { impl<O: IsA<RTSPAuth> + IsA<glib::object::Object>> RTSPAuthExt for O {
fn add_basic(&self, basic: &str, token: &mut RTSPToken) { fn add_basic(&self, basic: &str, token: &RTSPToken) {
unsafe { 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"))] #[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 { 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);
} }
} }

View file

@ -99,4 +99,5 @@ pub mod prelude {
pub use r_t_s_p_client::RTSPClientExtManual; pub use r_t_s_p_client::RTSPClientExtManual;
pub use r_t_s_p_session_pool::RTSPSessionPoolExtManual; pub use r_t_s_p_session_pool::RTSPSessionPoolExtManual;
pub use r_t_s_p_auth::RTSPAuthExtManual; pub use r_t_s_p_auth::RTSPAuthExtManual;
pub use r_t_s_p_token::GstRcRTSPTokenExt;
} }

View file

@ -1,12 +1,33 @@
use RTSPToken;
use glib::value::ToSendValue;
use gst;
use ffi; use ffi;
use gst_ffi;
use gst;
use glib;
use glib::StaticType;
use glib::value::ToSendValue;
use glib::translate::*; use glib::translate::*;
impl RTSPToken { use gst::miniobject::{MiniObject, GstRc};
pub fn new(values: &[(&str, &ToSendValue)]) -> RTSPToken {
let mut token = RTSPToken::new_empty(); pub trait GstRcRTSPTokenExt<T: MiniObject> {
fn new_empty() -> Self;
fn new(values: &[(&str, &ToSendValue)]) -> Self;
}
pub type RTSPToken = GstRc<RTSPTokenRef>;
pub struct RTSPTokenRef(ffi::GstRTSPToken);
unsafe impl MiniObject for RTSPTokenRef {
type GstType = ffi::GstRTSPToken;
}
impl GstRcRTSPTokenExt<RTSPTokenRef> for GstRc<RTSPTokenRef> {
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(); let structure = token.writable_structure().unwrap();
@ -18,10 +39,30 @@ impl RTSPToken {
token token
} }
}
pub fn writable_structure(&mut self) -> Option<&mut gst::StructureRef> { impl RTSPTokenRef {
pub fn get_string(&self, field: &str) -> Option<String> {
unsafe { 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<gst::Structure> {
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() { if structure.is_null() {
None None
} else { } else {
@ -30,3 +71,17 @@ impl RTSPToken {
} }
} }
} }
impl ToOwned for RTSPTokenRef {
type Owned = GstRc<RTSPTokenRef>;
fn to_owned(&self) -> GstRc<RTSPTokenRef> {
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()) }
}
}