Run everything through rustfmt

This commit is contained in:
Sebastian Dröge 2018-03-02 21:06:45 +02:00
parent 7f265a23bd
commit cd95920436
7 changed files with 86 additions and 58 deletions

View file

@ -45,17 +45,19 @@ fn print_stream_info(stream: &DiscovererStreamInfo) {
}
let caps_str = match stream.get_caps() {
Some(caps) => caps.to_string(),
None => String::from("--")
None => String::from("--"),
};
println!(" Format: {}", caps_str);
}
fn print_discoverer_info(info: &DiscovererInfo) -> Result<(), Error> {
let uri = info.get_uri().ok_or(DiscovererError("URI should not be null"))?;
let uri = info.get_uri()
.ok_or(DiscovererError("URI should not be null"))?;
println!("URI: {}", uri);
println!("Duration: {}", info.get_duration());
print_tags(info);
print_stream_info(&info.get_stream_info().ok_or(DiscovererError("Error while obtaining stream info"))?);
print_stream_info(&info.get_stream_info()
.ok_or(DiscovererError("Error while obtaining stream info"))?);
let children = info.get_stream_list();
println!("Children streams:");
@ -87,7 +89,7 @@ fn run_discoverer() -> Result<(), Error> {
fn example_main() {
match run_discoverer() {
Ok(_) => (),
Err(e) => eprintln!("Error: {}", e)
Err(e) => eprintln!("Error: {}", e),
}
}

View file

@ -1,14 +1,14 @@
extern crate glib;
extern crate failure;
extern crate gio;
extern crate glib;
#[macro_use]
extern crate failure_derive;
extern crate gstreamer_rtsp_server_sys as ffi;
extern crate gstreamer_rtsp_server as gst_rtsp_server;
extern crate gstreamer_rtsp as gst_rtsp;
extern crate gstreamer as gst;
extern crate gstreamer_rtsp as gst_rtsp;
extern crate gstreamer_rtsp_server as gst_rtsp_server;
extern crate gstreamer_rtsp_server_sys as ffi;
use std::env;
use std::ptr;
@ -67,11 +67,13 @@ fn main_loop() -> Result<(), Error> {
tTdPbW829BoUtIeH64cCIQDggG5i48v7HPacPBIH1RaSVhXl8qHCpQD3qrIw3FMw\
DwIga8PqH5Sf5sHedy2+CiK0V4MRfoU4c3zQ6kArI+bEgSkCIQCLA1vXBiE31B5s\
bdHoYa1BXebfZVd+1Hd95IfEM5mbRwIgSkDuQwV55BBlvWph3U8wVIMIb4GStaH8\
W535W8UBbEg=-----END PRIVATE KEY-----")?;
W535W8UBbEg=-----END PRIVATE KEY-----",
)?;
// Bindable versions were added in b1f515178a363df0322d7adbd5754e1f6e2083c9
unsafe {
ffi::gst_rtsp_media_factory_add_role(factory.to_glib_none().0,
ffi::gst_rtsp_media_factory_add_role(
factory.to_glib_none().0,
"user".to_glib_none().0,
RTSP_PERM_MEDIA_FACTORY_ACCESS.to_glib_none().0,
<bool as StaticType>::static_type().to_glib() as *const u8,
@ -79,7 +81,8 @@ fn main_loop() -> Result<(), Error> {
RTSP_PERM_MEDIA_FACTORY_CONSTRUCT.as_ptr() as *const u8,
<bool as StaticType>::static_type().to_glib() as *const u8,
true.to_glib() as *const u8,
ptr::null_mut::<u8>());
ptr::null_mut::<u8>(),
);
}
auth.set_tls_certificate(&cert);
@ -93,7 +96,10 @@ fn main_loop() -> Result<(), Error> {
server.attach(None);
println!("Stream ready at rtsps://127.0.0.1:{}/test", server.get_bound_port());
println!(
"Stream ready at rtsps://127.0.0.1:{}/test",
server.get_bound_port()
);
main_loop.run();

View file

@ -28,30 +28,49 @@ use std::boxed::Box as Box_;
impl Discoverer {
pub fn set_property_timeout(&self, timeout: gst::ClockTime) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0,
"timeout".to_glib_none().0, Value::from(&timeout).to_glib_none().0);
gobject_ffi::g_object_set_property(
self.to_glib_none().0,
"timeout".to_glib_none().0,
Value::from(&timeout).to_glib_none().0,
);
}
}
pub fn get_property_timeout(&self) -> gst::ClockTime {
let mut value = Value::from(&0u64);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "timeout".to_glib_none().0, value.to_glib_none_mut().0);
gobject_ffi::g_object_get_property(
self.to_glib_none().0,
"timeout".to_glib_none().0,
value.to_glib_none_mut().0,
);
}
value.get().unwrap()
}
pub fn connect_property_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
pub fn connect_property_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::timeout",
transmute(notify_timeout_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
connect(
self.to_glib_none().0,
"notify::timeout",
transmute(notify_timeout_trampoline::<Self> as usize),
Box_::into_raw(f) as *mut _,
)
}
}
}
unsafe extern "C" fn notify_timeout_trampoline<P>(this: *mut ffi::GstDiscoverer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Discoverer> {
unsafe extern "C" fn notify_timeout_trampoline<P>(
this: *mut ffi::GstDiscoverer,
_param_spec: glib_ffi::gpointer,
f: glib_ffi::gpointer,
) where
P: IsA<Discoverer>,
{
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&Discoverer::from_glib_borrow(this).downcast_unchecked())

View file

@ -12,7 +12,7 @@ use DiscovererStreamInfoExt;
pub struct Iter {
stream_info: Option<DiscovererStreamInfo>,
direction_forward: bool
direction_forward: bool,
}
impl Iterator for Iter {
@ -28,8 +28,8 @@ impl Iterator for Iter {
} else {
c.get_previous()
}
},
&None => None
}
&None => None,
};
current
}
@ -39,14 +39,14 @@ impl DiscovererStreamInfo {
pub fn next_iter(&self) -> Iter {
Iter {
stream_info: self.get_next(),
direction_forward: true
direction_forward: true,
}
}
pub fn previous_iter(&self) -> Iter {
Iter {
stream_info: self.get_previous(),
direction_forward: false
direction_forward: false,
}
}
}

