Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>2023-02-08 22:33:29 +0300
committerSebastian Dröge <sebastian@centricular.com>2023-07-05 14:37:55 +0300
commit72941b5dc5db729577441fac209bce974a3b81be (patch)
treea4ae08554038ed77bfe38e9f6dd168baae3117b3 /utils
parent0954af10c7e7c839f3c400eb8a7948f284db3213 (diff)
livesync: Improve EOS handling
I've looked at the GstQueue code again and tried making livesync behave better with EOS. This isn't very well tested, though. My goal was to make this look saner but I think this should be reviewed by someone who knows the queue code. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1267>
Diffstat (limited to 'utils')
-rw-r--r--utils/livesync/src/livesync/imp.rs65
1 files changed, 48 insertions, 17 deletions
diff --git a/utils/livesync/src/livesync/imp.rs b/utils/livesync/src/livesync/imp.rs
index 99eac29f3..d5de74eef 100644
--- a/utils/livesync/src/livesync/imp.rs
+++ b/utils/livesync/src/livesync/imp.rs
@@ -598,6 +598,9 @@ impl LiveSync {
}
}
+ let mut is_restart = false;
+ let mut is_eos = false;
+
match event.view() {
gst::EventView::FlushStart(_) => {
let ret = self.srcpad.push_event(event);
@@ -637,13 +640,11 @@ impl LiveSync {
return ret;
}
- gst::EventView::StreamStart(_) => {
- let mut state = self.state.lock();
- state.srcresult = Ok(gst::FlowSuccess::Ok);
- state.eos = false;
- }
+ gst::EventView::StreamStart(_) => is_restart = true,
gst::EventView::Segment(e) => {
+ is_restart = true;
+
let segment = match e.segment().downcast_ref() {
Some(s) => s,
None => {
@@ -656,17 +657,7 @@ impl LiveSync {
state.in_segment = Some(segment.clone());
}
- gst::EventView::Eos(_) => {
- let mut state = self.state.lock();
-
- if let Err(err) = state.srcresult {
- if matches!(err, gst::FlowError::Flushing | gst::FlowError::Eos) {
- self.flow_error(err);
- }
- }
-
- state.eos = true;
- }
+ gst::EventView::Eos(_) => is_eos = true,
gst::EventView::Caps(c) => {
let caps = c.caps_owned();
@@ -698,7 +689,33 @@ impl LiveSync {
}
let mut state = self.state.lock();
- if state.srcresult.is_err() {
+
+ if is_restart {
+ if state.srcresult == Err(gst::FlowError::Eos) {
+ state.srcresult = Ok(gst::FlowSuccess::Ok);
+ }
+
+ state.eos = false;
+ let _ = self.start_src_task();
+ }
+
+ if state.eos {
+ gst::trace!(CAT, imp: self, "Refusing event, we are EOS: {:?}", event);
+ return false;
+ }
+
+ if is_eos {
+ state.eos = true;
+ }
+
+ if let Err(err) = state.srcresult {
+ // Following GstQueue's behavior:
+ // > For EOS events, that are not followed by data flow, we still
+ // > return FALSE here though and report an error.
+ if is_eos && !matches!(err, gst::FlowError::Flushing | gst::FlowError::Eos) {
+ self.flow_error(err);
+ }
+
return false;
}
@@ -792,6 +809,11 @@ impl LiveSync {
let mut state = self.state.lock();
+ if state.eos {
+ gst::debug!(CAT, imp: self, "Refusing buffer, we are EOS");
+ return Err(gst::FlowError::Eos);
+ }
+
if state.upstream_latency.is_none() {
gst::debug!(CAT, imp: self, "Have no upstream latency yet, querying");
let mut q = gst::query::Latency::new();
@@ -988,6 +1010,9 @@ impl LiveSync {
self.cond.notify_all();
}
+ // Following GstQueue's behavior:
+ // > let app know about us giving up if upstream is not expected to do so
+ // > EOS is already taken care of elsewhere
if eos && !matches!(err, gst::FlowError::Flushing | gst::FlowError::Eos) {
self.flow_error(err);
pad.push_event(gst::event::Eos::new());
@@ -1032,6 +1057,12 @@ impl LiveSync {
push = false;
}
+ gst::EventView::Eos(_) => {
+ state.out_buffer = None;
+ state.out_timestamp = None;
+ state.srcresult = Err(gst::FlowError::Eos);
+ }
+
gst::EventView::Caps(e) => {
state.pending_caps = Some(e.caps_owned());
state.update_fallback_duration();