From 175498434c0370729c5691966dffe9395a6f8cf8 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Mon, 18 Mar 2013 07:34:13 +0100 Subject: [PATCH] hlsdemux: parse #EXT-X-KEY tags --- gst/hls/m3u8.c | 21 +++++++++++++++++++++ gst/hls/m3u8.h | 1 + 2 files changed, 22 insertions(+) diff --git a/gst/hls/m3u8.c b/gst/hls/m3u8.c index 68657a7840..0f54d10661 100644 --- a/gst/hls/m3u8.c +++ b/gst/hls/m3u8.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "gstfragmented.h" @@ -67,6 +68,7 @@ gst_m3u8_free (GstM3U8 * self) g_free (self->uri); g_free (self->allowcache); 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); @@ -351,6 +353,25 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated) } else if (g_str_has_prefix (data, "#EXT-X-ALLOW-CACHE:")) { g_free (self->allowcache); self->allowcache = g_strdup (data + 19); + } else if (g_str_has_prefix (data, "#EXT-X-KEY:")) { + gchar *v, *a; + + data = data + 11; + while (data && parse_attributes (&data, &a, &v)) { + if (g_str_equal (a, "URI")) { + gchar *key = g_strdup (v); + int len = strlen (key); + + /* handle the \"key\" case */ + if (key[len - 1] == '"') + key[len - 1] = '\0'; + if (key[0] == '"') + key += 1; + + self->key = uri_join (self->uri, key); + g_free (key); + } + } } else if (g_str_has_prefix (data, "#EXTINF:")) { gdouble fval; if (!double_from_string (data + 8, &data, &fval)) { diff --git a/gst/hls/m3u8.h b/gst/hls/m3u8.h index 27b1be3257..208e00a5ab 100644 --- a/gst/hls/m3u8.h +++ b/gst/hls/m3u8.h @@ -43,6 +43,7 @@ struct _GstM3U8 gint version; /* last EXT-X-VERSION */ GstClockTime targetduration; /* last EXT-X-TARGETDURATION */ gchar *allowcache; /* last EXT-X-ALLOWCACHE */ + gchar *key; gint bandwidth; gint program_id;