Commit 873ddf0d authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Run gstreamer-sdp and gstreamer-webrtc through rustfmt

parent 2de1f6f7
......@@ -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
......
......@@ -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,
})
}
......
......@@ -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<Option<&'a MIKEYDecryptInfo>>>(bytes: &glib::Bytes, info: P) -> Result<MIKEYMessage, Error> {
pub fn new_from_bytes<'a, P: Into<Option<&'a MIKEYDecryptInfo>>>(
bytes: &glib::Bytes,
info: P,
) -> Result<MIKEYMessage, Error> {
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<Option<&'a MIKEYDecryptInfo>>>(data: &[u8], info: P) -> Result<MIKEYMessage, Error> {
pub fn new_from_data<'a, P: Into<Option<&'a MIKEYDecryptInfo>>>(
data: &[u8],
info: P,
) -> Result<MIKEYMessage, Error> {
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<String> {
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,
))
}
}
}
......@@ -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,
))
}
}
}
......@@ -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) }
}
}
......@@ -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() }
}
}
......
......@@ -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 {
......
......@@ -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<Self, ()> {
assert_initialized_main_thread!();
pub fn new(
nettype: &str,
addrtype: &str,
address: &str,
ttl: u32,
addr_number: u32,
) -> Result<Self, ()> {
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 {
......
......@@ -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() }
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -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 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 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 addr(&self) -> &str {
unsafe {
CStr::from_ptr(self.0.addr).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_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 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() }
}
}
......@@ -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> {
......
......@@ -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() }
}
}
......
......@@ -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};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment