summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2015-09-08 15:14:13 +0100
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2015-09-16 09:44:19 +0100
commit69bfa8222f59096f9ab39cc85274c9b0573cb61d (patch)
treee3f72d8b967664488fb12733b4af444f2bac78a8
parent23ea8ccb43b0cca96275545ad5cfc22305d1705d (diff)
downloadgstreamer-plugins-bad-69bfa8222f59096f9ab39cc85274c9b0573cb61d.tar.gz
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
-rw-r--r--ext/dash/gstmpdparser.c34
-rw-r--r--ext/dash/gstmpdparser.h2
2 files changed, 34 insertions, 2 deletions
diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c
index 72992fabc..d34ed5cc2 100644
--- a/ext/dash/gstmpdparser.c
+++ b/ext/dash/gstmpdparser.c
@@ -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 *
@@ -285,6 +287,30 @@ gst_mpdparser_get_xml_prop_string_vector_type (xmlNode * a_node,
}
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 *
diff --git a/ext/dash/gstmpdparser.h b/ext/dash/gstmpdparser.h
index ff380e298..14a239021 100644
--- a/ext/dash/gstmpdparser.h
+++ b/ext/dash/gstmpdparser.h
@@ -138,7 +138,7 @@ struct _GstSNode
{
guint64 t;
guint64 d;
- guint r;
+ gint r;
};
struct _GstSegmentTimelineNode