forked from mirrors/gstreamer-rs
sdp: Use an actual error type instead of ()
Fixes a new clippy warning.
This commit is contained in:
parent
1523382b18
commit
59397c84be
2 changed files with 135 additions and 100 deletions
|
@ -187,11 +187,11 @@ impl SDPMediaRef {
|
|||
unsafe { ffi::gst_sdp_media_attributes_len(&self.0) }
|
||||
}
|
||||
|
||||
pub fn attributes_to_caps(&self, caps: &mut gst::CapsRef) -> Result<(), ()> {
|
||||
pub fn attributes_to_caps(&self, caps: &mut gst::CapsRef) -> Result<(), glib::BoolError> {
|
||||
let result = unsafe { ffi::gst_sdp_media_attributes_to_caps(&self.0, caps.as_mut_ptr()) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to store attributes in caps")),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,10 +369,14 @@ impl SDPMediaRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn insert_attribute(&mut self, idx: Option<u32>, attr: SDPAttribute) -> Result<(), ()> {
|
||||
pub fn insert_attribute(
|
||||
&mut self,
|
||||
idx: Option<u32>,
|
||||
attr: SDPAttribute,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.attributes_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert attribute"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,14 +385,18 @@ impl SDPMediaRef {
|
|||
let result = unsafe { ffi::gst_sdp_media_insert_attribute(&mut self.0, idx, &mut attr.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert attribute")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_bandwidth(&mut self, idx: Option<u32>, bw: SDPBandwidth) -> Result<(), ()> {
|
||||
pub fn insert_bandwidth(
|
||||
&mut self,
|
||||
idx: Option<u32>,
|
||||
bw: SDPBandwidth,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.bandwidths_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert bandwidth"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,14 +405,18 @@ impl SDPMediaRef {
|
|||
let result = unsafe { ffi::gst_sdp_media_insert_bandwidth(&mut self.0, idx, &mut bw.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert attribute")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_connection(&mut self, idx: Option<u32>, conn: SDPConnection) -> Result<(), ()> {
|
||||
pub fn insert_connection(
|
||||
&mut self,
|
||||
idx: Option<u32>,
|
||||
conn: SDPConnection,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.connections_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert connection"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -413,14 +425,14 @@ impl SDPMediaRef {
|
|||
let result = unsafe { ffi::gst_sdp_media_insert_connection(&mut self.0, idx, &mut conn.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert connection")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_format(&mut self, idx: Option<u32>, format: &str) -> Result<(), ()> {
|
||||
pub fn insert_format(&mut self, idx: Option<u32>, format: &str) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.formats_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert format"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,87 +441,95 @@ impl SDPMediaRef {
|
|||
unsafe { ffi::gst_sdp_media_insert_format(&mut self.0, idx, format.to_glib_none().0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert format")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_attribute(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_attribute(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.attributes_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove attribute"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_media_remove_attribute(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove attribute")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_bandwidth(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_bandwidth(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.bandwidths_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove bandwidth"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_media_remove_bandwidth(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove bandwidth")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_connection(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_connection(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.connections_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove connection"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_media_remove_connection(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove connection")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_format(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_format(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.formats_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove format"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_media_remove_format(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove format")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_attribute(&mut self, idx: u32, attr: SDPAttribute) -> Result<(), ()> {
|
||||
pub fn replace_attribute(
|
||||
&mut self,
|
||||
idx: u32,
|
||||
attr: SDPAttribute,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.attributes_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace attribute"));
|
||||
}
|
||||
|
||||
let mut attr = mem::ManuallyDrop::new(attr);
|
||||
let result = unsafe { ffi::gst_sdp_media_replace_attribute(&mut self.0, idx, &mut attr.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace attribute")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_bandwidth(&mut self, idx: u32, bw: SDPBandwidth) -> Result<(), ()> {
|
||||
pub fn replace_bandwidth(&mut self, idx: u32, bw: SDPBandwidth) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.bandwidths_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace bandwidth"));
|
||||
}
|
||||
|
||||
let mut bw = mem::ManuallyDrop::new(bw);
|
||||
let result = unsafe { ffi::gst_sdp_media_replace_bandwidth(&mut self.0, idx, &mut bw.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace bandwidth")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_connection(&mut self, idx: u32, conn: SDPConnection) -> Result<(), ()> {
|
||||
pub fn replace_connection(
|
||||
&mut self,
|
||||
idx: u32,
|
||||
conn: SDPConnection,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.connections_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace connection"));
|
||||
}
|
||||
|
||||
let mut conn = mem::ManuallyDrop::new(conn);
|
||||
|
@ -517,20 +537,20 @@ impl SDPMediaRef {
|
|||
unsafe { ffi::gst_sdp_media_replace_connection(&mut self.0, idx, &mut conn.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace connection")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_format(&mut self, idx: u32, format: &str) -> Result<(), ()> {
|
||||
pub fn replace_format(&mut self, idx: u32, format: &str) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.formats_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace format"));
|
||||
}
|
||||
|
||||
let result =
|
||||
unsafe { ffi::gst_sdp_media_replace_format(&mut self.0, idx, format.to_glib_none().0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace format")),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -556,7 +576,10 @@ impl SDPMediaRef {
|
|||
unsafe { ffi::gst_sdp_media_set_proto(&mut self.0, proto.to_glib_none().0) };
|
||||
}
|
||||
|
||||
pub fn set_media_from_caps(caps: &gst::Caps, media: &mut SDPMedia) -> Result<(), ()> {
|
||||
pub fn set_media_from_caps(
|
||||
caps: &gst::Caps,
|
||||
media: &mut SDPMedia,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
assert_initialized_main_thread!();
|
||||
let result = unsafe {
|
||||
ffi::gst_sdp_media_set_media_from_caps(
|
||||
|
@ -566,7 +589,7 @@ impl SDPMediaRef {
|
|||
};
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to set media from caps")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ impl SDPMessage {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse_buffer(data: &[u8]) -> Result<Self, ()> {
|
||||
pub fn parse_buffer(data: &[u8]) -> Result<Self, glib::BoolError> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let size = data.len() as u32;
|
||||
|
@ -86,13 +86,13 @@ impl SDPMessage {
|
|||
ffi::GST_SDP_OK => Ok(from_glib_full(msg)),
|
||||
_ => {
|
||||
ffi::gst_sdp_message_uninit(msg);
|
||||
Err(())
|
||||
Err(glib::bool_error!("Failed to parse buffer"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_uri(uri: &str) -> Result<Self, ()> {
|
||||
pub fn parse_uri(uri: &str) -> Result<Self, glib::BoolError> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut msg = ptr::null_mut();
|
||||
|
@ -102,7 +102,7 @@ impl SDPMessage {
|
|||
ffi::GST_SDP_OK => Ok(from_glib_full(msg)),
|
||||
_ => {
|
||||
ffi::gst_sdp_message_uninit(msg);
|
||||
Err(())
|
||||
Err(glib::bool_error!("Failed to parse URI"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,11 +221,11 @@ impl SDPMessageRef {
|
|||
unsafe { ffi::gst_sdp_message_attributes_len(&self.0) }
|
||||
}
|
||||
|
||||
pub fn attributes_to_caps(&self, caps: &mut gst::CapsRef) -> Result<(), ()> {
|
||||
pub fn attributes_to_caps(&self, caps: &mut gst::CapsRef) -> Result<(), glib::BoolError> {
|
||||
let result = unsafe { ffi::gst_sdp_message_attributes_to_caps(&self.0, caps.as_mut_ptr()) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to store attributes in caps")),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -492,10 +492,14 @@ impl SDPMessageRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn insert_attribute(&mut self, idx: Option<u32>, attr: SDPAttribute) -> Result<(), ()> {
|
||||
pub fn insert_attribute(
|
||||
&mut self,
|
||||
idx: Option<u32>,
|
||||
attr: SDPAttribute,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.attributes_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert attribute"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -505,14 +509,18 @@ impl SDPMessageRef {
|
|||
unsafe { ffi::gst_sdp_message_insert_attribute(&mut self.0, idx, &mut attr.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert attribute")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_bandwidth(&mut self, idx: Option<u32>, bw: SDPBandwidth) -> Result<(), ()> {
|
||||
pub fn insert_bandwidth(
|
||||
&mut self,
|
||||
idx: Option<u32>,
|
||||
bw: SDPBandwidth,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.bandwidths_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert bandwidth"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -521,14 +529,14 @@ impl SDPMessageRef {
|
|||
let result = unsafe { ffi::gst_sdp_message_insert_bandwidth(&mut self.0, idx, &mut bw.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert bandwidth")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_email(&mut self, idx: Option<u32>, email: &str) -> Result<(), ()> {
|
||||
pub fn insert_email(&mut self, idx: Option<u32>, email: &str) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.emails_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert email"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,14 +545,14 @@ impl SDPMessageRef {
|
|||
unsafe { ffi::gst_sdp_message_insert_email(&mut self.0, idx, email.to_glib_none().0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert email")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_phone(&mut self, idx: Option<u32>, phone: &str) -> Result<(), ()> {
|
||||
pub fn insert_phone(&mut self, idx: Option<u32>, phone: &str) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.phones_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert phone"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -553,14 +561,14 @@ impl SDPMessageRef {
|
|||
unsafe { ffi::gst_sdp_message_insert_phone(&mut self.0, idx, phone.to_glib_none().0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert phone")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_time(&mut self, idx: Option<u32>, time: SDPTime) -> Result<(), ()> {
|
||||
pub fn insert_time(&mut self, idx: Option<u32>, time: SDPTime) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.times_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert time"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,14 +577,14 @@ impl SDPMessageRef {
|
|||
let result = unsafe { ffi::gst_sdp_message_insert_time(&mut self.0, idx, &mut time.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert time")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_zone(&mut self, idx: Option<u32>, zone: SDPZone) -> Result<(), ()> {
|
||||
pub fn insert_zone(&mut self, idx: Option<u32>, zone: SDPZone) -> Result<(), glib::BoolError> {
|
||||
if let Some(idx) = idx {
|
||||
if idx >= self.zones_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to insert zone"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -585,7 +593,7 @@ impl SDPMessageRef {
|
|||
let result = unsafe { ffi::gst_sdp_message_insert_zone(&mut self.0, idx, &mut zone.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to insert zone")),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -597,81 +605,85 @@ impl SDPMessageRef {
|
|||
unsafe { ffi::gst_sdp_message_phones_len(&self.0) }
|
||||
}
|
||||
|
||||
pub fn remove_attribute(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_attribute(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.attributes_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove attribute"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_message_remove_attribute(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove attribute")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_bandwidth(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_bandwidth(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.bandwidths_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove bandwidth"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_message_remove_bandwidth(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove bandwidth")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_email(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_email(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.emails_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove email"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_message_remove_email(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove email")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_phone(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_phone(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.phones_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove phone"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_message_remove_phone(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove phone")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_time(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_time(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.times_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove time"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_message_remove_time(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove time")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_zone(&mut self, idx: u32) -> Result<(), ()> {
|
||||
pub fn remove_zone(&mut self, idx: u32) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.zones_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to remove zone"));
|
||||
}
|
||||
|
||||
let result = unsafe { ffi::gst_sdp_message_remove_zone(&mut self.0, idx) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to remove zone")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_attribute(&mut self, idx: u32, attr: SDPAttribute) -> Result<(), ()> {
|
||||
pub fn replace_attribute(
|
||||
&mut self,
|
||||
idx: u32,
|
||||
attr: SDPAttribute,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.attributes_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace attribute"));
|
||||
}
|
||||
|
||||
let mut attr = mem::ManuallyDrop::new(attr);
|
||||
|
@ -679,72 +691,72 @@ impl SDPMessageRef {
|
|||
unsafe { ffi::gst_sdp_message_replace_attribute(&mut self.0, idx, &mut attr.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace attribute")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_bandwidth(&mut self, idx: u32, bw: SDPBandwidth) -> Result<(), ()> {
|
||||
pub fn replace_bandwidth(&mut self, idx: u32, bw: SDPBandwidth) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.bandwidths_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace bandwidth"));
|
||||
}
|
||||
|
||||
let mut bw = mem::ManuallyDrop::new(bw);
|
||||
let result = unsafe { ffi::gst_sdp_message_replace_bandwidth(&mut self.0, idx, &mut bw.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace bandwidth")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_email(&mut self, idx: u32, email: &str) -> Result<(), ()> {
|
||||
pub fn replace_email(&mut self, idx: u32, email: &str) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.emails_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace email"));
|
||||
}
|
||||
|
||||
let result =
|
||||
unsafe { ffi::gst_sdp_message_replace_email(&mut self.0, idx, email.to_glib_none().0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace email")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_phone(&mut self, idx: u32, phone: &str) -> Result<(), ()> {
|
||||
pub fn replace_phone(&mut self, idx: u32, phone: &str) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.phones_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace phone"));
|
||||
}
|
||||
|
||||
let result =
|
||||
unsafe { ffi::gst_sdp_message_replace_phone(&mut self.0, idx, phone.to_glib_none().0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace phone")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_time(&mut self, idx: u32, time: SDPTime) -> Result<(), ()> {
|
||||
pub fn replace_time(&mut self, idx: u32, time: SDPTime) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.times_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace time"));
|
||||
}
|
||||
|
||||
let mut time = mem::ManuallyDrop::new(time);
|
||||
let result = unsafe { ffi::gst_sdp_message_replace_time(&mut self.0, idx, &mut time.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace time")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_zone(&mut self, idx: u32, zone: SDPZone) -> Result<(), ()> {
|
||||
pub fn replace_zone(&mut self, idx: u32, zone: SDPZone) -> Result<(), glib::BoolError> {
|
||||
if idx >= self.zones_len() {
|
||||
return Err(());
|
||||
return Err(glib::bool_error!("Failed to replace zone"));
|
||||
}
|
||||
|
||||
let mut zone = mem::ManuallyDrop::new(zone);
|
||||
let result = unsafe { ffi::gst_sdp_message_replace_zone(&mut self.0, idx, &mut zone.0) };
|
||||
match result {
|
||||
ffi::GST_SDP_OK => Ok(()),
|
||||
_ => Err(()),
|
||||
_ => Err(glib::bool_error!("Failed to replace zone")),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue