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_tracks.h" |
21 #include "media/base/mock_demuxer_host.h" | 22 #include "media/base/mock_demuxer_host.h" |
22 #include "media/base/mock_media_log.h" | 23 #include "media/base/mock_media_log.h" |
23 #include "media/base/test_data_util.h" | 24 #include "media/base/test_data_util.h" |
24 #include "media/base/test_helpers.h" | 25 #include "media/base/test_helpers.h" |
25 #include "media/base/timestamp_constants.h" | 26 #include "media/base/timestamp_constants.h" |
26 #include "media/formats/webm/cluster_builder.h" | 27 #include "media/formats/webm/cluster_builder.h" |
27 #include "media/formats/webm/webm_cluster_parser.h" | 28 #include "media/formats/webm/webm_cluster_parser.h" |
28 #include "media/formats/webm/webm_constants.h" | 29 #include "media/formats/webm/webm_constants.h" |
29 #include "media/media_features.h" | 30 #include "media/media_features.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 arraysize(kEncryptedMediaInitData)))) | 835 arraysize(kEncryptedMediaInitData)))) |
835 .Times(Exactly(need_key_count)); | 836 .Times(Exactly(need_key_count)); |
836 } | 837 } |
837 | 838 |
838 // Adding expectations prior to CreateInitDoneCB() here because InSequence | 839 // Adding expectations prior to CreateInitDoneCB() here because InSequence |
839 // tests require init segment received before duration set. Also, only | 840 // tests require init segment received before duration set. Also, only |
840 // expect an init segment received callback if there is actually a track in | 841 // expect an init segment received callback if there is actually a track in |
841 // it. | 842 // it. |
842 if (stream_flags != 0) { | 843 if (stream_flags != 0) { |
843 ExpectInitMediaLogs(stream_flags); | 844 ExpectInitMediaLogs(stream_flags); |
844 EXPECT_CALL(*this, InitSegmentReceived()); | 845 EXPECT_CALL(*this, InitSegmentReceived(_)); |
845 } else { | 846 } else { |
846 // OnNewConfigs() requires at least one audio, video, or text track. | 847 // OnNewConfigs() requires at least one audio, video, or text track. |
847 EXPECT_MEDIA_LOG(StreamParsingFailed()); | 848 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
848 } | 849 } |
849 | 850 |
850 demuxer_->Initialize( | 851 demuxer_->Initialize( |
851 &host_, CreateInitDoneCB(expected_duration, expected_status), true); | 852 &host_, CreateInitDoneCB(expected_duration, expected_status), true); |
852 | 853 |
853 if (AddId(kSourceId, stream_flags) != ChunkDemuxer::kOk) | 854 if (AddId(kSourceId, stream_flags) != ChunkDemuxer::kOk) |
854 return false; | 855 return false; |
(...skipping 21 matching lines...) Expand all Loading... |
876 | 877 |
877 if (has_text) { | 878 if (has_text) { |
878 audio_flags |= HAS_TEXT; | 879 audio_flags |= HAS_TEXT; |
879 video_flags |= HAS_TEXT; | 880 video_flags |= HAS_TEXT; |
880 } | 881 } |
881 | 882 |
882 // Note: Unlike InitDemuxerWithEncryptionInfo, this method is currently | 883 // Note: Unlike InitDemuxerWithEncryptionInfo, this method is currently |
883 // incompatible with InSequence tests. Refactoring of the duration | 884 // incompatible with InSequence tests. Refactoring of the duration |
884 // set expectation to not be added during CreateInitDoneCB() could fix this. | 885 // set expectation to not be added during CreateInitDoneCB() could fix this. |
885 ExpectInitMediaLogs(audio_flags); | 886 ExpectInitMediaLogs(audio_flags); |
886 EXPECT_CALL(*this, InitSegmentReceived()); | 887 EXPECT_CALL(*this, InitSegmentReceived(_)); |
887 AppendInitSegmentWithSourceId(audio_id, audio_flags); | 888 AppendInitSegmentWithSourceId(audio_id, audio_flags); |
888 | 889 |
889 ExpectInitMediaLogs(video_flags); | 890 ExpectInitMediaLogs(video_flags); |
890 EXPECT_CALL(*this, InitSegmentReceived()); | 891 EXPECT_CALL(*this, InitSegmentReceived(_)); |
891 AppendInitSegmentWithSourceId(video_id, video_flags); | 892 AppendInitSegmentWithSourceId(video_id, video_flags); |
892 return true; | 893 return true; |
893 } | 894 } |
894 | 895 |
895 bool InitDemuxerAudioAndVideoSources(const std::string& audio_id, | 896 bool InitDemuxerAudioAndVideoSources(const std::string& audio_id, |
896 const std::string& video_id) { | 897 const std::string& video_id) { |
897 return InitDemuxerAudioAndVideoSourcesText(audio_id, video_id, false); | 898 return InitDemuxerAudioAndVideoSourcesText(audio_id, video_id, false); |
898 } | 899 } |
899 | 900 |
900 // Initializes the demuxer with data from 2 files with different | 901 // Initializes the demuxer with data from 2 files with different |
(...skipping 15 matching lines...) Expand all Loading... |
916 // bear-640x360.webm : [527-759) | 917 // bear-640x360.webm : [527-759) |
917 bool InitDemuxerWithConfigChangeData() { | 918 bool InitDemuxerWithConfigChangeData() { |
918 scoped_refptr<DecoderBuffer> bear1 = ReadTestDataFile("bear-320x240.webm"); | 919 scoped_refptr<DecoderBuffer> bear1 = ReadTestDataFile("bear-320x240.webm"); |
919 scoped_refptr<DecoderBuffer> bear2 = ReadTestDataFile("bear-640x360.webm"); | 920 scoped_refptr<DecoderBuffer> bear2 = ReadTestDataFile("bear-640x360.webm"); |
920 | 921 |
921 EXPECT_CALL(*this, DemuxerOpened()); | 922 EXPECT_CALL(*this, DemuxerOpened()); |
922 | 923 |
923 // Adding expectation prior to CreateInitDoneCB() here because InSequence | 924 // Adding expectation prior to CreateInitDoneCB() here because InSequence |
924 // tests require init segment received before duration set. | 925 // tests require init segment received before duration set. |
925 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); | 926 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); |
926 EXPECT_CALL(*this, InitSegmentReceived()); | 927 EXPECT_CALL(*this, InitSegmentReceived(_)); |
927 demuxer_->Initialize( | 928 demuxer_->Initialize( |
928 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), | 929 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), |
929 PIPELINE_OK), true); | 930 PIPELINE_OK), true); |
930 | 931 |
931 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) | 932 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) |
932 return false; | 933 return false; |
933 | 934 |
934 // Append the whole bear1 file. | 935 // Append the whole bear1 file. |
935 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)).Times(7); | 936 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)).Times(7); |
936 // Expect duration adjustment since actual duration differs slightly from | 937 // Expect duration adjustment since actual duration differs slightly from |
937 // duration in the init segment. | 938 // duration in the init segment. |
938 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 939 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
939 AppendData(bear1->data(), bear1->data_size()); | 940 AppendData(bear1->data(), bear1->data_size()); |
940 // Last audio frame has timestamp 2721 and duration 24 (estimated from max | 941 // Last audio frame has timestamp 2721 and duration 24 (estimated from max |
941 // seen so far for audio track). | 942 // seen so far for audio track). |
942 // Last video frame has timestamp 2703 and duration 33 (from TrackEntry | 943 // Last video frame has timestamp 2703 and duration 33 (from TrackEntry |
943 // DefaultDuration for video track). | 944 // DefaultDuration for video track). |
944 CheckExpectedRanges("{ [0,2736) }"); | 945 CheckExpectedRanges("{ [0,2736) }"); |
945 | 946 |
946 // Append initialization segment for bear2. | 947 // Append initialization segment for bear2. |
947 // Note: Offsets here and below are derived from | 948 // Note: Offsets here and below are derived from |
948 // media/test/data/bear-640x360-manifest.js and | 949 // media/test/data/bear-640x360-manifest.js and |
949 // media/test/data/bear-320x240-manifest.js which were | 950 // media/test/data/bear-320x240-manifest.js which were |
950 // generated from media/test/data/bear-640x360.webm and | 951 // generated from media/test/data/bear-640x360.webm and |
951 // media/test/data/bear-320x240.webm respectively. | 952 // media/test/data/bear-320x240.webm respectively. |
952 EXPECT_CALL(*this, InitSegmentReceived()); | 953 EXPECT_CALL(*this, InitSegmentReceived(_)); |
953 AppendData(bear2->data(), 4340); | 954 AppendData(bear2->data(), 4340); |
954 | 955 |
955 // Append a media segment that goes from [0.527000, 1.014000). | 956 // Append a media segment that goes from [0.527000, 1.014000). |
956 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); | 957 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); |
957 EXPECT_MEDIA_LOG(GeneratedSplice(20000, 527000)); | 958 EXPECT_MEDIA_LOG(GeneratedSplice(20000, 527000)); |
958 AppendData(bear2->data() + 55290, 18785); | 959 AppendData(bear2->data() + 55290, 18785); |
959 CheckExpectedRanges("{ [0,1027) [1201,2736) }"); | 960 CheckExpectedRanges("{ [0,1027) [1201,2736) }"); |
960 | 961 |
961 // Append initialization segment for bear1 & fill gap with [779-1197) | 962 // Append initialization segment for bear1 & fill gap with [779-1197) |
962 // segment. | 963 // segment. |
963 EXPECT_CALL(*this, InitSegmentReceived()); | 964 EXPECT_CALL(*this, InitSegmentReceived(_)); |
964 AppendData(bear1->data(), 4370); | 965 AppendData(bear1->data(), 4370); |
965 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)); | 966 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)); |
966 EXPECT_MEDIA_LOG(GeneratedSplice(26000, 779000)); | 967 EXPECT_MEDIA_LOG(GeneratedSplice(26000, 779000)); |
967 AppendData(bear1->data() + 72737, 28183); | 968 AppendData(bear1->data() + 72737, 28183); |
968 CheckExpectedRanges("{ [0,2736) }"); | 969 CheckExpectedRanges("{ [0,2736) }"); |
969 | 970 |
970 MarkEndOfStream(PIPELINE_OK); | 971 MarkEndOfStream(PIPELINE_OK); |
971 return true; | 972 return true; |
972 } | 973 } |
973 | 974 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 int stream_flags) { | 1302 int stream_flags) { |
1302 EXPECT_CALL(*this, DemuxerOpened()); | 1303 EXPECT_CALL(*this, DemuxerOpened()); |
1303 demuxer_->Initialize( | 1304 demuxer_->Initialize( |
1304 &host_, CreateInitDoneCB(duration, PIPELINE_OK), true); | 1305 &host_, CreateInitDoneCB(duration, PIPELINE_OK), true); |
1305 | 1306 |
1306 if (AddId(kSourceId, stream_flags) != ChunkDemuxer::kOk) | 1307 if (AddId(kSourceId, stream_flags) != ChunkDemuxer::kOk) |
1307 return false; | 1308 return false; |
1308 | 1309 |
1309 // Read a WebM file into memory and send the data to the demuxer. | 1310 // Read a WebM file into memory and send the data to the demuxer. |
1310 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename); | 1311 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename); |
1311 EXPECT_CALL(*this, InitSegmentReceived()); | 1312 EXPECT_CALL(*this, InitSegmentReceived(_)); |
1312 AppendDataInPieces(buffer->data(), buffer->data_size(), 512); | 1313 AppendDataInPieces(buffer->data(), buffer->data_size(), 512); |
1313 | 1314 |
1314 // Verify that the timestamps on the first few packets match what we | 1315 // Verify that the timestamps on the first few packets match what we |
1315 // expect. | 1316 // expect. |
1316 for (size_t i = 0; | 1317 for (size_t i = 0; |
1317 (timestamps[i].audio_time_ms != kSkip || | 1318 (timestamps[i].audio_time_ms != kSkip || |
1318 timestamps[i].video_time_ms != kSkip); | 1319 timestamps[i].video_time_ms != kSkip); |
1319 i++) { | 1320 i++) { |
1320 bool audio_read_done = false; | 1321 bool audio_read_done = false; |
1321 bool video_read_done = false; | 1322 bool video_read_done = false; |
(...skipping 16 matching lines...) Expand all Loading... |
1338 } | 1339 } |
1339 | 1340 |
1340 return true; | 1341 return true; |
1341 } | 1342 } |
1342 | 1343 |
1343 MOCK_METHOD0(DemuxerOpened, void()); | 1344 MOCK_METHOD0(DemuxerOpened, void()); |
1344 MOCK_METHOD2(OnEncryptedMediaInitData, | 1345 MOCK_METHOD2(OnEncryptedMediaInitData, |
1345 void(EmeInitDataType init_data_type, | 1346 void(EmeInitDataType init_data_type, |
1346 const std::vector<uint8_t>& init_data)); | 1347 const std::vector<uint8_t>& init_data)); |
1347 | 1348 |
1348 MOCK_METHOD0(InitSegmentReceived, void(void)); | 1349 MOCK_METHOD1(InitSegmentReceived, void(const MediaTracks&)); |
1349 | 1350 |
1350 void Seek(base::TimeDelta seek_time) { | 1351 void Seek(base::TimeDelta seek_time) { |
1351 demuxer_->StartWaitingForSeek(seek_time); | 1352 demuxer_->StartWaitingForSeek(seek_time); |
1352 demuxer_->Seek(seek_time, NewExpectedStatusCB(PIPELINE_OK)); | 1353 demuxer_->Seek(seek_time, NewExpectedStatusCB(PIPELINE_OK)); |
1353 message_loop_.RunUntilIdle(); | 1354 message_loop_.RunUntilIdle(); |
1354 } | 1355 } |
1355 | 1356 |
1356 void MarkEndOfStream(PipelineStatus status) { | 1357 void MarkEndOfStream(PipelineStatus status) { |
1357 demuxer_->MarkEndOfStream(status); | 1358 demuxer_->MarkEndOfStream(status); |
1358 message_loop_.RunUntilIdle(); | 1359 message_loop_.RunUntilIdle(); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), | 1541 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "0K 23K", 23), |
1541 MuxedStreamInfo(kVideoTrackNum, "0K 30", 30), | 1542 MuxedStreamInfo(kVideoTrackNum, "0K 30", 30), |
1542 MuxedStreamInfo(kTextTrackNum, "10K")); | 1543 MuxedStreamInfo(kTextTrackNum, "10K")); |
1543 CheckExpectedRanges("{ [0,46) }"); | 1544 CheckExpectedRanges("{ [0,46) }"); |
1544 | 1545 |
1545 scoped_ptr<uint8_t[]> info_tracks; | 1546 scoped_ptr<uint8_t[]> info_tracks; |
1546 int info_tracks_size = 0; | 1547 int info_tracks_size = 0; |
1547 CreateInitSegmentWithAlternateTextTrackNum(HAS_TEXT | HAS_AUDIO | HAS_VIDEO, | 1548 CreateInitSegmentWithAlternateTextTrackNum(HAS_TEXT | HAS_AUDIO | HAS_VIDEO, |
1548 false, false, | 1549 false, false, |
1549 &info_tracks, &info_tracks_size); | 1550 &info_tracks, &info_tracks_size); |
1550 EXPECT_CALL(*this, InitSegmentReceived()); | 1551 EXPECT_CALL(*this, InitSegmentReceived(_)); |
1551 demuxer_->AppendData(kSourceId, info_tracks.get(), info_tracks_size, | 1552 demuxer_->AppendData(kSourceId, info_tracks.get(), info_tracks_size, |
1552 append_window_start_for_next_append_, | 1553 append_window_start_for_next_append_, |
1553 append_window_end_for_next_append_, | 1554 append_window_end_for_next_append_, |
1554 ×tamp_offset_map_[kSourceId], | 1555 ×tamp_offset_map_[kSourceId], |
1555 init_segment_received_cb_); | 1556 init_segment_received_cb_); |
1556 | 1557 |
1557 AppendMuxedCluster( | 1558 AppendMuxedCluster( |
1558 MuxedStreamInfo(kAudioTrackNum, "46K 69K", 23), | 1559 MuxedStreamInfo(kAudioTrackNum, "46K 69K", 23), |
1559 MuxedStreamInfo(kVideoTrackNum, "60K", | 1560 MuxedStreamInfo(kVideoTrackNum, "60K", |
1560 WebMClusterParser::kDefaultVideoBufferDurationInMs), | 1561 WebMClusterParser::kDefaultVideoBufferDurationInMs), |
(...skipping 24 matching lines...) Expand all Loading... |
1585 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 1586 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
1586 ASSERT_TRUE(audio_stream && video_stream && text_stream); | 1587 ASSERT_TRUE(audio_stream && video_stream && text_stream); |
1587 | 1588 |
1588 AppendMuxedCluster( | 1589 AppendMuxedCluster( |
1589 MuxedStreamInfo(kAudioTrackNum, "23K", | 1590 MuxedStreamInfo(kAudioTrackNum, "23K", |
1590 WebMClusterParser::kDefaultAudioBufferDurationInMs), | 1591 WebMClusterParser::kDefaultAudioBufferDurationInMs), |
1591 MuxedStreamInfo(kVideoTrackNum, "0 30K", 30), | 1592 MuxedStreamInfo(kVideoTrackNum, "0 30K", 30), |
1592 MuxedStreamInfo(kTextTrackNum, "25K 40K")); | 1593 MuxedStreamInfo(kTextTrackNum, "25K 40K")); |
1593 CheckExpectedRanges("{ [23,46) }"); | 1594 CheckExpectedRanges("{ [23,46) }"); |
1594 | 1595 |
1595 EXPECT_CALL(*this, InitSegmentReceived()); | 1596 EXPECT_CALL(*this, InitSegmentReceived(_)); |
1596 AppendInitSegment(HAS_TEXT | HAS_AUDIO | HAS_VIDEO); | 1597 AppendInitSegment(HAS_TEXT | HAS_AUDIO | HAS_VIDEO); |
1597 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "46K 69K", 23), | 1598 AppendMuxedCluster(MuxedStreamInfo(kAudioTrackNum, "46K 69K", 23), |
1598 MuxedStreamInfo(kVideoTrackNum, "60 90K", 30), | 1599 MuxedStreamInfo(kVideoTrackNum, "60 90K", 30), |
1599 MuxedStreamInfo(kTextTrackNum, "80K 90K")); | 1600 MuxedStreamInfo(kTextTrackNum, "80K 90K")); |
1600 CheckExpectedRanges("{ [23,92) }"); | 1601 CheckExpectedRanges("{ [23,92) }"); |
1601 | 1602 |
1602 CheckExpectedBuffers(audio_stream, "23K 46K 69K"); | 1603 CheckExpectedBuffers(audio_stream, "23K 46K 69K"); |
1603 CheckExpectedBuffers(video_stream, "30K 90K"); | 1604 CheckExpectedBuffers(video_stream, "30K 90K"); |
1604 CheckExpectedBuffers(text_stream, "25K 40K 80K 90K"); | 1605 CheckExpectedBuffers(text_stream, "25K 40K 80K 90K"); |
1605 } | 1606 } |
1606 | 1607 |
1607 // Make sure that the demuxer reports an error if Shutdown() | 1608 // Make sure that the demuxer reports an error if Shutdown() |
1608 // is called before all the initialization segments are appended. | 1609 // is called before all the initialization segments are appended. |
1609 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppended) { | 1610 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppended) { |
1610 EXPECT_CALL(*this, DemuxerOpened()); | 1611 EXPECT_CALL(*this, DemuxerOpened()); |
1611 demuxer_->Initialize( | 1612 demuxer_->Initialize( |
1612 &host_, CreateInitDoneCB( | 1613 &host_, CreateInitDoneCB( |
1613 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1614 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); |
1614 | 1615 |
1615 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); | 1616 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); |
1616 EXPECT_EQ(AddId("video", HAS_VIDEO), ChunkDemuxer::kOk); | 1617 EXPECT_EQ(AddId("video", HAS_VIDEO), ChunkDemuxer::kOk); |
1617 | 1618 |
1618 ExpectInitMediaLogs(HAS_AUDIO); | 1619 ExpectInitMediaLogs(HAS_AUDIO); |
1619 EXPECT_CALL(*this, InitSegmentReceived()); | 1620 EXPECT_CALL(*this, InitSegmentReceived(_)); |
1620 AppendInitSegmentWithSourceId("audio", HAS_AUDIO); | 1621 AppendInitSegmentWithSourceId("audio", HAS_AUDIO); |
1621 | 1622 |
1622 ShutdownDemuxer(); | 1623 ShutdownDemuxer(); |
1623 } | 1624 } |
1624 | 1625 |
1625 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppendedText) { | 1626 TEST_F(ChunkDemuxerTest, Shutdown_BeforeAllInitSegmentsAppendedText) { |
1626 EXPECT_CALL(*this, DemuxerOpened()); | 1627 EXPECT_CALL(*this, DemuxerOpened()); |
1627 demuxer_->Initialize( | 1628 demuxer_->Initialize( |
1628 &host_, CreateInitDoneCB( | 1629 &host_, CreateInitDoneCB( |
1629 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); | 1630 kDefaultDuration(), DEMUXER_ERROR_COULD_NOT_OPEN), true); |
1630 | 1631 |
1631 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); | 1632 EXPECT_EQ(AddId("audio", HAS_AUDIO), ChunkDemuxer::kOk); |
1632 EXPECT_EQ(AddId("video_and_text", HAS_VIDEO), ChunkDemuxer::kOk); | 1633 EXPECT_EQ(AddId("video_and_text", HAS_VIDEO), ChunkDemuxer::kOk); |
1633 | 1634 |
1634 EXPECT_CALL(host_, AddTextStream(_, _)) | 1635 EXPECT_CALL(host_, AddTextStream(_, _)) |
1635 .Times(Exactly(1)); | 1636 .Times(Exactly(1)); |
1636 | 1637 |
1637 ExpectInitMediaLogs(HAS_VIDEO); | 1638 ExpectInitMediaLogs(HAS_VIDEO); |
1638 EXPECT_CALL(*this, InitSegmentReceived()); | 1639 EXPECT_CALL(*this, InitSegmentReceived(_)); |
1639 AppendInitSegmentWithSourceId("video_and_text", HAS_VIDEO | HAS_TEXT); | 1640 AppendInitSegmentWithSourceId("video_and_text", HAS_VIDEO | HAS_TEXT); |
1640 | 1641 |
1641 ShutdownDemuxer(); | 1642 ShutdownDemuxer(); |
1642 } | 1643 } |
1643 | 1644 |
1644 // Verifies that all streams waiting for data receive an end of stream | 1645 // Verifies that all streams waiting for data receive an end of stream |
1645 // buffer when Shutdown() is called. | 1646 // buffer when Shutdown() is called. |
1646 TEST_F(ChunkDemuxerTest, Shutdown_EndOfStreamWhileWaitingForData) { | 1647 TEST_F(ChunkDemuxerTest, Shutdown_EndOfStreamWhileWaitingForData) { |
1647 DemuxerStream* text_stream = NULL; | 1648 DemuxerStream* text_stream = NULL; |
1648 EXPECT_CALL(host_, AddTextStream(_, _)) | 1649 EXPECT_CALL(host_, AddTextStream(_, _)) |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 memcpy(dst, info_tracks.get(), info_tracks_size); | 2151 memcpy(dst, info_tracks.get(), info_tracks_size); |
2151 dst += info_tracks_size; | 2152 dst += info_tracks_size; |
2152 | 2153 |
2153 memcpy(dst, cluster_a->data(), cluster_a->size()); | 2154 memcpy(dst, cluster_a->data(), cluster_a->size()); |
2154 dst += cluster_a->size(); | 2155 dst += cluster_a->size(); |
2155 | 2156 |
2156 memcpy(dst, cluster_b->data(), cluster_b->size()); | 2157 memcpy(dst, cluster_b->data(), cluster_b->size()); |
2157 dst += cluster_b->size(); | 2158 dst += cluster_b->size(); |
2158 | 2159 |
2159 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); | 2160 ExpectInitMediaLogs(HAS_AUDIO | HAS_VIDEO); |
2160 EXPECT_CALL(*this, InitSegmentReceived()); | 2161 EXPECT_CALL(*this, InitSegmentReceived(_)); |
2161 AppendDataInPieces(buffer.get(), buffer_size); | 2162 AppendDataInPieces(buffer.get(), buffer_size); |
2162 | 2163 |
2163 GenerateExpectedReads(0, 9); | 2164 GenerateExpectedReads(0, 9); |
2164 } | 2165 } |
2165 | 2166 |
2166 TEST_F(ChunkDemuxerTest, WebMFile_AudioAndVideo) { | 2167 TEST_F(ChunkDemuxerTest, WebMFile_AudioAndVideo) { |
2167 struct BufferTimestamps buffer_timestamps[] = { | 2168 struct BufferTimestamps buffer_timestamps[] = { |
2168 {0, 0}, | 2169 {0, 0}, |
2169 {33, 3}, | 2170 {33, 3}, |
2170 {67, 6}, | 2171 {67, 6}, |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2405 EXPECT_MEDIA_LOG(StreamParsingFailed()); | 2406 EXPECT_MEDIA_LOG(StreamParsingFailed()); |
2406 AppendInitSegment(HAS_VIDEO); | 2407 AppendInitSegment(HAS_VIDEO); |
2407 } | 2408 } |
2408 | 2409 |
2409 TEST_F(ChunkDemuxerTest, MultipleHeaders) { | 2410 TEST_F(ChunkDemuxerTest, MultipleHeaders) { |
2410 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2411 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
2411 | 2412 |
2412 AppendCluster(kDefaultFirstCluster()); | 2413 AppendCluster(kDefaultFirstCluster()); |
2413 | 2414 |
2414 // Append another identical initialization segment. | 2415 // Append another identical initialization segment. |
2415 EXPECT_CALL(*this, InitSegmentReceived()); | 2416 EXPECT_CALL(*this, InitSegmentReceived(_)); |
2416 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); | 2417 AppendInitSegment(HAS_AUDIO | HAS_VIDEO); |
2417 | 2418 |
2418 AppendCluster(kDefaultSecondCluster()); | 2419 AppendCluster(kDefaultSecondCluster()); |
2419 | 2420 |
2420 GenerateExpectedReads(0, 9); | 2421 GenerateExpectedReads(0, 9); |
2421 } | 2422 } |
2422 | 2423 |
2423 TEST_F(ChunkDemuxerTest, AddSeparateSourcesForAudioAndVideo) { | 2424 TEST_F(ChunkDemuxerTest, AddSeparateSourcesForAudioAndVideo) { |
2424 std::string audio_id = "audio1"; | 2425 std::string audio_id = "audio1"; |
2425 std::string video_id = "video1"; | 2426 std::string video_id = "video1"; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2461 | 2462 |
2462 std::string audio_id = "audio1"; | 2463 std::string audio_id = "audio1"; |
2463 std::string video_id = "video1"; | 2464 std::string video_id = "video1"; |
2464 | 2465 |
2465 ASSERT_EQ(AddId(audio_id, HAS_AUDIO), ChunkDemuxer::kOk); | 2466 ASSERT_EQ(AddId(audio_id, HAS_AUDIO), ChunkDemuxer::kOk); |
2466 | 2467 |
2467 // Adding an id with audio/video should fail because we already added audio. | 2468 // Adding an id with audio/video should fail because we already added audio. |
2468 ASSERT_EQ(AddId(), ChunkDemuxer::kReachedIdLimit); | 2469 ASSERT_EQ(AddId(), ChunkDemuxer::kReachedIdLimit); |
2469 | 2470 |
2470 ExpectInitMediaLogs(HAS_AUDIO); | 2471 ExpectInitMediaLogs(HAS_AUDIO); |
2471 EXPECT_CALL(*this, InitSegmentReceived()); | 2472 EXPECT_CALL(*this, InitSegmentReceived(_)); |
2472 AppendInitSegmentWithSourceId(audio_id, HAS_AUDIO); | 2473 AppendInitSegmentWithSourceId(audio_id, HAS_AUDIO); |
2473 | 2474 |
2474 // Adding an id after append should fail. | 2475 // Adding an id after append should fail. |
2475 ASSERT_EQ(AddId(video_id, HAS_VIDEO), ChunkDemuxer::kReachedIdLimit); | 2476 ASSERT_EQ(AddId(video_id, HAS_VIDEO), ChunkDemuxer::kReachedIdLimit); |
2476 } | 2477 } |
2477 | 2478 |
2478 // Test that Read() calls after a RemoveId() return "end of stream" buffers. | 2479 // Test that Read() calls after a RemoveId() return "end of stream" buffers. |
2479 TEST_F(ChunkDemuxerTest, RemoveId) { | 2480 TEST_F(ChunkDemuxerTest, RemoveId) { |
2480 std::string audio_id = "audio1"; | 2481 std::string audio_id = "audio1"; |
2481 std::string video_id = "video1"; | 2482 std::string video_id = "video1"; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 } | 2706 } |
2706 | 2707 |
2707 // Test ranges in an audio-only stream. | 2708 // Test ranges in an audio-only stream. |
2708 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioIdOnly) { | 2709 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioIdOnly) { |
2709 EXPECT_CALL(*this, DemuxerOpened()); | 2710 EXPECT_CALL(*this, DemuxerOpened()); |
2710 demuxer_->Initialize( | 2711 demuxer_->Initialize( |
2711 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); | 2712 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); |
2712 | 2713 |
2713 ASSERT_EQ(AddId(kSourceId, HAS_AUDIO), ChunkDemuxer::kOk); | 2714 ASSERT_EQ(AddId(kSourceId, HAS_AUDIO), ChunkDemuxer::kOk); |
2714 ExpectInitMediaLogs(HAS_AUDIO); | 2715 ExpectInitMediaLogs(HAS_AUDIO); |
2715 EXPECT_CALL(*this, InitSegmentReceived()); | 2716 EXPECT_CALL(*this, InitSegmentReceived(_)); |
2716 AppendInitSegment(HAS_AUDIO); | 2717 AppendInitSegment(HAS_AUDIO); |
2717 | 2718 |
2718 // Test a simple cluster. | 2719 // Test a simple cluster. |
2719 AppendCluster( | 2720 AppendCluster( |
2720 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); | 2721 GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration)); |
2721 | 2722 |
2722 CheckExpectedRanges("{ [0,92) }"); | 2723 CheckExpectedRanges("{ [0,92) }"); |
2723 | 2724 |
2724 // Append a disjoint cluster to check for two separate ranges. | 2725 // Append a disjoint cluster to check for two separate ranges. |
2725 AppendCluster(GenerateSingleStreamCluster( | 2726 AppendCluster(GenerateSingleStreamCluster( |
2726 150, 219, kAudioTrackNum, kAudioBlockDuration)); | 2727 150, 219, kAudioTrackNum, kAudioBlockDuration)); |
2727 | 2728 |
2728 CheckExpectedRanges("{ [0,92) [150,219) }"); | 2729 CheckExpectedRanges("{ [0,92) [150,219) }"); |
2729 } | 2730 } |
2730 | 2731 |
2731 // Test ranges in a video-only stream. | 2732 // Test ranges in a video-only stream. |
2732 TEST_F(ChunkDemuxerTest, GetBufferedRanges_VideoIdOnly) { | 2733 TEST_F(ChunkDemuxerTest, GetBufferedRanges_VideoIdOnly) { |
2733 EXPECT_CALL(*this, DemuxerOpened()); | 2734 EXPECT_CALL(*this, DemuxerOpened()); |
2734 demuxer_->Initialize( | 2735 demuxer_->Initialize( |
2735 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); | 2736 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK), true); |
2736 | 2737 |
2737 ASSERT_EQ(AddId(kSourceId, HAS_VIDEO), ChunkDemuxer::kOk); | 2738 ASSERT_EQ(AddId(kSourceId, HAS_VIDEO), ChunkDemuxer::kOk); |
2738 ExpectInitMediaLogs(HAS_VIDEO); | 2739 ExpectInitMediaLogs(HAS_VIDEO); |
2739 EXPECT_CALL(*this, InitSegmentReceived()); | 2740 EXPECT_CALL(*this, InitSegmentReceived(_)); |
2740 AppendInitSegment(HAS_VIDEO); | 2741 AppendInitSegment(HAS_VIDEO); |
2741 | 2742 |
2742 // Test a simple cluster. | 2743 // Test a simple cluster. |
2743 AppendCluster( | 2744 AppendCluster( |
2744 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); | 2745 GenerateSingleStreamCluster(0, 132, kVideoTrackNum, kVideoBlockDuration)); |
2745 | 2746 |
2746 CheckExpectedRanges("{ [0,132) }"); | 2747 CheckExpectedRanges("{ [0,132) }"); |
2747 | 2748 |
2748 // Append a disjoint cluster to check for two separate ranges. | 2749 // Append a disjoint cluster to check for two separate ranges. |
2749 AppendCluster(GenerateSingleStreamCluster( | 2750 AppendCluster(GenerateSingleStreamCluster( |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3399 // Audio: first PES: | 3400 // Audio: first PES: |
3400 // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000] | 3401 // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000] |
3401 // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767] | 3402 // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767] |
3402 // Video: last PES: | 3403 // Video: last PES: |
3403 // PTS: 370155 (0x0005a5eb) [= 90 kHz-Timestamp: 0:00:04.1128] | 3404 // PTS: 370155 (0x0005a5eb) [= 90 kHz-Timestamp: 0:00:04.1128] |
3404 // DTS: 367152 (0x00059a30) [= 90 kHz-Timestamp: 0:00:04.0794] | 3405 // DTS: 367152 (0x00059a30) [= 90 kHz-Timestamp: 0:00:04.0794] |
3405 // Audio: last PES: | 3406 // Audio: last PES: |
3406 // PTS: 353788 (0x000565fc) [= 90 kHz-Timestamp: 0:00:03.9309] | 3407 // PTS: 353788 (0x000565fc) [= 90 kHz-Timestamp: 0:00:03.9309] |
3407 | 3408 |
3408 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-1280x720.ts"); | 3409 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-1280x720.ts"); |
3409 EXPECT_CALL(*this, InitSegmentReceived()); | 3410 EXPECT_CALL(*this, InitSegmentReceived(_)); |
3410 AppendData(kSourceId, buffer->data(), buffer->data_size()); | 3411 AppendData(kSourceId, buffer->data(), buffer->data_size()); |
3411 | 3412 |
3412 // Confirm we're in the middle of parsing a media segment. | 3413 // Confirm we're in the middle of parsing a media segment. |
3413 ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId)); | 3414 ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId)); |
3414 | 3415 |
3415 // ResetParserState on the Mpeg2 TS parser triggers the emission of the last | 3416 // ResetParserState on the Mpeg2 TS parser triggers the emission of the last |
3416 // video buffer which is pending in the stream parser. | 3417 // video buffer which is pending in the stream parser. |
3417 Ranges<base::TimeDelta> range_before_abort = | 3418 Ranges<base::TimeDelta> range_before_abort = |
3418 demuxer_->GetBufferedRanges(kSourceId); | 3419 demuxer_->GetBufferedRanges(kSourceId); |
3419 demuxer_->ResetParserState(kSourceId, | 3420 demuxer_->ResetParserState(kSourceId, |
(...skipping 27 matching lines...) Expand all Loading... |
3447 // Audio: first PES: | 3448 // Audio: first PES: |
3448 // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000] | 3449 // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000] |
3449 // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767] | 3450 // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767] |
3450 // Video: last PES: | 3451 // Video: last PES: |
3451 // PTS: 370155 (0x0005a5eb) [= 90 kHz-Timestamp: 0:00:04.1128] | 3452 // PTS: 370155 (0x0005a5eb) [= 90 kHz-Timestamp: 0:00:04.1128] |
3452 // DTS: 367152 (0x00059a30) [= 90 kHz-Timestamp: 0:00:04.0794] | 3453 // DTS: 367152 (0x00059a30) [= 90 kHz-Timestamp: 0:00:04.0794] |
3453 // Audio: last PES: | 3454 // Audio: last PES: |
3454 // PTS: 353788 (0x000565fc) [= 90 kHz-Timestamp: 0:00:03.9309] | 3455 // PTS: 353788 (0x000565fc) [= 90 kHz-Timestamp: 0:00:03.9309] |
3455 | 3456 |
3456 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-1280x720.ts"); | 3457 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-1280x720.ts"); |
3457 EXPECT_CALL(*this, InitSegmentReceived()); | 3458 EXPECT_CALL(*this, InitSegmentReceived(_)); |
3458 AppendData(kSourceId, buffer->data(), buffer->data_size()); | 3459 AppendData(kSourceId, buffer->data(), buffer->data_size()); |
3459 | 3460 |
3460 // Confirm we're in the middle of parsing a media segment. | 3461 // Confirm we're in the middle of parsing a media segment. |
3461 ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId)); | 3462 ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId)); |
3462 | 3463 |
3463 // Seek to a time corresponding to buffers that will be emitted during the | 3464 // Seek to a time corresponding to buffers that will be emitted during the |
3464 // abort. | 3465 // abort. |
3465 Seek(base::TimeDelta::FromMilliseconds(4110)); | 3466 Seek(base::TimeDelta::FromMilliseconds(4110)); |
3466 | 3467 |
3467 // ResetParserState on the Mpeg2 TS parser triggers the emission of the last | 3468 // ResetParserState on the Mpeg2 TS parser triggers the emission of the last |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4058 // Set the append window to [50,150). | 4059 // Set the append window to [50,150). |
4059 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); | 4060 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
4060 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(150); | 4061 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(150); |
4061 | 4062 |
4062 // Read a WebM file into memory and send the data to the demuxer. The chunk | 4063 // Read a WebM file into memory and send the data to the demuxer. The chunk |
4063 // size has been chosen carefully to ensure the preroll buffer used by the | 4064 // size has been chosen carefully to ensure the preroll buffer used by the |
4064 // partial append window trim must come from a previous Append() call. | 4065 // partial append window trim must come from a previous Append() call. |
4065 scoped_refptr<DecoderBuffer> buffer = | 4066 scoped_refptr<DecoderBuffer> buffer = |
4066 ReadTestDataFile("bear-320x240-audio-only.webm"); | 4067 ReadTestDataFile("bear-320x240-audio-only.webm"); |
4067 ExpectInitMediaLogs(HAS_AUDIO); | 4068 ExpectInitMediaLogs(HAS_AUDIO); |
4068 EXPECT_CALL(*this, InitSegmentReceived()); | 4069 EXPECT_CALL(*this, InitSegmentReceived(_)); |
4069 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); | 4070 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); |
4070 AppendDataInPieces(buffer->data(), buffer->data_size(), 128); | 4071 AppendDataInPieces(buffer->data(), buffer->data_size(), 128); |
4071 | 4072 |
4072 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 4073 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
4073 CheckExpectedBuffers(stream, "50KP 50K 62K 86K 109K 122K 125K 128K"); | 4074 CheckExpectedBuffers(stream, "50KP 50K 62K 86K 109K 122K 125K 128K"); |
4074 } | 4075 } |
4075 | 4076 |
4076 TEST_F(ChunkDemuxerTest, AppendWindow_AudioConfigUpdateRemovesPreroll) { | 4077 TEST_F(ChunkDemuxerTest, AppendWindow_AudioConfigUpdateRemovesPreroll) { |
4077 EXPECT_CALL(*this, DemuxerOpened()); | 4078 EXPECT_CALL(*this, DemuxerOpened()); |
4078 demuxer_->Initialize( | 4079 demuxer_->Initialize( |
4079 &host_, | 4080 &host_, |
4080 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), | 4081 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), |
4081 true); | 4082 true); |
4082 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); | 4083 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); |
4083 | 4084 |
4084 // Set the append window such that the first file is completely before the | 4085 // Set the append window such that the first file is completely before the |
4085 // append window. | 4086 // append window. |
4086 // Expect duration adjustment since actual duration differs slightly from | 4087 // Expect duration adjustment since actual duration differs slightly from |
4087 // duration in the init segment. | 4088 // duration in the init segment. |
4088 const base::TimeDelta duration_1 = base::TimeDelta::FromMilliseconds(2746); | 4089 const base::TimeDelta duration_1 = base::TimeDelta::FromMilliseconds(2746); |
4089 append_window_start_for_next_append_ = duration_1; | 4090 append_window_start_for_next_append_ = duration_1; |
4090 | 4091 |
4091 // Read a WebM file into memory and append the data. | 4092 // Read a WebM file into memory and append the data. |
4092 scoped_refptr<DecoderBuffer> buffer = | 4093 scoped_refptr<DecoderBuffer> buffer = |
4093 ReadTestDataFile("bear-320x240-audio-only.webm"); | 4094 ReadTestDataFile("bear-320x240-audio-only.webm"); |
4094 ExpectInitMediaLogs(HAS_AUDIO); | 4095 ExpectInitMediaLogs(HAS_AUDIO); |
4095 EXPECT_CALL(*this, InitSegmentReceived()); | 4096 EXPECT_CALL(*this, InitSegmentReceived(_)); |
4096 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); | 4097 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(2)); |
4097 AppendDataInPieces(buffer->data(), buffer->data_size(), 512); | 4098 AppendDataInPieces(buffer->data(), buffer->data_size(), 512); |
4098 CheckExpectedRanges("{ }"); | 4099 CheckExpectedRanges("{ }"); |
4099 | 4100 |
4100 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 4101 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
4101 AudioDecoderConfig config_1 = stream->audio_decoder_config(); | 4102 AudioDecoderConfig config_1 = stream->audio_decoder_config(); |
4102 | 4103 |
4103 // Read a second WebM with a different config in and append the data. | 4104 // Read a second WebM with a different config in and append the data. |
4104 scoped_refptr<DecoderBuffer> buffer2 = | 4105 scoped_refptr<DecoderBuffer> buffer2 = |
4105 ReadTestDataFile("bear-320x240-audio-only-48khz.webm"); | 4106 ReadTestDataFile("bear-320x240-audio-only-48khz.webm"); |
4106 EXPECT_CALL(*this, InitSegmentReceived()); | 4107 EXPECT_CALL(*this, InitSegmentReceived(_)); |
4107 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(21)); | 4108 EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(21)); |
4108 EXPECT_CALL(host_, SetDuration(_)).Times(AnyNumber()); | 4109 EXPECT_CALL(host_, SetDuration(_)).Times(AnyNumber()); |
4109 ASSERT_TRUE(SetTimestampOffset(kSourceId, duration_1)); | 4110 ASSERT_TRUE(SetTimestampOffset(kSourceId, duration_1)); |
4110 AppendDataInPieces(buffer2->data(), buffer2->data_size(), 512); | 4111 AppendDataInPieces(buffer2->data(), buffer2->data_size(), 512); |
4111 CheckExpectedRanges("{ [2746,5519) }"); | 4112 CheckExpectedRanges("{ [2746,5519) }"); |
4112 | 4113 |
4113 Seek(duration_1); | 4114 Seek(duration_1); |
4114 ExpectConfigChanged(DemuxerStream::AUDIO); | 4115 ExpectConfigChanged(DemuxerStream::AUDIO); |
4115 ASSERT_FALSE(config_1.Matches(stream->audio_decoder_config())); | 4116 ASSERT_FALSE(config_1.Matches(stream->audio_decoder_config())); |
4116 CheckExpectedBuffers(stream, "2746K 2767K 2789K 2810K"); | 4117 CheckExpectedBuffers(stream, "2746K 2767K 2789K 2810K"); |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4607 cluster->size() - video_start); | 4608 cluster->size() - video_start); |
4608 | 4609 |
4609 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }"); | 4610 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }"); |
4610 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }"); | 4611 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }"); |
4611 CheckExpectedRanges("{ [30,90) }"); | 4612 CheckExpectedRanges("{ [30,90) }"); |
4612 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K"); | 4613 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K"); |
4613 CheckExpectedBuffers(video_stream, "71K 81"); | 4614 CheckExpectedBuffers(video_stream, "71K 81"); |
4614 } | 4615 } |
4615 | 4616 |
4616 } // namespace media | 4617 } // namespace media |
OLD | NEW |