4bbd0d94 by Steve Mayhew Committed by David LaPalomento

Fix EXT-X-KEY processing of relative URLs

The EXT-X-KEY URI attribute is not processed to spec.  It should be
interpreted as absolute or relative to the playlist containing the
EXT-X-KEY tag.

This is in the IETF spec
(https://tools.ietf.org/html/draft-pantos-http-live-streaming-13#section
-3.1).

The fix is simple, use the same URL resolution code the TS segments are
using.

Here is a stream that only works correctly with this fix:
  http://flashls-test.s3.amazonaws.com/7_copy.m3u8
1 parent 7436e467
......@@ -472,13 +472,20 @@ videojs.Hls.prototype.fillBuffer = function(offset) {
}
// resolve the segment URL relative to the playlist
segmentUri = this.resolveSegmentUrl(segment.uri);
this.loadSegment(segmentUri, offset);
};
videojs.Hls.prototype.resolveSegmentUrl = function(segmentRelativeUrl) {
var segmentUrl;
// resolve the segment URL relative to the playlist
if (this.playlists.media().uri === this.src_) {
segmentUri = resolveUrl(this.src_, segment.uri);
segmentUrl = resolveUrl(this.src_, segmentRelativeUrl);
} else {
segmentUri = resolveUrl(resolveUrl(this.src_, this.playlists.media().uri || ''), segment.uri);
segmentUrl = resolveUrl(resolveUrl(this.src_, this.playlists.media().uri || ''), segmentRelativeUrl);
}
this.loadSegment(segmentUri, offset);
return segmentUrl
};
/*
......@@ -684,7 +691,7 @@ videojs.Hls.prototype.fetchKeys = function(playlist, index) {
key = playlist.segments[i].key;
if (key && !key.bytes && !keyFailed(key)) {
keyXhr = videojs.Hls.xhr({
url: resolveUrl(playlist.uri, key.uri),
url: this.resolveSegmentUrl(key.uri),
responseType: 'arraybuffer',
withCredentials: settings.withCredentials
}, function(err, url) {
......