forked from mirrors/gstreamer-rs
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() {
|
let caps_str = match stream.get_caps() {
|
||||||
Some(caps) => caps.to_string(),
|
Some(caps) => caps.to_string(),
|
||||||
None => String::from("--")
|
None => String::from("--"),
|
||||||
};
|
};
|
||||||
println!(" Format: {}", caps_str);
|
println!(" Format: {}", caps_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_discoverer_info(info: &DiscovererInfo) -> Result<(), Error> {
|
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!("URI: {}", uri);
|
||||||
println!("Duration: {}", info.get_duration());
|
println!("Duration: {}", info.get_duration());
|
||||||
print_tags(info);
|
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();
|
let children = info.get_stream_list();
|
||||||
println!("Children streams:");
|
println!("Children streams:");
|
||||||
|
@ -87,7 +89,7 @@ fn run_discoverer() -> Result<(), Error> {
|
||||||
fn example_main() {
|
fn example_main() {
|
||||||
match run_discoverer() {
|
match run_discoverer() {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => eprintln!("Error: {}", e)
|
Err(e) => eprintln!("Error: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
extern crate glib;
|
|
||||||
extern crate failure;
|
extern crate failure;
|
||||||
extern crate gio;
|
extern crate gio;
|
||||||
|
extern crate glib;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure_derive;
|
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 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::env;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
@ -44,42 +44,45 @@ fn main_loop() -> Result<(), Error> {
|
||||||
let auth = RTSPAuth::new();
|
let auth = RTSPAuth::new();
|
||||||
let mut token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"user")]);
|
let mut token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"user")]);
|
||||||
let basic = RTSPAuth::make_basic("user", "password");
|
let basic = RTSPAuth::make_basic("user", "password");
|
||||||
let cert = gio::TlsCertificate::new_from_pem (
|
let cert = gio::TlsCertificate::new_from_pem(
|
||||||
"-----BEGIN CERTIFICATE-----\
|
"-----BEGIN CERTIFICATE-----\
|
||||||
MIICJjCCAY+gAwIBAgIBBzANBgkqhkiG9w0BAQUFADCBhjETMBEGCgmSJomT8ixk\
|
MIICJjCCAY+gAwIBAgIBBzANBgkqhkiG9w0BAQUFADCBhjETMBEGCgmSJomT8ixk\
|
||||||
ARkWA0NPTTEXMBUGCgmSJomT8ixkARkWB0VYQU1QTEUxHjAcBgNVBAsTFUNlcnRp\
|
ARkWA0NPTTEXMBUGCgmSJomT8ixkARkWB0VYQU1QTEUxHjAcBgNVBAsTFUNlcnRp\
|
||||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7KxYeadQxt75HFRpj4FhFO3DOpVRFgzHlOEo3Fwk\
|
||||||
PZOKjvkT0cbcoEq5whLH25dHoQxGoVQgFyAP5s+7Vp5AlHh8Y/vAoXeEVyy/RCIH\
|
PZOKjvkT0cbcoEq5whLH25dHoQxGoVQgFyAP5s+7Vp5AlHh8Y/vAoXeEVyy/RCIH\
|
||||||
QkhUlAflfDMcrrYjsmwoOPSjhx6Mm/AopX4=\
|
QkhUlAflfDMcrrYjsmwoOPSjhx6Mm/AopX4=\
|
||||||
-----END CERTIFICATE-----\
|
-----END CERTIFICATE-----\
|
||||||
-----BEGIN PRIVATE KEY-----\
|
-----BEGIN PRIVATE KEY-----\
|
||||||
MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEA2EnE8ZOeVwZmwzPc\
|
MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEA2EnE8ZOeVwZmwzPc\
|
||||||
88DvoK1ckhOK7nVrsx9j6TmyKJ6m34UaAGpSlZbhvY72xyPNXl8QnUjm79SgT9bG\
|
88DvoK1ckhOK7nVrsx9j6TmyKJ6m34UaAGpSlZbhvY72xyPNXl8QnUjm79SgT9bG\
|
||||||
zeUc6QIDAQABAkBRFJZ32VbqWMP9OVwDJLiwC01AlYLnka0mIQZbT/2xq9dUc9GW\
|
zeUc6QIDAQABAkBRFJZ32VbqWMP9OVwDJLiwC01AlYLnka0mIQZbT/2xq9dUc9GW\
|
||||||
U3kiVw4lL8v/+sPjtTPCYYdzHHOyDen6znVhAiEA9qJT7BtQvRxCvGrAhr9MS022\
|
U3kiVw4lL8v/+sPjtTPCYYdzHHOyDen6znVhAiEA9qJT7BtQvRxCvGrAhr9MS022\
|
||||||
tTdPbW829BoUtIeH64cCIQDggG5i48v7HPacPBIH1RaSVhXl8qHCpQD3qrIw3FMw\
|
tTdPbW829BoUtIeH64cCIQDggG5i48v7HPacPBIH1RaSVhXl8qHCpQD3qrIw3FMw\
|
||||||
DwIga8PqH5Sf5sHedy2+CiK0V4MRfoU4c3zQ6kArI+bEgSkCIQCLA1vXBiE31B5s\
|
DwIga8PqH5Sf5sHedy2+CiK0V4MRfoU4c3zQ6kArI+bEgSkCIQCLA1vXBiE31B5s\
|
||||||
bdHoYa1BXebfZVd+1Hd95IfEM5mbRwIgSkDuQwV55BBlvWph3U8wVIMIb4GStaH8\
|
bdHoYa1BXebfZVd+1Hd95IfEM5mbRwIgSkDuQwV55BBlvWph3U8wVIMIb4GStaH8\
|
||||||
W535W8UBbEg=-----END PRIVATE KEY-----")?;
|
W535W8UBbEg=-----END PRIVATE KEY-----",
|
||||||
|
)?;
|
||||||
|
|
||||||
// Bindable versions were added in b1f515178a363df0322d7adbd5754e1f6e2083c9
|
// Bindable versions were added in b1f515178a363df0322d7adbd5754e1f6e2083c9
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_rtsp_media_factory_add_role(factory.to_glib_none().0,
|
ffi::gst_rtsp_media_factory_add_role(
|
||||||
"user".to_glib_none().0,
|
factory.to_glib_none().0,
|
||||||
RTSP_PERM_MEDIA_FACTORY_ACCESS.to_glib_none().0,
|
"user".to_glib_none().0,
|
||||||
<bool as StaticType>::static_type().to_glib() as *const u8,
|
RTSP_PERM_MEDIA_FACTORY_ACCESS.to_glib_none().0,
|
||||||
true.to_glib() as *const u8,
|
<bool as StaticType>::static_type().to_glib() as *const u8,
|
||||||
RTSP_PERM_MEDIA_FACTORY_CONSTRUCT.as_ptr() as *const u8,
|
true.to_glib() as *const u8,
|
||||||
<bool as StaticType>::static_type().to_glib() as *const u8,
|
RTSP_PERM_MEDIA_FACTORY_CONSTRUCT.as_ptr() as *const u8,
|
||||||
true.to_glib() as *const u8,
|
<bool as StaticType>::static_type().to_glib() as *const u8,
|
||||||
ptr::null_mut::<u8>());
|
true.to_glib() as *const u8,
|
||||||
|
ptr::null_mut::<u8>(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
auth.set_tls_certificate(&cert);
|
auth.set_tls_certificate(&cert);
|
||||||
|
@ -93,7 +96,10 @@ fn main_loop() -> Result<(), Error> {
|
||||||
|
|
||||||
server.attach(None);
|
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();
|
main_loop.run();
|
||||||
|
|
||||||
|
|
|
@ -28,30 +28,49 @@ use std::boxed::Box as Box_;
|
||||||
impl Discoverer {
|
impl Discoverer {
|
||||||
pub fn set_property_timeout(&self, timeout: gst::ClockTime) {
|
pub fn set_property_timeout(&self, timeout: gst::ClockTime) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gobject_ffi::g_object_set_property(self.to_glib_none().0,
|
gobject_ffi::g_object_set_property(
|
||||||
"timeout".to_glib_none().0, Value::from(&timeout).to_glib_none().0);
|
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 {
|
pub fn get_property_timeout(&self) -> gst::ClockTime {
|
||||||
let mut value = Value::from(&0u64);
|
let mut value = Value::from(&0u64);
|
||||||
unsafe {
|
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()
|
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 {
|
unsafe {
|
||||||
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
|
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
|
||||||
connect(self.to_glib_none().0, "notify::timeout",
|
connect(
|
||||||
transmute(notify_timeout_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
|
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)
|
unsafe extern "C" fn notify_timeout_trampoline<P>(
|
||||||
where P: IsA<Discoverer> {
|
this: *mut ffi::GstDiscoverer,
|
||||||
|
_param_spec: glib_ffi::gpointer,
|
||||||
|
f: glib_ffi::gpointer,
|
||||||
|
) where
|
||||||
|
P: IsA<Discoverer>,
|
||||||
|
{
|
||||||
callback_guard!();
|
callback_guard!();
|
||||||
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
|
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
|
||||||
f(&Discoverer::from_glib_borrow(this).downcast_unchecked())
|
f(&Discoverer::from_glib_borrow(this).downcast_unchecked())
|
||||||
|
|
|
@ -12,7 +12,7 @@ use DiscovererStreamInfoExt;
|
||||||
|
|
||||||
pub struct Iter {
|
pub struct Iter {
|
||||||
stream_info: Option<DiscovererStreamInfo>,
|
stream_info: Option<DiscovererStreamInfo>,
|
||||||
direction_forward: bool
|
direction_forward: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for Iter {
|
impl Iterator for Iter {
|
||||||
|
@ -28,8 +28,8 @@ impl Iterator for Iter {
|
||||||
} else {
|
} else {
|
||||||
c.get_previous()
|
c.get_previous()
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
&None => None
|
&None => None,
|
||||||
};
|
};
|
||||||
current
|
current
|
||||||
}
|
}
|
||||||
|
@ -39,14 +39,14 @@ impl DiscovererStreamInfo {
|
||||||
pub fn next_iter(&self) -> Iter {
|
pub fn next_iter(&self) -> Iter {
|
||||||
Iter {
|
Iter {
|
||||||
stream_info: self.get_next(),
|
stream_info: self.get_next(),
|
||||||
direction_forward: true
|
direction_forward: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn previous_iter(&self) -> Iter {
|
pub fn previous_iter(&self) -> Iter {
|
||||||
Iter {
|
Iter {
|
||||||
stream_info: self.get_previous(),
|
stream_info: self.get_previous(),
|
||||||
direction_forward: false
|
direction_forward: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@ impl DiscovererVideoInfo {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst::Fraction::new(
|
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_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 {
|
unsafe {
|
||||||
gst::Fraction::new(
|
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_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 glib_sys as glib_ffi;
|
||||||
extern crate gobject_sys as gobject_ffi;
|
extern crate gobject_sys as gobject_ffi;
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
extern crate gstreamer_sys as gst_ffi;
|
|
||||||
extern crate gstreamer_pbutils_sys as ffi;
|
extern crate gstreamer_pbutils_sys as ffi;
|
||||||
|
extern crate gstreamer_sys as gst_ffi;
|
||||||
|
|
||||||
static PBUTILS_INIT: Once = ONCE_INIT;
|
static PBUTILS_INIT: Once = ONCE_INIT;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ pub trait RTSPAuthExtManual {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<O: IsA<RTSPAuth>> RTSPAuthExtManual for O {
|
impl<O: IsA<RTSPAuth>> RTSPAuthExtManual for O {
|
||||||
|
|
||||||
fn set_default_token<'a, P: Into<Option<&'a mut RTSPToken>>>(&self, token: P) {
|
fn set_default_token<'a, P: Into<Option<&'a mut RTSPToken>>>(&self, token: P) {
|
||||||
let mut token = token.into();
|
let mut token = token.into();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Reference in a new issue