14e6480c by David LaPalomento

Merge branch 'jsanford-bc-master'

Hand-merge for #256.
2 parents 1670a237 9ce3dc2c
...@@ -459,6 +459,10 @@ videojs.Hls.prototype.selectPlaylist = function () { ...@@ -459,6 +459,10 @@ videojs.Hls.prototype.selectPlaylist = function () {
459 // sort variants by resolution 459 // sort variants by resolution
460 bandwidthPlaylists.sort(videojs.Hls.comparePlaylistResolution); 460 bandwidthPlaylists.sort(videojs.Hls.comparePlaylistResolution);
461 461
462 // forget our old variant from above, or we might choose that in high-bandwidth scenarios
463 // (this could be the lowest bitrate rendition as we go through all of them above)
464 variant = null;
465
462 // iterate through the bandwidth-filtered playlists and find 466 // iterate through the bandwidth-filtered playlists and find
463 // best rendition by player dimension 467 // best rendition by player dimension
464 while (i--) { 468 while (i--) {
...@@ -485,7 +489,7 @@ videojs.Hls.prototype.selectPlaylist = function () { ...@@ -485,7 +489,7 @@ videojs.Hls.prototype.selectPlaylist = function () {
485 } else if (variant.attributes.RESOLUTION.width < player.width() && 489 } else if (variant.attributes.RESOLUTION.width < player.width() &&
486 variant.attributes.RESOLUTION.height < player.height()) { 490 variant.attributes.RESOLUTION.height < player.height()) {
487 // if we don't have an exact match, see if we have a good higher quality variant to use 491 // if we don't have an exact match, see if we have a good higher quality variant to use
488 if (oldvariant.attributes && oldvariant.attributes.RESOLUTION && 492 if (oldvariant && oldvariant.attributes && oldvariant.attributes.RESOLUTION &&
489 oldvariant.attributes.RESOLUTION.width && oldvariant.attributes.RESOLUTION.height) { 493 oldvariant.attributes.RESOLUTION.width && oldvariant.attributes.RESOLUTION.height) {
490 resolutionPlusOne = oldvariant; 494 resolutionPlusOne = oldvariant;
491 } 495 }
......
...@@ -852,6 +852,32 @@ test('selects the correct rendition by player dimensions', function() { ...@@ -852,6 +852,32 @@ test('selects the correct rendition by player dimensions', function() {
852 852
853 }); 853 });
854 854
855 test('selects the highest bitrate playlist when the player dimensions are ' +
856 'larger than any of the variants', function() {
857 var playlist;
858 player.src({
859 src: 'manifest/master.m3u8',
860 type: 'application/vnd.apple.mpegurl'
861 });
862 openMediaSource(player);
863 requests.shift().respond(200, null,
864 '#EXTM3U\n' +
865 '#EXT-X-STREAM-INF:BANDWIDTH=1000,RESOLUTION=2x1\n' +
866 'media.m3u8\n' +
867 '#EXT-X-STREAM-INF:BANDWIDTH=1,RESOLUTION=1x1\n' +
868 'media1.m3u8\n'); // master
869 standardXHRResponse(requests.shift()); // media
870 player.hls.bandwidth = 1e10;
871
872 player.width(1024);
873 player.height(768);
874
875 playlist = player.hls.selectPlaylist();
876
877 equal(playlist.attributes.BANDWIDTH,
878 1000,
879 'selected the highest bandwidth variant');
880 });
855 881
856 test('does not download the next segment if the buffer is full', function() { 882 test('does not download the next segment if the buffer is full', function() {
857 var currentTime = 15; 883 var currentTime = 15;
......