View file

@ -18,7 +18,8 @@ impl DiscovererVideoInfo {
unsafe {
gst::Fraction::new(
ffi::gst_discoverer_video_info_get_framerate_num(self.to_glib_none().0) as i32,
ffi::gst_discoverer_video_info_get_framerate_denom(self.to_glib_none().0) as i32)
ffi::gst_discoverer_video_info_get_framerate_denom(self.to_glib_none().0) as i32,
)
}
}
@ -26,7 +27,8 @@ impl DiscovererVideoInfo {
unsafe {
gst::Fraction::new(
ffi::gst_discoverer_video_info_get_par_num(self.to_glib_none().0) as i32,
ffi::gst_discoverer_video_info_get_par_denom(self.to_glib_none().0) as i32)
ffi::gst_discoverer_video_info_get_par_denom(self.to_glib_none().0) as i32,
)
}
}
}

View file

@ -17,8 +17,8 @@ extern crate glib;
extern crate glib_sys as glib_ffi;
extern crate gobject_sys as gobject_ffi;
extern crate gstreamer as gst;
extern crate gstreamer_sys as gst_ffi;
extern crate gstreamer_pbutils_sys as ffi;
extern crate gstreamer_sys as gst_ffi;
static PBUTILS_INIT: Once = ONCE_INIT;

View file

@ -9,7 +9,6 @@ pub trait RTSPAuthExtManual {
}
impl<O: IsA<RTSPAuth>> RTSPAuthExtManual for O {
fn set_default_token<'a, P: Into<Option<&'a mut RTSPToken>>>(&self, token: P) {
let mut token = token.into();
unsafe {