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/chunk_demuxer.h" | 5 #include "media/filters/chunk_demuxer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "media/base/audio_decoder_config.h" | 18 #include "media/base/audio_decoder_config.h" |
19 #include "media/base/decoder_buffer.h" | 19 #include "media/base/decoder_buffer.h" |
20 #include "media/base/decrypt_config.h" | 20 #include "media/base/decrypt_config.h" |
21 #include "media/base/media_log.h" | |
22 #include "media/base/mock_demuxer_host.h" | 21 #include "media/base/mock_demuxer_host.h" |
| 22 #include "media/base/mock_media_log.h" |
23 #include "media/base/test_data_util.h" | 23 #include "media/base/test_data_util.h" |
24 #include "media/base/test_helpers.h" | 24 #include "media/base/test_helpers.h" |
25 #include "media/base/timestamp_constants.h" | 25 #include "media/base/timestamp_constants.h" |
26 #include "media/formats/webm/cluster_builder.h" | 26 #include "media/formats/webm/cluster_builder.h" |
| 27 #include "media/formats/webm/webm_cluster_parser.h" |
27 #include "media/formats/webm/webm_constants.h" | 28 #include "media/formats/webm/webm_constants.h" |
28 #include "media/media_features.h" | 29 #include "media/media_features.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 | 31 |
31 using ::testing::AnyNumber; | 32 using ::testing::AnyNumber; |
32 using ::testing::Exactly; | 33 using ::testing::Exactly; |
33 using ::testing::InSequence; | 34 using ::testing::InSequence; |
34 using ::testing::NotNull; | 35 using ::testing::NotNull; |
35 using ::testing::Return; | 36 using ::testing::Return; |
36 using ::testing::SaveArg; | 37 using ::testing::SaveArg; |
37 using ::testing::SetArgumentPointee; | 38 using ::testing::SetArgumentPointee; |
| 39 using ::testing::StrictMock; |
38 using ::testing::_; | 40 using ::testing::_; |
39 | 41 |
40 namespace media { | 42 namespace media { |
41 | 43 |
42 const uint8_t kTracksHeader[] = { | 44 const uint8_t kTracksHeader[] = { |
43 0x16, 0x54, 0xAE, 0x6B, // Tracks ID | 45 0x16, 0x54, 0xAE, 0x6B, // Tracks ID |
44 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // tracks(size = 0) | 46 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // tracks(size = 0) |
45 }; | 47 }; |
46 | 48 |
47 // WebM Block bytes that represent a VP8 key frame. | 49 // WebM Block bytes that represent a VP8 key frame. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 112 } |
111 } | 113 } |
112 | 114 |
113 MATCHER_P(HasTimestamp, timestamp_in_ms, "") { | 115 MATCHER_P(HasTimestamp, timestamp_in_ms, "") { |
114 return arg.get() && !arg->end_of_stream() && | 116 return arg.get() && !arg->end_of_stream() && |
115 arg->timestamp().InMilliseconds() == timestamp_in_ms; | 117 arg->timestamp().InMilliseconds() == timestamp_in_ms; |
116 } | 118 } |
117 | 119 |
118 MATCHER(IsEndOfStream, "") { return arg.get() && arg->end_of_stream(); } | 120 MATCHER(IsEndOfStream, "") { return arg.get() && arg->end_of_stream(); } |
119 | 121 |
| 122 MATCHER(StreamParsingFailed, "") { |
| 123 return CONTAINS_STRING(arg, "Append: stream parsing failed."); |
| 124 } |
| 125 |
| 126 MATCHER_P(FoundStream, stream_type_string, "") { |
| 127 return CONTAINS_STRING( |
| 128 arg, "found_" + std::string(stream_type_string) + "_stream") && |
| 129 CONTAINS_STRING(arg, "true"); |
| 130 } |
| 131 |
| 132 MATCHER_P2(CodecName, stream_type_string, codec_string, "") { |
| 133 return CONTAINS_STRING(arg, |
| 134 std::string(stream_type_string) + "_codec_name") && |
| 135 CONTAINS_STRING(arg, std::string(codec_string)); |
| 136 } |
| 137 |
| 138 MATCHER_P2(InitSegmentMismatchesMimeType, |
| 139 track_type_string_with_article, |
| 140 mime_missing_track_type_bool, |
| 141 "") { |
| 142 return CONTAINS_STRING( |
| 143 arg, "Initialization segment " + |
| 144 std::string(mime_missing_track_type_bool ? "has " |
| 145 : "does not have ") + |
| 146 std::string(track_type_string_with_article) + |
| 147 " track, but the mimetype " + |
| 148 std::string(mime_missing_track_type_bool ? "does not specify " |
| 149 : "specifies ") + |
| 150 std::string(track_type_string_with_article) + " codec."); |
| 151 } |
| 152 |
| 153 MATCHER_P2(GeneratedSplice, duration_microseconds, time_microseconds, "") { |
| 154 return CONTAINS_STRING(arg, "Generated splice of overlap duration " + |
| 155 base::IntToString(duration_microseconds) + |
| 156 "us into new buffer at " + |
| 157 base::IntToString(time_microseconds) + "us."); |
| 158 } |
| 159 |
| 160 MATCHER_P2(SkippingSpliceAtOrBefore, |
| 161 new_microseconds, |
| 162 existing_microseconds, |
| 163 "") { |
| 164 return CONTAINS_STRING( |
| 165 arg, "Skipping splice frame generation: first new buffer at " + |
| 166 base::IntToString(new_microseconds) + |
| 167 "us begins at or before existing buffer at " + |
| 168 base::IntToString(existing_microseconds) + "us."); |
| 169 } |
| 170 |
| 171 MATCHER_P(SkippingSpliceAlreadySpliced, time_microseconds, "") { |
| 172 return CONTAINS_STRING( |
| 173 arg, "Skipping splice frame generation: overlapped buffers at " + |
| 174 base::IntToString(time_microseconds) + |
| 175 "us are in a previously buffered splice."); |
| 176 } |
| 177 |
| 178 MATCHER_P(WebMSimpleBlockDurationEstimated, estimated_duration_ms, "") { |
| 179 return CONTAINS_STRING(arg, "Estimating WebM block duration to be " + |
| 180 base::IntToString(estimated_duration_ms) + |
| 181 "ms for the last (Simple)Block in the " |
| 182 "Cluster for this Track. Use BlockGroups " |
| 183 "with BlockDurations at the end of each " |
| 184 "Track in a Cluster to avoid estimation."); |
| 185 } |
| 186 |
| 187 MATCHER_P(WebMNegativeTimecodeOffset, timecode_string, "") { |
| 188 return CONTAINS_STRING(arg, "Got a block with negative timecode offset " + |
| 189 std::string(timecode_string)); |
| 190 } |
| 191 |
| 192 MATCHER(WebMOutOfOrderTimecode, "") { |
| 193 return CONTAINS_STRING( |
| 194 arg, "Got a block with a timecode before the previous block."); |
| 195 } |
| 196 |
| 197 MATCHER(WebMClusterBeforeFirstInfo, "") { |
| 198 return CONTAINS_STRING(arg, "Found Cluster element before Info."); |
| 199 } |
| 200 |
120 static void OnReadDone(const base::TimeDelta& expected_time, | 201 static void OnReadDone(const base::TimeDelta& expected_time, |
121 bool* called, | 202 bool* called, |
122 DemuxerStream::Status status, | 203 DemuxerStream::Status status, |
123 const scoped_refptr<DecoderBuffer>& buffer) { | 204 const scoped_refptr<DecoderBuffer>& buffer) { |
124 EXPECT_EQ(status, DemuxerStream::kOk); | 205 EXPECT_EQ(status, DemuxerStream::kOk); |
125 EXPECT_EQ(expected_time, buffer->timestamp()); | 206 EXPECT_EQ(expected_time, buffer->timestamp()); |
126 *called = true; | 207 *called = true; |
127 } | 208 } |
128 | 209 |
129 static void OnReadDone_AbortExpected( | 210 static void OnReadDone_AbortExpected( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // Default cluster to append after kDefaultFirstCluster() | 244 // Default cluster to append after kDefaultFirstCluster() |
164 // has been appended. This cluster starts with blocks that | 245 // has been appended. This cluster starts with blocks that |
165 // have timestamps consistent with the end times of the blocks | 246 // have timestamps consistent with the end times of the blocks |
166 // in kDefaultFirstCluster() so that these two clusters represent | 247 // in kDefaultFirstCluster() so that these two clusters represent |
167 // a continuous region. | 248 // a continuous region. |
168 scoped_ptr<Cluster> kDefaultSecondCluster() { | 249 scoped_ptr<Cluster> kDefaultSecondCluster() { |
169 return GenerateCluster(46, 66, 5); | 250 return GenerateCluster(46, 66, 5); |
170 } | 251 } |
171 | 252 |
172 ChunkDemuxerTest() | 253 ChunkDemuxerTest() |
173 : append_window_end_for_next_append_(kInfiniteDuration()) { | 254 : media_log_(new StrictMock<MockMediaLog>()), |
| 255 append_window_end_for_next_append_(kInfiniteDuration()) { |
174 init_segment_received_cb_ = | 256 init_segment_received_cb_ = |
175 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, | 257 base::Bind(&ChunkDemuxerTest::InitSegmentReceived, |
176 base::Unretained(this)); | 258 base::Unretained(this)); |
177 CreateNewDemuxer(); | 259 CreateNewDemuxer(); |
178 } | 260 } |
179 | 261 |
180 void CreateNewDemuxer() { | 262 void CreateNewDemuxer() { |
181 base::Closure open_cb = | 263 base::Closure open_cb = |
182 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); | 264 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); |
183 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind( | 265 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind( |
184 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this)); | 266 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this)); |
185 demuxer_.reset(new ChunkDemuxer(open_cb, encrypted_media_init_data_cb, | 267 demuxer_.reset(new ChunkDemuxer(open_cb, encrypted_media_init_data_cb, |
186 scoped_refptr<MediaLog>(new MediaLog()), | 268 media_log_, true)); |
187 true)); | |
188 } | 269 } |
189 | 270 |
190 virtual ~ChunkDemuxerTest() { | 271 virtual ~ChunkDemuxerTest() { |
191 ShutdownDemuxer(); | 272 ShutdownDemuxer(); |
192 } | 273 } |
193 | 274 |
194 void CreateInitSegment(int stream_flags, | 275 void CreateInitSegment(int stream_flags, |
195 bool is_audio_encrypted, | 276 bool is_audio_encrypted, |
196 bool is_video_encrypted, | 277 bool is_video_encrypted, |
197 scoped_ptr<uint8_t[]>* buffer, | 278 scoped_ptr<uint8_t[]>* buffer, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } | 518 } |
438 }; | 519 }; |
439 | 520 |
440 // |track_number| - The track number to place in | 521 // |track_number| - The track number to place in |
441 // |block_descriptions| - A space delimited string of block info that | 522 // |block_descriptions| - A space delimited string of block info that |
442 // is used to populate |blocks|. Each block info has a timestamp in | 523 // is used to populate |blocks|. Each block info has a timestamp in |
443 // milliseconds and optionally followed by a 'K' to indicate that a block | 524 // milliseconds and optionally followed by a 'K' to indicate that a block |
444 // should be marked as a key frame. For example "0K 30 60" should populate | 525 // should be marked as a key frame. For example "0K 30 60" should populate |
445 // |blocks| with 3 BlockInfo objects: a key frame with timestamp 0 and 2 | 526 // |blocks| with 3 BlockInfo objects: a key frame with timestamp 0 and 2 |
446 // non-key-frames at 30ms and 60ms. | 527 // non-key-frames at 30ms and 60ms. |
| 528 // Every block will be a SimpleBlock, with the exception that the last block |
| 529 // may have an optional duration delimited with a 'D' and appended to the |
| 530 // block info timestamp, prior to the optional keyframe 'K'. For example "0K |
| 531 // 30 60D10K" indicates that the last block will be a keyframe BlockGroup |
| 532 // with duration 10ms. |
447 void ParseBlockDescriptions(int track_number, | 533 void ParseBlockDescriptions(int track_number, |
448 const std::string block_descriptions, | 534 const std::string block_descriptions, |
449 std::vector<BlockInfo>* blocks) { | 535 std::vector<BlockInfo>* blocks) { |
450 std::vector<std::string> timestamps = base::SplitString( | 536 std::vector<std::string> timestamps = base::SplitString( |
451 block_descriptions, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 537 block_descriptions, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
452 | 538 |
453 for (size_t i = 0; i < timestamps.size(); ++i) { | 539 for (size_t i = 0; i < timestamps.size(); ++i) { |
454 std::string timestamp_str = timestamps[i]; | 540 std::string timestamp_str = timestamps[i]; |
455 BlockInfo block_info; | 541 BlockInfo block_info; |
456 block_info.track_number = track_number; | 542 block_info.track_number = track_number; |
457 block_info.flags = 0; | 543 block_info.flags = 0; |
458 block_info.duration = 0; | 544 block_info.duration = 0; |
459 | 545 |
460 if (base::EndsWith(timestamp_str, "K", base::CompareCase::SENSITIVE)) { | 546 if (base::EndsWith(timestamp_str, "K", base::CompareCase::SENSITIVE)) { |
461 block_info.flags = kWebMFlagKeyframe; | 547 block_info.flags = kWebMFlagKeyframe; |
462 // Remove the "K" off of the token. | 548 // Remove the "K" off of the token. |
463 timestamp_str = timestamp_str.substr(0, timestamps[i].length() - 1); | 549 timestamp_str = timestamp_str.substr(0, timestamps[i].length() - 1); |
464 } | 550 } |
| 551 |
| 552 size_t duration_pos = timestamp_str.find('D'); |
| 553 const bool explicit_duration = duration_pos != std::string::npos; |
| 554 const bool is_last_block = i == timestamps.size() - 1; |
| 555 CHECK(!explicit_duration || is_last_block); |
| 556 if (explicit_duration) { |
| 557 CHECK(base::StringToInt(timestamp_str.substr(duration_pos + 1), |
| 558 &block_info.duration)); |
| 559 timestamp_str = timestamp_str.substr(0, duration_pos); |
| 560 } |
| 561 |
465 CHECK(base::StringToInt(timestamp_str, &block_info.timestamp_in_ms)); | 562 CHECK(base::StringToInt(timestamp_str, &block_info.timestamp_in_ms)); |
466 | 563 |
467 if (track_number == kTextTrackNum || | 564 if (track_number == kTextTrackNum || |
468 track_number == kAlternateTextTrackNum) { | 565 track_number == kAlternateTextTrackNum) { |
469 block_info.duration = kTextBlockDuration; | 566 block_info.duration = kTextBlockDuration; |
470 ASSERT_EQ(kWebMFlagKeyframe, block_info.flags) | 567 ASSERT_EQ(kWebMFlagKeyframe, block_info.flags) |
471 << "Text block with timestamp " << block_info.timestamp_in_ms | 568 << "Text block with timestamp " << block_info.timestamp_in_ms |
472 << " was not marked as a key frame." | 569 << " was not marked as a key frame." |
473 << " All text blocks must be key frames"; | 570 << " All text blocks must be key frames"; |
474 } | 571 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 void AppendSingleStreamCluster(const std::string& source_id, int track_number, | 625 void AppendSingleStreamCluster(const std::string& source_id, int track_number, |
529 const std::string& block_descriptions) { | 626 const std::string& block_descriptions) { |
530 std::vector<BlockInfo> blocks; | 627 std::vector<BlockInfo> blocks; |
531 ParseBlockDescriptions(track_number, block_descriptions, &blocks); | 628 ParseBlockDescriptions(track_number, block_descriptions, &blocks); |
532 AppendCluster(source_id, GenerateCluster(blocks, false)); | 629 AppendCluster(source_id, GenerateCluster(blocks, false)); |
533 } | 630 } |
534 | 631 |
535 struct MuxedStreamInfo { | 632 struct MuxedStreamInfo { |
536 MuxedStreamInfo() | 633 MuxedStreamInfo() |
537 : track_number(0), | 634 : track_number(0), |
538 block_descriptions("") | 635 block_descriptions(""), |
539 {} | 636 last_blocks_estimated_duration(-1) {} |
540 | 637 |
541 MuxedStreamInfo(int track_num, const char* block_desc) | 638 MuxedStreamInfo(int track_num, const char* block_desc) |
542 : track_number(track_num), | 639 : track_number(track_num), |
543 block_descriptions(block_desc) { | 640 block_descriptions(block_desc), |
544 } | 641 last_blocks_estimated_duration(-1) {} |
| 642 |
| 643 MuxedStreamInfo(int track_num, |
| 644 const char* block_desc, |
| 645 int last_block_duration_estimate) |
| 646 : track_number(track_num), |
| 647 block_descriptions(block_desc), |
| 648 last_blocks_estimated_duration(last_block_duration_estimate) {} |
545 | 649 |
546 int track_number; | 650 int track_number; |
547 // The block description passed to ParseBlockDescriptions(). | 651 // The block description passed to ParseBlockDescriptions(). |
548 // See the documentation for that method for details on the string format. | 652 // See the documentation for that method for details on the string format. |
549 const char* block_descriptions; | 653 const char* block_descriptions; |
| 654 |
| 655 // If -1, no WebMSimpleBlockDurationEstimated MediaLog expectation is added |
| 656 // when appending the resulting cluster. Otherwise, an expectation (in ms) |
| 657 // is added. |
| 658 int last_blocks_estimated_duration; |
550 }; | 659 }; |
551 | 660 |
552 void AppendMuxedCluster(const MuxedStreamInfo& msi_1, | 661 void AppendMuxedCluster(const MuxedStreamInfo& msi_1, |
553 const MuxedStreamInfo& msi_2) { | 662 const MuxedStreamInfo& msi_2) { |
554 std::vector<MuxedStreamInfo> msi(2); | 663 std::vector<MuxedStreamInfo> msi(2); |
555 msi[0] = msi_1; | 664 msi[0] = msi_1; |
556 msi[1] = msi_2; | 665 msi[1] = msi_2; |
557 AppendMuxedCluster(msi); | 666 AppendMuxedCluster(msi); |
558 } | 667 } |
559 | 668 |
560 void AppendMuxedCluster(const MuxedStreamInfo& msi_1, | 669 void AppendMuxedCluster(const MuxedStreamInfo& msi_1, |
561 const MuxedStreamInfo& msi_2, | 670 const MuxedStreamInfo& msi_2, |
562 const MuxedStreamInfo& msi_3) { | 671 const MuxedStreamInfo& msi_3) { |
563 std::vector<MuxedStreamInfo> msi(3); | 672 std::vector<MuxedStreamInfo> msi(3); |
564 msi[0] = msi_1; | 673 msi[0] = msi_1; |
565 msi[1] = msi_2; | 674 msi[1] = msi_2; |
566 msi[2] = msi_3; | 675 msi[2] = msi_3; |
567 AppendMuxedCluster(msi); | 676 AppendMuxedCluster(msi); |
568 } | 677 } |
569 | 678 |
570 void AppendMuxedCluster(const std::vector<MuxedStreamInfo> msi) { | 679 void AppendMuxedCluster(const std::vector<MuxedStreamInfo> msi) { |
571 std::priority_queue<BlockInfo> block_queue; | 680 std::priority_queue<BlockInfo> block_queue; |
572 for (size_t i = 0; i < msi.size(); ++i) { | 681 for (size_t i = 0; i < msi.size(); ++i) { |
573 std::vector<BlockInfo> track_blocks; | 682 std::vector<BlockInfo> track_blocks; |
574 ParseBlockDescriptions(msi[i].track_number, msi[i].block_descriptions, | 683 ParseBlockDescriptions(msi[i].track_number, msi[i].block_descriptions, |
575 &track_blocks); | 684 &track_blocks); |
576 | 685 |
577 for (size_t j = 0; j < track_blocks.size(); ++j) | 686 for (size_t j = 0; j < track_blocks.size(); ++j) { |
578 block_queue.push(track_blocks[j]); | 687 block_queue.push(track_blocks[j]); |
| 688 } |
| 689 |
| 690 if (msi[i].last_blocks_estimated_duration != -1) { |
| 691 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated( |
| 692 msi[i].last_blocks_estimated_duration)); |
| 693 } |
579 } | 694 } |
580 | 695 |
581 AppendCluster(kSourceId, GenerateCluster(block_queue, false)); | 696 AppendCluster(kSourceId, GenerateCluster(block_queue, false)); |
582 } | 697 } |
583 | 698 |
584 void AppendData(const std::string& source_id, | 699 void AppendData(const std::string& source_id, |
585 const uint8_t* data, | 700 const uint8_t* data, |
586 size_t length) { | 701 size_t length) { |
587 EXPECT_CALL(host_, OnBufferedTimeRangesChanged(_)).Times(AnyNumber()); | 702 EXPECT_CALL(host_, OnBufferedTimeRangesChanged(_)).Times(AnyNumber()); |
588 | 703 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 enum StreamFlags { | 780 enum StreamFlags { |
666 HAS_AUDIO = 1 << 0, | 781 HAS_AUDIO = 1 << 0, |
667 HAS_VIDEO = 1 << 1, | 782 HAS_VIDEO = 1 << 1, |
668 HAS_TEXT = 1 << 2 | 783 HAS_TEXT = 1 << 2 |
669 }; | 784 }; |
670 | 785 |
671 bool InitDemuxer(int stream_flags) { | 786 bool InitDemuxer(int stream_flags) { |
672 return InitDemuxerWithEncryptionInfo(stream_flags, false, false); | 787 return InitDemuxerWithEncryptionInfo(stream_flags, false, false); |
673 } | 788 } |
674 | 789 |
| 790 void ExpectInitMediaLogs(int stream_flags) { |
| 791 if (stream_flags & HAS_AUDIO) { |
| 792 EXPECT_MEDIA_LOG(FoundStream("audio")); |
| 793 EXPECT_MEDIA_LOG(CodecName("audio", "vorbis")); |
| 794 } |
| 795 |
| 796 if (stream_flags & HAS_VIDEO) { |
| 797 EXPECT_MEDIA_LOG(FoundStream("video")); |
| 798 EXPECT_MEDIA_LOG(CodecName("video", "vp8")); |
| 799 } |
| 800 } |
| 801 |
675 bool InitDemuxerWithEncryptionInfo( | 802 bool InitDemuxerWithEncryptionInfo( |
676 int stream_flags, bool is_audio_encrypted, bool is_video_encrypted) { | 803 int stream_flags, bool is_audio_encrypted, bool is_video_encrypted) { |
677 | 804 |
678 PipelineStatus expected_status = | 805 PipelineStatus expected_status = |
679 (stream_flags != 0) ? PIPELINE_OK : PIPELINE_ERROR_DECODE; | 806 (stream_flags != 0) ? PIPELINE_OK : PIPELINE_ERROR_DECODE; |
680 | 807 |
681 base::TimeDelta expected_duration = kNoTimestamp(); | 808 base::TimeDelta expected_duration = kNoTimestamp(); |
682 if (expected_status == PIPELINE_OK) | 809 if (expected_status == PIPELINE_OK) |
683 expected_duration = kDefaultDuration(); | 810 expected_duration = kDefaultDuration(); |
684 | 811 |
685 EXPECT_CALL(*this, DemuxerOpened()); | 812 EXPECT_CALL(*this, DemuxerOpened()); |
686 | 813 |
687 // Adding expectation prior to CreateInitDoneCB() here because InSequence | 814 if (is_audio_encrypted || is_video_encrypted) { |
| 815 DCHECK(!is_audio_encrypted || stream_flags & HAS_AUDIO); |
| 816 DCHECK(!is_video_encrypted || stream_flags & HAS_VIDEO); |
| 817 |
| 818 int need_key_count = |
| 819 (is_audio_encrypted ? 1 : 0) + (is_video_encrypted ? 1 : 0); |
| 820 EXPECT_CALL(*this, OnEncryptedMediaInitData( |
| 821 EmeInitDataType::WEBM, |
| 822 std::vector<uint8_t>( |
| 823 kEncryptedMediaInitData, |
| 824 kEncryptedMediaInitData + |
| 825 arraysize(kEncryptedMediaInitData)))) |
| 826 .Times(Exactly(need_key_count)); |
| 827 } |
| 828 |
| 829 // Adding expectations prior to CreateInitDoneCB() here because InSequence |
688 // tests require init segment received before duration set. Also, only | 830 // tests require init segment received before duration set. Also, only |
689 // expect an init segment received callback if there is actually a track in | 831 // expect an init segment received callback if there is actually a track in |
690 // it. | 832 // it. |
691 if (stream_flags != 0) | 833 if (stream_flags != 0) { |
| 834 ExpectInitMediaLogs(stream_flags); |
692 EXPECT_CALL(*this, InitSegmentReceived()); | 835 EXPECT_CALL(*this, InitSegmentReceived()); |
| 836 } else { |
| 837 // OnNewConfigs() requires at least one audio, video, or text track. |
| 838 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
| 839 } |
693 | 840 |
694 demuxer_->Initialize( | 841 demuxer_->Initialize( |
695 &host_, CreateInitDoneCB(expected_duration, expected_status), true); | 842 &host_, CreateInitDoneCB(expected_duration, expected_status), true); |
696 | 843 |
697 if (AddId(kSourceId, stream_flags) != ChunkDemuxer::kOk) | 844 if (AddId(kSourceId, stream_flags) != ChunkDemuxer::kOk) |
698 return false; | 845 return false; |
699 | 846 |
700 AppendInitSegmentWithEncryptedInfo( | 847 AppendInitSegmentWithEncryptedInfo( |
701 kSourceId, stream_flags, | 848 kSourceId, stream_flags, |
702 is_audio_encrypted, is_video_encrypted); | 849 is_audio_encrypted, is_video_encrypted); |
(...skipping 13 matching lines...) Expand all Loading... |
716 return false; | 863 return false; |
717 | 864 |
718 int audio_flags = HAS_AUDIO; | 865 int audio_flags = HAS_AUDIO; |
719 int video_flags = HAS_VIDEO; | 866 int video_flags = HAS_VIDEO; |
720 | 867 |
721 if (has_text) { | 868 if (has_text) { |
722 audio_flags |= HAS_TEXT; | 869 audio_flags |= HAS_TEXT; |
723 video_flags |= HAS_TEXT; | 870 video_flags |= HAS_TEXT; |
724 } | 871 } |
725 | 872 |
| 873 // Note: Unlike InitDemuxerWithEncryptionInfo, this method is currently |
| 874 // incompatible with InSequence tests. Refactoring of the duration |
| 875 // set expectation to not be added during CreateInitDoneCB() could fix this. |
| 876 ExpectInitMediaLogs(audio_flags); |
726 EXPECT_CALL(*this, InitSegmentReceived()); | 877 EXPECT_CALL(*this, InitSegmentReceived()); |
727 AppendInitSegmentWithSourceId(audio_id, audio_flags); | 878 AppendInitSegmentWithSourceId(audio_id, audio_flags); |
| 879 |
| 880 ExpectInitMediaLogs(video_flags); |
728 EXPECT_CALL(*this, InitSegmentReceived()); | 881 EXPECT_CALL(*this, InitSegmentReceived()); |
729 AppendInitSegmentWithSourceId(video_id, video_flags); | 882 AppendInitSegmentWithSourceId(video_id, video_flags); |
730 return true; | 883 return true; |
731 } | 884 } |
732 | 885 |
733 bool InitDemuxerAudioAndVideoSources(const std::string& audio_id, | 886 bool InitDemuxerAudioAndVideoSources(const std::string& audio_id, |
734 const std::string& video_id) { | 887 const std::string& video_id) { |
735 return InitDemuxerAudioAndVideoSourcesText(audio_id, video_id, false); | 888 return InitDemuxerAudioAndVideoSourcesText(audio_id, video_id, false); |
736 } | 889 } |
737 | 890 |
(...skipping 15 matching lines...) Expand all Loading... |
753 // bear-320x240.webm : [0-524) [779-2736) | 906 // bear-320x240.webm : [0-524) [779-2736) |
754 // bear-640x360.webm : [527-759) | 907 // bear-640x360.webm : [527-759) |
755 bool InitDemuxerWithConfigChangeData() { | 908 bool InitDemuxerWithConfigChangeData() { |
756 scoped_refptr<DecoderBuffer> bear1 = ReadTestDataFile("bear-320x240.webm"); | 909 scoped_refptr<DecoderBuffer> bear1 = ReadTestDataFile("bear-320x240.webm"); |
757 scoped_refptr<DecoderBuffer> bear2 = ReadTestDataFile("bear-640x360.webm"); | 910 scoped_refptr<DecoderBuffer> bear2 = ReadTestDataFile("bear-640x360.webm"); |
758 | 911 |
759 EXPECT_CALL(*this, DemuxerOpened()); | 912 EXPECT_CALL(*this, DemuxerOpened()); |
760 | 913 |
761 // Adding expectation prior to CreateInitDoneCB() here because InSequence | 914 // Adding expectation prior to CreateInitDoneCB() here because InSequence |
762 // tests require init segment received before duration set. | 915 // tests require init segment received before duration set. |
| 916 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); |
763 EXPECT_CALL(*this, InitSegmentReceived()); | 917 EXPECT_CALL(*this, InitSegmentReceived()); |
764 demuxer_->Initialize( | 918 demuxer_->Initialize( |
765 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), | 919 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), |
766 PIPELINE_OK), true); | 920 PIPELINE_OK), true); |
767 | 921 |
768 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) | 922 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) |
769 return false; | 923 return false; |
770 | 924 |
771 // Append the whole bear1 file. | 925 // Append the whole bear1 file. |
| 926 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)).Times(7); |
772 // Expect duration adjustment since actual duration differs slightly from | 927 // Expect duration adjustment since actual duration differs slightly from |
773 // duration in the init segment. | 928 // duration in the init segment. |
774 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 929 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
775 AppendData(bear1->data(), bear1->data_size()); | 930 AppendData(bear1->data(), bear1->data_size()); |
776 // Last audio frame has timestamp 2721 and duration 24 (estimated from max | 931 // Last audio frame has timestamp 2721 and duration 24 (estimated from max |
777 // seen so far for audio track). | 932 // seen so far for audio track). |
778 // Last video frame has timestamp 2703 and duration 33 (from TrackEntry | 933 // Last video frame has timestamp 2703 and duration 33 (from TrackEntry |
779 // DefaultDuration for video track). | 934 // DefaultDuration for video track). |
780 CheckExpectedRanges(kSourceId, "{ [0,2736) }"); | 935 CheckExpectedRanges(kSourceId, "{ [0,2736) }"); |
781 | 936 |
782 // Append initialization segment for bear2. | 937 // Append initialization segment for bear2. |
783 // Note: Offsets here and below are derived from | 938 // Note: Offsets here and below are derived from |
784 // media/test/data/bear-640x360-manifest.js and | 939 // media/test/data/bear-640x360-manifest.js and |
785 // media/test/data/bear-320x240-manifest.js which were | 940 // media/test/data/bear-320x240-manifest.js which were |
786 // generated from media/test/data/bear-640x360.webm and | 941 // generated from media/test/data/bear-640x360.webm and |
787 // media/test/data/bear-320x240.webm respectively. | 942 // media/test/data/bear-320x240.webm respectively. |
788 EXPECT_CALL(*this, InitSegmentReceived()); | 943 EXPECT_CALL(*this, InitSegmentReceived()); |
789 AppendData(bear2->data(), 4340); | 944 AppendData(bear2->data(), 4340); |
790 | 945 |
791 // Append a media segment that goes from [0.527000, 1.014000). | 946 // Append a media segment that goes from [0.527000, 1.014000). |
| 947 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); |
| 948 EXPECT_MEDIA_LOG(GeneratedSplice(20000, 527000)); |
792 AppendData(bear2->data() + 55290, 18785); | 949 AppendData(bear2->data() + 55290, 18785); |
793 CheckExpectedRanges(kSourceId, "{ [0,1027) [1201,2736) }"); | 950 CheckExpectedRanges(kSourceId, "{ [0,1027) [1201,2736) }"); |
794 | 951 |
795 // Append initialization segment for bear1 & fill gap with [779-1197) | 952 // Append initialization segment for bear1 & fill gap with [779-1197) |
796 // segment. | 953 // segment. |
797 EXPECT_CALL(*this, InitSegmentReceived()); | 954 EXPECT_CALL(*this, InitSegmentReceived()); |
798 AppendData(bear1->data(), 4370); | 955 AppendData(bear1->data(), 4370); |
| 956 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)); |
| 957 EXPECT_MEDIA_LOG(GeneratedSplice(26000, 779000)); |
799 AppendData(bear1->data() + 72737, 28183); | 958 AppendData(bear1->data() + 72737, 28183); |
800 CheckExpectedRanges(kSourceId, "{ [0,2736) }"); | 959 CheckExpectedRanges(kSourceId, "{ [0,2736) }"); |
801 | 960 |
802 MarkEndOfStream(PIPELINE_OK); | 961 MarkEndOfStream(PIPELINE_OK); |
803 return true; | 962 return true; |
804 } | 963 } |
805 | 964 |
806 void ShutdownDemuxer() { | 965 void ShutdownDemuxer() { |
807 if (demuxer_) { | 966 if (demuxer_) { |
808 demuxer_->Shutdown(); | 967 demuxer_->Shutdown(); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 if (demuxer_->IsParsingMediaSegment(id)) | 1350 if (demuxer_->IsParsingMediaSegment(id)) |
1192 return false; | 1351 return false; |
1193 | 1352 |
1194 timestamp_offset_map_[id] = timestamp_offset; | 1353 timestamp_offset_map_[id] = timestamp_offset; |
1195 return true; | 1354 return true; |
1196 } | 1355 } |
1197 | 1356 |
1198 base::MessageLoop message_loop_; | 1357 base::MessageLoop message_loop_; |
1199 MockDemuxerHost host_; | 1358 MockDemuxerHost host_; |
1200 | 1359 |
| 1360 scoped_refptr<StrictMock<MockMediaLog>> media_log_; |
| 1361 |
1201 scoped_ptr<ChunkDemuxer> demuxer_; | 1362 scoped_ptr<ChunkDemuxer> demuxer_; |
1202 MediaSourceState::InitSegmentReceivedCB init_segment_received_cb_; | 1363 MediaSourceState::InitSegmentReceivedCB init_segment_received_cb_; |
1203 | 1364 |
1204 base::TimeDelta append_window_start_for_next_append_; | 1365 base::TimeDelta append_window_start_for_next_append_; |
1205 base::TimeDelta append_window_end_for_next_append_; | 1366 base::TimeDelta append_window_end_for_next_append_; |
1206 | 1367 |
1207 // Map of source id to timestamp offset to use for the next AppendData() | 1368 // Map of source id to timestamp offset to use for the next AppendData() |
1208 // operation for that source id. | 1369 // operation for that source id. |
1209 std::map<std::string, base::TimeDelta> timestamp_offset_map_; | 1370 std::map<std::string, base::TimeDelta> timestamp_offset_map_; |
1210 | 1371 |
1211 private: | 1372 private: |
1212 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); | 1373 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); |
1213 }; | 1374 }; |
1214 | 1375 |
1215 TEST_F(ChunkDemuxerTest, Init) { | 1376 TEST_F(ChunkDemuxerTest, Init) { |
| 1377 InSequence s; |
| 1378 |
1216 // Test no streams, audio-only, video-only, and audio & video scenarios. | 1379 // Test no streams, audio-only, video-only, and audio & video scenarios. |
1217 // Audio and video streams can be encrypted or not encrypted. | 1380 // Audio and video streams can be encrypted or not encrypted. |
1218 for (int i = 0; i < 16; i++) { | 1381 for (int i = 0; i < 16; i++) { |
1219 bool has_audio = (i & 0x1) != 0; | 1382 bool has_audio = (i & 0x1) != 0; |
1220 bool has_video = (i & 0x2) != 0; | 1383 bool has_video = (i & 0x2) != 0; |
1221 bool is_audio_encrypted = (i & 0x4) != 0; | 1384 bool is_audio_encrypted = (i & 0x4) != 0; |
1222 bool is_video_encrypted = (i & 0x8) != 0; | 1385 bool is_video_encrypted = (i & 0x8) != 0; |
1223 | 1386 |
1224 // No test on invalid combination. | 1387 // No test on invalid combination. |
1225 if ((!has_audio && is_audio_encrypted) || | 1388 if ((!has_audio && is_audio_encrypted) || |
1226 (!has_video && is_video_encrypted)) { | 1389 (!has_video && is_video_encrypted)) { |
1227 continue; | 1390 continue; |
1228 } | 1391 } |
1229 | 1392 |
1230 CreateNewDemuxer(); | 1393 CreateNewDemuxer(); |
1231 | 1394 |
1232 if (is_audio_encrypted || is_video_encrypted) { | |
1233 int need_key_count = (is_audio_encrypted ? 1 : 0) + | |
1234 (is_video_encrypted ? 1 : 0); | |
1235 EXPECT_CALL(*this, OnEncryptedMediaInitData( | |
1236 EmeInitDataType::WEBM, | |
1237 std::vector<uint8_t>( | |
1238 kEncryptedMediaInitData, | |
1239 kEncryptedMediaInitData + | |
1240 arraysize(kEncryptedMediaInitData)))) | |
1241 .Times(Exactly(need_key_count)); | |
1242 } | |
1243 | |
1244 int stream_flags = 0; | 1395 int stream_flags = 0; |
1245 if (has_audio) | 1396 if (has_audio) |
1246 stream_flags |= HAS_AUDIO; | 1397 stream_flags |= HAS_AUDIO; |
1247 | 1398 |
1248 if (has_video) | 1399 if (has_video) |
1249 stream_flags |= HAS_VIDEO; | 1400 stream_flags |= HAS_VIDEO; |
1250 | 1401 |
1251 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( | 1402 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( |
1252 stream_flags, is_audio_encrypted, is_video_encrypted)); | 1403 stream_flags, is_audio_encrypted, is_video_encrypted)); |
1253 | 1404 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 .WillOnce(DoAll(SaveArg<0>(&text_stream), | 1517 .WillOnce(DoAll(SaveArg<0>(&text_stream), |
1367 SaveArg<1>(&text_config))); | 1518 SaveArg<1>(&text_config))); |
1368 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( | 1519 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( |
1369 HAS_TEXT | HAS_AUDIO | HAS_VIDEO, false, false)); | 1520 HAS_TEXT | HAS_AUDIO | HAS_VIDEO, false, false)); |
1370 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 1521 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
1371 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 1522 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
1372 ASSERT_TRUE(audio_stream); | 1523 ASSERT_TRUE(audio_stream); |
1373 ASSERT_TRUE(video_stream); | 1524 ASSERT_TRUE(video_stream); |
1374 ASSERT_TRUE(text_stream); | 1525 ASSERT_TRUE(text_stream); |
1375 | 1526 |
1376 AppendMuxedCluster( | 1527 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), |
1377 MuxedStreamInfo(kAudioTrackNum, "0K 23K"), | 1528 MuxedStreamInfo(kVideoTrackNum, "0K 30", 30), |
1378 MuxedStreamInfo(kVideoTrackNum, "0K 30"), | 1529 MuxedStreamInfo(kTextTrackNum, "10K")); |
1379 MuxedStreamInfo(kTextTrackNum, "10K")); | 1530 CheckExpectedRanges("{ [0,46) }"); |
1380 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | |
1381 | 1531 |
1382 scoped_ptr<uint8_t[]> info_tracks; | 1532 scoped_ptr<uint8_t[]> info_tracks; |
1383 int info_tracks_size = 0; | 1533 int info_tracks_size = 0; |
1384 CreateInitSegmentWithAlternateTextTrackNum(HAS_TEXT | HAS_AUDIO | HAS_VIDEO, | 1534 CreateInitSegmentWithAlternateTextTrackNum(HAS_TEXT | HAS_AUDIO | HAS_VIDEO, |
1385 false, false, | 1535 false, false, |
1386 &info_tracks, &info_tracks_size); | 1536 &info_tracks, &info_tracks_size); |
1387 EXPECT_CALL(*this, InitSegmentReceived()); | 1537 EXPECT_CALL(*this, InitSegmentReceived()); |
1388 demuxer_->AppendData(kSourceId, info_tracks.get(), info_tracks_size, | 1538 demuxer_->AppendData(kSourceId, info_tracks.get(), info_tracks_size, |
1389 append_window_start_for_next_append_, | 1539 append_window_start_for_next_append_, |
1390 append_window_end_for_next_append_, | 1540 append_window_end_for_next_append_, |
1391 ×tamp_offset_map_[kSourceId], | 1541 ×tamp_offset_map_[kSourceId], |
1392 init_segment_received_cb_); | 1542 init_segment_received_cb_); |
1393 | 1543 |
1394 AppendMuxedCluster( | 1544 AppendMuxedCluster( |
1395 MuxedStreamInfo(kAudioTrackNum, "46K 69K"), | 1545 MuxedStreamInfo(kAudioTrackNum, "46K 69K", 23), |
1396 MuxedStreamInfo(kVideoTrackNum, "60K"), | 1546 MuxedStreamInfo(kVideoTrackNum, "60K", |
| 1547 WebMClusterParser::kDefaultVideoBufferDurationInMs), |
1397 MuxedStreamInfo(kAlternateTextTrackNum, "45K")); | 1548 MuxedStreamInfo(kAlternateTextTrackNum, "45K")); |
1398 | 1549 |
1399 CheckExpectedRanges(kSourceId, "{ [0,92) }"); | 1550 CheckExpectedRanges(kSourceId, "{ [0,92) }"); |
1400 CheckExpectedBuffers(audio_stream, "0K 23K 46K 69K"); | 1551 CheckExpectedBuffers(audio_stream, "0K 23K 46K 69K"); |
1401 CheckExpectedBuffers(video_stream, "0K 30 60K"); | 1552 CheckExpectedBuffers(video_stream, "0K 30 60K"); |
1402 CheckExpectedBuffers(text_stream, "10K 45K"); | 1553 CheckExpectedBuffers(text_stream, "10K 45K"); |
1403 | 1554 |
1404 ShutdownDemuxer(); | 1555 ShutdownDemuxer(); |
1405 } | 1556 } |
1406 | 1557 |
1407 TEST_F(ChunkDemuxerTest, InitSegmentSetsNeedRandomAccessPointFlag) { | 1558 TEST_F(ChunkDemuxerTest, InitSegmentSetsNeedRandomAccessPointFlag) { |
1408 // Tests that non-key-frames following an init segment are allowed | 1559 // Tests that non-key-frames following an init segment are allowed |
1409 // and dropped, as expected if the initialization segment received | 1560 // and dropped, as expected if the initialization segment received |
1410 // algorithm correctly sets the needs random access point flag to true for all | 1561 // algorithm correctly sets the needs random access point flag to true for all |
1411 // track buffers. Note that the first initialization segment is insufficient | 1562 // track buffers. Note that the first initialization segment is insufficient |
1412 // to fully test this since needs random access point flag initializes to | 1563 // to fully test this since needs random access point flag initializes to |
1413 // true. | 1564 // true. |
1414 CreateNewDemuxer(); | 1565 CreateNewDemuxer(); |
1415 DemuxerStream* text_stream = NULL; | 1566 DemuxerStream* text_stream = NULL; |
1416 EXPECT_CALL(host_, AddTextStream(_, _)) | 1567 EXPECT_CALL(host_, AddTextStream(_, _)) |
1417 .WillOnce(SaveArg<0>(&text_stream)); | 1568 .WillOnce(SaveArg<0>(&text_stream)); |
1418 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( | 1569 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( |
1419 HAS_TEXT | HAS_AUDIO | HAS_VIDEO, false, false)); | 1570 HAS_TEXT | HAS_AUDIO | HAS_VIDEO, false, false)); |
1420 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 1571 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
1421 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 1572 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
1422 ASSERT_TRUE(audio_stream && video_stream && text_stream); | 1573 ASSERT_TRUE(audio_stream && video_stream && text_stream); |
1423 | 1574 |
1424 AppendMuxedCluster( | 1575 AppendMuxedCluster( |
1425 MuxedStreamInfo(kAudioTrackNum, "23K"), | 1576 MuxedStreamInfo(kAudioTrackNum, "23K", |
1426 MuxedStreamInfo(kVideoTrackNum, "0 30K"), | 1577 WebMClusterParser::kDefaultAudioBufferDurationInMs), |
| 1578 MuxedStreamInfo(kVideoTrackNum, "0 30K", 30), |
1427 MuxedStreamInfo(kTextTrackNum, "25K 40K")); | 1579 MuxedStreamInfo(kTextTrackNum, "25K 40K")); |
1428 CheckExpectedRanges(kSourceId, "{ [23,46) }"); | 1580 CheckExpectedRanges(kSourceId, "{ [23,46) }"); |
1429 | 1581 |
1430 EXPECT_CALL(*this, InitSegmentReceived()); | 1582 EXPECT_CALL(*this, InitSegmentReceived()); |
1431 AppendInitSegment(HAS_TEXT | HAS_AUDIO | HAS_VIDEO); | 1583 AppendInitSegment(HAS_TEXT | HAS_AUDIO | HAS_VIDEO); |
1432 AppendMuxedCluster( | 1584 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "46K 69K", 23), |
1433 MuxedStreamInfo(kAudioTrackNum, "46K 69K"), | 1585 MuxedStreamInfo(kVideoTrackNum, "60 90K", 30), |
1434 MuxedStreamInfo(kVideoTrackNum, "60 90K"), | 1586 MuxedStreamInfo(kTextTrackNum, "80K 90K")); |
1435 MuxedStreamInfo(kTextTrackNum, "80K 90K")); | 1587 CheckExpectedRanges("{ [23,92) }"); |
1436 CheckExpectedRanges(kSourceId, "{ [23,92) }"); | |
1437 | 1588 |
1438 CheckExpectedBuffers(audio_stream, "23K 46K 69K"); | 1589 CheckExpectedBuffers(audio_stream, "23K 46K 69K"); |
1439 CheckExpectedBuffers(video_stream, "30K 90K"); | 1590 CheckExpectedBuffers(video_stream, "30K 90K"); |
1440 CheckExpectedBuffers(text_stream, "25K 40K 80K 90K"); | 1591 CheckExpectedBuffers(text_stream, "25K 40K 80K 90K"); |
1441 } | 1592 } |
1442 | 1593 |
1443 // Make sure that the demuxer reports an error if Shutdown() | 1594 // Make sure that the demuxer reports an error if Shutdown() |
1444 // is called before all the initialization segments are appended. | 1595 // is called before all the initialization segments are appended. |
1445 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppended) { | 1596 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppended) { |
1446 EXPECT_CALL(*this, DemuxerOpened()); | 1597 EXPECT_CALL(*this, DemuxerOpened()); |
1447 demuxer_->Initialize( | 1598 demuxer_->Initialize( |
1448 &host_, CreateInitDoneCB( | 1599 &host_, CreateInitDoneCB( |
1449 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1600 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); |
1450 | 1601 |
1451 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); | 1602 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); |
1452 EXPECT_EQ(AddId("video", HAS_VIDEO), ChunkDemuxer::kOk); | 1603 EXPECT_EQ(AddId("video", HAS_VIDEO), ChunkDemuxer::kOk); |
1453 | 1604 |
| 1605 ExpectInitMediaLogs(HAS_AUDIO); |
1454 EXPECT_CALL(*this, InitSegmentReceived()); | 1606 EXPECT_CALL(*this, InitSegmentReceived()); |
1455 AppendInitSegmentWithSourceId("audio", HAS_AUDIO); | 1607 AppendInitSegmentWithSourceId("audio", HAS_AUDIO); |
1456 | 1608 |
1457 ShutdownDemuxer(); | 1609 ShutdownDemuxer(); |
1458 } | 1610 } |
1459 | 1611 |
1460 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppendedText) { | 1612 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppendedText) { |
1461 EXPECT_CALL(*this, DemuxerOpened()); | 1613 EXPECT_CALL(*this, DemuxerOpened()); |
1462 demuxer_->Initialize( | 1614 demuxer_->Initialize( |
1463 &host_, CreateInitDoneCB( | 1615 &host_, CreateInitDoneCB( |
1464 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1616 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); |
1465 | 1617 |
1466 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); | 1618 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); |
1467 EXPECT_EQ(AddId("video_and_text", HAS_VIDEO), ChunkDemuxer::kOk); | 1619 EXPECT_EQ(AddId("video_and_text", HAS_VIDEO), ChunkDemuxer::kOk); |
1468 | 1620 |
1469 EXPECT_CALL(host_, AddTextStream(_, _)) | 1621 EXPECT_CALL(host_, AddTextStream(_, _)) |
1470 .Times(Exactly(1)); | 1622 .Times(Exactly(1)); |
1471 | 1623 |
| 1624 ExpectInitMediaLogs(HAS_VIDEO); |
1472 EXPECT_CALL(*this, InitSegmentReceived()); | 1625 EXPECT_CALL(*this, InitSegmentReceived()); |
1473 AppendInitSegmentWithSourceId("video_and_text", HAS_VIDEO | HAS_TEXT); | 1626 AppendInitSegmentWithSourceId("video_and_text", HAS_VIDEO | HAS_TEXT); |
1474 | 1627 |
1475 ShutdownDemuxer(); | 1628 ShutdownDemuxer(); |
1476 } | 1629 } |
1477 | 1630 |
1478 // Verifies that all streams waiting for data receive an end of stream | 1631 // Verifies that all streams waiting for data receive an end of stream |
1479 // buffer when Shutdown() is called. | 1632 // buffer when Shutdown() is called. |
1480 TEST_F(ChunkDemuxerTest, Shutdown_EndOfStreamWhileWaitingForData) { | 1633 TEST_F(ChunkDemuxerTest, Shutdown_EndOfStreamWhileWaitingForData) { |
1481 DemuxerStream* text_stream = NULL; | 1634 DemuxerStream* text_stream = NULL; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 message_loop_.RunUntilIdle(); | 1679 message_loop_.RunUntilIdle(); |
1527 | 1680 |
1528 Checkpoint(2); | 1681 Checkpoint(2); |
1529 } | 1682 } |
1530 | 1683 |
1531 // Test that parsing errors are handled for clusters appended after init. | 1684 // Test that parsing errors are handled for clusters appended after init. |
1532 TEST_F(ChunkDemuxerTest, ErrorWhileParsingClusterAfterInit) { | 1685 TEST_F(ChunkDemuxerTest, ErrorWhileParsingClusterAfterInit) { |
1533 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1686 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
1534 AppendCluster(kDefaultFirstCluster()); | 1687 AppendCluster(kDefaultFirstCluster()); |
1535 | 1688 |
| 1689 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
1536 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1690 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
1537 AppendGarbage(); | 1691 AppendGarbage(); |
1538 } | 1692 } |
1539 | 1693 |
1540 // Test the case where a Seek() is requested while the parser | 1694 // Test the case where a Seek() is requested while the parser |
1541 // is in the middle of cluster. This is to verify that the parser | 1695 // is in the middle of cluster. This is to verify that the parser |
1542 // does not reset itself on a seek. | 1696 // does not reset itself on a seek. |
1543 TEST_F(ChunkDemuxerTest, SeekWhileParsingCluster) { | 1697 TEST_F(ChunkDemuxerTest, SeekWhileParsingCluster) { |
1544 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1698 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
1545 | 1699 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 base::TimeDelta::FromMilliseconds(0), | 1751 base::TimeDelta::FromMilliseconds(0), |
1598 &video_read_done)); | 1752 &video_read_done)); |
1599 | 1753 |
1600 EXPECT_TRUE(audio_read_done); | 1754 EXPECT_TRUE(audio_read_done); |
1601 EXPECT_TRUE(video_read_done); | 1755 EXPECT_TRUE(video_read_done); |
1602 } | 1756 } |
1603 | 1757 |
1604 TEST_F(ChunkDemuxerTest, OutOfOrderClusters) { | 1758 TEST_F(ChunkDemuxerTest, OutOfOrderClusters) { |
1605 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1759 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
1606 AppendCluster(kDefaultFirstCluster()); | 1760 AppendCluster(kDefaultFirstCluster()); |
| 1761 EXPECT_MEDIA_LOG(GeneratedSplice(13000, 10000)); |
1607 AppendCluster(GenerateCluster(10, 4)); | 1762 AppendCluster(GenerateCluster(10, 4)); |
1608 | 1763 |
1609 // Make sure that AppendCluster() does not fail with a cluster that has | 1764 // Make sure that AppendCluster() does not fail with a cluster that has |
1610 // overlaps with the previously appended cluster. | 1765 // overlaps with the previously appended cluster. |
| 1766 EXPECT_MEDIA_LOG(SkippingSpliceAlreadySpliced(0)); |
1611 AppendCluster(GenerateCluster(5, 4)); | 1767 AppendCluster(GenerateCluster(5, 4)); |
1612 | 1768 |
1613 // Verify that AppendData() can still accept more data. | 1769 // Verify that AppendData() can still accept more data. |
1614 scoped_ptr<Cluster> cluster_c(GenerateCluster(45, 2)); | 1770 scoped_ptr<Cluster> cluster_c(GenerateCluster(45, 2)); |
| 1771 EXPECT_MEDIA_LOG(GeneratedSplice(6000, 45000)); |
1615 demuxer_->AppendData(kSourceId, cluster_c->data(), cluster_c->size(), | 1772 demuxer_->AppendData(kSourceId, cluster_c->data(), cluster_c->size(), |
1616 append_window_start_for_next_append_, | 1773 append_window_start_for_next_append_, |
1617 append_window_end_for_next_append_, | 1774 append_window_end_for_next_append_, |
1618 ×tamp_offset_map_[kSourceId], | 1775 ×tamp_offset_map_[kSourceId], |
1619 init_segment_received_cb_); | 1776 init_segment_received_cb_); |
1620 } | 1777 } |
1621 | 1778 |
1622 TEST_F(ChunkDemuxerTest, NonMonotonicButAboveClusterTimecode) { | 1779 TEST_F(ChunkDemuxerTest, NonMonotonicButAboveClusterTimecode) { |
1623 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1780 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
1624 AppendCluster(kDefaultFirstCluster()); | 1781 AppendCluster(kDefaultFirstCluster()); |
1625 | 1782 |
1626 ClusterBuilder cb; | 1783 ClusterBuilder cb; |
1627 | 1784 |
1628 // Test the case where block timecodes are not monotonically | 1785 // Test the case where block timecodes are not monotonically |
1629 // increasing but stay above the cluster timecode. | 1786 // increasing but stay above the cluster timecode. |
1630 cb.SetClusterTimecode(5); | 1787 cb.SetClusterTimecode(5); |
1631 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 1788 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
1632 AddSimpleBlock(&cb, kVideoTrackNum, 10); | 1789 AddSimpleBlock(&cb, kVideoTrackNum, 10); |
1633 AddSimpleBlock(&cb, kAudioTrackNum, 7); | 1790 AddSimpleBlock(&cb, kAudioTrackNum, 7); |
1634 AddSimpleBlock(&cb, kVideoTrackNum, 15); | 1791 AddSimpleBlock(&cb, kVideoTrackNum, 15); |
1635 | 1792 |
| 1793 EXPECT_MEDIA_LOG(WebMOutOfOrderTimecode()); |
| 1794 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
1636 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1795 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
1637 AppendCluster(cb.Finish()); | 1796 AppendCluster(cb.Finish()); |
1638 | 1797 |
1639 // Verify that AppendData() ignores data after the error. | 1798 // Verify that AppendData() ignores data after the error. |
1640 scoped_ptr<Cluster> cluster_b(GenerateCluster(20, 2)); | 1799 scoped_ptr<Cluster> cluster_b(GenerateCluster(20, 2)); |
1641 demuxer_->AppendData(kSourceId, cluster_b->data(), cluster_b->size(), | 1800 demuxer_->AppendData(kSourceId, cluster_b->data(), cluster_b->size(), |
1642 append_window_start_for_next_append_, | 1801 append_window_start_for_next_append_, |
1643 append_window_end_for_next_append_, | 1802 append_window_end_for_next_append_, |
1644 ×tamp_offset_map_[kSourceId], | 1803 ×tamp_offset_map_[kSourceId], |
1645 init_segment_received_cb_); | 1804 init_segment_received_cb_); |
1646 } | 1805 } |
1647 | 1806 |
1648 TEST_F(ChunkDemuxerTest, BackwardsAndBeforeClusterTimecode) { | 1807 TEST_F(ChunkDemuxerTest, BackwardsAndBeforeClusterTimecode) { |
1649 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1808 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
1650 AppendCluster(kDefaultFirstCluster()); | 1809 AppendCluster(kDefaultFirstCluster()); |
1651 | 1810 |
1652 ClusterBuilder cb; | 1811 ClusterBuilder cb; |
1653 | 1812 |
1654 // Test timecodes going backwards and including values less than the cluster | 1813 // Test timecodes going backwards and including values less than the cluster |
1655 // timecode. | 1814 // timecode. |
1656 cb.SetClusterTimecode(5); | 1815 cb.SetClusterTimecode(5); |
1657 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 1816 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
1658 AddSimpleBlock(&cb, kVideoTrackNum, 5); | 1817 AddSimpleBlock(&cb, kVideoTrackNum, 5); |
1659 AddSimpleBlock(&cb, kAudioTrackNum, 3); | 1818 AddSimpleBlock(&cb, kAudioTrackNum, 3); |
1660 AddSimpleBlock(&cb, kVideoTrackNum, 3); | 1819 AddSimpleBlock(&cb, kVideoTrackNum, 3); |
1661 | 1820 |
| 1821 EXPECT_MEDIA_LOG(WebMNegativeTimecodeOffset("-2")); |
| 1822 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
1662 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1823 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
1663 AppendCluster(cb.Finish()); | 1824 AppendCluster(cb.Finish()); |
1664 | 1825 |
1665 // Verify that AppendData() ignores data after the error. | 1826 // Verify that AppendData() ignores data after the error. |
1666 scoped_ptr<Cluster> cluster_b(GenerateCluster(6, 2)); | 1827 scoped_ptr<Cluster> cluster_b(GenerateCluster(6, 2)); |
1667 demuxer_->AppendData(kSourceId, cluster_b->data(), cluster_b->size(), | 1828 demuxer_->AppendData(kSourceId, cluster_b->data(), cluster_b->size(), |
1668 append_window_start_for_next_append_, | 1829 append_window_start_for_next_append_, |
1669 append_window_end_for_next_append_, | 1830 append_window_end_for_next_append_, |
1670 ×tamp_offset_map_[kSourceId], | 1831 ×tamp_offset_map_[kSourceId], |
1671 init_segment_received_cb_); | 1832 init_segment_received_cb_); |
1672 } | 1833 } |
1673 | 1834 |
1674 | 1835 |
1675 TEST_F(ChunkDemuxerTest, PerStreamMonotonicallyIncreasingTimestamps) { | 1836 TEST_F(ChunkDemuxerTest, PerStreamMonotonicallyIncreasingTimestamps) { |
1676 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1837 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
1677 AppendCluster(kDefaultFirstCluster()); | 1838 AppendCluster(kDefaultFirstCluster()); |
1678 | 1839 |
1679 ClusterBuilder cb; | 1840 ClusterBuilder cb; |
1680 | 1841 |
1681 // Test monotonic increasing timestamps on a per stream | 1842 // Test monotonic increasing timestamps on a per stream |
1682 // basis. | 1843 // basis. |
1683 cb.SetClusterTimecode(5); | 1844 cb.SetClusterTimecode(4); |
1684 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 1845 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
1685 AddSimpleBlock(&cb, kVideoTrackNum, 5); | 1846 AddSimpleBlock(&cb, kVideoTrackNum, 5); |
1686 AddSimpleBlock(&cb, kAudioTrackNum, 4); | 1847 AddSimpleBlock(&cb, kAudioTrackNum, 4); |
1687 AddSimpleBlock(&cb, kVideoTrackNum, 7); | 1848 AddSimpleBlock(&cb, kVideoTrackNum, 7); |
1688 | 1849 |
| 1850 EXPECT_MEDIA_LOG(WebMOutOfOrderTimecode()); |
| 1851 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
1689 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 1852 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
1690 AppendCluster(cb.Finish()); | 1853 AppendCluster(cb.Finish()); |
1691 } | 1854 } |
1692 | 1855 |
1693 // Test the case where a cluster is passed to AppendCluster() before | 1856 // Test the case where a cluster is passed to AppendCluster() before |
1694 // INFO & TRACKS data. | 1857 // INFO & TRACKS data. |
1695 TEST_F(ChunkDemuxerTest, ClusterBeforeInitSegment) { | 1858 TEST_F(ChunkDemuxerTest, ClusterBeforeInitSegment) { |
1696 EXPECT_CALL(*this, DemuxerOpened()); | 1859 EXPECT_CALL(*this, DemuxerOpened()); |
1697 demuxer_->Initialize( | 1860 demuxer_->Initialize( |
1698 &host_, NewExpectedStatusCB(PIPELINE_ERROR_DECODE), true); | 1861 &host_, NewExpectedStatusCB(PIPELINE_ERROR_DECODE), true); |
1699 | 1862 |
1700 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 1863 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
1701 | 1864 |
| 1865 EXPECT_MEDIA_LOG(WebMClusterBeforeFirstInfo()); |
| 1866 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
1702 AppendCluster(GenerateCluster(0, 1)); | 1867 AppendCluster(GenerateCluster(0, 1)); |
1703 } | 1868 } |
1704 | 1869 |
1705 // Test cases where we get an MarkEndOfStream() call during initialization. | 1870 // Test cases where we get an MarkEndOfStream() call during initialization. |
1706 TEST_F(ChunkDemuxerTest, EOSDuringInit) { | 1871 TEST_F(ChunkDemuxerTest, EOSDuringInit) { |
1707 EXPECT_CALL(*this, DemuxerOpened()); | 1872 EXPECT_CALL(*this, DemuxerOpened()); |
1708 demuxer_->Initialize( | 1873 demuxer_->Initialize( |
1709 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1874 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN), true); |
1710 MarkEndOfStream(PIPELINE_OK); | 1875 MarkEndOfStream(PIPELINE_OK); |
1711 } | 1876 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 } | 2074 } |
1910 | 2075 |
1911 // Verify buffered range change behavior for audio/video/text tracks. | 2076 // Verify buffered range change behavior for audio/video/text tracks. |
1912 TEST_F(ChunkDemuxerTest, EndOfStreamRangeChanges) { | 2077 TEST_F(ChunkDemuxerTest, EndOfStreamRangeChanges) { |
1913 DemuxerStream* text_stream = NULL; | 2078 DemuxerStream* text_stream = NULL; |
1914 | 2079 |
1915 EXPECT_CALL(host_, AddTextStream(_, _)) | 2080 EXPECT_CALL(host_, AddTextStream(_, _)) |
1916 .WillOnce(SaveArg<0>(&text_stream)); | 2081 .WillOnce(SaveArg<0>(&text_stream)); |
1917 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 2082 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
1918 | 2083 |
1919 AppendMuxedCluster( | 2084 AppendMuxedCluster(MuxedStreamInfo(kVideoTrackNum, "0K 33", 33), |
1920 MuxedStreamInfo(kVideoTrackNum, "0K 33"), | 2085 MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23)); |
1921 MuxedStreamInfo(kAudioTrackNum, "0K 23K")); | |
1922 | 2086 |
1923 // Check expected ranges and verify that an empty text track does not | 2087 // Check expected ranges and verify that an empty text track does not |
1924 // affect the expected ranges. | 2088 // affect the expected ranges. |
1925 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 2089 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
1926 | 2090 |
1927 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); | 2091 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); |
1928 MarkEndOfStream(PIPELINE_OK); | 2092 MarkEndOfStream(PIPELINE_OK); |
1929 | 2093 |
1930 // Check expected ranges and verify that an empty text track does not | 2094 // Check expected ranges and verify that an empty text track does not |
1931 // affect the expected ranges. | 2095 // affect the expected ranges. |
1932 CheckExpectedRanges(kSourceId, "{ [0,66) }"); | 2096 CheckExpectedRanges(kSourceId, "{ [0,66) }"); |
1933 | 2097 |
1934 // Unmark end of stream state and verify that the ranges return to | 2098 // Unmark end of stream state and verify that the ranges return to |
1935 // their pre-"end of stream" values. | 2099 // their pre-"end of stream" values. |
1936 demuxer_->UnmarkEndOfStream(); | 2100 demuxer_->UnmarkEndOfStream(); |
1937 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 2101 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
1938 | 2102 |
1939 // Add text track data and verify that the buffered ranges don't change | 2103 // Add text track data and verify that the buffered ranges don't change |
1940 // since the intersection of all the tracks doesn't change. | 2104 // since the intersection of all the tracks doesn't change. |
| 2105 EXPECT_MEDIA_LOG(SkippingSpliceAtOrBefore(0, 0)); |
1941 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200))); | 2106 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200))); |
1942 AppendMuxedCluster( | 2107 AppendMuxedCluster(MuxedStreamInfo(kVideoTrackNum, "0K 33", 33), |
1943 MuxedStreamInfo(kVideoTrackNum, "0K 33"), | 2108 MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), |
1944 MuxedStreamInfo(kAudioTrackNum, "0K 23K"), | 2109 MuxedStreamInfo(kTextTrackNum, "0K 100K")); |
1945 MuxedStreamInfo(kTextTrackNum, "0K 100K")); | 2110 CheckExpectedRanges("{ [0,46) }"); |
1946 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | |
1947 | 2111 |
1948 // Mark end of stream and verify that text track data is reflected in | 2112 // Mark end of stream and verify that text track data is reflected in |
1949 // the new range. | 2113 // the new range. |
1950 MarkEndOfStream(PIPELINE_OK); | 2114 MarkEndOfStream(PIPELINE_OK); |
1951 CheckExpectedRanges(kSourceId, "{ [0,200) }"); | 2115 CheckExpectedRanges(kSourceId, "{ [0,200) }"); |
1952 } | 2116 } |
1953 | 2117 |
1954 // Make sure AppendData() will accept elements that span multiple calls. | 2118 // Make sure AppendData() will accept elements that span multiple calls. |
1955 TEST_F(ChunkDemuxerTest, AppendingInPieces) { | 2119 TEST_F(ChunkDemuxerTest, AppendingInPieces) { |
1956 EXPECT_CALL(*this, DemuxerOpened()); | 2120 EXPECT_CALL(*this, DemuxerOpened()); |
(...skipping 15 matching lines...) Expand all Loading... |
1972 uint8_t* dst = buffer.get(); | 2136 uint8_t* dst = buffer.get(); |
1973 memcpy(dst, info_tracks.get(), info_tracks_size); | 2137 memcpy(dst, info_tracks.get(), info_tracks_size); |
1974 dst += info_tracks_size; | 2138 dst += info_tracks_size; |
1975 | 2139 |
1976 memcpy(dst, cluster_a->data(), cluster_a->size()); | 2140 memcpy(dst, cluster_a->data(), cluster_a->size()); |
1977 dst += cluster_a->size(); | 2141 dst += cluster_a->size(); |
1978 | 2142 |
1979 memcpy(dst, cluster_b->data(), cluster_b->size()); | 2143 memcpy(dst, cluster_b->data(), cluster_b->size()); |
1980 dst += cluster_b->size(); | 2144 dst += cluster_b->size(); |
1981 | 2145 |
| 2146 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); |
1982 EXPECT_CALL(*this, InitSegmentReceived()); | 2147 EXPECT_CALL(*this, InitSegmentReceived()); |
1983 AppendDataInPieces(buffer.get(), buffer_size); | 2148 AppendDataInPieces(buffer.get(), buffer_size); |
1984 | 2149 |
1985 GenerateExpectedReads(0, 9); | 2150 GenerateExpectedReads(0, 9); |
1986 } | 2151 } |
1987 | 2152 |
1988 TEST_F(ChunkDemuxerTest, WebMFile_AudioAndVideo) { | 2153 TEST_F(ChunkDemuxerTest, WebMFile_AudioAndVideo) { |
1989 struct BufferTimestamps buffer_timestamps[] = { | 2154 struct BufferTimestamps buffer_timestamps[] = { |
1990 {0, 0}, | 2155 {0, 0}, |
1991 {33, 3}, | 2156 {33, 3}, |
1992 {67, 6}, | 2157 {67, 6}, |
1993 {100, 9}, | 2158 {100, 9}, |
1994 {133, 12}, | 2159 {133, 12}, |
1995 {kSkip, kSkip}, | 2160 {kSkip, kSkip}, |
1996 }; | 2161 }; |
1997 | 2162 |
| 2163 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); |
| 2164 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)).Times(7); |
| 2165 |
1998 // Expect duration adjustment since actual duration differs slightly from | 2166 // Expect duration adjustment since actual duration differs slightly from |
1999 // duration in the init segment. | 2167 // duration in the init segment. |
2000 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 2168 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
2001 | 2169 |
2002 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, | 2170 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, |
2003 base::TimeDelta::FromMilliseconds(2744))); | 2171 base::TimeDelta::FromMilliseconds(2744))); |
2004 EXPECT_EQ(212949, demuxer_->GetMemoryUsage()); | 2172 EXPECT_EQ(212949, demuxer_->GetMemoryUsage()); |
2005 } | 2173 } |
2006 | 2174 |
2007 TEST_F(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { | 2175 TEST_F(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { |
2008 struct BufferTimestamps buffer_timestamps[] = { | 2176 struct BufferTimestamps buffer_timestamps[] = { |
2009 {0, 0}, | 2177 {0, 0}, |
2010 {33, 3}, | 2178 {33, 3}, |
2011 {67, 6}, | 2179 {67, 6}, |
2012 {100, 9}, | 2180 {100, 9}, |
2013 {133, 12}, | 2181 {133, 12}, |
2014 {kSkip, kSkip}, | 2182 {kSkip, kSkip}, |
2015 }; | 2183 }; |
2016 | 2184 |
| 2185 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); |
| 2186 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)).Times(7); |
2017 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, | 2187 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, |
2018 kInfiniteDuration())); | 2188 kInfiniteDuration())); |
2019 | 2189 |
2020 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); | 2190 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); |
2021 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, audio->liveness()); | 2191 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, audio->liveness()); |
2022 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); | 2192 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); |
2023 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, video->liveness()); | 2193 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, video->liveness()); |
2024 EXPECT_EQ(212949, demuxer_->GetMemoryUsage()); | 2194 EXPECT_EQ(212949, demuxer_->GetMemoryUsage()); |
2025 } | 2195 } |
2026 | 2196 |
2027 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { | 2197 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { |
2028 struct BufferTimestamps buffer_timestamps[] = { | 2198 struct BufferTimestamps buffer_timestamps[] = { |
2029 {kSkip, 0}, | 2199 {kSkip, 0}, |
2030 {kSkip, 3}, | 2200 {kSkip, 3}, |
2031 {kSkip, 6}, | 2201 {kSkip, 6}, |
2032 {kSkip, 9}, | 2202 {kSkip, 9}, |
2033 {kSkip, 12}, | 2203 {kSkip, 12}, |
2034 {kSkip, kSkip}, | 2204 {kSkip, kSkip}, |
2035 }; | 2205 }; |
2036 | 2206 |
| 2207 ExpectInitMediaLogs(HAS_AUDIO); |
| 2208 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); |
| 2209 |
2037 // Expect duration adjustment since actual duration differs slightly from | 2210 // Expect duration adjustment since actual duration differs slightly from |
2038 // duration in the init segment. | 2211 // duration in the init segment. |
2039 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 2212 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
2040 | 2213 |
2041 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, | 2214 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, |
2042 base::TimeDelta::FromMilliseconds(2744), | 2215 base::TimeDelta::FromMilliseconds(2744), |
2043 HAS_AUDIO)); | 2216 HAS_AUDIO)); |
2044 EXPECT_EQ(18624, demuxer_->GetMemoryUsage()); | 2217 EXPECT_EQ(18624, demuxer_->GetMemoryUsage()); |
2045 } | 2218 } |
2046 | 2219 |
2047 TEST_F(ChunkDemuxerTest, WebMFile_VideoOnly) { | 2220 TEST_F(ChunkDemuxerTest, WebMFile_VideoOnly) { |
2048 struct BufferTimestamps buffer_timestamps[] = { | 2221 struct BufferTimestamps buffer_timestamps[] = { |
2049 {0, kSkip}, | 2222 {0, kSkip}, |
2050 {33, kSkip}, | 2223 {33, kSkip}, |
2051 {67, kSkip}, | 2224 {67, kSkip}, |
2052 {100, kSkip}, | 2225 {100, kSkip}, |
2053 {133, kSkip}, | 2226 {133, kSkip}, |
2054 {kSkip, kSkip}, | 2227 {kSkip, kSkip}, |
2055 }; | 2228 }; |
2056 | 2229 |
| 2230 ExpectInitMediaLogs(HAS_VIDEO); |
| 2231 |
2057 // Expect duration adjustment since actual duration differs slightly from | 2232 // Expect duration adjustment since actual duration differs slightly from |
2058 // duration in the init segment. | 2233 // duration in the init segment. |
2059 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2736))); | 2234 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2736))); |
2060 | 2235 |
2061 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, | 2236 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, |
2062 base::TimeDelta::FromMilliseconds(2703), | 2237 base::TimeDelta::FromMilliseconds(2703), |
2063 HAS_VIDEO)); | 2238 HAS_VIDEO)); |
2064 EXPECT_EQ(194325, demuxer_->GetMemoryUsage()); | 2239 EXPECT_EQ(194325, demuxer_->GetMemoryUsage()); |
2065 } | 2240 } |
2066 | 2241 |
2067 TEST_F(ChunkDemuxerTest, WebMFile_AltRefFrames) { | 2242 TEST_F(ChunkDemuxerTest, WebMFile_AltRefFrames) { |
2068 struct BufferTimestamps buffer_timestamps[] = { | 2243 struct BufferTimestamps buffer_timestamps[] = { |
2069 {0, 0}, | 2244 {0, 0}, |
2070 {33, 3}, | 2245 {33, 3}, |
2071 {33, 6}, | 2246 {33, 6}, |
2072 {67, 9}, | 2247 {67, 9}, |
2073 {100, 12}, | 2248 {100, 12}, |
2074 {kSkip, kSkip}, | 2249 {kSkip, kSkip}, |
2075 }; | 2250 }; |
2076 | 2251 |
| 2252 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); |
| 2253 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); |
2077 ASSERT_TRUE(ParseWebMFile("bear-320x240-altref.webm", buffer_timestamps, | 2254 ASSERT_TRUE(ParseWebMFile("bear-320x240-altref.webm", buffer_timestamps, |
2078 base::TimeDelta::FromMilliseconds(2767))); | 2255 base::TimeDelta::FromMilliseconds(2767))); |
2079 } | 2256 } |
2080 | 2257 |
2081 // Verify that we output buffers before the entire cluster has been parsed. | 2258 // Verify that we output buffers before the entire cluster has been parsed. |
2082 TEST_F(ChunkDemuxerTest, IncrementalClusterParsing) { | 2259 TEST_F(ChunkDemuxerTest, IncrementalClusterParsing) { |
2083 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2260 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
2084 AppendEmptyCluster(0); | 2261 AppendEmptyCluster(0); |
2085 | 2262 |
2086 scoped_ptr<Cluster> cluster(GenerateCluster(0, 6)); | 2263 scoped_ptr<Cluster> cluster(GenerateCluster(0, 6)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2133 } | 2310 } |
2134 | 2311 |
2135 TEST_F(ChunkDemuxerTest, ParseErrorDuringInit) { | 2312 TEST_F(ChunkDemuxerTest, ParseErrorDuringInit) { |
2136 EXPECT_CALL(*this, DemuxerOpened()); | 2313 EXPECT_CALL(*this, DemuxerOpened()); |
2137 demuxer_->Initialize( | 2314 demuxer_->Initialize( |
2138 &host_, CreateInitDoneCB( | 2315 &host_, CreateInitDoneCB( |
2139 kNoTimestamp(), PIPELINE_ERROR_DECODE), true); | 2316 kNoTimestamp(), PIPELINE_ERROR_DECODE), true); |
2140 | 2317 |
2141 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 2318 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
2142 | 2319 |
| 2320 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
2143 uint8_t tmp = 0; | 2321 uint8_t tmp = 0; |
2144 demuxer_->AppendData(kSourceId, &tmp, 1, | 2322 demuxer_->AppendData(kSourceId, &tmp, 1, |
2145 append_window_start_for_next_append_, | 2323 append_window_start_for_next_append_, |
2146 append_window_end_for_next_append_, | 2324 append_window_end_for_next_append_, |
2147 ×tamp_offset_map_[kSourceId], | 2325 ×tamp_offset_map_[kSourceId], |
2148 init_segment_received_cb_); | 2326 init_segment_received_cb_); |
2149 } | 2327 } |
2150 | 2328 |
2151 TEST_F(ChunkDemuxerTest, AVHeadersWithAudioOnlyType) { | 2329 TEST_F(ChunkDemuxerTest, AVHeadersWithAudioOnlyType) { |
2152 EXPECT_CALL(*this, DemuxerOpened()); | 2330 EXPECT_CALL(*this, DemuxerOpened()); |
2153 demuxer_->Initialize( | 2331 demuxer_->Initialize( |
2154 &host_, CreateInitDoneCB(kNoTimestamp(), | 2332 &host_, CreateInitDoneCB(kNoTimestamp(), |
2155 PIPELINE_ERROR_DECODE), true); | 2333 PIPELINE_ERROR_DECODE), true); |
2156 | 2334 |
2157 std::vector<std::string> codecs(1); | 2335 std::vector<std::string> codecs(1); |
2158 codecs[0] = "vorbis"; | 2336 codecs[0] = "vorbis"; |
2159 ASSERT_EQ(demuxer_->AddId(kSourceId, "audio/webm", codecs), | 2337 ASSERT_EQ(demuxer_->AddId(kSourceId, "audio/webm", codecs), |
2160 ChunkDemuxer::kOk); | 2338 ChunkDemuxer::kOk); |
2161 | 2339 |
| 2340 // Video track is unexpected per mimetype. |
| 2341 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("a video", true)); |
| 2342 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
2162 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); | 2343 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); |
2163 } | 2344 } |
2164 | 2345 |
2165 TEST_F(ChunkDemuxerTest, AVHeadersWithVideoOnlyType) { | 2346 TEST_F(ChunkDemuxerTest, AVHeadersWithVideoOnlyType) { |
2166 EXPECT_CALL(*this, DemuxerOpened()); | 2347 EXPECT_CALL(*this, DemuxerOpened()); |
2167 demuxer_->Initialize( | 2348 demuxer_->Initialize( |
2168 &host_, CreateInitDoneCB(kNoTimestamp(), | 2349 &host_, CreateInitDoneCB(kNoTimestamp(), |
2169 PIPELINE_ERROR_DECODE), true); | 2350 PIPELINE_ERROR_DECODE), true); |
2170 | 2351 |
2171 std::vector<std::string> codecs(1); | 2352 std::vector<std::string> codecs(1); |
2172 codecs[0] = "vp8"; | 2353 codecs[0] = "vp8"; |
2173 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), | 2354 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), |
2174 ChunkDemuxer::kOk); | 2355 ChunkDemuxer::kOk); |
2175 | 2356 |
| 2357 // Audio track is unexpected per mimetype. |
| 2358 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("an audio", true)); |
| 2359 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
2176 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); | 2360 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); |
2177 } | 2361 } |
2178 | 2362 |
| 2363 TEST_F(ChunkDemuxerTest, AudioOnlyHeaderWithAVType) { |
| 2364 EXPECT_CALL(*this, DemuxerOpened()); |
| 2365 demuxer_->Initialize( |
| 2366 &host_, CreateInitDoneCB(kNoTimestamp(), PIPELINE_ERROR_DECODE), true); |
| 2367 |
| 2368 std::vector<std::string> codecs(2); |
| 2369 codecs[0] = "vorbis"; |
| 2370 codecs[1] = "vp8"; |
| 2371 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), |
| 2372 ChunkDemuxer::kOk); |
| 2373 |
| 2374 // Video track is also expected per mimetype. |
| 2375 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("a video", false)); |
| 2376 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
| 2377 AppendInitSegment(HAS_AUDIO); |
| 2378 } |
| 2379 |
| 2380 TEST_F(ChunkDemuxerTest, VideoOnlyHeaderWithAVType) { |
| 2381 EXPECT_CALL(*this, DemuxerOpened()); |
| 2382 demuxer_->Initialize( |
| 2383 &host_, CreateInitDoneCB(kNoTimestamp(), PIPELINE_ERROR_DECODE), true); |
| 2384 |
| 2385 std::vector<std::string> codecs(2); |
| 2386 codecs[0] = "vorbis"; |
| 2387 codecs[1] = "vp8"; |
| 2388 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), |
| 2389 ChunkDemuxer::kOk); |
| 2390 |
| 2391 // Audio track is also expected per mimetype. |
| 2392 EXPECT_MEDIA_LOG(InitSegmentMismatchesMimeType("an audio", false)); |
| 2393 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
| 2394 AppendInitSegment(HAS_VIDEO); |
| 2395 } |
| 2396 |
2179 TEST_F(ChunkDemuxerTest, MultipleHeaders) { | 2397 TEST_F(ChunkDemuxerTest, MultipleHeaders) { |
2180 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2398 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
2181 | 2399 |
2182 AppendCluster(kDefaultFirstCluster()); | 2400 AppendCluster(kDefaultFirstCluster()); |
2183 | 2401 |
2184 // Append another identical initialization segment. | 2402 // Append another identical initialization segment. |
2185 EXPECT_CALL(*this, InitSegmentReceived()); | 2403 EXPECT_CALL(*this, InitSegmentReceived()); |
2186 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); | 2404 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); |
2187 | 2405 |
2188 AppendCluster(kDefaultSecondCluster()); | 2406 AppendCluster(kDefaultSecondCluster()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); | 2448 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); |
2231 | 2449 |
2232 std::string audio_id = "audio1"; | 2450 std::string audio_id = "audio1"; |
2233 std::string video_id = "video1"; | 2451 std::string video_id = "video1"; |
2234 | 2452 |
2235 ASSERT_EQ(AddId(audio_id, HAS_AUDIO), ChunkDemuxer::kOk); | 2453 ASSERT_EQ(AddId(audio_id, HAS_AUDIO), ChunkDemuxer::kOk); |
2236 | 2454 |
2237 // Adding an id with audio/video should fail because we already added audio. | 2455 // Adding an id with audio/video should fail because we already added audio. |
2238 ASSERT_EQ(AddId(), ChunkDemuxer::kReachedIdLimit); | 2456 ASSERT_EQ(AddId(), ChunkDemuxer::kReachedIdLimit); |
2239 | 2457 |
| 2458 ExpectInitMediaLogs(HAS_AUDIO); |
2240 EXPECT_CALL(*this, InitSegmentReceived()); | 2459 EXPECT_CALL(*this, InitSegmentReceived()); |
2241 AppendInitSegmentWithSourceId(audio_id, HAS_AUDIO); | 2460 AppendInitSegmentWithSourceId(audio_id, HAS_AUDIO); |
2242 | 2461 |
2243 // Adding an id after append should fail. | 2462 // Adding an id after append should fail. |
2244 ASSERT_EQ(AddId(video_id, HAS_VIDEO), ChunkDemuxer::kReachedIdLimit); | 2463 ASSERT_EQ(AddId(video_id, HAS_VIDEO), ChunkDemuxer::kReachedIdLimit); |
2245 } | 2464 } |
2246 | 2465 |
2247 // Test that Read() calls after a RemoveId() return "end of stream" buffers. | 2466 // Test that Read() calls after a RemoveId() return "end of stream" buffers. |
2248 TEST_F(ChunkDemuxerTest, RemoveId) { | 2467 TEST_F(ChunkDemuxerTest, RemoveId) { |
2249 std::string audio_id = "audio1"; | 2468 std::string audio_id = "audio1"; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2395 EXPECT_TRUE(video_read_done); | 2614 EXPECT_TRUE(video_read_done); |
2396 } | 2615 } |
2397 | 2616 |
2398 // Test that Seek() completes successfully when EndOfStream | 2617 // Test that Seek() completes successfully when EndOfStream |
2399 // is called before data is available for that seek point. | 2618 // is called before data is available for that seek point. |
2400 // This scenario might be useful if seeking past the end of stream | 2619 // This scenario might be useful if seeking past the end of stream |
2401 // of either audio or video (or both). | 2620 // of either audio or video (or both). |
2402 TEST_F(ChunkDemuxerTest, EndOfStreamAfterPastEosSeek) { | 2621 TEST_F(ChunkDemuxerTest, EndOfStreamAfterPastEosSeek) { |
2403 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2622 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
2404 | 2623 |
2405 AppendCluster(GenerateSingleStreamCluster(0, 120, kAudioTrackNum, 10)); | 2624 AppendMuxedCluster( |
2406 AppendCluster(GenerateSingleStreamCluster(0, 100, kVideoTrackNum, 5)); | 2625 MuxedStreamInfo(kAudioTrackNum, |
| 2626 "0K 10K 20K 30K 40K 50K 60K 70K 80K 90K 100K 110K", 10), |
| 2627 MuxedStreamInfo(kVideoTrackNum, "0K 20K 40K 60K 80K", 20)); |
| 2628 CheckExpectedRanges("{ [0,100) }"); |
2407 | 2629 |
2408 // Seeking past the end of video. | 2630 // Seeking past the end of video. |
2409 // Note: audio data is available for that seek point. | 2631 // Note: audio data is available for that seek point. |
2410 bool seek_cb_was_called = false; | 2632 bool seek_cb_was_called = false; |
2411 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(110); | 2633 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(110); |
2412 demuxer_->StartWaitingForSeek(seek_time); | 2634 demuxer_->StartWaitingForSeek(seek_time); |
2413 demuxer_->Seek(seek_time, | 2635 demuxer_->Seek(seek_time, |
2414 base::Bind(OnSeekDone_OKExpected, &seek_cb_was_called)); | 2636 base::Bind(OnSeekDone_OKExpected, &seek_cb_was_called)); |
2415 message_loop_.RunUntilIdle(); | 2637 message_loop_.RunUntilIdle(); |
2416 | 2638 |
2417 EXPECT_FALSE(seek_cb_was_called); | 2639 EXPECT_FALSE(seek_cb_was_called); |
2418 | 2640 |
2419 EXPECT_CALL(host_, SetDuration( | 2641 EXPECT_CALL(host_, SetDuration( |
2420 base::TimeDelta::FromMilliseconds(120))); | 2642 base::TimeDelta::FromMilliseconds(120))); |
2421 MarkEndOfStream(PIPELINE_OK); | 2643 MarkEndOfStream(PIPELINE_OK); |
2422 message_loop_.RunUntilIdle(); | 2644 message_loop_.RunUntilIdle(); |
2423 | 2645 |
2424 EXPECT_TRUE(seek_cb_was_called); | 2646 EXPECT_TRUE(seek_cb_was_called); |
2425 | 2647 |
2426 ShutdownDemuxer(); | 2648 ShutdownDemuxer(); |
2427 } | 2649 } |
2428 | 2650 |
2429 // Test that EndOfStream is ignored if coming during a pending seek | 2651 // Test that EndOfStream is ignored if coming during a pending seek |
2430 // whose seek time is before some existing ranges. | 2652 // whose seek time is before some existing ranges. |
2431 TEST_F(ChunkDemuxerTest, EndOfStreamDuringPendingSeek) { | 2653 TEST_F(ChunkDemuxerTest, EndOfStreamDuringPendingSeek) { |
2432 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2654 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
2433 | 2655 |
2434 AppendCluster(GenerateSingleStreamCluster(0, 120, kAudioTrackNum, 10)); | 2656 AppendMuxedCluster( |
2435 AppendCluster(GenerateSingleStreamCluster(0, 100, kVideoTrackNum, 5)); | 2657 MuxedStreamInfo(kAudioTrackNum, |
2436 AppendCluster(GenerateSingleStreamCluster(200, 300, kAudioTrackNum, 10)); | 2658 "0K 10K 20K 30K 40K 50K 60K 70K 80K 90K 100K 110K", 10), |
2437 AppendCluster(GenerateSingleStreamCluster(200, 300, kVideoTrackNum, 5)); | 2659 MuxedStreamInfo(kVideoTrackNum, "0K 20K 40K 60K 80K", 20)); |
| 2660 AppendMuxedCluster( |
| 2661 MuxedStreamInfo(kAudioTrackNum, |
| 2662 "200K 210K 220K 230K 240K 250K 260K 270K 280K 290K", 10), |
| 2663 MuxedStreamInfo(kVideoTrackNum, "200K 220K 240K 260K 280K", 20)); |
2438 | 2664 |
2439 bool seek_cb_was_called = false; | 2665 bool seek_cb_was_called = false; |
2440 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(160); | 2666 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(160); |
2441 demuxer_->StartWaitingForSeek(seek_time); | 2667 demuxer_->StartWaitingForSeek(seek_time); |
2442 demuxer_->Seek(seek_time, | 2668 demuxer_->Seek(seek_time, |
2443 base::Bind(OnSeekDone_OKExpected, &seek_cb_was_called)); | 2669 base::Bind(OnSeekDone_OKExpected, &seek_cb_was_called)); |
2444 message_loop_.RunUntilIdle(); | 2670 message_loop_.RunUntilIdle(); |
2445 | 2671 |
2446 EXPECT_FALSE(seek_cb_was_called); | 2672 EXPECT_FALSE(seek_cb_was_called); |
2447 | 2673 |
2448 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(300))); | 2674 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(300))); |
2449 MarkEndOfStream(PIPELINE_OK); | 2675 MarkEndOfStream(PIPELINE_OK); |
2450 message_loop_.RunUntilIdle(); | 2676 message_loop_.RunUntilIdle(); |
2451 | 2677 |
2452 EXPECT_FALSE(seek_cb_was_called); | 2678 EXPECT_FALSE(seek_cb_was_called); |
2453 | 2679 |
2454 demuxer_->UnmarkEndOfStream(); | 2680 demuxer_->UnmarkEndOfStream(); |
2455 | 2681 |
2456 AppendCluster(GenerateSingleStreamCluster(140, 180, kAudioTrackNum, 10)); | 2682 AppendMuxedCluster( |
2457 AppendCluster(GenerateSingleStreamCluster(140, 180, kVideoTrackNum, 5)); | 2683 MuxedStreamInfo(kAudioTrackNum, "140K 150K 160K 170K", 10), |
| 2684 MuxedStreamInfo(kVideoTrackNum, "140K 145K 150K 155K 160K 165K 170K 175K", |
| 2685 20)); |
2458 | 2686 |
2459 message_loop_.RunUntilIdle(); | 2687 message_loop_.RunUntilIdle(); |
2460 | 2688 |
2461 EXPECT_TRUE(seek_cb_was_called); | 2689 EXPECT_TRUE(seek_cb_was_called); |
2462 | 2690 |
2463 ShutdownDemuxer(); | 2691 ShutdownDemuxer(); |
2464 } | 2692 } |
2465 | 2693 |
2466 // Test ranges in an audio-only stream. | 2694 // Test ranges in an audio-only stream. |
2467 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioIdOnly) { | 2695 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioIdOnly) { |
2468 EXPECT_CALL(*this, DemuxerOpened()); | 2696 EXPECT_CALL(*this, DemuxerOpened()); |
2469 demuxer_->Initialize( | 2697 demuxer_->Initialize( |
2470 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); | 2698 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); |
2471 | 2699 |
2472 ASSERT_EQ(AddId(kSourceId, HAS_AUDIO), ChunkDemuxer::kOk); | 2700 ASSERT_EQ(AddId(kSourceId, HAS_AUDIO), ChunkDemuxer::kOk); |
| 2701 ExpectInitMediaLogs(HAS_AUDIO); |
2473 EXPECT_CALL(*this, InitSegmentReceived()); | 2702 EXPECT_CALL(*this, InitSegmentReceived()); |
2474 AppendInitSegment(HAS_AUDIO); | 2703 AppendInitSegment(HAS_AUDIO); |
2475 | 2704 |
2476 // Test a simple cluster. | 2705 // Test a simple cluster. |
2477 AppendCluster( | 2706 AppendCluster( |
2478 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); | 2707 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); |
2479 | 2708 |
2480 CheckExpectedRanges("{ [0,92) }"); | 2709 CheckExpectedRanges("{ [0,92) }"); |
2481 | 2710 |
2482 // Append a disjoint cluster to check for two separate ranges. | 2711 // Append a disjoint cluster to check for two separate ranges. |
2483 AppendCluster(GenerateSingleStreamCluster( | 2712 AppendCluster(GenerateSingleStreamCluster( |
2484 150, 219, kAudioTrackNum, kAudioBlockDuration)); | 2713 150, 219, kAudioTrackNum, kAudioBlockDuration)); |
2485 | 2714 |
2486 CheckExpectedRanges("{ [0,92) [150,219) }"); | 2715 CheckExpectedRanges("{ [0,92) [150,219) }"); |
2487 } | 2716 } |
2488 | 2717 |
2489 // Test ranges in a video-only stream. | 2718 // Test ranges in a video-only stream. |
2490 TEST_F(ChunkDemuxerTest, GetBufferedRanges_VideoIdOnly) { | 2719 TEST_F(ChunkDemuxerTest, GetBufferedRanges_VideoIdOnly) { |
2491 EXPECT_CALL(*this, DemuxerOpened()); | 2720 EXPECT_CALL(*this, DemuxerOpened()); |
2492 demuxer_->Initialize( | 2721 demuxer_->Initialize( |
2493 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); | 2722 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); |
2494 | 2723 |
2495 ASSERT_EQ(AddId(kSourceId, HAS_VIDEO), ChunkDemuxer::kOk); | 2724 ASSERT_EQ(AddId(kSourceId, HAS_VIDEO), ChunkDemuxer::kOk); |
| 2725 ExpectInitMediaLogs(HAS_VIDEO); |
2496 EXPECT_CALL(*this, InitSegmentReceived()); | 2726 EXPECT_CALL(*this, InitSegmentReceived()); |
2497 AppendInitSegment(HAS_VIDEO); | 2727 AppendInitSegment(HAS_VIDEO); |
2498 | 2728 |
2499 // Test a simple cluster. | 2729 // Test a simple cluster. |
2500 AppendCluster( | 2730 AppendCluster( |
2501 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); | 2731 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); |
2502 | 2732 |
2503 CheckExpectedRanges("{ [0,132) }"); | 2733 CheckExpectedRanges("{ [0,132) }"); |
2504 | 2734 |
2505 // Append a disjoint cluster to check for two separate ranges. | 2735 // Append a disjoint cluster to check for two separate ranges. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2550 | 2780 |
2551 // Audio: 900 -> 970 | 2781 // Audio: 900 -> 970 |
2552 // Video: 920 -> 950 | 2782 // Video: 920 -> 950 |
2553 // Buffered Range: 920 -> 950 (complete overlap, video) | 2783 // Buffered Range: 920 -> 950 (complete overlap, video) |
2554 AppendCluster(GenerateSingleStreamCluster(900, 970, kAudioTrackNum, 70)); | 2784 AppendCluster(GenerateSingleStreamCluster(900, 970, kAudioTrackNum, 70)); |
2555 AppendCluster(GenerateSingleStreamCluster(920, 950, kVideoTrackNum, 30)); | 2785 AppendCluster(GenerateSingleStreamCluster(920, 950, kVideoTrackNum, 30)); |
2556 | 2786 |
2557 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); | 2787 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); |
2558 | 2788 |
2559 // Appending within buffered range should not affect buffered ranges. | 2789 // Appending within buffered range should not affect buffered ranges. |
2560 AppendCluster(GenerateSingleStreamCluster(930, 950, kAudioTrackNum, 20)); | 2790 EXPECT_MEDIA_LOG(GeneratedSplice(40000, 930000)); |
| 2791 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "930D20K"), |
| 2792 MuxedStreamInfo(kVideoTrackNum, "930D20K")); |
2561 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); | 2793 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); |
2562 | 2794 |
2563 // Appending to single stream outside buffered ranges should not affect | 2795 // Appending to single stream outside buffered ranges should not affect |
2564 // buffered ranges. | 2796 // buffered ranges. |
2565 AppendCluster(GenerateSingleStreamCluster(1230, 1240, kVideoTrackNum, 10)); | 2797 AppendCluster(GenerateSingleStreamCluster(1230, 1240, kVideoTrackNum, 10)); |
2566 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); | 2798 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); |
2567 } | 2799 } |
2568 | 2800 |
2569 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) { | 2801 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) { |
2570 EXPECT_CALL(host_, AddTextStream(_, _)); | 2802 EXPECT_CALL(host_, AddTextStream(_, _)); |
2571 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 2803 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
2572 | 2804 |
2573 // Append audio & video data | 2805 // Append audio & video data |
2574 AppendMuxedCluster( | 2806 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), |
2575 MuxedStreamInfo(kAudioTrackNum, "0K 23K"), | 2807 MuxedStreamInfo(kVideoTrackNum, "0K 33", 33)); |
2576 MuxedStreamInfo(kVideoTrackNum, "0K 33")); | |
2577 | 2808 |
2578 // Verify that a text track with no cues does not result in an empty buffered | 2809 // Verify that a text track with no cues does not result in an empty buffered |
2579 // range. | 2810 // range. |
2580 CheckExpectedRanges("{ [0,46) }"); | 2811 CheckExpectedRanges("{ [0,46) }"); |
2581 | 2812 |
2582 // Add some text cues. | 2813 // Add some text cues. |
2583 AppendMuxedCluster( | 2814 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "100K 123K", 23), |
2584 MuxedStreamInfo(kAudioTrackNum, "100K 123K"), | 2815 MuxedStreamInfo(kVideoTrackNum, "100K 133", 33), |
2585 MuxedStreamInfo(kVideoTrackNum, "100K 133"), | 2816 MuxedStreamInfo(kTextTrackNum, "100K 200K")); |
2586 MuxedStreamInfo(kTextTrackNum, "100K 200K")); | |
2587 | 2817 |
2588 // Verify that the text cues are not reflected in the buffered ranges. | 2818 // Verify that the text cues are not reflected in the buffered ranges. |
2589 CheckExpectedRanges("{ [0,46) [100,146) }"); | 2819 CheckExpectedRanges("{ [0,46) [100,146) }"); |
2590 | 2820 |
2591 // Remove the buffered ranges. | 2821 // Remove the buffered ranges. |
2592 demuxer_->Remove(kSourceId, base::TimeDelta(), | 2822 demuxer_->Remove(kSourceId, base::TimeDelta(), |
2593 base::TimeDelta::FromMilliseconds(250)); | 2823 base::TimeDelta::FromMilliseconds(250)); |
2594 CheckExpectedRanges("{ }"); | 2824 CheckExpectedRanges("{ }"); |
2595 } | 2825 } |
2596 | 2826 |
2597 // Once MarkEndOfStream() is called, GetBufferedRanges should not cut off any | 2827 // Once MarkEndOfStream() is called, GetBufferedRanges should not cut off any |
2598 // over-hanging tails at the end of the ranges as this is likely due to block | 2828 // over-hanging tails at the end of the ranges as this is likely due to block |
2599 // duration differences. | 2829 // duration differences. |
2600 TEST_F(ChunkDemuxerTest, GetBufferedRanges_EndOfStream) { | 2830 TEST_F(ChunkDemuxerTest, GetBufferedRanges_EndOfStream) { |
2601 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2831 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
2602 | 2832 |
2603 AppendMuxedCluster( | 2833 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), |
2604 MuxedStreamInfo(kAudioTrackNum, "0K 23K"), | 2834 MuxedStreamInfo(kVideoTrackNum, "0K 33", 33)); |
2605 MuxedStreamInfo(kVideoTrackNum, "0K 33")); | |
2606 | 2835 |
2607 CheckExpectedRanges("{ [0,46) }"); | 2836 CheckExpectedRanges("{ [0,46) }"); |
2608 | 2837 |
2609 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); | 2838 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); |
2610 MarkEndOfStream(PIPELINE_OK); | 2839 MarkEndOfStream(PIPELINE_OK); |
2611 | 2840 |
2612 // Verify that the range extends to the end of the video data. | 2841 // Verify that the range extends to the end of the video data. |
2613 CheckExpectedRanges("{ [0,66) }"); | 2842 CheckExpectedRanges("{ [0,66) }"); |
2614 | 2843 |
2615 // Verify that the range reverts to the intersection when end of stream | 2844 // Verify that the range reverts to the intersection when end of stream |
2616 // has been cancelled. | 2845 // has been cancelled. |
2617 demuxer_->UnmarkEndOfStream(); | 2846 demuxer_->UnmarkEndOfStream(); |
2618 CheckExpectedRanges("{ [0,46) }"); | 2847 CheckExpectedRanges("{ [0,46) }"); |
2619 | 2848 |
2620 // Append and remove data so that the 2 streams' end ranges do not overlap. | 2849 // Append and remove data so that the 2 streams' end ranges do not overlap. |
2621 | |
2622 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(398))); | 2850 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(398))); |
2623 AppendMuxedCluster( | 2851 AppendMuxedCluster( |
2624 MuxedStreamInfo(kAudioTrackNum, "200K 223K"), | 2852 MuxedStreamInfo(kAudioTrackNum, "200K 223K", 23), |
2625 MuxedStreamInfo(kVideoTrackNum, "200K 233 266 299 332K 365")); | 2853 MuxedStreamInfo(kVideoTrackNum, "200K 233 266 299 332K 365", 33)); |
2626 | 2854 |
2627 // At this point, the per-stream ranges are as follows: | 2855 // At this point, the per-stream ranges are as follows: |
2628 // Audio: [0,46) [200,246) | 2856 // Audio: [0,46) [200,246) |
2629 // Video: [0,66) [200,398) | 2857 // Video: [0,66) [200,398) |
2630 CheckExpectedRanges("{ [0,46) [200,246) }"); | 2858 CheckExpectedRanges("{ [0,46) [200,246) }"); |
2631 | 2859 |
2632 demuxer_->Remove(kSourceId, base::TimeDelta::FromMilliseconds(200), | 2860 demuxer_->Remove(kSourceId, base::TimeDelta::FromMilliseconds(200), |
2633 base::TimeDelta::FromMilliseconds(300)); | 2861 base::TimeDelta::FromMilliseconds(300)); |
2634 | 2862 |
2635 // At this point, the per-stream ranges are as follows: | 2863 // At this point, the per-stream ranges are as follows: |
2636 // Audio: [0,46) | 2864 // Audio: [0,46) |
2637 // Video: [0,66) [332,398) | 2865 // Video: [0,66) [332,398) |
2638 CheckExpectedRanges("{ [0,46) }"); | 2866 CheckExpectedRanges("{ [0,46) }"); |
2639 | 2867 |
2640 AppendMuxedCluster( | 2868 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "200K 223K", 23), |
2641 MuxedStreamInfo(kAudioTrackNum, "200K 223K"), | 2869 MuxedStreamInfo(kVideoTrackNum, "200K 233", 33)); |
2642 MuxedStreamInfo(kVideoTrackNum, "200K 233")); | |
2643 | 2870 |
2644 // At this point, the per-stream ranges are as follows: | 2871 // At this point, the per-stream ranges are as follows: |
2645 // Audio: [0,46) [200,246) | 2872 // Audio: [0,46) [200,246) |
2646 // Video: [0,66) [200,266) [332,398) | 2873 // Video: [0,66) [200,266) [332,398) |
2647 // NOTE: The last range on each stream do not overlap in time. | 2874 // NOTE: The last range on each stream do not overlap in time. |
2648 CheckExpectedRanges("{ [0,46) [200,246) }"); | 2875 CheckExpectedRanges("{ [0,46) [200,246) }"); |
2649 | 2876 |
2650 MarkEndOfStream(PIPELINE_OK); | 2877 MarkEndOfStream(PIPELINE_OK); |
2651 | 2878 |
2652 // NOTE: The last range on each stream gets extended to the highest | 2879 // NOTE: The last range on each stream gets extended to the highest |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3046 | 3273 |
3047 // After ResetParserState(), parsing should no longer be in the middle of a | 3274 // After ResetParserState(), parsing should no longer be in the middle of a |
3048 // media segment. | 3275 // media segment. |
3049 ASSERT_FALSE(demuxer_->IsParsingMediaSegment(kSourceId)); | 3276 ASSERT_FALSE(demuxer_->IsParsingMediaSegment(kSourceId)); |
3050 } | 3277 } |
3051 | 3278 |
3052 #if defined(USE_PROPRIETARY_CODECS) | 3279 #if defined(USE_PROPRIETARY_CODECS) |
3053 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 3280 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
3054 TEST_F(ChunkDemuxerTest, EmitBuffersDuringAbort) { | 3281 TEST_F(ChunkDemuxerTest, EmitBuffersDuringAbort) { |
3055 EXPECT_CALL(*this, DemuxerOpened()); | 3282 EXPECT_CALL(*this, DemuxerOpened()); |
| 3283 EXPECT_MEDIA_LOG(FoundStream("audio")); |
| 3284 EXPECT_MEDIA_LOG(CodecName("audio", "aac")); |
| 3285 EXPECT_MEDIA_LOG(FoundStream("video")); |
| 3286 EXPECT_MEDIA_LOG(CodecName("video", "h264")); |
3056 demuxer_->Initialize( | 3287 demuxer_->Initialize( |
3057 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); | 3288 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); |
3058 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); | 3289 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); |
3059 | 3290 |
3060 // For info: | 3291 // For info: |
3061 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode | 3292 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode |
3062 // Video: first PES: | 3293 // Video: first PES: |
3063 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] | 3294 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] |
3064 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] | 3295 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] |
3065 // Audio: first PES: | 3296 // Audio: first PES: |
(...skipping 24 matching lines...) Expand all Loading... |
3090 demuxer_->GetBufferedRanges(kSourceId); | 3321 demuxer_->GetBufferedRanges(kSourceId); |
3091 | 3322 |
3092 ASSERT_EQ(range_before_abort.size(), 1u); | 3323 ASSERT_EQ(range_before_abort.size(), 1u); |
3093 ASSERT_EQ(range_after_abort.size(), 1u); | 3324 ASSERT_EQ(range_after_abort.size(), 1u); |
3094 EXPECT_EQ(range_after_abort.start(0), range_before_abort.start(0)); | 3325 EXPECT_EQ(range_after_abort.start(0), range_before_abort.start(0)); |
3095 EXPECT_GT(range_after_abort.end(0), range_before_abort.end(0)); | 3326 EXPECT_GT(range_after_abort.end(0), range_before_abort.end(0)); |
3096 } | 3327 } |
3097 | 3328 |
3098 TEST_F(ChunkDemuxerTest, SeekCompleteDuringAbort) { | 3329 TEST_F(ChunkDemuxerTest, SeekCompleteDuringAbort) { |
3099 EXPECT_CALL(*this, DemuxerOpened()); | 3330 EXPECT_CALL(*this, DemuxerOpened()); |
| 3331 EXPECT_MEDIA_LOG(FoundStream("audio")); |
| 3332 EXPECT_MEDIA_LOG(CodecName("audio", "aac")); |
| 3333 EXPECT_MEDIA_LOG(FoundStream("video")); |
| 3334 EXPECT_MEDIA_LOG(CodecName("video", "h264")); |
3100 demuxer_->Initialize( | 3335 demuxer_->Initialize( |
3101 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); | 3336 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true); |
3102 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); | 3337 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId)); |
3103 | 3338 |
3104 // For info: | 3339 // For info: |
3105 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode | 3340 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode |
3106 // Video: first PES: | 3341 // Video: first PES: |
3107 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] | 3342 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101] |
3108 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] | 3343 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767] |
3109 // Audio: first PES: | 3344 // Audio: first PES: |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3345 TEST_F(ChunkDemuxerTest, SetMemoryLimitType) { | 3580 TEST_F(ChunkDemuxerTest, SetMemoryLimitType) { |
3346 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 3581 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
3347 | 3582 |
3348 // Set different memory limits for audio and video. | 3583 // Set different memory limits for audio and video. |
3349 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize); | 3584 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize); |
3350 demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, 5 * kBlockSize + 1); | 3585 demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, 5 * kBlockSize + 1); |
3351 | 3586 |
3352 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(1000); | 3587 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(1000); |
3353 | 3588 |
3354 // Append data at the start that can be garbage collected: | 3589 // Append data at the start that can be garbage collected: |
3355 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 0, 10); | 3590 AppendMuxedCluster( |
3356 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, 0, 5); | 3591 MuxedStreamInfo(kAudioTrackNum, |
| 3592 "0K 23K 46K 69K 92K 115K 138K 161K 184K 207K", 23), |
| 3593 MuxedStreamInfo(kVideoTrackNum, "0K 33K 66K 99K 132K", 33)); |
3357 | 3594 |
3358 // We should be right at buffer limit, should pass | 3595 // We should be right at buffer limit, should pass |
3359 EXPECT_TRUE(demuxer_->EvictCodedFrames( | 3596 EXPECT_TRUE(demuxer_->EvictCodedFrames( |
3360 kSourceId, base::TimeDelta::FromMilliseconds(0), 0)); | 3597 kSourceId, base::TimeDelta::FromMilliseconds(0), 0)); |
3361 | 3598 |
3362 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [0,230) }"); | 3599 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [0,230) }"); |
3363 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,165) }"); | 3600 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,165) }"); |
3364 | 3601 |
3365 // Seek so we can garbage collect the data appended above. | 3602 // Seek so we can garbage collect the data appended above. |
3366 Seek(seek_time); | 3603 Seek(seek_time); |
3367 | 3604 |
3368 // Append data at seek_time. | 3605 // Append data at seek_time. |
3369 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, | 3606 AppendMuxedCluster( |
3370 seek_time.InMilliseconds(), 10); | 3607 MuxedStreamInfo( |
3371 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3608 kAudioTrackNum, |
3372 seek_time.InMilliseconds(), 5); | 3609 "1000K 1023K 1046K 1069K 1092K 1115K 1138K 1161K 1184K 1207K", 23), |
| 3610 MuxedStreamInfo(kVideoTrackNum, "1000K 1033K 1066K 1099K 1132K", 33)); |
3373 | 3611 |
3374 // We should delete first append, and be exactly at buffer limit | 3612 // We should delete first append, and be exactly at buffer limit |
3375 EXPECT_TRUE(demuxer_->EvictCodedFrames(kSourceId, seek_time, 0)); | 3613 EXPECT_TRUE(demuxer_->EvictCodedFrames(kSourceId, seek_time, 0)); |
3376 | 3614 |
3377 // Verify that the old data, and nothing more, has been garbage collected. | 3615 // Verify that the old data, and nothing more, has been garbage collected. |
3378 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [1000,1230) }"); | 3616 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [1000,1230) }"); |
3379 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [1000,1165) }"); | 3617 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [1000,1165) }"); |
3380 } | 3618 } |
3381 | 3619 |
3382 TEST_F(ChunkDemuxerTest, GCDuringSeek_SingleRange_SeekForward) { | 3620 TEST_F(ChunkDemuxerTest, GCDuringSeek_SingleRange_SeekForward) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3586 | 3824 |
3587 TEST_F(ChunkDemuxerTest, AppendWindow_Video) { | 3825 TEST_F(ChunkDemuxerTest, AppendWindow_Video) { |
3588 ASSERT_TRUE(InitDemuxer(HAS_VIDEO)); | 3826 ASSERT_TRUE(InitDemuxer(HAS_VIDEO)); |
3589 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3827 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
3590 | 3828 |
3591 // Set the append window to [50,280). | 3829 // Set the append window to [50,280). |
3592 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); | 3830 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
3593 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3831 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
3594 | 3832 |
3595 // Append a cluster that starts before and ends after the append window. | 3833 // Append a cluster that starts before and ends after the append window. |
| 3834 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(30)); |
3596 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3835 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
3597 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"); | 3836 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"); |
3598 | 3837 |
3599 // Verify that GOPs that start outside the window are not included | 3838 // Verify that GOPs that start outside the window are not included |
3600 // in the buffer. Also verify that buffers that start inside the | 3839 // in the buffer. Also verify that buffers that start inside the |
3601 // window and extend beyond the end of the window are not included. | 3840 // window and extend beyond the end of the window are not included. |
3602 CheckExpectedRanges(kSourceId, "{ [120,270) }"); | 3841 CheckExpectedRanges(kSourceId, "{ [120,270) }"); |
3603 CheckExpectedBuffers(stream, "120K 150 180 210 240K"); | 3842 CheckExpectedBuffers(stream, "120K 150 180 210 240K"); |
3604 | 3843 |
3605 // Extend the append window to [50,650). | 3844 // Extend the append window to [50,650). |
3606 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); | 3845 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
3607 | 3846 |
3608 // Append more data and verify that adding buffers start at the next | 3847 // Append more data and verify that adding buffers start at the next |
3609 // key frame. | 3848 // key frame. |
| 3849 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(30)); |
3610 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3850 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
3611 "360 390 420K 450 480 510 540K 570 600 630K"); | 3851 "360 390 420K 450 480 510 540K 570 600 630K"); |
3612 CheckExpectedRanges(kSourceId, "{ [120,270) [420,630) }"); | 3852 CheckExpectedRanges(kSourceId, "{ [120,270) [420,630) }"); |
3613 } | 3853 } |
3614 | 3854 |
3615 TEST_F(ChunkDemuxerTest, AppendWindow_Audio) { | 3855 TEST_F(ChunkDemuxerTest, AppendWindow_Audio) { |
3616 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); | 3856 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
3617 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3857 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
3618 | 3858 |
3619 // Set the append window to [50,280). | 3859 // Set the append window to [50,280). |
3620 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); | 3860 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
3621 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3861 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
3622 | 3862 |
3623 // Append a cluster that starts before and ends after the append window. | 3863 // Append a cluster that starts before and ends after the append window. |
| 3864 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(30)); |
3624 AppendSingleStreamCluster( | 3865 AppendSingleStreamCluster( |
3625 kSourceId, kAudioTrackNum, | 3866 kSourceId, kAudioTrackNum, |
3626 "0K 30K 60K 90K 120K 150K 180K 210K 240K 270K 300K 330K"); | 3867 "0K 30K 60K 90K 120K 150K 180K 210K 240K 270K 300K 330K"); |
3627 | 3868 |
3628 // Verify that frames that end outside the window are not included | 3869 // Verify that frames that end outside the window are not included |
3629 // in the buffer. Also verify that buffers that start inside the | 3870 // in the buffer. Also verify that buffers that start inside the |
3630 // window and extend beyond the end of the window are not included. | 3871 // window and extend beyond the end of the window are not included. |
3631 // | 3872 // |
3632 // The first 50ms of the range should be truncated since it overlaps | 3873 // The first 50ms of the range should be truncated since it overlaps |
3633 // the start of the append window. | 3874 // the start of the append window. |
3634 CheckExpectedRanges(kSourceId, "{ [50,280) }"); | 3875 CheckExpectedRanges(kSourceId, "{ [50,280) }"); |
3635 | 3876 |
3636 // The "50P" buffer is the "0" buffer marked for complete discard. The next | 3877 // The "50P" buffer is the "0" buffer marked for complete discard. The next |
3637 // "50" buffer is the "30" buffer marked with 20ms of start discard. | 3878 // "50" buffer is the "30" buffer marked with 20ms of start discard. |
3638 CheckExpectedBuffers(stream, "50KP 50K 60K 90K 120K 150K 180K 210K 240K"); | 3879 CheckExpectedBuffers(stream, "50KP 50K 60K 90K 120K 150K 180K 210K 240K"); |
3639 | 3880 |
3640 // Extend the append window to [50,650). | 3881 // Extend the append window to [50,650). |
3641 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); | 3882 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
3642 | 3883 |
3643 // Append more data and verify that a new range is created. | 3884 // Append more data and verify that a new range is created. |
| 3885 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(30)); |
3644 AppendSingleStreamCluster( | 3886 AppendSingleStreamCluster( |
3645 kSourceId, kAudioTrackNum, | 3887 kSourceId, kAudioTrackNum, |
3646 "360K 390K 420K 450K 480K 510K 540K 570K 600K 630K"); | 3888 "360K 390K 420K 450K 480K 510K 540K 570K 600K 630K"); |
3647 CheckExpectedRanges(kSourceId, "{ [50,280) [360,650) }"); | 3889 CheckExpectedRanges(kSourceId, "{ [50,280) [360,650) }"); |
3648 } | 3890 } |
3649 | 3891 |
3650 TEST_F(ChunkDemuxerTest, AppendWindow_AudioOverlapStartAndEnd) { | 3892 TEST_F(ChunkDemuxerTest, AppendWindow_AudioOverlapStartAndEnd) { |
3651 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); | 3893 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
3652 | 3894 |
3653 // Set the append window to [10,20). | 3895 // Set the append window to [10,20). |
3654 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(10); | 3896 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(10); |
3655 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(20); | 3897 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
3656 | 3898 |
3657 // Append a cluster that starts before and ends after the append window. | 3899 // Append a cluster that starts before and ends after the append window. |
| 3900 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated( |
| 3901 WebMClusterParser::kDefaultAudioBufferDurationInMs)); |
3658 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K"); | 3902 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K"); |
3659 | 3903 |
3660 // Verify the append is clipped to the append window. | 3904 // Verify the append is clipped to the append window. |
3661 CheckExpectedRanges(kSourceId, "{ [10,20) }"); | 3905 CheckExpectedRanges(kSourceId, "{ [10,20) }"); |
3662 } | 3906 } |
3663 | 3907 |
3664 TEST_F(ChunkDemuxerTest, AppendWindow_WebMFile_AudioOnly) { | 3908 TEST_F(ChunkDemuxerTest, AppendWindow_WebMFile_AudioOnly) { |
3665 EXPECT_CALL(*this, DemuxerOpened()); | 3909 EXPECT_CALL(*this, DemuxerOpened()); |
3666 demuxer_->Initialize( | 3910 demuxer_->Initialize( |
3667 &host_, | 3911 &host_, |
3668 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), | 3912 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), |
3669 true); | 3913 true); |
3670 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); | 3914 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); |
3671 | 3915 |
3672 // Set the append window to [50,150). | 3916 // Set the append window to [50,150). |
3673 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); | 3917 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
3674 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(150); | 3918 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(150); |
3675 | 3919 |
3676 // Read a WebM file into memory and send the data to the demuxer. The chunk | 3920 // Read a WebM file into memory and send the data to the demuxer. The chunk |
3677 // size has been chosen carefully to ensure the preroll buffer used by the | 3921 // size has been chosen carefully to ensure the preroll buffer used by the |
3678 // partial append window trim must come from a previous Append() call. | 3922 // partial append window trim must come from a previous Append() call. |
3679 scoped_refptr<DecoderBuffer> buffer = | 3923 scoped_refptr<DecoderBuffer> buffer = |
3680 ReadTestDataFile("bear-320x240-audio-only.webm"); | 3924 ReadTestDataFile("bear-320x240-audio-only.webm"); |
| 3925 ExpectInitMediaLogs(HAS_AUDIO); |
3681 EXPECT_CALL(*this, InitSegmentReceived()); | 3926 EXPECT_CALL(*this, InitSegmentReceived()); |
| 3927 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); |
3682 AppendDataInPieces(buffer->data(), buffer->data_size(), 128); | 3928 AppendDataInPieces(buffer->data(), buffer->data_size(), 128); |
3683 | 3929 |
3684 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3930 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
3685 CheckExpectedBuffers(stream, "50KP 50K 62K 86K 109K 122K 125K 128K"); | 3931 CheckExpectedBuffers(stream, "50KP 50K 62K 86K 109K 122K 125K 128K"); |
3686 } | 3932 } |
3687 | 3933 |
3688 TEST_F(ChunkDemuxerTest, AppendWindow_AudioConfigUpdateRemovesPreroll) { | 3934 TEST_F(ChunkDemuxerTest, AppendWindow_AudioConfigUpdateRemovesPreroll) { |
3689 EXPECT_CALL(*this, DemuxerOpened()); | 3935 EXPECT_CALL(*this, DemuxerOpened()); |
3690 demuxer_->Initialize( | 3936 demuxer_->Initialize( |
3691 &host_, | 3937 &host_, |
3692 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), | 3938 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), |
3693 true); | 3939 true); |
3694 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); | 3940 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); |
3695 | 3941 |
3696 // Set the append window such that the first file is completely before the | 3942 // Set the append window such that the first file is completely before the |
3697 // append window. | 3943 // append window. |
3698 // Expect duration adjustment since actual duration differs slightly from | 3944 // Expect duration adjustment since actual duration differs slightly from |
3699 // duration in the init segment. | 3945 // duration in the init segment. |
3700 const base::TimeDelta duration_1 = base::TimeDelta::FromMilliseconds(2746); | 3946 const base::TimeDelta duration_1 = base::TimeDelta::FromMilliseconds(2746); |
3701 append_window_start_for_next_append_ = duration_1; | 3947 append_window_start_for_next_append_ = duration_1; |
3702 | 3948 |
3703 // Read a WebM file into memory and append the data. | 3949 // Read a WebM file into memory and append the data. |
3704 scoped_refptr<DecoderBuffer> buffer = | 3950 scoped_refptr<DecoderBuffer> buffer = |
3705 ReadTestDataFile("bear-320x240-audio-only.webm"); | 3951 ReadTestDataFile("bear-320x240-audio-only.webm"); |
| 3952 ExpectInitMediaLogs(HAS_AUDIO); |
3706 EXPECT_CALL(*this, InitSegmentReceived()); | 3953 EXPECT_CALL(*this, InitSegmentReceived()); |
| 3954 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); |
3707 AppendDataInPieces(buffer->data(), buffer->data_size(), 512); | 3955 AppendDataInPieces(buffer->data(), buffer->data_size(), 512); |
3708 CheckExpectedRanges(kSourceId, "{ }"); | 3956 CheckExpectedRanges(kSourceId, "{ }"); |
3709 | 3957 |
3710 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3958 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
3711 AudioDecoderConfig config_1 = stream->audio_decoder_config(); | 3959 AudioDecoderConfig config_1 = stream->audio_decoder_config(); |
3712 | 3960 |
3713 // Read a second WebM with a different config in and append the data. | 3961 // Read a second WebM with a different config in and append the data. |
3714 scoped_refptr<DecoderBuffer> buffer2 = | 3962 scoped_refptr<DecoderBuffer> buffer2 = |
3715 ReadTestDataFile("bear-320x240-audio-only-48khz.webm"); | 3963 ReadTestDataFile("bear-320x240-audio-only-48khz.webm"); |
3716 EXPECT_CALL(*this, InitSegmentReceived()); | 3964 EXPECT_CALL(*this, InitSegmentReceived()); |
| 3965 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(21)); |
3717 EXPECT_CALL(host_, SetDuration(_)).Times(AnyNumber()); | 3966 EXPECT_CALL(host_, SetDuration(_)).Times(AnyNumber()); |
3718 ASSERT_TRUE(SetTimestampOffset(kSourceId, duration_1)); | 3967 ASSERT_TRUE(SetTimestampOffset(kSourceId, duration_1)); |
3719 AppendDataInPieces(buffer2->data(), buffer2->data_size(), 512); | 3968 AppendDataInPieces(buffer2->data(), buffer2->data_size(), 512); |
3720 CheckExpectedRanges(kSourceId, "{ [2746,5519) }"); | 3969 CheckExpectedRanges(kSourceId, "{ [2746,5519) }"); |
3721 | 3970 |
3722 Seek(duration_1); | 3971 Seek(duration_1); |
3723 ExpectConfigChanged(DemuxerStream::AUDIO); | 3972 ExpectConfigChanged(DemuxerStream::AUDIO); |
3724 ASSERT_FALSE(config_1.Matches(stream->audio_decoder_config())); | 3973 ASSERT_FALSE(config_1.Matches(stream->audio_decoder_config())); |
3725 CheckExpectedBuffers(stream, "2746K 2767K 2789K 2810K"); | 3974 CheckExpectedBuffers(stream, "2746K 2767K 2789K 2810K"); |
3726 } | 3975 } |
3727 | 3976 |
3728 TEST_F(ChunkDemuxerTest, AppendWindow_Text) { | 3977 TEST_F(ChunkDemuxerTest, AppendWindow_Text) { |
3729 DemuxerStream* text_stream = NULL; | 3978 DemuxerStream* text_stream = NULL; |
3730 EXPECT_CALL(host_, AddTextStream(_, _)) | 3979 EXPECT_CALL(host_, AddTextStream(_, _)) |
3731 .WillOnce(SaveArg<0>(&text_stream)); | 3980 .WillOnce(SaveArg<0>(&text_stream)); |
3732 ASSERT_TRUE(InitDemuxer(HAS_VIDEO | HAS_TEXT)); | 3981 ASSERT_TRUE(InitDemuxer(HAS_VIDEO | HAS_TEXT)); |
3733 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3982 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
3734 | 3983 |
3735 // Set the append window to [20,280). | 3984 // Set the append window to [20,280). |
3736 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); | 3985 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
3737 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3986 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
3738 | 3987 |
3739 // Append a cluster that starts before and ends after the append | 3988 // Append a cluster that starts before and ends after the append |
3740 // window. | 3989 // window. |
3741 AppendMuxedCluster( | 3990 AppendMuxedCluster( |
3742 MuxedStreamInfo(kVideoTrackNum, | 3991 MuxedStreamInfo(kVideoTrackNum, |
3743 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"), | 3992 "0K 30 60 90 120K 150 180 210 240K 270 300 330K", 30), |
3744 MuxedStreamInfo(kTextTrackNum, "0K 100K 200K 300K" )); | 3993 MuxedStreamInfo(kTextTrackNum, "0K 100K 200K 300K")); |
3745 | 3994 |
3746 // Verify that text cues that start outside the window are not included | 3995 // Verify that text cues that start outside the window are not included |
3747 // in the buffer. Also verify that cues that extend beyond the | 3996 // in the buffer. Also verify that cues that extend beyond the |
3748 // window are not included. | 3997 // window are not included. |
3749 CheckExpectedRanges(kSourceId, "{ [100,270) }"); | 3998 CheckExpectedRanges(kSourceId, "{ [100,270) }"); |
3750 CheckExpectedBuffers(video_stream, "120K 150 180 210 240K"); | 3999 CheckExpectedBuffers(video_stream, "120K 150 180 210 240K"); |
3751 CheckExpectedBuffers(text_stream, "100K"); | 4000 CheckExpectedBuffers(text_stream, "100K"); |
3752 | 4001 |
3753 // Extend the append window to [20,650). | 4002 // Extend the append window to [20,650). |
3754 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); | 4003 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
3755 | 4004 |
3756 // Append more data and verify that a new range is created. | 4005 // Append more data and verify that a new range is created. |
3757 AppendMuxedCluster( | 4006 AppendMuxedCluster( |
3758 MuxedStreamInfo(kVideoTrackNum, | 4007 MuxedStreamInfo(kVideoTrackNum, |
3759 "360 390 420K 450 480 510 540K 570 600 630K"), | 4008 "360 390 420K 450 480 510 540K 570 600 630K", 30), |
3760 MuxedStreamInfo(kTextTrackNum, "400K 500K 600K 700K" )); | 4009 MuxedStreamInfo(kTextTrackNum, "400K 500K 600K 700K")); |
3761 CheckExpectedRanges(kSourceId, "{ [100,270) [400,630) }"); | 4010 CheckExpectedRanges("{ [100,270) [400,630) }"); |
3762 | 4011 |
3763 // Seek to the new range and verify that the expected buffers are returned. | 4012 // Seek to the new range and verify that the expected buffers are returned. |
3764 Seek(base::TimeDelta::FromMilliseconds(420)); | 4013 Seek(base::TimeDelta::FromMilliseconds(420)); |
3765 CheckExpectedBuffers(video_stream, "420K 450 480 510 540K 570 600"); | 4014 CheckExpectedBuffers(video_stream, "420K 450 480 510 540K 570 600"); |
3766 CheckExpectedBuffers(text_stream, "400K 500K"); | 4015 CheckExpectedBuffers(text_stream, "400K 500K"); |
3767 } | 4016 } |
3768 | 4017 |
3769 TEST_F(ChunkDemuxerTest, StartWaitingForSeekAfterParseError) { | 4018 TEST_F(ChunkDemuxerTest, StartWaitingForSeekAfterParseError) { |
3770 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 4019 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 4020 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
3771 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 4021 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
3772 AppendGarbage(); | 4022 AppendGarbage(); |
3773 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(50); | 4023 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(50); |
3774 demuxer_->StartWaitingForSeek(seek_time); | 4024 demuxer_->StartWaitingForSeek(seek_time); |
3775 } | 4025 } |
3776 | 4026 |
3777 TEST_F(ChunkDemuxerTest, Remove_AudioVideoText) { | 4027 TEST_F(ChunkDemuxerTest, Remove_AudioVideoText) { |
3778 DemuxerStream* text_stream = NULL; | 4028 DemuxerStream* text_stream = NULL; |
3779 EXPECT_CALL(host_, AddTextStream(_, _)) | 4029 EXPECT_CALL(host_, AddTextStream(_, _)) |
3780 .WillOnce(SaveArg<0>(&text_stream)); | 4030 .WillOnce(SaveArg<0>(&text_stream)); |
3781 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 4031 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
3782 | 4032 |
3783 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 4033 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
3784 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 4034 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
3785 | 4035 |
3786 AppendMuxedCluster( | 4036 AppendMuxedCluster( |
3787 MuxedStreamInfo(kAudioTrackNum, "0K 20K 40K 60K 80K 100K 120K 140K"), | 4037 MuxedStreamInfo(kAudioTrackNum, "0K 20K 40K 60K 80K 100K 120K 140K", 20), |
3788 MuxedStreamInfo(kVideoTrackNum, "0K 30 60 90 120K 150 180"), | 4038 MuxedStreamInfo(kVideoTrackNum, "0K 30 60 90 120K 150 180", 30), |
3789 MuxedStreamInfo(kTextTrackNum, "0K 100K 200K")); | 4039 MuxedStreamInfo(kTextTrackNum, "0K 100K 200K")); |
3790 | 4040 |
3791 CheckExpectedBuffers(audio_stream, "0K 20K 40K 60K 80K 100K 120K 140K"); | 4041 CheckExpectedBuffers(audio_stream, "0K 20K 40K 60K 80K 100K 120K 140K"); |
3792 CheckExpectedBuffers(video_stream, "0K 30 60 90 120K 150 180"); | 4042 CheckExpectedBuffers(video_stream, "0K 30 60 90 120K 150 180"); |
3793 CheckExpectedBuffers(text_stream, "0K 100K 200K"); | 4043 CheckExpectedBuffers(text_stream, "0K 100K 200K"); |
3794 | 4044 |
3795 // Remove the buffers that were added. | 4045 // Remove the buffers that were added. |
3796 demuxer_->Remove(kSourceId, base::TimeDelta(), | 4046 demuxer_->Remove(kSourceId, base::TimeDelta(), |
3797 base::TimeDelta::FromMilliseconds(300)); | 4047 base::TimeDelta::FromMilliseconds(300)); |
3798 | 4048 |
3799 // Verify that all the appended data has been removed. | 4049 // Verify that all the appended data has been removed. |
3800 CheckExpectedRanges(kSourceId, "{ }"); | 4050 CheckExpectedRanges(kSourceId, "{ }"); |
3801 | 4051 |
3802 // Append new buffers that are clearly different than the original | 4052 // Append new buffers that are clearly different than the original |
3803 // ones and verify that only the new buffers are returned. | 4053 // ones and verify that only the new buffers are returned. |
3804 AppendMuxedCluster( | 4054 AppendMuxedCluster( |
3805 MuxedStreamInfo(kAudioTrackNum, "1K 21K 41K 61K 81K 101K 121K 141K"), | 4055 MuxedStreamInfo(kAudioTrackNum, "1K 21K 41K 61K 81K 101K 121K 141K", 20), |
3806 MuxedStreamInfo(kVideoTrackNum, "1K 31 61 91 121K 151 181"), | 4056 MuxedStreamInfo(kVideoTrackNum, "1K 31 61 91 121K 151 181", 30), |
3807 MuxedStreamInfo(kTextTrackNum, "1K 101K 201K")); | 4057 MuxedStreamInfo(kTextTrackNum, "1K 101K 201K")); |
3808 | 4058 |
3809 Seek(base::TimeDelta()); | 4059 Seek(base::TimeDelta()); |
3810 CheckExpectedBuffers(audio_stream, "1K 21K 41K 61K 81K 101K 121K 141K"); | 4060 CheckExpectedBuffers(audio_stream, "1K 21K 41K 61K 81K 101K 121K 141K"); |
3811 CheckExpectedBuffers(video_stream, "1K 31 61 91 121K 151 181"); | 4061 CheckExpectedBuffers(video_stream, "1K 31 61 91 121K 151 181"); |
3812 CheckExpectedBuffers(text_stream, "1K 101K 201K"); | 4062 CheckExpectedBuffers(text_stream, "1K 101K 201K"); |
3813 } | 4063 } |
3814 | 4064 |
3815 TEST_F(ChunkDemuxerTest, Remove_StartAtDuration) { | 4065 TEST_F(ChunkDemuxerTest, Remove_StartAtDuration) { |
3816 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); | 4066 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
3817 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 4067 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
3818 | 4068 |
3819 // Set the duration to something small so that the append that | 4069 // Set the duration to something small so that the append that |
3820 // follows updates the duration to reflect the end of the appended data. | 4070 // follows updates the duration to reflect the end of the appended data. |
3821 EXPECT_CALL(host_, SetDuration( | 4071 EXPECT_CALL(host_, SetDuration( |
3822 base::TimeDelta::FromMilliseconds(1))); | 4072 base::TimeDelta::FromMilliseconds(1))); |
3823 demuxer_->SetDuration(0.001); | 4073 demuxer_->SetDuration(0.001); |
3824 | 4074 |
3825 EXPECT_CALL(host_, SetDuration( | 4075 EXPECT_CALL(host_, SetDuration( |
3826 base::TimeDelta::FromMilliseconds(160))); | 4076 base::TimeDelta::FromMilliseconds(160))); |
3827 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, | 4077 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, |
3828 "0K 20K 40K 60K 80K 100K 120K 140K"); | 4078 "0K 20K 40K 60K 80K 100K 120K 140D20K"); |
3829 | 4079 |
3830 CheckExpectedRanges(kSourceId, "{ [0,160) }"); | 4080 CheckExpectedRanges(kSourceId, "{ [0,160) }"); |
3831 CheckExpectedBuffers(audio_stream, "0K 20K 40K 60K 80K 100K 120K 140K"); | 4081 CheckExpectedBuffers(audio_stream, "0K 20K 40K 60K 80K 100K 120K 140K"); |
3832 | 4082 |
3833 demuxer_->Remove(kSourceId, | 4083 demuxer_->Remove(kSourceId, |
3834 base::TimeDelta::FromSecondsD(demuxer_->GetDuration()), | 4084 base::TimeDelta::FromSecondsD(demuxer_->GetDuration()), |
3835 kInfiniteDuration()); | 4085 kInfiniteDuration()); |
3836 | 4086 |
3837 Seek(base::TimeDelta()); | 4087 Seek(base::TimeDelta()); |
3838 CheckExpectedRanges(kSourceId, "{ [0,160) }"); | 4088 CheckExpectedRanges(kSourceId, "{ [0,160) }"); |
(...skipping 22 matching lines...) Expand all Loading... |
3861 EXPECT_FALSE(seek_cb_was_called); | 4111 EXPECT_FALSE(seek_cb_was_called); |
3862 | 4112 |
3863 bool text_read_done = false; | 4113 bool text_read_done = false; |
3864 text_stream->Read(base::Bind(&OnReadDone, | 4114 text_stream->Read(base::Bind(&OnReadDone, |
3865 base::TimeDelta::FromMilliseconds(225), | 4115 base::TimeDelta::FromMilliseconds(225), |
3866 &text_read_done)); | 4116 &text_read_done)); |
3867 | 4117 |
3868 // Append audio & video data so the seek completes. | 4118 // Append audio & video data so the seek completes. |
3869 AppendMuxedCluster( | 4119 AppendMuxedCluster( |
3870 MuxedStreamInfo(kAudioTrackNum, | 4120 MuxedStreamInfo(kAudioTrackNum, |
3871 "0K 20K 40K 60K 80K 100K 120K 140K 160K 180K 200K"), | 4121 "0K 20K 40K 60K 80K 100K 120K 140K 160K 180K 200K", 20), |
3872 MuxedStreamInfo(kVideoTrackNum, "0K 30 60 90 120K 150 180 210")); | 4122 MuxedStreamInfo(kVideoTrackNum, "0K 30 60 90 120K 150 180 210", 30)); |
3873 | 4123 |
3874 message_loop_.RunUntilIdle(); | 4124 message_loop_.RunUntilIdle(); |
3875 EXPECT_TRUE(seek_cb_was_called); | 4125 EXPECT_TRUE(seek_cb_was_called); |
3876 EXPECT_FALSE(text_read_done); | 4126 EXPECT_FALSE(text_read_done); |
3877 | 4127 |
3878 // Read some audio & video buffers to further verify seek completion. | 4128 // Read some audio & video buffers to further verify seek completion. |
3879 CheckExpectedBuffers(audio_stream, "120K 140K"); | 4129 CheckExpectedBuffers(audio_stream, "120K 140K"); |
3880 CheckExpectedBuffers(video_stream, "120K 150"); | 4130 CheckExpectedBuffers(video_stream, "120K 150"); |
3881 | 4131 |
3882 EXPECT_FALSE(text_read_done); | 4132 EXPECT_FALSE(text_read_done); |
3883 | 4133 |
3884 // Append text cues that start after the seek point and verify that | 4134 // Append text cues that start after the seek point and verify that |
3885 // they are returned by Read() calls. | 4135 // they are returned by Read() calls. |
3886 AppendMuxedCluster( | 4136 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "220K 240K 260K 280K", 20), |
3887 MuxedStreamInfo(kAudioTrackNum, "220K 240K 260K 280K"), | 4137 MuxedStreamInfo(kVideoTrackNum, "240K 270 300 330", 30), |
3888 MuxedStreamInfo(kVideoTrackNum, "240K 270 300 330"), | 4138 MuxedStreamInfo(kTextTrackNum, "225K 275K 325K")); |
3889 MuxedStreamInfo(kTextTrackNum, "225K 275K 325K")); | |
3890 | 4139 |
3891 message_loop_.RunUntilIdle(); | 4140 message_loop_.RunUntilIdle(); |
3892 EXPECT_TRUE(text_read_done); | 4141 EXPECT_TRUE(text_read_done); |
3893 | 4142 |
3894 // NOTE: we start at 275 here because the buffer at 225 was returned | 4143 // NOTE: we start at 275 here because the buffer at 225 was returned |
3895 // to the pending read initiated above. | 4144 // to the pending read initiated above. |
3896 CheckExpectedBuffers(text_stream, "275K 325K"); | 4145 CheckExpectedBuffers(text_stream, "275K 325K"); |
3897 | 4146 |
3898 // Verify that audio & video streams continue to return expected values. | 4147 // Verify that audio & video streams continue to return expected values. |
3899 CheckExpectedBuffers(audio_stream, "160K 180K"); | 4148 CheckExpectedBuffers(audio_stream, "160K 180K"); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3939 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize); | 4188 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize); |
3940 demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, 15 * kBlockSize); | 4189 demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, 15 * kBlockSize); |
3941 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 4190 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
3942 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 4191 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
3943 | 4192 |
3944 const char* kAudioStreamInfo = "0K 40K 80K 120K 160K 200K 240K 280K"; | 4193 const char* kAudioStreamInfo = "0K 40K 80K 120K 160K 200K 240K 280K"; |
3945 const char* kVideoStreamInfo = "0K 10 20K 30 40K 50 60K 70 80K 90 100K " | 4194 const char* kVideoStreamInfo = "0K 10 20K 30 40K 50 60K 70 80K 90 100K " |
3946 "110 120K 130 140K"; | 4195 "110 120K 130 140K"; |
3947 // Append 8 blocks (80 bytes) of data to audio stream and 15 blocks (150 | 4196 // Append 8 blocks (80 bytes) of data to audio stream and 15 blocks (150 |
3948 // bytes) to video stream. | 4197 // bytes) to video stream. |
3949 AppendMuxedCluster( | 4198 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, kAudioStreamInfo, 40), |
3950 MuxedStreamInfo(kAudioTrackNum, kAudioStreamInfo), | 4199 MuxedStreamInfo(kVideoTrackNum, kVideoStreamInfo, 10)); |
3951 MuxedStreamInfo(kVideoTrackNum, kVideoStreamInfo)); | |
3952 CheckExpectedBuffers(audio_stream, kAudioStreamInfo); | 4200 CheckExpectedBuffers(audio_stream, kAudioStreamInfo); |
3953 CheckExpectedBuffers(video_stream, kVideoStreamInfo); | 4201 CheckExpectedBuffers(video_stream, kVideoStreamInfo); |
3954 | 4202 |
3955 // If we want to append 80 more blocks of muxed a+v data and the current | 4203 // If we want to append 80 more blocks of muxed a+v data and the current |
3956 // position is 0, that will fail, because EvictCodedFrames won't remove the | 4204 // position is 0, that will fail, because EvictCodedFrames won't remove the |
3957 // data after the current playback position. | 4205 // data after the current playback position. |
3958 ASSERT_FALSE(demuxer_->EvictCodedFrames(kSourceId, | 4206 ASSERT_FALSE(demuxer_->EvictCodedFrames(kSourceId, |
3959 base::TimeDelta::FromMilliseconds(0), | 4207 base::TimeDelta::FromMilliseconds(0), |
3960 80)); | 4208 80)); |
3961 // EvictCodedFrames has failed, so data should be unchanged. | 4209 // EvictCodedFrames has failed, so data should be unchanged. |
(...skipping 17 matching lines...) Expand all Loading... |
3979 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 | 4227 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 |
3980 // byte block to stay under 100 bytes memory limit after append | 4228 // byte block to stay under 100 bytes memory limit after append |
3981 // 80 - 10 + 28 = 98). | 4229 // 80 - 10 + 28 = 98). |
3982 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to | 4230 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to |
3983 // remove at least 6 blocks to stay under limit. | 4231 // remove at least 6 blocks to stay under limit. |
3984 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); | 4232 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); |
3985 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); | 4233 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); |
3986 } | 4234 } |
3987 | 4235 |
3988 } // namespace media | 4236 } // namespace media |
OLD | NEW |