Merge branch 'stevemayhew-fix-keyurl'
Showing
2 changed files
with
54 additions
and
5 deletions
... | @@ -472,13 +472,20 @@ videojs.Hls.prototype.fillBuffer = function(offset) { | ... | @@ -472,13 +472,20 @@ videojs.Hls.prototype.fillBuffer = function(offset) { |
472 | } | 472 | } |
473 | 473 | ||
474 | // resolve the segment URL relative to the playlist | 474 | // resolve the segment URL relative to the playlist |
475 | segmentUri = this.playlistUriToUrl(segment.uri); | ||
476 | |||
477 | this.loadSegment(segmentUri, offset); | ||
478 | }; | ||
479 | |||
480 | videojs.Hls.prototype.playlistUriToUrl = function(segmentRelativeUrl) { | ||
481 | var playListUrl; | ||
482 | // resolve the segment URL relative to the playlist | ||
475 | if (this.playlists.media().uri === this.src_) { | 483 | if (this.playlists.media().uri === this.src_) { |
476 | segmentUri = resolveUrl(this.src_, segment.uri); | 484 | playListUrl = resolveUrl(this.src_, segmentRelativeUrl); |
477 | } else { | 485 | } else { |
478 | segmentUri = resolveUrl(resolveUrl(this.src_, this.playlists.media().uri || ''), segment.uri); | 486 | playListUrl = resolveUrl(resolveUrl(this.src_, this.playlists.media().uri || ''), segmentRelativeUrl); |
479 | } | 487 | } |
480 | 488 | return playListUrl; | |
481 | this.loadSegment(segmentUri, offset); | ||
482 | }; | 489 | }; |
483 | 490 | ||
484 | /* | 491 | /* |
... | @@ -684,7 +691,7 @@ videojs.Hls.prototype.fetchKeys = function(playlist, index) { | ... | @@ -684,7 +691,7 @@ videojs.Hls.prototype.fetchKeys = function(playlist, index) { |
684 | key = playlist.segments[i].key; | 691 | key = playlist.segments[i].key; |
685 | if (key && !key.bytes && !keyFailed(key)) { | 692 | if (key && !key.bytes && !keyFailed(key)) { |
686 | keyXhr = videojs.Hls.xhr({ | 693 | keyXhr = videojs.Hls.xhr({ |
687 | url: resolveUrl(playlist.uri, key.uri), | 694 | url: this.playlistUriToUrl(key.uri), |
688 | responseType: 'arraybuffer', | 695 | responseType: 'arraybuffer', |
689 | withCredentials: settings.withCredentials | 696 | withCredentials: settings.withCredentials |
690 | }, function(err, url) { | 697 | }, function(err, url) { | ... | ... |
... | @@ -1612,6 +1612,48 @@ test('calling fetchKeys() when a new playlist is loaded will create an XHR', fun | ... | @@ -1612,6 +1612,48 @@ test('calling fetchKeys() when a new playlist is loaded will create an XHR', fun |
1612 | player.hls.playlists.media = oldMedia; | 1612 | player.hls.playlists.media = oldMedia; |
1613 | }); | 1613 | }); |
1614 | 1614 | ||
1615 | test('fetchKeys() resolves URLs relative to the master playlist', function() { | ||
1616 | player.src({ | ||
1617 | src: 'video/master-encrypted.m3u8', | ||
1618 | type: 'application/vnd.apple.mpegurl' | ||
1619 | }); | ||
1620 | openMediaSource(player); | ||
1621 | requests.shift().respond(200, null, | ||
1622 | '#EXTM3U\n' + | ||
1623 | '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=17\n' + | ||
1624 | 'playlist/playlist.m3u8\n' + | ||
1625 | '#EXT-X-ENDLIST\n'); | ||
1626 | requests.shift().respond(200, null, | ||
1627 | '#EXTM3U\n' + | ||
1628 | '#EXT-X-TARGETDURATION:15\n' + | ||
1629 | '#EXT-X-KEY:METHOD=AES-128,URI="keys/key.php"\n' + | ||
1630 | '#EXTINF:2.833,\n' + | ||
1631 | 'http://media.example.com/fileSequence1.ts\n' + | ||
1632 | '#EXT-X-ENDLIST\n'); | ||
1633 | |||
1634 | equal(requests.length, 2, 'requested two URLs'); | ||
1635 | ok((/video\/playlist\/keys\/key\.php$/).test(requests[0].url), | ||
1636 | 'resolves multiple relative paths'); | ||
1637 | }); | ||
1638 | |||
1639 | test('fetchKeys() resolves URLs relative to their containing playlist', function() { | ||
1640 | player.src({ | ||
1641 | src: 'video/media-encrypted.m3u8', | ||
1642 | type: 'application/vnd.apple.mpegurl' | ||
1643 | }); | ||
1644 | openMediaSource(player); | ||
1645 | requests.shift().respond(200, null, | ||
1646 | '#EXTM3U\n' + | ||
1647 | '#EXT-X-TARGETDURATION:15\n' + | ||
1648 | '#EXT-X-KEY:METHOD=AES-128,URI="keys/key.php"\n' + | ||
1649 | '#EXTINF:2.833,\n' + | ||
1650 | 'http://media.example.com/fileSequence1.ts\n' + | ||
1651 | '#EXT-X-ENDLIST\n'); | ||
1652 | equal(requests.length, 2, 'requested two URLs'); | ||
1653 | ok((/video\/keys\/key\.php$/).test(requests[0].url), | ||
1654 | 'resolves multiple relative paths'); | ||
1655 | }); | ||
1656 | |||
1615 | test('a new keys XHR is created when a previous key XHR finishes', function() { | 1657 | test('a new keys XHR is created when a previous key XHR finishes', function() { |
1616 | player.src({ | 1658 | player.src({ |
1617 | src: 'https://example.com/encrypted-media.m3u8', | 1659 | src: 'https://example.com/encrypted-media.m3u8', | ... | ... |
-
Please register or sign in to post a comment