hlsdemux: parse #EXT-X-KEY tags

This commit is contained in:
Alessandro Decina 2013-03-18 07:34:13 +01:00
parent 4ca7426f2a
commit 175498434c
2 changed files with 22 additions and 0 deletions

View file

@ -23,6 +23,7 @@
#include <math.h> #include <math.h>
#include <errno.h> #include <errno.h>
#include <glib.h> #include <glib.h>
#include <string.h>
#include <gst/glib-compat-private.h> #include <gst/glib-compat-private.h>
#include "gstfragmented.h" #include "gstfragmented.h"
@ -67,6 +68,7 @@ gst_m3u8_free (GstM3U8 * self)
g_free (self->uri); g_free (self->uri);
g_free (self->allowcache); g_free (self->allowcache);
g_free (self->codecs); g_free (self->codecs);
g_free (self->key);
g_list_foreach (self->files, (GFunc) gst_m3u8_media_file_free, NULL); g_list_foreach (self->files, (GFunc) gst_m3u8_media_file_free, NULL);
g_list_free (self->files); 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:")) { } else if (g_str_has_prefix (data, "#EXT-X-ALLOW-CACHE:")) {
g_free (self->allowcache); g_free (self->allowcache);
self->allowcache = g_strdup (data + 19); 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:")) { } else if (g_str_has_prefix (data, "#EXTINF:")) {
gdouble fval; gdouble fval;
if (!double_from_string (data + 8, &data, &fval)) { if (!double_from_string (data + 8, &data, &fval)) {

View file

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