diff options
author | Alessandro Decina <alessandro.d@gmail.com> | 2013-03-18 07:34:13 +0100 |
---|---|---|
committer | Alessandro Decina <alessandro.d@gmail.com> | 2013-03-18 07:34:13 +0100 |
commit | 175498434c0370729c5691966dffe9395a6f8cf8 (patch) | |
tree | 4a459b559a49764da57d4c247a5c6ba2af7bc1f5 | |
parent | 4ca7426f2a78fe7e42b75f0d0ebdffc1d485b7f2 (diff) | |
download | gstreamer-plugins-bad-175498434c0370729c5691966dffe9395a6f8cf8.tar.gz |
hlsdemux: parse #EXT-X-KEY tags
-rw-r--r-- | gst/hls/m3u8.c | 21 | ||||
-rw-r--r-- | gst/hls/m3u8.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/gst/hls/m3u8.c b/gst/hls/m3u8.c index 68657a784..0f54d1066 100644 --- a/gst/hls/m3u8.c +++ b/gst/hls/m3u8.c @@ -23,6 +23,7 @@ #include <math.h> #include <errno.h> #include <glib.h> +#include <string.h> #include <gst/glib-compat-private.h> #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 27b1be325..208e00a5a 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; |