mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 21:48:55 +00:00
dashdemux: Properly parse base uri from mpd.
This commit is contained in:
parent
6ecb58c4f8
commit
b9272dc0e6
2 changed files with 40 additions and 19 deletions
|
@ -110,7 +110,7 @@ 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 GstStreamPeriod *gst_mpdparser_get_stream_period (GstMpdClient * client);
|
static GstStreamPeriod *gst_mpdparser_get_stream_period (GstMpdClient * client);
|
||||||
static gchar *gst_mpdparser_parse_baseURL (GstMpdClient * client,
|
static gchar *gst_mpdparser_parse_baseURL (GstMpdClient * client,
|
||||||
GstActiveStream * stream);
|
GstActiveStream * stream, gchar ** query);
|
||||||
static gchar *gst_mpdparser_get_segmentURL_for_range (gchar * url,
|
static gchar *gst_mpdparser_get_segmentURL_for_range (gchar * url,
|
||||||
GstRange * range);
|
GstRange * range);
|
||||||
static gchar *gst_mpdparser_get_mediaURL (GstActiveStream * stream,
|
static gchar *gst_mpdparser_get_mediaURL (GstActiveStream * stream,
|
||||||
|
@ -1850,14 +1850,14 @@ gst_mpdparser_get_segment_base (GstPeriodNode * Period,
|
||||||
if (Representation && Representation->SegmentList
|
if (Representation && Representation->SegmentList
|
||||||
&& Representation->SegmentList->MultSegBaseType
|
&& Representation->SegmentList->MultSegBaseType
|
||||||
&& Representation->SegmentList->MultSegBaseType->SegBaseType
|
&& Representation->SegmentList->MultSegBaseType->SegBaseType
|
||||||
&& Representation->SegmentList->MultSegBaseType->
|
&& Representation->SegmentList->MultSegBaseType->SegBaseType->
|
||||||
SegBaseType->Initialization) {
|
Initialization) {
|
||||||
SegmentBase = Representation->SegmentList->MultSegBaseType->SegBaseType;
|
SegmentBase = Representation->SegmentList->MultSegBaseType->SegBaseType;
|
||||||
} else if (AdaptationSet && AdaptationSet->SegmentList
|
} else if (AdaptationSet && AdaptationSet->SegmentList
|
||||||
&& AdaptationSet->SegmentList->MultSegBaseType
|
&& AdaptationSet->SegmentList->MultSegBaseType
|
||||||
&& AdaptationSet->SegmentList->MultSegBaseType->SegBaseType
|
&& AdaptationSet->SegmentList->MultSegBaseType->SegBaseType
|
||||||
&& AdaptationSet->SegmentList->MultSegBaseType->
|
&& AdaptationSet->SegmentList->MultSegBaseType->SegBaseType->
|
||||||
SegBaseType->Initialization) {
|
Initialization) {
|
||||||
SegmentBase = AdaptationSet->SegmentList->MultSegBaseType->SegBaseType;
|
SegmentBase = AdaptationSet->SegmentList->MultSegBaseType->SegBaseType;
|
||||||
} else if (Period && Period->SegmentList
|
} else if (Period && Period->SegmentList
|
||||||
&& Period->SegmentList->MultSegBaseType
|
&& Period->SegmentList->MultSegBaseType
|
||||||
|
@ -2298,6 +2298,10 @@ static void
|
||||||
gst_mpdparser_free_active_stream (GstActiveStream * active_stream)
|
gst_mpdparser_free_active_stream (GstActiveStream * active_stream)
|
||||||
{
|
{
|
||||||
if (active_stream) {
|
if (active_stream) {
|
||||||
|
g_free (active_stream->baseURL);
|
||||||
|
active_stream->baseURL = NULL;
|
||||||
|
g_free (active_stream->queryURL);
|
||||||
|
active_stream->queryURL = NULL;
|
||||||
g_list_foreach (active_stream->segments,
|
g_list_foreach (active_stream->segments,
|
||||||
(GFunc) gst_mpdparser_free_media_segment, NULL);
|
(GFunc) gst_mpdparser_free_media_segment, NULL);
|
||||||
g_list_free (active_stream->segments);
|
g_list_free (active_stream->segments);
|
||||||
|
@ -2424,7 +2428,8 @@ gst_mpdparser_get_stream_period (GstMpdClient * client)
|
||||||
|
|
||||||
/* select a stream and extract the baseURL (if present) */
|
/* select a stream and extract the baseURL (if present) */
|
||||||
static gchar *
|
static gchar *
|
||||||
gst_mpdparser_parse_baseURL (GstMpdClient * client, GstActiveStream * stream)
|
gst_mpdparser_parse_baseURL (GstMpdClient * client, GstActiveStream * stream,
|
||||||
|
gchar ** query)
|
||||||
{
|
{
|
||||||
//GstActiveStream *stream;
|
//GstActiveStream *stream;
|
||||||
GstStreamPeriod *stream_period;
|
GstStreamPeriod *stream_period;
|
||||||
|
@ -2484,19 +2489,32 @@ gst_mpdparser_parse_baseURL (GstMpdClient * client, GstActiveStream * stream)
|
||||||
/* get base URI from MPD file URI, if the "http" scheme is missing */
|
/* get base URI from MPD file URI, if the "http" scheme is missing */
|
||||||
if (client->mpd_uri != NULL && strncmp (ret, "http://", 7) != 0) {
|
if (client->mpd_uri != NULL && strncmp (ret, "http://", 7) != 0) {
|
||||||
gchar *last_sep, *tmp1, *tmp2;
|
gchar *last_sep, *tmp1, *tmp2;
|
||||||
|
|
||||||
|
if (ret[0] == '?') {
|
||||||
|
if (query)
|
||||||
|
*query = g_strdup (ret);
|
||||||
|
g_free (ret);
|
||||||
|
ret = NULL;
|
||||||
|
} else {
|
||||||
|
if (query)
|
||||||
|
*query = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
last_sep = strrchr (client->mpd_uri, '/');
|
last_sep = strrchr (client->mpd_uri, '/');
|
||||||
if (last_sep) {
|
if (last_sep) {
|
||||||
tmp1 = g_strndup (client->mpd_uri, last_sep - client->mpd_uri + 1);
|
tmp1 = g_strndup (client->mpd_uri, last_sep - client->mpd_uri + 1);
|
||||||
|
if (ret) {
|
||||||
tmp2 = ret;
|
tmp2 = ret;
|
||||||
GST_DEBUG ("Got base URI from MPD file URI %s", tmp1);
|
|
||||||
ret = g_strconcat (tmp1, tmp2, NULL);
|
ret = g_strconcat (tmp1, tmp2, NULL);
|
||||||
g_free (tmp1);
|
g_free (tmp1);
|
||||||
g_free (tmp2);
|
g_free (tmp2);
|
||||||
|
} else {
|
||||||
|
ret = tmp1;
|
||||||
|
}
|
||||||
|
GST_WARNING ("Got base URI from MPD file URI %s", ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG ("selected baseURL with index %d: %s", stream->baseURL_idx, ret);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2897,7 +2915,9 @@ gst_mpd_client_setup_representation (GstMpdClient * client,
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (stream->baseURL);
|
g_free (stream->baseURL);
|
||||||
stream->baseURL = gst_mpdparser_parse_baseURL (client, stream);
|
g_free (stream->queryURL);
|
||||||
|
stream->baseURL =
|
||||||
|
gst_mpdparser_parse_baseURL (client, stream, &stream->queryURL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -3202,11 +3222,11 @@ gst_mpd_client_get_next_fragment (GstMpdClient * client,
|
||||||
/* single segment with URL encoded in the baseURL syntax element */
|
/* single segment with URL encoded in the baseURL syntax element */
|
||||||
*uri = g_strdup (stream->baseURL);
|
*uri = g_strdup (stream->baseURL);
|
||||||
} else if (strncmp (mediaURL, "http://", 7) != 0) {
|
} else if (strncmp (mediaURL, "http://", 7) != 0) {
|
||||||
*uri = g_strconcat (stream->baseURL, mediaURL, NULL);
|
*uri = g_strconcat (stream->baseURL, mediaURL, stream->queryURL, NULL);
|
||||||
g_free (mediaURL);
|
|
||||||
} else {
|
} else {
|
||||||
*uri = mediaURL;
|
*uri = g_strconcat (mediaURL, stream->queryURL, NULL);
|
||||||
}
|
}
|
||||||
|
g_free (mediaURL);
|
||||||
gst_mpd_client_set_segment_index (stream, segment_idx + 1);
|
gst_mpd_client_set_segment_index (stream, segment_idx + 1);
|
||||||
GST_MPD_CLIENT_UNLOCK (client);
|
GST_MPD_CLIENT_UNLOCK (client);
|
||||||
|
|
||||||
|
@ -3234,8 +3254,8 @@ gst_mpd_client_get_next_header (GstMpdClient * client, const gchar ** uri,
|
||||||
*uri = NULL;
|
*uri = NULL;
|
||||||
if (stream->cur_segment_base && stream->cur_segment_base->Initialization) {
|
if (stream->cur_segment_base && stream->cur_segment_base->Initialization) {
|
||||||
*uri =
|
*uri =
|
||||||
gst_mpdparser_get_initializationURL (stream->
|
gst_mpdparser_get_initializationURL (stream->cur_segment_base->
|
||||||
cur_segment_base->Initialization);
|
Initialization);
|
||||||
} else if (stream->cur_seg_template) {
|
} else if (stream->cur_seg_template) {
|
||||||
const gchar *initialization = NULL;
|
const gchar *initialization = NULL;
|
||||||
if (stream->cur_seg_template->initialization) {
|
if (stream->cur_seg_template->initialization) {
|
||||||
|
|
|
@ -428,6 +428,7 @@ struct _GstActiveStream
|
||||||
|
|
||||||
guint baseURL_idx; /* index of the baseURL used for last request */
|
guint baseURL_idx; /* index of the baseURL used for last request */
|
||||||
gchar *baseURL; /* active baseURL used for last request */
|
gchar *baseURL; /* active baseURL used for last request */
|
||||||
|
gchar *queryURL; /* active baseURL used for last request */
|
||||||
guint max_bandwidth; /* max bandwidth allowed for this mimeType */
|
guint max_bandwidth; /* max bandwidth allowed for this mimeType */
|
||||||
|
|
||||||
GstAdaptationSetNode *cur_adapt_set; /* active adaptation set */
|
GstAdaptationSetNode *cur_adapt_set; /* active adaptation set */
|
||||||
|
|
Loading…
Reference in a new issue