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
This commit is contained in:
Vincent Penquerc'h 2015-09-08 15:14:13 +01:00
parent 23ea8ccb43
commit 69bfa8222f
2 changed files with 34 additions and 2 deletions

View file

@ -37,6 +37,8 @@ static gboolean gst_mpdparser_get_xml_prop_string (xmlNode * a_node,
const gchar * property_name, gchar ** property_value); const gchar * property_name, gchar ** property_value);
static gboolean gst_mpdparser_get_xml_prop_string_vector_type (xmlNode * a_node, static gboolean gst_mpdparser_get_xml_prop_string_vector_type (xmlNode * a_node,
const gchar * property_name, gchar *** property_value); 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, static gboolean gst_mpdparser_get_xml_prop_unsigned_integer (xmlNode * a_node,
const gchar * property_name, guint default_val, guint * property_value); const gchar * property_name, guint default_val, guint * property_value);
static gboolean gst_mpdparser_get_xml_prop_unsigned_integer_64 (xmlNode * 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; 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 static gboolean
gst_mpdparser_get_xml_prop_unsigned_integer (xmlNode * a_node, gst_mpdparser_get_xml_prop_unsigned_integer (xmlNode * a_node,
const gchar * property_name, guint default_val, guint * property_value) 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); &new_s_node->t);
gst_mpdparser_get_xml_prop_unsigned_integer_64 (a_node, "d", 0, gst_mpdparser_get_xml_prop_unsigned_integer_64 (a_node, "d", 0,
&new_s_node->d); &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 * static GstSegmentTimelineNode *

View file

@ -138,7 +138,7 @@ struct _GstSNode
{ {
guint64 t; guint64 t;
guint64 d; guint64 d;
guint r; gint r;
}; };
struct _GstSegmentTimelineNode struct _GstSegmentTimelineNode