From dcb36832329fde0113a41b80ebdb5efd28ead68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 27 Jul 2018 13:35:58 +0300 Subject: [PATCH] Run everything through latest rustfmt --- gst-plugin-audiofx/src/audioecho.rs | 3 +- gst-plugin-flv/src/flvdemux.rs | 22 ++++++++----- gst-plugin-http/src/httpsrc.rs | 5 +-- gst-plugin-simple/src/demuxer.rs | 31 +++---------------- gst-plugin-simple/src/sink.rs | 2 +- gst-plugin-simple/src/source.rs | 2 +- .../examples/gtk_recording.rs | 2 +- gst-plugin-togglerecord/src/togglerecord.rs | 27 ++++++++++------ gst-plugin/src/base_transform.rs | 3 +- gst-plugin/src/bytes.rs | 12 ++----- gst-plugin/src/element.rs | 8 ++--- gst-plugin/src/object.rs | 2 +- gst-plugin/src/pipeline.rs | 3 +- gst-plugin/src/uri_handler.rs | 3 +- 14 files changed, 55 insertions(+), 70 deletions(-) diff --git a/gst-plugin-audiofx/src/audioecho.rs b/gst-plugin-audiofx/src/audioecho.rs index 8e96135d..eabfe9fc 100644 --- a/gst-plugin-audiofx/src/audioecho.rs +++ b/gst-plugin-audiofx/src/audioecho.rs @@ -161,7 +161,8 @@ impl AudioEcho { state: &mut State, settings: &Settings, ) { - let delay_frames = (settings.delay as usize) * (state.info.channels() as usize) + let delay_frames = (settings.delay as usize) + * (state.info.channels() as usize) * (state.info.rate() as usize) / (gst::SECOND_VAL as usize); for (i, (o, e)) in data.iter_mut().zip(state.buffer.iter(delay_frames)) { diff --git a/gst-plugin-flv/src/flvdemux.rs b/gst-plugin-flv/src/flvdemux.rs index f944dbd1..d9251cac 100644 --- a/gst-plugin-flv/src/flvdemux.rs +++ b/gst-plugin-flv/src/flvdemux.rs @@ -83,7 +83,9 @@ struct AudioFormat { // Ignores bitrate impl PartialEq for AudioFormat { fn eq(&self, other: &Self) -> bool { - self.format.eq(&other.format) && self.rate.eq(&other.rate) && self.width.eq(&other.width) + self.format.eq(&other.format) + && self.rate.eq(&other.rate) + && self.width.eq(&other.width) && self.channels.eq(&other.channels) && self.aac_sequence_header.eq(&other.aac_sequence_header) } @@ -372,7 +374,8 @@ impl VideoFormat { // Ignores bitrate impl PartialEq for VideoFormat { fn eq(&self, other: &Self) -> bool { - self.format.eq(&other.format) && self.width.eq(&other.width) + self.format.eq(&other.format) + && self.width.eq(&other.width) && self.height.eq(&other.height) && self.pixel_aspect_ratio.eq(&other.pixel_aspect_ratio) && self.framerate.eq(&other.framerate) @@ -515,7 +518,8 @@ impl FlvDemux { self.adapter.flush(15).unwrap(); - let buffer = self.adapter + let buffer = self + .adapter .get_buffer(tag_header.data_size as usize) .unwrap(); let map = buffer.map_readable().unwrap(); @@ -669,7 +673,8 @@ impl FlvDemux { match header.packet_type { flavors::AACPacketType::SequenceHeader => { self.adapter.flush(15 + 1 + 1).unwrap(); - let buffer = self.adapter + let buffer = self + .adapter .get_buffer((tag_header.data_size - 1 - 1) as usize) .unwrap(); gst_debug!( @@ -724,7 +729,8 @@ impl FlvDemux { self.adapter.flush(offset as usize).unwrap(); } - let mut buffer = self.adapter + let mut buffer = self + .adapter .get_buffer((tag_header.data_size - 1 - offset) as usize) .unwrap(); @@ -845,7 +851,8 @@ impl FlvDemux { match header.packet_type { flavors::AVCPacketType::SequenceHeader => { self.adapter.flush(15 + 1 + 4).unwrap(); - let buffer = self.adapter + let buffer = self + .adapter .get_buffer((tag_header.data_size - 1 - 4) as usize) .unwrap(); gst_debug!( @@ -910,7 +917,8 @@ impl FlvDemux { self.adapter.flush(offset as usize).unwrap(); } - let mut buffer = self.adapter + let mut buffer = self + .adapter .get_buffer((tag_header.data_size - 1 - offset) as usize) .unwrap(); diff --git a/gst-plugin-http/src/httpsrc.rs b/gst-plugin-http/src/httpsrc.rs index 04e9e3fe..e7f32ddf 100644 --- a/gst-plugin-http/src/httpsrc.rs +++ b/gst-plugin-http/src/httpsrc.rs @@ -6,8 +6,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use reqwest::header::{AcceptRanges, ByteRangeSpec, ContentLength, ContentRange, ContentRangeSpec, - Range, RangeUnit}; +use reqwest::header::{ + AcceptRanges, ByteRangeSpec, ContentLength, ContentRange, ContentRangeSpec, Range, RangeUnit, +}; use reqwest::{Client, Response}; use std::io::Read; use std::u64; diff --git a/gst-plugin-simple/src/demuxer.rs b/gst-plugin-simple/src/demuxer.rs index ec116db2..d1af4683 100644 --- a/gst-plugin-simple/src/demuxer.rs +++ b/gst-plugin-simple/src/demuxer.rs @@ -338,11 +338,7 @@ impl Demuxer { mode: gst::PadMode, active: bool, ) -> bool { - let element = parent - .as_ref() - .unwrap() - .downcast_ref::() - .unwrap(); + let element = parent.as_ref().unwrap().downcast_ref::().unwrap(); let demuxer = element.get_impl().downcast_ref::().unwrap(); if active { @@ -375,11 +371,7 @@ impl Demuxer { parent: &Option, buffer: gst::Buffer, ) -> gst::FlowReturn { - let element = parent - .as_ref() - .unwrap() - .downcast_ref::() - .unwrap(); + let element = parent.as_ref().unwrap().downcast_ref::().unwrap(); let demuxer = element.get_impl().downcast_ref::().unwrap(); let mut res = { @@ -472,11 +464,7 @@ impl Demuxer { fn sink_event(pad: &gst::Pad, parent: &Option, event: gst::Event) -> bool { use gst::EventView; - let element = parent - .as_ref() - .unwrap() - .downcast_ref::() - .unwrap(); + let element = parent.as_ref().unwrap().downcast_ref::().unwrap(); let demuxer = element.get_impl().downcast_ref::().unwrap(); match event.view() { @@ -487,12 +475,7 @@ impl Demuxer { match demuxer_impl.end_of_stream(element) { Ok(_) => (), Err(ref msg) => { - gst_error!( - demuxer.cat, - obj: element, - "Failed end of stream: {:?}", - msg - ); + gst_error!(demuxer.cat, obj: element, "Failed end of stream: {:?}", msg); element.post_error_message(msg); } } @@ -506,11 +489,7 @@ impl Demuxer { fn src_query(pad: &gst::Pad, parent: &Option, query: &mut gst::QueryRef) -> bool { use gst::QueryView; - let element = parent - .as_ref() - .unwrap() - .downcast_ref::() - .unwrap(); + let element = parent.as_ref().unwrap().downcast_ref::().unwrap(); let demuxer = element.get_impl().downcast_ref::().unwrap(); match query.view_mut() { diff --git a/gst-plugin-simple/src/sink.rs b/gst-plugin-simple/src/sink.rs index 0fff26b7..3ec1dd1a 100644 --- a/gst-plugin-simple/src/sink.rs +++ b/gst-plugin-simple/src/sink.rs @@ -19,8 +19,8 @@ use gobject_subclass::object::*; use gst_plugin::base_sink::*; use gst_plugin::element::*; -use gst_plugin::uri_handler::*; use gst_plugin::error::*; +use gst_plugin::uri_handler::*; pub use gst_plugin::base_sink::BaseSink; diff --git a/gst-plugin-simple/src/source.rs b/gst-plugin-simple/src/source.rs index 7c7c1c72..3d07fedc 100644 --- a/gst-plugin-simple/src/source.rs +++ b/gst-plugin-simple/src/source.rs @@ -21,8 +21,8 @@ use gobject_subclass::object::*; use gst_plugin::base_src::*; use gst_plugin::element::*; -use gst_plugin::uri_handler::*; use gst_plugin::error::*; +use gst_plugin::uri_handler::*; pub use gst_plugin::base_src::BaseSrc; diff --git a/gst-plugin-togglerecord/examples/gtk_recording.rs b/gst-plugin-togglerecord/examples/gtk_recording.rs index 28e11e44..5f0795f6 100644 --- a/gst-plugin-togglerecord/examples/gtk_recording.rs +++ b/gst-plugin-togglerecord/examples/gtk_recording.rs @@ -26,8 +26,8 @@ use gst::prelude::*; extern crate gtk; use gtk::prelude::*; -use std::env; use std::cell::RefCell; +use std::env; fn create_pipeline() -> ( gst::Pipeline, diff --git a/gst-plugin-togglerecord/src/togglerecord.rs b/gst-plugin-togglerecord/src/togglerecord.rs index fa6a025c..503d46fc 100644 --- a/gst-plugin-togglerecord/src/togglerecord.rs +++ b/gst-plugin-togglerecord/src/togglerecord.rs @@ -611,7 +611,8 @@ impl ToggleRecord { // stop position that we're EOS now // If we're before the start position (we were starting before EOS), // drop the buffer - if rec_state.last_recording_stop.is_none() || rec_state.last_recording_start.is_none() + if rec_state.last_recording_stop.is_none() + || rec_state.last_recording_start.is_none() || current_running_time_end > rec_state.last_recording_stop { gst_debug!( @@ -982,7 +983,9 @@ impl ToggleRecord { // If a serialized event and coming after Segment and a new Segment is pending, // queue up and send at a later time (buffer/gap) after we sent the Segment let type_ = event.get_type(); - if forward && type_ != gst::EventType::Eos && type_.is_serialized() + if forward + && type_ != gst::EventType::Eos + && type_.is_serialized() && type_.partial_cmp(&gst::EventType::Segment) == Some(cmp::Ordering::Greater) { let mut state = stream.state.lock().unwrap(); @@ -1111,12 +1114,14 @@ impl ToggleRecord { let (flags, min, max, align) = new_query.get_result(); q.set(flags, min, max, align); - q.add_scheduling_modes(&new_query - .get_scheduling_modes() - .iter() - .cloned() - .filter(|m| m != &gst::PadMode::Pull) - .collect::>()); + q.add_scheduling_modes( + &new_query + .get_scheduling_modes() + .iter() + .cloned() + .filter(|m| m != &gst::PadMode::Pull) + .collect::>(), + ); gst_log!(self.cat, obj: pad, "Returning {:?}", q.get_mut_query()); return true; } @@ -1240,7 +1245,8 @@ impl ElementImpl for ToggleRecord { match transition { gst::StateChange::ReadyToPaused => { - for s in self.other_streams + for s in self + .other_streams .lock() .unwrap() .0 @@ -1274,7 +1280,8 @@ impl ElementImpl for ToggleRecord { match transition { gst::StateChange::PausedToReady => { - for s in self.other_streams + for s in self + .other_streams .lock() .unwrap() .0 diff --git a/gst-plugin/src/base_transform.rs b/gst-plugin/src/base_transform.rs index e8d84091..e6090a60 100644 --- a/gst-plugin/src/base_transform.rs +++ b/gst-plugin/src/base_transform.rs @@ -328,8 +328,7 @@ unsafe impl + IsA + ObjectType> Ba for T where T::InstanceStructType: PanicPoison, -{ -} +{} pub type BaseTransformClass = ClassStruct; // FIXME: Boilerplate diff --git a/gst-plugin/src/bytes.rs b/gst-plugin/src/bytes.rs index b049cae1..d16be1d1 100644 --- a/gst-plugin/src/bytes.rs +++ b/gst-plugin/src/bytes.rs @@ -72,11 +72,7 @@ pub trait ReadBytesExtShort: io::Read { } } -impl ReadBytesExtShort for T -where - T: ReadBytesExt, -{ -} +impl ReadBytesExtShort for T where T: ReadBytesExt {} pub trait WriteBytesExtShort: WriteBytesExt { fn write_u16le(&mut self, n: u16) -> io::Result<()> { @@ -141,8 +137,4 @@ pub trait WriteBytesExtShort: WriteBytesExt { } } -impl WriteBytesExtShort for T -where - T: WriteBytesExt, -{ -} +impl WriteBytesExtShort for T where T: WriteBytesExt {} diff --git a/gst-plugin/src/element.rs b/gst-plugin/src/element.rs index e04f74d1..47ca7a80 100644 --- a/gst-plugin/src/element.rs +++ b/gst-plugin/src/element.rs @@ -197,11 +197,9 @@ glib_wrapper! { } } -unsafe impl + ObjectType> ElementBase for T -where - Self::InstanceStructType: PanicPoison, -{ -} +unsafe impl + ObjectType> ElementBase for T where + Self::InstanceStructType: PanicPoison +{} pub type ElementClass = ClassStruct; diff --git a/gst-plugin/src/object.rs b/gst-plugin/src/object.rs index e4ee13e7..293903ff 100644 --- a/gst-plugin/src/object.rs +++ b/gst-plugin/src/object.rs @@ -1,8 +1,8 @@ use std::ptr; use std::sync::atomic::AtomicBool; -use gobject_subclass::object::*; use glib::wrapper::Wrapper; +use gobject_subclass::object::*; #[repr(C)] pub struct ElementInstanceStruct { diff --git a/gst-plugin/src/pipeline.rs b/gst-plugin/src/pipeline.rs index 813ecec4..56ccf933 100644 --- a/gst-plugin/src/pipeline.rs +++ b/gst-plugin/src/pipeline.rs @@ -62,8 +62,7 @@ glib_wrapper! { unsafe impl + IsA + IsA + ObjectType> PipelineBase for T -{ -} +{} pub type PipelineClass = ClassStruct; // FIXME: Boilerplate diff --git a/gst-plugin/src/uri_handler.rs b/gst-plugin/src/uri_handler.rs index 49d4ff96..07abd615 100644 --- a/gst-plugin/src/uri_handler.rs +++ b/gst-plugin/src/uri_handler.rs @@ -121,7 +121,8 @@ pub fn register_uri_handler>( imp: &I, ) { unsafe { - let mut protocols: Vec<_> = imp.get_protocols() + let mut protocols: Vec<_> = imp + .get_protocols() .iter() .map(|s| s.to_glib_full()) .collect();