Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 block_flags = kWebMFlagKeyframe; | 374 block_flags = kWebMFlagKeyframe; |
| 375 // Remove the "K" off of the token. | 375 // Remove the "K" off of the token. |
| 376 timestamp_str = timestamp_str.substr(0, timestamps[i].length() - 1); | 376 timestamp_str = timestamp_str.substr(0, timestamps[i].length() - 1); |
| 377 } | 377 } |
| 378 int timestamp_in_ms; | 378 int timestamp_in_ms; |
| 379 CHECK(base::StringToInt(timestamp_str, ×tamp_in_ms)); | 379 CHECK(base::StringToInt(timestamp_str, ×tamp_in_ms)); |
| 380 | 380 |
| 381 if (i == 0) | 381 if (i == 0) |
| 382 cb.SetClusterTimecode(timestamp_in_ms); | 382 cb.SetClusterTimecode(timestamp_in_ms); |
| 383 | 383 |
| 384 if (track_number == kTextTrackNum) { | 384 switch (track_number) { |
| 385 cb.AddBlockGroup(track_number, timestamp_in_ms, kTextBlockDuration, | 385 case kVideoTrackNum: |
| 386 block_flags, &data[0], data.size()); | 386 AddVideoBlockGroup(&cb, kVideoTrackNum, timestamp_in_ms, |
| 387 } else { | 387 kVideoBlockDuration, block_flags); |
| 388 cb.AddSimpleBlock(track_number, timestamp_in_ms, block_flags, | 388 break; |
| 389 &data[0], data.size()); | 389 case kAudioTrackNum: |
| 390 cb.AddBlockGroup(kAudioTrackNum, timestamp_in_ms, | |
| 391 kAudioBlockDuration, block_flags, &data[0], | |
| 392 data.size()); | |
| 393 break; | |
| 394 case kTextTrackNum: | |
| 395 cb.AddBlockGroup(kTextTrackNum, timestamp_in_ms, | |
| 396 kTextBlockDuration, block_flags, &data[0], | |
| 397 data.size()); | |
| 398 break; | |
| 399 default: | |
| 400 DCHECK(false) << "Unknown track number: " << track_number; | |
| 390 } | 401 } |
| 391 } | 402 } |
| 392 AppendCluster(source_id, cb.Finish()); | 403 AppendCluster(source_id, cb.Finish()); |
| 393 } | 404 } |
| 394 | 405 |
| 395 void AppendData(const std::string& source_id, | 406 void AppendData(const std::string& source_id, |
| 396 const uint8* data, size_t length) { | 407 const uint8* data, size_t length) { |
| 397 EXPECT_CALL(host_, AddBufferedTimeRange(_, _)).Times(AnyNumber()); | 408 EXPECT_CALL(host_, AddBufferedTimeRange(_, _)).Times(AnyNumber()); |
| 398 | 409 |
| 399 // TODO(wolenetz): Test timestamp offset updating once "sequence" append | 410 // TODO(wolenetz): Test timestamp offset updating once "sequence" append |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 // bear-640x360.webm AudioDecoderConfig returns 3935 for its extra_data_size() | 560 // bear-640x360.webm AudioDecoderConfig returns 3935 for its extra_data_size() |
| 550 // The resulting audio stream returns data from each file for the following | 561 // The resulting audio stream returns data from each file for the following |
| 551 // time ranges. | 562 // time ranges. |
| 552 // bear-320x240.webm : [0-524) [779-2737) | 563 // bear-320x240.webm : [0-524) [779-2737) |
| 553 // bear-640x360.webm : [527-759) | 564 // bear-640x360.webm : [527-759) |
| 554 bool InitDemuxerWithConfigChangeData() { | 565 bool InitDemuxerWithConfigChangeData() { |
| 555 scoped_refptr<DecoderBuffer> bear1 = ReadTestDataFile("bear-320x240.webm"); | 566 scoped_refptr<DecoderBuffer> bear1 = ReadTestDataFile("bear-320x240.webm"); |
| 556 scoped_refptr<DecoderBuffer> bear2 = ReadTestDataFile("bear-640x360.webm"); | 567 scoped_refptr<DecoderBuffer> bear2 = ReadTestDataFile("bear-640x360.webm"); |
| 557 | 568 |
| 558 EXPECT_CALL(*this, DemuxerOpened()); | 569 EXPECT_CALL(*this, DemuxerOpened()); |
| 570 | |
| 571 // TODO(wolenetz/acolwell): Remove this SetDuration expectation once the | |
| 572 // files are fixed to have the correct duration in their init segments. | |
| 573 // See http://crbug.com/354284. | |
| 574 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2744))); | |
|
acolwell GONE FROM CHROMIUM
2014/03/21 15:50:15
What triggers this? Does this need to be here or c
wolenetz
2014/03/21 18:14:01
The file has 2744 encoded in its init segment. Par
| |
| 575 | |
| 559 demuxer_->Initialize( | 576 demuxer_->Initialize( |
| 560 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), | 577 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2768), |
| 561 PIPELINE_OK), true); | 578 PIPELINE_OK), true); |
| 562 | 579 |
| 563 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) | 580 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) |
| 564 return false; | 581 return false; |
| 565 | 582 |
| 566 // Append the whole bear1 file. | 583 // Append the whole bear1 file. |
| 567 AppendData(bear1->data(), bear1->data_size()); | 584 AppendData(bear1->data(), bear1->data_size()); |
| 568 CheckExpectedRanges(kSourceId, "{ [0,2737) }"); | 585 CheckExpectedRanges(kSourceId, "{ [0,2737) }"); |
| 569 | 586 |
| 570 // Append initialization segment for bear2. | 587 // Append initialization segment for bear2. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 if (block_count == 1) { | 645 if (block_count == 1) { |
| 629 cb.AddBlockGroup(kAudioTrackNum, first_audio_timecode, | 646 cb.AddBlockGroup(kAudioTrackNum, first_audio_timecode, |
| 630 kAudioBlockDuration, kWebMFlagKeyframe, | 647 kAudioBlockDuration, kWebMFlagKeyframe, |
| 631 data.get(), size); | 648 data.get(), size); |
| 632 return cb.Finish(); | 649 return cb.Finish(); |
| 633 } | 650 } |
| 634 | 651 |
| 635 int audio_timecode = first_audio_timecode; | 652 int audio_timecode = first_audio_timecode; |
| 636 int video_timecode = first_video_timecode; | 653 int video_timecode = first_video_timecode; |
| 637 | 654 |
| 638 // Create simple blocks for everything except the last 2 blocks. | 655 // Create block groups for everything to ensure parser can emit durations |
| 639 // The first video frame must be a keyframe. | 656 // for every buffer. The first video frame must be a keyframe. |
| 657 // TODO(acolwell): Also use simple blocks once WebM stream parser can emit | |
| 658 // valid frame durations for them. See http://crbug.com/351166. | |
| 640 uint8 video_flag = kWebMFlagKeyframe; | 659 uint8 video_flag = kWebMFlagKeyframe; |
| 641 for (int i = 0; i < block_count - 2; i++) { | 660 for (int i = 0; i < block_count; i++) { |
| 642 if (audio_timecode <= video_timecode) { | 661 if (audio_timecode <= video_timecode) { |
| 643 cb.AddSimpleBlock(kAudioTrackNum, audio_timecode, kWebMFlagKeyframe, | 662 cb.AddBlockGroup(kAudioTrackNum, audio_timecode, kAudioBlockDuration, |
| 644 data.get(), size); | 663 kWebMFlagKeyframe, data.get(), size); |
| 645 audio_timecode += kAudioBlockDuration; | 664 audio_timecode += kAudioBlockDuration; |
| 646 continue; | 665 continue; |
| 647 } | 666 } |
| 648 | 667 |
| 649 cb.AddSimpleBlock(kVideoTrackNum, video_timecode, video_flag, data.get(), | 668 AddVideoBlockGroup(&cb, kVideoTrackNum, video_timecode, |
| 650 size); | 669 kVideoBlockDuration, video_flag); |
| 651 video_timecode += kVideoBlockDuration; | 670 video_timecode += kVideoBlockDuration; |
| 652 video_flag = 0; | 671 video_flag = 0; |
| 653 } | 672 } |
| 654 | 673 |
| 655 // Make the last 2 blocks BlockGroups so that they don't get delayed by the | |
| 656 // block duration calculation logic. | |
| 657 if (audio_timecode <= video_timecode) { | |
| 658 cb.AddBlockGroup(kAudioTrackNum, audio_timecode, kAudioBlockDuration, | |
| 659 kWebMFlagKeyframe, data.get(), size); | |
| 660 AddVideoBlockGroup(&cb, kVideoTrackNum, video_timecode, | |
| 661 kVideoBlockDuration, video_flag); | |
| 662 } else { | |
| 663 AddVideoBlockGroup(&cb, kVideoTrackNum, video_timecode, | |
| 664 kVideoBlockDuration, video_flag); | |
| 665 cb.AddBlockGroup(kAudioTrackNum, audio_timecode, kAudioBlockDuration, | |
| 666 kWebMFlagKeyframe, data.get(), size); | |
| 667 } | |
| 668 | |
| 669 return cb.Finish(); | 674 return cb.Finish(); |
| 670 } | 675 } |
| 671 | 676 |
| 672 scoped_ptr<Cluster> GenerateSingleStreamCluster(int timecode, | 677 scoped_ptr<Cluster> GenerateSingleStreamCluster(int timecode, |
| 673 int end_timecode, | 678 int end_timecode, |
| 674 int track_number, | 679 int track_number, |
| 675 int block_duration) { | 680 int block_duration) { |
| 676 CHECK_GT(end_timecode, timecode); | 681 CHECK_GT(end_timecode, timecode); |
| 677 | 682 |
| 678 std::vector<uint8> data(kBlockSize); | 683 std::vector<uint8> data(kBlockSize); |
| 679 | 684 |
| 680 ClusterBuilder cb; | 685 ClusterBuilder cb; |
| 681 cb.SetClusterTimecode(timecode); | 686 cb.SetClusterTimecode(timecode); |
| 682 | 687 |
| 688 // Create block groups for everything to ensure parser can emit durations | |
| 689 // for every buffer. Sets every frame to be a key frame. | |
| 690 // TODO(acolwell): Also use simple blocks once WebM stream parser can emit | |
| 691 // valid frame durations for them. See http://crbug.com/351166. | |
| 692 | |
| 683 // Create simple blocks for everything except the last block. | 693 // Create simple blocks for everything except the last block. |
| 684 for (int i = 0; timecode < (end_timecode - block_duration); i++) { | 694 for (int i = 0; timecode < end_timecode; i++) { |
| 685 cb.AddSimpleBlock(track_number, timecode, kWebMFlagKeyframe, | 695 if (track_number == kVideoTrackNum) { |
| 686 &data[0], data.size()); | 696 AddVideoBlockGroup(&cb, track_number, timecode, block_duration, |
| 697 kWebMFlagKeyframe); | |
| 698 } else { | |
| 699 cb.AddBlockGroup(track_number, timecode, block_duration, | |
| 700 kWebMFlagKeyframe, &data[0], data.size()); | |
| 701 } | |
| 702 | |
| 687 timecode += block_duration; | 703 timecode += block_duration; |
| 688 } | 704 } |
| 689 | 705 |
| 690 // Make the last block a BlockGroup so that it doesn't get delayed by the | |
| 691 // block duration calculation logic. | |
| 692 if (track_number == kVideoTrackNum) { | |
|
acolwell GONE FROM CHROMIUM
2014/03/21 15:50:15
heh.. this is a left over from my previous attempt
| |
| 693 AddVideoBlockGroup(&cb, track_number, timecode, block_duration, | |
| 694 kWebMFlagKeyframe); | |
| 695 } else { | |
| 696 cb.AddBlockGroup(track_number, timecode, block_duration, | |
| 697 kWebMFlagKeyframe, &data[0], data.size()); | |
| 698 } | |
| 699 return cb.Finish(); | 706 return cb.Finish(); |
| 700 } | 707 } |
| 701 | 708 |
| 702 void Read(DemuxerStream::Type type, const DemuxerStream::ReadCB& read_cb) { | 709 void Read(DemuxerStream::Type type, const DemuxerStream::ReadCB& read_cb) { |
| 703 demuxer_->GetStream(type)->Read(read_cb); | 710 demuxer_->GetStream(type)->Read(read_cb); |
| 704 message_loop_.RunUntilIdle(); | 711 message_loop_.RunUntilIdle(); |
| 705 } | 712 } |
| 706 | 713 |
| 707 void ReadAudio(const DemuxerStream::ReadCB& read_cb) { | 714 void ReadAudio(const DemuxerStream::ReadCB& read_cb) { |
| 708 Read(DemuxerStream::AUDIO, read_cb); | 715 Read(DemuxerStream::AUDIO, read_cb); |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1569 } | 1576 } |
| 1570 | 1577 |
| 1571 // Verify buffered range change behavior for audio/video/text tracks. | 1578 // Verify buffered range change behavior for audio/video/text tracks. |
| 1572 TEST_F(ChunkDemuxerTest, EndOfStreamRangeChanges) { | 1579 TEST_F(ChunkDemuxerTest, EndOfStreamRangeChanges) { |
| 1573 DemuxerStream* text_stream = NULL; | 1580 DemuxerStream* text_stream = NULL; |
| 1574 | 1581 |
| 1575 EXPECT_CALL(host_, AddTextStream(_, _)) | 1582 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 1576 .WillOnce(SaveArg<0>(&text_stream)); | 1583 .WillOnce(SaveArg<0>(&text_stream)); |
| 1577 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 1584 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
| 1578 | 1585 |
| 1579 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 30"); | 1586 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); |
| 1580 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23K"); | 1587 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23K"); |
| 1581 | 1588 |
| 1582 // Check expected ranges and verify that an empty text track does not | 1589 // Check expected ranges and verify that an empty text track does not |
| 1583 // affect the expected ranges. | 1590 // affect the expected ranges. |
| 1584 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 1591 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
| 1585 | 1592 |
| 1586 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(60))); | 1593 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); |
| 1587 MarkEndOfStream(PIPELINE_OK); | 1594 MarkEndOfStream(PIPELINE_OK); |
| 1588 | 1595 |
| 1589 // Check expected ranges and verify that an empty text track does not | 1596 // Check expected ranges and verify that an empty text track does not |
| 1590 // affect the expected ranges. | 1597 // affect the expected ranges. |
| 1591 CheckExpectedRanges(kSourceId, "{ [0,60) }"); | 1598 CheckExpectedRanges(kSourceId, "{ [0,66) }"); |
| 1592 | 1599 |
| 1593 // Unmark end of stream state and verify that the ranges return to | 1600 // Unmark end of stream state and verify that the ranges return to |
| 1594 // their pre-"end of stream" values. | 1601 // their pre-"end of stream" values. |
| 1595 demuxer_->UnmarkEndOfStream(); | 1602 demuxer_->UnmarkEndOfStream(); |
| 1596 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 1603 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
| 1597 | 1604 |
| 1598 // Add text track data and verify that the buffered ranges don't change | 1605 // Add text track data and verify that the buffered ranges don't change |
| 1599 // since the intersection of all the tracks doesn't change. | 1606 // since the intersection of all the tracks doesn't change. |
| 1600 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200))); | 1607 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200))); |
| 1601 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K"); | 1608 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K"); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1643 TEST_F(ChunkDemuxerTest, WebMFile_AudioAndVideo) { | 1650 TEST_F(ChunkDemuxerTest, WebMFile_AudioAndVideo) { |
| 1644 struct BufferTimestamps buffer_timestamps[] = { | 1651 struct BufferTimestamps buffer_timestamps[] = { |
| 1645 {0, 0}, | 1652 {0, 0}, |
| 1646 {33, 3}, | 1653 {33, 3}, |
| 1647 {67, 6}, | 1654 {67, 6}, |
| 1648 {100, 9}, | 1655 {100, 9}, |
| 1649 {133, 12}, | 1656 {133, 12}, |
| 1650 {kSkip, kSkip}, | 1657 {kSkip, kSkip}, |
| 1651 }; | 1658 }; |
| 1652 | 1659 |
| 1660 // TODO(wolenetz/acolwell): Remove this SetDuration expectation once the | |
| 1661 // file is fixed to have the correct duration in the init segment. | |
| 1662 // See http://crbug.com/354284. | |
| 1663 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2744))); | |
| 1664 | |
| 1653 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, | 1665 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, |
| 1654 base::TimeDelta::FromMilliseconds(2744))); | 1666 base::TimeDelta::FromMilliseconds(2768))); |
| 1655 } | 1667 } |
| 1656 | 1668 |
| 1657 TEST_F(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { | 1669 TEST_F(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { |
| 1658 struct BufferTimestamps buffer_timestamps[] = { | 1670 struct BufferTimestamps buffer_timestamps[] = { |
| 1659 {0, 0}, | 1671 {0, 0}, |
| 1660 {33, 3}, | 1672 {33, 3}, |
| 1661 {67, 6}, | 1673 {67, 6}, |
| 1662 {100, 9}, | 1674 {100, 9}, |
| 1663 {133, 12}, | 1675 {133, 12}, |
| 1664 {kSkip, kSkip}, | 1676 {kSkip, kSkip}, |
| 1665 }; | 1677 }; |
| 1666 | 1678 |
| 1667 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, | 1679 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, |
| 1668 kInfiniteDuration())); | 1680 kInfiniteDuration())); |
| 1669 } | 1681 } |
| 1670 | 1682 |
| 1671 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { | 1683 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { |
| 1672 struct BufferTimestamps buffer_timestamps[] = { | 1684 struct BufferTimestamps buffer_timestamps[] = { |
| 1673 {kSkip, 0}, | 1685 {kSkip, 0}, |
| 1674 {kSkip, 3}, | 1686 {kSkip, 3}, |
| 1675 {kSkip, 6}, | 1687 {kSkip, 6}, |
| 1676 {kSkip, 9}, | 1688 {kSkip, 9}, |
| 1677 {kSkip, 12}, | 1689 {kSkip, 12}, |
| 1678 {kSkip, kSkip}, | 1690 {kSkip, kSkip}, |
| 1679 }; | 1691 }; |
| 1680 | 1692 |
| 1693 // TODO(wolenetz/acolwell): Remove this SetDuration expectation once the | |
| 1694 // file is fixed to have the correct duration in the init segment. | |
| 1695 // See http://crbug.com/354284. | |
| 1696 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2744))); | |
| 1697 | |
| 1681 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, | 1698 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, |
| 1682 base::TimeDelta::FromMilliseconds(2744), | 1699 base::TimeDelta::FromMilliseconds(2768), |
| 1683 HAS_AUDIO)); | 1700 HAS_AUDIO)); |
| 1684 } | 1701 } |
| 1685 | 1702 |
| 1686 TEST_F(ChunkDemuxerTest, WebMFile_VideoOnly) { | 1703 TEST_F(ChunkDemuxerTest, WebMFile_VideoOnly) { |
| 1687 struct BufferTimestamps buffer_timestamps[] = { | 1704 struct BufferTimestamps buffer_timestamps[] = { |
| 1688 {0, kSkip}, | 1705 {0, kSkip}, |
| 1689 {33, kSkip}, | 1706 {33, kSkip}, |
| 1690 {67, kSkip}, | 1707 {67, kSkip}, |
| 1691 {100, kSkip}, | 1708 {100, kSkip}, |
| 1692 {133, kSkip}, | 1709 {133, kSkip}, |
| 1693 {kSkip, kSkip}, | 1710 {kSkip, kSkip}, |
| 1694 }; | 1711 }; |
| 1695 | 1712 |
| 1713 // TODO(wolenetz/acolwell): Remove this SetDuration expectation once the | |
| 1714 // file is fixed to have the correct duration in the init segment. | |
| 1715 // See http://crbug.com/354284. | |
| 1716 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2703))); | |
| 1717 | |
| 1696 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, | 1718 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, |
| 1697 base::TimeDelta::FromMilliseconds(2703), | 1719 base::TimeDelta::FromMilliseconds(2737), |
| 1698 HAS_VIDEO)); | 1720 HAS_VIDEO)); |
| 1699 } | 1721 } |
| 1700 | 1722 |
| 1701 TEST_F(ChunkDemuxerTest, WebMFile_AltRefFrames) { | 1723 TEST_F(ChunkDemuxerTest, WebMFile_AltRefFrames) { |
| 1702 struct BufferTimestamps buffer_timestamps[] = { | 1724 struct BufferTimestamps buffer_timestamps[] = { |
| 1703 {0, 0}, | 1725 {0, 0}, |
| 1704 {33, 3}, | 1726 {33, 3}, |
| 1705 {33, 6}, | 1727 {33, 6}, |
| 1706 {67, 9}, | 1728 {67, 9}, |
| 1707 {100, 12}, | 1729 {100, 12}, |
| 1708 {kSkip, kSkip}, | 1730 {kSkip, kSkip}, |
| 1709 }; | 1731 }; |
| 1710 | 1732 |
| 1733 // TODO(wolenetz/acolwell): Remove this SetDuration expectation once the | |
| 1734 // file is fixed to have the correct duration in the init segment. | |
| 1735 // See http://crbug.com/354284. | |
| 1736 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2767))); | |
| 1737 | |
| 1711 ASSERT_TRUE(ParseWebMFile("bear-320x240-altref.webm", buffer_timestamps, | 1738 ASSERT_TRUE(ParseWebMFile("bear-320x240-altref.webm", buffer_timestamps, |
| 1712 base::TimeDelta::FromMilliseconds(2767))); | 1739 base::TimeDelta::FromMilliseconds(2768))); |
| 1713 } | 1740 } |
| 1714 | 1741 |
| 1715 // Verify that we output buffers before the entire cluster has been parsed. | 1742 // Verify that we output buffers before the entire cluster has been parsed. |
| 1716 TEST_F(ChunkDemuxerTest, IncrementalClusterParsing) { | 1743 TEST_F(ChunkDemuxerTest, IncrementalClusterParsing) { |
| 1717 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 1744 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 1718 AppendEmptyCluster(0); | 1745 AppendEmptyCluster(0); |
| 1719 | 1746 |
| 1720 scoped_ptr<Cluster> cluster(GenerateCluster(0, 6)); | 1747 scoped_ptr<Cluster> cluster(GenerateCluster(0, 6)); |
| 1721 | 1748 |
| 1722 bool audio_read_done = false; | 1749 bool audio_read_done = false; |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2716 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2743 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2717 const int kStreamDuration = kDefaultDuration().InMilliseconds(); | 2744 const int kStreamDuration = kDefaultDuration().InMilliseconds(); |
| 2718 | 2745 |
| 2719 // Add data leading up to the currently set duration. | 2746 // Add data leading up to the currently set duration. |
| 2720 AppendCluster(GenerateCluster(kStreamDuration - kAudioBlockDuration, | 2747 AppendCluster(GenerateCluster(kStreamDuration - kAudioBlockDuration, |
| 2721 kStreamDuration - kVideoBlockDuration, | 2748 kStreamDuration - kVideoBlockDuration, |
| 2722 2)); | 2749 2)); |
| 2723 | 2750 |
| 2724 CheckExpectedRanges(kSourceId, "{ [201191,201224) }"); | 2751 CheckExpectedRanges(kSourceId, "{ [201191,201224) }"); |
| 2725 | 2752 |
| 2726 // Add data at the currently set duration. The duration should not increase. | 2753 // Add data beginning at the currently set duration and expect a new duration |
| 2754 // to be signaled. Note that the last video block will have a higher end | |
| 2755 // timestamp than the last audio block. | |
| 2756 // TODO(wolenetz): Compliant coded frame processor will emit a max of one | |
| 2757 // duration change per each ProcessFrames(). Remove the first expectation here | |
| 2758 // once compliant coded frame processor is used. See http://crbug.com/249422. | |
| 2759 const int kNewStreamDurationAudio = kStreamDuration + kAudioBlockDuration; | |
| 2760 EXPECT_CALL(host_, SetDuration( | |
| 2761 base::TimeDelta::FromMilliseconds(kNewStreamDurationAudio))); | |
| 2762 const int kNewStreamDurationVideo = kStreamDuration + kVideoBlockDuration; | |
| 2763 EXPECT_CALL(host_, SetDuration( | |
| 2764 base::TimeDelta::FromMilliseconds(kNewStreamDurationVideo))); | |
| 2727 AppendCluster(GenerateCluster(kDefaultDuration().InMilliseconds(), 2)); | 2765 AppendCluster(GenerateCluster(kDefaultDuration().InMilliseconds(), 2)); |
| 2728 | 2766 |
| 2729 // Range should not be affected. | 2767 CheckExpectedRanges(kSourceId, "{ [201191,201247) }"); |
| 2730 CheckExpectedRanges(kSourceId, "{ [201191,201224) }"); | |
| 2731 | 2768 |
| 2732 // Now add data past the duration and expect a new duration to be signalled. | 2769 // Add more data to the end of each media type. Note that the last audio block |
| 2733 const int kNewStreamDuration = kStreamDuration + kAudioBlockDuration * 2; | 2770 // will have a higher end timestamp than the last video block. |
| 2771 const int kFinalStreamDuration = kStreamDuration + kAudioBlockDuration * 3; | |
| 2734 EXPECT_CALL(host_, SetDuration( | 2772 EXPECT_CALL(host_, SetDuration( |
| 2735 base::TimeDelta::FromMilliseconds(kNewStreamDuration))); | 2773 base::TimeDelta::FromMilliseconds(kFinalStreamDuration))); |
| 2736 AppendCluster(GenerateCluster(kStreamDuration + kAudioBlockDuration, | 2774 AppendCluster(GenerateCluster(kStreamDuration + kAudioBlockDuration, |
| 2737 kStreamDuration + kVideoBlockDuration, | 2775 kStreamDuration + kVideoBlockDuration, |
| 2738 2)); | 2776 3)); |
| 2739 | 2777 |
| 2740 // See that the range has increased appropriately. | 2778 // See that the range has increased appropriately (but not to the full |
| 2741 CheckExpectedRanges(kSourceId, "{ [201191,201270) }"); | 2779 // duration of 201293, since there is not enough video appended for that). |
| 2780 CheckExpectedRanges(kSourceId, "{ [201191,201290) }"); | |
| 2742 } | 2781 } |
| 2743 | 2782 |
| 2744 TEST_F(ChunkDemuxerTest, DurationChangeTimestampOffset) { | 2783 TEST_F(ChunkDemuxerTest, DurationChangeTimestampOffset) { |
| 2745 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2784 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2746 | 2785 |
| 2747 ASSERT_TRUE(SetTimestampOffset(kSourceId, kDefaultDuration())); | 2786 ASSERT_TRUE(SetTimestampOffset(kSourceId, kDefaultDuration())); |
| 2748 | 2787 |
| 2788 // TODO(wolenetz): Compliant coded frame processor will emit a max of one | |
| 2789 // duration change per each ProcessFrames(). Remove the first expectation here | |
| 2790 // once compliant coded frame processor is used. See http://crbug.com/249422. | |
| 2749 EXPECT_CALL(host_, SetDuration( | 2791 EXPECT_CALL(host_, SetDuration( |
| 2750 kDefaultDuration() + base::TimeDelta::FromMilliseconds( | 2792 kDefaultDuration() + base::TimeDelta::FromMilliseconds( |
| 2751 kAudioBlockDuration * 2))); | 2793 kAudioBlockDuration * 2))); |
| 2794 EXPECT_CALL(host_, SetDuration( | |
| 2795 kDefaultDuration() + base::TimeDelta::FromMilliseconds( | |
| 2796 kVideoBlockDuration * 2))); | |
| 2752 AppendCluster(GenerateCluster(0, 4)); | 2797 AppendCluster(GenerateCluster(0, 4)); |
| 2753 } | 2798 } |
| 2754 | 2799 |
| 2755 TEST_F(ChunkDemuxerTest, EndOfStreamTruncateDuration) { | 2800 TEST_F(ChunkDemuxerTest, EndOfStreamTruncateDuration) { |
| 2756 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2801 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2757 | 2802 |
| 2758 AppendCluster(kDefaultFirstCluster()); | 2803 AppendCluster(kDefaultFirstCluster()); |
| 2759 | 2804 |
| 2760 EXPECT_CALL(host_, SetDuration( | 2805 EXPECT_CALL(host_, SetDuration( |
| 2761 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); | 2806 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2806 | 2851 |
| 2807 // Normally this would return an audio buffer at timestamp zero, but | 2852 // Normally this would return an audio buffer at timestamp zero, but |
| 2808 // all reads should return EOS buffers when disabled. | 2853 // all reads should return EOS buffers when disabled. |
| 2809 bool audio_read_done = false; | 2854 bool audio_read_done = false; |
| 2810 stream->Read(base::Bind(&OnReadDone_EOSExpected, &audio_read_done)); | 2855 stream->Read(base::Bind(&OnReadDone_EOSExpected, &audio_read_done)); |
| 2811 message_loop_.RunUntilIdle(); | 2856 message_loop_.RunUntilIdle(); |
| 2812 | 2857 |
| 2813 EXPECT_TRUE(audio_read_done); | 2858 EXPECT_TRUE(audio_read_done); |
| 2814 } | 2859 } |
| 2815 | 2860 |
| 2816 // Verifies that signalling end of stream while stalled at a gap | 2861 // Verifies that signaling end of stream while stalled at a gap |
| 2817 // boundary does not trigger end of stream buffers to be returned. | 2862 // boundary does not trigger end of stream buffers to be returned. |
| 2818 TEST_F(ChunkDemuxerTest, EndOfStreamWhileWaitingForGapToBeFilled) { | 2863 TEST_F(ChunkDemuxerTest, EndOfStreamWhileWaitingForGapToBeFilled) { |
| 2819 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2864 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2820 | 2865 |
| 2821 AppendCluster(0, 10); | 2866 AppendCluster(0, 10); |
| 2822 AppendCluster(300, 10); | 2867 AppendCluster(300, 10); |
| 2823 CheckExpectedRanges(kSourceId, "{ [0,132) [300,432) }"); | 2868 CheckExpectedRanges(kSourceId, "{ [0,132) [300,432) }"); |
| 2824 | 2869 |
| 2825 | |
| 2826 GenerateExpectedReads(0, 10); | 2870 GenerateExpectedReads(0, 10); |
| 2827 | 2871 |
| 2828 bool audio_read_done = false; | 2872 bool audio_read_done = false; |
| 2829 bool video_read_done = false; | 2873 bool video_read_done = false; |
| 2830 ReadAudio(base::Bind(&OnReadDone, | 2874 ReadAudio(base::Bind(&OnReadDone, |
| 2831 base::TimeDelta::FromMilliseconds(138), | 2875 base::TimeDelta::FromMilliseconds(138), |
| 2832 &audio_read_done)); | 2876 &audio_read_done)); |
| 2833 ReadVideo(base::Bind(&OnReadDone, | 2877 ReadVideo(base::Bind(&OnReadDone, |
| 2834 base::TimeDelta::FromMilliseconds(138), | 2878 base::TimeDelta::FromMilliseconds(138), |
| 2835 &video_read_done)); | 2879 &video_read_done)); |
| 2836 | 2880 |
| 2837 // Verify that the reads didn't complete | 2881 // Verify that the reads didn't complete |
| 2838 EXPECT_FALSE(audio_read_done); | 2882 EXPECT_FALSE(audio_read_done); |
| 2839 EXPECT_FALSE(video_read_done); | 2883 EXPECT_FALSE(video_read_done); |
| 2840 | 2884 |
| 2841 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(438))); | 2885 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(438))); |
| 2842 MarkEndOfStream(PIPELINE_OK); | 2886 MarkEndOfStream(PIPELINE_OK); |
| 2843 | 2887 |
| 2844 // Verify that the reads still haven't completed. | 2888 // Verify that the reads still haven't completed. |
| 2845 EXPECT_FALSE(audio_read_done); | 2889 EXPECT_FALSE(audio_read_done); |
| 2846 EXPECT_FALSE(video_read_done); | 2890 EXPECT_FALSE(video_read_done); |
| 2847 | 2891 |
| 2848 demuxer_->UnmarkEndOfStream(); | 2892 demuxer_->UnmarkEndOfStream(); |
| 2849 | 2893 |
| 2850 AppendCluster(138, 24); | 2894 AppendCluster(138, 22); |
| 2851 | 2895 |
| 2852 message_loop_.RunUntilIdle(); | 2896 message_loop_.RunUntilIdle(); |
| 2853 | 2897 |
| 2854 CheckExpectedRanges(kSourceId, "{ [0,438) }"); | 2898 CheckExpectedRanges(kSourceId, "{ [0,435) }"); |
| 2855 | 2899 |
| 2856 // Verify that the reads have completed. | 2900 // Verify that the reads have completed. |
| 2857 EXPECT_TRUE(audio_read_done); | 2901 EXPECT_TRUE(audio_read_done); |
| 2858 EXPECT_TRUE(video_read_done); | 2902 EXPECT_TRUE(video_read_done); |
| 2859 | 2903 |
| 2860 // Read the rest of the buffers. | 2904 // Read the rest of the buffers. |
| 2861 GenerateExpectedReads(161, 171, 22); | 2905 GenerateExpectedReads(161, 171, 20); |
| 2862 | 2906 |
| 2863 // Verify that reads block because the append cleared the end of stream state. | 2907 // Verify that reads block because the append cleared the end of stream state. |
| 2864 audio_read_done = false; | 2908 audio_read_done = false; |
| 2865 video_read_done = false; | 2909 video_read_done = false; |
| 2866 ReadAudio(base::Bind(&OnReadDone_EOSExpected, | 2910 ReadAudio(base::Bind(&OnReadDone_EOSExpected, |
| 2867 &audio_read_done)); | 2911 &audio_read_done)); |
| 2868 ReadVideo(base::Bind(&OnReadDone_EOSExpected, | 2912 ReadVideo(base::Bind(&OnReadDone_EOSExpected, |
| 2869 &video_read_done)); | 2913 &video_read_done)); |
| 2870 | 2914 |
| 2871 // Verify that the reads don't complete. | 2915 // Verify that the reads don't complete. |
| 2872 EXPECT_FALSE(audio_read_done); | 2916 EXPECT_FALSE(audio_read_done); |
| 2873 EXPECT_FALSE(video_read_done); | 2917 EXPECT_FALSE(video_read_done); |
| 2874 | 2918 |
| 2919 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(437))); | |
| 2875 MarkEndOfStream(PIPELINE_OK); | 2920 MarkEndOfStream(PIPELINE_OK); |
| 2876 | 2921 |
| 2877 EXPECT_TRUE(audio_read_done); | 2922 EXPECT_TRUE(audio_read_done); |
| 2878 EXPECT_TRUE(video_read_done); | 2923 EXPECT_TRUE(video_read_done); |
| 2879 } | 2924 } |
| 2880 | 2925 |
| 2881 TEST_F(ChunkDemuxerTest, CanceledSeekDuringInitialPreroll) { | 2926 TEST_F(ChunkDemuxerTest, CanceledSeekDuringInitialPreroll) { |
| 2882 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2927 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2883 | 2928 |
| 2884 // Cancel preroll. | 2929 // Cancel preroll. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2953 // Set the append window to [20,280). | 2998 // Set the append window to [20,280). |
| 2954 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); | 2999 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
| 2955 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3000 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
| 2956 | 3001 |
| 2957 // Append a cluster that starts before and ends after the append window. | 3002 // Append a cluster that starts before and ends after the append window. |
| 2958 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3003 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
| 2959 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"); | 3004 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"); |
| 2960 | 3005 |
| 2961 // Verify that GOPs that start outside the window are not included | 3006 // Verify that GOPs that start outside the window are not included |
| 2962 // in the buffer. Also verify that buffers that start inside the | 3007 // in the buffer. Also verify that buffers that start inside the |
| 2963 // window and extend beyond the end of the window are included. | 3008 // window and extend beyond the end of the window are not included. |
| 2964 CheckExpectedRanges(kSourceId, "{ [120,300) }"); | 3009 CheckExpectedRanges(kSourceId, "{ [120,273) }"); |
| 2965 CheckExpectedBuffers(stream, "120 150 180 210 240 270"); | 3010 CheckExpectedBuffers(stream, "120 150 180 210 240"); |
| 2966 | 3011 |
| 2967 // Extend the append window to [20,650). | 3012 // Extend the append window to [20,650). |
| 2968 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); | 3013 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
| 2969 | 3014 |
| 2970 // Append more data and verify that adding buffers start at the next | 3015 // Append more data and verify that adding buffers start at the next |
| 2971 // keyframe. | 3016 // keyframe. |
| 2972 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3017 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
| 2973 "360 390 420K 450 480 510 540K 570 600 630K"); | 3018 "360 390 420K 450 480 510 540K 570 600 630K"); |
| 2974 CheckExpectedRanges(kSourceId, "{ [120,300) [420,660) }"); | 3019 CheckExpectedRanges(kSourceId, "{ [120,273) [420,633) }"); |
| 2975 } | 3020 } |
| 2976 | 3021 |
| 2977 TEST_F(ChunkDemuxerTest, AppendWindow_Audio) { | 3022 TEST_F(ChunkDemuxerTest, AppendWindow_Audio) { |
| 2978 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); | 3023 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
| 2979 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3024 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 2980 | 3025 |
| 2981 // Set the append window to [20,280). | 3026 // Set the append window to [20,280). |
| 2982 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); | 3027 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
| 2983 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3028 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
| 2984 | 3029 |
| 2985 // Append a cluster that starts before and ends after the append window. | 3030 // Append a cluster that starts before and ends after the append window. |
| 2986 AppendSingleStreamCluster( | 3031 AppendSingleStreamCluster( |
| 2987 kSourceId, kAudioTrackNum, | 3032 kSourceId, kAudioTrackNum, |
| 2988 "0K 30K 60K 90K 120K 150K 180K 210K 240K 270K 300K 330K"); | 3033 "0K 30K 60K 90K 120K 150K 180K 210K 240K 270K 300K 330K"); |
| 2989 | 3034 |
| 2990 // Verify that frames that start outside the window are not included | 3035 // Verify that frames that start outside the window are not included |
| 2991 // in the buffer. Also verify that buffers that start inside the | 3036 // in the buffer. Also verify that buffers that start inside the |
| 2992 // window and extend beyond the end of the window are included. | 3037 // window and extend beyond the end of the window are not included. |
|
acolwell GONE FROM CHROMIUM
2014/03/21 15:50:15
Why did this change? Is this an artifact of suppor
wolenetz
2014/03/21 18:14:01
Yes. I included that step's support in this change
| |
| 2993 CheckExpectedRanges(kSourceId, "{ [30,300) }"); | 3038 CheckExpectedRanges(kSourceId, "{ [30,263) }"); |
| 2994 CheckExpectedBuffers(stream, "30 60 90 120 150 180 210 240 270"); | 3039 CheckExpectedBuffers(stream, "30 60 90 120 150 180 210 240"); |
| 2995 | 3040 |
| 2996 // Extend the append window to [20,650). | 3041 // Extend the append window to [20,650). |
| 2997 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); | 3042 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
| 2998 | 3043 |
| 2999 // Append more data and verify that a new range is created. | 3044 // Append more data and verify that a new range is created. |
| 3000 AppendSingleStreamCluster( | 3045 AppendSingleStreamCluster( |
| 3001 kSourceId, kAudioTrackNum, | 3046 kSourceId, kAudioTrackNum, |
| 3002 "360K 390K 420K 450K 480K 510K 540K 570K 600K 630K"); | 3047 "360K 390K 420K 450K 480K 510K 540K 570K 600K 630K"); |
| 3003 CheckExpectedRanges(kSourceId, "{ [30,300) [360,660) }"); | 3048 CheckExpectedRanges(kSourceId, "{ [30,263) [360,623) }"); |
| 3004 } | 3049 } |
| 3005 | 3050 |
| 3006 TEST_F(ChunkDemuxerTest, AppendWindow_Text) { | 3051 TEST_F(ChunkDemuxerTest, AppendWindow_Text) { |
| 3007 DemuxerStream* text_stream = NULL; | 3052 DemuxerStream* text_stream = NULL; |
| 3008 EXPECT_CALL(host_, AddTextStream(_, _)) | 3053 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 3009 .WillOnce(SaveArg<0>(&text_stream)); | 3054 .WillOnce(SaveArg<0>(&text_stream)); |
| 3010 ASSERT_TRUE(InitDemuxer(HAS_VIDEO | HAS_TEXT)); | 3055 ASSERT_TRUE(InitDemuxer(HAS_VIDEO | HAS_TEXT)); |
| 3011 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3056 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 3012 | 3057 |
| 3013 // Set the append window to [20,280). | 3058 // Set the append window to [20,280). |
| 3014 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); | 3059 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
| 3015 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3060 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
| 3016 | 3061 |
| 3017 // Append a cluster that starts before and ends after the append | 3062 // Append a cluster that starts before and ends after the append |
| 3018 // window. | 3063 // window. |
| 3019 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3064 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
| 3020 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"); | 3065 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"); |
| 3021 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K 200K 300K"); | 3066 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K 200K 300K"); |
| 3022 | 3067 |
| 3023 // Verify that text cues that start outside the window are not included | 3068 // Verify that text cues that start outside the window are not included |
| 3024 // in the buffer. Also verify that cues that extend beyond the | 3069 // in the buffer. Also verify that cues that extend beyond the |
| 3025 // window are included. | 3070 // window are not included. |
| 3026 CheckExpectedRanges(kSourceId, "{ [120,300) }"); | 3071 CheckExpectedRanges(kSourceId, "{ [120,273) }"); |
| 3027 CheckExpectedBuffers(video_stream, "120 150 180 210 240 270"); | 3072 CheckExpectedBuffers(video_stream, "120 150 180 210 240"); |
| 3028 CheckExpectedBuffers(text_stream, "100 200"); | 3073 CheckExpectedBuffers(text_stream, "100"); |
| 3029 | 3074 |
| 3030 // Extend the append window to [20,650). | 3075 // Extend the append window to [20,650). |
| 3031 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); | 3076 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
| 3032 | 3077 |
| 3033 // Append more data and verify that a new range is created. | 3078 // Append more data and verify that a new range is created. |
| 3034 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3079 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
| 3035 "360 390 420K 450 480 510 540K 570 600 630K"); | 3080 "360 390 420K 450 480 510 540K 570 600 630K"); |
| 3036 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "400K 500K 600K 700K"); | 3081 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "400K 500K 600K 700K"); |
| 3037 CheckExpectedRanges(kSourceId, "{ [120,300) [420,660) }"); | 3082 CheckExpectedRanges(kSourceId, "{ [120,273) [420,633) }"); |
| 3038 | 3083 |
| 3039 // Seek to the new range and verify that the expected buffers are returned. | 3084 // Seek to the new range and verify that the expected buffers are returned. |
| 3040 Seek(base::TimeDelta::FromMilliseconds(420)); | 3085 Seek(base::TimeDelta::FromMilliseconds(420)); |
| 3041 CheckExpectedBuffers(video_stream, "420 450 480 510 540 570 600 630"); | 3086 CheckExpectedBuffers(video_stream, "420 450 480 510 540 570 600"); |
| 3042 CheckExpectedBuffers(text_stream, "400 500 600"); | 3087 CheckExpectedBuffers(text_stream, "400 500"); |
| 3043 } | 3088 } |
| 3044 | 3089 |
| 3045 TEST_F(ChunkDemuxerTest, StartWaitingForSeekAfterParseError) { | 3090 TEST_F(ChunkDemuxerTest, StartWaitingForSeekAfterParseError) { |
| 3046 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 3091 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 3047 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 3092 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
| 3048 AppendGarbage(); | 3093 AppendGarbage(); |
| 3049 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(50); | 3094 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(50); |
| 3050 demuxer_->StartWaitingForSeek(seek_time); | 3095 demuxer_->StartWaitingForSeek(seek_time); |
| 3051 } | 3096 } |
| 3052 | 3097 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3113 | 3158 |
| 3114 bool text_read_done = false; | 3159 bool text_read_done = false; |
| 3115 text_stream->Read(base::Bind(&OnReadDone, | 3160 text_stream->Read(base::Bind(&OnReadDone, |
| 3116 base::TimeDelta::FromMilliseconds(125), | 3161 base::TimeDelta::FromMilliseconds(125), |
| 3117 &text_read_done)); | 3162 &text_read_done)); |
| 3118 | 3163 |
| 3119 // Append audio & video data so the seek completes. | 3164 // Append audio & video data so the seek completes. |
| 3120 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, | 3165 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, |
| 3121 "0K 20K 40K 60K 80K 100K 120K 140K 160K 180K"); | 3166 "0K 20K 40K 60K 80K 100K 120K 140K 160K 180K"); |
| 3122 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3167 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, |
| 3123 "0K 30 60 90 120K 150 180 210"); | 3168 "0K 30 60 90K 120K 150 180 210"); |
| 3124 | 3169 |
| 3125 message_loop_.RunUntilIdle(); | 3170 message_loop_.RunUntilIdle(); |
| 3126 EXPECT_TRUE(seek_cb_was_called); | 3171 EXPECT_TRUE(seek_cb_was_called); |
| 3127 EXPECT_FALSE(text_read_done); | 3172 EXPECT_FALSE(text_read_done); |
| 3128 | 3173 |
| 3129 // Read some audio & video buffers to further verify seek completion. | 3174 // Read some audio & video buffers to further verify seek completion. |
| 3130 CheckExpectedBuffers(audio_stream, "120 140"); | 3175 CheckExpectedBuffers(audio_stream, "120 140"); |
| 3131 CheckExpectedBuffers(video_stream, "120 150"); | 3176 CheckExpectedBuffers(video_stream, "120 150"); |
| 3132 | 3177 |
| 3133 EXPECT_FALSE(text_read_done); | 3178 EXPECT_FALSE(text_read_done); |
| 3134 | 3179 |
| 3135 // Append text cues that start after the seek point and verify that | 3180 // Append text cues that start after the seek point and verify that |
| 3136 // they are returned by Read() calls. | 3181 // they are returned by Read() calls. |
| 3137 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "125K 175K 225K"); | 3182 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "125K 175K 225K"); |
| 3138 | 3183 |
| 3139 message_loop_.RunUntilIdle(); | 3184 message_loop_.RunUntilIdle(); |
| 3140 EXPECT_TRUE(text_read_done); | 3185 EXPECT_TRUE(text_read_done); |
| 3141 | 3186 |
| 3142 // NOTE: we start at 175 here because the buffer at 125 was returned | 3187 // NOTE: we start at 175 here because the buffer at 125 was returned |
| 3143 // to the pending read initiated above. | 3188 // to the pending read initiated above. |
| 3144 CheckExpectedBuffers(text_stream, "175 225"); | 3189 CheckExpectedBuffers(text_stream, "175 225"); |
| 3145 | 3190 |
| 3146 // Verify that audio & video streams contiue to return expected values. | 3191 // Verify that audio & video streams continue to return expected values. |
| 3147 CheckExpectedBuffers(audio_stream, "160 180"); | 3192 CheckExpectedBuffers(audio_stream, "160 180"); |
| 3148 CheckExpectedBuffers(video_stream, "180 210"); | 3193 CheckExpectedBuffers(video_stream, "180 210"); |
| 3149 } | 3194 } |
| 3150 | 3195 |
| 3151 } // namespace media | 3196 } // namespace media |
| OLD | NEW |