hlsdemux: Don't store the current key in the playlist

It's per fragment and applying to all following fragments
until the next key is specified.
This commit is contained in:
Sebastian Dröge 2014-06-06 13:08:04 +03:00
parent 008edeadae
commit 37ffe063f6
2 changed files with 8 additions and 7 deletions

View file

@ -73,7 +73,6 @@ gst_m3u8_free (GstM3U8 * self)
g_free (self->base_uri);
g_free (self->name);
g_free (self->codecs);
g_free (self->key);
g_list_foreach (self->files, (GFunc) gst_m3u8_media_file_free, NULL);
g_list_free (self->files);
@ -137,7 +136,6 @@ _m3u8_copy (const GstM3U8 * self, GstM3U8 * parent)
dup->version = self->version;
dup->targetduration = self->targetduration;
dup->allowcache = self->allowcache;
dup->key = g_strdup (self->key);
dup->bandwidth = self->bandwidth;
dup->program_id = self->program_id;
dup->codecs = g_strdup (self->codecs);
@ -350,6 +348,7 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated)
gchar *title, *end;
gboolean discontinuity = FALSE;
GstM3U8 *list;
gchar *current_key = NULL;
gboolean have_iv = FALSE;
guint8 iv[16] = { 0, };
gint64 size = -1, offset = -1;
@ -431,7 +430,7 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated)
self->mediasequence++);
/* set encryption params */
file->key = g_strdup (self->key);
file->key = current_key ? g_strdup (current_key) : NULL;
if (file->key) {
if (have_iv) {
memcpy (file->iv, iv, sizeof (iv));
@ -562,8 +561,8 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated)
/* IV and KEY are only valid until the next #EXT-X-KEY */
have_iv = FALSE;
g_free (self->key);
self->key = NULL;
g_free (current_key);
current_key = NULL;
while (data && parse_attributes (&data, &a, &v)) {
if (g_str_equal (a, "URI")) {
gchar *key = g_strdup (v);
@ -588,7 +587,7 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated)
}
}
self->key =
current_key =
uri_join (self->base_uri ? self->base_uri : self->uri, key);
g_free (keyp);
} else if (g_str_equal (a, "IV")) {
@ -663,6 +662,9 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated)
data = g_utf8_next_char (end); /* skip \n */
}
g_free (current_key);
current_key = NULL;
/* reorder playlists by bitrate */
if (self->lists) {
gchar *top_variant_uri = NULL;

View file

@ -47,7 +47,6 @@ struct _GstM3U8
gint version; /* last EXT-X-VERSION */
GstClockTime targetduration; /* last EXT-X-TARGETDURATION */
gboolean allowcache; /* last EXT-X-ALLOWCACHE */
gchar *key;
gint bandwidth;
gint program_id;