mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-20 22:28:22 +00:00
dashdemux: Always use the redirect target to resolve relative URIs
But redownload the playlists from the original URI if it's not a permanent redirect.
This commit is contained in:
parent
9cb3d745db
commit
ae679506b1
3 changed files with 37 additions and 11 deletions
|
@ -787,9 +787,24 @@ gst_dash_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||
query = gst_query_new_uri ();
|
||||
query_res = gst_pad_peer_query (pad, query);
|
||||
if (query_res) {
|
||||
gst_query_parse_uri (query, &demux->client->mpd_uri);
|
||||
GST_DEBUG_OBJECT (demux, "Fetched MPD file at URI: %s",
|
||||
demux->client->mpd_uri);
|
||||
gchar *uri, *redirect_uri;
|
||||
gboolean permanent;
|
||||
|
||||
gst_query_parse_uri (query, &uri);
|
||||
gst_query_parse_uri_redirection (query, &redirect_uri);
|
||||
gst_query_parse_uri_redirection_permanent (query, &permanent);
|
||||
|
||||
if (permanent && redirect_uri) {
|
||||
demux->client->mpd_uri = redirect_uri;
|
||||
demux->client->mpd_base_uri = NULL;
|
||||
g_free (uri);
|
||||
} else {
|
||||
demux->client->mpd_uri = uri;
|
||||
demux->client->mpd_base_uri = redirect_uri;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (demux, "Fetched MPD file at URI: %s (base: %s)",
|
||||
demux->client->mpd_uri, GST_STR_NULL (demux->client->mpd_base_uri));
|
||||
} else {
|
||||
GST_WARNING_OBJECT (demux, "MPD URI query failed.");
|
||||
}
|
||||
|
@ -1282,7 +1297,14 @@ gst_dash_demux_refresh_mpd (GstDashDemux * demux)
|
|||
GstMapInfo mapinfo;
|
||||
|
||||
new_client = gst_mpd_client_new ();
|
||||
new_client->mpd_uri = g_strdup (demux->client->mpd_uri);
|
||||
|
||||
if (download->redirect_permanent && download->redirect_uri) {
|
||||
new_client->mpd_uri = g_strdup (download->redirect_uri);
|
||||
new_client->mpd_base_uri = NULL;
|
||||
} else {
|
||||
new_client->mpd_uri = g_strdup (download->uri);
|
||||
new_client->mpd_base_uri = g_strdup (download->redirect_uri);
|
||||
}
|
||||
|
||||
gst_buffer_map (buffer, &mapinfo, GST_MAP_READ);
|
||||
|
||||
|
|
|
@ -2653,6 +2653,7 @@ gst_mpdparser_parse_baseURL (GstMpdClient * client, GstActiveStream * stream,
|
|||
{
|
||||
GstStreamPeriod *stream_period;
|
||||
GstBaseURL *baseURL;
|
||||
gchar *mpd_uri;
|
||||
GList *list;
|
||||
static gchar *baseURL_array[5];
|
||||
static gchar empty[] = "";
|
||||
|
@ -2704,7 +2705,8 @@ gst_mpdparser_parse_baseURL (GstMpdClient * client, GstActiveStream * stream,
|
|||
ret = g_strjoinv (NULL, baseURL_array);
|
||||
|
||||
/* get base URI from MPD file URI, if the "http" scheme is missing */
|
||||
if (client->mpd_uri != NULL && strncmp (ret, "http://", 7) != 0) {
|
||||
mpd_uri = client->mpd_base_uri ? client->mpd_base_uri : client->mpd_uri;
|
||||
if (mpd_uri != NULL && strncmp (ret, "http://", 7) != 0) {
|
||||
gchar *last_sep, *tmp1, *tmp2;
|
||||
|
||||
if (ret[0] == '?') {
|
||||
|
@ -2717,9 +2719,9 @@ gst_mpdparser_parse_baseURL (GstMpdClient * client, GstActiveStream * stream,
|
|||
*query = NULL;
|
||||
}
|
||||
|
||||
last_sep = strrchr (client->mpd_uri, '/');
|
||||
last_sep = strrchr (mpd_uri, '/');
|
||||
if (last_sep) {
|
||||
tmp1 = g_strndup (client->mpd_uri, last_sep - client->mpd_uri + 1);
|
||||
tmp1 = g_strndup (mpd_uri, last_sep - mpd_uri + 1);
|
||||
if (ret) {
|
||||
tmp2 = ret;
|
||||
ret = g_strconcat (tmp1, tmp2, NULL);
|
||||
|
@ -2819,10 +2821,10 @@ gst_mpd_client_free (GstMpdClient * client)
|
|||
|
||||
g_mutex_clear (&client->lock);
|
||||
|
||||
if (client->mpd_uri) {
|
||||
g_free (client->mpd_uri);
|
||||
client->mpd_uri = NULL;
|
||||
}
|
||||
g_free (client->mpd_uri);
|
||||
client->mpd_uri = NULL;
|
||||
g_free (client->mpd_base_uri);
|
||||
client->mpd_base_uri = NULL;
|
||||
|
||||
g_free (client);
|
||||
}
|
||||
|
|
|
@ -469,6 +469,8 @@ struct _GstMpdClient
|
|||
|
||||
guint update_failed_count;
|
||||
gchar *mpd_uri; /* manifest file URI */
|
||||
gchar *mpd_base_uri; /* base URI for resolving relative URIs.
|
||||
* this will be different for redirects */
|
||||
GMutex lock;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue