Run everything through rustfmt again

This commit is contained in:
Sebastian Dröge 2018-10-08 09:32:08 +03:00
parent 2d45d3840f
commit 2c7dff3b45
15 changed files with 77 additions and 66 deletions

View file

@ -115,14 +115,12 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
.map(|sample| {
let f = f64::from(*sample) / f64::from(i16::MAX);
f * f
})
.sum();
}).sum();
let rms = (sum / (samples.len() as f64)).sqrt();
println!("rms: {}", rms);
gst::FlowReturn::Ok
})
.build(),
}).build(),
);
Ok(pipeline)

View file

@ -105,8 +105,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
// appsrc already handles the error here
let _ = appsrc.push_buffer(buffer);
})
.build(),
}).build(),
);
Ok(pipeline)

View file

@ -178,8 +178,7 @@ fn example_main() -> Result<(), Error> {
.and_then(|v| {
v.downcast_ref::<Arc<Mutex<Option<Error>>>>()
.and_then(|v| v.lock().unwrap().take())
})
.map(Result::Err)
}).map(Result::Err)
.expect("error-details message without actual error"),
_ => Err(ErrorMessage {
src: err

View file

@ -26,7 +26,12 @@ mod examples_common;
struct MissingElement(&'static str);
#[derive(Debug, Fail)]
#[fail(display = "Received error from {}: {} (debug: {:?})", src, error, debug)]
#[fail(
display = "Received error from {}: {} (debug: {:?})",
src,
error,
debug
)]
struct ErrorMessage {
src: String,
error: String,
@ -37,32 +42,25 @@ struct ErrorMessage {
fn configure_encodebin(encodebin: &gst::Element) -> Result<(), Error> {
let audio_profile = gst_pbutils::EncodingAudioProfileBuilder::new()
.format(&gst::Caps::new_simple(
"audio/x-vorbis",
&[],
))
.format(&gst::Caps::new_simple("audio/x-vorbis", &[]))
.presence(0)
.build()?;
let video_profile = gst_pbutils::EncodingVideoProfileBuilder::new()
.format(&gst::Caps::new_simple(
"video/x-theora",
&[],
))
.format(&gst::Caps::new_simple("video/x-theora", &[]))
.presence(0)
.build()?;
let container_profile = gst_pbutils::EncodingContainerProfileBuilder::new()
.name("container")
.format(&gst::Caps::new_simple(
"video/x-matroska",
&[],
))
.format(&gst::Caps::new_simple("video/x-matroska", &[]))
.add_profile(&(video_profile))
.add_profile(&(audio_profile))
.build()?;
encodebin.set_property("profile", &container_profile).expect("set profile property failed");
encodebin
.set_property("profile", &container_profile)
.expect("set profile property failed");
Ok(())
}
@ -83,16 +81,22 @@ fn example_main() -> Result<(), Error> {
};
let pipeline = gst::Pipeline::new(None);
let src = gst::ElementFactory::make("uridecodebin", None).ok_or(MissingElement("uridecodebin"))?;
let encodebin = gst::ElementFactory::make("encodebin", None).ok_or(MissingElement("encodebin"))?;
let src =
gst::ElementFactory::make("uridecodebin", None).ok_or(MissingElement("uridecodebin"))?;
let encodebin =
gst::ElementFactory::make("encodebin", None).ok_or(MissingElement("encodebin"))?;
let sink = gst::ElementFactory::make("filesink", None).ok_or(MissingElement("filesink"))?;
src.set_property("uri", &uri).expect("setting URI Property failed");
sink.set_property("location", &output_file).expect("setting location property failed");
src.set_property("uri", &uri)
.expect("setting URI Property failed");
sink.set_property("location", &output_file)
.expect("setting location property failed");
configure_encodebin(&encodebin)?;
pipeline.add_many(&[&src, &encodebin, &sink]).expect("failed to add elements to pipeline");
pipeline
.add_many(&[&src, &encodebin, &sink])
.expect("failed to add elements to pipeline");
gst::Element::link_many(&[&encodebin, &sink])?;
// Need to move a new reference into the closure
@ -113,7 +117,10 @@ fn example_main() -> Result<(), Error> {
gst_element_warning!(
dbin,
gst::CoreError::Negotiation,
("Failed to get media type from pad {}", dbin_src_pad.get_name())
(
"Failed to get media type from pad {}",
dbin_src_pad.get_name()
)
);
return;
@ -132,11 +139,17 @@ fn example_main() -> Result<(), Error> {
.ok_or(MissingElement("audioresample"))?;
let elements = &[&queue, &convert, &resample];
pipeline.add_many(elements).expect("failed to add audio elements to pipeline");
pipeline
.add_many(elements)
.expect("failed to add audio elements to pipeline");
gst::Element::link_many(elements)?;
let enc_sink_pad = encodebin.get_request_pad("audio_%u").expect("Could not get audio pad from encodebin");
let src_pad = resample.get_static_pad("src").expect("resample has no srcpad");
let enc_sink_pad = encodebin
.get_request_pad("audio_%u")
.expect("Could not get audio pad from encodebin");
let src_pad = resample
.get_static_pad("src")
.expect("resample has no srcpad");
src_pad.link(&enc_sink_pad).into_result()?;
for e in elements {
@ -154,11 +167,17 @@ fn example_main() -> Result<(), Error> {
.ok_or(MissingElement("videoscale"))?;
let elements = &[&queue, &convert, &scale];
pipeline.add_many(elements).expect("failed to add video elements to pipeline");
pipeline
.add_many(elements)
.expect("failed to add video elements to pipeline");
gst::Element::link_many(elements)?;
let enc_sink_pad = encodebin.get_request_pad("video_%u").expect("Could not get video pad from encodebin");
let src_pad = scale.get_static_pad("src").expect("videoscale has no srcpad");
let enc_sink_pad = encodebin
.get_request_pad("video_%u")
.expect("Could not get video pad from encodebin");
let src_pad = scale
.get_static_pad("src")
.expect("videoscale has no srcpad");
src_pad.link(&enc_sink_pad).into_result()?;
for e in elements {
@ -217,11 +236,11 @@ fn example_main() -> Result<(), Error> {
.and_then(|v| {
v.downcast_ref::<Arc<Mutex<Option<Error>>>>()
.and_then(|v| v.lock().unwrap().take())
})
.map(Result::Err)
}).map(Result::Err)
.expect("error-details message without actual error"),
_ => Err(ErrorMessage {
src: err.get_src()
src: err
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
@ -233,7 +252,8 @@ fn example_main() -> Result<(), Error> {
#[cfg(not(feature = "v1_10"))]
{
Err(ErrorMessage {
src: err.get_src()
src: err
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),

View file

@ -44,8 +44,7 @@ fn example_main() {
} else {
Ok(())
}
})
.and_then(|_| Ok(()));
}).and_then(|_| Ok(()));
let _ = block_on(messages);

View file

@ -47,8 +47,7 @@ fn example_main() {
} else {
Ok(())
}
})
.and_then(|_| Ok(()));
}).and_then(|_| Ok(()));
let _ = ctx.block_on(messages);

View file

@ -36,8 +36,7 @@ fn example_main() {
.map(|sample| {
let f = f64::from(*sample) / f64::from(i16::MAX);
f * f
})
.sum();
}).sum();
let rms = (sum / (samples.len() as f64)).sqrt();
println!("rms: {}", rms);
}

View file

@ -60,8 +60,7 @@ fn example_main() {
}
None
})
.unwrap();
}).unwrap();
let bus = playbin.get_bus().unwrap();

