static gboolean gst_mpdparser_get_xml_prop_dateTime (xmlNode * a_node,
const gchar * property_name, GstDateTime ** property_value);
static gboolean gst_mpdparser_get_xml_prop_duration (xmlNode * a_node,
- const gchar * property_name, gint64 default_value, gint64 * property_value);
+ const gchar * property_name, guint64 default_value,
+ guint64 * property_value);
static gboolean gst_mpdparser_get_xml_node_content (xmlNode * a_node,
gchar ** content);
static gchar *gst_mpdparser_get_xml_node_namespace (xmlNode * a_node,
xmlNode * a_node);
/* Helper functions */
-static gint convert_to_millisecs (gint decimals, gint pos);
+static guint convert_to_millisecs (guint decimals, gint pos);
static int strncmp_ext (const char *s1, const char *s2);
static GstStreamPeriod *gst_mpdparser_get_stream_period (GstMpdClient * client);
static GstSNode *gst_mpdparser_clone_s_node (GstSNode * pointer);
static gchar *gst_mpdparser_build_URL_from_template (const gchar * url_template,
const gchar * id, guint number, guint bandwidth, guint64 time);
static gboolean gst_mpd_client_add_media_segment (GstActiveStream * stream,
- GstSegmentURLNode * url_node, guint number, gint repeat, gint64 scale_start,
- gint64 scale_duration, GstClockTime start, GstClockTime duration);
+ GstSegmentURLNode * url_node, guint number, gint repeat,
+ guint64 scale_start, guint64 scale_duration, GstClockTime start,
+ GstClockTime duration);
static const gchar *gst_mpdparser_mimetype_to_caps (const gchar * mimeType);
static GstClockTime gst_mpd_client_get_segment_duration (GstMpdClient * client,
- GstActiveStream * stream, gint64 * scale_duration);
+ GstActiveStream * stream, guint64 * scale_duration);
static GstDateTime *gst_mpd_client_get_availability_start_time (GstMpdClient *
client);
*/
/* this function computes decimals * 10 ^ (3 - pos) */
-static gint
-convert_to_millisecs (gint decimals, gint pos)
+static guint
+convert_to_millisecs (guint decimals, gint pos)
{
- gint num = 1, den = 1, i = 3 - pos;
+ guint num = 1, den = 1;
+ gint i = 3 - pos;
while (i < 0) {
den *= 10;
}
static gboolean
-gst_mpdparser_get_xml_prop_duration_inner (xmlNode * a_node,
- const gchar * property_name, gint64 default_value, gint64 * property_value,
- gboolean allow_negative)
+gst_mpdparser_get_xml_prop_duration (xmlNode * a_node,
+ const gchar * property_name, guint64 default_value,
+ guint64 * property_value)
{
xmlChar *prop_string;
gchar *str;
- gint ret, read, len, pos, posT;
- gint years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds =
- 0, decimals = 0;
- gint sign = 1;
+ gint ret, len, pos, posT;
+ guint years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds =
+ 0, decimals = 0, read;
gboolean have_ms = FALSE;
gboolean exists = FALSE;
len = xmlStrlen (prop_string);
str = (gchar *) prop_string;
GST_TRACE ("duration: %s, len %d", str, len);
- /* read "-" for sign, if present */
- pos = strcspn (str, "-");
- if (pos < len) { /* found "-" */
- if (pos != 0) {
- GST_WARNING ("sign \"-\" non at the beginning of the string");
- goto error;
- }
- GST_TRACE ("found - sign at the beginning");
- if (!allow_negative) {
- GST_WARNING ("sign \"-\" not allowed for property '%s'", property_name);
- goto error;
- }
- sign = -1;
- str++;
- len--;
- /* look for another "-" sign */
- if (strcspn (str, "-") != len) {
- GST_WARNING ("found a second \"-\" sign");
- goto error;
- }
+ if (strchr (str, '-') != NULL) {
+ GST_WARNING ("'-' sign found while parsing unsigned duration");
+ goto error;
}
/* read "P" for period */
pos = strcspn (str, "P");
do {
GST_TRACE ("parsing substring %s", str);
pos = strcspn (str, "YMD");
- ret = sscanf (str, "%d", &read);
+ ret = sscanf (str, "%u", &read);
if (ret != 1) {
GST_WARNING ("can not read integer value from string %s!", str);
goto error;
goto error;
break;
}
- GST_TRACE ("read number %d type %c", read, str[pos]);
+ GST_TRACE ("read number %u type %c", read, str[pos]);
str += (pos + 1);
posT -= (pos + 1);
} while (posT > 0);
- GST_TRACE ("Y:M:D=%d:%d:%d", years, months, days);
+ GST_TRACE ("Y:M:D=%u:%u:%u", years, months, days);
}
/* read "T" for time (if present) */
/* here T is at pos == 0 */
do {
GST_TRACE ("parsing substring %s", str);
pos = strcspn (str, "HMS,.");
- ret = sscanf (str, "%d", &read);
+ ret = sscanf (str, "%u", &read);
if (ret != 1) {
GST_WARNING ("can not read integer value from string %s!", str);
goto error;
if (have_ms) {
/* we have read the decimal part of the seconds */
decimals = convert_to_millisecs (read, pos);
- GST_TRACE ("decimal number %d (%d digits) -> %d ms", read, pos,
+ GST_TRACE ("decimal number %u (%d digits) -> %d ms", read, pos,
decimals);
} else {
/* no decimals */
goto error;
break;
}
- GST_TRACE ("read number %d type %c", read, str[pos]);
+ GST_TRACE ("read number %u type %c", read, str[pos]);
str += pos + 1;
len -= (pos + 1);
} while (len > 0);
- GST_TRACE ("H:M:S.MS=%d:%d:%d.%03d", hours, minutes, seconds, decimals);
+ GST_TRACE ("H:M:S.MS=%u:%u:%u.%03u", hours, minutes, seconds, decimals);
}
xmlFree (prop_string);
exists = TRUE;
*property_value =
- sign * ((((((gint64) years * 365 + months * 30 + days) * 24 +
- hours) * 60 + minutes) * 60 + seconds) * 1000 + decimals);
- GST_LOG (" - %s: %" G_GINT64_FORMAT, property_name, *property_value);
+ (((((guint64) years * 365 + months * 30 + days) * 24 +
+ hours) * 60 + minutes) * 60 + seconds) * 1000 + decimals;
+ GST_LOG (" - %s: %" G_GUINT64_FORMAT, property_name, *property_value);
}
return exists;
}
static gboolean
-gst_mpdparser_get_xml_prop_duration (xmlNode * a_node,
- const gchar * property_name, gint64 default_value, gint64 * property_value)
-{
- return gst_mpdparser_get_xml_prop_duration_inner (a_node, property_name,
- default_value, property_value, TRUE);
-}
-
-static gboolean
-gst_mpdparser_get_xml_prop_duration_unsigned (xmlNode * a_node,
- const gchar * property_name, gint64 default_value, gint64 * property_value)
-{
- return gst_mpdparser_get_xml_prop_duration_inner (a_node, property_name,
- default_value, property_value, FALSE);
-}
-
-static gboolean
gst_mpdparser_get_xml_node_content (xmlNode * a_node, gchar ** content)
{
xmlChar *node_content = NULL;
}
gst_mpdparser_get_xml_prop_string (a_node, "id", &new_period->id);
- gst_mpdparser_get_xml_prop_duration (a_node, "start", -1, &new_period->start);
- gst_mpdparser_get_xml_prop_duration (a_node, "duration", -1,
- &new_period->duration);
- gst_mpdparser_get_xml_prop_boolean (a_node, "bitstreamSwitching",
- FALSE, &new_period->bitstreamSwitching);
+ gst_mpdparser_get_xml_prop_duration (a_node, "start", GST_MPD_DURATION_NONE,
+ &new_period->start);
+ gst_mpdparser_get_xml_prop_duration (a_node, "duration",
+ GST_MPD_DURATION_NONE, &new_period->duration);
+ gst_mpdparser_get_xml_prop_boolean (a_node, "bitstreamSwitching", FALSE,
+ &new_period->bitstreamSwitching);
/* explore children nodes */
for (cur_node = a_node->children; cur_node; cur_node = cur_node->next) {
*list = g_list_append (*list, new_metrics_range);
GST_LOG ("attributes of Metrics Range node:");
- gst_mpdparser_get_xml_prop_duration (a_node, "starttime", -1,
- &new_metrics_range->starttime);
- gst_mpdparser_get_xml_prop_duration (a_node, "duration", -1,
- &new_metrics_range->duration);
+ gst_mpdparser_get_xml_prop_duration (a_node, "starttime",
+ GST_MPD_DURATION_NONE, &new_metrics_range->starttime);
+ gst_mpdparser_get_xml_prop_duration (a_node, "duration",
+ GST_MPD_DURATION_NONE, &new_metrics_range->duration);
}
static void
&new_mpd->availabilityStartTime);
gst_mpdparser_get_xml_prop_dateTime (a_node, "availabilityEndTime",
&new_mpd->availabilityEndTime);
- gst_mpdparser_get_xml_prop_duration (a_node, "mediaPresentationDuration", -1,
- &new_mpd->mediaPresentationDuration);
- gst_mpdparser_get_xml_prop_duration (a_node, "minimumUpdatePeriod", -1,
- &new_mpd->minimumUpdatePeriod);
- gst_mpdparser_get_xml_prop_duration (a_node, "minBufferTime", -1,
- &new_mpd->minBufferTime);
- gst_mpdparser_get_xml_prop_duration (a_node, "timeShiftBufferDepth", -1,
- &new_mpd->timeShiftBufferDepth);
- gst_mpdparser_get_xml_prop_duration_unsigned (a_node,
- "suggestedPresentationDelay", -1, &new_mpd->suggestedPresentationDelay);
- gst_mpdparser_get_xml_prop_duration (a_node, "maxSegmentDuration", -1,
- &new_mpd->maxSegmentDuration);
- gst_mpdparser_get_xml_prop_duration (a_node, "maxSubsegmentDuration", -1,
- &new_mpd->maxSubsegmentDuration);
+ gst_mpdparser_get_xml_prop_duration (a_node, "mediaPresentationDuration",
+ GST_MPD_DURATION_NONE, &new_mpd->mediaPresentationDuration);
+ gst_mpdparser_get_xml_prop_duration (a_node, "minimumUpdatePeriod",
+ GST_MPD_DURATION_NONE, &new_mpd->minimumUpdatePeriod);
+ gst_mpdparser_get_xml_prop_duration (a_node, "minBufferTime",
+ GST_MPD_DURATION_NONE, &new_mpd->minBufferTime);
+ gst_mpdparser_get_xml_prop_duration (a_node, "timeShiftBufferDepth",
+ GST_MPD_DURATION_NONE, &new_mpd->timeShiftBufferDepth);
+ gst_mpdparser_get_xml_prop_duration (a_node, "suggestedPresentationDelay",
+ GST_MPD_DURATION_NONE, &new_mpd->suggestedPresentationDelay);
+ gst_mpdparser_get_xml_prop_duration (a_node, "maxSegmentDuration",
+ GST_MPD_DURATION_NONE, &new_mpd->maxSegmentDuration);
+ gst_mpdparser_get_xml_prop_duration (a_node, "maxSubsegmentDuration",
+ GST_MPD_DURATION_NONE, &new_mpd->maxSubsegmentDuration);
/* explore children Period nodes */
for (cur_node = a_node->children; cur_node; cur_node = cur_node->next) {
static GstClockTime
gst_mpd_client_get_segment_duration (GstMpdClient * client,
- GstActiveStream * stream, gint64 * scale_dur)
+ GstActiveStream * stream, guint64 * scale_dur)
{
GstStreamPeriod *stream_period;
GstMultSegmentBaseType *base = NULL;
} else {
GstClockTime duration;
GstStreamPeriod *stream_period;
- gint64 scale_dur;
+ guint64 scale_dur;
g_return_val_if_fail (stream->cur_seg_template->MultSegBaseType->
SegmentTimeline == NULL, FALSE);
static gboolean
gst_mpd_client_add_media_segment (GstActiveStream * stream,
GstSegmentURLNode * url_node, guint number, gint repeat,
- gint64 scale_start, gint64 scale_duration,
+ guint64 scale_start, guint64 scale_duration,
GstClockTime start, GstClockTime duration)
{
GstMediaSegment *media_segment;
SegmentURL = g_list_next (SegmentURL);
}
} else {
- gint64 scale_dur;
+ guint64 scale_dur;
duration =
gst_mpd_client_get_segment_duration (client, stream, &scale_dur);
assert_equals_int (gst_date_time_get_minute (availabilityEndTime), 10);
assert_equals_int (gst_date_time_get_second (availabilityEndTime), 50);
- assert_equals_int64 (mpdclient->mpd_node->mediaPresentationDuration,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 500));
+ assert_equals_uint64 (mpdclient->mpd_node->mediaPresentationDuration,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 500));
- assert_equals_int64 (mpdclient->mpd_node->minimumUpdatePeriod,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 500));
+ assert_equals_uint64 (mpdclient->mpd_node->minimumUpdatePeriod,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 500));
- assert_equals_int64 (mpdclient->mpd_node->minBufferTime,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 500));
+ assert_equals_uint64 (mpdclient->mpd_node->minBufferTime,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 500));
- assert_equals_int64 (mpdclient->mpd_node->timeShiftBufferDepth,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 500));
+ assert_equals_uint64 (mpdclient->mpd_node->timeShiftBufferDepth,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 500));
- assert_equals_int64 (mpdclient->mpd_node->suggestedPresentationDelay,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 500));
+ assert_equals_uint64 (mpdclient->mpd_node->suggestedPresentationDelay,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 500));
- assert_equals_int64 (mpdclient->mpd_node->maxSegmentDuration,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 500));
+ assert_equals_uint64 (mpdclient->mpd_node->maxSegmentDuration,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 500));
- assert_equals_int64 (mpdclient->mpd_node->maxSubsegmentDuration,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 500));
+ assert_equals_uint64 (mpdclient->mpd_node->maxSubsegmentDuration,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 500));
gst_mpd_client_free (mpdclient);
}
metricsNode = (GstMetricsNode *) mpdclient->mpd_node->Metrics->data;
assert_equals_pointer (metricsNode->metrics, NULL);
metricsRangeNode = (GstMetricsRangeNode *) metricsNode->MetricsRanges->data;
- assert_equals_int64 (metricsRangeNode->starttime,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 500));
- assert_equals_int64 (metricsRangeNode->duration,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 123));
+ assert_equals_uint64 (metricsRangeNode->starttime,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 500));
+ assert_equals_uint64 (metricsRangeNode->duration,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 123));
gst_mpd_client_free (mpdclient);
}
periodNode = (GstPeriodNode *) mpdclient->mpd_node->Periods->data;
assert_equals_string (periodNode->id, "TestId");
- assert_equals_int64 (periodNode->start,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 123));
- assert_equals_int64 (periodNode->duration,
- (gint64) duration_to_ms (0, 1, 2, 12, 10, 20, 765));
+ assert_equals_uint64 (periodNode->start,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 123));
+ assert_equals_uint64 (periodNode->duration,
+ duration_to_ms (0, 1, 2, 12, 10, 20, 765));
assert_equals_int (periodNode->bitstreamSwitching, 1);
gst_mpd_client_free (mpdclient);
periodNode =
(GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 0);
assert_equals_string (periodNode->id, "Period0");
- assert_equals_int64 (periodNode->start,
- (gint64) duration_to_ms (0, 0, 0, 0, 0, 1, 0));
+ assert_equals_uint64 (periodNode->start,
+ duration_to_ms (0, 0, 0, 0, 0, 1, 0));
periodNode =
(GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 1);
assert_equals_string (periodNode->id, "Period1");
- assert_equals_int64 (periodNode->start,
- (gint64) duration_to_ms (0, 0, 0, 0, 0, 1, 500));
+ assert_equals_uint64 (periodNode->start,
+ duration_to_ms (0, 0, 0, 0, 0, 1, 500));
periodNode =
(GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 2);
assert_equals_string (periodNode->id, "Period2");
- assert_equals_int64 (periodNode->start,
- (gint64) duration_to_ms (0, 0, 0, 0, 0, 1, 700));
+ assert_equals_uint64 (periodNode->start,
+ duration_to_ms (0, 0, 0, 0, 0, 1, 700));
periodNode =
(GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 3);
assert_equals_string (periodNode->id, "Period3");
- assert_equals_int64 (periodNode->start,
- (gint64) duration_to_ms (0, 0, 0, 0, 1, 0, 0));
+ assert_equals_uint64 (periodNode->start,
+ duration_to_ms (0, 0, 0, 0, 1, 0, 0));
periodNode =
(GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 4);
assert_equals_string (periodNode->id, "Period4");
- assert_equals_int64 (periodNode->start,
- (gint64) duration_to_ms (0, 0, 0, 1, 0, 0, 0));
+ assert_equals_uint64 (periodNode->start,
+ duration_to_ms (0, 0, 0, 1, 0, 0, 0));
periodNode =
(GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 5);
assert_equals_string (periodNode->id, "Period5");
- assert_equals_int64 (periodNode->start,
- (gint64) duration_to_ms (0, 0, 1, 0, 0, 0, 0));
+ assert_equals_uint64 (periodNode->start,
+ duration_to_ms (0, 0, 1, 0, 0, 0, 0));
periodNode =
(GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 6);
assert_equals_string (periodNode->id, "Period6");
- assert_equals_int64 (periodNode->start,
- (gint64) duration_to_ms (0, 1, 0, 0, 0, 0, 0));
+ assert_equals_uint64 (periodNode->start,
+ duration_to_ms (0, 1, 0, 0, 0, 0, 0));
periodNode =
(GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 7);
assert_equals_string (periodNode->id, "Period7");
- assert_equals_int64 (periodNode->start,
- (gint64) duration_to_ms (1, 0, 0, 0, 0, 0, 0));
+ assert_equals_uint64 (periodNode->start,
+ duration_to_ms (1, 0, 0, 0, 0, 0, 0));
gst_mpd_client_free (mpdclient);
}