OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/filters/source_buffer_stream.h" | 5 #include "media/filters/source_buffer_stream.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 typedef StreamParser::BufferQueue BufferQueue; | 24 typedef StreamParser::BufferQueue BufferQueue; |
25 | 25 |
26 static const int kDefaultFramesPerSecond = 30; | 26 static const int kDefaultFramesPerSecond = 30; |
27 static const int kDefaultKeyframesPerSecond = 6; | 27 static const int kDefaultKeyframesPerSecond = 6; |
28 static const uint8 kDataA = 0x11; | 28 static const uint8 kDataA = 0x11; |
29 static const uint8 kDataB = 0x33; | 29 static const uint8 kDataB = 0x33; |
30 static const int kDataSize = 1; | 30 static const int kDataSize = 1; |
31 | 31 |
32 class SourceBufferStreamTest : public testing::Test { | 32 class SourceBufferStreamTest : public testing::Test { |
33 protected: | 33 protected: |
34 SourceBufferStreamTest() { | 34 SourceBufferStreamTest() |
| 35 : accurate_durations_(false) { |
35 video_config_ = TestVideoConfig::Normal(); | 36 video_config_ = TestVideoConfig::Normal(); |
36 SetStreamInfo(kDefaultFramesPerSecond, kDefaultKeyframesPerSecond); | 37 SetStreamInfo(kDefaultFramesPerSecond, kDefaultKeyframesPerSecond); |
37 stream_.reset(new SourceBufferStream(video_config_, log_cb(), true)); | 38 stream_.reset(new SourceBufferStream(video_config_, log_cb(), true)); |
38 } | 39 } |
39 | 40 |
40 void SetMemoryLimit(int buffers_of_data) { | 41 void SetMemoryLimit(int buffers_of_data) { |
41 stream_->set_memory_limit_for_testing(buffers_of_data * kDataSize); | 42 stream_->set_memory_limit_for_testing(buffers_of_data * kDataSize); |
42 } | 43 } |
43 | 44 |
44 void SetStreamInfo(int frames_per_second, int keyframes_per_second) { | 45 void SetStreamInfo(int frames_per_second, int keyframes_per_second) { |
45 frames_per_second_ = frames_per_second; | 46 frames_per_second_ = frames_per_second; |
46 keyframes_per_second_ = keyframes_per_second; | 47 keyframes_per_second_ = keyframes_per_second; |
47 frame_duration_ = ConvertToFrameDuration(frames_per_second); | 48 frame_duration_ = ConvertToFrameDuration(frames_per_second); |
48 } | 49 } |
49 | 50 |
50 void SetTextStream() { | 51 void SetTextStream() { |
51 video_config_ = TestVideoConfig::Invalid(); | 52 video_config_ = TestVideoConfig::Invalid(); |
52 TextTrackConfig config(kTextSubtitles, "", "", ""); | 53 TextTrackConfig config(kTextSubtitles, "", "", ""); |
53 stream_.reset(new SourceBufferStream(config, LogCB(), true)); | 54 stream_.reset(new SourceBufferStream(config, LogCB(), true)); |
54 SetStreamInfo(2, 2); | 55 SetStreamInfo(2, 2); |
55 } | 56 } |
56 | 57 |
57 void SetAudioStream() { | 58 void SetAudioStream() { |
58 video_config_ = TestVideoConfig::Invalid(); | 59 video_config_ = TestVideoConfig::Invalid(); |
| 60 accurate_durations_ = true; |
59 audio_config_.Initialize(kCodecVorbis, | 61 audio_config_.Initialize(kCodecVorbis, |
60 kSampleFormatPlanarF32, | 62 kSampleFormatPlanarF32, |
61 CHANNEL_LAYOUT_STEREO, | 63 CHANNEL_LAYOUT_STEREO, |
62 1000, | 64 1000, |
63 NULL, | 65 NULL, |
64 0, | 66 0, |
65 false, | 67 false, |
66 false, | 68 false, |
67 base::TimeDelta(), | 69 base::TimeDelta(), |
68 0); | 70 0); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 stream_->GetCurrentVideoDecoderConfig(); | 271 stream_->GetCurrentVideoDecoderConfig(); |
270 break; | 272 break; |
271 case SourceBufferStream::kAudio: | 273 case SourceBufferStream::kAudio: |
272 stream_->GetCurrentAudioDecoderConfig(); | 274 stream_->GetCurrentAudioDecoderConfig(); |
273 break; | 275 break; |
274 case SourceBufferStream::kText: | 276 case SourceBufferStream::kText: |
275 stream_->GetCurrentTextTrackConfig(); | 277 stream_->GetCurrentTextTrackConfig(); |
276 break; | 278 break; |
277 } | 279 } |
278 | 280 |
279 EXPECT_EQ("C", timestamps[i]); | 281 if (timestamps[i] == "C") |
| 282 EXPECT_EQ(SourceBufferStream::kConfigChange, status); |
280 | 283 |
281 ss << "C"; | 284 ss << "C"; |
282 continue; | 285 continue; |
283 } | 286 } |
284 | 287 |
285 EXPECT_EQ(SourceBufferStream::kSuccess, status); | 288 EXPECT_EQ(SourceBufferStream::kSuccess, status); |
286 if (status != SourceBufferStream::kSuccess) | 289 if (status != SourceBufferStream::kSuccess) |
287 break; | 290 break; |
288 | 291 |
289 ss << buffer->GetDecodeTimestamp().InMilliseconds(); | 292 ss << buffer->GetDecodeTimestamp().InMilliseconds(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 if (is_keyframe) { | 400 if (is_keyframe) { |
398 presentation_timestamp = timestamp; | 401 presentation_timestamp = timestamp; |
399 } else if ((position - 1) % keyframe_interval == 0) { | 402 } else if ((position - 1) % keyframe_interval == 0) { |
400 // This is the P-frame (first frame following the I-frame) | 403 // This is the P-frame (first frame following the I-frame) |
401 presentation_timestamp = | 404 presentation_timestamp = |
402 (timestamp + frame_duration_ * (keyframe_interval - 2)); | 405 (timestamp + frame_duration_ * (keyframe_interval - 2)); |
403 } else { | 406 } else { |
404 presentation_timestamp = timestamp - frame_duration_; | 407 presentation_timestamp = timestamp - frame_duration_; |
405 } | 408 } |
406 buffer->set_timestamp(presentation_timestamp); | 409 buffer->set_timestamp(presentation_timestamp); |
407 buffer->set_duration(frame_duration_); | 410 if (accurate_durations_) |
| 411 buffer->set_duration(frame_duration_); |
408 | 412 |
409 queue.push_back(buffer); | 413 queue.push_back(buffer); |
410 } | 414 } |
411 if (!queue.empty()) | 415 if (!queue.empty()) |
412 EXPECT_EQ(expect_success, stream_->Append(queue)); | 416 EXPECT_EQ(expect_success, stream_->Append(queue)); |
413 } | 417 } |
414 | 418 |
415 void UpdateLastBufferDuration(base::TimeDelta current_dts, | |
416 BufferQueue* buffers) { | |
417 if (buffers->empty() || buffers->back()->duration() > base::TimeDelta()) | |
418 return; | |
419 | |
420 base::TimeDelta last_dts = buffers->back()->GetDecodeTimestamp(); | |
421 DCHECK(current_dts >= last_dts); | |
422 buffers->back()->set_duration(current_dts - last_dts); | |
423 } | |
424 | |
425 // StringToBufferQueue() allows for the generation of StreamParserBuffers from | 419 // StringToBufferQueue() allows for the generation of StreamParserBuffers from |
426 // coded strings of timestamps separated by spaces. Supported syntax: | 420 // coded strings of timestamps separated by spaces. Supported syntax: |
427 // | 421 // |
428 // ## or ##Dyy: | 422 // ##: |
429 // Generates a StreamParserBuffer with decode timestamp ##. E.g., "0 1 2 3". | 423 // Generates a StreamParserBuffer with decode timestamp ##. E.g., "0 1 2 3". |
430 // The form with the 'D' sets the decode timestamp to ## and the duration to | |
431 // yy milliseconds. | |
432 // | 424 // |
433 // ##K or ##DyyK: | 425 // ##K: |
434 // Indicates the buffer with timestamp ## reflects a keyframe. E.g., "0K 1". | 426 // Indicates the buffer with timestamp ## reflects a keyframe. E.g., "0K 1". |
435 // The form with the 'D' indicates a buffer with timestamp ##, duration yy, | |
436 // and is marked as a keyframe. | |
437 // | 427 // |
438 // S(a# ... y# z#) | 428 // S(a# ... y# z#) |
439 // Indicates a splice frame buffer should be created with timestamp z#. The | 429 // Indicates a splice frame buffer should be created with timestamp z#. The |
440 // preceding timestamps a# ... y# will be treated as the fade out preroll for | 430 // preceding timestamps a# ... y# will be treated as the fade out preroll for |
441 // the splice frame. If a timestamp within the preroll ends with C the config | 431 // the splice frame. If a timestamp within the preroll ends with C the config |
442 // id to use for that and subsequent preroll appends is incremented by one. | 432 // id to use for that and subsequent preroll appends is incremented by one. |
443 // The config id for non-splice frame appends will not be affected. | 433 // The config id for non-splice frame appends will not be affected. |
444 BufferQueue StringToBufferQueue(const std::string& buffers_to_append) { | 434 BufferQueue StringToBufferQueue(const std::string& buffers_to_append) { |
445 std::vector<std::string> timestamps; | 435 std::vector<std::string> timestamps; |
446 base::SplitString(buffers_to_append, ' ', ×tamps); | 436 base::SplitString(buffers_to_append, ' ', ×tamps); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); | 472 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); |
483 } | 473 } |
484 // Handle preroll buffers. | 474 // Handle preroll buffers. |
485 if (EndsWith(timestamps[i], "P", true)) { | 475 if (EndsWith(timestamps[i], "P", true)) { |
486 is_keyframe = true; | 476 is_keyframe = true; |
487 has_preroll = true; | 477 has_preroll = true; |
488 // Remove the "P" off of the token. | 478 // Remove the "P" off of the token. |
489 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); | 479 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); |
490 } | 480 } |
491 | 481 |
492 int time_in_ms = 0; | 482 int time_in_ms; |
493 int duration_in_ms = 0; | |
494 size_t duration_pos = timestamps[i].find('D'); | |
495 if (duration_pos != std::string::npos) { | |
496 CHECK(base::StringToInt(timestamps[i].substr(duration_pos + 1), | |
497 &duration_in_ms)); | |
498 timestamps[i] = timestamps[i].substr(0, duration_pos); | |
499 } | |
500 | |
501 CHECK(base::StringToInt(timestamps[i], &time_in_ms)); | 483 CHECK(base::StringToInt(timestamps[i], &time_in_ms)); |
502 | 484 |
503 // Create buffer. Buffer type and track ID are meaningless to these tests. | 485 // Create buffer. Buffer type and track ID are meaningless to these tests. |
504 scoped_refptr<StreamParserBuffer> buffer = | 486 scoped_refptr<StreamParserBuffer> buffer = |
505 StreamParserBuffer::CopyFrom(&kDataA, kDataSize, is_keyframe, | 487 StreamParserBuffer::CopyFrom(&kDataA, kDataSize, is_keyframe, |
506 DemuxerStream::AUDIO, 0); | 488 DemuxerStream::AUDIO, 0); |
507 base::TimeDelta timestamp = | 489 base::TimeDelta timestamp = |
508 base::TimeDelta::FromMilliseconds(time_in_ms); | 490 base::TimeDelta::FromMilliseconds(time_in_ms); |
509 buffer->set_timestamp(timestamp); | 491 buffer->set_timestamp(timestamp); |
510 if (duration_in_ms) | 492 if (accurate_durations_) |
511 buffer->set_duration(base::TimeDelta::FromMilliseconds(duration_in_ms)); | 493 buffer->set_duration(frame_duration_); |
512 buffer->SetDecodeTimestamp(timestamp); | 494 buffer->SetDecodeTimestamp(timestamp); |
513 | 495 |
514 // Simulate preroll buffers by just generating another buffer and sticking | 496 // Simulate preroll buffers by just generating another buffer and sticking |
515 // it as the preroll. | 497 // it as the preroll. |
516 if (has_preroll) { | 498 if (has_preroll) { |
517 scoped_refptr<StreamParserBuffer> preroll_buffer = | 499 scoped_refptr<StreamParserBuffer> preroll_buffer = |
518 StreamParserBuffer::CopyFrom( | 500 StreamParserBuffer::CopyFrom( |
519 &kDataA, kDataSize, is_keyframe, DemuxerStream::AUDIO, 0); | 501 &kDataA, kDataSize, is_keyframe, DemuxerStream::AUDIO, 0); |
520 preroll_buffer->set_duration(frame_duration_); | 502 preroll_buffer->set_duration(frame_duration_); |
521 buffer->SetPrerollBuffer(preroll_buffer); | 503 buffer->SetPrerollBuffer(preroll_buffer); |
522 } | 504 } |
523 | 505 |
524 if (splice_frame) { | 506 if (splice_frame) { |
525 if (!pre_splice_buffers.empty()) { | 507 if (!pre_splice_buffers.empty()) { |
526 // Enforce strictly monotonically increasing timestamps. | 508 // Enforce strictly monotonically increasing timestamps. |
527 CHECK_GT( | 509 CHECK_GT( |
528 timestamp.InMicroseconds(), | 510 timestamp.InMicroseconds(), |
529 pre_splice_buffers.back()->GetDecodeTimestamp().InMicroseconds()); | 511 pre_splice_buffers.back()->GetDecodeTimestamp().InMicroseconds()); |
530 } | 512 } |
531 buffer->SetConfigId(splice_config_id); | 513 buffer->SetConfigId(splice_config_id); |
532 UpdateLastBufferDuration(buffer->GetDecodeTimestamp(), | |
533 &pre_splice_buffers); | |
534 pre_splice_buffers.push_back(buffer); | 514 pre_splice_buffers.push_back(buffer); |
535 continue; | 515 continue; |
536 } | 516 } |
537 | 517 |
538 if (last_splice_frame) { | 518 if (last_splice_frame) { |
539 // Require at least one additional buffer for a splice. | 519 // Require at least one additional buffer for a splice. |
540 CHECK(!pre_splice_buffers.empty()); | 520 CHECK(!pre_splice_buffers.empty()); |
541 buffer->SetConfigId(splice_config_id); | 521 buffer->SetConfigId(splice_config_id); |
542 buffer->ConvertToSpliceBuffer(pre_splice_buffers); | 522 buffer->ConvertToSpliceBuffer(pre_splice_buffers); |
543 pre_splice_buffers.clear(); | 523 pre_splice_buffers.clear(); |
544 } | 524 } |
545 | 525 |
546 UpdateLastBufferDuration(buffer->GetDecodeTimestamp(), &buffers); | |
547 buffers.push_back(buffer); | 526 buffers.push_back(buffer); |
548 } | 527 } |
549 | |
550 // If the last buffer doesn't have a duration, assume it is the | |
551 // same as the second to last buffer. | |
552 if (buffers.size() >= 2 && | |
553 buffers.back()->duration() <= base::TimeDelta()) { | |
554 buffers.back()->set_duration( | |
555 buffers[buffers.size() - 2]->duration()); | |
556 } | |
557 | |
558 return buffers; | 528 return buffers; |
559 } | 529 } |
560 | 530 |
561 void AppendBuffers(const std::string& buffers_to_append, | 531 void AppendBuffers(const std::string& buffers_to_append, |
562 bool start_new_segment, | 532 bool start_new_segment, |
563 base::TimeDelta segment_start_timestamp, | 533 base::TimeDelta segment_start_timestamp, |
564 bool one_by_one, | 534 bool one_by_one, |
565 bool expect_success) { | 535 bool expect_success) { |
566 BufferQueue buffers = StringToBufferQueue(buffers_to_append); | 536 BufferQueue buffers = StringToBufferQueue(buffers_to_append); |
567 | 537 |
(...skipping 20 matching lines...) Expand all Loading... |
588 } | 558 } |
589 } | 559 } |
590 | 560 |
591 void DebugMediaLog(const std::string& log) { | 561 void DebugMediaLog(const std::string& log) { |
592 DVLOG(1) << log; | 562 DVLOG(1) << log; |
593 } | 563 } |
594 | 564 |
595 int frames_per_second_; | 565 int frames_per_second_; |
596 int keyframes_per_second_; | 566 int keyframes_per_second_; |
597 base::TimeDelta frame_duration_; | 567 base::TimeDelta frame_duration_; |
| 568 // TODO(dalecurtis): It's silly to have this, all tests should use accurate |
| 569 // durations instead. However, currently all tests are written with an |
| 570 // expectation of 0 duration, so it's an involved change. |
| 571 bool accurate_durations_; |
598 DISALLOW_COPY_AND_ASSIGN(SourceBufferStreamTest); | 572 DISALLOW_COPY_AND_ASSIGN(SourceBufferStreamTest); |
599 }; | 573 }; |
600 | 574 |
601 TEST_F(SourceBufferStreamTest, Append_SingleRange) { | 575 TEST_F(SourceBufferStreamTest, Append_SingleRange) { |
602 // Append 15 buffers at positions 0 through 14. | 576 // Append 15 buffers at positions 0 through 14. |
603 NewSegmentAppend(0, 15); | 577 NewSegmentAppend(0, 15); |
604 | 578 |
605 // Check expected range. | 579 // Check expected range. |
606 CheckExpectedRanges("{ [0,14) }"); | 580 CheckExpectedRanges("{ [0,14) }"); |
607 // Check buffers in range. | 581 // Check buffers in range. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 // Append a segment with a start timestamp of 0, but the first | 684 // Append a segment with a start timestamp of 0, but the first |
711 // buffer starts at 30ms. This can happen in muxed content where the | 685 // buffer starts at 30ms. This can happen in muxed content where the |
712 // audio starts before the first frame. | 686 // audio starts before the first frame. |
713 NewSegmentAppend(base::TimeDelta::FromMilliseconds(0), "30K 60K 90K 120K"); | 687 NewSegmentAppend(base::TimeDelta::FromMilliseconds(0), "30K 60K 90K 120K"); |
714 | 688 |
715 CheckExpectedRangesByTimestamp("{ [0,150) }"); | 689 CheckExpectedRangesByTimestamp("{ [0,150) }"); |
716 | 690 |
717 // Completely overlap the old buffers, with a segment that starts | 691 // Completely overlap the old buffers, with a segment that starts |
718 // after the old segment start timestamp, but before the timestamp | 692 // after the old segment start timestamp, but before the timestamp |
719 // of the first buffer in the segment. | 693 // of the first buffer in the segment. |
720 NewSegmentAppend("20K 50K 80K 110D10K"); | 694 NewSegmentAppend("20K 50K 80K 110K"); |
721 | 695 |
722 // Verify that the buffered ranges are updated properly and we don't crash. | 696 // Verify that the buffered ranges are updated properly and we don't crash. |
723 CheckExpectedRangesByTimestamp("{ [20,150) }"); | 697 CheckExpectedRangesByTimestamp("{ [20,150) }"); |
724 | 698 |
725 SeekToTimestamp(base::TimeDelta::FromMilliseconds(20)); | 699 SeekToTimestamp(base::TimeDelta::FromMilliseconds(20)); |
726 CheckExpectedBuffers("20K 50K 80K 110K 120K"); | 700 CheckExpectedBuffers("20K 50K 80K 110K 120K"); |
727 } | 701 } |
728 | 702 |
729 TEST_F(SourceBufferStreamTest, Complete_Overlap_EdgeCase) { | 703 TEST_F(SourceBufferStreamTest, Complete_Overlap_EdgeCase) { |
730 // Make each frame a keyframe so that it's okay to overlap frames at any point | 704 // Make each frame a keyframe so that it's okay to overlap frames at any point |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 // new : *0K* | 772 // new : *0K* |
799 // after: *0K* *120K* 150K | 773 // after: *0K* *120K* 150K |
800 // track: | 774 // track: |
801 TEST_F(SourceBufferStreamTest, End_Overlap_SingleBuffer) { | 775 TEST_F(SourceBufferStreamTest, End_Overlap_SingleBuffer) { |
802 // Seek to start of stream. | 776 // Seek to start of stream. |
803 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); | 777 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); |
804 | 778 |
805 NewSegmentAppend("0K 30 60 90 120K 150"); | 779 NewSegmentAppend("0K 30 60 90 120K 150"); |
806 CheckExpectedRangesByTimestamp("{ [0,180) }"); | 780 CheckExpectedRangesByTimestamp("{ [0,180) }"); |
807 | 781 |
808 NewSegmentAppend("0D30K"); | 782 NewSegmentAppend("0K"); |
809 CheckExpectedRangesByTimestamp("{ [0,30) [120,180) }"); | 783 CheckExpectedRangesByTimestamp("{ [0,30) [120,180) }"); |
810 | 784 |
811 CheckExpectedBuffers("0K"); | 785 CheckExpectedBuffers("0K"); |
812 CheckNoNextBuffer(); | 786 CheckNoNextBuffer(); |
813 } | 787 } |
814 | 788 |
815 TEST_F(SourceBufferStreamTest, Complete_Overlap_Several) { | 789 TEST_F(SourceBufferStreamTest, Complete_Overlap_Several) { |
816 // Append 2 buffers at positions 5 through 6. | 790 // Append 2 buffers at positions 5 through 6. |
817 NewSegmentAppend(5, 2); | 791 NewSegmentAppend(5, 2); |
818 | 792 |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 CheckExpectedBuffers(0, 9, &kDataB); | 1541 CheckExpectedBuffers(0, 9, &kDataB); |
1568 } | 1542 } |
1569 | 1543 |
1570 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_DeleteGroup) { | 1544 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_DeleteGroup) { |
1571 NewSegmentAppendOneByOne("10K 40 70 100 130K"); | 1545 NewSegmentAppendOneByOne("10K 40 70 100 130K"); |
1572 CheckExpectedRangesByTimestamp("{ [10,160) }"); | 1546 CheckExpectedRangesByTimestamp("{ [10,160) }"); |
1573 | 1547 |
1574 // Seek to 130ms. | 1548 // Seek to 130ms. |
1575 SeekToTimestamp(base::TimeDelta::FromMilliseconds(130)); | 1549 SeekToTimestamp(base::TimeDelta::FromMilliseconds(130)); |
1576 | 1550 |
1577 // Overlap with a new segment from 0 to 130ms. | 1551 // Overlap with a new segment from 0 to 120ms. |
1578 NewSegmentAppendOneByOne("0K 120D10"); | 1552 NewSegmentAppendOneByOne("0K 120"); |
1579 | 1553 |
1580 // Next buffer should still be 130ms. | 1554 // Next buffer should still be 130ms. |
1581 CheckExpectedBuffers("130K"); | 1555 CheckExpectedBuffers("130K"); |
1582 | 1556 |
1583 // Check the final buffers is correct. | 1557 // Check the final buffers is correct. |
1584 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); | 1558 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); |
1585 CheckExpectedBuffers("0K 120 130K"); | 1559 CheckExpectedBuffers("0K 120 130K"); |
1586 } | 1560 } |
1587 | 1561 |
1588 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_BetweenMediaSegments) { | 1562 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_BetweenMediaSegments) { |
(...skipping 10 matching lines...) Expand all Loading... |
1599 // Check the final buffers is correct; the keyframe at 110ms should be | 1573 // Check the final buffers is correct; the keyframe at 110ms should be |
1600 // deleted. | 1574 // deleted. |
1601 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); | 1575 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); |
1602 CheckExpectedBuffers("0K 30 60 90 120K 150 180 210"); | 1576 CheckExpectedBuffers("0K 30 60 90 120K 150 180 210"); |
1603 } | 1577 } |
1604 | 1578 |
1605 // old : 10K 40 *70* 100K 125 130K | 1579 // old : 10K 40 *70* 100K 125 130K |
1606 // new : 0K 30 60 90 120K | 1580 // new : 0K 30 60 90 120K |
1607 // after: 0K 30 60 90 *120K* 130K | 1581 // after: 0K 30 60 90 *120K* 130K |
1608 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer) { | 1582 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer) { |
1609 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K"); | 1583 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); |
1610 CheckExpectedRangesByTimestamp("{ [10,160) }"); | 1584 CheckExpectedRangesByTimestamp("{ [10,160) }"); |
1611 | 1585 |
1612 // Seek to 70ms. | 1586 // Seek to 70ms. |
1613 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); | 1587 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); |
1614 CheckExpectedBuffers("10K 40"); | 1588 CheckExpectedBuffers("10K 40"); |
1615 | 1589 |
1616 // Overlap with a new segment from 0 to 130ms. | 1590 // Overlap with a new segment from 0 to 120ms. |
1617 NewSegmentAppendOneByOne("0K 30 60 90 120D10K"); | 1591 NewSegmentAppendOneByOne("0K 30 60 90 120K"); |
1618 CheckExpectedRangesByTimestamp("{ [0,160) }"); | 1592 CheckExpectedRangesByTimestamp("{ [0,160) }"); |
1619 | 1593 |
1620 // Should return frame 70ms from the track buffer, then switch | 1594 // Should return frames 70ms and 100ms from the track buffer, then switch |
1621 // to the new data at 120K, then switch back to the old data at 130K. The | 1595 // to the new data at 120K, then switch back to the old data at 130K. The |
1622 // frame at 125ms that depended on keyframe 100ms should have been deleted. | 1596 // frame at 125ms that depended on keyframe 100ms should have been deleted. |
1623 CheckExpectedBuffers("70 120K 130K"); | 1597 CheckExpectedBuffers("70 100K 120K 130K"); |
1624 | 1598 |
1625 // Check the final result: should not include data from the track buffer. | 1599 // Check the final result: should not include data from the track buffer. |
1626 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); | 1600 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); |
1627 CheckExpectedBuffers("0K 30 60 90 120K 130K"); | 1601 CheckExpectedBuffers("0K 30 60 90 120K 130K"); |
1628 } | 1602 } |
1629 | 1603 |
1630 // Overlap the next keyframe after the end of the track buffer with a new | 1604 // Overlap the next keyframe after the end of the track buffer with a new |
1631 // keyframe. | 1605 // keyframe. |
1632 // old : 10K 40 *70* 100K 125 130K | 1606 // old : 10K 40 *70* 100K 125 130K |
1633 // new : 0K 30 60 90 120K | 1607 // new : 0K 30 60 90 120K |
1634 // after: 0K 30 60 90 *120K* 130K | 1608 // after: 0K 30 60 90 *120K* 130K |
1635 // track: 70 | 1609 // track: 70 100K |
1636 // new : 110K 130 | 1610 // new : 110K 130 |
1637 // after: 0K 30 60 90 *110K* 130 | 1611 // after: 0K 30 60 90 *110K* 130 |
1638 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer2) { | 1612 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer2) { |
1639 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K"); | 1613 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); |
1640 CheckExpectedRangesByTimestamp("{ [10,160) }"); | 1614 CheckExpectedRangesByTimestamp("{ [10,160) }"); |
1641 | 1615 |
1642 // Seek to 70ms. | 1616 // Seek to 70ms. |
1643 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); | 1617 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); |
1644 CheckExpectedBuffers("10K 40"); | 1618 CheckExpectedBuffers("10K 40"); |
1645 | 1619 |
1646 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track | 1620 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track |
1647 // buffer. | 1621 // buffer. |
1648 NewSegmentAppendOneByOne("0K 30 60 90 120D10K"); | 1622 NewSegmentAppendOneByOne("0K 30 60 90 120K"); |
1649 CheckExpectedRangesByTimestamp("{ [0,160) }"); | 1623 CheckExpectedRangesByTimestamp("{ [0,160) }"); |
1650 | 1624 |
1651 // Now overlap the keyframe at 120ms. | 1625 // Now overlap the keyframe at 120ms. |
1652 NewSegmentAppendOneByOne("110K 130"); | 1626 NewSegmentAppendOneByOne("110K 130"); |
1653 | 1627 |
1654 // Should return frame 70ms from the track buffer. Then it should | 1628 // Should expect buffers 70ms and 100ms from the track buffer. Then it should |
1655 // return the keyframe after the track buffer, which is at 110ms. | 1629 // return the keyframe after the track buffer, which is at 110ms. |
1656 CheckExpectedBuffers("70 110K 130"); | 1630 CheckExpectedBuffers("70 100K 110K 130"); |
1657 } | 1631 } |
1658 | 1632 |
1659 // Overlap the next keyframe after the end of the track buffer without a | 1633 // Overlap the next keyframe after the end of the track buffer without a |
1660 // new keyframe. | 1634 // new keyframe. |
1661 // old : 10K 40 *70* 100K 125 130K | 1635 // old : 10K 40 *70* 100K 125 130K |
1662 // new : 0K 30 60 90 120K | 1636 // new : 0K 30 60 90 120K |
1663 // after: 0K 30 60 90 *120K* 130K | 1637 // after: 0K 30 60 90 *120K* 130K |
1664 // track: 70 | 1638 // track: 70 100K |
1665 // new : 50K 80 110 140 | 1639 // new : 50K 80 110 140 |
1666 // after: 0K 30 50K 80 110 140 * (waiting for keyframe) | 1640 // after: 0K 30 50K 80 110 140 * (waiting for keyframe) |
1667 // track: 70 | 1641 // track: 70 100K 120K 130K |
1668 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer3) { | 1642 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer3) { |
1669 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K"); | 1643 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); |
1670 CheckExpectedRangesByTimestamp("{ [10,160) }"); | 1644 CheckExpectedRangesByTimestamp("{ [10,160) }"); |
1671 | 1645 |
1672 // Seek to 70ms. | 1646 // Seek to 70ms. |
1673 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); | 1647 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); |
1674 CheckExpectedBuffers("10K 40"); | 1648 CheckExpectedBuffers("10K 40"); |
1675 | 1649 |
1676 // Overlap with a new segment from 0 to 120ms; 70ms goes in track buffer. | 1650 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track |
1677 NewSegmentAppendOneByOne("0K 30 60 90 120D10K"); | 1651 // buffer. |
| 1652 NewSegmentAppendOneByOne("0K 30 60 90 120K"); |
1678 CheckExpectedRangesByTimestamp("{ [0,160) }"); | 1653 CheckExpectedRangesByTimestamp("{ [0,160) }"); |
1679 | 1654 |
1680 // Now overlap the keyframe at 120ms and 130ms. | 1655 // Now overlap the keyframe at 120ms. There's no keyframe after 70ms, so 120ms |
| 1656 // and 130ms go into the track buffer. |
1681 NewSegmentAppendOneByOne("50K 80 110 140"); | 1657 NewSegmentAppendOneByOne("50K 80 110 140"); |
1682 CheckExpectedRangesByTimestamp("{ [0,170) }"); | |
1683 | 1658 |
1684 // Should have all the buffers from the track buffer, then stall. | 1659 // Should have all the buffers from the track buffer, then stall. |
1685 CheckExpectedBuffers("70"); | 1660 CheckExpectedBuffers("70 100K 120K 130K"); |
1686 CheckNoNextBuffer(); | 1661 CheckNoNextBuffer(); |
1687 | 1662 |
1688 // Appending a keyframe should fulfill the read. | 1663 // Appending a keyframe should fulfill the read. |
1689 AppendBuffersOneByOne("150D30K"); | 1664 AppendBuffersOneByOne("150K"); |
1690 CheckExpectedBuffers("150K"); | 1665 CheckExpectedBuffers("150K"); |
1691 CheckNoNextBuffer(); | 1666 CheckNoNextBuffer(); |
1692 } | 1667 } |
1693 | 1668 |
1694 // Overlap the next keyframe after the end of the track buffer with a keyframe | 1669 // Overlap the next keyframe after the end of the track buffer with a keyframe |
1695 // that comes before the end of the track buffer. | 1670 // that comes before the end of the track buffer. |
1696 // old : 10K 40 *70* 100K 125 130K | 1671 // old : 10K 40 *70* 100K 125 130K |
1697 // new : 0K 30 60 90 120K | 1672 // new : 0K 30 60 90 120K |
1698 // after: 0K 30 60 90 *120K* 130K | 1673 // after: 0K 30 60 90 *120K* 130K |
1699 // track: 70 | 1674 // track: 70 100K |
1700 // new : 80K 110 140 | 1675 // new : 80K 110 140 |
1701 // after: 0K 30 60 *80K* 110 140 | 1676 // after: 0K 30 60 *80K* 110 140 |
1702 // track: 70 | 1677 // track: 70 |
1703 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer4) { | 1678 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer4) { |
1704 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K"); | 1679 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); |
1705 CheckExpectedRangesByTimestamp("{ [10,160) }"); | 1680 CheckExpectedRangesByTimestamp("{ [10,160) }"); |
1706 | 1681 |
1707 // Seek to 70ms. | 1682 // Seek to 70ms. |
1708 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); | 1683 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); |
1709 CheckExpectedBuffers("10K 40"); | 1684 CheckExpectedBuffers("10K 40"); |
1710 | 1685 |
1711 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track | 1686 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track |
1712 // buffer. | 1687 // buffer. |
1713 NewSegmentAppendOneByOne("0K 30 60 90 120D10K"); | 1688 NewSegmentAppendOneByOne("0K 30 60 90 120K"); |
1714 CheckExpectedRangesByTimestamp("{ [0,160) }"); | 1689 CheckExpectedRangesByTimestamp("{ [0,160) }"); |
1715 | 1690 |
1716 // Now append a keyframe at 80ms. | 1691 // Now append a keyframe at 80ms. |
1717 NewSegmentAppendOneByOne("80K 110 140"); | 1692 NewSegmentAppendOneByOne("80K 110 140"); |
1718 | 1693 |
1719 CheckExpectedBuffers("70 80K 110 140"); | 1694 CheckExpectedBuffers("70 80K 110 140"); |
1720 CheckNoNextBuffer(); | 1695 CheckNoNextBuffer(); |
1721 } | 1696 } |
1722 | 1697 |
1723 // Overlap the next keyframe after the end of the track buffer with a keyframe | 1698 // Overlap the next keyframe after the end of the track buffer with a keyframe |
1724 // that comes before the end of the track buffer, when the selected stream was | 1699 // that comes before the end of the track buffer, when the selected stream was |
1725 // waiting for the next keyframe. | 1700 // waiting for the next keyframe. |
1726 // old : 10K 40 *70* 100K | 1701 // old : 10K 40 *70* 100K |
1727 // new : 0K 30 60 90 120 | 1702 // new : 0K 30 60 90 120 |
1728 // after: 0K 30 60 90 120 * (waiting for keyframe) | 1703 // after: 0K 30 60 90 120 * (waiting for keyframe) |
1729 // track: 70 | 1704 // track: 70 100K |
1730 // new : 80K 110 140 | 1705 // new : 80K 110 140 |
1731 // after: 0K 30 60 *80K* 110 140 | 1706 // after: 0K 30 60 *80K* 110 140 |
1732 // track: 70 | 1707 // track: 70 |
1733 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer5) { | 1708 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer5) { |
1734 NewSegmentAppendOneByOne("10K 40 70 100K"); | 1709 NewSegmentAppendOneByOne("10K 40 70 100K"); |
1735 CheckExpectedRangesByTimestamp("{ [10,130) }"); | 1710 CheckExpectedRangesByTimestamp("{ [10,130) }"); |
1736 | 1711 |
1737 // Seek to 70ms. | 1712 // Seek to 70ms. |
1738 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); | 1713 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); |
1739 CheckExpectedBuffers("10K 40"); | 1714 CheckExpectedBuffers("10K 40"); |
1740 | 1715 |
1741 // Overlap with a new segment from 0 to 120ms; 70ms goes in track | 1716 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track |
1742 // buffer. | 1717 // buffer. |
1743 NewSegmentAppendOneByOne("0K 30 60 90 120"); | 1718 NewSegmentAppendOneByOne("0K 30 60 90 120"); |
1744 CheckExpectedRangesByTimestamp("{ [0,150) }"); | 1719 CheckExpectedRangesByTimestamp("{ [0,150) }"); |
1745 | 1720 |
1746 // Now append a keyframe at 80ms. | 1721 // Now append a keyframe at 80ms. The buffer at 100ms should be deleted from |
| 1722 // the track buffer. |
1747 NewSegmentAppendOneByOne("80K 110 140"); | 1723 NewSegmentAppendOneByOne("80K 110 140"); |
1748 | 1724 |
1749 CheckExpectedBuffers("70 80K 110 140"); | 1725 CheckExpectedBuffers("70 80K 110 140"); |
1750 CheckNoNextBuffer(); | 1726 CheckNoNextBuffer(); |
1751 } | 1727 } |
1752 | 1728 |
1753 // Test that appending to a different range while there is data in | 1729 // Test that appending to a different range while there is data in |
1754 // the track buffer doesn't affect the selected range or track buffer state. | 1730 // the track buffer doesn't affect the selected range or track buffer state. |
1755 // old : 10K 40 *70* 100K 125 130K ... 200K 230 | 1731 // old : 10K 40 *70* 100K 125 130K ... 200K 230 |
1756 // new : 0K 30 60 90 120K | 1732 // new : 0K 30 60 90 120K |
1757 // after: 0K 30 60 90 *120K* 130K ... 200K 230 | 1733 // after: 0K 30 60 90 *120K* 130K ... 200K 230 |
1758 // track: 70 | 1734 // track: 70 100K |
1759 // old : 0K 30 60 90 *120K* 130K ... 200K 230 | 1735 // old : 0K 30 60 90 *120K* 130K ... 200K 230 |
1760 // new : 260K 290 | 1736 // new : 260K 290 |
1761 // after: 0K 30 60 90 *120K* 130K ... 200K 230 260K 290 | 1737 // after: 0K 30 60 90 *120K* 130K ... 200K 230 260K 290 |
1762 // track: 70 | 1738 // track: 70 100K |
1763 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer6) { | 1739 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer6) { |
1764 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K"); | 1740 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); |
1765 NewSegmentAppendOneByOne("200K 230"); | 1741 NewSegmentAppendOneByOne("200K 230"); |
1766 CheckExpectedRangesByTimestamp("{ [10,160) [200,260) }"); | 1742 CheckExpectedRangesByTimestamp("{ [10,160) [200,260) }"); |
1767 | 1743 |
1768 // Seek to 70ms. | 1744 // Seek to 70ms. |
1769 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); | 1745 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); |
1770 CheckExpectedBuffers("10K 40"); | 1746 CheckExpectedBuffers("10K 40"); |
1771 | 1747 |
1772 // Overlap with a new segment from 0 to 120ms. | 1748 // Overlap with a new segment from 0 to 120ms. |
1773 NewSegmentAppendOneByOne("0K 30 60 90 120D10K"); | 1749 NewSegmentAppendOneByOne("0K 30 60 90 120K"); |
1774 CheckExpectedRangesByTimestamp("{ [0,160) [200,260) }"); | 1750 CheckExpectedRangesByTimestamp("{ [0,160) [200,260) }"); |
1775 | 1751 |
1776 // Verify that 70 gets read out of the track buffer. | 1752 // Verify that 70 gets read out of the track buffer. |
1777 CheckExpectedBuffers("70"); | 1753 CheckExpectedBuffers("70"); |
1778 | 1754 |
1779 // Append more data to the unselected range. | 1755 // Append more data to the unselected range. |
1780 NewSegmentAppendOneByOne("260K 290"); | 1756 NewSegmentAppendOneByOne("260K 290"); |
1781 CheckExpectedRangesByTimestamp("{ [0,160) [200,320) }"); | 1757 CheckExpectedRangesByTimestamp("{ [0,160) [200,320) }"); |
1782 | 1758 |
1783 CheckExpectedBuffers("120K 130K"); | 1759 CheckExpectedBuffers("100K 120K 130K"); |
1784 CheckNoNextBuffer(); | 1760 CheckNoNextBuffer(); |
1785 | 1761 |
1786 // Check the final result: should not include data from the track buffer. | 1762 // Check the final result: should not include data from the track buffer. |
1787 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); | 1763 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); |
1788 CheckExpectedBuffers("0K 30 60 90 120K 130K"); | 1764 CheckExpectedBuffers("0K 30 60 90 120K 130K"); |
1789 CheckNoNextBuffer(); | 1765 CheckNoNextBuffer(); |
1790 } | 1766 } |
1791 | 1767 |
1792 TEST_F(SourceBufferStreamTest, Seek_Keyframe) { | 1768 TEST_F(SourceBufferStreamTest, Seek_Keyframe) { |
1793 // Append 6 buffers at positions 0 through 5. | 1769 // Append 6 buffers at positions 0 through 5. |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 // GetNextBuffer() skips to second GOP in the newly appended data instead | 2115 // GetNextBuffer() skips to second GOP in the newly appended data instead |
2140 // of returning two buffers with the same timestamp. | 2116 // of returning two buffers with the same timestamp. |
2141 TEST_F(SourceBufferStreamTest, GetNextBuffer_ExhaustThenStartOverlap2) { | 2117 TEST_F(SourceBufferStreamTest, GetNextBuffer_ExhaustThenStartOverlap2) { |
2142 NewSegmentAppend("0K 30 60 90 120"); | 2118 NewSegmentAppend("0K 30 60 90 120"); |
2143 | 2119 |
2144 Seek(0); | 2120 Seek(0); |
2145 CheckExpectedBuffers("0K 30 60 90 120"); | 2121 CheckExpectedBuffers("0K 30 60 90 120"); |
2146 CheckNoNextBuffer(); | 2122 CheckNoNextBuffer(); |
2147 | 2123 |
2148 // Append a keyframe with the same timestamp as the last buffer output. | 2124 // Append a keyframe with the same timestamp as the last buffer output. |
2149 NewSegmentAppend("120D30K"); | 2125 NewSegmentAppend("120K"); |
2150 CheckNoNextBuffer(); | 2126 CheckNoNextBuffer(); |
2151 | 2127 |
2152 // Append the rest of the segment and make sure that buffers are returned | 2128 // Append the rest of the segment and make sure that buffers are returned |
2153 // from the first GOP after 120. | 2129 // from the first GOP after 120. |
2154 AppendBuffers("150 180 210K 240"); | 2130 AppendBuffers("150 180 210K 240"); |
2155 CheckExpectedBuffers("210K 240"); | 2131 CheckExpectedBuffers("210K 240"); |
2156 | 2132 |
2157 // Seek to the beginning and verify the contents of the source buffer. | 2133 // Seek to the beginning and verify the contents of the source buffer. |
2158 Seek(0); | 2134 Seek(0); |
2159 CheckExpectedBuffers("0K 30 60 90 120K 150 180 210K 240"); | 2135 CheckExpectedBuffers("0K 30 60 90 120K 150 180 210K 240"); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2567 // Test saving the last GOP appended when this GOP is the only GOP in its range. | 2543 // Test saving the last GOP appended when this GOP is the only GOP in its range. |
2568 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP) { | 2544 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP) { |
2569 // Set memory limit to 3 and make sure the 4-byte GOP is not garbage | 2545 // Set memory limit to 3 and make sure the 4-byte GOP is not garbage |
2570 // collected. | 2546 // collected. |
2571 SetMemoryLimit(3); | 2547 SetMemoryLimit(3); |
2572 NewSegmentAppend("0K 30 60 90"); | 2548 NewSegmentAppend("0K 30 60 90"); |
2573 CheckExpectedRangesByTimestamp("{ [0,120) }"); | 2549 CheckExpectedRangesByTimestamp("{ [0,120) }"); |
2574 | 2550 |
2575 // Make sure you can continue appending data to this GOP; again, GC should not | 2551 // Make sure you can continue appending data to this GOP; again, GC should not |
2576 // wipe out anything. | 2552 // wipe out anything. |
2577 AppendBuffers("120D30"); | 2553 AppendBuffers("120"); |
2578 CheckExpectedRangesByTimestamp("{ [0,150) }"); | 2554 CheckExpectedRangesByTimestamp("{ [0,150) }"); |
2579 | 2555 |
2580 // Set memory limit to 100 and append a 2nd range after this without | 2556 // Set memory limit to 100 and append a 2nd range after this without |
2581 // triggering GC. | 2557 // triggering GC. |
2582 SetMemoryLimit(100); | 2558 SetMemoryLimit(100); |
2583 NewSegmentAppend("200K 230 260 290K 320 350"); | 2559 NewSegmentAppend("200K 230 260 290K 320 350"); |
2584 CheckExpectedRangesByTimestamp("{ [0,150) [200,380) }"); | 2560 CheckExpectedRangesByTimestamp("{ [0,150) [200,380) }"); |
2585 | 2561 |
2586 // Seek to 290ms. | 2562 // Seek to 290ms. |
2587 SeekToTimestamp(base::TimeDelta::FromMilliseconds(290)); | 2563 SeekToTimestamp(base::TimeDelta::FromMilliseconds(290)); |
2588 | 2564 |
2589 // Now set memory limit to 3 and append a GOP in a separate range after the | 2565 // Now set memory limit to 3 and append a GOP in a separate range after the |
2590 // selected range. Because it is after 290ms, this tests that the GOP is saved | 2566 // selected range. Because it is after 290ms, this tests that the GOP is saved |
2591 // when deleting from the back. | 2567 // when deleting from the back. |
2592 SetMemoryLimit(3); | 2568 SetMemoryLimit(3); |
2593 NewSegmentAppend("500K 530 560 590"); | 2569 NewSegmentAppend("500K 530 560 590"); |
2594 | 2570 |
2595 // Should save GOP with 290ms and last GOP appended. | 2571 // Should save GOP with 290ms and last GOP appended. |
2596 CheckExpectedRangesByTimestamp("{ [290,380) [500,620) }"); | 2572 CheckExpectedRangesByTimestamp("{ [290,380) [500,620) }"); |
2597 | 2573 |
2598 // Continue appending to this GOP after GC. | 2574 // Continue appending to this GOP after GC. |
2599 AppendBuffers("620D30"); | 2575 AppendBuffers("620"); |
2600 CheckExpectedRangesByTimestamp("{ [290,380) [500,650) }"); | 2576 CheckExpectedRangesByTimestamp("{ [290,380) [500,650) }"); |
2601 } | 2577 } |
2602 | 2578 |
2603 // Test saving the last GOP appended when this GOP is in the middle of a | 2579 // Test saving the last GOP appended when this GOP is in the middle of a |
2604 // non-selected range. | 2580 // non-selected range. |
2605 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Middle) { | 2581 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Middle) { |
2606 // Append 3 GOPs starting at 0ms, 30ms apart. | 2582 // Append 3 GOPs starting at 0ms, 30ms apart. |
2607 NewSegmentAppend("0K 30 60 90K 120 150 180K 210 240"); | 2583 NewSegmentAppend("0K 30 60 90K 120 150 180K 210 240"); |
2608 CheckExpectedRangesByTimestamp("{ [0,270) }"); | 2584 CheckExpectedRangesByTimestamp("{ [0,270) }"); |
2609 | 2585 |
2610 // Now set the memory limit to 1 and overlap the middle of the range with a | 2586 // Now set the memory limit to 1 and overlap the middle of the range with a |
2611 // new GOP. | 2587 // new GOP. |
2612 SetMemoryLimit(1); | 2588 SetMemoryLimit(1); |
2613 NewSegmentAppend("80K 110 140"); | 2589 NewSegmentAppend("80K 110 140"); |
2614 | 2590 |
2615 // This whole GOP should be saved, and should be able to continue appending | 2591 // This whole GOP should be saved, and should be able to continue appending |
2616 // data to it. | 2592 // data to it. |
2617 CheckExpectedRangesByTimestamp("{ [80,170) }"); | 2593 CheckExpectedRangesByTimestamp("{ [80,170) }"); |
2618 AppendBuffers("170D30"); | 2594 AppendBuffers("170"); |
2619 CheckExpectedRangesByTimestamp("{ [80,200) }"); | 2595 CheckExpectedRangesByTimestamp("{ [80,200) }"); |
2620 | 2596 |
2621 // Set memory limit to 100 and append a 2nd range after this without | 2597 // Set memory limit to 100 and append a 2nd range after this without |
2622 // triggering GC. | 2598 // triggering GC. |
2623 SetMemoryLimit(100); | 2599 SetMemoryLimit(100); |
2624 NewSegmentAppend("400K 430 460 490K 520 550 580K 610 640"); | 2600 NewSegmentAppend("400K 430 460 490K 520 550 580K 610 640"); |
2625 CheckExpectedRangesByTimestamp("{ [80,200) [400,670) }"); | 2601 CheckExpectedRangesByTimestamp("{ [80,200) [400,670) }"); |
2626 | 2602 |
2627 // Seek to 80ms to make the first range the selected range. | 2603 // Seek to 80ms to make the first range the selected range. |
2628 SeekToTimestamp(base::TimeDelta::FromMilliseconds(80)); | 2604 SeekToTimestamp(base::TimeDelta::FromMilliseconds(80)); |
2629 | 2605 |
2630 // Now set memory limit to 3 and append a GOP in the middle of the second | 2606 // Now set memory limit to 3 and append a GOP in the middle of the second |
2631 // range. Because it is after the selected range, this tests that the GOP is | 2607 // range. Because it is after the selected range, this tests that the GOP is |
2632 // saved when deleting from the back. | 2608 // saved when deleting from the back. |
2633 SetMemoryLimit(3); | 2609 SetMemoryLimit(3); |
2634 NewSegmentAppend("500K 530 560 590"); | 2610 NewSegmentAppend("500K 530 560 590"); |
2635 | 2611 |
2636 // Should save the GOP containing the seek point and GOP that was last | 2612 // Should save the GOP containing the seek point and GOP that was last |
2637 // appended. | 2613 // appended. |
2638 CheckExpectedRangesByTimestamp("{ [80,200) [500,620) }"); | 2614 CheckExpectedRangesByTimestamp("{ [80,200) [500,620) }"); |
2639 | 2615 |
2640 // Continue appending to this GOP after GC. | 2616 // Continue appending to this GOP after GC. |
2641 AppendBuffers("620D30"); | 2617 AppendBuffers("620"); |
2642 CheckExpectedRangesByTimestamp("{ [80,200) [500,650) }"); | 2618 CheckExpectedRangesByTimestamp("{ [80,200) [500,650) }"); |
2643 } | 2619 } |
2644 | 2620 |
2645 // Test saving the last GOP appended when the GOP containing the next buffer is | 2621 // Test saving the last GOP appended when the GOP containing the next buffer is |
2646 // adjacent to the last GOP appended. | 2622 // adjacent to the last GOP appended. |
2647 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Selected1) { | 2623 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Selected1) { |
2648 // Append 3 GOPs at 0ms, 90ms, and 180ms. | 2624 // Append 3 GOPs at 0ms, 90ms, and 180ms. |
2649 NewSegmentAppend("0K 30 60 90K 120 150 180K 210 240"); | 2625 NewSegmentAppend("0K 30 60 90K 120 150 180K 210 240"); |
2650 CheckExpectedRangesByTimestamp("{ [0,270) }"); | 2626 CheckExpectedRangesByTimestamp("{ [0,270) }"); |
2651 | 2627 |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3646 Seek(0); | 3622 Seek(0); |
3647 CheckExpectedBuffers("0K 500K 1000K 3000K 3500K 4000K"); | 3623 CheckExpectedBuffers("0K 500K 1000K 3000K 3500K 4000K"); |
3648 } | 3624 } |
3649 | 3625 |
3650 TEST_F(SourceBufferStreamTest, Text_CompleteOverlap) { | 3626 TEST_F(SourceBufferStreamTest, Text_CompleteOverlap) { |
3651 SetTextStream(); | 3627 SetTextStream(); |
3652 NewSegmentAppend("3000K 3500K 4000K"); | 3628 NewSegmentAppend("3000K 3500K 4000K"); |
3653 CheckExpectedRangesByTimestamp("{ [3000,4500) }"); | 3629 CheckExpectedRangesByTimestamp("{ [3000,4500) }"); |
3654 NewSegmentAppend("0K 501K 1001K 1501K 2001K 2501K " | 3630 NewSegmentAppend("0K 501K 1001K 1501K 2001K 2501K " |
3655 "3001K 3501K 4001K 4501K 5001K"); | 3631 "3001K 3501K 4001K 4501K 5001K"); |
3656 CheckExpectedRangesByTimestamp("{ [0,5501) }"); | 3632 CheckExpectedRangesByTimestamp("{ [0,5502) }"); |
3657 | 3633 |
3658 Seek(0); | 3634 Seek(0); |
3659 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 2501K " | 3635 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 2501K " |
3660 "3001K 3501K 4001K 4501K 5001K"); | 3636 "3001K 3501K 4001K 4501K 5001K"); |
3661 } | 3637 } |
3662 | 3638 |
3663 TEST_F(SourceBufferStreamTest, Text_OverlapAfter) { | 3639 TEST_F(SourceBufferStreamTest, Text_OverlapAfter) { |
3664 SetTextStream(); | 3640 SetTextStream(); |
3665 NewSegmentAppend("0K 500K 1000K 1500K 2000K"); | 3641 NewSegmentAppend("0K 500K 1000K 1500K 2000K"); |
3666 CheckExpectedRangesByTimestamp("{ [0,2500) }"); | 3642 CheckExpectedRangesByTimestamp("{ [0,2500) }"); |
3667 NewSegmentAppend("1499K 2001K 2501K 3001K"); | 3643 NewSegmentAppend("1499K 2001K 2501K 3001K"); |
3668 CheckExpectedRangesByTimestamp("{ [0,3501) }"); | 3644 CheckExpectedRangesByTimestamp("{ [0,3503) }"); |
3669 | 3645 |
3670 Seek(0); | 3646 Seek(0); |
3671 CheckExpectedBuffers("0K 500K 1000K 1499K 2001K 2501K 3001K"); | 3647 CheckExpectedBuffers("0K 500K 1000K 1499K 2001K 2501K 3001K"); |
3672 } | 3648 } |
3673 | 3649 |
3674 TEST_F(SourceBufferStreamTest, Text_OverlapBefore) { | 3650 TEST_F(SourceBufferStreamTest, Text_OverlapBefore) { |
3675 SetTextStream(); | 3651 SetTextStream(); |
3676 NewSegmentAppend("1500K 2000K 2500K 3000K 3500K"); | 3652 NewSegmentAppend("1500K 2000K 2500K 3000K 3500K"); |
3677 CheckExpectedRangesByTimestamp("{ [1500,4000) }"); | 3653 CheckExpectedRangesByTimestamp("{ [1500,4000) }"); |
3678 NewSegmentAppend("0K 501K 1001K 1501K 2001K"); | 3654 NewSegmentAppend("0K 501K 1001K 1501K 2001K"); |
3679 CheckExpectedRangesByTimestamp("{ [0,4000) }"); | 3655 CheckExpectedRangesByTimestamp("{ [0,4001) }"); |
3680 | 3656 |
3681 Seek(0); | 3657 Seek(0); |
3682 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 3000K 3500K"); | 3658 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 2500K 3000K 3500K"); |
3683 } | 3659 } |
3684 | 3660 |
3685 TEST_F(SourceBufferStreamTest, SpliceFrame_Basic) { | 3661 TEST_F(SourceBufferStreamTest, SpliceFrame_Basic) { |
3686 Seek(0); | 3662 Seek(0); |
3687 NewSegmentAppend("0K S(3K 6 9D3 10D5) 15 20 S(25K 30D5 35D5) 40"); | 3663 NewSegmentAppend("0K S(3K 6 9 10) 15 20 S(25K 30 35) 40"); |
3688 CheckExpectedBuffers("0K 3K 6 9 C 10 15 20 25K 30 C 35 40"); | 3664 CheckExpectedBuffers("0K 3K 6 9 C 10 15 20 25K 30 C 35 40"); |
3689 CheckNoNextBuffer(); | 3665 CheckNoNextBuffer(); |
3690 } | 3666 } |
3691 | 3667 |
3692 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSplice) { | 3668 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSplice) { |
3693 Seek(0); | 3669 Seek(0); |
3694 NewSegmentAppend("0K S(3K 6 9D3 10D5) 15K 20"); | 3670 NewSegmentAppend("0K S(3K 6 9 10) 15K 20"); |
3695 CheckExpectedBuffers("0K 3K 6"); | 3671 CheckExpectedBuffers("0K 3K 6"); |
3696 | 3672 |
3697 SeekToTimestamp(base::TimeDelta::FromMilliseconds(15)); | 3673 SeekToTimestamp(base::TimeDelta::FromMilliseconds(15)); |
3698 CheckExpectedBuffers("15K 20"); | 3674 CheckExpectedBuffers("15K 20"); |
3699 CheckNoNextBuffer(); | 3675 CheckNoNextBuffer(); |
3700 } | 3676 } |
3701 | 3677 |
3702 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSpliceFromTrackBuffer) { | 3678 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSpliceFromTrackBuffer) { |
3703 Seek(0); | 3679 Seek(0); |
3704 NewSegmentAppend("0K 2K S(3K 6 9D3 10D5) 15K 20"); | 3680 NewSegmentAppend("0K 2K S(3K 6 9 10) 15K 20"); |
3705 CheckExpectedBuffers("0K 2K"); | 3681 CheckExpectedBuffers("0K 2K"); |
3706 | 3682 |
3707 // Overlap the existing segment. | 3683 // Overlap the existing segment. |
3708 NewSegmentAppend("5K 15K 20"); | 3684 NewSegmentAppend("5K 15K 20"); |
3709 CheckExpectedBuffers("3K 6"); | 3685 CheckExpectedBuffers("3K 6"); |
3710 | 3686 |
3711 SeekToTimestamp(base::TimeDelta::FromMilliseconds(15)); | 3687 SeekToTimestamp(base::TimeDelta::FromMilliseconds(15)); |
3712 CheckExpectedBuffers("15K 20"); | 3688 CheckExpectedBuffers("15K 20"); |
3713 CheckNoNextBuffer(); | 3689 CheckNoNextBuffer(); |
3714 } | 3690 } |
3715 | 3691 |
3716 TEST_F(SourceBufferStreamTest, SpliceFrame_ConfigChangeWithinSplice) { | 3692 TEST_F(SourceBufferStreamTest, SpliceFrame_ConfigChangeWithinSplice) { |
3717 VideoDecoderConfig new_config = TestVideoConfig::Large(); | 3693 VideoDecoderConfig new_config = TestVideoConfig::Large(); |
3718 ASSERT_FALSE(new_config.Matches(video_config_)); | 3694 ASSERT_FALSE(new_config.Matches(video_config_)); |
3719 | 3695 |
3720 // Add a new video config, then reset the config index back to the original. | 3696 // Add a new video config, then reset the config index back to the original. |
3721 stream_->UpdateVideoConfig(new_config); | 3697 stream_->UpdateVideoConfig(new_config); |
3722 stream_->UpdateVideoConfig(video_config_); | 3698 stream_->UpdateVideoConfig(video_config_); |
3723 | 3699 |
3724 Seek(0); | 3700 Seek(0); |
3725 CheckVideoConfig(video_config_); | 3701 CheckVideoConfig(video_config_); |
3726 NewSegmentAppend("0K S(3K 6C 9D3 10D5) 15"); | 3702 NewSegmentAppend("0K S(3K 6C 9 10) 15"); |
3727 | 3703 |
3728 CheckExpectedBuffers("0K 3K C"); | 3704 CheckExpectedBuffers("0K 3K C"); |
3729 CheckVideoConfig(new_config); | 3705 CheckVideoConfig(new_config); |
3730 CheckExpectedBuffers("6 9 C"); | 3706 CheckExpectedBuffers("6 9 C"); |
3731 CheckExpectedBuffers("10 C"); | 3707 CheckExpectedBuffers("10 C"); |
3732 CheckVideoConfig(video_config_); | 3708 CheckVideoConfig(video_config_); |
3733 CheckExpectedBuffers("15"); | 3709 CheckExpectedBuffers("15"); |
3734 CheckNoNextBuffer(); | 3710 CheckNoNextBuffer(); |
3735 } | 3711 } |
3736 | 3712 |
3737 TEST_F(SourceBufferStreamTest, SpliceFrame_BasicFromTrackBuffer) { | 3713 TEST_F(SourceBufferStreamTest, SpliceFrame_BasicFromTrackBuffer) { |
3738 Seek(0); | 3714 Seek(0); |
3739 NewSegmentAppend("0K 5K S(8K 9D1 10D10) 20"); | 3715 NewSegmentAppend("0K 5K S(8K 9 10) 20"); |
3740 CheckExpectedBuffers("0K 5K"); | 3716 CheckExpectedBuffers("0K 5K"); |
3741 | 3717 |
3742 // Overlap the existing segment. | 3718 // Overlap the existing segment. |
3743 NewSegmentAppend("5K 20"); | 3719 NewSegmentAppend("5K 20"); |
3744 CheckExpectedBuffers("8K 9 C 10 20"); | 3720 CheckExpectedBuffers("8K 9 C 10 20"); |
3745 CheckNoNextBuffer(); | 3721 CheckNoNextBuffer(); |
3746 } | 3722 } |
3747 | 3723 |
3748 TEST_F(SourceBufferStreamTest, | 3724 TEST_F(SourceBufferStreamTest, |
3749 SpliceFrame_ConfigChangeWithinSpliceFromTrackBuffer) { | 3725 SpliceFrame_ConfigChangeWithinSpliceFromTrackBuffer) { |
3750 VideoDecoderConfig new_config = TestVideoConfig::Large(); | 3726 VideoDecoderConfig new_config = TestVideoConfig::Large(); |
3751 ASSERT_FALSE(new_config.Matches(video_config_)); | 3727 ASSERT_FALSE(new_config.Matches(video_config_)); |
3752 | 3728 |
3753 // Add a new video config, then reset the config index back to the original. | 3729 // Add a new video config, then reset the config index back to the original. |
3754 stream_->UpdateVideoConfig(new_config); | 3730 stream_->UpdateVideoConfig(new_config); |
3755 stream_->UpdateVideoConfig(video_config_); | 3731 stream_->UpdateVideoConfig(video_config_); |
3756 | 3732 |
3757 Seek(0); | 3733 Seek(0); |
3758 CheckVideoConfig(video_config_); | 3734 CheckVideoConfig(video_config_); |
3759 NewSegmentAppend("0K 5K S(7K 8C 9D1 10D10) 20"); | 3735 NewSegmentAppend("0K 5K S(7K 8C 9 10) 20"); |
3760 CheckExpectedBuffers("0K 5K"); | 3736 CheckExpectedBuffers("0K 5K"); |
3761 | 3737 |
3762 // Overlap the existing segment. | 3738 // Overlap the existing segment. |
3763 NewSegmentAppend("5K 20"); | 3739 NewSegmentAppend("5K 20"); |
3764 CheckExpectedBuffers("7K C"); | 3740 CheckExpectedBuffers("7K C"); |
3765 CheckVideoConfig(new_config); | 3741 CheckVideoConfig(new_config); |
3766 CheckExpectedBuffers("8 9 C"); | 3742 CheckExpectedBuffers("8 9 C"); |
3767 CheckExpectedBuffers("10 C"); | 3743 CheckExpectedBuffers("10 C"); |
3768 CheckVideoConfig(video_config_); | 3744 CheckVideoConfig(video_config_); |
3769 CheckExpectedBuffers("20"); | 3745 CheckExpectedBuffers("20"); |
(...skipping 24 matching lines...) Expand all Loading... |
3794 Seek(0); | 3770 Seek(0); |
3795 NewSegmentAppend("0K 2K 4K 6K 8K 10K 12K"); | 3771 NewSegmentAppend("0K 2K 4K 6K 8K 10K 12K"); |
3796 NewSegmentAppend("11K 13K 15K 17K"); | 3772 NewSegmentAppend("11K 13K 15K 17K"); |
3797 | 3773 |
3798 // Verify the splice was created. | 3774 // Verify the splice was created. |
3799 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11K 13K 15K 17K"); | 3775 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11K 13K 15K 17K"); |
3800 CheckNoNextBuffer(); | 3776 CheckNoNextBuffer(); |
3801 Seek(0); | 3777 Seek(0); |
3802 | 3778 |
3803 // Create a splice before the first splice which would include it. | 3779 // Create a splice before the first splice which would include it. |
3804 NewSegmentAppend("9D2K"); | 3780 NewSegmentAppend("9K"); |
3805 | 3781 |
3806 // A splice on top of a splice should result in a discard of the original | 3782 // A splice on top of a splice should result in a discard of the original |
3807 // splice and no new splice frame being generated. | 3783 // splice and no new splice frame being generated. |
3808 CheckExpectedBuffers("0K 2K 4K 6K 8K 9K 13K 15K 17K"); | 3784 CheckExpectedBuffers("0K 2K 4K 6K 8K 9K 13K 15K 17K"); |
3809 CheckNoNextBuffer(); | 3785 CheckNoNextBuffer(); |
3810 } | 3786 } |
3811 | 3787 |
3812 // Test that a splice is not created if an end timestamp and start timestamp | 3788 // Test that a splice is not created if an end timestamp and start timestamp |
3813 // overlap. | 3789 // overlap. |
3814 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoSplice) { | 3790 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoSplice) { |
3815 SetAudioStream(); | 3791 SetAudioStream(); |
3816 Seek(0); | 3792 Seek(0); |
3817 NewSegmentAppend("0K 2K 4K 6K 8K 10K"); | 3793 NewSegmentAppend("0K 2K 4K 6K 8K 10K"); |
3818 NewSegmentAppend("12K 14K 16K 18K"); | 3794 NewSegmentAppend("12K 14K 16K 18K"); |
3819 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K 14K 16K 18K"); | 3795 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K 14K 16K 18K"); |
3820 CheckNoNextBuffer(); | 3796 CheckNoNextBuffer(); |
3821 } | 3797 } |
3822 | 3798 |
3823 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_CorrectMediaSegmentStartTime) { | 3799 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_CorrectMediaSegmentStartTime) { |
3824 SetAudioStream(); | 3800 SetAudioStream(); |
3825 Seek(0); | 3801 Seek(0); |
3826 NewSegmentAppend("0K 2K 4K"); | 3802 NewSegmentAppend("0K 2K 4K"); |
3827 CheckExpectedRangesByTimestamp("{ [0,6) }"); | 3803 CheckExpectedRangesByTimestamp("{ [0,6) }"); |
3828 NewSegmentAppend("6K 8K 10K"); | 3804 NewSegmentAppend("6K 8K 10K"); |
3829 CheckExpectedRangesByTimestamp("{ [0,12) }"); | 3805 CheckExpectedRangesByTimestamp("{ [0,12) }"); |
3830 NewSegmentAppend("1K 4D2K"); | 3806 NewSegmentAppend("1K 4K"); |
3831 CheckExpectedRangesByTimestamp("{ [0,12) }"); | 3807 CheckExpectedRangesByTimestamp("{ [0,12) }"); |
3832 CheckExpectedBuffers("0K 2K 4K C 1K 4K 6K 8K 10K"); | 3808 CheckExpectedBuffers("0K 2K 4K C 1K 4K 6K 8K 10K"); |
3833 CheckNoNextBuffer(); | 3809 CheckNoNextBuffer(); |
3834 } | 3810 } |
3835 | 3811 |
3836 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_ConfigChange) { | 3812 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_ConfigChange) { |
3837 SetAudioStream(); | 3813 SetAudioStream(); |
3838 | 3814 |
3839 AudioDecoderConfig new_config(kCodecVorbis, | 3815 AudioDecoderConfig new_config(kCodecVorbis, |
3840 kSampleFormatPlanarF32, | 3816 kSampleFormatPlanarF32, |
(...skipping 16 matching lines...) Expand all Loading... |
3857 | 3833 |
3858 // Ensure splices are not created if there are not enough frames to crossfade. | 3834 // Ensure splices are not created if there are not enough frames to crossfade. |
3859 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoTinySplices) { | 3835 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoTinySplices) { |
3860 SetAudioStream(); | 3836 SetAudioStream(); |
3861 Seek(0); | 3837 Seek(0); |
3862 | 3838 |
3863 // Overlap the range [0, 2) with [1, 3). Since each frame has a duration of | 3839 // Overlap the range [0, 2) with [1, 3). Since each frame has a duration of |
3864 // 2ms this results in an overlap of 1ms between the ranges. A splice frame | 3840 // 2ms this results in an overlap of 1ms between the ranges. A splice frame |
3865 // should not be generated since it requires at least 2 frames, or 2ms in this | 3841 // should not be generated since it requires at least 2 frames, or 2ms in this |
3866 // case, of data to crossfade. | 3842 // case, of data to crossfade. |
3867 NewSegmentAppend("0D2K"); | 3843 NewSegmentAppend("0K"); |
3868 CheckExpectedRangesByTimestamp("{ [0,2) }"); | 3844 CheckExpectedRangesByTimestamp("{ [0,2) }"); |
3869 NewSegmentAppend("1D2K"); | 3845 NewSegmentAppend("1K"); |
3870 CheckExpectedRangesByTimestamp("{ [0,3) }"); | 3846 CheckExpectedRangesByTimestamp("{ [0,3) }"); |
3871 CheckExpectedBuffers("0K 1K"); | 3847 CheckExpectedBuffers("0K 1K"); |
3872 CheckNoNextBuffer(); | 3848 CheckNoNextBuffer(); |
3873 } | 3849 } |
3874 | 3850 |
3875 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_Preroll) { | 3851 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_Preroll) { |
3876 SetAudioStream(); | 3852 SetAudioStream(); |
3877 Seek(0); | 3853 Seek(0); |
3878 NewSegmentAppend("0K 2K 4K 6K 8K 10K 12K"); | 3854 NewSegmentAppend("0K 2K 4K 6K 8K 10K 12K"); |
3879 NewSegmentAppend("11P 13K 15K 17K"); | 3855 NewSegmentAppend("11P 13K 15K 17K"); |
3880 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11P 13K 15K 17K"); | 3856 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11P 13K 15K 17K"); |
3881 CheckNoNextBuffer(); | 3857 CheckNoNextBuffer(); |
3882 } | 3858 } |
3883 | 3859 |
3884 TEST_F(SourceBufferStreamTest, Audio_PrerollFrame) { | 3860 TEST_F(SourceBufferStreamTest, Audio_PrerollFrame) { |
3885 Seek(0); | 3861 Seek(0); |
3886 NewSegmentAppend("0K 3P 6K"); | 3862 NewSegmentAppend("0K 3P 6K"); |
3887 CheckExpectedBuffers("0K 3P 6K"); | 3863 CheckExpectedBuffers("0K 3P 6K"); |
3888 CheckNoNextBuffer(); | 3864 CheckNoNextBuffer(); |
3889 } | 3865 } |
3890 | 3866 |
3891 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. | 3867 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. |
3892 // (crbug.com/133557) | 3868 // (crbug.com/133557) |
3893 | 3869 |
3894 // TODO(vrk): Add unit tests with end of stream being called at interesting | 3870 // TODO(vrk): Add unit tests with end of stream being called at interesting |
3895 // times. | 3871 // times. |
3896 | 3872 |
3897 } // namespace media | 3873 } // namespace media |
OLD | NEW |