b7b5d4d1 by jrivera

Fixes base on review

1 parent e266db29
...@@ -256,8 +256,8 @@ videojs.Hls.findSoleUncommonTimeRangesEnd_ = function(original, update) { ...@@ -256,8 +256,8 @@ videojs.Hls.findSoleUncommonTimeRangesEnd_ = function(original, update) {
256 // 2) Not result from the shrinking of a range that already existed 256 // 2) Not result from the shrinking of a range that already existed
257 // in the `original` ranges 257 // in the `original` ranges
258 // 3) Not be contained inside of a range that existed in `original` 258 // 3) Not be contained inside of a range that existed in `original`
259 checkEdges = function(span) { 259 overlapsCurrentEnd = function(span) {
260 return (span[0] <= end && span[1] > end) || span[1] === end; 260 return (span[0] <= end && span[1] >= end);
261 }; 261 };
262 262
263 if (original) { 263 if (original) {
...@@ -277,7 +277,7 @@ videojs.Hls.findSoleUncommonTimeRangesEnd_ = function(original, update) { ...@@ -277,7 +277,7 @@ videojs.Hls.findSoleUncommonTimeRangesEnd_ = function(original, update) {
277 start = update.start(i); 277 start = update.start(i);
278 end = update.end(i); 278 end = update.end(i);
279 279
280 if (edges.some(checkEdges)) { 280 if (edges.some(overlapsCurrentEnd)) {
281 continue; 281 continue;
282 } 282 }
283 283
...@@ -290,9 +290,9 @@ videojs.Hls.findSoleUncommonTimeRangesEnd_ = function(original, update) { ...@@ -290,9 +290,9 @@ videojs.Hls.findSoleUncommonTimeRangesEnd_ = function(original, update) {
290 // exactly *one* differing end edge in the search above 290 // exactly *one* differing end edge in the search above
291 if (result.length !== 1) { 291 if (result.length !== 1) {
292 return null; 292 return null;
293 } else {
294 return result[0];
295 } 293 }
294
295 return result[0];
296 }; 296 };
297 297
298 var parseCodecs = function(codecs) { 298 var parseCodecs = function(codecs) {
...@@ -1005,20 +1005,17 @@ videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) { ...@@ -1005,20 +1005,17 @@ videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) {
1005 return; 1005 return;
1006 } 1006 }
1007 1007
1008 // if a segment request times out, we may have better luck with another playlist
1009 if (request.timedout) {
1010 // the segment request is no longer outstanding 1008 // the segment request is no longer outstanding
1011 self.segmentXhr_ = null; 1009 self.segmentXhr_ = null;
1010
1011 // if a segment request times out, we may have better luck with another playlist
1012 if (request.timedout) {
1012 self.bandwidth = 1; 1013 self.bandwidth = 1;
1013 return self.playlists.media(self.selectPlaylist()); 1014 return self.playlists.media(self.selectPlaylist());
1014 } 1015 }
1015 1016
1016 // otherwise, trigger a network error 1017 // otherwise, trigger a network error
1017 if (!request.aborted && error) { 1018 if (!request.aborted && error) {
1018 // the segment request is no longer outstanding
1019 self.segmentXhr_ = null;
1020
1021 self.pendingSegment_ = null;
1022 return self.blacklistCurrentPlaylist_({ 1019 return self.blacklistCurrentPlaylist_({
1023 status: request.status, 1020 status: request.status,
1024 message: 'HLS segment request error at URL: ' + segmentInfo.uri, 1021 message: 'HLS segment request error at URL: ' + segmentInfo.uri,
...@@ -1028,8 +1025,6 @@ videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) { ...@@ -1028,8 +1025,6 @@ videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) {
1028 1025
1029 // stop processing if the request was aborted 1026 // stop processing if the request was aborted
1030 if (!request.response) { 1027 if (!request.response) {
1031 // the segment request is no longer outstanding
1032 self.segmentXhr_ = null;
1033 return; 1028 return;
1034 } 1029 }
1035 1030
...@@ -1047,13 +1042,11 @@ videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) { ...@@ -1047,13 +1042,11 @@ videojs.HlsHandler.prototype.loadSegment = function(segmentInfo) {
1047 self.tech_.trigger('progress'); 1042 self.tech_.trigger('progress');
1048 self.drainBuffer(); 1043 self.drainBuffer();
1049 1044
1050 // the segment request is no longer outstanding
1051 self.segmentXhr_ = null;
1052
1053 // figure out what stream the next segment should be downloaded from 1045 // figure out what stream the next segment should be downloaded from
1054 // with the updated bandwidth information 1046 // with the updated bandwidth information
1055 self.playlists.media(self.selectPlaylist()); 1047 self.playlists.media(self.selectPlaylist());
1056 }); 1048 });
1049
1057 }; 1050 };
1058 1051
1059 videojs.HlsHandler.prototype.drainBuffer = function(event) { 1052 videojs.HlsHandler.prototype.drainBuffer = function(event) {
...@@ -1178,10 +1171,10 @@ videojs.HlsHandler.prototype.updateEndHandler_ = function () { ...@@ -1178,10 +1171,10 @@ videojs.HlsHandler.prototype.updateEndHandler_ = function () {
1178 seekable, 1171 seekable,
1179 timelineUpdate; 1172 timelineUpdate;
1180 1173
1174 this.pendingSegment_ = null;
1181 1175
1182 // stop here if the update errored or was aborted 1176 // stop here if the update errored or was aborted
1183 if (!segmentInfo) { 1177 if (!segmentInfo) {
1184 this.pendingSegment_ = null;
1185 return; 1178 return;
1186 } 1179 }
1187 1180
...@@ -1193,7 +1186,6 @@ videojs.HlsHandler.prototype.updateEndHandler_ = function () { ...@@ -1193,7 +1186,6 @@ videojs.HlsHandler.prototype.updateEndHandler_ = function () {
1193 // if we switched renditions don't try to add segment timeline 1186 // if we switched renditions don't try to add segment timeline
1194 // information to the playlist 1187 // information to the playlist
1195 if (segmentInfo.playlist.uri !== this.playlists.media().uri) { 1188 if (segmentInfo.playlist.uri !== this.playlists.media().uri) {
1196 this.pendingSegment_ = null;
1197 return this.fillBuffer(); 1189 return this.fillBuffer();
1198 } 1190 }
1199 1191
...@@ -1232,21 +1224,17 @@ videojs.HlsHandler.prototype.updateEndHandler_ = function () { ...@@ -1232,21 +1224,17 @@ videojs.HlsHandler.prototype.updateEndHandler_ = function () {
1232 segments[segments.length - 1].end <= currentBuffered.end(0) && 1224 segments[segments.length - 1].end <= currentBuffered.end(0) &&
1233 this.mediaSource.readyState === 'open') { 1225 this.mediaSource.readyState === 'open') {
1234 this.mediaSource.endOfStream(); 1226 this.mediaSource.endOfStream();
1235 this.pendingSegment_ = null;
1236 return; 1227 return;
1237 } 1228 }
1238 1229
1239 if (timelineUpdate !== null || 1230 if (timelineUpdate !== null ||
1240 segmentInfo.buffered.length !== this.tech_.buffered().length) { 1231 segmentInfo.buffered.length !== this.tech_.buffered().length) {
1241 this.updateDuration(playlist); 1232 this.updateDuration(playlist);
1242 this.pendingSegment_ = null;
1243 // check if it's time to download the next segment 1233 // check if it's time to download the next segment
1244 this.fillBuffer(); 1234 this.fillBuffer();
1245 return; 1235 return;
1246 } 1236 }
1247 1237
1248 this.pendingSegment_ = null;
1249
1250 // the last segment append must have been entirely in the 1238 // the last segment append must have been entirely in the
1251 // already buffered time ranges. just buffer forward until we 1239 // already buffered time ranges. just buffer forward until we
1252 // find a segment that adds to the buffered time ranges and 1240 // find a segment that adds to the buffered time ranges and
......