summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2020-10-31 12:49:08 +1100
committerTim-Philipp Müller <tim@centricular.com>2020-10-31 11:40:08 +0000
commit2abd43ebd2425c0612401d51d1dad7b1fc963562 (patch)
tree401ac584d16799d7062e590187df9a32a9c8bdcc
parent21f0da0b642900f9967fda891551f6b2c66adbca (diff)
downloadgstreamer-plugins-good-2abd43ebd2425c0612401d51d1dad7b1fc963562.tar.gz
splitmuxsink: Change EOS catching logic.
Add a new state for ending the overall stream, and use it to decide whether to pass the final EOS message up the bus instead of dropping it. Fixes a small race that makes the testsuite sometimes not generate the last fragment(s) sometimes because the wrong EOS gets allowed through too early. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/799>
-rw-r--r--gst/multifile/gstsplitmuxsink.c19
-rw-r--r--gst/multifile/gstsplitmuxsink.h1
2 files changed, 14 insertions, 6 deletions
diff --git a/gst/multifile/gstsplitmuxsink.c b/gst/multifile/gstsplitmuxsink.c
index 02342cbba..185b4ad5a 100644
--- a/gst/multifile/gstsplitmuxsink.c
+++ b/gst/multifile/gstsplitmuxsink.c
@@ -1267,6 +1267,7 @@ complete_or_wait_on_out (GstSplitMuxSink * splitmux, MqStreamCtx * ctx)
continue;
case SPLITMUX_OUTPUT_STATE_ENDING_FILE:
+ case SPLITMUX_OUTPUT_STATE_ENDING_STREAM:
/* We've reached the max out running_time to get here, so end this file now */
if (ctx->out_eos == FALSE) {
if (splitmux->async_finalize) {
@@ -1590,6 +1591,12 @@ handle_mq_output (GstPad * pad, GstPadProbeInfo * info, MqStreamCtx * ctx)
if (splitmux->output_state == SPLITMUX_OUTPUT_STATE_STOPPED)
goto beach;
ctx->out_eos = TRUE;
+
+ if (ctx == splitmux->reference_ctx) {
+ splitmux->output_state = SPLITMUX_OUTPUT_STATE_ENDING_STREAM;
+ GST_SPLITMUX_BROADCAST_OUTPUT (splitmux);
+ }
+
GST_INFO_OBJECT (splitmux,
"Have EOS event at pad %" GST_PTR_FORMAT " ctx %p", pad, ctx);
break;
@@ -2095,7 +2102,12 @@ bus_handler (GstBin * bin, GstMessage * message)
GST_SPLITMUX_UNLOCK (splitmux);
return;
}
- } else if (splitmux->output_state == SPLITMUX_OUTPUT_STATE_ENDING_FILE) {
+ } else if (splitmux->output_state == SPLITMUX_OUTPUT_STATE_ENDING_STREAM) {
+ GST_DEBUG_OBJECT (splitmux,
+ "Passing EOS message. Output state %d max_out_running_time %"
+ GST_STIME_FORMAT, splitmux->output_state,
+ GST_STIME_ARGS (splitmux->max_out_running_time));
+ } else {
GST_DEBUG_OBJECT (splitmux, "Caught EOS at end of fragment, dropping");
splitmux->output_state = SPLITMUX_OUTPUT_STATE_START_NEXT_FILE;
GST_SPLITMUX_BROADCAST_OUTPUT (splitmux);
@@ -2103,11 +2115,6 @@ bus_handler (GstBin * bin, GstMessage * message)
gst_message_unref (message);
GST_SPLITMUX_UNLOCK (splitmux);
return;
- } else {
- GST_DEBUG_OBJECT (splitmux,
- "Passing EOS message. Output state %d max_out_running_time %"
- GST_STIME_FORMAT, splitmux->output_state,
- GST_STIME_ARGS (splitmux->max_out_running_time));
}
GST_SPLITMUX_UNLOCK (splitmux);
break;
diff --git a/gst/multifile/gstsplitmuxsink.h b/gst/multifile/gstsplitmuxsink.h
index e1cc14c72..f00d884bf 100644
--- a/gst/multifile/gstsplitmuxsink.h
+++ b/gst/multifile/gstsplitmuxsink.h
@@ -50,6 +50,7 @@ typedef enum _SplitMuxOutputState
SPLITMUX_OUTPUT_STATE_AWAITING_COMMAND, /* Waiting first command packet from input */
SPLITMUX_OUTPUT_STATE_OUTPUT_GOP, /* Outputting a collected GOP */
SPLITMUX_OUTPUT_STATE_ENDING_FILE, /* Finishing the current fragment */
+ SPLITMUX_OUTPUT_STATE_ENDING_STREAM, /* Finishing up the entire stream due to input EOS */
SPLITMUX_OUTPUT_STATE_START_NEXT_FILE /* Restarting after ENDING_FILE */
} SplitMuxOutputState;