Revert "hlsdemux: Simplify logic in process_manifest"
authorThiago Santos <thiagoss@osg.samsung.com>
Fri, 5 Jun 2015 12:15:34 +0000 (09:15 -0300)
committerThiago Santos <thiagoss@osg.samsung.com>
Fri, 5 Jun 2015 12:43:10 +0000 (09:43 -0300)
This reverts commit 4ca3a22b6b33ad8be4383063e76f79c4d346535d.

The connection-speed=0 is used as a special value in the property
of hlsdemux to mean 'automatic' selection, m3u8.c doesn't need
to know about that as it should be as simple as possible.

So this patch hides this automatic selection documented in hlsdemux
into m3u8 logic and I think the gets harder to understand the code.

It also makes the hlsdemux unit tests work again

https://bugzilla.gnome.org/show_bug.cgi?id=749328

ext/hls/gsthlsdemux.c
ext/hls/m3u8.c

index d8578e7..1535815 100644 (file)
@@ -436,12 +436,18 @@ gst_hls_demux_process_manifest (GstAdaptiveDemux * demux, GstBuffer * buf)
   if (gst_m3u8_client_has_variant_playlist (hlsdemux->client)) {
     GstM3U8 *child = NULL;
     GError *err = NULL;
-    GList *current_variant = NULL;
 
-    current_variant =
-        gst_m3u8_client_get_playlist_for_bitrate (hlsdemux->client,
-        demux->connection_speed);
-    child = GST_M3U8 (current_variant->data);
+    /* TODO seems like something that could be simplified */
+    if (demux->connection_speed == 0) {
+      GST_M3U8_CLIENT_LOCK (hlsdemux->client);
+      child = hlsdemux->client->main->current_variant->data;
+      GST_M3U8_CLIENT_UNLOCK (hlsdemux->client);
+    } else {
+      GList *tmp = gst_m3u8_client_get_playlist_for_bitrate (hlsdemux->client,
+          demux->connection_speed);
+
+      child = GST_M3U8 (tmp->data);
+    }
 
     gst_m3u8_client_set_current (hlsdemux->client, child);
     if (!gst_hls_demux_update_playlist (hlsdemux, FALSE, &err)) {
index 3f3c278..4b6e362 100755 (executable)
@@ -1293,11 +1293,6 @@ gst_m3u8_client_get_playlist_for_bitrate (GstM3U8Client * client, guint bitrate)
   GST_M3U8_CLIENT_LOCK (client);
   current_variant = client->main->current_variant;
 
-  if (bitrate == 0) {
-    GST_M3U8_CLIENT_UNLOCK (client);
-    return current_variant;
-  }
-
   /*  Go to the highest possible bandwidth allowed */
   while (GST_M3U8 (current_variant->data)->bandwidth <= bitrate) {
     list = g_list_next (current_variant);