diff --git a/AUTHORS b/AUTHORS index 8aa390b452..37cef4bf4b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -20,6 +20,7 @@ Jesper Haug Karsrud Nick Desaulniers Oskar Arvidsson Philo Inc. <*@philo.com> +Robert Colantuoni Roi Lipman Sanborn Hilland TalkTalk Plc <*@talktalkplc.com> diff --git a/CONTRIBUTORS b/CONTRIBUTORS index eb45c91862..52d6111bf7 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -31,6 +31,7 @@ Jono Ward Natalie Harris Nick Desaulniers Oskar Arvidsson +Robert Colantuoni Rohit Makasana Roi Lipman Sanborn Hilland diff --git a/lib/dash/mpd_parser.js b/lib/dash/mpd_parser.js index 5d8339acd2..86d0310f64 100644 --- a/lib/dash/mpd_parser.js +++ b/lib/dash/mpd_parser.js @@ -36,12 +36,13 @@ goog.require('shaka.util.Uint8ArrayUtils'); * Numbers, times, and byte ranges are set to null if they cannot be parsed. * * @param {string} source The MPD XML text. - * @param {!Array.} url The MPD URL for relative BaseURL resolution. + * @param {!Array.} origUrl MPD URL for original download location. + * @param {!Array.} baseUrl MPD URL for relative BaseURL resolution. * @return {shaka.dash.mpd.Mpd} * * @see ISO/IEC 23009-1 */ -shaka.dash.mpd.parseMpd = function(source, url) { +shaka.dash.mpd.parseMpd = function(source, origUrl, baseUrl) { var parser = new DOMParser(); var xml = parser.parseFromString(source, 'text/xml'); @@ -51,7 +52,7 @@ shaka.dash.mpd.parseMpd = function(source, url) { } // Construct a virtual parent for the MPD to use in resolving relative URLs. - var parent = { baseUrl: url }; + var parent = { origUrl: origUrl, baseUrl: baseUrl }; return shaka.dash.mpd.parseChild_(parent, xml, shaka.dash.mpd.Mpd); }; @@ -89,6 +90,9 @@ shaka.dash.mpd.Mpd = function() { /** @type {string} */ this.type = 'static'; + /** @type {Array.} */ + this.origUrl = null; + /** @type {Array.} */ this.baseUrl = null; @@ -869,7 +873,7 @@ shaka.dash.mpd.Mpd.prototype.parse = function(parent, elem) { var mpd = shaka.dash.mpd; // Parse attributes. - this.url = parent.baseUrl; + this.url = parent.origUrl; this.id = mpd.parseAttr_(elem, 'id', mpd.parseString_); this.type = mpd.parseAttr_(elem, 'type', mpd.parseString_) || 'static'; this.mediaPresentationDuration = mpd.parseAttr_( diff --git a/lib/dash/mpd_request.js b/lib/dash/mpd_request.js index a414a82313..e3a7789678 100644 --- a/lib/dash/mpd_request.js +++ b/lib/dash/mpd_request.js @@ -65,7 +65,7 @@ shaka.dash.MpdRequest.prototype.send = function() { /** @param {!ArrayBuffer|string} data */ function(data) { var mpd = shaka.dash.mpd.parseMpd( - /** @type {string} */ (data), url.urls); + /** @type {string} */ (data), url.urls, [url.currentUrl]); if (mpd) { return Promise.resolve(mpd); } diff --git a/lib/util/failover_uri.js b/lib/util/failover_uri.js index 229d2ec6ce..a6435059b4 100644 --- a/lib/util/failover_uri.js +++ b/lib/util/failover_uri.js @@ -56,6 +56,9 @@ shaka.util.FailoverUri = function(callback, urls, opt_startByte, opt_endByte) { /** @private {shaka.util.FailoverUri.NetworkCallback} */ this.callback_ = callback; + + /** @type {goog.Uri} */ + this.currentUrl = null; }; @@ -134,6 +137,7 @@ shaka.util.FailoverUri.prototype.abortFetch = function() { this.requestPromise_ = null; this.request_.abort(); this.request_ = null; + this.currentUrl = null; } }; @@ -168,6 +172,12 @@ shaka.util.FailoverUri.prototype.createRequest_ = // effectively cache every response. this.requestPromise_ = null; this.request_ = null; + this.currentUrl = null; + if (xhr.responseURL) { + this.currentUrl = new goog.Uri(xhr.responseURL); + } else { + this.currentUrl = this.urls[i]; + } return Promise.resolve(xhr.response); })); diff --git a/spec/mpd_parser_base_url_spec.js b/spec/mpd_parser_base_url_spec.js index 81c475ce66..20cfb67bdc 100644 --- a/spec/mpd_parser_base_url_spec.js +++ b/spec/mpd_parser_base_url_spec.js @@ -147,7 +147,9 @@ describe('mpd.BaseUrl', function() { ''].join('\n'); var mpdUrl = 'http://example.com/dash/test.mpd'; - var mpd = shaka.dash.mpd.parseMpd(source, createFailover(mpdUrl).urls); + var mpd = shaka.dash.mpd.parseMpd(source, + createFailover(mpdUrl).urls, + createFailover(mpdUrl).urls); expect(mpd).toBeTruthy(); expect(mpd.baseUrl.toString()).toBe(mpdUrl); expect(mpd.periods.length).toBe(1); diff --git a/spec/mpd_spec.js b/spec/mpd_spec.js index 6edff951e8..39c588b9f1 100644 --- a/spec/mpd_spec.js +++ b/spec/mpd_spec.js @@ -550,8 +550,9 @@ describe('mpd', function() { ' updated_mpd', ''].join('\n'); - var mpd = shaka.dash.mpd.parseMpd(source, createFailover( - 'http://example.com/mpd').urls); + var mpd = shaka.dash.mpd.parseMpd(source, + createFailover('http://example.com/mpd').urls, + createFailover('http://example.com/mpd').urls); expect(mpd.updateLocation.toString()).toBe( 'http://example.com/updated_mpd'); });