summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2020-09-17 22:56:01 +1000
committerTim-Philipp Müller <tim@centricular.com>2020-10-31 11:40:08 +0000
commitf8d6a68c69928ba83ff9cb2f0a39c61328f7cf0b (patch)
treee63c555b04370a01ebcd451596950b0eb26a7a39
parentf0e4a39a50d46cdb08ed5e31af8df22c161188f3 (diff)
downloadgstreamer-plugins-good-f8d6a68c69928ba83ff9cb2f0a39c61328f7cf0b.tar.gz
splitmuxsink: Never start a new fragment with no reference buffers
If there has been no bytes from the reference stream muxed into the current fragment, then time can't have advanced, there's no GOP... this fragment would be broken or empty, so wait for some data on the reference buffer. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/799>
-rw-r--r--gst/multifile/gstsplitmuxsink.c11
-rw-r--r--gst/multifile/gstsplitmuxsink.h4
2 files changed, 13 insertions, 2 deletions
diff --git a/gst/multifile/gstsplitmuxsink.c b/gst/multifile/gstsplitmuxsink.c
index e59f56866..2154eade8 100644
--- a/gst/multifile/gstsplitmuxsink.c
+++ b/gst/multifile/gstsplitmuxsink.c
@@ -2186,8 +2186,10 @@ need_new_fragment (GstSplitMuxSink * splitmux,
&& splitmux->muxer_has_reserved_props;
GST_OBJECT_UNLOCK (splitmux);
- /* Have we muxed anything into the new file at all? */
- if (splitmux->fragment_total_bytes <= 0)
+ /* Have we muxed at least one thing from the reference
+ * stream into the file? If not, no other streams can have
+ * either */
+ if (splitmux->fragment_reference_bytes <= 0)
return FALSE;
/* User told us to split now */
@@ -2361,6 +2363,7 @@ handle_gathered_gop (GstSplitMuxSink * splitmux)
new_out_ts = splitmux->reference_ctx->in_running_time;
splitmux->fragment_start_time = splitmux->gop_start_time;
splitmux->fragment_total_bytes = 0;
+ splitmux->fragment_reference_bytes = 0;
if (splitmux->tc_interval) {
video_time_code_replace (&splitmux->fragment_start_tc,
@@ -2800,6 +2803,9 @@ handle_mq_input (GstPad * pad, GstPadProbeInfo * info, MqStreamCtx * ctx)
/* Update total input byte counter for overflow detect */
splitmux->gop_total_bytes += buf_info->buf_size;
+ if (ctx->is_reference) {
+ splitmux->fragment_reference_bytes += buf_info->buf_size;
+ }
/* Now add this buffer to the queue just before returning */
g_queue_push_head (&ctx->queued_bufs, buf_info);
@@ -3494,6 +3500,7 @@ gst_splitmux_sink_reset (GstSplitMuxSink * splitmux)
GST_CLOCK_STIME_NONE;
splitmux->max_out_running_time = 0;
splitmux->fragment_total_bytes = 0;
+ splitmux->fragment_reference_bytes = 0;
splitmux->gop_total_bytes = 0;
splitmux->muxed_out_bytes = 0;
splitmux->ready_for_output = FALSE;
diff --git a/gst/multifile/gstsplitmuxsink.h b/gst/multifile/gstsplitmuxsink.h
index 67df4d4d4..bd629bdd0 100644
--- a/gst/multifile/gstsplitmuxsink.h
+++ b/gst/multifile/gstsplitmuxsink.h
@@ -144,6 +144,10 @@ struct _GstSplitMuxSink
/* Number of bytes sent to the
* current fragment */
guint64 fragment_total_bytes;
+ /* Number of bytes for the reference
+ * stream in this fragment */
+ guint64 fragment_reference_bytes;
+
/* Number of bytes we've collected into
* the GOP that's being collected */
guint64 gop_total_bytes;