OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "media/base/audio_decoder_config.h" | 6 #include "media/base/audio_decoder_config.h" |
7 #include "media/base/mock_callback.h" | 7 #include "media/base/mock_callback.h" |
8 #include "media/base/mock_demuxer_host.h" | 8 #include "media/base/mock_demuxer_host.h" |
9 #include "media/base/test_data_util.h" | 9 #include "media/base/test_data_util.h" |
10 #include "media/filters/chunk_demuxer.h" | 10 #include "media/filters/chunk_demuxer.h" |
11 #include "media/filters/chunk_demuxer_client.h" | 11 #include "media/filters/chunk_demuxer_client.h" |
12 #include "media/webm/cluster_builder.h" | 12 #include "media/webm/cluster_builder.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using ::testing::AnyNumber; | 15 using ::testing::AnyNumber; |
16 using ::testing::InSequence; | 16 using ::testing::InSequence; |
17 using ::testing::Return; | 17 using ::testing::Return; |
18 using ::testing::SetArgumentPointee; | 18 using ::testing::SetArgumentPointee; |
| 19 using ::testing::NiceMock; |
19 using ::testing::_; | 20 using ::testing::_; |
20 | 21 |
21 namespace media { | 22 namespace media { |
22 | 23 |
23 static const uint8 kTracksHeader[] = { | 24 static const uint8 kTracksHeader[] = { |
24 0x16, 0x54, 0xAE, 0x6B, // Tracks ID | 25 0x16, 0x54, 0xAE, 0x6B, // Tracks ID |
25 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // tracks(size = 0) | 26 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // tracks(size = 0) |
26 }; | 27 }; |
27 | 28 |
28 static const int kTracksHeaderSize = sizeof(kTracksHeader); | 29 static const int kTracksHeaderSize = sizeof(kTracksHeader); |
29 static const int kTracksSizeOffset = 4; | 30 static const int kTracksSizeOffset = 4; |
30 | 31 |
31 static const int kVideoTrackNum = 1; | 32 static const int kVideoTrackNum = 1; |
32 static const int kAudioTrackNum = 2; | 33 static const int kAudioTrackNum = 2; |
33 | 34 |
34 MATCHER_P(HasTimestamp, timestamp_in_ms, "") { | |
35 return !arg->IsEndOfStream() && | |
36 arg->GetTimestamp().InMilliseconds() == timestamp_in_ms; | |
37 } | |
38 | |
39 class MockChunkDemuxerClient : public ChunkDemuxerClient { | 35 class MockChunkDemuxerClient : public ChunkDemuxerClient { |
40 public: | 36 public: |
41 MockChunkDemuxerClient() {} | 37 MockChunkDemuxerClient() {} |
42 virtual ~MockChunkDemuxerClient() {} | 38 virtual ~MockChunkDemuxerClient() {} |
43 | 39 |
44 MOCK_METHOD1(DemuxerOpened, void(ChunkDemuxer* demuxer)); | 40 MOCK_METHOD1(DemuxerOpened, void(ChunkDemuxer* demuxer)); |
45 MOCK_METHOD0(DemuxerClosed, void()); | 41 MOCK_METHOD0(DemuxerClosed, void()); |
46 | 42 |
47 private: | 43 private: |
48 DISALLOW_COPY_AND_ASSIGN(MockChunkDemuxerClient); | 44 DISALLOW_COPY_AND_ASSIGN(MockChunkDemuxerClient); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 uint8 data[] = { 0x00 }; | 185 uint8 data[] = { 0x00 }; |
190 cb->AddSimpleBlock(track_num, timecode, 0, data, sizeof(data)); | 186 cb->AddSimpleBlock(track_num, timecode, 0, data, sizeof(data)); |
191 } | 187 } |
192 | 188 |
193 void AddSimpleBlock(ClusterBuilder* cb, int track_num, int64 timecode, | 189 void AddSimpleBlock(ClusterBuilder* cb, int track_num, int64 timecode, |
194 int size) { | 190 int size) { |
195 scoped_array<uint8> data(new uint8[size]); | 191 scoped_array<uint8> data(new uint8[size]); |
196 cb->AddSimpleBlock(track_num, timecode, 0, data.get(), size); | 192 cb->AddSimpleBlock(track_num, timecode, 0, data.get(), size); |
197 } | 193 } |
198 | 194 |
199 MOCK_METHOD1(ReadDone, void(const scoped_refptr<Buffer>&)); | |
200 | |
201 void ExpectRead(DemuxerStream* stream, int64 timestamp_in_ms) { | |
202 EXPECT_CALL(*this, ReadDone(HasTimestamp(timestamp_in_ms))); | |
203 stream->Read(base::Bind(&ChunkDemuxerTest::ReadDone, | |
204 base::Unretained(this))); | |
205 } | |
206 | |
207 MOCK_METHOD1(Checkpoint, void(int id)); | 195 MOCK_METHOD1(Checkpoint, void(int id)); |
208 | 196 |
209 MockDemuxerHost mock_demuxer_host_; | 197 MockDemuxerHost mock_demuxer_host_; |
210 | 198 |
211 scoped_ptr<MockChunkDemuxerClient> client_; | 199 scoped_ptr<MockChunkDemuxerClient> client_; |
212 scoped_refptr<ChunkDemuxer> demuxer_; | 200 scoped_refptr<ChunkDemuxer> demuxer_; |
213 | 201 |
214 private: | 202 private: |
215 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); | 203 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); |
216 }; | 204 }; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 AddSimpleBlock(&cb, kVideoTrackNum, 0); | 270 AddSimpleBlock(&cb, kVideoTrackNum, 0); |
283 scoped_ptr<Cluster> cluster(cb.Finish()); | 271 scoped_ptr<Cluster> cluster(cb.Finish()); |
284 | 272 |
285 Checkpoint(1); | 273 Checkpoint(1); |
286 | 274 |
287 AppendData(cluster->data(), cluster->size()); | 275 AppendData(cluster->data(), cluster->size()); |
288 | 276 |
289 Checkpoint(2); | 277 Checkpoint(2); |
290 } | 278 } |
291 | 279 |
292 // Test the case where a Seek() is requested while the parser | |
293 // is in the middle of cluster. This is to verify that the parser | |
294 // resets itself on seek and is in the right state when data from | |
295 // the new seek point arrives. | |
296 TEST_F(ChunkDemuxerTest, TestSeekWhileParsingCluster) { | |
297 InitDemuxer(true, true); | |
298 | |
299 scoped_refptr<DemuxerStream> audio = | |
300 demuxer_->GetStream(DemuxerStream::AUDIO); | |
301 scoped_refptr<DemuxerStream> video = | |
302 demuxer_->GetStream(DemuxerStream::VIDEO); | |
303 | |
304 InSequence s; | |
305 | |
306 ClusterBuilder cb; | |
307 cb.SetClusterTimecode(0); | |
308 AddSimpleBlock(&cb, kAudioTrackNum, 1); | |
309 AddSimpleBlock(&cb, kVideoTrackNum, 2); | |
310 AddSimpleBlock(&cb, kAudioTrackNum, 10); | |
311 AddSimpleBlock(&cb, kVideoTrackNum, 20); | |
312 scoped_ptr<Cluster> cluster_a(cb.Finish()); | |
313 | |
314 cb.SetClusterTimecode(5000); | |
315 AddSimpleBlock(&cb, kAudioTrackNum, 5000); | |
316 AddSimpleBlock(&cb, kVideoTrackNum, 5005); | |
317 AddSimpleBlock(&cb, kAudioTrackNum, 5007); | |
318 AddSimpleBlock(&cb, kVideoTrackNum, 5035); | |
319 scoped_ptr<Cluster> cluster_b(cb.Finish()); | |
320 | |
321 // Append all but the last byte so that everything but | |
322 // the last block can be parsed. | |
323 AppendData(cluster_a->data(), cluster_a->size() - 1); | |
324 | |
325 ExpectRead(audio, 1); | |
326 ExpectRead(video, 2); | |
327 ExpectRead(audio, 10); | |
328 | |
329 demuxer_->FlushData(); | |
330 demuxer_->Seek(base::TimeDelta::FromSeconds(5), | |
331 NewExpectedStatusCB(PIPELINE_OK)); | |
332 | |
333 | |
334 // Append the new cluster and verify that only the blocks | |
335 // in the new cluster are returned. | |
336 AppendData(cluster_b->data(), cluster_b->size()); | |
337 ExpectRead(audio, 5000); | |
338 ExpectRead(video, 5005); | |
339 ExpectRead(audio, 5007); | |
340 ExpectRead(video, 5035); | |
341 } | |
342 | |
343 // Test the case where AppendData() is called before Init(). | 280 // Test the case where AppendData() is called before Init(). |
344 TEST_F(ChunkDemuxerTest, TestAppendDataBeforeInit) { | 281 TEST_F(ChunkDemuxerTest, TestAppendDataBeforeInit) { |
345 scoped_array<uint8> info_tracks; | 282 scoped_array<uint8> info_tracks; |
346 int info_tracks_size = 0; | 283 int info_tracks_size = 0; |
347 CreateInfoTracks(true, true, &info_tracks, &info_tracks_size); | 284 CreateInfoTracks(true, true, &info_tracks, &info_tracks_size); |
348 | 285 |
349 EXPECT_FALSE(demuxer_->AppendData(info_tracks.get(), info_tracks_size)); | 286 EXPECT_FALSE(demuxer_->AppendData(info_tracks.get(), info_tracks_size)); |
350 } | 287 } |
351 | 288 |
352 static void OnReadDone(const base::TimeDelta& expected_time, | 289 static void OnReadDone(const base::TimeDelta& expected_time, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 TEST_F(ChunkDemuxerTest, TestOutOfOrderClusters) { | 327 TEST_F(ChunkDemuxerTest, TestOutOfOrderClusters) { |
391 InitDemuxer(true, true); | 328 InitDemuxer(true, true); |
392 | 329 |
393 ClusterBuilder cb; | 330 ClusterBuilder cb; |
394 | 331 |
395 cb.SetClusterTimecode(10); | 332 cb.SetClusterTimecode(10); |
396 AddSimpleBlock(&cb, kAudioTrackNum, 10); | 333 AddSimpleBlock(&cb, kAudioTrackNum, 10); |
397 AddSimpleBlock(&cb, kVideoTrackNum, 10); | 334 AddSimpleBlock(&cb, kVideoTrackNum, 10); |
398 AddSimpleBlock(&cb, kAudioTrackNum, 33); | 335 AddSimpleBlock(&cb, kAudioTrackNum, 33); |
399 AddSimpleBlock(&cb, kVideoTrackNum, 43); | 336 AddSimpleBlock(&cb, kVideoTrackNum, 43); |
400 scoped_ptr<Cluster> cluster_a(cb.Finish()); | 337 scoped_ptr<Cluster> clusterA(cb.Finish()); |
401 | 338 |
402 AppendData(cluster_a->data(), cluster_a->size()); | 339 AppendData(clusterA->data(), clusterA->size()); |
403 | 340 |
404 // Cluster B starts before cluster_a and has data | 341 // Cluster B starts before clusterA and has data |
405 // that overlaps. | 342 // that overlaps. |
406 cb.SetClusterTimecode(5); | 343 cb.SetClusterTimecode(5); |
407 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 344 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
408 AddSimpleBlock(&cb, kVideoTrackNum, 7); | 345 AddSimpleBlock(&cb, kVideoTrackNum, 7); |
409 AddSimpleBlock(&cb, kAudioTrackNum, 28); | 346 AddSimpleBlock(&cb, kAudioTrackNum, 28); |
410 AddSimpleBlock(&cb, kVideoTrackNum, 40); | 347 AddSimpleBlock(&cb, kVideoTrackNum, 40); |
411 scoped_ptr<Cluster> cluster_b(cb.Finish()); | 348 scoped_ptr<Cluster> clusterB(cb.Finish()); |
412 | 349 |
413 // Make sure that AppendData() fails because this cluster data | 350 // Make sure that AppendData() fails because this cluster data |
414 // is before previous data. | 351 // is before previous data. |
415 EXPECT_CALL(mock_demuxer_host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 352 EXPECT_CALL(mock_demuxer_host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
416 AppendData(cluster_b->data(), cluster_b->size()); | 353 AppendData(clusterB->data(), clusterB->size()); |
417 | 354 |
418 // Verify that AppendData() doesn't accept more data now. | 355 // Verify that AppendData() doesn't accept more data now. |
419 cb.SetClusterTimecode(45); | 356 cb.SetClusterTimecode(45); |
420 AddSimpleBlock(&cb, kAudioTrackNum, 45); | 357 AddSimpleBlock(&cb, kAudioTrackNum, 45); |
421 AddSimpleBlock(&cb, kVideoTrackNum, 45); | 358 AddSimpleBlock(&cb, kVideoTrackNum, 45); |
422 scoped_ptr<Cluster> cluster_c(cb.Finish()); | 359 scoped_ptr<Cluster> clusterC(cb.Finish()); |
423 EXPECT_FALSE(demuxer_->AppendData(cluster_c->data(), cluster_c->size())); | 360 EXPECT_FALSE(demuxer_->AppendData(clusterC->data(), clusterC->size())); |
424 } | 361 } |
425 | 362 |
426 TEST_F(ChunkDemuxerTest, TestNonMonotonicButAboveClusterTimecode) { | 363 TEST_F(ChunkDemuxerTest, TestNonMonotonicButAboveClusterTimecode) { |
427 InitDemuxer(true, true); | 364 InitDemuxer(true, true); |
428 | 365 |
429 ClusterBuilder cb; | 366 ClusterBuilder cb; |
430 | 367 |
431 // Test the case where block timecodes are not monotonically | 368 // Test the case where block timecodes are not monotonically |
432 // increasing but stay above the cluster timecode. | 369 // increasing but stay above the cluster timecode. |
433 cb.SetClusterTimecode(5); | 370 cb.SetClusterTimecode(5); |
434 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 371 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
435 AddSimpleBlock(&cb, kVideoTrackNum, 10); | 372 AddSimpleBlock(&cb, kVideoTrackNum, 10); |
436 AddSimpleBlock(&cb, kAudioTrackNum, 7); | 373 AddSimpleBlock(&cb, kAudioTrackNum, 7); |
437 AddSimpleBlock(&cb, kVideoTrackNum, 15); | 374 AddSimpleBlock(&cb, kVideoTrackNum, 15); |
438 scoped_ptr<Cluster> cluster_a(cb.Finish()); | 375 scoped_ptr<Cluster> clusterA(cb.Finish()); |
439 | 376 |
440 EXPECT_CALL(mock_demuxer_host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 377 EXPECT_CALL(mock_demuxer_host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
441 AppendData(cluster_a->data(), cluster_a->size()); | 378 AppendData(clusterA->data(), clusterA->size()); |
442 | 379 |
443 // Verify that AppendData() doesn't accept more data now. | 380 // Verify that AppendData() doesn't accept more data now. |
444 cb.SetClusterTimecode(20); | 381 cb.SetClusterTimecode(20); |
445 AddSimpleBlock(&cb, kAudioTrackNum, 20); | 382 AddSimpleBlock(&cb, kAudioTrackNum, 20); |
446 AddSimpleBlock(&cb, kVideoTrackNum, 20); | 383 AddSimpleBlock(&cb, kVideoTrackNum, 20); |
447 scoped_ptr<Cluster> cluster_b(cb.Finish()); | 384 scoped_ptr<Cluster> clusterB(cb.Finish()); |
448 EXPECT_FALSE(demuxer_->AppendData(cluster_b->data(), cluster_b->size())); | 385 EXPECT_FALSE(demuxer_->AppendData(clusterB->data(), clusterB->size())); |
449 } | 386 } |
450 | 387 |
451 TEST_F(ChunkDemuxerTest, TestBackwardsAndBeforeClusterTimecode) { | 388 TEST_F(ChunkDemuxerTest, TestBackwardsAndBeforeClusterTimecode) { |
452 InitDemuxer(true, true); | 389 InitDemuxer(true, true); |
453 | 390 |
454 ClusterBuilder cb; | 391 ClusterBuilder cb; |
455 | 392 |
456 // Test timecodes going backwards and including values less than the cluster | 393 // Test timecodes going backwards and including values less than the cluster |
457 // timecode. | 394 // timecode. |
458 cb.SetClusterTimecode(5); | 395 cb.SetClusterTimecode(5); |
459 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 396 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
460 AddSimpleBlock(&cb, kVideoTrackNum, 5); | 397 AddSimpleBlock(&cb, kVideoTrackNum, 5); |
461 AddSimpleBlock(&cb, kAudioTrackNum, 3); | 398 AddSimpleBlock(&cb, kAudioTrackNum, 3); |
462 AddSimpleBlock(&cb, kVideoTrackNum, 3); | 399 AddSimpleBlock(&cb, kVideoTrackNum, 3); |
463 scoped_ptr<Cluster> cluster_a(cb.Finish()); | 400 scoped_ptr<Cluster> clusterA(cb.Finish()); |
464 | 401 |
465 EXPECT_CALL(mock_demuxer_host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 402 EXPECT_CALL(mock_demuxer_host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
466 AppendData(cluster_a->data(), cluster_a->size()); | 403 AppendData(clusterA->data(), clusterA->size()); |
467 | 404 |
468 // Verify that AppendData() doesn't accept more data now. | 405 // Verify that AppendData() doesn't accept more data now. |
469 cb.SetClusterTimecode(6); | 406 cb.SetClusterTimecode(6); |
470 AddSimpleBlock(&cb, kAudioTrackNum, 6); | 407 AddSimpleBlock(&cb, kAudioTrackNum, 6); |
471 AddSimpleBlock(&cb, kVideoTrackNum, 6); | 408 AddSimpleBlock(&cb, kVideoTrackNum, 6); |
472 scoped_ptr<Cluster> cluster_b(cb.Finish()); | 409 scoped_ptr<Cluster> clusterB(cb.Finish()); |
473 EXPECT_FALSE(demuxer_->AppendData(cluster_b->data(), cluster_b->size())); | 410 EXPECT_FALSE(demuxer_->AppendData(clusterB->data(), clusterB->size())); |
474 } | 411 } |
475 | 412 |
476 | 413 |
477 TEST_F(ChunkDemuxerTest, TestPerStreamMonotonicallyIncreasingTimestamps) { | 414 TEST_F(ChunkDemuxerTest, TestPerStreamMonotonicallyIncreasingTimestamps) { |
478 InitDemuxer(true, true); | 415 InitDemuxer(true, true); |
479 | 416 |
480 ClusterBuilder cb; | 417 ClusterBuilder cb; |
481 | 418 |
482 // Test strict monotonic increasing timestamps on a per stream | 419 // Test strict monotonic increasing timestamps on a per stream |
483 // basis. | 420 // basis. |
(...skipping 11 matching lines...) Expand all Loading... |
495 TEST_F(ChunkDemuxerTest, TestMonotonicallyIncreasingTimestampsAcrossClusters) { | 432 TEST_F(ChunkDemuxerTest, TestMonotonicallyIncreasingTimestampsAcrossClusters) { |
496 InitDemuxer(true, true); | 433 InitDemuxer(true, true); |
497 | 434 |
498 ClusterBuilder cb; | 435 ClusterBuilder cb; |
499 | 436 |
500 // Test strict monotonic increasing timestamps on a per stream | 437 // Test strict monotonic increasing timestamps on a per stream |
501 // basis across clusters. | 438 // basis across clusters. |
502 cb.SetClusterTimecode(5); | 439 cb.SetClusterTimecode(5); |
503 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 440 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
504 AddSimpleBlock(&cb, kVideoTrackNum, 5); | 441 AddSimpleBlock(&cb, kVideoTrackNum, 5); |
505 scoped_ptr<Cluster> cluster_a(cb.Finish()); | 442 scoped_ptr<Cluster> clusterA(cb.Finish()); |
506 | 443 |
507 AppendData(cluster_a->data(), cluster_a->size()); | 444 AppendData(clusterA->data(), clusterA->size()); |
508 | 445 |
509 cb.SetClusterTimecode(5); | 446 cb.SetClusterTimecode(5); |
510 AddSimpleBlock(&cb, kAudioTrackNum, 5); | 447 AddSimpleBlock(&cb, kAudioTrackNum, 5); |
511 AddSimpleBlock(&cb, kVideoTrackNum, 7); | 448 AddSimpleBlock(&cb, kVideoTrackNum, 7); |
512 scoped_ptr<Cluster> cluster_b(cb.Finish()); | 449 scoped_ptr<Cluster> clusterB(cb.Finish()); |
513 | 450 |
514 EXPECT_CALL(mock_demuxer_host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); | 451 EXPECT_CALL(mock_demuxer_host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); |
515 AppendData(cluster_b->data(), cluster_b->size()); | 452 AppendData(clusterB->data(), clusterB->size()); |
516 | 453 |
517 // Verify that AppendData() doesn't accept more data now. | 454 // Verify that AppendData() doesn't accept more data now. |
518 cb.SetClusterTimecode(10); | 455 cb.SetClusterTimecode(10); |
519 AddSimpleBlock(&cb, kAudioTrackNum, 10); | 456 AddSimpleBlock(&cb, kAudioTrackNum, 10); |
520 AddSimpleBlock(&cb, kVideoTrackNum, 10); | 457 AddSimpleBlock(&cb, kVideoTrackNum, 10); |
521 scoped_ptr<Cluster> cluster_c(cb.Finish()); | 458 scoped_ptr<Cluster> clusterC(cb.Finish()); |
522 EXPECT_FALSE(demuxer_->AppendData(cluster_c->data(), cluster_c->size())); | 459 EXPECT_FALSE(demuxer_->AppendData(clusterC->data(), clusterC->size())); |
523 } | 460 } |
524 | 461 |
525 // Test the case where a cluster is passed to AppendData() before | 462 // Test the case where a cluster is passed to AppendData() before |
526 // INFO & TRACKS data. | 463 // INFO & TRACKS data. |
527 TEST_F(ChunkDemuxerTest, TestClusterBeforeInfoTracks) { | 464 TEST_F(ChunkDemuxerTest, TestClusterBeforeInfoTracks) { |
528 EXPECT_CALL(*client_, DemuxerOpened(_)); | 465 EXPECT_CALL(*client_, DemuxerOpened(_)); |
529 demuxer_->Init(NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN)); | 466 demuxer_->Init(NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN)); |
530 | 467 |
531 ClusterBuilder cb; | 468 ClusterBuilder cb; |
532 cb.SetClusterTimecode(0); | 469 cb.SetClusterTimecode(0); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 demuxer_->Init(CreateInitDoneCB(201224, PIPELINE_OK)); | 663 demuxer_->Init(CreateInitDoneCB(201224, PIPELINE_OK)); |
727 | 664 |
728 scoped_array<uint8> info_tracks; | 665 scoped_array<uint8> info_tracks; |
729 int info_tracks_size = 0; | 666 int info_tracks_size = 0; |
730 CreateInfoTracks(true, true, &info_tracks, &info_tracks_size); | 667 CreateInfoTracks(true, true, &info_tracks, &info_tracks_size); |
731 | 668 |
732 ClusterBuilder cb; | 669 ClusterBuilder cb; |
733 cb.SetClusterTimecode(0); | 670 cb.SetClusterTimecode(0); |
734 AddSimpleBlock(&cb, kAudioTrackNum, 32, 512); | 671 AddSimpleBlock(&cb, kAudioTrackNum, 32, 512); |
735 AddSimpleBlock(&cb, kVideoTrackNum, 123, 1024); | 672 AddSimpleBlock(&cb, kVideoTrackNum, 123, 1024); |
736 scoped_ptr<Cluster> cluster_a(cb.Finish()); | 673 scoped_ptr<Cluster> clusterA(cb.Finish()); |
737 | 674 |
738 cb.SetClusterTimecode(125); | 675 cb.SetClusterTimecode(125); |
739 AddSimpleBlock(&cb, kAudioTrackNum, 125, 2048); | 676 AddSimpleBlock(&cb, kAudioTrackNum, 125, 2048); |
740 AddSimpleBlock(&cb, kVideoTrackNum, 150, 2048); | 677 AddSimpleBlock(&cb, kVideoTrackNum, 150, 2048); |
741 scoped_ptr<Cluster> cluster_b(cb.Finish()); | 678 scoped_ptr<Cluster> clusterB(cb.Finish()); |
742 | 679 |
743 size_t buffer_size = info_tracks_size + cluster_a->size() + cluster_b->size(); | 680 size_t buffer_size = info_tracks_size + clusterA->size() + clusterB->size(); |
744 scoped_array<uint8> buffer(new uint8[buffer_size]); | 681 scoped_array<uint8> buffer(new uint8[buffer_size]); |
745 uint8* dst = buffer.get(); | 682 uint8* dst = buffer.get(); |
746 memcpy(dst, info_tracks.get(), info_tracks_size); | 683 memcpy(dst, info_tracks.get(), info_tracks_size); |
747 dst += info_tracks_size; | 684 dst += info_tracks_size; |
748 | 685 |
749 memcpy(dst, cluster_a->data(), cluster_a->size()); | 686 memcpy(dst, clusterA->data(), clusterA->size()); |
750 dst += cluster_a->size(); | 687 dst += clusterA->size(); |
751 | 688 |
752 memcpy(dst, cluster_b->data(), cluster_b->size()); | 689 memcpy(dst, clusterB->data(), clusterB->size()); |
753 dst += cluster_b->size(); | 690 dst += clusterB->size(); |
754 | 691 |
755 AppendDataInPieces(buffer.get(), buffer_size); | 692 AppendDataInPieces(buffer.get(), buffer_size); |
756 | 693 |
757 scoped_refptr<DemuxerStream> audio = | 694 scoped_refptr<DemuxerStream> audio = |
758 demuxer_->GetStream(DemuxerStream::AUDIO); | 695 demuxer_->GetStream(DemuxerStream::AUDIO); |
759 scoped_refptr<DemuxerStream> video = | 696 scoped_refptr<DemuxerStream> video = |
760 demuxer_->GetStream(DemuxerStream::VIDEO); | 697 demuxer_->GetStream(DemuxerStream::VIDEO); |
761 | 698 |
762 ASSERT_TRUE(audio); | 699 ASSERT_TRUE(audio); |
763 ASSERT_TRUE(video); | 700 ASSERT_TRUE(video); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 EXPECT_FALSE(video_read_done); | 843 EXPECT_FALSE(video_read_done); |
907 | 844 |
908 // Append the remaining data. | 845 // Append the remaining data. |
909 AppendData(cluster->data() + i, cluster->size() - i); | 846 AppendData(cluster->data() + i, cluster->size() - i); |
910 | 847 |
911 EXPECT_TRUE(audio_read_done); | 848 EXPECT_TRUE(audio_read_done); |
912 EXPECT_TRUE(video_read_done); | 849 EXPECT_TRUE(video_read_done); |
913 } | 850 } |
914 | 851 |
915 } // namespace media | 852 } // namespace media |
OLD | NEW |