mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
Simplify toc example a bit
There's not need for checking audio/video if both are going directly to a fakesink anyway.
This commit is contained in:
parent
04f09ebc86
commit
07e9383ddf
1 changed files with 10 additions and 35 deletions
|
@ -30,44 +30,19 @@ fn main() {
|
||||||
let pipeline_clone = pipeline.clone();
|
let pipeline_clone = pipeline.clone();
|
||||||
decodebin.connect_pad_added(move |_, src_pad| {
|
decodebin.connect_pad_added(move |_, src_pad| {
|
||||||
let pipeline = &pipeline_clone;
|
let pipeline = &pipeline_clone;
|
||||||
|
let queue = gst::ElementFactory::make("queue", None).unwrap();
|
||||||
|
let sink = gst::ElementFactory::make("fakesink", None).unwrap();
|
||||||
|
|
||||||
let (is_audio, is_video) = {
|
let elements = &[&queue, &sink];
|
||||||
let caps = src_pad.get_current_caps().unwrap();
|
pipeline.add_many(elements).unwrap();
|
||||||
let structure = caps.get_structure(0).unwrap();
|
gst::Element::link_many(elements).unwrap();
|
||||||
let name = structure.get_name();
|
|
||||||
|
|
||||||
(name.starts_with("audio/"), name.starts_with("video/"))
|
for e in elements {
|
||||||
};
|
e.sync_state_with_parent().unwrap();
|
||||||
|
|
||||||
if is_audio {
|
|
||||||
let queue = gst::ElementFactory::make("queue", None).unwrap();
|
|
||||||
let sink = gst::ElementFactory::make("fakesink", None).unwrap();
|
|
||||||
|
|
||||||
let elements = &[&queue, &sink];
|
|
||||||
pipeline.add_many(elements).unwrap();
|
|
||||||
gst::Element::link_many(elements).unwrap();
|
|
||||||
|
|
||||||
for e in elements {
|
|
||||||
e.sync_state_with_parent().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
let sink_pad = queue.get_static_pad("sink").unwrap();
|
|
||||||
assert_eq!(src_pad.link(&sink_pad), gst::PadLinkReturn::Ok);
|
|
||||||
} else if is_video {
|
|
||||||
let queue = gst::ElementFactory::make("queue", None).unwrap();
|
|
||||||
let sink = gst::ElementFactory::make("fakesink", None).unwrap();
|
|
||||||
|
|
||||||
let elements = &[&queue, &sink];
|
|
||||||
pipeline.add_many(elements).unwrap();
|
|
||||||
gst::Element::link_many(elements).unwrap();
|
|
||||||
|
|
||||||
for e in elements {
|
|
||||||
e.sync_state_with_parent().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
let sink_pad = queue.get_static_pad("sink").unwrap();
|
|
||||||
assert_eq!(src_pad.link(&sink_pad), gst::PadLinkReturn::Ok);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sink_pad = queue.get_static_pad("sink").unwrap();
|
||||||
|
assert_eq!(src_pad.link(&sink_pad), gst::PadLinkReturn::Ok);
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_ne!(
|
assert_ne!(
|
||||||
|
|
Loading…
Reference in a new issue