2018-03-29 18:43:25 +00:00
|
|
|
// Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
// //
|
|
|
|
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// // option. This file may not be copied, modified, or distributed
|
|
|
|
// // except according to those terms.
|
|
|
|
|
2018-04-05 17:41:31 +00:00
|
|
|
use std::ffi::CStr;
|
2018-03-29 18:43:25 +00:00
|
|
|
use std::mem;
|
|
|
|
use std::ptr;
|
|
|
|
|
|
|
|
use ffi;
|
|
|
|
use glib::translate::*;
|
|
|
|
use gst;
|
|
|
|
|
2018-04-23 17:37:08 +00:00
|
|
|
use sdp_attribute::SDPAttribute;
|
|
|
|
use sdp_bandwidth::SDPBandwidth;
|
|
|
|
use sdp_connection::SDPConnection;
|
|
|
|
use sdp_key::SDPKey;
|
2018-03-29 18:43:25 +00:00
|
|
|
|
2018-04-05 20:00:25 +00:00
|
|
|
#[cfg(any(feature = "v1_8_1", feature = "dox"))]
|
|
|
|
use MIKEYMessage;
|
|
|
|
|
2018-03-29 18:43:25 +00:00
|
|
|
glib_wrapper! {
|
2019-01-22 15:43:29 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
2018-03-29 18:43:25 +00:00
|
|
|
pub struct SDPMedia(Boxed<ffi::GstSDPMedia>);
|
|
|
|
|
|
|
|
match fn {
|
2018-04-04 18:40:45 +00:00
|
|
|
copy => |ptr| {
|
|
|
|
let mut copy = ptr::null_mut();
|
|
|
|
ffi::gst_sdp_media_copy(ptr as *const ffi::GstSDPMedia, &mut copy);
|
|
|
|
copy
|
|
|
|
},
|
|
|
|
free => |ptr| {
|
|
|
|
ffi::gst_sdp_media_free(ptr);
|
|
|
|
},
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SDPMedia {
|
2018-04-05 14:46:13 +00:00
|
|
|
pub fn new() -> Result<Self, ()> {
|
2018-04-04 18:40:45 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
|
|
|
let mut media = ptr::null_mut();
|
2018-04-05 18:05:49 +00:00
|
|
|
let result = ffi::gst_sdp_media_new(&mut media);
|
2018-04-05 14:46:13 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(from_glib_full(media)),
|
2018-04-05 14:46:13 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
2018-04-04 18:40:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-05 17:41:31 +00:00
|
|
|
pub fn add_attribute<'a, P: Into<Option<&'a str>>>(
|
|
|
|
&mut self,
|
|
|
|
key: &str,
|
|
|
|
value: P,
|
|
|
|
) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let value = value.into();
|
|
|
|
let value = value.to_glib_none();
|
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_add_attribute(
|
2018-04-05 17:41:31 +00:00
|
|
|
self.to_glib_none_mut().0,
|
|
|
|
key.to_glib_none().0,
|
|
|
|
value.0,
|
2018-04-05 18:05:49 +00:00
|
|
|
)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn add_bandwidth(&mut self, bwtype: &str, bandwidth: u32) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_add_bandwidth(
|
2018-04-05 17:41:31 +00:00
|
|
|
self.to_glib_none_mut().0,
|
|
|
|
bwtype.to_glib_none().0,
|
|
|
|
bandwidth,
|
2018-04-05 18:05:49 +00:00
|
|
|
)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-05 17:41:31 +00:00
|
|
|
pub fn add_connection(
|
|
|
|
&mut self,
|
|
|
|
nettype: &str,
|
|
|
|
addrtype: &str,
|
|
|
|
address: &str,
|
|
|
|
ttl: u32,
|
|
|
|
addr_number: u32,
|
|
|
|
) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_add_connection(
|
2018-04-05 17:41:31 +00:00
|
|
|
self.to_glib_none_mut().0,
|
|
|
|
nettype.to_glib_none().0,
|
|
|
|
addrtype.to_glib_none().0,
|
|
|
|
address.to_glib_none().0,
|
|
|
|
ttl,
|
|
|
|
addr_number,
|
2018-04-05 18:05:49 +00:00
|
|
|
)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn add_format(&mut self, format: &str) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_add_format(self.to_glib_none_mut().0, format.to_glib_none().0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_text(&self) -> Option<String> {
|
2018-04-05 17:41:31 +00:00
|
|
|
unsafe { from_glib_full(ffi::gst_sdp_media_as_text(self.to_glib_none().0)) }
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn attributes_len(&self) -> u32 {
|
2018-04-05 17:41:31 +00:00
|
|
|
unsafe { ffi::gst_sdp_media_attributes_len(self.to_glib_none().0) }
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn attributes_to_caps(&self, caps: &gst::Caps) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_attributes_to_caps(self.to_glib_none().0, caps.to_glib_none().0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn bandwidths_len(&self) -> u32 {
|
2018-04-05 17:41:31 +00:00
|
|
|
unsafe { ffi::gst_sdp_media_bandwidths_len(self.to_glib_none().0) }
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn connections_len(&self) -> u32 {
|
2018-04-05 17:41:31 +00:00
|
|
|
unsafe { ffi::gst_sdp_media_connections_len(self.to_glib_none().0) }
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn formats_len(&self) -> u32 {
|
2018-04-05 17:41:31 +00:00
|
|
|
unsafe { ffi::gst_sdp_media_formats_len(self.to_glib_none().0) }
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_attribute(&self, idx: u32) -> Option<&SDPAttribute> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-04 18:40:45 +00:00
|
|
|
let ptr = ffi::gst_sdp_media_get_attribute(self.to_glib_none().0, idx);
|
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(&*(ptr as *mut SDPAttribute))
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_attribute_val(&self, key: &str) -> Option<&str> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-05 17:41:31 +00:00
|
|
|
let ptr =
|
|
|
|
ffi::gst_sdp_media_get_attribute_val(self.to_glib_none().0, key.to_glib_none().0);
|
2018-04-04 18:40:45 +00:00
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
let result = CStr::from_ptr(ptr).to_str();
|
|
|
|
match result {
|
|
|
|
Ok(attr) => Some(attr),
|
|
|
|
Err(_) => None,
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_attribute_val_n(&self, key: &str, nth: u32) -> Option<&str> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-05 17:41:31 +00:00
|
|
|
let ptr = ffi::gst_sdp_media_get_attribute_val_n(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
key.to_glib_none().0,
|
|
|
|
nth,
|
|
|
|
);
|
2018-04-04 18:40:45 +00:00
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
let result = CStr::from_ptr(ptr).to_str();
|
|
|
|
match result {
|
|
|
|
Ok(attr) => Some(attr),
|
|
|
|
Err(_) => None,
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_bandwidth(&self, idx: u32) -> Option<&SDPBandwidth> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-04 18:40:45 +00:00
|
|
|
let ptr = ffi::gst_sdp_media_get_bandwidth(self.to_glib_none().0, idx);
|
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(&*(ptr as *mut SDPBandwidth))
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_caps_from_media(&self, pt: i32) -> Option<gst::Caps> {
|
|
|
|
unsafe {
|
2018-04-05 17:41:31 +00:00
|
|
|
from_glib_full(ffi::gst_sdp_media_get_caps_from_media(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
pt,
|
|
|
|
))
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_connection(&self, idx: u32) -> Option<&SDPConnection> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-04 18:40:45 +00:00
|
|
|
let ptr = ffi::gst_sdp_media_get_connection(self.to_glib_none().0, idx);
|
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(&*(ptr as *mut SDPConnection))
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_format(&self, idx: u32) -> Option<&str> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-04 18:40:45 +00:00
|
|
|
let ptr = ffi::gst_sdp_media_get_format(self.to_glib_none().0, idx);
|
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
let result = CStr::from_ptr(ptr).to_str();
|
|
|
|
match result {
|
|
|
|
Ok(attr) => Some(attr),
|
|
|
|
Err(_) => None,
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_information(&self) -> Option<&str> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-04 18:40:45 +00:00
|
|
|
let ptr = ffi::gst_sdp_media_get_information(self.to_glib_none().0);
|
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
let result = CStr::from_ptr(ptr).to_str();
|
|
|
|
match result {
|
|
|
|
Ok(attr) => Some(attr),
|
|
|
|
Err(_) => None,
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_key(&self) -> Option<&SDPKey> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-04 18:40:45 +00:00
|
|
|
let ptr = ffi::gst_sdp_media_get_key(self.to_glib_none().0);
|
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(&*(ptr as *mut SDPKey))
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_media(&self) -> Option<&str> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-04 18:40:45 +00:00
|
|
|
let ptr = ffi::gst_sdp_media_get_media(self.to_glib_none().0);
|
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
let result = CStr::from_ptr(ptr).to_str();
|
|
|
|
match result {
|
|
|
|
Ok(attr) => Some(attr),
|
|
|
|
Err(_) => None,
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_num_ports(&self) -> u32 {
|
2018-04-05 17:41:31 +00:00
|
|
|
unsafe { ffi::gst_sdp_media_get_num_ports(self.to_glib_none().0) }
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_port(&self) -> u32 {
|
2018-04-05 17:41:31 +00:00
|
|
|
unsafe { ffi::gst_sdp_media_get_port(self.to_glib_none().0) }
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn get_proto(&self) -> Option<&str> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
2018-04-04 18:40:45 +00:00
|
|
|
let ptr = ffi::gst_sdp_media_get_proto(self.to_glib_none().0);
|
|
|
|
if ptr.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
let result = CStr::from_ptr(ptr).to_str();
|
|
|
|
match result {
|
|
|
|
Ok(attr) => Some(attr),
|
|
|
|
Err(_) => None,
|
|
|
|
}
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn insert_attribute(&mut self, idx: i32, mut attr: SDPAttribute) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_insert_attribute(self.to_glib_none_mut().0, idx, &mut attr.0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
2018-04-04 18:40:45 +00:00
|
|
|
mem::forget(attr);
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn insert_bandwidth(&mut self, idx: i32, mut bw: SDPBandwidth) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_insert_bandwidth(self.to_glib_none_mut().0, idx, &mut bw.0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
2018-04-04 18:40:45 +00:00
|
|
|
mem::forget(bw);
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn insert_connection(&mut self, idx: i32, mut conn: SDPConnection) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_insert_connection(self.to_glib_none_mut().0, idx, &mut conn.0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
2018-04-04 18:40:45 +00:00
|
|
|
mem::forget(conn);
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn insert_format(&mut self, idx: i32, format: &str) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_insert_format(
|
2018-04-05 17:41:31 +00:00
|
|
|
self.to_glib_none_mut().0,
|
|
|
|
idx,
|
|
|
|
format.to_glib_none().0,
|
2018-04-05 18:05:49 +00:00
|
|
|
)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_8_1", feature = "dox"))]
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn parse_keymgmt(&self) -> Result<MIKEYMessage, ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
unsafe {
|
|
|
|
let mut mikey = ptr::null_mut();
|
2018-04-05 18:05:49 +00:00
|
|
|
let result = ffi::gst_sdp_media_parse_keymgmt(self.to_glib_none().0, &mut mikey);
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(from_glib_full(mikey)),
|
2018-04-04 18:40:45 +00:00
|
|
|
_ => Err(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn remove_attribute(&mut self, idx: u32) -> Result<(), ()> {
|
2018-04-05 18:05:49 +00:00
|
|
|
let result = unsafe { ffi::gst_sdp_media_remove_attribute(self.to_glib_none_mut().0, idx) };
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn remove_bandwidth(&mut self, idx: u32) -> Result<(), ()> {
|
2018-04-05 18:05:49 +00:00
|
|
|
let result = unsafe { ffi::gst_sdp_media_remove_bandwidth(self.to_glib_none_mut().0, idx) };
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn remove_connection(&mut self, idx: u32) -> Result<(), ()> {
|
2018-04-05 18:05:49 +00:00
|
|
|
let result =
|
|
|
|
unsafe { ffi::gst_sdp_media_remove_connection(self.to_glib_none_mut().0, idx) };
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn remove_format(&mut self, idx: u32) -> Result<(), ()> {
|
2018-04-05 18:05:49 +00:00
|
|
|
let result = unsafe { ffi::gst_sdp_media_remove_format(self.to_glib_none_mut().0, idx) };
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn replace_attribute(&mut self, idx: u32, mut attr: SDPAttribute) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_replace_attribute(self.to_glib_none_mut().0, idx, &mut attr.0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
2018-04-04 18:40:45 +00:00
|
|
|
mem::forget(attr);
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn replace_bandwidth(&mut self, idx: u32, mut bw: SDPBandwidth) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_replace_bandwidth(self.to_glib_none_mut().0, idx, &mut bw.0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
2018-04-04 18:40:45 +00:00
|
|
|
mem::forget(bw);
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn replace_connection(&mut self, idx: u32, mut conn: SDPConnection) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_replace_connection(self.to_glib_none_mut().0, idx, &mut conn.0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
2018-04-04 18:40:45 +00:00
|
|
|
mem::forget(conn);
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn replace_format(&mut self, idx: u32, format: &str) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_replace_format(
|
2018-04-05 17:41:31 +00:00
|
|
|
self.to_glib_none_mut().0,
|
|
|
|
idx,
|
|
|
|
format.to_glib_none().0,
|
2018-04-05 18:05:49 +00:00
|
|
|
)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn set_information(&mut self, information: &str) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_set_information(
|
2018-04-05 17:41:31 +00:00
|
|
|
self.to_glib_none_mut().0,
|
|
|
|
information.to_glib_none().0,
|
2018-04-05 18:05:49 +00:00
|
|
|
)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn set_key(&mut self, type_: &str, data: &str) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_set_key(
|
2018-04-05 17:41:31 +00:00
|
|
|
self.to_glib_none_mut().0,
|
|
|
|
type_.to_glib_none().0,
|
|
|
|
data.to_glib_none().0,
|
2018-04-05 18:05:49 +00:00
|
|
|
)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn set_media(&mut self, med: &str) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_set_media(self.to_glib_none_mut().0, med.to_glib_none().0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn set_port_info(&mut self, port: u32, num_ports: u32) -> Result<(), ()> {
|
2018-04-05 18:05:49 +00:00
|
|
|
let result =
|
|
|
|
unsafe { ffi::gst_sdp_media_set_port_info(self.to_glib_none_mut().0, port, num_ports) };
|
2018-03-29 18:43:25 +00:00
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn set_proto(&mut self, proto: &str) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_set_proto(self.to_glib_none_mut().0, proto.to_glib_none().0)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 18:40:45 +00:00
|
|
|
pub fn set_media_from_caps(caps: &gst::Caps, media: &mut SDPMedia) -> Result<(), ()> {
|
2018-03-29 18:43:25 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let result = unsafe {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::gst_sdp_media_set_media_from_caps(
|
2018-04-05 17:41:31 +00:00
|
|
|
caps.to_glib_none().0,
|
|
|
|
media.to_glib_none_mut().0,
|
2018-04-05 18:05:49 +00:00
|
|
|
)
|
2018-03-29 18:43:25 +00:00
|
|
|
};
|
|
|
|
match result {
|
2018-04-05 18:05:49 +00:00
|
|
|
ffi::GST_SDP_OK => Ok(()),
|
2018-03-29 18:43:25 +00:00
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|