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