mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-25 17:40:34 +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();
|
||||
decodebin.connect_pad_added(move |_, src_pad| {
|
||||
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 caps = src_pad.get_current_caps().unwrap();
|
||||
let structure = caps.get_structure(0).unwrap();
|
||||
let name = structure.get_name();
|
||||
let elements = &[&queue, &sink];
|
||||
pipeline.add_many(elements).unwrap();
|
||||
gst::Element::link_many(elements).unwrap();
|
||||
|
||||
(name.starts_with("audio/"), name.starts_with("video/"))
|
||||
};
|
||||
|
||||
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);
|
||||
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);
|
||||
});
|
||||
|
||||
assert_ne!(
|
||||
|
|
Loading…
Reference in a new issue