From: Eunhae Choi Date: Thu, 13 Sep 2018 08:22:17 +0000 (+0900) Subject: hlsdemux: check num of codec before switching stream X-Git-Tag: accepted/tizen/unified/20220217.153506~2^2~10^2~9^2~12^2~2^2~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=975e839cb1621b411efd426646112f1eb1a4073e;p=platform%2Fupstream%2Fgstreamer.git hlsdemux: check num of codec before switching stream Change-Id: I4a20f367edea52e69e246ed308ccda319a39288f --- diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c old mode 100755 new mode 100644 index cd50c78..85a65d6 --- a/ext/hls/gsthlsdemux.c +++ b/ext/hls/gsthlsdemux.c @@ -1377,6 +1377,7 @@ gst_hls_demux_update_variant_playlist (GstHLSDemux * hlsdemux, gchar * data, if (hlsdemux->master->is_simple) { GST_ERROR ("Cannot update variant playlist: Current playlist is not a variant playlist"); + gst_hls_master_playlist_unref (new_master); goto out; } diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c index 2f0c980..0e74175 100644 --- a/ext/hls/m3u8.c +++ b/ext/hls/m3u8.c @@ -1775,6 +1775,44 @@ gst_hls_variant_find_matching_media (GstHLSVariantStream * stream, } #ifdef TIZEN_FEATURE_ADAPTIVE_MODIFICATION +static guint +get_num_of_codec(GstHLSVariantStream * variant) +{ +#define MAX_NUM_OF_CODEC 10 + + guint cnt = 0; + gchar** codec_list = NULL; + + if (!variant || !variant->codecs) + return 0; + + codec_list = g_strsplit(variant->codecs, ",", MAX_NUM_OF_CODEC); + if (codec_list) { + cnt = g_strv_length(codec_list); + g_strfreev(codec_list); + } + + return cnt; +} + +static gboolean +check_num_of_codec(GstHLSVariantStream * variant, guint req_num) +{ + guint num_of_codec = 0; + + if (!variant) + return FALSE; + + num_of_codec = get_num_of_codec(variant); + + if (num_of_codec > 0 && req_num > 0 && num_of_codec != req_num) { + GST_WARNING("can not support to change codec"); + return FALSE; + } + + return TRUE; +} + GstHLSVariantStream * gst_hls_master_playlist_get_variant_for_max_limit (GstHLSMasterPlaylist * playlist, GstHLSVariantStream * current_variant, guint bitrate, gint bandwidth, gint width, gint height) @@ -1783,6 +1821,9 @@ gst_hls_master_playlist_get_variant_for_max_limit (GstHLSMasterPlaylist * GstHLSVariantStream *variant = NULL; GList *l; guint max_bandwidth = (bandwidth > DEFAULT_ADAPTIVE_VARIANT)?(guint)(bandwidth):(bitrate); + guint num_of_codec = 0; + + num_of_codec = get_num_of_codec(current_variant); GST_INFO("max limit : %u, %d, [w]%d [h]%d", bitrate, bandwidth, width, height); @@ -1793,6 +1834,9 @@ gst_hls_master_playlist_get_variant_for_max_limit (GstHLSMasterPlaylist * l = g_list_last (playlist->iframe_variants); for (; l; l = g_list_previous(l)) { + if (!check_num_of_codec((GstHLSVariantStream *)l->data, num_of_codec)) + continue; + tmp = l->data; if (tmp->bandwidth > max_bandwidth) diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index 691263a..145da7a 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -2528,7 +2528,7 @@ gst_adaptive_demux_stream_push_buffer (GstAdaptiveDemuxStream * stream, GST_BUFFER_DTS (buffer) = GST_CLOCK_TIME_NONE; if (G_UNLIKELY (stream->pending_caps)) { #ifdef TIZEN_FEATURE_ADAPTIVE_MODIFICATION - gst_caps_make_writable (stream->pending_caps); + stream->pending_caps = gst_caps_make_writable (stream->pending_caps); if (gst_adaptive_demux_is_live (demux)) { gst_caps_set_simple (stream->pending_caps, "is_live", G_TYPE_BOOLEAN, TRUE, NULL); diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.h b/gst-libs/gst/adaptivedemux/gstadaptivedemux.h index 1a14db7..8c2c658 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.h +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.h @@ -38,7 +38,7 @@ G_BEGIN_DECLS (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_ADAPTIVE_DEMUX,GstAdaptiveDemuxClass)) #define GST_IS_ADAPTIVE_DEMUX(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ADAPTIVE_DEMUX)) -#define GST_IS_ADAPTIVE_DEMUX_CLASS(obj) \ +#define GST_IS_ADAPTIVE_DEMUX_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ADAPTIVE_DEMUX)) #define GST_ADAPTIVE_DEMUX_CAST(obj) ((GstAdaptiveDemux *)obj)