diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index 672c23cf12..de9017be65 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); @@ -2183,44 +2184,39 @@ gst_mpdparser_free_active_stream (GstActiveStream * active_stream) } } +static gchar * +gst_mpdparser_get_segmentURL_for_range (gchar *url, GstRange *range) +{ + gchar *segmentURL; + + 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 { + segmentURL = g_strdup (url); + } + + return segmentURL; +} + static gchar * 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); - 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); - } else { - mediaURL = g_strdup (segmentURL->media); - } - - return mediaURL; + return gst_mpdparser_get_segmentURL_for_range(segmentURL->media, segmentURL->mediaRange); } static gchar * gst_mpdparser_get_initializationURL (GstURLType *InitializationURL) { - gchar *mediaURL; - 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 *