Added tests for timestampOffset and findCurrentBuffered_
Showing
1 changed file
with
58 additions
and
5 deletions
... | @@ -551,6 +551,28 @@ test('starts downloading a segment on loadedmetadata', function() { | ... | @@ -551,6 +551,28 @@ test('starts downloading a segment on loadedmetadata', function() { |
551 | 'the first segment is requested'); | 551 | 'the first segment is requested'); |
552 | }); | 552 | }); |
553 | 553 | ||
554 | test('finds the correct buffered region based on currentTime', function() { | ||
555 | player.src({ | ||
556 | src: 'manifest/media.m3u8', | ||
557 | type: 'application/vnd.apple.mpegurl' | ||
558 | }); | ||
559 | player.tech_.buffered = function() { | ||
560 | return videojs.createTimeRanges([[0, 5], [6, 12]]); | ||
561 | }; | ||
562 | openMediaSource(player); | ||
563 | |||
564 | standardXHRResponse(requests[0]); | ||
565 | standardXHRResponse(requests[1]); | ||
566 | player.currentTime(3); | ||
567 | clock.tick(1); | ||
568 | equal(player.tech_.hls.findCurrentBuffered_().end(0), | ||
569 | 5, 'inside the first buffered region'); | ||
570 | player.currentTime(6); | ||
571 | clock.tick(1); | ||
572 | equal(player.tech_.hls.findCurrentBuffered_().end(0), | ||
573 | 12, 'inside the second buffered region'); | ||
574 | }); | ||
575 | |||
554 | test('recognizes absolute URIs and requests them unmodified', function() { | 576 | test('recognizes absolute URIs and requests them unmodified', function() { |
555 | player.src({ | 577 | player.src({ |
556 | src: 'manifest/absoluteUris.m3u8', | 578 | src: 'manifest/absoluteUris.m3u8', |
... | @@ -2242,6 +2264,38 @@ test('clears the segment buffer on seek', function() { | ... | @@ -2242,6 +2264,38 @@ test('clears the segment buffer on seek', function() { |
2242 | equal(player.tech_.hls.segmentBuffer_.length, 0, 'cleared the segment buffer'); | 2264 | equal(player.tech_.hls.segmentBuffer_.length, 0, 'cleared the segment buffer'); |
2243 | }); | 2265 | }); |
2244 | 2266 | ||
2267 | test('calls mediaSource\'s timestampOffset on discontinuity', function() { | ||
2268 | player.src({ | ||
2269 | src: 'discontinuity.m3u8', | ||
2270 | type: 'application/vnd.apple.mpegurl' | ||
2271 | }); | ||
2272 | openMediaSource(player); | ||
2273 | player.play(); | ||
2274 | player.tech_.buffered = function() { | ||
2275 | return videojs.createTimeRange(0, 10); | ||
2276 | }; | ||
2277 | |||
2278 | requests.pop().respond(200, null, | ||
2279 | '#EXTM3U\n' + | ||
2280 | '#EXTINF:10,0\n' + | ||
2281 | '1.ts\n' + | ||
2282 | '#EXT-X-DISCONTINUITY\n' + | ||
2283 | '#EXTINF:10,0\n' + | ||
2284 | '2.ts\n' + | ||
2285 | '#EXT-X-ENDLIST\n'); | ||
2286 | standardXHRResponse(requests.pop()); // 1.ts | ||
2287 | player.tech_.hls.sourceBuffer.timestampOffset = 0; | ||
2288 | |||
2289 | equal(player.tech_.hls.sourceBuffer.timestampOffset, 0, 'timestampOffset starts at zero'); | ||
2290 | |||
2291 | // play to 6s to trigger the next segment request | ||
2292 | clock.tick(6000); | ||
2293 | |||
2294 | standardXHRResponse(requests.pop()); // 2.ts | ||
2295 | equal(player.tech_.hls.sourceBuffer.timestampOffset, 10, 'timestampOffset set after discontinuity'); | ||
2296 | }); | ||
2297 | |||
2298 | |||
2245 | test('can seek before the source buffer opens', function() { | 2299 | test('can seek before the source buffer opens', function() { |
2246 | player.src({ | 2300 | player.src({ |
2247 | src: 'media.m3u8', | 2301 | src: 'media.m3u8', |
... | @@ -2256,8 +2310,7 @@ test('can seek before the source buffer opens', function() { | ... | @@ -2256,8 +2310,7 @@ test('can seek before the source buffer opens', function() { |
2256 | equal(player.currentTime(), 1, 'seeked'); | 2310 | equal(player.currentTime(), 1, 'seeked'); |
2257 | }); | 2311 | }); |
2258 | 2312 | ||
2259 | // TODO: Decide on proper discontinuity behavior | 2313 | test('sets the timestampOffset after seeking to discontinuity', function() { |
2260 | QUnit.skip('sets the timestampOffset after seeking to discontinuity', function() { | ||
2261 | var bufferEnd; | 2314 | var bufferEnd; |
2262 | player.src({ | 2315 | player.src({ |
2263 | src: 'discontinuity.m3u8', | 2316 | src: 'discontinuity.m3u8', |
... | @@ -2282,11 +2335,11 @@ QUnit.skip('sets the timestampOffset after seeking to discontinuity', function() | ... | @@ -2282,11 +2335,11 @@ QUnit.skip('sets the timestampOffset after seeking to discontinuity', function() |
2282 | player.tech_.setCurrentTime(10); | 2335 | player.tech_.setCurrentTime(10); |
2283 | bufferEnd = 9.9; | 2336 | bufferEnd = 9.9; |
2284 | clock.tick(1); | 2337 | clock.tick(1); |
2285 | standardXHRResponse(requests.pop()); // 1.ts | 2338 | standardXHRResponse(requests.pop()); // 1.ts, again |
2286 | player.tech_.hls.checkBuffer_(); | 2339 | player.tech_.hls.checkBuffer_(); |
2287 | standardXHRResponse(requests.pop()); // 2.ts, again | 2340 | standardXHRResponse(requests.pop()); // 2.ts |
2288 | equal(player.tech_.hls.sourceBuffer.timestampOffset, | 2341 | equal(player.tech_.hls.sourceBuffer.timestampOffset, |
2289 | 10, | 2342 | 9.9, |
2290 | 'set the timestamp offset'); | 2343 | 'set the timestamp offset'); |
2291 | }); | 2344 | }); |
2292 | 2345 | ... | ... |
-
Please register or sign in to post a comment