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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 cb.AddBlockGroup(track_number, timestamp_in_ms, kTextBlockDuration, | 429 cb.AddBlockGroup(track_number, timestamp_in_ms, kTextBlockDuration, |
| 430 block_flags, &data[0], data.size()); | 430 block_flags, &data[0], data.size()); |
| 431 } else { | 431 } else { |
| 432 cb.AddSimpleBlock(track_number, timestamp_in_ms, block_flags, | 432 cb.AddSimpleBlock(track_number, timestamp_in_ms, block_flags, |
| 433 &data[0], data.size()); | 433 &data[0], data.size()); |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 AppendCluster(source_id, cb.Finish()); | 436 AppendCluster(source_id, cb.Finish()); |
| 437 } | 437 } |
| 438 | 438 |
| 439 struct MuxedStreamInfo { | |
| 440 int track_number; | |
| 441 const char* description; | |
|
wolenetz
2014/07/07 21:31:45
nit: s/description/cluster_description/. Also mayb
acolwell GONE FROM CHROMIUM
2014/07/07 23:56:36
Done.
| |
| 442 }; | |
| 443 | |
| 444 void AppendMuxedCluster(const MuxedStreamInfo& msi_1, | |
| 445 const MuxedStreamInfo& msi_2) { | |
| 446 std::vector<MuxedStreamInfo> msi(2); | |
| 447 msi[0] = msi_1; | |
| 448 msi[1] = msi_2; | |
| 449 AppendMuxedCluster(msi); | |
| 450 } | |
| 451 | |
| 452 void AppendMuxedCluster(const MuxedStreamInfo& msi_1, | |
| 453 const MuxedStreamInfo& msi_2, | |
| 454 const MuxedStreamInfo& msi_3) { | |
| 455 std::vector<MuxedStreamInfo> msi(3); | |
| 456 msi[0] = msi_1; | |
| 457 msi[1] = msi_2; | |
| 458 msi[2] = msi_3; | |
| 459 AppendMuxedCluster(msi); | |
| 460 } | |
| 461 | |
| 462 void AppendMuxedCluster(const std::vector<MuxedStreamInfo> msi) { | |
| 463 for (size_t i = 0; i < msi.size(); ++i) { | |
| 464 AppendSingleStreamCluster(kSourceId, | |
|
wolenetz
2014/07/07 21:31:44
nit: Include a TODO for the follow-up CL to actual
acolwell GONE FROM CHROMIUM
2014/07/07 23:56:36
I have the follow-up CL written already. I was jus
wolenetz
2014/07/08 00:47:33
sgtm
| |
| 465 msi[i].track_number, | |
| 466 msi[i].description); | |
| 467 } | |
| 468 } | |
| 469 | |
| 439 void AppendData(const std::string& source_id, | 470 void AppendData(const std::string& source_id, |
| 440 const uint8* data, size_t length) { | 471 const uint8* data, size_t length) { |
| 441 EXPECT_CALL(host_, AddBufferedTimeRange(_, _)).Times(AnyNumber()); | 472 EXPECT_CALL(host_, AddBufferedTimeRange(_, _)).Times(AnyNumber()); |
| 442 | 473 |
| 443 demuxer_->AppendData(source_id, data, length, | 474 demuxer_->AppendData(source_id, data, length, |
| 444 append_window_start_for_next_append_, | 475 append_window_start_for_next_append_, |
| 445 append_window_end_for_next_append_, | 476 append_window_end_for_next_append_, |
| 446 ×tamp_offset_map_[source_id]); | 477 ×tamp_offset_map_[source_id]); |
| 447 } | 478 } |
| 448 | 479 |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1191 .WillOnce(DoAll(SaveArg<0>(&text_stream), | 1222 .WillOnce(DoAll(SaveArg<0>(&text_stream), |
| 1192 SaveArg<1>(&text_config))); | 1223 SaveArg<1>(&text_config))); |
| 1193 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( | 1224 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( |
| 1194 HAS_TEXT | HAS_AUDIO | HAS_VIDEO, false, false)); | 1225 HAS_TEXT | HAS_AUDIO | HAS_VIDEO, false, false)); |
| 1195 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 1226 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 1196 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 1227 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 1197 ASSERT_TRUE(audio_stream); | 1228 ASSERT_TRUE(audio_stream); |
| 1198 ASSERT_TRUE(video_stream); | 1229 ASSERT_TRUE(video_stream); |
| 1199 ASSERT_TRUE(text_stream); | 1230 ASSERT_TRUE(text_stream); |
| 1200 | 1231 |
| 1201 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23K"); | 1232 AppendMuxedCluster( |
| 1202 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 30"); | 1233 { kAudioTrackNum, "0K 23K" }, |
| 1203 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "10K"); | 1234 { kVideoTrackNum, "0K 30" }, |
| 1235 { kTextTrackNum, "10K" }); | |
| 1204 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 1236 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
| 1205 | 1237 |
| 1206 scoped_ptr<uint8[]> info_tracks; | 1238 scoped_ptr<uint8[]> info_tracks; |
| 1207 int info_tracks_size = 0; | 1239 int info_tracks_size = 0; |
| 1208 CreateInitSegmentWithAlternateTextTrackNum(HAS_TEXT | HAS_AUDIO | HAS_VIDEO, | 1240 CreateInitSegmentWithAlternateTextTrackNum(HAS_TEXT | HAS_AUDIO | HAS_VIDEO, |
| 1209 false, false, | 1241 false, false, |
| 1210 &info_tracks, &info_tracks_size); | 1242 &info_tracks, &info_tracks_size); |
| 1211 demuxer_->AppendData(kSourceId, info_tracks.get(), info_tracks_size, | 1243 demuxer_->AppendData(kSourceId, info_tracks.get(), info_tracks_size, |
| 1212 append_window_start_for_next_append_, | 1244 append_window_start_for_next_append_, |
| 1213 append_window_end_for_next_append_, | 1245 append_window_end_for_next_append_, |
| 1214 ×tamp_offset_map_[kSourceId]); | 1246 ×tamp_offset_map_[kSourceId]); |
| 1215 | 1247 |
| 1216 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "46K 69K"); | 1248 AppendMuxedCluster( |
| 1217 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "60K"); | 1249 { kAudioTrackNum, "46K 69K" }, |
| 1218 AppendSingleStreamCluster(kSourceId, kAlternateTextTrackNum, "45K"); | 1250 { kVideoTrackNum, "60K" }, |
| 1251 { kAlternateTextTrackNum, "45K" }); | |
| 1219 | 1252 |
| 1220 CheckExpectedRanges(kSourceId, "{ [0,92) }"); | 1253 CheckExpectedRanges(kSourceId, "{ [0,92) }"); |
| 1221 CheckExpectedBuffers(audio_stream, "0 23 46 69"); | 1254 CheckExpectedBuffers(audio_stream, "0 23 46 69"); |
| 1222 CheckExpectedBuffers(video_stream, "0 30 60"); | 1255 CheckExpectedBuffers(video_stream, "0 30 60"); |
| 1223 CheckExpectedBuffers(text_stream, "10 45"); | 1256 CheckExpectedBuffers(text_stream, "10 45"); |
| 1224 | 1257 |
| 1225 ShutdownDemuxer(); | 1258 ShutdownDemuxer(); |
| 1226 } | 1259 } |
| 1227 | 1260 |
| 1228 TEST_F(ChunkDemuxerTest, InitSegmentSetsNeedRandomAccessPointFlag) { | 1261 TEST_F(ChunkDemuxerTest, InitSegmentSetsNeedRandomAccessPointFlag) { |
| 1229 // Tests that non-keyframes following an init segment are allowed | 1262 // Tests that non-keyframes following an init segment are allowed |
| 1230 // and dropped, as expected if the initialization segment received | 1263 // and dropped, as expected if the initialization segment received |
| 1231 // algorithm correctly sets the needs random access point flag to true for all | 1264 // algorithm correctly sets the needs random access point flag to true for all |
| 1232 // track buffers. Note that the first initialization segment is insufficient | 1265 // track buffers. Note that the first initialization segment is insufficient |
| 1233 // to fully test this since needs random access point flag initializes to | 1266 // to fully test this since needs random access point flag initializes to |
| 1234 // true. | 1267 // true. |
| 1235 CreateNewDemuxer(); | 1268 CreateNewDemuxer(); |
| 1236 DemuxerStream* text_stream = NULL; | 1269 DemuxerStream* text_stream = NULL; |
| 1237 EXPECT_CALL(host_, AddTextStream(_, _)) | 1270 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 1238 .WillOnce(SaveArg<0>(&text_stream)); | 1271 .WillOnce(SaveArg<0>(&text_stream)); |
| 1239 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( | 1272 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( |
| 1240 HAS_TEXT | HAS_AUDIO | HAS_VIDEO, false, false)); | 1273 HAS_TEXT | HAS_AUDIO | HAS_VIDEO, false, false)); |
| 1241 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 1274 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 1242 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 1275 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 1243 ASSERT_TRUE(audio_stream && video_stream && text_stream); | 1276 ASSERT_TRUE(audio_stream && video_stream && text_stream); |
| 1244 | 1277 |
| 1245 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0 23K"); | 1278 AppendMuxedCluster( |
| 1246 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0 30K"); | 1279 { kAudioTrackNum, "0 23K" }, |
| 1247 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0 40K"); | 1280 { kVideoTrackNum, "0 30K" }, |
| 1281 { kTextTrackNum, "0 40K" }); | |
| 1248 CheckExpectedRanges(kSourceId, "{ [30,46) }"); | 1282 CheckExpectedRanges(kSourceId, "{ [30,46) }"); |
| 1249 | 1283 |
| 1250 AppendInitSegment(HAS_TEXT | HAS_AUDIO | HAS_VIDEO); | 1284 AppendInitSegment(HAS_TEXT | HAS_AUDIO | HAS_VIDEO); |
| 1251 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "46 69K"); | 1285 AppendMuxedCluster( |
| 1252 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "60 90K"); | 1286 { kAudioTrackNum, "46 69K" }, |
| 1253 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "80 90K"); | 1287 { kVideoTrackNum, "60 90K" }, |
| 1288 { kTextTrackNum, "80 90K" }); | |
| 1254 CheckExpectedRanges(kSourceId, "{ [30,92) }"); | 1289 CheckExpectedRanges(kSourceId, "{ [30,92) }"); |
| 1255 | 1290 |
| 1256 CheckExpectedBuffers(audio_stream, "23 69"); | 1291 CheckExpectedBuffers(audio_stream, "23 69"); |
| 1257 CheckExpectedBuffers(video_stream, "30 90"); | 1292 CheckExpectedBuffers(video_stream, "30 90"); |
| 1258 | 1293 |
| 1259 // WebM parser marks all text buffers as keyframes. | 1294 // WebM parser marks all text buffers as keyframes. |
| 1260 CheckExpectedBuffers(text_stream, "0 40 80 90"); | 1295 CheckExpectedBuffers(text_stream, "0 40 80 90"); |
| 1261 } | 1296 } |
| 1262 | 1297 |
| 1263 // Make sure that the demuxer reports an error if Shutdown() | 1298 // Make sure that the demuxer reports an error if Shutdown() |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1723 } | 1758 } |
| 1724 | 1759 |
| 1725 // Verify buffered range change behavior for audio/video/text tracks. | 1760 // Verify buffered range change behavior for audio/video/text tracks. |
| 1726 TEST_F(ChunkDemuxerTest, EndOfStreamRangeChanges) { | 1761 TEST_F(ChunkDemuxerTest, EndOfStreamRangeChanges) { |
| 1727 DemuxerStream* text_stream = NULL; | 1762 DemuxerStream* text_stream = NULL; |
| 1728 | 1763 |
| 1729 EXPECT_CALL(host_, AddTextStream(_, _)) | 1764 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 1730 .WillOnce(SaveArg<0>(&text_stream)); | 1765 .WillOnce(SaveArg<0>(&text_stream)); |
| 1731 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 1766 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
| 1732 | 1767 |
| 1733 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); | 1768 AppendMuxedCluster( |
| 1734 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23K"); | 1769 { kVideoTrackNum, "0K 33" }, |
| 1770 { kAudioTrackNum, "0K 23K" }); | |
| 1735 | 1771 |
| 1736 // Check expected ranges and verify that an empty text track does not | 1772 // Check expected ranges and verify that an empty text track does not |
| 1737 // affect the expected ranges. | 1773 // affect the expected ranges. |
| 1738 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 1774 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
| 1739 | 1775 |
| 1740 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); | 1776 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); |
| 1741 MarkEndOfStream(PIPELINE_OK); | 1777 MarkEndOfStream(PIPELINE_OK); |
| 1742 | 1778 |
| 1743 // Check expected ranges and verify that an empty text track does not | 1779 // Check expected ranges and verify that an empty text track does not |
| 1744 // affect the expected ranges. | 1780 // affect the expected ranges. |
| 1745 CheckExpectedRanges(kSourceId, "{ [0,66) }"); | 1781 CheckExpectedRanges(kSourceId, "{ [0,66) }"); |
| 1746 | 1782 |
| 1747 // Unmark end of stream state and verify that the ranges return to | 1783 // Unmark end of stream state and verify that the ranges return to |
| 1748 // their pre-"end of stream" values. | 1784 // their pre-"end of stream" values. |
| 1749 demuxer_->UnmarkEndOfStream(); | 1785 demuxer_->UnmarkEndOfStream(); |
| 1750 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 1786 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
| 1751 | 1787 |
| 1752 // Add text track data and verify that the buffered ranges don't change | 1788 // Add text track data and verify that the buffered ranges don't change |
| 1753 // since the intersection of all the tracks doesn't change. | 1789 // since the intersection of all the tracks doesn't change. |
| 1754 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200))); | 1790 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(200))); |
| 1755 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K"); | 1791 AppendMuxedCluster( |
| 1792 { kVideoTrackNum, "0K 33" }, | |
| 1793 { kAudioTrackNum, "0K 23K" }, | |
| 1794 { kTextTrackNum, "0K 100K" }); | |
| 1756 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 1795 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
| 1757 | 1796 |
| 1758 // Mark end of stream and verify that text track data is reflected in | 1797 // Mark end of stream and verify that text track data is reflected in |
| 1759 // the new range. | 1798 // the new range. |
| 1760 MarkEndOfStream(PIPELINE_OK); | 1799 MarkEndOfStream(PIPELINE_OK); |
| 1761 CheckExpectedRanges(kSourceId, "{ [0,200) }"); | 1800 CheckExpectedRanges(kSourceId, "{ [0,200) }"); |
| 1762 } | 1801 } |
| 1763 | 1802 |
| 1764 // Make sure AppendData() will accept elements that span multiple calls. | 1803 // Make sure AppendData() will accept elements that span multiple calls. |
| 1765 TEST_F(ChunkDemuxerTest, AppendingInPieces) { | 1804 TEST_F(ChunkDemuxerTest, AppendingInPieces) { |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2362 // buffered ranges. | 2401 // buffered ranges. |
| 2363 AppendCluster(GenerateSingleStreamCluster(1230, 1240, kVideoTrackNum, 10)); | 2402 AppendCluster(GenerateSingleStreamCluster(1230, 1240, kVideoTrackNum, 10)); |
| 2364 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); | 2403 CheckExpectedRanges("{ [0,23) [320,400) [520,570) [720,750) [920,950) }"); |
| 2365 } | 2404 } |
| 2366 | 2405 |
| 2367 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) { | 2406 TEST_F(ChunkDemuxerTest, GetBufferedRanges_AudioVideoText) { |
| 2368 EXPECT_CALL(host_, AddTextStream(_, _)); | 2407 EXPECT_CALL(host_, AddTextStream(_, _)); |
| 2369 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 2408 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
| 2370 | 2409 |
| 2371 // Append audio & video data | 2410 // Append audio & video data |
| 2372 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23"); | 2411 AppendMuxedCluster( |
| 2373 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); | 2412 { kAudioTrackNum, "0K 23" }, |
| 2413 { kVideoTrackNum, "0K 33" }); | |
| 2374 | 2414 |
| 2375 // Verify that a text track with no cues does not result in an empty buffered | 2415 // Verify that a text track with no cues does not result in an empty buffered |
| 2376 // range. | 2416 // range. |
| 2377 CheckExpectedRanges("{ [0,46) }"); | 2417 CheckExpectedRanges("{ [0,46) }"); |
| 2378 | 2418 |
| 2379 // Add some text cues. | 2419 // Add some text cues. |
| 2380 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K"); | 2420 AppendMuxedCluster( |
| 2421 { kAudioTrackNum, "100K 123" }, | |
| 2422 { kVideoTrackNum, "100K 133" }, | |
| 2423 { kTextTrackNum, "100K 200K"}); | |
|
wolenetz
2014/07/07 21:31:44
nit: s/"}/" }/
acolwell GONE FROM CHROMIUM
2014/07/07 23:56:36
Done.
| |
| 2381 | 2424 |
| 2382 // Verify that the new cues did not affect the buffered ranges. | 2425 // Verify that the text cues are not reflected in the buffered ranges. |
| 2383 CheckExpectedRanges("{ [0,46) }"); | 2426 CheckExpectedRanges("{ [0,46) [100,146) }"); |
| 2384 | 2427 |
| 2385 // Remove the buffered range. | 2428 // Remove the buffered ranges. |
|
wolenetz
2014/07/07 21:31:44
nit: Fix related to my comment below, since the te
acolwell GONE FROM CHROMIUM
2014/07/07 23:56:36
I changed the remove range so that everything gets
| |
| 2386 demuxer_->Remove(kSourceId, base::TimeDelta(), | 2429 demuxer_->Remove(kSourceId, base::TimeDelta(), |
| 2387 base::TimeDelta::FromMilliseconds(46)); | 2430 base::TimeDelta::FromMilliseconds(146)); |
| 2388 CheckExpectedRanges("{ }"); | 2431 CheckExpectedRanges("{ }"); |
|
wolenetz
2014/07/07 21:31:44
nit (maybe best left to a separate CL): If MarkEnd
acolwell GONE FROM CHROMIUM
2014/07/07 23:56:36
This seems like a completely separate issue that s
wolenetz
2014/07/08 00:47:33
sgtm. I've filed https://crbug.com/392006
| |
| 2389 } | 2432 } |
| 2390 | 2433 |
| 2391 // Once MarkEndOfStream() is called, GetBufferedRanges should not cut off any | 2434 // Once MarkEndOfStream() is called, GetBufferedRanges should not cut off any |
| 2392 // over-hanging tails at the end of the ranges as this is likely due to block | 2435 // over-hanging tails at the end of the ranges as this is likely due to block |
| 2393 // duration differences. | 2436 // duration differences. |
| 2394 TEST_F(ChunkDemuxerTest, GetBufferedRanges_EndOfStream) { | 2437 TEST_F(ChunkDemuxerTest, GetBufferedRanges_EndOfStream) { |
| 2395 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 2438 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 2396 | 2439 |
| 2397 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "0K 23K"); | 2440 AppendMuxedCluster( |
| 2398 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "0K 33"); | 2441 { kAudioTrackNum, "0K 23K" }, |
| 2442 { kVideoTrackNum, "0K 33"}); | |
|
wolenetz
2014/07/07 21:31:44
nit: s/"}/" }/
acolwell GONE FROM CHROMIUM
2014/07/07 23:56:36
Done.
| |
| 2399 | 2443 |
| 2400 CheckExpectedRanges("{ [0,46) }"); | 2444 CheckExpectedRanges("{ [0,46) }"); |
| 2401 | 2445 |
| 2402 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); | 2446 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(66))); |
| 2403 MarkEndOfStream(PIPELINE_OK); | 2447 MarkEndOfStream(PIPELINE_OK); |
| 2404 | 2448 |
| 2405 // Verify that the range extends to the end of the video data. | 2449 // Verify that the range extends to the end of the video data. |
| 2406 CheckExpectedRanges("{ [0,66) }"); | 2450 CheckExpectedRanges("{ [0,66) }"); |
| 2407 | 2451 |
| 2408 // Verify that the range reverts to the intersection when end of stream | 2452 // Verify that the range reverts to the intersection when end of stream |
| 2409 // has been cancelled. | 2453 // has been cancelled. |
| 2410 demuxer_->UnmarkEndOfStream(); | 2454 demuxer_->UnmarkEndOfStream(); |
| 2411 CheckExpectedRanges("{ [0,46) }"); | 2455 CheckExpectedRanges("{ [0,46) }"); |
| 2412 | 2456 |
| 2413 // Append and remove data so that the 2 streams' end ranges do not overlap. | 2457 // Append and remove data so that the 2 streams' end ranges do not overlap. |
| 2414 | 2458 |
| 2415 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(246))); | 2459 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(246))); |
| 2416 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(398))); | 2460 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(398))); |
| 2417 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "200K 223K"); | 2461 AppendMuxedCluster( |
| 2418 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 2462 { kAudioTrackNum, "200K 223K" }, |
| 2419 "200K 233 266 299 332K 365"); | 2463 { kVideoTrackNum, "200K 233 266 299 332K 365" }); |
| 2420 | 2464 |
| 2421 // At this point, the per-stream ranges are as follows: | 2465 // At this point, the per-stream ranges are as follows: |
| 2422 // Audio: [0,46) [200,246) | 2466 // Audio: [0,46) [200,246) |
| 2423 // Video: [0,66) [200,398) | 2467 // Video: [0,66) [200,398) |
| 2424 CheckExpectedRanges("{ [0,46) [200,246) }"); | 2468 CheckExpectedRanges("{ [0,46) [200,246) }"); |
| 2425 | 2469 |
| 2426 demuxer_->Remove(kSourceId, base::TimeDelta::FromMilliseconds(200), | 2470 demuxer_->Remove(kSourceId, base::TimeDelta::FromMilliseconds(200), |
| 2427 base::TimeDelta::FromMilliseconds(300)); | 2471 base::TimeDelta::FromMilliseconds(300)); |
| 2428 | 2472 |
| 2429 // At this point, the per-stream ranges are as follows: | 2473 // At this point, the per-stream ranges are as follows: |
| 2430 // Audio: [0,46) | 2474 // Audio: [0,46) |
| 2431 // Video: [0,66) [332,398) | 2475 // Video: [0,66) [332,398) |
| 2432 CheckExpectedRanges("{ [0,46) }"); | 2476 CheckExpectedRanges("{ [0,46) }"); |
| 2433 | 2477 |
| 2434 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, "200K 223K"); | 2478 AppendMuxedCluster( |
| 2435 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, "200K 233"); | 2479 { kAudioTrackNum, "200K 223K" }, |
| 2480 { kVideoTrackNum, "200K 233" }); | |
| 2436 | 2481 |
| 2437 // At this point, the per-stream ranges are as follows: | 2482 // At this point, the per-stream ranges are as follows: |
| 2438 // Audio: [0,46) [200,246) | 2483 // Audio: [0,46) [200,246) |
| 2439 // Video: [0,66) [200,266) [332,398) | 2484 // Video: [0,66) [200,266) [332,398) |
| 2440 // NOTE: The last range on each stream do not overlap in time. | 2485 // NOTE: The last range on each stream do not overlap in time. |
| 2441 CheckExpectedRanges("{ [0,46) [200,246) }"); | 2486 CheckExpectedRanges("{ [0,46) [200,246) }"); |
| 2442 | 2487 |
| 2443 MarkEndOfStream(PIPELINE_OK); | 2488 MarkEndOfStream(PIPELINE_OK); |
| 2444 | 2489 |
| 2445 // NOTE: The last range on each stream gets extended to the highest | 2490 // NOTE: The last range on each stream gets extended to the highest |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3281 .WillOnce(SaveArg<0>(&text_stream)); | 3326 .WillOnce(SaveArg<0>(&text_stream)); |
| 3282 ASSERT_TRUE(InitDemuxer(HAS_VIDEO | HAS_TEXT)); | 3327 ASSERT_TRUE(InitDemuxer(HAS_VIDEO | HAS_TEXT)); |
| 3283 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3328 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 3284 | 3329 |
| 3285 // Set the append window to [20,280). | 3330 // Set the append window to [20,280). |
| 3286 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); | 3331 append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
| 3287 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); | 3332 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
| 3288 | 3333 |
| 3289 // Append a cluster that starts before and ends after the append | 3334 // Append a cluster that starts before and ends after the append |
| 3290 // window. | 3335 // window. |
| 3291 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3336 AppendMuxedCluster( |
| 3292 "0K 30 60 90 120K 150 180 210 240K 270 300 330K"); | 3337 { kVideoTrackNum, "0K 30 60 90 120K 150 180 210 240K 270 300 330K" }, |
| 3293 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K 200K 300K"); | 3338 { kTextTrackNum, "0K 100K 200K 300K" }); |
| 3294 | 3339 |
| 3295 // Verify that text cues that start outside the window are not included | 3340 // Verify that text cues that start outside the window are not included |
| 3296 // in the buffer. Also verify that cues that extend beyond the | 3341 // in the buffer. Also verify that cues that extend beyond the |
| 3297 // window are not included. | 3342 // window are not included. |
| 3298 CheckExpectedRanges(kSourceId, "{ [120,270) }"); | 3343 CheckExpectedRanges(kSourceId, "{ [120,270) }"); |
| 3299 CheckExpectedBuffers(video_stream, "120 150 180 210 240"); | 3344 CheckExpectedBuffers(video_stream, "120 150 180 210 240"); |
| 3300 CheckExpectedBuffers(text_stream, "100"); | 3345 CheckExpectedBuffers(text_stream, "100"); |
| 3301 | 3346 |
| 3302 // Extend the append window to [20,650). | 3347 // Extend the append window to [20,650). |
| 3303 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); | 3348 append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
| 3304 | 3349 |
| 3305 // Append more data and verify that a new range is created. | 3350 // Append more data and verify that a new range is created. |
| 3306 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3351 AppendMuxedCluster( |
| 3307 "360 390 420K 450 480 510 540K 570 600 630K"); | 3352 { kVideoTrackNum, "360 390 420K 450 480 510 540K 570 600 630K" }, |
| 3308 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "400K 500K 600K 700K"); | 3353 { kTextTrackNum, "400K 500K 600K 700K" }); |
| 3309 CheckExpectedRanges(kSourceId, "{ [120,270) [420,630) }"); | 3354 CheckExpectedRanges(kSourceId, "{ [120,270) [420,630) }"); |
| 3310 | 3355 |
| 3311 // Seek to the new range and verify that the expected buffers are returned. | 3356 // Seek to the new range and verify that the expected buffers are returned. |
| 3312 Seek(base::TimeDelta::FromMilliseconds(420)); | 3357 Seek(base::TimeDelta::FromMilliseconds(420)); |
| 3313 CheckExpectedBuffers(video_stream, "420 450 480 510 540 570 600"); | 3358 CheckExpectedBuffers(video_stream, "420 450 480 510 540 570 600"); |
| 3314 CheckExpectedBuffers(text_stream, "400 500"); | 3359 CheckExpectedBuffers(text_stream, "400 500"); |
| 3315 } | 3360 } |
| 3316 | 3361 |
| 3317 TEST_F(ChunkDemuxerTest, StartWaitingForSeekAfterParseError) { | 3362 TEST_F(ChunkDemuxerTest, StartWaitingForSeekAfterParseError) { |
| 3318 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 3363 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 3319 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 3364 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
| 3320 AppendGarbage(); | 3365 AppendGarbage(); |
| 3321 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(50); | 3366 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(50); |
| 3322 demuxer_->StartWaitingForSeek(seek_time); | 3367 demuxer_->StartWaitingForSeek(seek_time); |
| 3323 } | 3368 } |
| 3324 | 3369 |
| 3325 TEST_F(ChunkDemuxerTest, Remove_AudioVideoText) { | 3370 TEST_F(ChunkDemuxerTest, Remove_AudioVideoText) { |
| 3326 DemuxerStream* text_stream = NULL; | 3371 DemuxerStream* text_stream = NULL; |
| 3327 EXPECT_CALL(host_, AddTextStream(_, _)) | 3372 EXPECT_CALL(host_, AddTextStream(_, _)) |
| 3328 .WillOnce(SaveArg<0>(&text_stream)); | 3373 .WillOnce(SaveArg<0>(&text_stream)); |
| 3329 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); | 3374 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO | HAS_TEXT)); |
| 3330 | 3375 |
| 3331 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3376 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 3332 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 3377 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 3333 | 3378 |
| 3334 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, | 3379 AppendMuxedCluster( |
| 3335 "0K 20K 40K 60K 80K 100K 120K 140K"); | 3380 { kAudioTrackNum, "0K 20K 40K 60K 80K 100K 120K 140K" }, |
| 3336 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3381 { kVideoTrackNum, "0K 30 60 90 120K 150 180" }, |
| 3337 "0K 30 60 90 120K 150 180"); | 3382 { kTextTrackNum, "0K 100K 200K" }); |
| 3338 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "0K 100K 200K"); | |
| 3339 | 3383 |
| 3340 CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140"); | 3384 CheckExpectedBuffers(audio_stream, "0 20 40 60 80 100 120 140"); |
| 3341 CheckExpectedBuffers(video_stream, "0 30 60 90 120 150 180"); | 3385 CheckExpectedBuffers(video_stream, "0 30 60 90 120 150 180"); |
| 3342 CheckExpectedBuffers(text_stream, "0 100 200"); | 3386 CheckExpectedBuffers(text_stream, "0 100 200"); |
| 3343 | 3387 |
| 3344 // Remove the buffers that were added. | 3388 // Remove the buffers that were added. |
| 3345 demuxer_->Remove(kSourceId, base::TimeDelta(), | 3389 demuxer_->Remove(kSourceId, base::TimeDelta(), |
| 3346 base::TimeDelta::FromMilliseconds(300)); | 3390 base::TimeDelta::FromMilliseconds(300)); |
| 3347 | 3391 |
| 3348 // Verify that all the appended data has been removed. | 3392 // Verify that all the appended data has been removed. |
| 3349 CheckExpectedRanges(kSourceId, "{ }"); | 3393 CheckExpectedRanges(kSourceId, "{ }"); |
| 3350 | 3394 |
| 3351 // Append new buffers that are clearly different than the original | 3395 // Append new buffers that are clearly different than the original |
| 3352 // ones and verify that only the new buffers are returned. | 3396 // ones and verify that only the new buffers are returned. |
| 3353 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, | 3397 AppendMuxedCluster( |
| 3354 "1K 21K 41K 61K 81K 101K 121K 141K"); | 3398 { kAudioTrackNum, "1K 21K 41K 61K 81K 101K 121K 141K" }, |
| 3355 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3399 { kVideoTrackNum, "1K 31 61 91 121K 151 181" }, |
| 3356 "1K 31 61 91 121K 151 181"); | 3400 { kTextTrackNum, "1K 101K 201K" }); |
| 3357 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "1K 101K 201K"); | |
| 3358 | 3401 |
| 3359 Seek(base::TimeDelta()); | 3402 Seek(base::TimeDelta()); |
| 3360 CheckExpectedBuffers(audio_stream, "1 21 41 61 81 101 121 141"); | 3403 CheckExpectedBuffers(audio_stream, "1 21 41 61 81 101 121 141"); |
| 3361 CheckExpectedBuffers(video_stream, "1 31 61 91 121 151 181"); | 3404 CheckExpectedBuffers(video_stream, "1 31 61 91 121 151 181"); |
| 3362 CheckExpectedBuffers(text_stream, "1 101 201"); | 3405 CheckExpectedBuffers(text_stream, "1 101 201"); |
| 3363 } | 3406 } |
| 3364 | 3407 |
| 3365 TEST_F(ChunkDemuxerTest, Remove_StartAtDuration) { | 3408 TEST_F(ChunkDemuxerTest, Remove_StartAtDuration) { |
| 3366 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); | 3409 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
| 3367 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); | 3410 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3409 message_loop_.RunUntilIdle(); | 3452 message_loop_.RunUntilIdle(); |
| 3410 | 3453 |
| 3411 EXPECT_FALSE(seek_cb_was_called); | 3454 EXPECT_FALSE(seek_cb_was_called); |
| 3412 | 3455 |
| 3413 bool text_read_done = false; | 3456 bool text_read_done = false; |
| 3414 text_stream->Read(base::Bind(&OnReadDone, | 3457 text_stream->Read(base::Bind(&OnReadDone, |
| 3415 base::TimeDelta::FromMilliseconds(125), | 3458 base::TimeDelta::FromMilliseconds(125), |
| 3416 &text_read_done)); | 3459 &text_read_done)); |
| 3417 | 3460 |
| 3418 // Append audio & video data so the seek completes. | 3461 // Append audio & video data so the seek completes. |
| 3419 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, | 3462 AppendMuxedCluster( |
| 3420 "0K 20K 40K 60K 80K 100K 120K 140K 160K 180K"); | 3463 { kAudioTrackNum, "0K 20K 40K 60K 80K 100K 120K 140K 160K 180K" }, |
| 3421 AppendSingleStreamCluster(kSourceId, kVideoTrackNum, | 3464 { kVideoTrackNum, "0K 30 60 90 120K 150 180 210" }); |
| 3422 "0K 30 60 90 120K 150 180 210"); | |
| 3423 | 3465 |
| 3424 message_loop_.RunUntilIdle(); | 3466 message_loop_.RunUntilIdle(); |
| 3425 EXPECT_TRUE(seek_cb_was_called); | 3467 EXPECT_TRUE(seek_cb_was_called); |
| 3426 EXPECT_FALSE(text_read_done); | 3468 EXPECT_FALSE(text_read_done); |
| 3427 | 3469 |
| 3428 // Read some audio & video buffers to further verify seek completion. | 3470 // Read some audio & video buffers to further verify seek completion. |
| 3429 CheckExpectedBuffers(audio_stream, "120 140"); | 3471 CheckExpectedBuffers(audio_stream, "120 140"); |
| 3430 CheckExpectedBuffers(video_stream, "120 150"); | 3472 CheckExpectedBuffers(video_stream, "120 150"); |
| 3431 | 3473 |
| 3432 EXPECT_FALSE(text_read_done); | 3474 EXPECT_FALSE(text_read_done); |
| 3433 | 3475 |
| 3434 // Append text cues that start after the seek point and verify that | 3476 // Append text cues that start after the seek point and verify that |
| 3435 // they are returned by Read() calls. | 3477 // they are returned by Read() calls. |
| 3436 AppendSingleStreamCluster(kSourceId, kTextTrackNum, "125K 175K 225K"); | 3478 AppendMuxedCluster( |
| 3479 { kAudioTrackNum, "0K 20K 40K 60K 80K 100K 120K 140K 160K 180K" }, | |
| 3480 { kVideoTrackNum, "0K 30 60 90 120K 150 180 210" }, | |
| 3481 { kTextTrackNum, "125K 175K 225K" }); | |
| 3437 | 3482 |
| 3438 message_loop_.RunUntilIdle(); | 3483 message_loop_.RunUntilIdle(); |
| 3439 EXPECT_TRUE(text_read_done); | 3484 EXPECT_TRUE(text_read_done); |
| 3440 | 3485 |
| 3441 // NOTE: we start at 175 here because the buffer at 125 was returned | 3486 // NOTE: we start at 175 here because the buffer at 125 was returned |
| 3442 // to the pending read initiated above. | 3487 // to the pending read initiated above. |
| 3443 CheckExpectedBuffers(text_stream, "175 225"); | 3488 CheckExpectedBuffers(text_stream, "175 225"); |
| 3444 | 3489 |
| 3445 // Verify that audio & video streams continue to return expected values. | 3490 // Verify that audio & video streams continue to return expected values. |
| 3446 CheckExpectedBuffers(audio_stream, "160 180"); | 3491 CheckExpectedBuffers(audio_stream, "160 180"); |
| 3447 CheckExpectedBuffers(video_stream, "180 210"); | 3492 CheckExpectedBuffers(video_stream, "180 210"); |
|
wolenetz
2014/07/07 21:31:44
Hmm. Perhaps I misunderstand, but now that we have
acolwell GONE FROM CHROMIUM
2014/07/07 23:56:36
I changed the code around so that there isn't an o
| |
| 3448 } | 3493 } |
| 3449 | 3494 |
| 3450 TEST_F(ChunkDemuxerTest, ClusterWithUnknownSize) { | 3495 TEST_F(ChunkDemuxerTest, ClusterWithUnknownSize) { |
| 3451 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 3496 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 3452 | 3497 |
| 3453 AppendCluster(GenerateCluster(0, 0, 4, true)); | 3498 AppendCluster(GenerateCluster(0, 0, 4, true)); |
| 3454 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | 3499 CheckExpectedRanges(kSourceId, "{ [0,46) }"); |
| 3455 | 3500 |
| 3456 // A new cluster indicates end of the previous cluster with unknown size. | 3501 // A new cluster indicates end of the previous cluster with unknown size. |
| 3457 AppendCluster(GenerateCluster(46, 66, 5, true)); | 3502 AppendCluster(GenerateCluster(46, 66, 5, true)); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 3475 TEST_F(ChunkDemuxerTest, CuesBetweenClusters) { | 3520 TEST_F(ChunkDemuxerTest, CuesBetweenClusters) { |
| 3476 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | 3521 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); |
| 3477 | 3522 |
| 3478 AppendCluster(GenerateCluster(0, 0, 4)); | 3523 AppendCluster(GenerateCluster(0, 0, 4)); |
| 3479 AppendData(kCuesHeader, sizeof(kCuesHeader)); | 3524 AppendData(kCuesHeader, sizeof(kCuesHeader)); |
| 3480 AppendCluster(GenerateCluster(46, 66, 5)); | 3525 AppendCluster(GenerateCluster(46, 66, 5)); |
| 3481 CheckExpectedRanges(kSourceId, "{ [0,115) }"); | 3526 CheckExpectedRanges(kSourceId, "{ [0,115) }"); |
| 3482 } | 3527 } |
| 3483 | 3528 |
| 3484 } // namespace media | 3529 } // namespace media |
| OLD | NEW |