mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 00:26:31 +00:00
Run everything through rustfmt
This commit is contained in:
parent
7f265a23bd
commit
cd95920436
7 changed files with 86 additions and 58 deletions
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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\
|
||||
zeUc6QIDAQABAkBRFJZ32VbqWMP9OVwDJLiwC01AlYLnka0mIQZbT/2xq9dUc9GW\
|
||||
U3kiVw4lL8v/+sPjtTPCYYdzHHOyDen6znVhAiEA9qJT7BtQvRxCvGrAhr9MS022\
|
||||
tTdPbW829BoUtIeH64cCIQDggG5i48v7HPacPBIH1RaSVhXl8qHCpQD3qrIw3FMw\
|
||||
DwIga8PqH5Sf5sHedy2+CiK0V4MRfoU4c3zQ6kArI+bEgSkCIQCLA1vXBiE31B5s\
|
||||
bdHoYa1BXebfZVd+1Hd95IfEM5mbRwIgSkDuQwV55BBlvWph3U8wVIMIb4GStaH8\
|
||||
W535W8UBbEg=-----END PRIVATE KEY-----")?;
|
||||
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\
|
||||
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,
|
||||
<bool as StaticType>::static_type().to_glib() as *const u8,
|
||||
true.to_glib() as *const u8,
|
||||
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>());
|
||||
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,
|
||||
true.to_glib() as *const u8,
|
||||
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>(),
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue