2018-03-01 23:46:12 +00:00
|
|
|
use glib;
|
2018-02-23 02:33:37 +00:00
|
|
|
use glib::translate::*;
|
2018-04-01 08:30:03 +00:00
|
|
|
use glib::value::ToSendValue;
|
|
|
|
use gst;
|
2018-12-08 09:31:07 +00:00
|
|
|
use gst::miniobject::*;
|
2019-03-19 07:58:20 +00:00
|
|
|
use gst_rtsp_server_sys;
|
2018-02-23 02:33:37 +00:00
|
|
|
|
2018-12-08 09:31:07 +00:00
|
|
|
use std::fmt;
|
2018-03-01 23:46:12 +00:00
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_define_mini_object_wrapper!(
|
|
|
|
RTSPToken,
|
|
|
|
RTSPTokenRef,
|
|
|
|
gst_rtsp_server_sys::GstRTSPToken,
|
|
|
|
[Debug,],
|
|
|
|
|| gst_rtsp_server_sys::gst_rtsp_token_get_type()
|
|
|
|
);
|
2018-03-01 23:46:12 +00:00
|
|
|
|
2018-12-08 09:31:07 +00:00
|
|
|
impl RTSPToken {
|
|
|
|
pub fn new_empty() -> Self {
|
2018-03-01 23:46:12 +00:00
|
|
|
assert_initialized_main_thread!();
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe { from_glib_full(gst_rtsp_server_sys::gst_rtsp_token_new_empty()) }
|
2018-03-01 23:46:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 09:31:07 +00:00
|
|
|
pub fn new(values: &[(&str, &ToSendValue)]) -> Self {
|
2018-07-20 07:21:06 +00:00
|
|
|
let mut token = RTSPToken::new_empty();
|
2018-02-23 02:33:37 +00:00
|
|
|
|
|
|
|
{
|
2018-07-20 07:21:06 +00:00
|
|
|
let token = token.get_mut().unwrap();
|
|
|
|
let structure = token.get_mut_structure().unwrap();
|
2018-02-23 02:33:37 +00:00
|
|
|
|
|
|
|
for &(f, v) in values {
|
|
|
|
structure.set_value(f, v.to_send_value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
token
|
|
|
|
}
|
2018-03-01 23:46:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl RTSPTokenRef {
|
|
|
|
pub fn get_string(&self, field: &str) -> Option<String> {
|
|
|
|
unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
from_glib_none(gst_rtsp_server_sys::gst_rtsp_token_get_string(
|
2018-04-01 08:30:03 +00:00
|
|
|
self.as_mut_ptr(),
|
|
|
|
field.to_glib_none().0,
|
|
|
|
))
|
2018-03-01 23:46:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_structure(&self) -> Option<gst::Structure> {
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
|
|
|
from_glib_none(gst_rtsp_server_sys::gst_rtsp_token_get_structure(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
))
|
|
|
|
}
|
2018-03-01 23:46:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_allowed(&self, field: &str) -> bool {
|
|
|
|
unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
from_glib(gst_rtsp_server_sys::gst_rtsp_token_is_allowed(
|
2018-04-01 08:30:03 +00:00
|
|
|
self.as_mut_ptr(),
|
|
|
|
field.to_glib_none().0,
|
|
|
|
))
|
2018-03-01 23:46:12 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-23 02:33:37 +00:00
|
|
|
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn get_mut_structure(&mut self) -> Option<&mut gst::StructureRef> {
|
2018-02-23 02:33:37 +00:00
|
|
|
unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
let structure =
|
|
|
|
gst_rtsp_server_sys::gst_rtsp_token_writable_structure(self.as_mut_ptr());
|
2018-02-23 02:33:37 +00:00
|
|
|
if structure.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(gst::StructureRef::from_glib_borrow_mut(structure))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-01 23:46:12 +00:00
|
|
|
|
2018-12-08 09:31:07 +00:00
|
|
|
impl fmt::Debug for RTSPTokenRef {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
f.debug_struct("RTSPToken")
|
|
|
|
.field("structure", &self.get_structure())
|
|
|
|
.finish()
|
2018-03-01 23:46:12 +00:00
|
|
|
}
|
|
|
|
}
|