summaryrefslogtreecommitdiff
path: root/gst/hls/m3u8.c
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2011-08-18 23:54:59 +0000
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2011-08-22 15:46:41 +0200
commit690e59e49769fc67b3d88fa98be69cef6cfed3c2 (patch)
treee855f085d5d8a5123cce9677827d99460d6c95c9 /gst/hls/m3u8.c
parent1c73e77e3260458e6af63b16c8a83e88f6bbd0fd (diff)
downloadgstreamer-plugins-bad-690e59e49769fc67b3d88fa98be69cef6cfed3c2.tar.gz
hlsdemux: Keep a separate variable for the current variant used
By using a separate variable, first it allows us to sort the lists of alternates but keep the pointer on the first occurence in the main playlist (to respect the spec of starting with the bitrate specified first in the main playlist). It also avoid playing with the lists variable which should be used to store the list of playlists and not as a pointer to the current one. Also fixes a memleak with the g_list_foreach freeing the lists, if it wasn't pointing to the first element of the list.
Diffstat (limited to 'gst/hls/m3u8.c')
-rw-r--r--gst/hls/m3u8.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gst/hls/m3u8.c b/gst/hls/m3u8.c
index 66b4f1642..26548101f 100644
--- a/gst/hls/m3u8.c
+++ b/gst/hls/m3u8.c
@@ -206,6 +206,7 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated)
if (!g_str_has_prefix (data, "#EXTM3U")) {
GST_WARNING ("Data doesn't start with #EXTM3U");
+ *updated = FALSE;
g_free (data);
return FALSE;
}
@@ -350,11 +351,22 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated)
}
/* redorder playlists by bitrate */
- if (self->lists)
+ if (self->lists) {
+ gchar *top_variant_uri = NULL;
+
+ if (!self->current_variant)
+ top_variant_uri = GST_M3U8 (self->lists->data)->uri;
+ else
+ top_variant_uri = GST_M3U8 (self->current_variant->data)->uri;
+
self->lists =
g_list_sort (self->lists,
(GCompareFunc) gst_m3u8_compare_playlist_by_bitrate);
+ self->current_variant = g_list_find_custom (self->lists, top_variant_uri,
+ (GCompareFunc) _m3u8_compare_uri);
+ }
+
return TRUE;
}
@@ -416,7 +428,7 @@ gst_m3u8_client_update (GstM3U8Client * self, gchar * data)
/* select the first playlist, for now */
if (!self->current) {
if (self->main->lists) {
- self->current = g_list_first (self->main->lists)->data;
+ self->current = self->main->current_variant->data;
} else {
self->current = self->main;
}