View file

@ -40,7 +40,7 @@ fn example_main() {
None
}
}.and_then(|pos| pos.try_into_time().ok())
.unwrap();
.unwrap();
let dur = {
let mut q = gst::Query::new_duration(gst::Format::Time);
@ -50,7 +50,7 @@ fn example_main() {
None
}
}.and_then(|dur| dur.try_into_time().ok())
.unwrap();
.unwrap();
println!("{} / {}", pos, dur);

View file

@ -64,6 +64,6 @@ pub mod prelude {
pub use glib::prelude::*;
pub use gst::prelude::*;
pub use encoding_profile::EncodingProfileBuilder;
pub use auto::traits::*;
pub use encoding_profile::EncodingProfileBuilder;
}

View file

@ -82,8 +82,7 @@ fn tutorial_main() {
.seek_simple(
gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT,
30 * gst::SECOND,
)
.expect("Failed to seek.");
).expect("Failed to seek.");
custom_data.seek_done = true;
}
}

View file

@ -328,24 +328,21 @@ mod tutorial5 {
let pipeline = args[0].get::<gst::Element>().unwrap();
post_app_message(&pipeline);
None
})
.unwrap();
}).unwrap();
playbin
.connect("audio-tags-changed", false, |args| {
let pipeline = args[0].get::<gst::Element>().unwrap();
post_app_message(&pipeline);
None
})
.unwrap();
}).unwrap();
playbin
.connect("text-tags-changed", false, move |args| {
let pipeline = args[0].get::<gst::Element>().unwrap();
post_app_message(&pipeline);
None
})
.unwrap();
}).unwrap();
let window = create_ui(&playbin);

View file

@ -137,18 +137,23 @@ fn tutorial_main() {
break;
}
MessageView::StateChanged(state_changed) =>
// We are only interested in state-changed messages from the pipeline
if state_changed.get_src().map(|s| s == pipeline).unwrap_or(false) {
// We are only interested in state-changed messages from the pipeline
{
if state_changed
.get_src()
.map(|s| s == pipeline)
.unwrap_or(false)
{
let new_state = state_changed.get_current();
let old_state = state_changed.get_old();
println!(
"Pipeline state changed from {:?} to {:?}",
old_state,
new_state
old_state, new_state
);
print_pad_capabilities(&sink, "sink");
},
}
}
_ => (),
}
}

View file

@ -40,8 +40,7 @@ fn tutorial_main() {
&visual,
&video_convert,
&video_sink,
])
.unwrap();
]).unwrap();
gst::Element::link_many(&[&audio_source, &tee]).unwrap();
gst::Element::link_many(&[&audio_queue, &audio_convert, &audio_resample, &audio_sink]).unwrap();

View file

@ -86,8 +86,7 @@ fn main() {
&video_sink,
&app_queue,
&appsink,
])
.unwrap();
]).unwrap();
gst::Element::link_many(&[&appsrc, &tee]).unwrap();
gst::Element::link_many(&[&audio_queue, &audio_convert1, &audio_resample, &audio_sink])