hlsdemux: Improve parsing quoted key URIs and apply it for I-frame-based stream URI

https://bugzilla.gnome.org/show_bug.cgi?id=730830
This commit is contained in:
Damian Ziobro 2014-06-04 18:34:44 +01:00 committed by Sebastian Dröge
parent 37ffe063f6
commit be28578942

View file

@ -322,6 +322,28 @@ parse_attributes (gchar ** ptr, gchar ** a, gchar ** v)
return TRUE; return TRUE;
} }
static gchar *
unquote_string (gchar * string)
{
gchar *string_ret;
string_ret = strchr (string, '"');
if (string_ret != NULL) {
/* found initialization quotation mark of string */
string = string_ret + 1;
string_ret = strchr (string, '"');
if (string_ret != NULL) {
/* found finalizing quotation mark of string */
string_ret[0] = '\0';
} else {
GST_WARNING
("wrong string unqouting - cannot find finalizing quotation mark");
return NULL;
}
}
return string;
}
static gint static gint
_m3u8_compare_uri (GstM3U8 * a, gchar * uri) _m3u8_compare_uri (GstM3U8 * a, gchar * uri)
{ {
@ -507,23 +529,24 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated)
gchar *name; gchar *name;
gchar *uri = g_strdup (v); gchar *uri = g_strdup (v);
gchar *urip = uri; gchar *urip = uri;
int len = strlen (uri);
/* handle the \"uri\" case */ uri = unquote_string (uri);
if (uri[len - 1] == '"') if (uri) {
uri[len - 1] = '\0'; uri = uri_join (self->base_uri ? self->base_uri : self->uri, uri);
if (uri[0] == '"')
uri += 1;
name = g_strdup (uri); uri = uri_join (self->base_uri ? self->base_uri : self->uri, uri);
uri = uri_join (self->base_uri ? self->base_uri : self->uri, uri); if (uri == NULL) {
g_free (urip); g_free (urip);
continue;
}
name = g_strdup (uri);
if (uri == NULL) { gst_m3u8_set_uri (new_list, uri, NULL, name);
g_free (name); } else {
continue; GST_WARNING
("Cannot remove quotation marks from i-frame-stream URI");
} }
gst_m3u8_set_uri (new_list, uri, NULL, name); g_free (urip);
} }
} }
@ -567,28 +590,15 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated)
if (g_str_equal (a, "URI")) { if (g_str_equal (a, "URI")) {
gchar *key = g_strdup (v); gchar *key = g_strdup (v);
gchar *keyp = key; gchar *keyp = key;
gchar *key_ret;
/* handle the \"key\" case * key = unquote_string (key);
* there are sometimes situations where we have white signs if (key) {
* before or after \" sign of URL therefore we are using for loops current_key =
* in order to remove first and last \" sign from decryption key URI */ uri_join (self->base_uri ? self->base_uri : self->uri, key);
key_ret = strchr (key, '"'); } else {
if (key_ret != NULL) { GST_WARNING
/* found initialization quotation mark key URI */ ("Cannot remove quotation marks from decryption key URI");
key = key_ret + 1;
key_ret = strchr (key, '"');
if (key_ret != NULL) {
/* found finalizing quotation mark inside key URI */
key_ret[0] = '\0';
} else {
GST_WARNING
("Decryption key URL parsing - cannot find finalizing quotation mark");
}
} }
current_key =
uri_join (self->base_uri ? self->base_uri : self->uri, key);
g_free (keyp); g_free (keyp);
} else if (g_str_equal (a, "IV")) { } else if (g_str_equal (a, "IV")) {
gchar *ivp = v; gchar *ivp = v;