forked from mirrors/gstreamer-rs
Run everything through rustfmt again
This commit is contained in:
parent
65b77971ef
commit
5d40a3ba2d
1 changed files with 49 additions and 29 deletions
|
@ -26,7 +26,10 @@ mod examples_common;
|
||||||
struct MissingElement(&'static str);
|
struct MissingElement(&'static str);
|
||||||
|
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
#[fail(display = "Received error from {}: {} (debug: {:?})", src, error, debug)]
|
#[fail(
|
||||||
|
display = "Received error from {}: {} (debug: {:?})",
|
||||||
|
src, error, debug
|
||||||
|
)]
|
||||||
struct ErrorMessage {
|
struct ErrorMessage {
|
||||||
src: String,
|
src: String,
|
||||||
error: String,
|
error: String,
|
||||||
|
@ -37,32 +40,25 @@ struct ErrorMessage {
|
||||||
|
|
||||||
fn configure_encodebin(encodebin: &gst::Element) -> Result<(), Error> {
|
fn configure_encodebin(encodebin: &gst::Element) -> Result<(), Error> {
|
||||||
let audio_profile = gst_pbutils::EncodingAudioProfileBuilder::new()
|
let audio_profile = gst_pbutils::EncodingAudioProfileBuilder::new()
|
||||||
.format(&gst::Caps::new_simple(
|
.format(&gst::Caps::new_simple("audio/x-vorbis", &[]))
|
||||||
"audio/x-vorbis",
|
|
||||||
&[],
|
|
||||||
))
|
|
||||||
.presence(0)
|
.presence(0)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let video_profile = gst_pbutils::EncodingVideoProfileBuilder::new()
|
let video_profile = gst_pbutils::EncodingVideoProfileBuilder::new()
|
||||||
.format(&gst::Caps::new_simple(
|
.format(&gst::Caps::new_simple("video/x-theora", &[]))
|
||||||
"video/x-theora",
|
|
||||||
&[],
|
|
||||||
))
|
|
||||||
.presence(0)
|
.presence(0)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let container_profile = gst_pbutils::EncodingContainerProfileBuilder::new()
|
let container_profile = gst_pbutils::EncodingContainerProfileBuilder::new()
|
||||||
.name("container")
|
.name("container")
|
||||||
.format(&gst::Caps::new_simple(
|
.format(&gst::Caps::new_simple("video/x-matroska", &[]))
|
||||||
"video/x-matroska",
|
|
||||||
&[],
|
|
||||||
))
|
|
||||||
.add_profile(&(video_profile))
|
.add_profile(&(video_profile))
|
||||||
.add_profile(&(audio_profile))
|
.add_profile(&(audio_profile))
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
encodebin.set_property("profile", &container_profile).expect("set profile property failed");
|
encodebin
|
||||||
|
.set_property("profile", &container_profile)
|
||||||
|
.expect("set profile property failed");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -83,16 +79,22 @@ fn example_main() -> Result<(), Error> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let pipeline = gst::Pipeline::new(None);
|
let pipeline = gst::Pipeline::new(None);
|
||||||
let src = gst::ElementFactory::make("uridecodebin", None).ok_or(MissingElement("uridecodebin"))?;
|
let src =
|
||||||
let encodebin = gst::ElementFactory::make("encodebin", None).ok_or(MissingElement("encodebin"))?;
|
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"))?;
|
let sink = gst::ElementFactory::make("filesink", None).ok_or(MissingElement("filesink"))?;
|
||||||
|
|
||||||
src.set_property("uri", &uri).expect("setting URI Property failed");
|
src.set_property("uri", &uri)
|
||||||
sink.set_property("location", &output_file).expect("setting location property failed");
|
.expect("setting URI Property failed");
|
||||||
|
sink.set_property("location", &output_file)
|
||||||
|
.expect("setting location property failed");
|
||||||
|
|
||||||
configure_encodebin(&encodebin)?;
|
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])?;
|
gst::Element::link_many(&[&encodebin, &sink])?;
|
||||||
|
|
||||||
// Need to move a new reference into the closure
|
// Need to move a new reference into the closure
|
||||||
|
@ -113,7 +115,10 @@ fn example_main() -> Result<(), Error> {
|
||||||
gst_element_warning!(
|
gst_element_warning!(
|
||||||
dbin,
|
dbin,
|
||||||
gst::CoreError::Negotiation,
|
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;
|
return;
|
||||||
|
@ -132,11 +137,17 @@ fn example_main() -> Result<(), Error> {
|
||||||
.ok_or(MissingElement("audioresample"))?;
|
.ok_or(MissingElement("audioresample"))?;
|
||||||
|
|
||||||
let elements = &[&queue, &convert, &resample];
|
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)?;
|
gst::Element::link_many(elements)?;
|
||||||
|
|
||||||
let enc_sink_pad = encodebin.get_request_pad("audio_%u").expect("Could not get audio pad from encodebin");
|
let enc_sink_pad = encodebin
|
||||||
let src_pad = resample.get_static_pad("src").expect("resample has no srcpad");
|
.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()?;
|
src_pad.link(&enc_sink_pad).into_result()?;
|
||||||
|
|
||||||
for e in elements {
|
for e in elements {
|
||||||
|
@ -154,11 +165,17 @@ fn example_main() -> Result<(), Error> {
|
||||||
.ok_or(MissingElement("videoscale"))?;
|
.ok_or(MissingElement("videoscale"))?;
|
||||||
|
|
||||||
let elements = &[&queue, &convert, &scale];
|
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)?;
|
gst::Element::link_many(elements)?;
|
||||||
|
|
||||||
let enc_sink_pad = encodebin.get_request_pad("video_%u").expect("Could not get video pad from encodebin");
|
let enc_sink_pad = encodebin
|
||||||
let src_pad = scale.get_static_pad("src").expect("videoscale has no srcpad");
|
.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()?;
|
src_pad.link(&enc_sink_pad).into_result()?;
|
||||||
|
|
||||||
for e in elements {
|
for e in elements {
|
||||||
|
@ -221,19 +238,22 @@ fn example_main() -> Result<(), Error> {
|
||||||
.map(Result::Err)
|
.map(Result::Err)
|
||||||
.expect("error-details message without actual error"),
|
.expect("error-details message without actual error"),
|
||||||
_ => Err(ErrorMessage {
|
_ => Err(ErrorMessage {
|
||||||
src: err.get_src()
|
src: err
|
||||||
|
.get_src()
|
||||||
.map(|s| s.get_path_string())
|
.map(|s| s.get_path_string())
|
||||||
.unwrap_or_else(|| String::from("None")),
|
.unwrap_or_else(|| String::from("None")),
|
||||||
error: err.get_error().description().into(),
|
error: err.get_error().description().into(),
|
||||||
debug: err.get_debug(),
|
debug: err.get_debug(),
|
||||||
cause: err.get_error(),
|
cause: err.get_error(),
|
||||||
}.into()),
|
}
|
||||||
|
.into()),
|
||||||
}?;
|
}?;
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "v1_10"))]
|
#[cfg(not(feature = "v1_10"))]
|
||||||
{
|
{
|
||||||
Err(ErrorMessage {
|
Err(ErrorMessage {
|
||||||
src: err.get_src()
|
src: err
|
||||||
|
.get_src()
|
||||||
.map(|s| s.get_path_string())
|
.map(|s| s.get_path_string())
|
||||||
.unwrap_or_else(|| String::from("None")),
|
.unwrap_or_else(|| String::from("None")),
|
||||||
error: err.get_error().description().into(),
|
error: err.get_error().description().into(),
|
||||||
|
|
Loading…
Reference in a new issue