Reformat code with 'cargo fmt'

This commit is contained in:
Thibault Saunier 2022-02-08 12:26:32 +00:00 committed by Mathieu Duponchelle
parent 22205c235d
commit 51c2f35909

View file

@ -2,10 +2,10 @@ use anyhow::Context;
use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst_video::prelude::*;
use gst_video::subclass::prelude::*;
use gst::{gst_debug, gst_error, gst_info, gst_log, gst_trace, gst_warning};
use gst_rtp::prelude::*;
use gst_video::prelude::*;
use gst_video::subclass::prelude::*;
use gst_webrtc::WebRTCDataChannel;
use async_std::task;
@ -198,7 +198,7 @@ struct State {
navigation_handler: Option<NavigationEventHandler>,
}
fn create_navigation_event<N: IsA< gst_video::Navigation>>(sink: &N, msg: &str) {
fn create_navigation_event<N: IsA<gst_video::Navigation>>(sink: &N, msg: &str) {
let event: Result<gst_video::NavigationEvent, _> = serde_json::from_str(msg);
if let Ok(event) = event {
@ -206,8 +206,6 @@ fn create_navigation_event<N: IsA< gst_video::Navigation>>(sink: &N, msg: &str)
} else {
gst_error!(CAT, "Invalid navigation event: {:?}", msg);
}
}
/// Simple utility for tearing down a pipeline cleanly
struct PipelineWrapper(gst::Pipeline);
@ -362,7 +360,8 @@ fn setup_encoding(
// to incorrect color display in Chrome (but interestingly not in
// Firefox). In any case, restrict to exclude RGB formats altogether,
// and let videoconvert do the conversion properly if needed.
structure_builder = structure_builder.field("format", &gst::List::new(&[&"NV12", &"YV12", &"I420"]));
structure_builder =
structure_builder.field("format", &gst::List::new(&[&"NV12", &"YV12", &"I420"]));
}
gst::Caps::builder_full_with_any_features()
@ -886,7 +885,12 @@ impl State {
}
}
fn remove_consumer(&mut self, element: &super::WebRTCSink, peer_id: &str, signal: bool) -> Option<Consumer> {
fn remove_consumer(
&mut self,
element: &super::WebRTCSink,
peer_id: &str,
signal: bool,
) -> Option<Consumer> {
if let Some(consumer) = self.consumers.remove(peer_id) {
self.finalize_consumer(element, &consumer, signal);
Some(consumer)
@ -1202,11 +1206,7 @@ impl InputStream {
}
impl NavigationEventHandler {
pub fn new(
element: &super::WebRTCSink,
webrtcbin: &gst::Element,
) -> Self {
pub fn new(element: &super::WebRTCSink, webrtcbin: &gst::Element) -> Self {
let channel = webrtcbin.emit_by_name::<WebRTCDataChannel>(
"create-data-channel",
&[&"input", &None::<gst::Structure>],
@ -1725,9 +1725,7 @@ impl WebRTCSink {
})?;
if settings.enable_data_channel_navigation {
state.navigation_handler = Some(
NavigationEventHandler::new(&element, &webrtcbin)
);
state.navigation_handler = Some(NavigationEventHandler::new(&element, &webrtcbin));
}
pipeline.set_state(gst::State::Playing).map_err(|err| {
@ -2413,7 +2411,8 @@ impl ObjectImpl for WebRTCSink {
}
"enable-data-channel-navigation" => {
let mut settings = self.settings.lock().unwrap();
settings.enable_data_channel_navigation = value.get::<bool>().expect("type checked upstream");
settings.enable_data_channel_navigation =
value.get::<bool>().expect("type checked upstream");
}
_ => unimplemented!(),
}
@ -2486,7 +2485,6 @@ impl ObjectImpl for WebRTCSink {
glib::types::Type::UNIT.into(),
)
.build(),
/*
* RsWebRTCSink::consumer_removed:
* @consumer_id: Identifier of the consumer that was removed
@ -2504,7 +2502,6 @@ impl ObjectImpl for WebRTCSink {
glib::types::Type::UNIT.into(),
)
.build(),
/*
* RsWebRTCSink::get_consumers:
*
@ -2726,17 +2723,14 @@ impl NavigationImpl for WebRTCSink {
let mut state = self.state.lock().unwrap();
let event = gst::event::Navigation::new(event_def);
state
.streams
.iter_mut()
.for_each(|(_, stream)| {
if stream.sink_pad.name().starts_with("video_") {
gst_log!(CAT, "Navigating to: {:?}", event);
// FIXME: Handle multi tracks.
if !stream.sink_pad.push_event(event.clone()) {
gst_info!(CAT, "Could not send event: {:?}", event);
}
state.streams.iter_mut().for_each(|(_, stream)| {
if stream.sink_pad.name().starts_with("video_") {
gst_log!(CAT, "Navigating to: {:?}", event);
// FIXME: Handle multi tracks.
if !stream.sink_pad.push_event(event.clone()) {
gst_info!(CAT, "Could not send event: {:?}", event);
}
});
}
});
}
}