From 767a5ebed09983056f9521799338930d1b5a9a0c Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Wed, 24 Oct 2012 18:04:07 +0200 Subject: [PATCH] mpdparser: factorize adding range parameter to URL --- ext/dash/gstmpdparser.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index 672c23c..de9017b 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -76,6 +76,7 @@ static void gst_mpdparser_parse_root_node (GstMpdClient * client, xmlNode *a_nod static gint convert_to_millisecs (gint decimals, gint pos); static int strncmp_ext (const char *s1, const char *s2); static gchar *gst_mpdparser_parse_baseURL (GstMpdClient * client); +static gchar *gst_mpdparser_get_segmentURL_for_range (gchar *url, GstRange *range); static gchar *gst_mpdparser_get_mediaURL (GstSegmentURLNode *segmentURL); static gchar *gst_mpdparser_get_initializationURL (GstURLType *InitializationURL); static gchar *gst_mpdparser_build_URL_from_template (const gchar *url_template, const gchar *id, guint number, guint bandwidth, guint time); @@ -2184,43 +2185,38 @@ gst_mpdparser_free_active_stream (GstActiveStream * active_stream) } static gchar * -gst_mpdparser_get_mediaURL (GstSegmentURLNode *segmentURL) +gst_mpdparser_get_segmentURL_for_range (gchar *url, GstRange *range) { - gchar *mediaURL; - - g_return_val_if_fail (segmentURL != NULL, NULL); - g_return_val_if_fail (segmentURL->media != NULL, NULL); + gchar *segmentURL; - if (segmentURL->mediaRange) { - gchar *range; - range = g_strdup_printf ("?range=%llu-%llu", segmentURL->mediaRange->first_byte_pos, segmentURL->mediaRange->last_byte_pos); - mediaURL = g_strconcat (segmentURL->media, range, NULL); - g_free (range); + if (range) { + gchar *range_suffix; + range_suffix = g_strdup_printf ("?range=%llu-%llu", range->first_byte_pos, range->last_byte_pos); + segmentURL = g_strconcat (url, range_suffix, NULL); + g_free (range_suffix); } else { - mediaURL = g_strdup (segmentURL->media); + segmentURL = g_strdup (url); } - return mediaURL; + return segmentURL; } static gchar * -gst_mpdparser_get_initializationURL (GstURLType *InitializationURL) +gst_mpdparser_get_mediaURL (GstSegmentURLNode *segmentURL) { - gchar *mediaURL; + g_return_val_if_fail (segmentURL != NULL, NULL); + g_return_val_if_fail (segmentURL->media != NULL, NULL); + return gst_mpdparser_get_segmentURL_for_range(segmentURL->media, segmentURL->mediaRange); +} + +static gchar * +gst_mpdparser_get_initializationURL (GstURLType *InitializationURL) +{ g_return_val_if_fail (InitializationURL != NULL, NULL); g_return_val_if_fail (InitializationURL->sourceURL != NULL, NULL); - if (InitializationURL->range) { - gchar *range; - range = g_strdup_printf ("?range=%llu-%llu", InitializationURL->range->first_byte_pos, InitializationURL->range->last_byte_pos); - mediaURL = g_strconcat (InitializationURL->sourceURL, range, NULL); - g_free (range); - } else { - mediaURL = g_strdup (InitializationURL->sourceURL); - } - - return mediaURL; + return gst_mpdparser_get_segmentURL_for_range(InitializationURL->sourceURL, InitializationURL->range); } static gchar * -- 2.7.4