From 3d7daea5447d7c03f6160f71bd0c26330a1a38ee Mon Sep 17 00:00:00 2001 From: Eunhye Choi Date: Mon, 29 Nov 2021 16:09:19 +0900 Subject: [PATCH] hlsdemux: fix block issue if webvtt data is empty - send webvtt dummy buffer to avoid block and expose all the hlsdemux pad normally Change-Id: I5ff48c4498752353ca4fd985a73df0c9bbe914f2 --- ext/hls/gsthlsdemux.c | 49 +++++++++++++++++++++++++++++------------- packaging/gst-plugins-bad.spec | 3 ++- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c index 96ae1c2..c09b5e6 100644 --- a/ext/hls/gsthlsdemux.c +++ b/ext/hls/gsthlsdemux.c @@ -677,7 +677,6 @@ create_stream_for_playlist (GstAdaptiveDemux * demux, GstM3U8 * playlist, GST_LOG_OBJECT (demux, "Ignoring not-selected stream"); return; } - #ifdef TIZEN_FEATURE_UPSTREAM GST_DEBUG_OBJECT (demux, "is_primary_playlist:%d selected:%d playlist name '%s'", @@ -1268,23 +1267,44 @@ gst_hls_demux_handle_buffer (GstAdaptiveDemux * demux, } if (G_UNLIKELY (!caps)) { - /* Won't need this mapping any more all paths return inside this if() */ - gst_buffer_unmap (buffer, &info); - - /* Only fail typefinding if we already a good amount of data - * and we still don't know the type */ - if (buffer_size > (2 * 1024 * 1024) || at_eos) { - GST_ELEMENT_ERROR (hlsdemux, STREAM, TYPE_NOT_FOUND, - ("Could not determine type of stream"), (NULL)); +#ifdef TIZEN_FEATURE_HLSDEMUX_EMPTY_VTT + if (at_eos && info.data + && g_strrstr ((const gchar *) info.data, "WEBVTT")) { + gchar *dummy = + g_strdup ("WEBVTT\nX-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:0"); + GstBuffer *dummy_buffer = + gst_buffer_new_wrapped (dummy, strlen (dummy)); + + gst_buffer_unmap (buffer, &info); gst_buffer_unref (buffer); - return GST_FLOW_NOT_NEGOTIATED; - } - hls_stream->pending_typefind_buffer = buffer; + GST_WARNING_OBJECT (stream->pad, + "replace the empty VTT buffer with dummy"); - return GST_FLOW_OK; - } + buffer = dummy_buffer; + gst_buffer_map (buffer, &info, GST_MAP_READ); + + caps = gst_caps_new_simple ("application/x-subtitle-vtt", + "parsed", G_TYPE_BOOLEAN, FALSE, NULL); + } else +#endif + { + /* Won't need this mapping any more all paths return inside this if() */ + gst_buffer_unmap (buffer, &info); + + /* Only fail typefinding if we already a good amount of data + * and we still don't know the type */ + if (buffer_size > (2 * 1024 * 1024) || at_eos) { + GST_ELEMENT_ERROR (hlsdemux, STREAM, TYPE_NOT_FOUND, + ("Could not determine type of stream"), (NULL)); + gst_buffer_unref (buffer); + return GST_FLOW_NOT_NEGOTIATED; + } + hls_stream->pending_typefind_buffer = buffer; + return GST_FLOW_OK; + } + } #ifdef TIZEN_FEATURE_UPSTREAM GST_DEBUG_OBJECT (stream->pad, "Typefind result: %" GST_PTR_FORMAT " prob:%d", caps, prob); @@ -2190,7 +2210,6 @@ retry_failover_protection: } return gst_hls_demux_change_playlist (demux, new_bandwidth - 1, changed); } - #ifdef TIZEN_FEATURE_UPSTREAM gst_hls_variant_stream_unref (previous_variant); #endif diff --git a/packaging/gst-plugins-bad.spec b/packaging/gst-plugins-bad.spec index 8be4dfb..60956e9 100644 --- a/packaging/gst-plugins-bad.spec +++ b/packaging/gst-plugins-bad.spec @@ -4,7 +4,7 @@ Name: gst-plugins-bad Version: 1.16.2 -Release: 25 +Release: 26 Summary: GStreamer Streaming-Media Framework Plug-Ins License: LGPL-2.0+ Group: Multimedia/Framework @@ -81,6 +81,7 @@ NOCONFIGURE=1 ./autogen.sh export CFLAGS+=" -Wall -g -fPIC\ -DTIZEN_FEATURE_ADAPTIVE_MODIFICATION\ -DTIZEN_FEATURE_HLSDEMUX_PROPERTY\ + -DTIZEN_FEATURE_HLSDEMUX_EMPTY_VTT\ -DTIZEN_FEATURE_TSDEMUX_MODIFICATION\ -DTIZEN_FEATURE_TSDEMUX_INVALID_PCR_PID\ -DTIZEN_FEATURE_TSDEMUX_LANG_TAG\ -- 2.7.4