Run everything through latest rustfmt

This commit is contained in:
Sebastian Dröge 2018-07-27 13:35:58 +03:00
parent bdfc95e6e8
commit dcb3683232
14 changed files with 55 additions and 70 deletions

View file

@ -161,7 +161,8 @@ impl AudioEcho {
state: &mut State, state: &mut State,
settings: &Settings, 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); * (state.info.rate() as usize) / (gst::SECOND_VAL as usize);
for (i, (o, e)) in data.iter_mut().zip(state.buffer.iter(delay_frames)) { for (i, (o, e)) in data.iter_mut().zip(state.buffer.iter(delay_frames)) {

View file

@ -83,7 +83,9 @@ struct AudioFormat {
// Ignores bitrate // Ignores bitrate
impl PartialEq for AudioFormat { impl PartialEq for AudioFormat {
fn eq(&self, other: &Self) -> bool { 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.channels.eq(&other.channels)
&& self.aac_sequence_header.eq(&other.aac_sequence_header) && self.aac_sequence_header.eq(&other.aac_sequence_header)
} }
@ -372,7 +374,8 @@ impl VideoFormat {
// Ignores bitrate // Ignores bitrate
impl PartialEq for VideoFormat { impl PartialEq for VideoFormat {
fn eq(&self, other: &Self) -> bool { 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.height.eq(&other.height)
&& self.pixel_aspect_ratio.eq(&other.pixel_aspect_ratio) && self.pixel_aspect_ratio.eq(&other.pixel_aspect_ratio)
&& self.framerate.eq(&other.framerate) && self.framerate.eq(&other.framerate)
@ -515,7 +518,8 @@ impl FlvDemux {
self.adapter.flush(15).unwrap(); self.adapter.flush(15).unwrap();
let buffer = self.adapter let buffer = self
.adapter
.get_buffer(tag_header.data_size as usize) .get_buffer(tag_header.data_size as usize)
.unwrap(); .unwrap();
let map = buffer.map_readable().unwrap(); let map = buffer.map_readable().unwrap();
@ -669,7 +673,8 @@ impl FlvDemux {
match header.packet_type { match header.packet_type {
flavors::AACPacketType::SequenceHeader => { flavors::AACPacketType::SequenceHeader => {
self.adapter.flush(15 + 1 + 1).unwrap(); 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) .get_buffer((tag_header.data_size - 1 - 1) as usize)
.unwrap(); .unwrap();
gst_debug!( gst_debug!(
@ -724,7 +729,8 @@ impl FlvDemux {
self.adapter.flush(offset as usize).unwrap(); 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) .get_buffer((tag_header.data_size - 1 - offset) as usize)
.unwrap(); .unwrap();
@ -845,7 +851,8 @@ impl FlvDemux {
match header.packet_type { match header.packet_type {
flavors::AVCPacketType::SequenceHeader => { flavors::AVCPacketType::SequenceHeader => {
self.adapter.flush(15 + 1 + 4).unwrap(); 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) .get_buffer((tag_header.data_size - 1 - 4) as usize)
.unwrap(); .unwrap();
gst_debug!( gst_debug!(
@ -910,7 +917,8 @@ impl FlvDemux {
self.adapter.flush(offset as usize).unwrap(); 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) .get_buffer((tag_header.data_size - 1 - offset) as usize)
.unwrap(); .unwrap();

View file

@ -6,8 +6,9 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use reqwest::header::{AcceptRanges, ByteRangeSpec, ContentLength, ContentRange, ContentRangeSpec, use reqwest::header::{
Range, RangeUnit}; AcceptRanges, ByteRangeSpec, ContentLength, ContentRange, ContentRangeSpec, Range, RangeUnit,
};
use reqwest::{Client, Response}; use reqwest::{Client, Response};
use std::io::Read; use std::io::Read;
use std::u64; use std::u64;

View file

@ -338,11 +338,7 @@ impl Demuxer {
mode: gst::PadMode, mode: gst::PadMode,
active: bool, active: bool,
) -> bool { ) -> bool {
let element = parent let element = parent.as_ref().unwrap().downcast_ref::<Element>().unwrap();
.as_ref()
.unwrap()
.downcast_ref::<Element>()
.unwrap();
let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap(); let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap();
if active { if active {
@ -375,11 +371,7 @@ impl Demuxer {
parent: &Option<gst::Object>, parent: &Option<gst::Object>,
buffer: gst::Buffer, buffer: gst::Buffer,
) -> gst::FlowReturn { ) -> gst::FlowReturn {
let element = parent let element = parent.as_ref().unwrap().downcast_ref::<Element>().unwrap();
.as_ref()
.unwrap()
.downcast_ref::<Element>()
.unwrap();
let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap(); let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap();
let mut res = { let mut res = {
@ -472,11 +464,7 @@ impl Demuxer {
fn sink_event(pad: &gst::Pad, parent: &Option<gst::Object>, event: gst::Event) -> bool { fn sink_event(pad: &gst::Pad, parent: &Option<gst::Object>, event: gst::Event) -> bool {
use gst::EventView; use gst::EventView;
let element = parent let element = parent.as_ref().unwrap().downcast_ref::<Element>().unwrap();
.as_ref()
.unwrap()
.downcast_ref::<Element>()
.unwrap();
let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap(); let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap();
match event.view() { match event.view() {
@ -487,12 +475,7 @@ impl Demuxer {
match demuxer_impl.end_of_stream(element) { match demuxer_impl.end_of_stream(element) {
Ok(_) => (), Ok(_) => (),
Err(ref msg) => { Err(ref msg) => {
gst_error!( gst_error!(demuxer.cat, obj: element, "Failed end of stream: {:?}", msg);
demuxer.cat,
obj: element,
"Failed end of stream: {:?}",
msg
);
element.post_error_message(msg); element.post_error_message(msg);
} }
} }
@ -506,11 +489,7 @@ impl Demuxer {
fn src_query(pad: &gst::Pad, parent: &Option<gst::Object>, query: &mut gst::QueryRef) -> bool { fn src_query(pad: &gst::Pad, parent: &Option<gst::Object>, query: &mut gst::QueryRef) -> bool {
use gst::QueryView; use gst::QueryView;
let element = parent let element = parent.as_ref().unwrap().downcast_ref::<Element>().unwrap();
.as_ref()
.unwrap()
.downcast_ref::<Element>()
.unwrap();
let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap(); let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap();
match query.view_mut() { match query.view_mut() {

View file

@ -19,8 +19,8 @@ use gobject_subclass::object::*;
use gst_plugin::base_sink::*; use gst_plugin::base_sink::*;
use gst_plugin::element::*; use gst_plugin::element::*;
use gst_plugin::uri_handler::*;
use gst_plugin::error::*; use gst_plugin::error::*;
use gst_plugin::uri_handler::*;
pub use gst_plugin::base_sink::BaseSink; pub use gst_plugin::base_sink::BaseSink;

View file

@ -21,8 +21,8 @@ use gobject_subclass::object::*;
use gst_plugin::base_src::*; use gst_plugin::base_src::*;
use gst_plugin::element::*; use gst_plugin::element::*;
use gst_plugin::uri_handler::*;
use gst_plugin::error::*; use gst_plugin::error::*;
use gst_plugin::uri_handler::*;
pub use gst_plugin::base_src::BaseSrc; pub use gst_plugin::base_src::BaseSrc;

View file

@ -26,8 +26,8 @@ use gst::prelude::*;
extern crate gtk; extern crate gtk;
use gtk::prelude::*; use gtk::prelude::*;
use std::env;
use std::cell::RefCell; use std::cell::RefCell;
use std::env;
fn create_pipeline() -> ( fn create_pipeline() -> (
gst::Pipeline, gst::Pipeline,

View file

@ -611,7 +611,8 @@ impl ToggleRecord {
// stop position that we're EOS now // stop position that we're EOS now
// If we're before the start position (we were starting before EOS), // If we're before the start position (we were starting before EOS),
// drop the buffer // 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 || current_running_time_end > rec_state.last_recording_stop
{ {
gst_debug!( gst_debug!(
@ -982,7 +983,9 @@ impl ToggleRecord {
// If a serialized event and coming after Segment and a new Segment is pending, // 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 // queue up and send at a later time (buffer/gap) after we sent the Segment
let type_ = event.get_type(); 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) && type_.partial_cmp(&gst::EventType::Segment) == Some(cmp::Ordering::Greater)
{ {
let mut state = stream.state.lock().unwrap(); let mut state = stream.state.lock().unwrap();
@ -1111,12 +1114,14 @@ impl ToggleRecord {
let (flags, min, max, align) = new_query.get_result(); let (flags, min, max, align) = new_query.get_result();
q.set(flags, min, max, align); q.set(flags, min, max, align);
q.add_scheduling_modes(&new_query q.add_scheduling_modes(
.get_scheduling_modes() &new_query
.iter() .get_scheduling_modes()
.cloned() .iter()
.filter(|m| m != &gst::PadMode::Pull) .cloned()
.collect::<Vec<_>>()); .filter(|m| m != &gst::PadMode::Pull)
.collect::<Vec<_>>(),
);
gst_log!(self.cat, obj: pad, "Returning {:?}", q.get_mut_query()); gst_log!(self.cat, obj: pad, "Returning {:?}", q.get_mut_query());
return true; return true;
} }
@ -1240,7 +1245,8 @@ impl ElementImpl<Element> for ToggleRecord {
match transition { match transition {
gst::StateChange::ReadyToPaused => { gst::StateChange::ReadyToPaused => {
for s in self.other_streams for s in self
.other_streams
.lock() .lock()
.unwrap() .unwrap()
.0 .0
@ -1274,7 +1280,8 @@ impl ElementImpl<Element> for ToggleRecord {
match transition { match transition {
gst::StateChange::PausedToReady => { gst::StateChange::PausedToReady => {
for s in self.other_streams for s in self
.other_streams
.lock() .lock()
.unwrap() .unwrap()
.0 .0

View file

@ -328,8 +328,7 @@ unsafe impl<T: IsA<gst::Element> + IsA<gst_base::BaseTransform> + ObjectType> Ba
for T for T
where where
T::InstanceStructType: PanicPoison, T::InstanceStructType: PanicPoison,
{ {}
}
pub type BaseTransformClass = ClassStruct<BaseTransform>; pub type BaseTransformClass = ClassStruct<BaseTransform>;
// FIXME: Boilerplate // FIXME: Boilerplate

View file

@ -72,11 +72,7 @@ pub trait ReadBytesExtShort: io::Read {
} }
} }
impl<T> ReadBytesExtShort for T impl<T> ReadBytesExtShort for T where T: ReadBytesExt {}
where
T: ReadBytesExt,
{
}
pub trait WriteBytesExtShort: WriteBytesExt { pub trait WriteBytesExtShort: WriteBytesExt {
fn write_u16le(&mut self, n: u16) -> io::Result<()> { fn write_u16le(&mut self, n: u16) -> io::Result<()> {
@ -141,8 +137,4 @@ pub trait WriteBytesExtShort: WriteBytesExt {
} }
} }
impl<T> WriteBytesExtShort for T impl<T> WriteBytesExtShort for T where T: WriteBytesExt {}
where
T: WriteBytesExt,
{
}

View file

@ -197,11 +197,9 @@ glib_wrapper! {
} }
} }
unsafe impl<T: IsA<gst::Element> + ObjectType> ElementBase for T unsafe impl<T: IsA<gst::Element> + ObjectType> ElementBase for T where
where Self::InstanceStructType: PanicPoison
Self::InstanceStructType: PanicPoison, {}
{
}
pub type ElementClass = ClassStruct<Element>; pub type ElementClass = ClassStruct<Element>;

View file

@ -1,8 +1,8 @@
use std::ptr; use std::ptr;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use gobject_subclass::object::*;
use glib::wrapper::Wrapper; use glib::wrapper::Wrapper;
use gobject_subclass::object::*;
#[repr(C)] #[repr(C)]
pub struct ElementInstanceStruct<T: ObjectType> { pub struct ElementInstanceStruct<T: ObjectType> {

View file

@ -62,8 +62,7 @@ glib_wrapper! {
unsafe impl<T: IsA<gst::Element> + IsA<gst::Bin> + IsA<gst::Pipeline> + ObjectType> PipelineBase unsafe impl<T: IsA<gst::Element> + IsA<gst::Bin> + IsA<gst::Pipeline> + ObjectType> PipelineBase
for T for T
{ {}
}
pub type PipelineClass = ClassStruct<Pipeline>; pub type PipelineClass = ClassStruct<Pipeline>;
// FIXME: Boilerplate // FIXME: Boilerplate

View file

@ -121,7 +121,8 @@ pub fn register_uri_handler<T: ObjectType, I: URIHandlerImplStatic<T>>(
imp: &I, imp: &I,
) { ) {
unsafe { unsafe {
let mut protocols: Vec<_> = imp.get_protocols() let mut protocols: Vec<_> = imp
.get_protocols()
.iter() .iter()
.map(|s| s.to_glib_full()) .map(|s| s.to_glib_full())
.collect(); .collect();