mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-23 10:30:40 +00:00
fallbacksrc: Remove imagefreeze if it becomes unneeded
This commit is contained in:
parent
874063668b
commit
7233d6936c
1 changed files with 22 additions and 5 deletions
|
@ -123,6 +123,9 @@ struct Stream {
|
||||||
// clocksync for source source pad
|
// clocksync for source source pad
|
||||||
clocksync: gst::Element,
|
clocksync: gst::Element,
|
||||||
|
|
||||||
|
// imagefreeze if this is an image stream
|
||||||
|
imagefreeze: Option<gst::Element>,
|
||||||
|
|
||||||
clocksync_queue: gst::Element,
|
clocksync_queue: gst::Element,
|
||||||
clocksync_queue_srcpad: gst::Pad,
|
clocksync_queue_srcpad: gst::Pad,
|
||||||
|
|
||||||
|
@ -983,6 +986,7 @@ impl FallbackSrc {
|
||||||
source_srcpad: None,
|
source_srcpad: None,
|
||||||
source_srcpad_block: None,
|
source_srcpad_block: None,
|
||||||
clocksync,
|
clocksync,
|
||||||
|
imagefreeze: None,
|
||||||
clocksync_queue_srcpad: clocksync_queue.static_pad("src").unwrap(),
|
clocksync_queue_srcpad: clocksync_queue.static_pad("src").unwrap(),
|
||||||
clocksync_queue,
|
clocksync_queue,
|
||||||
switch,
|
switch,
|
||||||
|
@ -1318,12 +1322,19 @@ impl FallbackSrc {
|
||||||
};
|
};
|
||||||
|
|
||||||
let sinkpad = if is_image {
|
let sinkpad = if is_image {
|
||||||
let imagefreeze =
|
let imagefreeze = if let Some(ref imagefreeze) = stream.imagefreeze {
|
||||||
gst::ElementFactory::make("imagefreeze", None).expect("no imagefreeze found");
|
imagefreeze
|
||||||
|
} else {
|
||||||
|
let imagefreeze =
|
||||||
|
gst::ElementFactory::make("imagefreeze", None).expect("no imagefreeze found");
|
||||||
|
|
||||||
|
gst::debug!(CAT, "image stream, inserting imagefreeze");
|
||||||
|
element.add(&imagefreeze).unwrap();
|
||||||
|
imagefreeze.set_property("is-live", true);
|
||||||
|
stream.imagefreeze = Some(imagefreeze);
|
||||||
|
stream.imagefreeze.as_ref().unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
gst::debug!(CAT, "image stream, inserting imagefreeze");
|
|
||||||
element.add(&imagefreeze).unwrap();
|
|
||||||
imagefreeze.set_property("is-live", true);
|
|
||||||
if imagefreeze.sync_state_with_parent().is_err() {
|
if imagefreeze.sync_state_with_parent().is_err() {
|
||||||
gst::error!(CAT, obj: element, "imagefreeze failed to change state",);
|
gst::error!(CAT, obj: element, "imagefreeze failed to change state",);
|
||||||
return Err(gst::error_msg!(
|
return Err(gst::error_msg!(
|
||||||
|
@ -1334,6 +1345,12 @@ impl FallbackSrc {
|
||||||
imagefreeze.link(&stream.clocksync_queue).unwrap();
|
imagefreeze.link(&stream.clocksync_queue).unwrap();
|
||||||
imagefreeze.static_pad("sink").unwrap()
|
imagefreeze.static_pad("sink").unwrap()
|
||||||
} else {
|
} else {
|
||||||
|
if let Some(imagefreeze) = stream.imagefreeze.take() {
|
||||||
|
imagefreeze.set_locked_state(true);
|
||||||
|
let _ = imagefreeze.set_state(gst::State::Null);
|
||||||
|
element.remove(&imagefreeze).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
stream.clocksync_queue.static_pad("sink").unwrap()
|
stream.clocksync_queue.static_pad("sink").unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue