diff --git a/gstreamer-sdp/src/lib.rs b/gstreamer-sdp/src/lib.rs index 8ffe1a938..bb056c3ad 100644 --- a/gstreamer-sdp/src/lib.rs +++ b/gstreamer-sdp/src/lib.rs @@ -18,11 +18,11 @@ extern crate gstreamer_sdp_sys as ffi; extern crate gstreamer_sys as gst_ffi; macro_rules! assert_initialized_main_thread { - () => ( - if unsafe {::gst_ffi::gst_is_initialized()} != ::glib_ffi::GTRUE { + () => { + if unsafe { ::gst_ffi::gst_is_initialized() } != ::glib_ffi::GTRUE { panic!("GStreamer has not been initialized. Call `gst::init` first."); } - ) + }; } macro_rules! skip_assert_initialized { @@ -38,19 +38,19 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue mod auto; pub use auto::*; -mod s_d_p_message; -mod s_d_p_media; +mod m_i_k_e_y_decrypt_info; +mod m_i_k_e_y_encrypt_info; +mod m_i_k_e_y_map_s_r_t_p; +mod m_i_k_e_y_payload_s_p_param; mod s_d_p_attribute; mod s_d_p_bandwidth; mod s_d_p_connection; mod s_d_p_key; +mod s_d_p_media; +mod s_d_p_message; mod s_d_p_origin; mod s_d_p_time; mod s_d_p_zone; -mod m_i_k_e_y_payload_s_p_param; -mod m_i_k_e_y_encrypt_info; -mod m_i_k_e_y_decrypt_info; -mod m_i_k_e_y_map_s_r_t_p; // Re-export all the traits in a prelude module, so that applications // can always "use gst::prelude::*" without getting conflicts diff --git a/gstreamer-sdp/src/m_i_k_e_y_map_s_r_t_p.rs b/gstreamer-sdp/src/m_i_k_e_y_map_s_r_t_p.rs index 3b158e646..4c69f884c 100644 --- a/gstreamer-sdp/src/m_i_k_e_y_map_s_r_t_p.rs +++ b/gstreamer-sdp/src/m_i_k_e_y_map_s_r_t_p.rs @@ -13,10 +13,10 @@ pub struct MIKEYMapSRTP(ffi::GstMIKEYMapSRTP); impl MIKEYMapSRTP { pub fn new(policy: u8, ssrc: u32, roc: u32) -> MIKEYMapSRTP { - MIKEYMapSRTP(ffi::GstMIKEYMapSRTP{ - policy: policy, - ssrc: ssrc, - roc: roc, + MIKEYMapSRTP(ffi::GstMIKEYMapSRTP { + policy: policy, + ssrc: ssrc, + roc: roc, }) } diff --git a/gstreamer-sdp/src/m_i_k_e_y_message.rs b/gstreamer-sdp/src/m_i_k_e_y_message.rs index 8f6e2cc9e..67434696b 100644 --- a/gstreamer-sdp/src/m_i_k_e_y_message.rs +++ b/gstreamer-sdp/src/m_i_k_e_y_message.rs @@ -15,50 +15,81 @@ use glib_ffi; use gobject_ffi; use gst; -use auto::{ - MIKEYMessage, - MIKEYTSType, -}; -use m_i_k_e_y_payload::MIKEYPayload; +use auto::{MIKEYMessage, MIKEYTSType}; use m_i_k_e_y_decrypt_info::MIKEYDecryptInfo; use m_i_k_e_y_encrypt_info::MIKEYEncryptInfo; use m_i_k_e_y_map_s_r_t_p::MIKEYMapSRTP; +use m_i_k_e_y_payload::MIKEYPayload; impl MIKEYMessage { - pub fn new_from_bytes<'a, P: Into>>(bytes: &glib::Bytes, info: P) -> Result { + pub fn new_from_bytes<'a, P: Into>>( + bytes: &glib::Bytes, + info: P, + ) -> Result { unsafe { let mut error = ptr::null_mut(); - let ret = ffi::gst_mikey_message_new_from_bytes(bytes.to_glib_none(), info.to_glib_full(), &mut error); + let ret = ffi::gst_mikey_message_new_from_bytes( + bytes.to_glib_none(), + info.to_glib_full(), + &mut error, + ); mem::forget(bytes); mem::forget(info); - if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } } } - pub fn new_from_data<'a, P: Into>>(data: &[u8], info: P) -> Result { + pub fn new_from_data<'a, P: Into>>( + data: &[u8], + info: P, + ) -> Result { unsafe { let mut error = ptr::null_mut(); - let ret = ffi::gst_mikey_message_new_from_data(data.to_glib_none().0, data.len(), info.to_glib_full(), &mut err); + let ret = ffi::gst_mikey_message_new_from_data( + data.to_glib_none().0, + data.len(), + info.to_glib_full(), + &mut err, + ); mem::forget(info); - if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } } } pub fn add_t(&mut self, type_: MIKEYTSType, ts_value: &[u8]) -> bool { unsafe { - from_glib(ffi::gst_mikey_message_add_t(self.to_glib_none_mut().0, type_.to_glib(), ts_value.to_glib_none().0)) + from_glib(ffi::gst_mikey_message_add_t( + self.to_glib_none_mut().0, + type_.to_glib(), + ts_value.to_glib_none().0, + )) } } pub fn get_cs_srtp(&self, idx: u32) -> Option<&MIKEYMapSRTP> { unsafe { - &*(from_glib_none(ffi::gst_mikey_message_get_cs_srtp(self.to_glib_none().0, idx)) as *mut MIKEYMapSRTP) + &*(from_glib_none(ffi::gst_mikey_message_get_cs_srtp( + self.to_glib_none().0, + idx, + )) as *mut MIKEYMapSRTP) } } pub fn insert_cs_srtp(&mut self, idx: i32, map: MIKEYMapSRTP) -> bool { unsafe { - let ret = from_glib(ffi::gst_mikey_message_insert_cs_srtp(self.to_glib_none_mut().0, idx, map.to_glib_full())); + let ret = from_glib(ffi::gst_mikey_message_insert_cs_srtp( + self.to_glib_none_mut().0, + idx, + map.to_glib_full(), + )); mem::forget(map); ret } @@ -66,21 +97,31 @@ impl MIKEYMessage { pub fn get_payload(&self, idx: u32) -> Option<&MIKEYPayload> { unsafe { - &*(from_glib_none(ffi::gst_mikey_message_get_payload(self.to_glib_none().0, idx)) as *mut MIKEYPayload) + &*(from_glib_none(ffi::gst_mikey_message_get_payload( + self.to_glib_none().0, + idx, + )) as *mut MIKEYPayload) } } - pub fn add_payload(&mut self, payload: MIKEYPayload) -> bool { - unsafe { - let ret = from_glib(ffi::gst_mikey_message_add_payload(self.to_glib_none_mut().0, payload.to_glib_full())); + pub fn add_payload(&mut self, payload: MIKEYPayload) -> bool { + unsafe { + let ret = from_glib(ffi::gst_mikey_message_add_payload( + self.to_glib_none_mut().0, + payload.to_glib_full(), + )); mem::forget(payload); ret - } + } } pub fn insert_payload(&mut self, idx: u32, payload: MIKEYPayload) -> bool { unsafe { - let ret = from_glib(ffi::gst_mikey_message_insert_payload(self.to_glib_none_mut().0, idx, payload.to_glib_full())); + let ret = from_glib(ffi::gst_mikey_message_insert_payload( + self.to_glib_none_mut().0, + idx, + payload.to_glib_full(), + )); mem::forget(payload); ret } @@ -88,7 +129,11 @@ impl MIKEYMessage { pub fn replace_cs_srtp(&mut self, idx: i32, map: MIKEYMapSRTP) -> bool { unsafe { - let ret = from_glib(ffi::gst_mikey_message_replace_cs_srtp(self.to_glib_none_mut().0, idx, map.to_glib_full())); + let ret = from_glib(ffi::gst_mikey_message_replace_cs_srtp( + self.to_glib_none_mut().0, + idx, + map.to_glib_full(), + )); mem::forget(map); ret } @@ -96,7 +141,11 @@ impl MIKEYMessage { pub fn replace_payload(&mut self, idx: u32, payload: MIKEYPayload) -> bool { unsafe { - let ret = from_glib(ffi::gst_mikey_message_replace_payload(self.to_glib_none_mut().0, idx, payload.to_glib_full())); + let ret = from_glib(ffi::gst_mikey_message_replace_payload( + self.to_glib_none_mut().0, + idx, + payload.to_glib_full(), + )); mem::forget(payload); ret } @@ -104,7 +153,9 @@ impl MIKEYMessage { pub fn base64_encode(&self) -> Option { unsafe { - from_glib_full(ffi::gst_mikey_message_base64_encode(self.to_glib_none_mut().0)) + from_glib_full(ffi::gst_mikey_message_base64_encode( + self.to_glib_none_mut().0, + )) } } } diff --git a/gstreamer-sdp/src/m_i_k_e_y_payload.rs b/gstreamer-sdp/src/m_i_k_e_y_payload.rs index 26bd0e65a..82c02e910 100644 --- a/gstreamer-sdp/src/m_i_k_e_y_payload.rs +++ b/gstreamer-sdp/src/m_i_k_e_y_payload.rs @@ -18,10 +18,12 @@ use auto::MIKEYPayload; use m_i_k_e_y_map_s_r_t_p::MIKEYPayloadSPParam; impl MIKEYPayload { - pub fn kemac_add_sub(&mut self, newpay: MIKEYPayload) -> bool { unsafe { - let ret = from_glib(ffi::gst_mikey_payload_kemac_add_sub(self.to_glib_none_mut().0, newpay.to_glib_full())); + let ret = from_glib(ffi::gst_mikey_payload_kemac_add_sub( + self.to_glib_none_mut().0, + newpay.to_glib_full(), + )); mem::forget(newpay); ret } @@ -29,19 +31,29 @@ impl MIKEYPayload { pub fn kemac_get_sub(&self, idx: u32) -> Option<&MIKEYPayload> { unsafe { - &*(from_glib_none(ffi::gst_mikey_payload_kemac_get_sub(self.to_glib_none().0, idx)) as *mut MIKEYPayload) + &*(from_glib_none(ffi::gst_mikey_payload_kemac_get_sub( + self.to_glib_none().0, + idx, + )) as *mut MIKEYPayload) } } pub fn sp_get_param(&self, idx: u32) -> Option<&MIKEYPayloadSPParam> { unsafe { - &*(from_glib_none(ffi::gst_mikey_payload_sp_get_param(self.to_glib_none().0, idx)) as *mut MIKEYPayloadSPParam) + &*(from_glib_none(ffi::gst_mikey_payload_sp_get_param( + self.to_glib_none().0, + idx, + )) as *mut MIKEYPayloadSPParam) } } pub fn t_set(&mut self, type_: MIKEYTSType, ts_value: &[u8]) -> bool { unsafe { - from_glib(ffi::gst_mikey_payload_t_set(self.to_glib_none_mut().0, type_.to_glib(), ts_value.to_glib_none().0)) + from_glib(ffi::gst_mikey_payload_t_set( + self.to_glib_none_mut().0, + type_.to_glib(), + ts_value.to_glib_none().0, + )) } } @@ -49,8 +61,13 @@ impl MIKEYPayload { let vf_len = vf_data.len() as u8; let vt_len = vt_data.len() as u8; unsafe { - from_glib(ffi::gst_mikey_payload_key_data_set_interval(self.to_glib_none_mut().0, vf_len, vf_data.to_glib_none().0, vt_len, vt_data.to_glib_none().0)) + from_glib(ffi::gst_mikey_payload_key_data_set_interval( + self.to_glib_none_mut().0, + vf_len, + vf_data.to_glib_none().0, + vt_len, + vt_data.to_glib_none().0, + )) } } - } diff --git a/gstreamer-sdp/src/m_i_k_e_y_payload_s_p_param.rs b/gstreamer-sdp/src/m_i_k_e_y_payload_s_p_param.rs index 1623f95b2..8d39ba5c5 100644 --- a/gstreamer-sdp/src/m_i_k_e_y_payload_s_p_param.rs +++ b/gstreamer-sdp/src/m_i_k_e_y_payload_s_p_param.rs @@ -23,8 +23,6 @@ impl MIKEYPayloadSPParam { } pub fn val(&self) -> &[u8] { - unsafe { - slice::from_raw_parts(self.0.val as *const u8, self.0.len as usize) - } + unsafe { slice::from_raw_parts(self.0.val as *const u8, self.0.len as usize) } } } diff --git a/gstreamer-sdp/src/s_d_p_attribute.rs b/gstreamer-sdp/src/s_d_p_attribute.rs index 02642daf1..30581b230 100644 --- a/gstreamer-sdp/src/s_d_p_attribute.rs +++ b/gstreamer-sdp/src/s_d_p_attribute.rs @@ -6,8 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; use std::ffi::CStr; +use std::mem; use ffi; use glib::translate::*; @@ -22,7 +22,11 @@ impl SDPAttribute { assert_initialized_main_thread!(); unsafe { let mut attr = mem::zeroed(); - let result = from_glib(ffi::gst_sdp_attribute_set(&mut attr, key.to_glib_none().0, value.to_glib_none().0)); + let result = from_glib(ffi::gst_sdp_attribute_set( + &mut attr, + key.to_glib_none().0, + value.to_glib_none().0, + )); match result { SDPResult::Ok => Ok(SDPAttribute(attr)), _ => Err(()), @@ -31,15 +35,11 @@ impl SDPAttribute { } pub fn key(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.key).to_str().unwrap() - } + unsafe { CStr::from_ptr(self.0.key).to_str().unwrap() } } pub fn value(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.value).to_str().unwrap() - } + unsafe { CStr::from_ptr(self.0.value).to_str().unwrap() } } } diff --git a/gstreamer-sdp/src/s_d_p_bandwidth.rs b/gstreamer-sdp/src/s_d_p_bandwidth.rs index f9f6a8477..f4f28a4e7 100644 --- a/gstreamer-sdp/src/s_d_p_bandwidth.rs +++ b/gstreamer-sdp/src/s_d_p_bandwidth.rs @@ -6,8 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; use std::ffi::CStr; +use std::mem; use ffi; use glib::translate::*; @@ -22,7 +22,11 @@ impl SDPBandwidth { assert_initialized_main_thread!(); unsafe { let mut bw = mem::zeroed(); - let result = from_glib(ffi::gst_sdp_bandwidth_set(&mut bw, bwtype.to_glib_none().0, bandwidth)); + let result = from_glib(ffi::gst_sdp_bandwidth_set( + &mut bw, + bwtype.to_glib_none().0, + bandwidth, + )); match result { SDPResult::Ok => Ok(SDPBandwidth(bw)), _ => Err(()), @@ -31,9 +35,7 @@ impl SDPBandwidth { } pub fn bwtype(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.bwtype).to_str().unwrap() - } + unsafe { CStr::from_ptr(self.0.bwtype).to_str().unwrap() } } pub fn value(&self) -> u32 { diff --git a/gstreamer-sdp/src/s_d_p_connection.rs b/gstreamer-sdp/src/s_d_p_connection.rs index 022ff50a7..24a1c3042 100644 --- a/gstreamer-sdp/src/s_d_p_connection.rs +++ b/gstreamer-sdp/src/s_d_p_connection.rs @@ -6,8 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; use std::ffi::CStr; +use std::mem; use ffi; use glib::translate::*; @@ -18,10 +18,16 @@ use auto::SDPResult; pub struct SDPConnection(pub(crate) ffi::GstSDPConnection); impl SDPConnection { - pub fn new(nettype: &str, addrtype: &str, address: &str, ttl: u32, addr_number: u32) -> Result { - assert_initialized_main_thread!(); + pub fn new( + nettype: &str, + addrtype: &str, + address: &str, + ttl: u32, + addr_number: u32, + ) -> Result { + assert_initialized_main_thread!(); unsafe { - let mut conn = mem::zeroed(); + let mut conn = mem::zeroed(); let result = from_glib(ffi::gst_sdp_connection_set( &mut conn, nettype.to_glib_none().0, @@ -30,38 +36,32 @@ impl SDPConnection { ttl, addr_number, )); - match result { - SDPResult::Ok => Ok(SDPConnection(conn)), - _ => Err(()), - } + match result { + SDPResult::Ok => Ok(SDPConnection(conn)), + _ => Err(()), + } } } - pub fn nettype(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.nettype).to_str().unwrap() - } - } + pub fn nettype(&self) -> &str { + unsafe { CStr::from_ptr(self.0.nettype).to_str().unwrap() } + } - pub fn addrtype(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.addrtype).to_str().unwrap() - } - } + pub fn addrtype(&self) -> &str { + unsafe { CStr::from_ptr(self.0.addrtype).to_str().unwrap() } + } - pub fn address(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.address).to_str().unwrap() - } - } + pub fn address(&self) -> &str { + unsafe { CStr::from_ptr(self.0.address).to_str().unwrap() } + } - pub fn ttl(&self) -> u32 { - self.0.ttl as u32 - } + pub fn ttl(&self) -> u32 { + self.0.ttl as u32 + } - pub fn addr_number(&self) -> u32 { - self.0.addr_number as u32 - } + pub fn addr_number(&self) -> u32 { + self.0.addr_number as u32 + } } impl Drop for SDPConnection { diff --git a/gstreamer-sdp/src/s_d_p_key.rs b/gstreamer-sdp/src/s_d_p_key.rs index 5f48bcfd9..2fb1660bb 100644 --- a/gstreamer-sdp/src/s_d_p_key.rs +++ b/gstreamer-sdp/src/s_d_p_key.rs @@ -13,15 +13,11 @@ use ffi; pub struct SDPKey(ffi::GstSDPKey); impl SDPKey { - pub fn type_(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.type_).to_str().unwrap() - } - } + pub fn type_(&self) -> &str { + unsafe { CStr::from_ptr(self.0.type_).to_str().unwrap() } + } - pub fn data(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.data).to_str().unwrap() - } - } + pub fn data(&self) -> &str { + unsafe { CStr::from_ptr(self.0.data).to_str().unwrap() } + } } diff --git a/gstreamer-sdp/src/s_d_p_media.rs b/gstreamer-sdp/src/s_d_p_media.rs index bda0683da..cb60e48bf 100644 --- a/gstreamer-sdp/src/s_d_p_media.rs +++ b/gstreamer-sdp/src/s_d_p_media.rs @@ -6,19 +6,16 @@ // // option. This file may not be copied, modified, or distributed // // except according to those terms. +use std::ffi::CStr; use std::mem; use std::ptr; -use std::ffi::CStr; use ffi; use glib::translate::*; use glib_ffi; use gst; -use auto::{ - SDPResult, - MIKEYMessage, -}; +use auto::{MIKEYMessage, SDPResult}; use s_d_p_attribute::SDPAttribute; use s_d_p_bandwidth::SDPBandwidth; use s_d_p_connection::SDPConnection; @@ -52,11 +49,19 @@ impl SDPMedia { } } - pub fn add_attribute<'a, P: Into>>(&mut self, key: &str, value: P) -> Result<(), ()> { + pub fn add_attribute<'a, P: Into>>( + &mut self, + key: &str, + value: P, + ) -> Result<(), ()> { let value = value.into(); let value = value.to_glib_none(); let result = unsafe { - from_glib(ffi::gst_sdp_media_add_attribute(self.to_glib_none_mut().0, key.to_glib_none().0, value.0)) + from_glib(ffi::gst_sdp_media_add_attribute( + self.to_glib_none_mut().0, + key.to_glib_none().0, + value.0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -66,7 +71,11 @@ impl SDPMedia { pub fn add_bandwidth(&mut self, bwtype: &str, bandwidth: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_add_bandwidth(self.to_glib_none_mut().0, bwtype.to_glib_none().0, bandwidth)) + from_glib(ffi::gst_sdp_media_add_bandwidth( + self.to_glib_none_mut().0, + bwtype.to_glib_none().0, + bandwidth, + )) }; match result { SDPResult::Ok => Ok(()), @@ -74,9 +83,23 @@ impl SDPMedia { } } - pub fn add_connection(&mut self, nettype: &str, addrtype: &str, address: &str, ttl: u32, addr_number: u32) -> Result<(), ()> { + pub fn add_connection( + &mut self, + nettype: &str, + addrtype: &str, + address: &str, + ttl: u32, + addr_number: u32, + ) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_add_connection(self.to_glib_none_mut().0, nettype.to_glib_none().0, addrtype.to_glib_none().0, address.to_glib_none().0, ttl, addr_number)) + from_glib(ffi::gst_sdp_media_add_connection( + self.to_glib_none_mut().0, + nettype.to_glib_none().0, + addrtype.to_glib_none().0, + address.to_glib_none().0, + ttl, + addr_number, + )) }; match result { SDPResult::Ok => Ok(()), @@ -86,7 +109,10 @@ impl SDPMedia { pub fn add_format(&mut self, format: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_add_format(self.to_glib_none_mut().0, format.to_glib_none().0)) + from_glib(ffi::gst_sdp_media_add_format( + self.to_glib_none_mut().0, + format.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -95,20 +121,19 @@ impl SDPMedia { } pub fn as_text(&self) -> Option { - unsafe { - from_glib_full(ffi::gst_sdp_media_as_text(self.to_glib_none().0)) - } + unsafe { from_glib_full(ffi::gst_sdp_media_as_text(self.to_glib_none().0)) } } pub fn attributes_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_media_attributes_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_media_attributes_len(self.to_glib_none().0) } } pub fn attributes_to_caps(&self, caps: &gst::Caps) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_attributes_to_caps(self.to_glib_none().0, caps.to_glib_none().0)) + from_glib(ffi::gst_sdp_media_attributes_to_caps( + self.to_glib_none().0, + caps.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -117,21 +142,15 @@ impl SDPMedia { } pub fn bandwidths_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_media_bandwidths_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_media_bandwidths_len(self.to_glib_none().0) } } pub fn connections_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_media_connections_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_media_connections_len(self.to_glib_none().0) } } pub fn formats_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_media_formats_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_media_formats_len(self.to_glib_none().0) } } pub fn get_attribute(&self, idx: u32) -> Option<&SDPAttribute> { @@ -147,7 +166,8 @@ impl SDPMedia { pub fn get_attribute_val(&self, key: &str) -> Option<&str> { unsafe { - let ptr = ffi::gst_sdp_media_get_attribute_val(self.to_glib_none().0, key.to_glib_none().0); + let ptr = + ffi::gst_sdp_media_get_attribute_val(self.to_glib_none().0, key.to_glib_none().0); if ptr.is_null() { None } else { @@ -162,7 +182,11 @@ impl SDPMedia { pub fn get_attribute_val_n(&self, key: &str, nth: u32) -> Option<&str> { unsafe { - let ptr = ffi::gst_sdp_media_get_attribute_val_n(self.to_glib_none().0, key.to_glib_none().0, nth); + let ptr = ffi::gst_sdp_media_get_attribute_val_n( + self.to_glib_none().0, + key.to_glib_none().0, + nth, + ); if ptr.is_null() { None } else { @@ -188,7 +212,10 @@ impl SDPMedia { pub fn get_caps_from_media(&self, pt: i32) -> Option { unsafe { - from_glib_full(ffi::gst_sdp_media_get_caps_from_media(self.to_glib_none().0, pt)) + from_glib_full(ffi::gst_sdp_media_get_caps_from_media( + self.to_glib_none().0, + pt, + )) } } @@ -260,15 +287,11 @@ impl SDPMedia { } pub fn get_num_ports(&self) -> u32 { - unsafe { - ffi::gst_sdp_media_get_num_ports(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_media_get_num_ports(self.to_glib_none().0) } } pub fn get_port(&self) -> u32 { - unsafe { - ffi::gst_sdp_media_get_port(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_media_get_port(self.to_glib_none().0) } } pub fn get_proto(&self) -> Option<&str> { @@ -288,7 +311,11 @@ impl SDPMedia { pub fn insert_attribute(&mut self, idx: i32, mut attr: SDPAttribute) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_insert_attribute(self.to_glib_none_mut().0, idx, &mut attr.0)) + from_glib(ffi::gst_sdp_media_insert_attribute( + self.to_glib_none_mut().0, + idx, + &mut attr.0, + )) }; mem::forget(attr); match result { @@ -299,7 +326,11 @@ impl SDPMedia { pub fn insert_bandwidth(&mut self, idx: i32, mut bw: SDPBandwidth) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_insert_bandwidth(self.to_glib_none_mut().0, idx, &mut bw.0)) + from_glib(ffi::gst_sdp_media_insert_bandwidth( + self.to_glib_none_mut().0, + idx, + &mut bw.0, + )) }; mem::forget(bw); match result { @@ -310,7 +341,11 @@ impl SDPMedia { pub fn insert_connection(&mut self, idx: i32, mut conn: SDPConnection) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_insert_connection(self.to_glib_none_mut().0, idx, &mut conn.0)) + from_glib(ffi::gst_sdp_media_insert_connection( + self.to_glib_none_mut().0, + idx, + &mut conn.0, + )) }; mem::forget(conn); match result { @@ -321,7 +356,11 @@ impl SDPMedia { pub fn insert_format(&mut self, idx: i32, format: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_insert_format(self.to_glib_none_mut().0, idx, format.to_glib_none().0)) + from_glib(ffi::gst_sdp_media_insert_format( + self.to_glib_none_mut().0, + idx, + format.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -333,7 +372,10 @@ impl SDPMedia { pub fn parse_keymgmt(&self) -> Result { unsafe { let mut mikey = ptr::null_mut(); - let result = from_glib(ffi::gst_sdp_media_parse_keymgmt(self.to_glib_none().0, &mut mikey)); + let result = from_glib(ffi::gst_sdp_media_parse_keymgmt( + self.to_glib_none().0, + &mut mikey, + )); match result { SDPResult::Ok => Ok(from_glib_full(mikey)), _ => Err(()), @@ -343,7 +385,10 @@ impl SDPMedia { pub fn remove_attribute(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_remove_attribute(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_media_remove_attribute( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -353,7 +398,10 @@ impl SDPMedia { pub fn remove_bandwidth(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_remove_bandwidth(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_media_remove_bandwidth( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -363,7 +411,10 @@ impl SDPMedia { pub fn remove_connection(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_remove_connection(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_media_remove_connection( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -373,7 +424,10 @@ impl SDPMedia { pub fn remove_format(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_remove_format(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_media_remove_format( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -383,7 +437,11 @@ impl SDPMedia { pub fn replace_attribute(&mut self, idx: u32, mut attr: SDPAttribute) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_replace_attribute(self.to_glib_none_mut().0, idx, &mut attr.0)) + from_glib(ffi::gst_sdp_media_replace_attribute( + self.to_glib_none_mut().0, + idx, + &mut attr.0, + )) }; mem::forget(attr); match result { @@ -394,7 +452,11 @@ impl SDPMedia { pub fn replace_bandwidth(&mut self, idx: u32, mut bw: SDPBandwidth) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_replace_bandwidth(self.to_glib_none_mut().0, idx, &mut bw.0)) + from_glib(ffi::gst_sdp_media_replace_bandwidth( + self.to_glib_none_mut().0, + idx, + &mut bw.0, + )) }; mem::forget(bw); match result { @@ -405,7 +467,11 @@ impl SDPMedia { pub fn replace_connection(&mut self, idx: u32, mut conn: SDPConnection) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_replace_connection(self.to_glib_none_mut().0, idx, &mut conn.0)) + from_glib(ffi::gst_sdp_media_replace_connection( + self.to_glib_none_mut().0, + idx, + &mut conn.0, + )) }; mem::forget(conn); match result { @@ -416,7 +482,11 @@ impl SDPMedia { pub fn replace_format(&mut self, idx: u32, format: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_replace_format(self.to_glib_none_mut().0, idx, format.to_glib_none().0)) + from_glib(ffi::gst_sdp_media_replace_format( + self.to_glib_none_mut().0, + idx, + format.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -426,7 +496,10 @@ impl SDPMedia { pub fn set_information(&mut self, information: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_set_information(self.to_glib_none_mut().0, information.to_glib_none().0)) + from_glib(ffi::gst_sdp_media_set_information( + self.to_glib_none_mut().0, + information.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -436,7 +509,11 @@ impl SDPMedia { pub fn set_key(&mut self, type_: &str, data: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_set_key(self.to_glib_none_mut().0, type_.to_glib_none().0, data.to_glib_none().0)) + from_glib(ffi::gst_sdp_media_set_key( + self.to_glib_none_mut().0, + type_.to_glib_none().0, + data.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -446,7 +523,10 @@ impl SDPMedia { pub fn set_media(&mut self, med: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_set_media(self.to_glib_none_mut().0, med.to_glib_none().0)) + from_glib(ffi::gst_sdp_media_set_media( + self.to_glib_none_mut().0, + med.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -456,7 +536,11 @@ impl SDPMedia { pub fn set_port_info(&mut self, port: u32, num_ports: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_set_port_info(self.to_glib_none_mut().0, port, num_ports)) + from_glib(ffi::gst_sdp_media_set_port_info( + self.to_glib_none_mut().0, + port, + num_ports, + )) }; match result { SDPResult::Ok => Ok(()), @@ -466,7 +550,10 @@ impl SDPMedia { pub fn set_proto(&mut self, proto: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_media_set_proto(self.to_glib_none_mut().0, proto.to_glib_none().0)) + from_glib(ffi::gst_sdp_media_set_proto( + self.to_glib_none_mut().0, + proto.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -477,7 +564,10 @@ impl SDPMedia { pub fn set_media_from_caps(caps: &gst::Caps, media: &mut SDPMedia) -> Result<(), ()> { assert_initialized_main_thread!(); let result = unsafe { - from_glib(ffi::gst_sdp_media_set_media_from_caps(caps.to_glib_none().0, media.to_glib_none_mut().0)) + from_glib(ffi::gst_sdp_media_set_media_from_caps( + caps.to_glib_none().0, + media.to_glib_none_mut().0, + )) }; mem::forget(media); match result { diff --git a/gstreamer-sdp/src/s_d_p_message.rs b/gstreamer-sdp/src/s_d_p_message.rs index 37f0a5d5c..835289ed8 100644 --- a/gstreamer-sdp/src/s_d_p_message.rs +++ b/gstreamer-sdp/src/s_d_p_message.rs @@ -6,26 +6,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::ffi::CStr; use std::mem; use std::ptr; -use std::ffi::CStr; use ffi; -use gst; +use glib::translate::*; use glib_ffi; use gobject_ffi; -use glib::translate::*; +use gst; use gst::MiniObject; -use auto::{ - SDPResult, - MIKEYMessage, -}; -use s_d_p_media::SDPMedia; +use auto::{MIKEYMessage, SDPResult}; use s_d_p_attribute::SDPAttribute; use s_d_p_bandwidth::SDPBandwidth; use s_d_p_connection::SDPConnection; use s_d_p_key::SDPKey; +use s_d_p_media::SDPMedia; use s_d_p_origin::SDPOrigin; use s_d_p_time::SDPTime; use s_d_p_zone::SDPZone; @@ -50,9 +47,17 @@ impl SDPMessage { } } - pub fn add_attribute<'a, P: Into>>(&mut self, key: &str, value: P) -> Result<(), ()> { + pub fn add_attribute<'a, P: Into>>( + &mut self, + key: &str, + value: P, + ) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_add_attribute(self.to_glib_none_mut().0, key.to_glib_none().0, value.into().to_glib_none().0)) + from_glib(ffi::gst_sdp_message_add_attribute( + self.to_glib_none_mut().0, + key.to_glib_none().0, + value.into().to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -62,7 +67,10 @@ impl SDPMessage { pub fn add_email(&mut self, email: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_add_email(self.to_glib_none_mut().0, email.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_add_email( + self.to_glib_none_mut().0, + email.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -72,7 +80,10 @@ impl SDPMessage { pub fn add_media(&mut self, media: SDPMedia) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_add_media(self.to_glib_none_mut().0, media.to_glib_full() as *mut ffi::GstSDPMedia)) + from_glib(ffi::gst_sdp_message_add_media( + self.to_glib_none_mut().0, + media.to_glib_full() as *mut ffi::GstSDPMedia, + )) }; mem::forget(media); match result { @@ -83,7 +94,10 @@ impl SDPMessage { pub fn add_phone(&mut self, phone: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_add_phone(self.to_glib_none_mut().0, phone.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_add_phone( + self.to_glib_none_mut().0, + phone.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -93,7 +107,12 @@ impl SDPMessage { pub fn add_time(&mut self, start: &str, stop: &str, repeat: &[&str]) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_add_time(self.to_glib_none_mut().0, start.to_glib_none().0, stop.to_glib_none().0, repeat.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_add_time( + self.to_glib_none_mut().0, + start.to_glib_none().0, + stop.to_glib_none().0, + repeat.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -103,7 +122,11 @@ impl SDPMessage { pub fn add_zone(&mut self, adj_time: &str, typed_time: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_add_zone(self.to_glib_none_mut().0, adj_time.to_glib_none().0, typed_time.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_add_zone( + self.to_glib_none_mut().0, + adj_time.to_glib_none().0, + typed_time.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -112,20 +135,19 @@ impl SDPMessage { } pub fn as_text(&self) -> Option { - unsafe { - from_glib_full(ffi::gst_sdp_message_as_text(self.to_glib_none().0)) - } + unsafe { from_glib_full(ffi::gst_sdp_message_as_text(self.to_glib_none().0)) } } pub fn attributes_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_message_attributes_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_message_attributes_len(self.to_glib_none().0) } } pub fn attributes_to_caps(&self, caps: &mut gst::CapsRef) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_attributes_to_caps(self.to_glib_none().0, caps.as_mut_ptr())) + from_glib(ffi::gst_sdp_message_attributes_to_caps( + self.to_glib_none().0, + caps.as_mut_ptr(), + )) }; match result { SDPResult::Ok => Ok(()), @@ -134,15 +156,11 @@ impl SDPMessage { } pub fn bandwidths_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_message_bandwidths_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_message_bandwidths_len(self.to_glib_none().0) } } pub fn dump(&self) -> Result<(), ()> { - let result = unsafe { - from_glib(ffi::gst_sdp_message_dump(self.to_glib_none().0)) - }; + let result = unsafe { from_glib(ffi::gst_sdp_message_dump(self.to_glib_none().0)) }; match result { SDPResult::Ok => Ok(()), _ => Err(()), @@ -150,9 +168,7 @@ impl SDPMessage { } pub fn emails_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_message_emails_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_message_emails_len(self.to_glib_none().0) } } pub fn get_attribute(&self, idx: u32) -> Option<&SDPAttribute> { @@ -168,7 +184,8 @@ impl SDPMessage { pub fn get_attribute_val(&self, key: &str) -> Option<&str> { unsafe { - let ptr = ffi::gst_sdp_message_get_attribute_val(self.to_glib_none().0, key.to_glib_none().0); + let ptr = + ffi::gst_sdp_message_get_attribute_val(self.to_glib_none().0, key.to_glib_none().0); if ptr.is_null() { None } else { @@ -183,7 +200,11 @@ impl SDPMessage { pub fn get_attribute_val_n(&self, key: &str, nth: u32) -> Option<&str> { unsafe { - let ptr = ffi::gst_sdp_message_get_attribute_val_n(self.to_glib_none().0, key.to_glib_none().0, nth); + let ptr = ffi::gst_sdp_message_get_attribute_val_n( + self.to_glib_none().0, + key.to_glib_none().0, + nth, + ); if ptr.is_null() { None } else { @@ -365,7 +386,11 @@ impl SDPMessage { pub fn insert_attribute(&mut self, idx: i32, mut attr: SDPAttribute) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_insert_attribute(self.to_glib_none_mut().0, idx, &mut attr.0)) + from_glib(ffi::gst_sdp_message_insert_attribute( + self.to_glib_none_mut().0, + idx, + &mut attr.0, + )) }; mem::forget(attr); match result { @@ -376,7 +401,11 @@ impl SDPMessage { pub fn insert_bandwidth(&mut self, idx: i32, mut bw: SDPBandwidth) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_insert_bandwidth(self.to_glib_none_mut().0, idx, &mut bw.0)) + from_glib(ffi::gst_sdp_message_insert_bandwidth( + self.to_glib_none_mut().0, + idx, + &mut bw.0, + )) }; mem::forget(bw); match result { @@ -387,7 +416,11 @@ impl SDPMessage { pub fn insert_email(&mut self, idx: i32, email: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_insert_email(self.to_glib_none_mut().0, idx, email.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_insert_email( + self.to_glib_none_mut().0, + idx, + email.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -397,7 +430,11 @@ impl SDPMessage { pub fn insert_phone(&mut self, idx: i32, phone: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_insert_phone(self.to_glib_none_mut().0, idx, phone.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_insert_phone( + self.to_glib_none_mut().0, + idx, + phone.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -407,7 +444,11 @@ impl SDPMessage { pub fn insert_time(&mut self, idx: i32, mut time: SDPTime) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_insert_time(self.to_glib_none_mut().0, idx, &mut time.0)) + from_glib(ffi::gst_sdp_message_insert_time( + self.to_glib_none_mut().0, + idx, + &mut time.0, + )) }; mem::forget(time); match result { @@ -418,7 +459,11 @@ impl SDPMessage { pub fn insert_zone(&mut self, idx: i32, mut zone: SDPZone) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_insert_zone(self.to_glib_none_mut().0, idx, &mut zone.0)) + from_glib(ffi::gst_sdp_message_insert_zone( + self.to_glib_none_mut().0, + idx, + &mut zone.0, + )) }; mem::forget(zone); match result { @@ -428,15 +473,16 @@ impl SDPMessage { } pub fn medias_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_message_medias_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_message_medias_len(self.to_glib_none().0) } } #[cfg(any(feature = "v1_8_1", feature = "dox"))] pub fn parse_keymgmt(&self, mikey: MIKEYMessage) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_parse_keymgmt(self.to_glib_none().0, &mut mikey)) + from_glib(ffi::gst_sdp_message_parse_keymgmt( + self.to_glib_none().0, + &mut mikey, + )) }; mem::forget(mikey); match result { @@ -446,14 +492,15 @@ impl SDPMessage { } pub fn phones_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_message_phones_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_message_phones_len(self.to_glib_none().0) } } pub fn remove_attribute(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_remove_attribute(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_message_remove_attribute( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -463,7 +510,10 @@ impl SDPMessage { pub fn remove_bandwidth(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_remove_bandwidth(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_message_remove_bandwidth( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -473,7 +523,10 @@ impl SDPMessage { pub fn remove_email(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_remove_email(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_message_remove_email( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -483,7 +536,10 @@ impl SDPMessage { pub fn remove_phone(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_remove_phone(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_message_remove_phone( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -493,7 +549,10 @@ impl SDPMessage { pub fn remove_time(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_remove_time(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_message_remove_time( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -503,7 +562,10 @@ impl SDPMessage { pub fn remove_zone(&mut self, idx: u32) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_remove_zone(self.to_glib_none_mut().0, idx)) + from_glib(ffi::gst_sdp_message_remove_zone( + self.to_glib_none_mut().0, + idx, + )) }; match result { SDPResult::Ok => Ok(()), @@ -513,7 +575,11 @@ impl SDPMessage { pub fn replace_attribute(&mut self, idx: u32, mut attr: SDPAttribute) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_replace_attribute(self.to_glib_none_mut().0, idx, &mut attr.0)) + from_glib(ffi::gst_sdp_message_replace_attribute( + self.to_glib_none_mut().0, + idx, + &mut attr.0, + )) }; mem::forget(attr); match result { @@ -524,7 +590,11 @@ impl SDPMessage { pub fn replace_bandwidth(&mut self, idx: u32, mut bw: SDPBandwidth) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_replace_bandwidth(self.to_glib_none_mut().0, idx, &mut bw.0)) + from_glib(ffi::gst_sdp_message_replace_bandwidth( + self.to_glib_none_mut().0, + idx, + &mut bw.0, + )) }; mem::forget(bw); match result { @@ -535,7 +605,11 @@ impl SDPMessage { pub fn replace_email(&mut self, idx: u32, email: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_replace_email(self.to_glib_none_mut().0, idx, email.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_replace_email( + self.to_glib_none_mut().0, + idx, + email.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -545,7 +619,11 @@ impl SDPMessage { pub fn replace_phone(&mut self, idx: u32, phone: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_replace_phone(self.to_glib_none_mut().0, idx, phone.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_replace_phone( + self.to_glib_none_mut().0, + idx, + phone.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -555,7 +633,11 @@ impl SDPMessage { pub fn replace_time(&mut self, idx: u32, mut time: SDPTime) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_replace_time(self.to_glib_none_mut().0, idx, &mut time.0)) + from_glib(ffi::gst_sdp_message_replace_time( + self.to_glib_none_mut().0, + idx, + &mut time.0, + )) }; mem::forget(time); match result { @@ -566,7 +648,11 @@ impl SDPMessage { pub fn replace_zone(&mut self, idx: u32, mut zone: SDPZone) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_replace_zone(self.to_glib_none_mut().0, idx, &mut zone.0)) + from_glib(ffi::gst_sdp_message_replace_zone( + self.to_glib_none_mut().0, + idx, + &mut zone.0, + )) }; mem::forget(zone); match result { @@ -575,9 +661,23 @@ impl SDPMessage { } } - pub fn set_connection(&mut self, nettype: &str, addrtype: &str, address: &str, ttl: u32, addr_number: u32) -> Result<(), ()> { + pub fn set_connection( + &mut self, + nettype: &str, + addrtype: &str, + address: &str, + ttl: u32, + addr_number: u32, + ) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_set_connection(self.to_glib_none_mut().0, nettype.to_glib_none().0, addrtype.to_glib_none().0, address.to_glib_none().0, ttl, addr_number)) + from_glib(ffi::gst_sdp_message_set_connection( + self.to_glib_none_mut().0, + nettype.to_glib_none().0, + addrtype.to_glib_none().0, + address.to_glib_none().0, + ttl, + addr_number, + )) }; match result { SDPResult::Ok => Ok(()), @@ -587,7 +687,10 @@ impl SDPMessage { pub fn set_information(&mut self, information: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_set_information(self.to_glib_none_mut().0, information.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_set_information( + self.to_glib_none_mut().0, + information.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -597,7 +700,11 @@ impl SDPMessage { pub fn set_key(&mut self, type_: &str, data: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_set_key(self.to_glib_none_mut().0, type_.to_glib_none().0, data.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_set_key( + self.to_glib_none_mut().0, + type_.to_glib_none().0, + data.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -605,9 +712,25 @@ impl SDPMessage { } } - pub fn set_origin(&mut self, username: &str, sess_id: &str, sess_version: &str, nettype: &str, addrtype: &str, addr: &str) -> Result<(), ()> { + pub fn set_origin( + &mut self, + username: &str, + sess_id: &str, + sess_version: &str, + nettype: &str, + addrtype: &str, + addr: &str, + ) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_set_origin(self.to_glib_none_mut().0, username.to_glib_none().0, sess_id.to_glib_none().0, sess_version.to_glib_none().0, nettype.to_glib_none().0, addrtype.to_glib_none().0, addr.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_set_origin( + self.to_glib_none_mut().0, + username.to_glib_none().0, + sess_id.to_glib_none().0, + sess_version.to_glib_none().0, + nettype.to_glib_none().0, + addrtype.to_glib_none().0, + addr.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -617,7 +740,10 @@ impl SDPMessage { pub fn set_session_name(&mut self, session_name: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_set_session_name(self.to_glib_none_mut().0, session_name.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_set_session_name( + self.to_glib_none_mut().0, + session_name.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -627,7 +753,10 @@ impl SDPMessage { pub fn set_uri(&mut self, uri: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_set_uri(self.to_glib_none_mut().0, uri.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_set_uri( + self.to_glib_none_mut().0, + uri.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -637,7 +766,10 @@ impl SDPMessage { pub fn set_version(&mut self, version: &str) -> Result<(), ()> { let result = unsafe { - from_glib(ffi::gst_sdp_message_set_version(self.to_glib_none_mut().0, version.to_glib_none().0)) + from_glib(ffi::gst_sdp_message_set_version( + self.to_glib_none_mut().0, + version.to_glib_none().0, + )) }; match result { SDPResult::Ok => Ok(()), @@ -646,21 +778,20 @@ impl SDPMessage { } pub fn times_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_message_times_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_message_times_len(self.to_glib_none().0) } } pub fn zones_len(&self) -> u32 { - unsafe { - ffi::gst_sdp_message_zones_len(self.to_glib_none().0) - } + unsafe { ffi::gst_sdp_message_zones_len(self.to_glib_none().0) } } pub fn as_uri(scheme: &str, msg: &SDPMessage) -> Option { assert_initialized_main_thread!(); unsafe { - from_glib_full(ffi::gst_sdp_message_as_uri(scheme.to_glib_none().0, msg.to_glib_none().0)) + from_glib_full(ffi::gst_sdp_message_as_uri( + scheme.to_glib_none().0, + msg.to_glib_none().0, + )) } } @@ -668,14 +799,19 @@ impl SDPMessage { assert_initialized_main_thread!(); unsafe { let size = data.len() as u32; - let msg = glib_ffi::g_malloc0(mem::size_of::()) as *mut ffi::GstSDPMessage; - let result = from_glib(ffi::gst_sdp_message_parse_buffer(data.to_glib_none().0, size, msg)); + let msg = glib_ffi::g_malloc0(mem::size_of::()) + as *mut ffi::GstSDPMessage; + let result = from_glib(ffi::gst_sdp_message_parse_buffer( + data.to_glib_none().0, + size, + msg, + )); match result { SDPResult::Ok => Ok(from_glib_full(msg)), _ => { glib_ffi::g_free(msg as *mut _); Err(()) - }, + } } } } @@ -683,14 +819,15 @@ impl SDPMessage { pub fn parse_uri(uri: &str) -> Result { assert_initialized_main_thread!(); unsafe { - let msg = glib_ffi::g_malloc0(mem::size_of::()) as *mut ffi::GstSDPMessage; + let msg = glib_ffi::g_malloc0(mem::size_of::()) + as *mut ffi::GstSDPMessage; let result = from_glib(ffi::gst_sdp_message_parse_uri(uri.to_glib_none().0, msg)); match result { SDPResult::Ok => Ok(from_glib_full(msg)), _ => { glib_ffi::g_free(msg as *mut _); Err(()) - }, + } } } } diff --git a/gstreamer-sdp/src/s_d_p_origin.rs b/gstreamer-sdp/src/s_d_p_origin.rs index 6ada76d42..8f3bc2e08 100644 --- a/gstreamer-sdp/src/s_d_p_origin.rs +++ b/gstreamer-sdp/src/s_d_p_origin.rs @@ -14,39 +14,27 @@ use ffi; pub struct SDPOrigin(pub(crate) ffi::GstSDPOrigin); impl SDPOrigin { - pub fn username(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.username).to_str().unwrap() - } - } + pub fn username(&self) -> &str { + unsafe { CStr::from_ptr(self.0.username).to_str().unwrap() } + } - pub fn sess_id(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.sess_id).to_str().unwrap() - } - } + pub fn sess_id(&self) -> &str { + unsafe { CStr::from_ptr(self.0.sess_id).to_str().unwrap() } + } - pub fn sess_version(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.sess_version).to_str().unwrap() - } - } + pub fn sess_version(&self) -> &str { + unsafe { CStr::from_ptr(self.0.sess_version).to_str().unwrap() } + } - pub fn nettype(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.nettype).to_str().unwrap() - } - } + pub fn nettype(&self) -> &str { + unsafe { CStr::from_ptr(self.0.nettype).to_str().unwrap() } + } - pub fn addrtype(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.addrtype).to_str().unwrap() - } - } + pub fn addrtype(&self) -> &str { + unsafe { CStr::from_ptr(self.0.addrtype).to_str().unwrap() } + } - pub fn addr(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.addr).to_str().unwrap() - } - } + pub fn addr(&self) -> &str { + unsafe { CStr::from_ptr(self.0.addr).to_str().unwrap() } + } } diff --git a/gstreamer-sdp/src/s_d_p_time.rs b/gstreamer-sdp/src/s_d_p_time.rs index acc0335aa..177e51022 100644 --- a/gstreamer-sdp/src/s_d_p_time.rs +++ b/gstreamer-sdp/src/s_d_p_time.rs @@ -6,9 +6,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::ffi::CStr; use std::mem; use std::os::raw::c_char; -use std::ffi::CStr; use ffi; use glib::translate::*; @@ -29,23 +29,19 @@ impl SDPTime { stop.to_glib_none().0, repeat.to_glib_none().0, )); - match result { - SDPResult::Ok => Ok(SDPTime(time)), - _ => Err(()), - } + match result { + SDPResult::Ok => Ok(SDPTime(time)), + _ => Err(()), + } } } pub fn start(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.start).to_str().unwrap() - } + unsafe { CStr::from_ptr(self.0.start).to_str().unwrap() } } pub fn stop(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.stop).to_str().unwrap() - } + unsafe { CStr::from_ptr(self.0.stop).to_str().unwrap() } } pub fn repeat(&self) -> Vec<&str> { diff --git a/gstreamer-sdp/src/s_d_p_zone.rs b/gstreamer-sdp/src/s_d_p_zone.rs index 714620b7b..40073f656 100644 --- a/gstreamer-sdp/src/s_d_p_zone.rs +++ b/gstreamer-sdp/src/s_d_p_zone.rs @@ -6,8 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; use std::ffi::CStr; +use std::mem; use ffi; use glib::translate::*; @@ -22,24 +22,24 @@ impl SDPZone { assert_initialized_main_thread!(); unsafe { let mut zone = mem::zeroed(); - let result = from_glib(ffi::gst_sdp_zone_set(&mut zone, time.to_glib_none().0, typed_time.to_glib_none().0)); - match result { - SDPResult::Ok => Ok(SDPZone(zone)), - _ => Err(()), - } + let result = from_glib(ffi::gst_sdp_zone_set( + &mut zone, + time.to_glib_none().0, + typed_time.to_glib_none().0, + )); + match result { + SDPResult::Ok => Ok(SDPZone(zone)), + _ => Err(()), + } } } pub fn time(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.time).to_str().unwrap() - } + unsafe { CStr::from_ptr(self.0.time).to_str().unwrap() } } pub fn typed_time(&self) -> &str { - unsafe { - CStr::from_ptr(self.0.typed_time).to_str().unwrap() - } + unsafe { CStr::from_ptr(self.0.typed_time).to_str().unwrap() } } } diff --git a/gstreamer-webrtc/src/lib.rs b/gstreamer-webrtc/src/lib.rs index dbd7990e6..b75912b8a 100644 --- a/gstreamer-webrtc/src/lib.rs +++ b/gstreamer-webrtc/src/lib.rs @@ -12,28 +12,27 @@ extern crate libc; extern crate glib; extern crate glib_sys as glib_ffi; extern crate gobject_sys as gobject_ffi; -extern crate gstreamer_sys as gst_ffi; -extern crate gstreamer_webrtc_sys as ffi; extern crate gstreamer as gst; extern crate gstreamer_sdp as gst_sdp; +extern crate gstreamer_sys as gst_ffi; +extern crate gstreamer_webrtc_sys as ffi; macro_rules! assert_initialized_main_thread { - () => ( - if unsafe {::gst_ffi::gst_is_initialized()} != ::glib_ffi::GTRUE { + () => { + if unsafe { ::gst_ffi::gst_is_initialized() } != ::glib_ffi::GTRUE { panic!("GStreamer has not been initialized. Call `gst::init` first."); } - ) + }; } macro_rules! skip_assert_initialized { - () => ( - ) + () => {}; } macro_rules! callback_guard { - () => ( + () => { let _guard = ::glib::CallbackGuard::new(); - ) + }; } pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue, Value};