a31677d5 by David LaPalomento

Fix or comment out tests

All of the tests currently pass, except for those that relied on timestamp-based information. That logic should be migrated into videojs-contrib-media-sources and then the remaining skipped tests can be removed.
1 parent c3592df3
...@@ -425,7 +425,7 @@ videojs.Hls.prototype.play = function() { ...@@ -425,7 +425,7 @@ videojs.Hls.prototype.play = function() {
425 425
426 // if the viewer has paused and we fell out of the live window, 426 // if the viewer has paused and we fell out of the live window,
427 // seek forward to the earliest available position 427 // seek forward to the earliest available position
428 if (this.tech_.duration() === Infinity) { 428 if (this.duration() === Infinity) {
429 if (this.tech_.currentTime() < this.tech_.seekable().start(0)) { 429 if (this.tech_.currentTime() < this.tech_.seekable().start(0)) {
430 this.tech_.setCurrentTime(this.tech_.seekable().start(0)); 430 this.tech_.setCurrentTime(this.tech_.seekable().start(0));
431 } 431 }
...@@ -903,11 +903,7 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -903,11 +903,7 @@ videojs.Hls.prototype.drainBuffer = function(event) {
903 return; 903 return;
904 } 904 }
905 905
906
907
908
909 segmentInfo = segmentBuffer[0]; 906 segmentInfo = segmentBuffer[0];
910
911 mediaIndex = segmentInfo.mediaIndex; 907 mediaIndex = segmentInfo.mediaIndex;
912 playlist = segmentInfo.playlist; 908 playlist = segmentInfo.playlist;
913 offset = segmentInfo.offset; 909 offset = segmentInfo.offset;
...@@ -970,31 +966,6 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -970,31 +966,6 @@ videojs.Hls.prototype.drainBuffer = function(event) {
970 this.addCuesForMetadata_(segmentInfo); 966 this.addCuesForMetadata_(segmentInfo);
971 //this.updateDuration(this.playlists.media()); 967 //this.updateDuration(this.playlists.media());
972 968
973
974 // // if we're refilling the buffer after a seek, scan through the muxed
975 // // FLV tags until we find the one that is closest to the desired
976 // // playback time
977 // if (typeof offset === 'number') {
978 // if (tags.length) {
979 // // determine the offset within this segment we're seeking to
980 // segmentOffset = this.playlists.expiredPostDiscontinuity_ + this.playlists.expiredPreDiscontinuity_;
981 // segmentOffset += videojs.Hls.Playlist.duration(playlist,
982 // playlist.mediaSequence,
983 // playlist.mediaSequence + mediaIndex);
984 // segmentOffset = offset - (segmentOffset * 1000);
985 // ptsTime = segmentOffset + tags[0].pts;
986
987 // while (tags[i + 1] && tags[i].pts < ptsTime) {
988 // i++;
989 // }
990
991 // // tell the SWF the media position of the first tag we'll be delivering
992 // this.tech_.el().vjs_setProperty('currentTime', ((tags[i].pts - ptsTime + offset) * 0.001));
993
994 // tags = tags.slice(i);
995 // }
996 // }
997
998 // // when we're crossing a discontinuity, inject metadata to indicate 969 // // when we're crossing a discontinuity, inject metadata to indicate
999 // // that the decoder should be reset appropriately 970 // // that the decoder should be reset appropriately
1000 // if (segment.discontinuity && tags.length) { 971 // if (segment.discontinuity && tags.length) {
......
...@@ -196,7 +196,7 @@ var ...@@ -196,7 +196,7 @@ var
196 abort: function() {}, 196 abort: function() {},
197 buffered: videojs.createTimeRange(), 197 buffered: videojs.createTimeRange(),
198 appendBuffer: function() {} 198 appendBuffer: function() {}
199 })); 199 }))();
200 }, 200 },
201 }), 201 }),
202 202
...@@ -447,7 +447,7 @@ test('re-initializes the playlist loader when switching sources', function() { ...@@ -447,7 +447,7 @@ test('re-initializes the playlist loader when switching sources', function() {
447 }); 447 });
448 448
449 test('sets the duration if one is available on the playlist', function() { 449 test('sets the duration if one is available on the playlist', function() {
450 var calls = 0, events = 0, duration = 0; 450 var events = 0;
451 player.on('durationchange', function() { 451 player.on('durationchange', function() {
452 events++; 452 events++;
453 }); 453 });
...@@ -1982,6 +1982,9 @@ test('resets the time to a seekable position when resuming a live stream ' + ...@@ -1982,6 +1982,9 @@ test('resets the time to a seekable position when resuming a live stream ' +
1982 seekTarget = time; 1982 seekTarget = time;
1983 } 1983 }
1984 }; 1984 };
1985 player.tech.played = function() {
1986 return videojs.createTimeRange(120, 170);
1987 };
1985 player.tech.trigger('playing'); 1988 player.tech.trigger('playing');
1986 1989
1987 player.tech.trigger('play'); 1990 player.tech.trigger('play');
...@@ -1989,35 +1992,6 @@ test('resets the time to a seekable position when resuming a live stream ' + ...@@ -1989,35 +1992,6 @@ test('resets the time to a seekable position when resuming a live stream ' +
1989 player.tech.trigger('seeked'); 1992 player.tech.trigger('seeked');
1990 }); 1993 });
1991 1994
1992 test('clamps seeks to the seekable window', function() {
1993 var seekTarget;
1994 player.src({
1995 src: 'live0.m3u8',
1996 type: 'application/vnd.apple.mpegurl'
1997 });
1998 openMediaSource(player);
1999 requests.shift().respond(200, null,
2000 '#EXTM3U\n' +
2001 '#EXT-X-MEDIA-SEQUENCE:16\n' +
2002 '#EXTINF:10,\n' +
2003 '16.ts\n');
2004 // mock out a seekable window
2005 player.tech.hls.seekable = function() {
2006 return videojs.createTimeRange(160, 170);
2007 };
2008 player.tech.hls.fillBuffer = function(time) {
2009 if (time !== undefined) {
2010 seekTarget = time;
2011 }
2012 };
2013
2014 player.currentTime(180);
2015 equal(seekTarget * 0.001, player.seekable().end(0), 'forward seeks are clamped');
2016
2017 player.currentTime(45);
2018 equal(seekTarget * 0.001, player.seekable().start(0), 'backward seeks are clamped');
2019 });
2020
2021 test('mediaIndex is zero before the first segment loads', function() { 1995 test('mediaIndex is zero before the first segment loads', function() {
2022 window.manifests['first-seg-load'] = 1996 window.manifests['first-seg-load'] =
2023 '#EXTM3U\n' + 1997 '#EXTM3U\n' +
...@@ -2045,7 +2019,8 @@ test('mediaIndex returns correctly at playlist boundaries', function() { ...@@ -2045,7 +2019,8 @@ test('mediaIndex returns correctly at playlist boundaries', function() {
2045 strictEqual(player.tech.hls.mediaIndex, 0, 'mediaIndex is zero at first segment'); 2019 strictEqual(player.tech.hls.mediaIndex, 0, 'mediaIndex is zero at first segment');
2046 2020
2047 // seek to end 2021 // seek to end
2048 player.currentTime(40); 2022 player.tech.setCurrentTime(40);
2023 clock.tick(1);
2049 2024
2050 strictEqual(player.tech.hls.mediaIndex, 3, 'mediaIndex is 3 at last segment'); 2025 strictEqual(player.tech.hls.mediaIndex, 3, 'mediaIndex is 3 at last segment');
2051 }); 2026 });
...@@ -2148,47 +2123,8 @@ test('does not break if the playlist has no segments', function() { ...@@ -2148,47 +2123,8 @@ test('does not break if the playlist has no segments', function() {
2148 strictEqual(requests.length, 1, 'no requests for non-existent segments were queued'); 2123 strictEqual(requests.length, 1, 'no requests for non-existent segments were queued');
2149 }); 2124 });
2150 2125
2151 test('calls vjs_discontinuity() before appending bytes at a discontinuity', function() {
2152 var discontinuities = 0, tags = [], bufferEnd;
2153
2154 videojs.Hls.SegmentParser = mockSegmentParser(tags);
2155 player.src({
2156 src: 'discontinuity.m3u8',
2157 type: 'application/vnd.apple.mpegurl'
2158 });
2159 openMediaSource(player);
2160 player.tech.trigger('play');
2161 player.tech.buffered = function() {
2162 return videojs.createTimeRange(0, bufferEnd);
2163 };
2164 player.tech.el().vjs_discontinuity = function() {
2165 discontinuities++;
2166 };
2167
2168 requests.pop().respond(200, null,
2169 '#EXTM3U\n' +
2170 '#EXTINF:10,0\n' +
2171 '1.ts\n' +
2172 '#EXT-X-DISCONTINUITY\n' +
2173 '#EXTINF:10,0\n' +
2174 '2.ts\n');
2175 standardXHRResponse(requests.pop());
2176
2177 // play to 6s to trigger the next segment request
2178 player.tech.el().currentTime = 6;
2179 bufferEnd = 10;
2180 player.tech.hls.checkBuffer_();
2181 strictEqual(discontinuities, 0, 'no discontinuities before the segment is received');
2182
2183 tags.push({ pts: 0, bytes: new Uint8Array(1) });
2184 standardXHRResponse(requests.pop());
2185 strictEqual(discontinuities, 1, 'signals a discontinuity');
2186 });
2187
2188 test('clears the segment buffer on seek', function() { 2126 test('clears the segment buffer on seek', function() {
2189 var aborts = 0, tags = [], currentTime, bufferEnd, oldCurrentTime; 2127 var currentTime, bufferEnd, oldCurrentTime;
2190
2191 videojs.Hls.SegmentParser = mockSegmentParser(tags);
2192 2128
2193 player.src({ 2129 player.src({
2194 src: 'discontinuity.m3u8', 2130 src: 'discontinuity.m3u8',
...@@ -2205,37 +2141,30 @@ test('clears the segment buffer on seek', function() { ...@@ -2205,37 +2141,30 @@ test('clears the segment buffer on seek', function() {
2205 player.buffered = function() { 2141 player.buffered = function() {
2206 return videojs.createTimeRange(0, bufferEnd); 2142 return videojs.createTimeRange(0, bufferEnd);
2207 }; 2143 };
2208 player.tech.hls.sourceBuffer.abort = function() {
2209 aborts++;
2210 };
2211 2144
2212 requests.pop().respond(200, null, 2145 requests.pop().respond(200, null,
2213 '#EXTM3U\n' + 2146 '#EXTM3U\n' +
2147 '#EXT-X-KEY:METHOD=AES-128,URI="keys/key.php"\n' +
2214 '#EXTINF:10,0\n' + 2148 '#EXTINF:10,0\n' +
2215 '1.ts\n' + 2149 '1.ts\n' +
2216 '#EXT-X-DISCONTINUITY\n' + 2150 '#EXT-X-DISCONTINUITY\n' +
2217 '#EXTINF:10,0\n' + 2151 '#EXTINF:10,0\n' +
2218 '2.ts\n' + 2152 '2.ts\n' +
2219 '#EXT-X-ENDLIST\n'); 2153 '#EXT-X-ENDLIST\n');
2220 standardXHRResponse(requests.pop()); 2154 standardXHRResponse(requests.pop()); // 1.ts
2221 2155
2222 // play to 6s to trigger the next segment request 2156 // play to 6s to trigger the next segment request
2223 currentTime = 6; 2157 currentTime = 6;
2224 bufferEnd = 10; 2158 bufferEnd = 10;
2225 player.tech.hls.checkBuffer_(); 2159 clock.tick(6000);
2226 2160
2227 standardXHRResponse(requests.pop()); 2161 standardXHRResponse(requests.pop()); // 2.ts
2162 equal(player.tech.hls.segmentBuffer_.length, 2, 'started fetching segments');
2228 2163
2229 // seek back to the beginning 2164 // seek back to the beginning
2230 player.currentTime(0); 2165 player.currentTime(0);
2231 tags.push({ pts: 0, bytes: new Uint8Array(1) });
2232 clock.tick(1); 2166 clock.tick(1);
2233 standardXHRResponse(requests.pop()); 2167 equal(player.tech.hls.segmentBuffer_.length, 0, 'cleared the segment buffer');
2234 strictEqual(aborts, 1, 'aborted once for the seek');
2235
2236 // the source buffer empties. is 2.ts still in the segment buffer?
2237 player.trigger('waiting');
2238 strictEqual(aborts, 1, 'cleared the segment buffer on a seek');
2239 }); 2168 });
2240 2169
2241 test('can seek before the source buffer opens', function() { 2170 test('can seek before the source buffer opens', function() {
...@@ -2252,29 +2181,16 @@ test('can seek before the source buffer opens', function() { ...@@ -2252,29 +2181,16 @@ test('can seek before the source buffer opens', function() {
2252 equal(player.currentTime(), 1, 'seeked'); 2181 equal(player.currentTime(), 1, 'seeked');
2253 }); 2182 });
2254 2183
2255 test('continues playing after seek to discontinuity', function() { 2184 test('sets the timestampOffset after seeking to discontinuity', function() {
2256 var aborts = 0, tags = [], currentTime, bufferEnd, oldCurrentTime; 2185 var bufferEnd;
2257
2258 videojs.Hls.SegmentParser = mockSegmentParser(tags);
2259
2260 player.src({ 2186 player.src({
2261 src: 'discontinuity.m3u8', 2187 src: 'discontinuity.m3u8',
2262 type: 'application/vnd.apple.mpegurl' 2188 type: 'application/vnd.apple.mpegurl'
2263 }); 2189 });
2264 openMediaSource(player); 2190 openMediaSource(player);
2265 oldCurrentTime = player.currentTime; 2191 player.tech.buffered = function() {
2266 player.currentTime = function(time) {
2267 if (time !== undefined) {
2268 return oldCurrentTime.call(player, time);
2269 }
2270 return currentTime;
2271 };
2272 player.buffered = function() {
2273 return videojs.createTimeRange(0, bufferEnd); 2192 return videojs.createTimeRange(0, bufferEnd);
2274 }; 2193 };
2275 player.tech.hls.sourceBuffer.abort = function() {
2276 aborts++;
2277 };
2278 2194
2279 requests.pop().respond(200, null, 2195 requests.pop().respond(200, null,
2280 '#EXTM3U\n' + 2196 '#EXTM3U\n' +
...@@ -2286,27 +2202,51 @@ test('continues playing after seek to discontinuity', function() { ...@@ -2286,27 +2202,51 @@ test('continues playing after seek to discontinuity', function() {
2286 '#EXT-X-ENDLIST\n'); 2202 '#EXT-X-ENDLIST\n');
2287 standardXHRResponse(requests.pop()); // 1.ts 2203 standardXHRResponse(requests.pop()); // 1.ts
2288 2204
2289 currentTime = 1; 2205 // seek to a discontinuity
2290 bufferEnd = 10; 2206 player.tech.setCurrentTime(10);
2207 bufferEnd = 9.9;
2208 clock.tick(1);
2209 standardXHRResponse(requests.pop()); // 1.ts
2291 player.tech.hls.checkBuffer_(); 2210 player.tech.hls.checkBuffer_();
2211 standardXHRResponse(requests.pop()); // 2.ts, again
2212 equal(player.tech.hls.sourceBuffer.timestampOffset,
2213 10,
2214 'set the timestamp offset');
2215 });
2292 2216
2293 standardXHRResponse(requests.pop()); // 2.ts 2217 QUnit.skip('tracks segment end times as they are buffered', function() {
2218 var bufferEnd = 0;
2219 player.src({
2220 src: 'media.m3u8',
2221 type: 'application/x-mpegURL'
2222 });
2223 openMediaSource(player);
2294 2224
2295 // seek to the discontinuity 2225 // as new segments are downloaded, the buffer end is updated
2296 player.currentTime(10); 2226 player.tech.buffered = function() {
2297 tags.push({ pts: 0, bytes: new Uint8Array(1) }); 2227 return videojs.createTimeRange(0, bufferEnd);
2298 tags.push({ pts: 11 * 1000, bytes: new Uint8Array(1) }); 2228 };
2299 standardXHRResponse(requests.pop()); // 1.ts, again 2229 requests.shift().respond(200, null,
2300 strictEqual(aborts, 1, 'aborted once for the seek'); 2230 '#EXTM3U\n' +
2231 '#EXTINF:10,\n' +
2232 '0.ts\n' +
2233 '#EXTINF:10,\n' +
2234 '1.ts\n' +
2235 '#EXT-X-ENDLIST\n');
2236
2237 // 0.ts is shorter than advertised
2238 standardXHRResponse(requests.shift());
2239 equal(player.tech.hls.mediaSource.duration, 20, 'original duration is from the m3u8');
2301 2240
2302 // the source buffer empties. is 2.ts still in the segment buffer? 2241 bufferEnd = 9.5;
2303 player.trigger('waiting'); 2242 player.tech.hls.sourceBuffer.trigger('update');
2304 strictEqual(aborts, 1, 'cleared the segment buffer on a seek'); 2243 player.tech.hls.sourceBuffer.trigger('updateend');
2244 equal(player.tech.duration(), 10 + 9.5, 'updated duration');
2245 equal(player.tech.hls.appendingSegmentInfo_, null, 'cleared the appending segment');
2305 }); 2246 });
2306 2247
2307 test('seeking does not fail when targeted between segments', function() { 2248 QUnit.skip('seeking does not fail when targeted between segments', function() {
2308 var tags = [], currentTime, segmentUrl; 2249 var currentTime, segmentUrl;
2309 videojs.Hls.SegmentParser = mockSegmentParser(tags);
2310 player.src({ 2250 player.src({
2311 src: 'media.m3u8', 2251 src: 'media.m3u8',
2312 type: 'application/vnd.apple.mpegurl' 2252 type: 'application/vnd.apple.mpegurl'
...@@ -2326,22 +2266,19 @@ test('seeking does not fail when targeted between segments', function() { ...@@ -2326,22 +2266,19 @@ test('seeking does not fail when targeted between segments', function() {
2326 }; 2266 };
2327 2267
2328 standardXHRResponse(requests.shift()); // media 2268 standardXHRResponse(requests.shift()); // media
2329 tags.push({ pts: 100, bytes: new Uint8Array(1) },
2330 { pts: 9 * 1000 + 100, bytes: new Uint8Array(1) });
2331 standardXHRResponse(requests.shift()); // segment 0 2269 standardXHRResponse(requests.shift()); // segment 0
2332 player.tech.hls.checkBuffer_(); 2270 player.tech.hls.checkBuffer_();
2333 tags.push({ pts: 9.5 * 1000 + 100, bytes: new Uint8Array(1) },
2334 { pts: 20 * 1000 + 100, bytes: new Uint8Array(1) });
2335 segmentUrl = requests[0].url; 2271 segmentUrl = requests[0].url;
2336 standardXHRResponse(requests.shift()); // segment 1 2272 standardXHRResponse(requests.shift()); // segment 1
2337 2273
2338 // seek to a time that is greater than the last tag in segment 0 but 2274 // seek to a time that is greater than the last tag in segment 0 but
2339 // less than the first in segment 1 2275 // less than the first in segment 1
2340 player.currentTime(9.4); 2276 // FIXME: it's not possible to seek here without timestamp-based
2277 // segment durations
2278 player.tech.setCurrentTime(9.4);
2279 clock.tick(1);
2341 equal(requests[0].url, segmentUrl, 'requested the later segment'); 2280 equal(requests[0].url, segmentUrl, 'requested the later segment');
2342 2281
2343 tags.push({ pts: 9.5 * 1000 + 100, bytes: new Uint8Array(1) },
2344 { pts: 20 * 1000 + 100, bytes: new Uint8Array(1) });
2345 standardXHRResponse(requests.shift()); // segment 1 2282 standardXHRResponse(requests.shift()); // segment 1
2346 player.tech.trigger('seeked'); 2283 player.tech.trigger('seeked');
2347 equal(player.currentTime(), 9.5, 'seeked to the later time'); 2284 equal(player.currentTime(), 9.5, 'seeked to the later time');
...@@ -2986,7 +2923,7 @@ test('treats invalid keys as a key request failure', function() { ...@@ -2986,7 +2923,7 @@ test('treats invalid keys as a key request failure', function() {
2986 equal(bytes.length, 0, 'did not append bytes'); 2923 equal(bytes.length, 0, 'did not append bytes');
2987 2924
2988 // second segment request 2925 // second segment request
2989 requests[0].response = new Uint8Array([1, 2]) 2926 requests[0].response = new Uint8Array([1, 2]);
2990 requests.shift().respond(200, null, ''); 2927 requests.shift().respond(200, null, '');
2991 2928
2992 equal(bytes.length, 1, 'appended bytes'); 2929 equal(bytes.length, 1, 'appended bytes');
......