hlsdemux: check num of codec before switching stream
authorEunhae Choi <eunhae1.choi@samsung.com>
Thu, 13 Sep 2018 08:22:17 +0000 (17:22 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Thu, 13 Sep 2018 08:22:17 +0000 (17:22 +0900)
Change-Id: I4a20f367edea52e69e246ed308ccda319a39288f

ext/hls/gsthlsdemux.c [changed mode: 0755->0644]
ext/hls/m3u8.c
gst-libs/gst/adaptivedemux/gstadaptivedemux.c
gst-libs/gst/adaptivedemux/gstadaptivedemux.h

old mode 100755 (executable)
new mode 100644 (file)
index cd50c78..85a65d6
@@ -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;
   }
 
index 2f0c980..0e74175 100644 (file)
@@ -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)
index 691263a..145da7a 100644 (file)
@@ -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);
index 1a14db7..8c2c658 100644 (file)
@@ -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)