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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 MATCHER_P(ContainsTrackBufferExhaustionSkipLog, skip_milliseconds, "") { | 51 MATCHER_P(ContainsTrackBufferExhaustionSkipLog, skip_milliseconds, "") { |
52 return CONTAINS_STRING(arg, | 52 return CONTAINS_STRING(arg, |
53 "Media append that overlapped current playback " | 53 "Media append that overlapped current playback " |
54 "position caused time gap in playing VIDEO stream " | 54 "position caused time gap in playing VIDEO stream " |
55 "because the next keyframe is " + | 55 "because the next keyframe is " + |
56 base::IntToString(skip_milliseconds) + | 56 base::IntToString(skip_milliseconds) + |
57 "ms beyond last overlapped frame. Media may " | 57 "ms beyond last overlapped frame. Media may " |
58 "appear temporarily frozen."); | 58 "appear temporarily frozen."); |
59 } | 59 } |
60 | 60 |
61 MATCHER_P2(ContainsGeneratedSpliceLog, | 61 MATCHER_P3(TrimmedSpliceOverlap, |
62 duration_microseconds, | 62 splice_time_us, |
63 time_microseconds, | 63 overlapped_start_us, |
64 trim_duration_us, | |
64 "") { | 65 "") { |
65 return CONTAINS_STRING(arg, "Generated splice of overlap duration " + | 66 return CONTAINS_STRING( |
66 base::IntToString(duration_microseconds) + | 67 arg, "Audio buffer splice at PTS=" + base::IntToString(splice_time_us) + |
67 "us into new buffer at " + | 68 "us. Trimmed tail of overlapped buffer (PTS=" + |
68 base::IntToString(time_microseconds) + "us."); | 69 base::IntToString(overlapped_start_us) + "us) by " + |
70 base::IntToString(trim_duration_us)); | |
69 } | 71 } |
70 | 72 |
71 class SourceBufferStreamTest : public testing::Test { | 73 class SourceBufferStreamTest : public testing::Test { |
72 protected: | 74 protected: |
73 SourceBufferStreamTest() : media_log_(new StrictMock<MockMediaLog>()) { | 75 SourceBufferStreamTest() : media_log_(new StrictMock<MockMediaLog>()) { |
74 video_config_ = TestVideoConfig::Normal(); | 76 video_config_ = TestVideoConfig::Normal(); |
75 SetStreamInfo(kDefaultFramesPerSecond, kDefaultKeyframesPerSecond); | 77 SetStreamInfo(kDefaultFramesPerSecond, kDefaultKeyframesPerSecond); |
76 stream_.reset(new SourceBufferStream(video_config_, media_log_, true)); | 78 stream_.reset(new SourceBufferStream(video_config_, media_log_)); |
77 } | 79 } |
78 | 80 |
79 void SetMemoryLimit(size_t buffers_of_data) { | 81 void SetMemoryLimit(size_t buffers_of_data) { |
80 stream_->set_memory_limit(buffers_of_data * kDataSize); | 82 stream_->set_memory_limit(buffers_of_data * kDataSize); |
81 } | 83 } |
82 | 84 |
83 void SetStreamInfo(int frames_per_second, int keyframes_per_second) { | 85 void SetStreamInfo(int frames_per_second, int keyframes_per_second) { |
84 frames_per_second_ = frames_per_second; | 86 frames_per_second_ = frames_per_second; |
85 keyframes_per_second_ = keyframes_per_second; | 87 keyframes_per_second_ = keyframes_per_second; |
86 frame_duration_ = ConvertToFrameDuration(frames_per_second); | 88 frame_duration_ = ConvertToFrameDuration(frames_per_second); |
87 } | 89 } |
88 | 90 |
89 void SetTextStream() { | 91 void SetTextStream() { |
90 video_config_ = TestVideoConfig::Invalid(); | 92 video_config_ = TestVideoConfig::Invalid(); |
91 TextTrackConfig config(kTextSubtitles, "", "", ""); | 93 TextTrackConfig config(kTextSubtitles, "", "", ""); |
92 stream_.reset(new SourceBufferStream(config, media_log_, true)); | 94 stream_.reset(new SourceBufferStream(config, media_log_)); |
93 SetStreamInfo(2, 2); | 95 SetStreamInfo(2, 2); |
94 } | 96 } |
95 | 97 |
96 void SetAudioStream() { | 98 void SetAudioStream() { |
97 video_config_ = TestVideoConfig::Invalid(); | 99 video_config_ = TestVideoConfig::Invalid(); |
98 audio_config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32, | 100 audio_config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32, |
99 CHANNEL_LAYOUT_STEREO, 1000, EmptyExtraData(), | 101 CHANNEL_LAYOUT_STEREO, 1000, EmptyExtraData(), |
100 Unencrypted(), base::TimeDelta(), 0); | 102 Unencrypted(), base::TimeDelta(), 0); |
101 stream_.reset(new SourceBufferStream(audio_config_, media_log_, true)); | 103 stream_.reset(new SourceBufferStream(audio_config_, media_log_)); |
102 | 104 |
103 // Equivalent to 2ms per frame. | 105 // Equivalent to 2ms per frame. |
104 SetStreamInfo(500, 500); | 106 SetStreamInfo(500, 500); |
105 } | 107 } |
106 | 108 |
107 void NewCodedFrameGroupAppend(int starting_position, int number_of_buffers) { | 109 void NewCodedFrameGroupAppend(int starting_position, int number_of_buffers) { |
108 AppendBuffers(starting_position, number_of_buffers, true, | 110 AppendBuffers(starting_position, number_of_buffers, true, |
109 base::TimeDelta(), true, &kDataA, kDataSize); | 111 base::TimeDelta(), true, &kDataA, kDataSize); |
110 } | 112 } |
111 | 113 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 } | 301 } |
300 | 302 |
301 EXPECT_EQ(ending_position + 1, current_position); | 303 EXPECT_EQ(ending_position + 1, current_position); |
302 } | 304 } |
303 | 305 |
304 void CheckExpectedBuffers(const std::string& expected) { | 306 void CheckExpectedBuffers(const std::string& expected) { |
305 std::vector<std::string> timestamps = base::SplitString( | 307 std::vector<std::string> timestamps = base::SplitString( |
306 expected, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 308 expected, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
307 std::stringstream ss; | 309 std::stringstream ss; |
308 const SourceBufferStream::Type type = stream_->GetType(); | 310 const SourceBufferStream::Type type = stream_->GetType(); |
309 base::TimeDelta active_splice_timestamp = kNoTimestamp; | |
310 for (size_t i = 0; i < timestamps.size(); i++) { | 311 for (size_t i = 0; i < timestamps.size(); i++) { |
311 scoped_refptr<StreamParserBuffer> buffer; | 312 scoped_refptr<StreamParserBuffer> buffer; |
312 SourceBufferStream::Status status = stream_->GetNextBuffer(&buffer); | 313 SourceBufferStream::Status status = stream_->GetNextBuffer(&buffer); |
313 | 314 |
314 if (i > 0) | 315 if (i > 0) |
315 ss << " "; | 316 ss << " "; |
316 | 317 |
317 if (status == SourceBufferStream::kConfigChange) { | 318 if (status == SourceBufferStream::kConfigChange) { |
318 switch (type) { | 319 switch (type) { |
319 case SourceBufferStream::kVideo: | 320 case SourceBufferStream::kVideo: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 ASSERT_EQ(buffer->GetDecodeTimestamp(), | 374 ASSERT_EQ(buffer->GetDecodeTimestamp(), |
374 preroll_buffer->GetDecodeTimestamp()); | 375 preroll_buffer->GetDecodeTimestamp()); |
375 ASSERT_EQ(kInfiniteDuration, preroll_buffer->discard_padding().first); | 376 ASSERT_EQ(kInfiniteDuration, preroll_buffer->discard_padding().first); |
376 ASSERT_EQ(base::TimeDelta(), preroll_buffer->discard_padding().second); | 377 ASSERT_EQ(base::TimeDelta(), preroll_buffer->discard_padding().second); |
377 ASSERT_TRUE(buffer->is_key_frame()); | 378 ASSERT_TRUE(buffer->is_key_frame()); |
378 | 379 |
379 ss << "P"; | 380 ss << "P"; |
380 } else if (buffer->is_key_frame()) { | 381 } else if (buffer->is_key_frame()) { |
381 ss << "K"; | 382 ss << "K"; |
382 } | 383 } |
383 | |
384 // Until the last splice frame is seen, indicated by a matching timestamp, | |
385 // all buffers must have the same splice_timestamp(). | |
386 if (buffer->timestamp() == active_splice_timestamp) { | |
387 ASSERT_EQ(buffer->splice_timestamp(), kNoTimestamp); | |
388 } else { | |
389 ASSERT_TRUE(active_splice_timestamp == kNoTimestamp || | |
390 active_splice_timestamp == buffer->splice_timestamp()); | |
391 } | |
392 | |
393 active_splice_timestamp = buffer->splice_timestamp(); | |
394 } | 384 } |
395 EXPECT_EQ(expected, ss.str()); | 385 EXPECT_EQ(expected, ss.str()); |
396 } | 386 } |
397 | 387 |
398 void CheckNoNextBuffer() { | 388 void CheckNoNextBuffer() { |
399 scoped_refptr<StreamParserBuffer> buffer; | 389 scoped_refptr<StreamParserBuffer> buffer; |
400 EXPECT_EQ(SourceBufferStream::kNeedBuffer, stream_->GetNextBuffer(&buffer)); | 390 EXPECT_EQ(SourceBufferStream::kNeedBuffer, stream_->GetNextBuffer(&buffer)); |
401 } | 391 } |
402 | 392 |
403 void CheckEOSReached() { | 393 void CheckEOSReached() { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 // Indicates that the buffer should be marked as containing an *estimated* | 510 // Indicates that the buffer should be marked as containing an *estimated* |
521 // duration. E.g., "0D20E 20 25E 30" | 511 // duration. E.g., "0D20E 20 25E 30" |
522 // | 512 // |
523 // P: | 513 // P: |
524 // Indicates the buffer with will also have a preroll buffer | 514 // Indicates the buffer with will also have a preroll buffer |
525 // associated with it. The preroll buffer will just be dummy data. | 515 // associated with it. The preroll buffer will just be dummy data. |
526 // E.g. "0P 5 10" | 516 // E.g. "0P 5 10" |
527 // | 517 // |
528 // K: | 518 // K: |
529 // Indicates the buffer is a keyframe. E.g., "0K 1|2K 2|4D2K 6 8". | 519 // Indicates the buffer is a keyframe. E.g., "0K 1|2K 2|4D2K 6 8". |
530 // | |
531 // S(a# ... y# z#) | |
532 // Indicates a splice frame buffer should be created with timestamp z#. The | |
533 // preceding timestamps a# ... y# will be treated as the fade out preroll for | |
534 // the splice frame. If a timestamp within the preroll ends with C the config | |
535 // id to use for that and subsequent preroll appends is incremented by one. | |
536 // The config id for non-splice frame appends will not be affected. | |
537 BufferQueue StringToBufferQueue(const std::string& buffers_to_append) { | 520 BufferQueue StringToBufferQueue(const std::string& buffers_to_append) { |
538 std::vector<std::string> timestamps = base::SplitString( | 521 std::vector<std::string> timestamps = base::SplitString( |
539 buffers_to_append, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 522 buffers_to_append, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
540 | 523 |
541 CHECK_GT(timestamps.size(), 0u); | 524 CHECK_GT(timestamps.size(), 0u); |
542 | 525 |
543 bool splice_frame = false; | |
544 size_t splice_config_id = stream_->append_config_index_; | |
545 BufferQueue pre_splice_buffers; | |
546 BufferQueue buffers; | 526 BufferQueue buffers; |
547 for (size_t i = 0; i < timestamps.size(); i++) { | 527 for (size_t i = 0; i < timestamps.size(); i++) { |
548 bool is_keyframe = false; | 528 bool is_keyframe = false; |
549 bool has_preroll = false; | 529 bool has_preroll = false; |
550 bool last_splice_frame = false; | |
551 bool is_duration_estimated = false; | 530 bool is_duration_estimated = false; |
552 | 531 |
553 // Handle splice frame starts. | |
554 if (base::StartsWith(timestamps[i], "S(", base::CompareCase::SENSITIVE)) { | |
555 CHECK(!splice_frame); | |
556 splice_frame = true; | |
557 // Remove the "S(" off of the token. | |
558 timestamps[i] = timestamps[i].substr(2, timestamps[i].length()); | |
559 } | |
560 if (splice_frame && | |
561 base::EndsWith(timestamps[i], ")", base::CompareCase::SENSITIVE)) { | |
562 splice_frame = false; | |
563 last_splice_frame = true; | |
564 // Remove the ")" off of the token. | |
565 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); | |
566 } | |
567 // Handle config changes within the splice frame. | |
568 if (splice_frame && | |
569 base::EndsWith(timestamps[i], "C", base::CompareCase::SENSITIVE)) { | |
570 splice_config_id++; | |
571 CHECK(splice_config_id < stream_->audio_configs_.size() || | |
572 splice_config_id < stream_->video_configs_.size()); | |
573 // Remove the "C" off of the token. | |
574 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); | |
575 } | |
576 if (base::EndsWith(timestamps[i], "K", base::CompareCase::SENSITIVE)) { | 532 if (base::EndsWith(timestamps[i], "K", base::CompareCase::SENSITIVE)) { |
577 is_keyframe = true; | 533 is_keyframe = true; |
578 // Remove the "K" off of the token. | 534 // Remove the "K" off of the token. |
579 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); | 535 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); |
580 } | 536 } |
581 // Handle preroll buffers. | 537 // Handle preroll buffers. |
582 if (base::EndsWith(timestamps[i], "P", base::CompareCase::SENSITIVE)) { | 538 if (base::EndsWith(timestamps[i], "P", base::CompareCase::SENSITIVE)) { |
583 is_keyframe = true; | 539 is_keyframe = true; |
584 has_preroll = true; | 540 has_preroll = true; |
585 // Remove the "P" off of the token. | 541 // Remove the "P" off of the token. |
586 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); | 542 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); |
587 } | 543 } |
588 | 544 |
589 if (base::EndsWith(timestamps[i], "E", base::CompareCase::SENSITIVE)) { | 545 if (base::EndsWith(timestamps[i], "E", base::CompareCase::SENSITIVE)) { |
590 is_duration_estimated = true; | 546 is_duration_estimated = true; |
591 // Remove the "E" off of the token. | 547 // Remove the "E" off of the token. |
592 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); | 548 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); |
593 } | 549 } |
594 | 550 |
595 int duration_in_ms = 0; | 551 int duration_in_ms = -1; |
596 size_t duration_pos = timestamps[i].find('D'); | 552 size_t duration_pos = timestamps[i].find('D'); |
597 if (duration_pos != std::string::npos) { | 553 if (duration_pos != std::string::npos) { |
598 CHECK(base::StringToInt(timestamps[i].substr(duration_pos + 1), | 554 CHECK(base::StringToInt(timestamps[i].substr(duration_pos + 1), |
599 &duration_in_ms)); | 555 &duration_in_ms)); |
600 timestamps[i] = timestamps[i].substr(0, duration_pos); | 556 timestamps[i] = timestamps[i].substr(0, duration_pos); |
601 } | 557 } |
602 | 558 |
603 std::vector<std::string> buffer_timestamps = base::SplitString( | 559 std::vector<std::string> buffer_timestamps = base::SplitString( |
604 timestamps[i], "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 560 timestamps[i], "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
605 | 561 |
(...skipping 12 matching lines...) Expand all Loading... | |
618 StreamParserBuffer::CopyFrom(&kDataA, kDataSize, is_keyframe, | 574 StreamParserBuffer::CopyFrom(&kDataA, kDataSize, is_keyframe, |
619 DemuxerStream::AUDIO, 0); | 575 DemuxerStream::AUDIO, 0); |
620 buffer->set_timestamp(base::TimeDelta::FromMilliseconds(pts_in_ms)); | 576 buffer->set_timestamp(base::TimeDelta::FromMilliseconds(pts_in_ms)); |
621 buffer->set_is_duration_estimated(is_duration_estimated); | 577 buffer->set_is_duration_estimated(is_duration_estimated); |
622 | 578 |
623 if (dts_in_ms != pts_in_ms) { | 579 if (dts_in_ms != pts_in_ms) { |
624 buffer->SetDecodeTimestamp( | 580 buffer->SetDecodeTimestamp( |
625 DecodeTimestamp::FromMilliseconds(dts_in_ms)); | 581 DecodeTimestamp::FromMilliseconds(dts_in_ms)); |
626 } | 582 } |
627 | 583 |
628 if (duration_in_ms) | 584 if (duration_in_ms >= 0) |
629 buffer->set_duration(base::TimeDelta::FromMilliseconds(duration_in_ms)); | 585 buffer->set_duration(base::TimeDelta::FromMilliseconds(duration_in_ms)); |
630 | 586 |
631 // Simulate preroll buffers by just generating another buffer and sticking | 587 // Simulate preroll buffers by just generating another buffer and sticking |
632 // it as the preroll. | 588 // it as the preroll. |
633 if (has_preroll) { | 589 if (has_preroll) { |
634 scoped_refptr<StreamParserBuffer> preroll_buffer = | 590 scoped_refptr<StreamParserBuffer> preroll_buffer = |
635 StreamParserBuffer::CopyFrom( | 591 StreamParserBuffer::CopyFrom( |
636 &kDataA, kDataSize, is_keyframe, DemuxerStream::AUDIO, 0); | 592 &kDataA, kDataSize, is_keyframe, DemuxerStream::AUDIO, 0); |
637 preroll_buffer->set_duration(frame_duration_); | 593 preroll_buffer->set_duration(frame_duration_); |
638 buffer->SetPrerollBuffer(preroll_buffer); | 594 buffer->SetPrerollBuffer(preroll_buffer); |
639 } | 595 } |
640 | 596 |
641 if (splice_frame) { | |
642 // Make sure that splice frames aren't used with content where decode | |
643 // and presentation timestamps can differ. (i.e., B-frames) | |
644 CHECK_EQ(buffer->GetDecodeTimestamp().InMicroseconds(), | |
645 buffer->timestamp().InMicroseconds()); | |
646 if (!pre_splice_buffers.empty()) { | |
647 // Enforce strictly monotonically increasing timestamps. | |
648 CHECK_GT( | |
649 buffer->timestamp().InMicroseconds(), | |
650 pre_splice_buffers.back()->timestamp().InMicroseconds()); | |
651 CHECK_GT( | |
652 buffer->GetDecodeTimestamp().InMicroseconds(), | |
653 pre_splice_buffers.back()->GetDecodeTimestamp().InMicroseconds()); | |
654 } | |
655 buffer->SetConfigId(splice_config_id); | |
656 UpdateLastBufferDuration(buffer->GetDecodeTimestamp(), | |
657 &pre_splice_buffers); | |
658 pre_splice_buffers.push_back(buffer); | |
659 continue; | |
660 } | |
661 | |
662 if (last_splice_frame) { | |
663 // Require at least one additional buffer for a splice. | |
664 CHECK(!pre_splice_buffers.empty()); | |
665 buffer->SetConfigId(splice_config_id); | |
666 buffer->ConvertToSpliceBuffer(pre_splice_buffers); | |
667 pre_splice_buffers.clear(); | |
668 } | |
669 | |
670 UpdateLastBufferDuration(buffer->GetDecodeTimestamp(), &buffers); | 597 UpdateLastBufferDuration(buffer->GetDecodeTimestamp(), &buffers); |
671 buffers.push_back(buffer); | 598 buffers.push_back(buffer); |
672 } | 599 } |
673 | 600 |
674 // If the last buffer doesn't have a duration, assume it is the | 601 // If the last buffer doesn't have a duration, assume it is the |
675 // same as the second to last buffer. | 602 // same as the second to last buffer. |
676 if (buffers.size() >= 2 && | 603 if (buffers.size() >= 2 && buffers.back()->duration() == kNoTimestamp) { |
677 buffers.back()->duration() <= base::TimeDelta()) { | |
678 buffers.back()->set_duration( | 604 buffers.back()->set_duration( |
679 buffers[buffers.size() - 2]->duration()); | 605 buffers[buffers.size() - 2]->duration()); |
680 } | 606 } |
681 | 607 |
682 return buffers; | 608 return buffers; |
683 } | 609 } |
684 | 610 |
685 void AppendBuffers(const std::string& buffers_to_append, | 611 void AppendBuffers(const std::string& buffers_to_append, |
686 bool start_new_coded_frame_group, | 612 bool start_new_coded_frame_group, |
687 base::TimeDelta coded_frame_group_start_timestamp, | 613 base::TimeDelta coded_frame_group_start_timestamp, |
(...skipping 2921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3609 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_SingleAppend) { | 3535 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_SingleAppend) { |
3610 Seek(0); | 3536 Seek(0); |
3611 NewCodedFrameGroupAppend("0K 30 30 60 90 120K 150"); | 3537 NewCodedFrameGroupAppend("0K 30 30 60 90 120K 150"); |
3612 CheckExpectedBuffers("0K 30 30 60 90 120K 150"); | 3538 CheckExpectedBuffers("0K 30 30 60 90 120K 150"); |
3613 } | 3539 } |
3614 | 3540 |
3615 // Verify that non-keyframes with the same timestamp can occur | 3541 // Verify that non-keyframes with the same timestamp can occur |
3616 // in different appends. | 3542 // in different appends. |
3617 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_TwoAppends) { | 3543 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_TwoAppends) { |
3618 Seek(0); | 3544 Seek(0); |
3619 NewCodedFrameGroupAppend("0K 30"); | 3545 NewCodedFrameGroupAppend("0K 30D0"); |
3620 AppendBuffers("30 60 90 120K 150"); | 3546 AppendBuffers("30 60 90 120K 150"); |
3621 CheckExpectedBuffers("0K 30 30 60 90 120K 150"); | 3547 CheckExpectedBuffers("0K 30 30 60 90 120K 150"); |
3622 } | 3548 } |
3623 | 3549 |
3624 // Verify that a non-keyframe followed by a keyframe with the same timestamp | 3550 // Verify that a non-keyframe followed by a keyframe with the same timestamp |
3625 // is allowed, but also results in a MediaLog. | 3551 // is allowed, but also results in a MediaLog. |
3626 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_SingleAppend_Warning) { | 3552 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_SingleAppend_Warning) { |
3627 EXPECT_MEDIA_LOG(ContainsSameTimestampAt30MillisecondsLog()); | 3553 EXPECT_MEDIA_LOG(ContainsSameTimestampAt30MillisecondsLog()); |
3628 | 3554 |
3629 Seek(0); | 3555 Seek(0); |
3630 NewCodedFrameGroupAppend("0K 30 30K 60"); | 3556 NewCodedFrameGroupAppend("0K 30 30K 60"); |
3631 CheckExpectedBuffers("0K 30 30K 60"); | 3557 CheckExpectedBuffers("0K 30 30K 60"); |
3632 } | 3558 } |
3633 | 3559 |
3634 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_TwoAppends_Warning) { | 3560 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_TwoAppends_Warning) { |
3635 EXPECT_MEDIA_LOG(ContainsSameTimestampAt30MillisecondsLog()); | 3561 EXPECT_MEDIA_LOG(ContainsSameTimestampAt30MillisecondsLog()); |
3636 | 3562 |
3637 Seek(0); | 3563 Seek(0); |
3638 NewCodedFrameGroupAppend("0K 30"); | 3564 NewCodedFrameGroupAppend("0K 30D0"); |
3639 AppendBuffers("30K 60"); | 3565 AppendBuffers("30K 60"); |
3640 CheckExpectedBuffers("0K 30 30K 60"); | 3566 CheckExpectedBuffers("0K 30 30K 60"); |
3641 } | 3567 } |
3642 | 3568 |
3643 // Verify that a keyframe followed by a non-keyframe with the same timestamp | 3569 // Verify that a keyframe followed by a non-keyframe with the same timestamp |
3644 // is allowed. | 3570 // is allowed. |
3645 TEST_F(SourceBufferStreamTest, SameTimestamp_VideoKeyFrame_TwoAppends) { | 3571 TEST_F(SourceBufferStreamTest, SameTimestamp_VideoKeyFrame_TwoAppends) { |
3646 Seek(0); | 3572 Seek(0); |
3647 NewCodedFrameGroupAppend("0K 30K"); | 3573 NewCodedFrameGroupAppend("0K 30D0K"); |
3648 AppendBuffers("30 60"); | 3574 AppendBuffers("30 60"); |
3649 CheckExpectedBuffers("0K 30K 30 60"); | 3575 CheckExpectedBuffers("0K 30K 30 60"); |
3650 } | 3576 } |
3651 | 3577 |
3652 TEST_F(SourceBufferStreamTest, SameTimestamp_VideoKeyFrame_SingleAppend) { | 3578 TEST_F(SourceBufferStreamTest, SameTimestamp_VideoKeyFrame_SingleAppend) { |
3653 Seek(0); | 3579 Seek(0); |
3654 NewCodedFrameGroupAppend("0K 30K 30 60"); | 3580 NewCodedFrameGroupAppend("0K 30K 30 60"); |
3655 CheckExpectedBuffers("0K 30K 30 60"); | 3581 CheckExpectedBuffers("0K 30K 30 60"); |
3656 } | 3582 } |
3657 | 3583 |
3658 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_Overlap_1) { | 3584 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_Overlap_1) { |
3659 Seek(0); | 3585 Seek(0); |
3660 NewCodedFrameGroupAppend("0K 30 60 60 90 120K 150"); | 3586 NewCodedFrameGroupAppend("0K 30 60 60 90 120K 150"); |
3661 | 3587 |
3662 NewCodedFrameGroupAppend("60K 91 121K 151"); | 3588 NewCodedFrameGroupAppend("60K 91 121K 151"); |
3663 CheckExpectedBuffers("0K 30 60K 91 121K 151"); | 3589 CheckExpectedBuffers("0K 30 60K 91 121K 151"); |
3664 } | 3590 } |
3665 | 3591 |
3666 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_Overlap_2) { | 3592 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_Overlap_2) { |
3667 Seek(0); | 3593 Seek(0); |
3668 NewCodedFrameGroupAppend("0K 30 60 60 90 120K 150"); | 3594 NewCodedFrameGroupAppend("0K 30 60 60 90 120K 150"); |
3669 NewCodedFrameGroupAppend("0K 30 61"); | 3595 NewCodedFrameGroupAppend("0K 30 61"); |
3670 CheckExpectedBuffers("0K 30 61 120K 150"); | 3596 CheckExpectedBuffers("0K 30 61 120K 150"); |
3671 } | 3597 } |
3672 | 3598 |
3673 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_Overlap_3) { | 3599 TEST_F(SourceBufferStreamTest, SameTimestamp_Video_Overlap_3) { |
3674 Seek(0); | 3600 Seek(0); |
3675 NewCodedFrameGroupAppend("0K 20 40 60 80 100K 101 102 103K"); | 3601 NewCodedFrameGroupAppend("0K 20 40 60 80 100K 101 102 103K"); |
3676 NewCodedFrameGroupAppend("0K 20 40 60 80 90"); | 3602 NewCodedFrameGroupAppend("0K 20 40 60 80 90D0"); |
3677 CheckExpectedBuffers("0K 20 40 60 80 90 100K 101 102 103K"); | 3603 CheckExpectedBuffers("0K 20 40 60 80 90 100K 101 102 103K"); |
3678 AppendBuffers("90 110K 150"); | 3604 AppendBuffers("90 110K 150"); |
3679 Seek(0); | 3605 Seek(0); |
3680 CheckExpectedBuffers("0K 20 40 60 80 90 90 110K 150"); | 3606 CheckExpectedBuffers("0K 20 40 60 80 90 90 110K 150"); |
3681 CheckNoNextBuffer(); | 3607 CheckNoNextBuffer(); |
3682 CheckExpectedRangesByTimestamp("{ [0,190) }"); | 3608 CheckExpectedRangesByTimestamp("{ [0,190) }"); |
3683 } | 3609 } |
3684 | 3610 |
3685 // Test all the valid same timestamp cases for audio. | 3611 // Test all the valid same timestamp cases for audio. |
3686 TEST_F(SourceBufferStreamTest, SameTimestamp_Audio) { | 3612 TEST_F(SourceBufferStreamTest, SameTimestamp_Audio) { |
3687 AudioDecoderConfig config(kCodecMP3, kSampleFormatF32, CHANNEL_LAYOUT_STEREO, | 3613 AudioDecoderConfig config(kCodecMP3, kSampleFormatF32, CHANNEL_LAYOUT_STEREO, |
3688 44100, EmptyExtraData(), Unencrypted()); | 3614 44100, EmptyExtraData(), Unencrypted()); |
3689 stream_.reset(new SourceBufferStream(config, media_log_, true)); | 3615 stream_.reset(new SourceBufferStream(config, media_log_)); |
3690 Seek(0); | 3616 Seek(0); |
3691 NewCodedFrameGroupAppend("0K 0K 30K 30 60 60"); | 3617 NewCodedFrameGroupAppend("0K 0K 30K 30 60 60"); |
3692 CheckExpectedBuffers("0K 0K 30K 30 60 60"); | 3618 CheckExpectedBuffers("0K 0K 30K 30 60 60"); |
3693 } | 3619 } |
3694 | 3620 |
3695 TEST_F(SourceBufferStreamTest, SameTimestamp_Audio_SingleAppend_Warning) { | 3621 TEST_F(SourceBufferStreamTest, SameTimestamp_Audio_SingleAppend_Warning) { |
3696 EXPECT_MEDIA_LOG(ContainsSameTimestampAt30MillisecondsLog()); | 3622 EXPECT_MEDIA_LOG(ContainsSameTimestampAt30MillisecondsLog()); |
3697 | 3623 |
3698 AudioDecoderConfig config(kCodecMP3, kSampleFormatF32, CHANNEL_LAYOUT_STEREO, | 3624 AudioDecoderConfig config(kCodecMP3, kSampleFormatF32, CHANNEL_LAYOUT_STEREO, |
3699 44100, EmptyExtraData(), Unencrypted()); | 3625 44100, EmptyExtraData(), Unencrypted()); |
3700 stream_.reset(new SourceBufferStream(config, media_log_, true)); | 3626 stream_.reset(new SourceBufferStream(config, media_log_)); |
3701 Seek(0); | 3627 Seek(0); |
3702 | 3628 |
3703 // Note, in reality, a non-keyframe audio frame is rare or perhaps not | 3629 // Note, in reality, a non-keyframe audio frame is rare or perhaps not |
3704 // possible. | 3630 // possible. |
3705 NewCodedFrameGroupAppend("0K 30 30K 60"); | 3631 NewCodedFrameGroupAppend("0K 30 30K 60"); |
3706 CheckExpectedBuffers("0K 30 30K 60"); | 3632 CheckExpectedBuffers("0K 30 30K 60"); |
3707 } | 3633 } |
3708 | 3634 |
3709 // If seeking past any existing range and the seek is pending | 3635 // If seeking past any existing range and the seek is pending |
3710 // because no data has been provided for that position, | 3636 // because no data has been provided for that position, |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4082 SetTextStream(); | 4008 SetTextStream(); |
4083 NewCodedFrameGroupAppend("1500K 2000K 2500K 3000K 3500K"); | 4009 NewCodedFrameGroupAppend("1500K 2000K 2500K 3000K 3500K"); |
4084 CheckExpectedRangesByTimestamp("{ [1500,4000) }"); | 4010 CheckExpectedRangesByTimestamp("{ [1500,4000) }"); |
4085 NewCodedFrameGroupAppend("0K 501K 1001K 1501K 2001K"); | 4011 NewCodedFrameGroupAppend("0K 501K 1001K 1501K 2001K"); |
4086 CheckExpectedRangesByTimestamp("{ [0,4000) }"); | 4012 CheckExpectedRangesByTimestamp("{ [0,4000) }"); |
4087 | 4013 |
4088 Seek(0); | 4014 Seek(0); |
4089 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 3000K 3500K"); | 4015 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 3000K 3500K"); |
4090 } | 4016 } |
4091 | 4017 |
4092 TEST_F(SourceBufferStreamTest, SpliceFrame_Basic) { | 4018 TEST_F(SourceBufferStreamTest, Audio_SpliceTrimmingForOverlap) { |
4019 SetAudioStream(); | |
4093 Seek(0); | 4020 Seek(0); |
4094 NewCodedFrameGroupAppend("0K S(3K 6 9D3 10D5) 15 20 S(25K 30D5 35D5) 40"); | 4021 NewCodedFrameGroupAppend("0K 2K 4K 6K 8K 10K 12K"); |
4095 CheckExpectedBuffers("0K 3K 6 9 C 10 15 20 25K 30 C 35 40"); | 4022 CheckExpectedRangesByTimestamp("{ [0,14) }"); |
4023 // Note that duration of frame at time 10 is verified to be 2 ms. | |
4024 CheckExpectedBuffers("0K 2K 4K 6K 8K 10D2K 12K"); | |
4025 CheckNoNextBuffer(); | |
4026 | |
4027 // Append new group with front slightly overlapping existing buffer at 10ms. | |
4028 EXPECT_MEDIA_LOG(TrimmedSpliceOverlap(11000, 10000, 1000)); | |
4029 NewCodedFrameGroupAppend("11K 13K 15K 17K"); | |
4030 | |
4031 // Cross-fade splicing is no longer implemented. Instead we should expect | |
4032 // wholly overlapped buffers to be removed (12K). If a buffer is partially | |
4033 // overlapped (e.g. last millisecond of 10K), the existing buffer should be | |
4034 // trimmed to perfectly abut the newly appended buffers. | |
4035 Seek(0); | |
4036 CheckExpectedRangesByTimestamp("{ [0,19) }"); | |
4037 CheckExpectedBuffers("0K 2K 4K 6K 8K 10D1K 11D2K 13K 15K 17K"); | |
4096 CheckNoNextBuffer(); | 4038 CheckNoNextBuffer(); |
4097 } | 4039 } |
4098 | 4040 |
4099 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSplice) { | |
4100 Seek(0); | |
4101 NewCodedFrameGroupAppend("0K S(3K 6 9D3 10D5) 15K 20"); | |
4102 CheckExpectedBuffers("0K 3K 6"); | |
4103 | |
4104 SeekToTimestampMs(15); | |
4105 CheckExpectedBuffers("15K 20"); | |
4106 CheckNoNextBuffer(); | |
4107 } | |
4108 | |
4109 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSpliceFromTrackBuffer) { | |
4110 Seek(0); | |
4111 NewCodedFrameGroupAppend("0K 2K S(3K 6 9D3 10D5) 15K 20"); | |
4112 CheckExpectedBuffers("0K 2K"); | |
4113 | |
4114 // Overlap the existing coded frame group. | |
4115 NewCodedFrameGroupAppend("5K 15K 20"); | |
4116 CheckExpectedBuffers("3K 6"); | |
4117 | |
4118 SeekToTimestampMs(15); | |
4119 CheckExpectedBuffers("15K 20"); | |
4120 CheckNoNextBuffer(); | |
4121 } | |
4122 | |
4123 TEST_F(SourceBufferStreamTest, SpliceFrame_ConfigChangeWithinSplice) { | |
4124 VideoDecoderConfig new_config = TestVideoConfig::Large(); | |
4125 ASSERT_FALSE(new_config.Matches(video_config_)); | |
4126 | |
4127 // Add a new video config, then reset the config index back to the original. | |
4128 stream_->UpdateVideoConfig(new_config); | |
4129 stream_->UpdateVideoConfig(video_config_); | |
4130 | |
4131 Seek(0); | |
4132 CheckVideoConfig(video_config_); | |
4133 NewCodedFrameGroupAppend("0K S(3K 6C 9D3 10D5) 15"); | |
4134 | |
4135 CheckExpectedBuffers("0K 3K C"); | |
4136 CheckVideoConfig(new_config); | |
4137 CheckExpectedBuffers("6 9 C"); | |
4138 CheckExpectedBuffers("10 C"); | |
4139 CheckVideoConfig(video_config_); | |
4140 CheckExpectedBuffers("15"); | |
4141 CheckNoNextBuffer(); | |
4142 } | |
4143 | |
4144 TEST_F(SourceBufferStreamTest, SpliceFrame_BasicFromTrackBuffer) { | |
4145 Seek(0); | |
4146 NewCodedFrameGroupAppend("0K 5K S(8K 9D1 10D10) 20"); | |
4147 CheckExpectedBuffers("0K 5K"); | |
4148 | |
4149 // Overlap the existing coded frame group. | |
4150 NewCodedFrameGroupAppend("5K 20"); | |
4151 CheckExpectedBuffers("8K 9 C 10 20"); | |
4152 CheckNoNextBuffer(); | |
4153 } | |
4154 | |
4155 TEST_F(SourceBufferStreamTest, | |
4156 SpliceFrame_ConfigChangeWithinSpliceFromTrackBuffer) { | |
4157 VideoDecoderConfig new_config = TestVideoConfig::Large(); | |
4158 ASSERT_FALSE(new_config.Matches(video_config_)); | |
4159 | |
4160 // Add a new video config, then reset the config index back to the original. | |
4161 stream_->UpdateVideoConfig(new_config); | |
4162 stream_->UpdateVideoConfig(video_config_); | |
4163 | |
4164 Seek(0); | |
4165 CheckVideoConfig(video_config_); | |
4166 NewCodedFrameGroupAppend("0K 5K S(7K 8C 9D1 10D10) 20"); | |
4167 CheckExpectedBuffers("0K 5K"); | |
4168 | |
4169 // Overlap the existing coded frame group. | |
4170 NewCodedFrameGroupAppend("5K 20"); | |
4171 CheckExpectedBuffers("7K C"); | |
4172 CheckVideoConfig(new_config); | |
4173 CheckExpectedBuffers("8 9 C"); | |
4174 CheckExpectedBuffers("10 C"); | |
4175 CheckVideoConfig(video_config_); | |
4176 CheckExpectedBuffers("20"); | |
4177 CheckNoNextBuffer(); | |
4178 } | |
4179 | |
4180 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_Basic) { | |
4181 EXPECT_MEDIA_LOG(ContainsGeneratedSpliceLog(3000, 11000)); | |
4182 | |
4183 SetAudioStream(); | |
4184 Seek(0); | |
4185 NewCodedFrameGroupAppend("0K 2K 4K 6K 8K 10K 12K"); | |
4186 NewCodedFrameGroupAppend("11K 13K 15K 17K"); | |
4187 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11K 13K 15K 17K"); | |
4188 CheckNoNextBuffer(); | |
4189 } | |
4190 | |
4191 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoExactSplices) { | |
4192 EXPECT_MEDIA_LOG( | |
4193 HasSubstr("Skipping splice frame generation: first new buffer at 10000us " | |
4194 "begins at or before existing buffer at 10000us.")); | |
4195 | |
4196 SetAudioStream(); | |
4197 Seek(0); | |
4198 NewCodedFrameGroupAppend("0K 2K 4K 6K 8K 10K 12K"); | |
4199 NewCodedFrameGroupAppend("10K 14K"); | |
4200 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 14K"); | |
4201 CheckNoNextBuffer(); | |
4202 } | |
4203 | |
4204 // Do not allow splices on top of splices. | |
4205 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoDoubleSplice) { | |
4206 InSequence s; | |
4207 EXPECT_MEDIA_LOG(ContainsGeneratedSpliceLog(3000, 11000)); | |
4208 EXPECT_MEDIA_LOG( | |
4209 HasSubstr("Skipping splice frame generation: overlapped buffers at " | |
4210 "10000us are in a previously buffered splice.")); | |
4211 | |
4212 SetAudioStream(); | |
4213 Seek(0); | |
4214 NewCodedFrameGroupAppend("0K 2K 4K 6K 8K 10K 12K"); | |
4215 NewCodedFrameGroupAppend("11K 13K 15K 17K"); | |
4216 | |
4217 // Verify the splice was created. | |
4218 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11K 13K 15K 17K"); | |
4219 CheckNoNextBuffer(); | |
4220 Seek(0); | |
4221 | |
4222 // Create a splice before the first splice which would include it. | |
4223 NewCodedFrameGroupAppend("9D2K"); | |
4224 | |
4225 // A splice on top of a splice should result in a discard of the original | |
4226 // splice and no new splice frame being generated. | |
4227 CheckExpectedBuffers("0K 2K 4K 6K 8K 9K 13K 15K 17K"); | |
4228 CheckNoNextBuffer(); | |
4229 } | |
4230 | |
4231 // Test that a splice is not created if an end timestamp and start timestamp | |
4232 // overlap. | |
4233 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoSplice) { | |
4234 SetAudioStream(); | |
4235 Seek(0); | |
4236 NewCodedFrameGroupAppend("0K 2K 4K 6K 8K 10K"); | |
4237 NewCodedFrameGroupAppend("12K 14K 16K 18K"); | |
4238 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K 14K 16K 18K"); | |
4239 CheckNoNextBuffer(); | |
4240 } | |
4241 | |
4242 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_CorrectGroupStartTime) { | |
4243 EXPECT_MEDIA_LOG(ContainsGeneratedSpliceLog(5000, 1000)); | |
4244 | |
4245 SetAudioStream(); | |
4246 Seek(0); | |
4247 NewCodedFrameGroupAppend("0K 2K 4K"); | |
4248 CheckExpectedRangesByTimestamp("{ [0,6) }"); | |
4249 NewCodedFrameGroupAppend("6K 8K 10K"); | |
4250 CheckExpectedRangesByTimestamp("{ [0,12) }"); | |
4251 NewCodedFrameGroupAppend("1K 4D2K"); | |
4252 CheckExpectedRangesByTimestamp("{ [0,12) }"); | |
4253 CheckExpectedBuffers("0K 2K 4K C 1K 4K 6K 8K 10K"); | |
4254 CheckNoNextBuffer(); | |
4255 } | |
4256 | |
4257 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_ConfigChange) { | |
4258 EXPECT_MEDIA_LOG(ContainsGeneratedSpliceLog(3000, 5000)); | |
4259 | |
4260 SetAudioStream(); | |
4261 | |
4262 AudioDecoderConfig new_config(kCodecVorbis, kSampleFormatPlanarF32, | |
4263 CHANNEL_LAYOUT_MONO, 1000, EmptyExtraData(), | |
4264 Unencrypted()); | |
4265 ASSERT_NE(new_config.channel_layout(), audio_config_.channel_layout()); | |
4266 | |
4267 Seek(0); | |
4268 CheckAudioConfig(audio_config_); | |
4269 NewCodedFrameGroupAppend("0K 2K 4K 6K"); | |
4270 stream_->UpdateAudioConfig(new_config); | |
4271 NewCodedFrameGroupAppend("5K 8K 12K"); | |
4272 CheckExpectedBuffers("0K 2K 4K 6K C 5K 8K 12K"); | |
4273 CheckAudioConfig(new_config); | |
4274 CheckNoNextBuffer(); | |
4275 } | |
4276 | |
4277 // Ensure splices are not created if there are not enough frames to crossfade. | |
4278 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoTinySplices) { | |
4279 EXPECT_MEDIA_LOG(HasSubstr( | |
4280 "Skipping splice frame generation: not enough samples for splicing new " | |
4281 "buffer at 1000us. Have 1000us, but need 2000us.")); | |
4282 | |
4283 SetAudioStream(); | |
4284 Seek(0); | |
4285 | |
4286 // Overlap the range [0, 2) with [1, 3). Since each frame has a duration of | |
4287 // 2ms this results in an overlap of 1ms between the ranges. A splice frame | |
4288 // should not be generated since it requires at least 2 frames, or 2ms in this | |
4289 // case, of data to crossfade. | |
4290 NewCodedFrameGroupAppend("0D2K"); | |
4291 CheckExpectedRangesByTimestamp("{ [0,2) }"); | |
4292 NewCodedFrameGroupAppend("1D2K"); | |
4293 CheckExpectedRangesByTimestamp("{ [0,3) }"); | |
4294 CheckExpectedBuffers("0K 1K"); | |
4295 CheckNoNextBuffer(); | |
4296 } | |
4297 | |
4298 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoMillisecondSplices) { | |
DaleCurtis
2016/09/16 22:28:29
Some of these rejection tests should be ported as
chcunningham
2016/09/19 22:51:37
Done. Added back the following:
- NoMillisecondSpl
| |
4299 EXPECT_MEDIA_LOG( | |
4300 HasSubstr("Skipping splice frame generation: not enough samples for " | |
4301 "splicing new buffer at 1250us. Have 750us, but need 1000us.")); | |
4302 | |
4303 video_config_ = TestVideoConfig::Invalid(); | |
4304 audio_config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32, | |
4305 CHANNEL_LAYOUT_STEREO, 4000, EmptyExtraData(), | |
4306 Unencrypted(), base::TimeDelta(), 0); | |
4307 stream_.reset(new SourceBufferStream(audio_config_, media_log_, true)); | |
4308 // Equivalent to 0.5ms per frame. | |
4309 SetStreamInfo(2000, 2000); | |
4310 Seek(0); | |
4311 | |
4312 // Append four buffers with a 0.5ms duration each. | |
4313 NewCodedFrameGroupAppend(0, 4); | |
4314 CheckExpectedRangesByTimestamp("{ [0,2) }"); | |
4315 | |
4316 // Overlap the range [0, 2) with [1.25, 2); this results in an overlap of | |
4317 // 0.75ms between the ranges. | |
4318 NewCodedFrameGroupAppend_OffsetFirstBuffer( | |
4319 2, 2, base::TimeDelta::FromMillisecondsD(0.25)); | |
4320 CheckExpectedRangesByTimestamp("{ [0,2) }"); | |
4321 | |
4322 // A splice frame should not be generated (indicated by the lack of a config | |
4323 // change in the expected buffer string) since it requires at least 1ms of | |
4324 // data to crossfade. | |
4325 CheckExpectedBuffers("0K 0K 1K 1K"); | |
4326 CheckNoNextBuffer(); | |
4327 } | |
4328 | |
4329 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_Preroll) { | |
4330 EXPECT_MEDIA_LOG(ContainsGeneratedSpliceLog(3000, 11000)); | |
4331 | |
4332 SetAudioStream(); | |
4333 Seek(0); | |
4334 NewCodedFrameGroupAppend("0K 2K 4K 6K 8K 10K 12K"); | |
4335 NewCodedFrameGroupAppend("11P 13K 15K 17K"); | |
4336 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11P 13K 15K 17K"); | |
4337 CheckNoNextBuffer(); | |
4338 } | |
4339 | |
4340 TEST_F(SourceBufferStreamTest, Audio_PrerollFrame) { | 4041 TEST_F(SourceBufferStreamTest, Audio_PrerollFrame) { |
4341 Seek(0); | 4042 Seek(0); |
4342 NewCodedFrameGroupAppend("0K 3P 6K"); | 4043 NewCodedFrameGroupAppend("0K 3P 6K"); |
4343 CheckExpectedBuffers("0K 3P 6K"); | 4044 CheckExpectedBuffers("0K 3P 6K"); |
4344 CheckNoNextBuffer(); | 4045 CheckNoNextBuffer(); |
4345 } | 4046 } |
4346 | 4047 |
4347 TEST_F(SourceBufferStreamTest, BFrames) { | 4048 TEST_F(SourceBufferStreamTest, BFrames) { |
4348 Seek(0); | 4049 Seek(0); |
4349 NewCodedFrameGroupAppend("0K 120|30 30|60 60|90 90|120"); | 4050 NewCodedFrameGroupAppend("0K 120|30 30|60 60|90 90|120"); |
4350 CheckExpectedRangesByTimestamp("{ [0,150) }"); | 4051 CheckExpectedRangesByTimestamp("{ [0,150) }"); |
4351 | 4052 |
4352 CheckExpectedBuffers("0K 120|30 30|60 60|90 90|120"); | 4053 CheckExpectedBuffers("0K 120|30 30|60 60|90 90|120"); |
4353 CheckNoNextBuffer(); | 4054 CheckNoNextBuffer(); |
4354 } | 4055 } |
4355 | 4056 |
4356 TEST_F(SourceBufferStreamTest, RemoveShouldAlwaysExcludeEnd) { | |
4357 NewCodedFrameGroupAppend("10D2K 12D2 14D2"); | |
4358 CheckExpectedRangesByTimestamp("{ [10,16) }"); | |
4359 | |
4360 // Start new coded frame group, appending KF to abut the start of previous | |
4361 // group. | |
4362 NewCodedFrameGroupAppend("0D10K"); | |
4363 Seek(0); | |
4364 CheckExpectedRangesByTimestamp("{ [0,16) }"); | |
4365 CheckExpectedBuffers("0K 10K 12 14"); | |
4366 CheckNoNextBuffer(); | |
4367 | |
4368 // Append another buffer with the same timestamp as the last KF. This triggers | |
4369 // special logic that allows two buffers to have the same timestamp. When | |
4370 // preparing for this new append, there is no reason to remove the later GOP | |
4371 // starting at timestamp 10. This verifies the fix for http://crbug.com/469325 | |
4372 // where the decision *not* to remove the start of the overlapped range was | |
4373 // erroneously triggering buffers with a timestamp matching the end | |
4374 // of the append (and any later dependent frames) to be removed. | |
4375 AppendBuffers("0D10"); | |
4376 Seek(0); | |
4377 CheckExpectedRangesByTimestamp("{ [0,16) }"); | |
chcunningham
2016/09/19 22:51:37
Why this test was removed:
This test used to cove
wolenetz
2016/10/28 23:08:18
This test checks that 0D10K prepended to 10K..., f
chcunningham
2016/11/02 01:28:42
Yep, this test passes now. My original comment was
wolenetz
2016/11/02 20:39:34
Acknowledged.
| |
4378 CheckExpectedBuffers("0K 0 10K 12 14"); | |
4379 CheckNoNextBuffer(); | |
4380 } | |
4381 | |
4382 TEST_F(SourceBufferStreamTest, RefinedDurationEstimates_BackOverlap) { | 4057 TEST_F(SourceBufferStreamTest, RefinedDurationEstimates_BackOverlap) { |
4383 // Append a few buffers, the last one having estimated duration. | 4058 // Append a few buffers, the last one having estimated duration. |
4384 NewCodedFrameGroupAppend("0K 5 10 20D10E"); | 4059 NewCodedFrameGroupAppend("0K 5 10 20D10E"); |
4385 CheckExpectedRangesByTimestamp("{ [0,30) }"); | 4060 CheckExpectedRangesByTimestamp("{ [0,30) }"); |
4386 Seek(0); | 4061 Seek(0); |
4387 CheckExpectedBuffers("0K 5 10 20D10E"); | 4062 CheckExpectedBuffers("0K 5 10 20D10E"); |
4388 CheckNoNextBuffer(); | 4063 CheckNoNextBuffer(); |
4389 | 4064 |
4390 // Append a buffer to the end that overlaps the *back* of the existing range. | 4065 // Append a buffer to the end that overlaps the *back* of the existing range. |
4391 // This should trigger the estimated duration to be recomputed as a timestamp | 4066 // This should trigger the estimated duration to be recomputed as a timestamp |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4820 EXPECT_EQ(base::TimeDelta(), stream_->GetHighestPresentationTimestamp()); | 4495 EXPECT_EQ(base::TimeDelta(), stream_->GetHighestPresentationTimestamp()); |
4821 } | 4496 } |
4822 | 4497 |
4823 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. | 4498 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. |
4824 // (crbug.com/133557) | 4499 // (crbug.com/133557) |
4825 | 4500 |
4826 // TODO(vrk): Add unit tests with end of stream being called at interesting | 4501 // TODO(vrk): Add unit tests with end of stream being called at interesting |
4827 // times. | 4502 // times. |
4828 | 4503 |
4829 } // namespace media | 4504 } // namespace media |
OLD | NEW |