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