Commit 69bfa822 authored by Vincent Penquerc'h's avatar Vincent Penquerc'h

mpdparser: properly read signed r values for S elements

The spec defines these as signed in 5.3.9.6.1.
Since we don't support this behavior, warn and default to 0
(non repeating), which is the spec's default when the value
is not present.

https://bugzilla.gnome.org/show_bug.cgi?id=752480
parent 23ea8ccb
......@@ -37,6 +37,8 @@ static gboolean gst_mpdparser_get_xml_prop_string (xmlNode * a_node,
const gchar * property_name, gchar ** property_value);
static gboolean gst_mpdparser_get_xml_prop_string_vector_type (xmlNode * a_node,
const gchar * property_name, gchar *** property_value);
static gboolean gst_mpdparser_get_xml_prop_signed_integer (xmlNode * a_node,
const gchar * property_name, gint default_val, gint * property_value);
static gboolean gst_mpdparser_get_xml_prop_unsigned_integer (xmlNode * a_node,
const gchar * property_name, guint default_val, guint * property_value);
static gboolean gst_mpdparser_get_xml_prop_unsigned_integer_64 (xmlNode *
......@@ -284,6 +286,30 @@ gst_mpdparser_get_xml_prop_string_vector_type (xmlNode * a_node,
return exists;
}
static gboolean
gst_mpdparser_get_xml_prop_signed_integer (xmlNode * a_node,
const gchar * property_name, gint default_val, gint * property_value)
{
xmlChar *prop_string;
gboolean exists = FALSE;
*property_value = default_val;
prop_string = xmlGetProp (a_node, (const xmlChar *) property_name);
if (prop_string) {
if (sscanf ((const gchar *) prop_string, "%d", property_value) == 1) {
exists = TRUE;
GST_LOG (" - %s: %d", property_name, *property_value);
} else {
GST_WARNING
("failed to parse signed integer property %s from xml string %s",
property_name, prop_string);
}
xmlFree (prop_string);
}
return exists;
}
static gboolean
gst_mpdparser_get_xml_prop_unsigned_integer (xmlNode * a_node,
const gchar * property_name, guint default_val, guint * property_value)
......@@ -1287,7 +1313,13 @@ gst_mpdparser_parse_s_node (GQueue * queue, xmlNode * a_node)
&new_s_node->t);
gst_mpdparser_get_xml_prop_unsigned_integer_64 (a_node, "d", 0,
&new_s_node->d);
gst_mpdparser_get_xml_prop_unsigned_integer (a_node, "r", 0, &new_s_node->r);
gst_mpdparser_get_xml_prop_signed_integer (a_node, "r", 0, &new_s_node->r);
/* we don't support negative r values yet (5.3.9.6.1) */
if (new_s_node->r < 0) {
GST_WARNING ("Negative r are unsupported, defaulting to 0");
new_s_node->r = 0; /* single segment */
}
}
static GstSegmentTimelineNode *
......
......@@ -138,7 +138,7 @@ struct _GstSNode
{
guint64 t;
guint64 d;
guint r;
gint r;
};
struct _GstSegmentTimelineNode
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment