mpdparser: factorize adding range parameter to URL

This commit is contained in:
Olivier Blin 2012-10-24 18:04:07 +02:00 committed by Thiago Santos
parent 53f383eff0
commit 767a5ebed0

View file

@ -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 gint convert_to_millisecs (gint decimals, gint pos);
static int strncmp_ext (const char *s1, const char *s2); static int strncmp_ext (const char *s1, const char *s2);
static gchar *gst_mpdparser_parse_baseURL (GstMpdClient * client); 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_mediaURL (GstSegmentURLNode *segmentURL);
static gchar *gst_mpdparser_get_initializationURL (GstURLType *InitializationURL); 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); 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 * static gchar *
gst_mpdparser_get_mediaURL (GstSegmentURLNode *segmentURL) gst_mpdparser_get_mediaURL (GstSegmentURLNode *segmentURL)
{ {
gchar *mediaURL;
g_return_val_if_fail (segmentURL != NULL, NULL); g_return_val_if_fail (segmentURL != NULL, NULL);
g_return_val_if_fail (segmentURL->media != NULL, NULL); g_return_val_if_fail (segmentURL->media != NULL, NULL);
if (segmentURL->mediaRange) { return gst_mpdparser_get_segmentURL_for_range(segmentURL->media, 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;
} }
static gchar * static gchar *
gst_mpdparser_get_initializationURL (GstURLType *InitializationURL) gst_mpdparser_get_initializationURL (GstURLType *InitializationURL)
{ {
gchar *mediaURL;
g_return_val_if_fail (InitializationURL != NULL, NULL); g_return_val_if_fail (InitializationURL != NULL, NULL);
g_return_val_if_fail (InitializationURL->sourceURL != NULL, NULL); g_return_val_if_fail (InitializationURL->sourceURL != NULL, NULL);
if (InitializationURL->range) { return gst_mpdparser_get_segmentURL_for_range(InitializationURL->sourceURL, 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;
} }
static gchar * static gchar *