mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +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,16 +30,6 @@ fn main() {
|
|||
let pipeline_clone = pipeline.clone();
|
||||
decodebin.connect_pad_added(move |_, src_pad| {
|
||||
let pipeline = &pipeline_clone;
|
||||
|
||||
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();
|
||||
|
||||
(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();
|
||||
|
||||
|
@ -53,21 +43,6 @@ fn main() {
|
|||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
assert_ne!(
|
||||
|
|
Loading…
Reference in a new issue