diff --git a/examples/src/bin/discoverer.rs b/examples/src/bin/discoverer.rs index 0f1cf0d74..7b9f10b7f 100644 --- a/examples/src/bin/discoverer.rs +++ b/examples/src/bin/discoverer.rs @@ -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), } } diff --git a/examples/src/bin/rtsp-server-record.rs b/examples/src/bin/rtsp-server-record.rs index 3068f0a9b..75932871d 100644 --- a/examples/src/bin/rtsp-server-record.rs +++ b/examples/src/bin/rtsp-server-record.rs @@ -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; @@ -44,42 +44,45 @@ fn main_loop() -> Result<(), Error> { let auth = RTSPAuth::new(); let mut token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"user")]); let basic = RTSPAuth::make_basic("user", "password"); - let cert = gio::TlsCertificate::new_from_pem ( + let cert = gio::TlsCertificate::new_from_pem( "-----BEGIN CERTIFICATE-----\ - MIICJjCCAY+gAwIBAgIBBzANBgkqhkiG9w0BAQUFADCBhjETMBEGCgmSJomT8ixk\ - ARkWA0NPTTEXMBUGCgmSJomT8ixkARkWB0VYQU1QTEUxHjAcBgNVBAsTFUNlcnRp\ - ZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAxMOY2EuZXhhbXBsZS5jb20xHTAbBgkq\ - hkiG9w0BCQEWDmNhQGV4YW1wbGUuY29tMB4XDTExMDExNzE5NDcxN1oXDTIxMDEx\ - NDE5NDcxN1owSzETMBEGCgmSJomT8ixkARkWA0NPTTEXMBUGCgmSJomT8ixkARkW\ - B0VYQU1QTEUxGzAZBgNVBAMTEnNlcnZlci5leGFtcGxlLmNvbTBcMA0GCSqGSIb3\ - DQEBAQUAA0sAMEgCQQDYScTxk55XBmbDM9zzwO+grVySE4rudWuzH2PpObIonqbf\ - hRoAalKVluG9jvbHI81eXxCdSObv1KBP1sbN5RzpAgMBAAGjIjAgMAkGA1UdEwQC\ - MAAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDQYJKoZIhvcNAQEFBQADgYEAYx6fMqT1\ - Gvo0jq88E8mc+bmp4LfXD4wJ7KxYeadQxt75HFRpj4FhFO3DOpVRFgzHlOEo3Fwk\ - PZOKjvkT0cbcoEq5whLH25dHoQxGoVQgFyAP5s+7Vp5AlHh8Y/vAoXeEVyy/RCIH\ - QkhUlAflfDMcrrYjsmwoOPSjhx6Mm/AopX4=\ - -----END CERTIFICATE-----\ - -----BEGIN PRIVATE KEY-----\ - MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEA2EnE8ZOeVwZmwzPc\ - 88DvoK1ckhOK7nVrsx9j6TmyKJ6m34UaAGpSlZbhvY72xyPNXl8QnUjm79SgT9bG\ - zeUc6QIDAQABAkBRFJZ32VbqW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+ QkhUlAflfDMcrrYjsmwoOPSjhx6Mm/AopX4=\ + -----END CERTIFICATE-----\ + -----BEGIN PRIVATE KEY-----\ + MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEA2EnE8ZOeVwZmwzPc\ + 88DvoK1ckhOK7nVrsx9j6TmyKJ6m34UaAGpSlZbhvY72xyPNXl8QnUjm79SgT9bG\ + zeUc6QIDAQABAkBRFJZ32VbqWMP9OVwDJLiwC01AlYLnka0mIQZbT/2xq9dUc9GW\ + U3kiVw4lL8v/+sPjtTPCYYdzHHOyDen6znVhAiEA9qJT7BtQvRxCvGrAhr9MS022\ + tTdPbW829BoUtIeH64cCIQDggG5i48v7HPacPBIH1RaSVhXl8qHCpQD3qrIw3FMw\ + DwIga8PqH5Sf5sHedy2+CiK0V4MRfoU4c3zQ6kArI+bEgSkCIQCLA1vXBiE31B5s\ + bdHoYa1BXebfZVd+1Hd95IfEM5mbRwIgSkDuQwV55BBlvWph3U8wVIMIb4GStaH8\ + W535W8UBbEg=-----END PRIVATE KEY-----", + )?; // Bindable versions were added in b1f515178a363df0322d7adbd5754e1f6e2083c9 unsafe { - 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, - ::static_type().to_glib() as *const u8, - true.to_glib() as *const u8, - RTSP_PERM_MEDIA_FACTORY_CONSTRUCT.as_ptr() as *const u8, - ::static_type().to_glib() as *const u8, - true.to_glib() as *const u8, - ptr::null_mut::()); + 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, + ::static_type().to_glib() as *const u8, + true.to_glib() as *const u8, + RTSP_PERM_MEDIA_FACTORY_CONSTRUCT.as_ptr() as *const u8, + ::static_type().to_glib() as *const u8, + true.to_glib() as *const u8, + ptr::null_mut::(), + ); } 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(); diff --git a/gstreamer-pbutils/src/discoverer.rs b/gstreamer-pbutils/src/discoverer.rs index 5515fb369..223211fbd 100644 --- a/gstreamer-pbutils/src/discoverer.rs +++ b/gstreamer-pbutils/src/discoverer.rs @@ -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(&self, f: F) -> SignalHandlerId { + pub fn connect_property_timeout_notify( + &self, + f: F, + ) -> SignalHandlerId { unsafe { let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "notify::timeout", - transmute(notify_timeout_trampoline:: as usize), Box_::into_raw(f) as *mut _) + connect( + self.to_glib_none().0, + "notify::timeout", + transmute(notify_timeout_trampoline:: as usize), + Box_::into_raw(f) as *mut _, + ) } } } -unsafe extern "C" fn notify_timeout_trampoline

(this: *mut ffi::GstDiscoverer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) -where P: IsA { +unsafe extern "C" fn notify_timeout_trampoline

( + this: *mut ffi::GstDiscoverer, + _param_spec: glib_ffi::gpointer, + f: glib_ffi::gpointer, +) where + P: IsA, +{ callback_guard!(); let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f); f(&Discoverer::from_glib_borrow(this).downcast_unchecked()) diff --git a/gstreamer-pbutils/src/discoverer_stream_info.rs b/gstreamer-pbutils/src/discoverer_stream_info.rs index ec41271fe..38334a582 100644 --- a/gstreamer-pbutils/src/discoverer_stream_info.rs +++ b/gstreamer-pbutils/src/discoverer_stream_info.rs @@ -12,7 +12,7 @@ use DiscovererStreamInfoExt; pub struct Iter { stream_info: Option, - 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, } } } diff --git a/gstreamer-pbutils/src/discoverer_video_info.rs b/gstreamer-pbutils/src/discoverer_video_info.rs index 44f9964d3..90a1f28ea 100644 --- a/gstreamer-pbutils/src/discoverer_video_info.rs +++ b/gstreamer-pbutils/src/discoverer_video_info.rs @@ -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, + ) } } } diff --git a/gstreamer-pbutils/src/lib.rs b/gstreamer-pbutils/src/lib.rs index 778e64ba2..b8907cef6 100644 --- a/gstreamer-pbutils/src/lib.rs +++ b/gstreamer-pbutils/src/lib.rs @@ -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; diff --git a/gstreamer-rtsp-server/src/r_t_s_p_auth.rs b/gstreamer-rtsp-server/src/r_t_s_p_auth.rs index 909a5b14b..e49b13f14 100644 --- a/gstreamer-rtsp-server/src/r_t_s_p_auth.rs +++ b/gstreamer-rtsp-server/src/r_t_s_p_auth.rs @@ -9,7 +9,6 @@ pub trait RTSPAuthExtManual { } impl> RTSPAuthExtManual for O { - fn set_default_token<'a, P: Into>>(&self, token: P) { let mut token = token.into(); unsafe {