From a427b36f7910975f0799cbe5db082ff643105be0 Mon Sep 17 00:00:00 2001 From: Aaron Boxer Date: Thu, 8 Aug 2019 16:54:32 -0400 Subject: [PATCH] tsdemux: do not error if buffer size is invalid due to DISCONT Don't signal a pipeline error when processing incomplete j2pk PES packets that are too small. That can happen normally during a DISCONT and shouldn't shut down the whole pipeline --- gst/mpegtsdemux/tsdemux.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index 0ac3661046..a9fe30cce3 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -2848,9 +2848,22 @@ parse_jp2k_access_unit (TSDemuxStream * stream) /* Check if we have enough data to create a valid buffer */ if ((stream->current_size - data_location) < (AUF[0] + AUF[1])) { - GST_ERROR ("Required size (%d) greater than remaining size in buffer (%d)", + GST_ERROR_OBJECT + (stream->pad, + "Required size (%d) greater than remaining size in buffer (%d)", AUF[0] + AUF[1], (stream->current_size - data_location)); - goto error; + if (stream->expected_size && stream->current_size != stream->expected_size) { + /* warn if buffer is truncated due to draining */ + GST_WARNING_OBJECT + (stream->pad, + "Truncated buffer: current size (%d) doesn't match expected size (%d)", + stream->current_size, stream->expected_size); + } else { + /* kill pipeline if either we don't know what expected size is, or + * we know the expected size, and thus are sure that the buffer is not + * truncated due to draining */ + goto error; + } } retbuf = gst_buffer_new_wrapped_full (0, stream->data, stream->current_size,