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/pipeline_integration_test_base.h" | 5 #include "media/filters/pipeline_integration_test_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "media/base/decoder_buffer.h" | 10 #include "media/base/decoder_buffer.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 static const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; | 25 static const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; |
26 | 26 |
27 // Key used to encrypt video track in test file "bear-320x240-encrypted.webm". | 27 // Key used to encrypt video track in test file "bear-320x240-encrypted.webm". |
28 static const uint8 kSecretKey[] = { | 28 static const uint8 kSecretKey[] = { |
29 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, | 29 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, |
30 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c | 30 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c |
31 }; | 31 }; |
32 | 32 |
33 static const int kAppendWholeFile = -1; | 33 static const int kAppendWholeFile = -1; |
34 | 34 |
| 35 // Constants for the Media Source config change tests. |
| 36 static const int kAppendTimeSec = 1; |
| 37 static const int kAppendTimeMs = kAppendTimeSec * 1000; |
| 38 static const int k320WebMFileDurationMs = 2737; |
| 39 static const int k640WebMFileDurationMs = 2763; |
| 40 static const int k1280IsoFileDurationMs = 2736; |
| 41 |
| 42 // Note: Tests using this class only exercise the DecryptingDemuxerStream path. |
| 43 // They do not exercise the Decrypting{Audio|Video}Decoder path. |
35 class FakeEncryptedMedia { | 44 class FakeEncryptedMedia { |
36 public: | 45 public: |
37 FakeEncryptedMedia() | 46 FakeEncryptedMedia() |
38 : decryptor_(base::Bind(&FakeEncryptedMedia::KeyAdded, | 47 : decryptor_(base::Bind(&FakeEncryptedMedia::KeyAdded, |
39 base::Unretained(this)), | 48 base::Unretained(this)), |
40 base::Bind(&FakeEncryptedMedia::KeyError, | 49 base::Bind(&FakeEncryptedMedia::KeyError, |
41 base::Unretained(this)), | 50 base::Unretained(this)), |
42 base::Bind(&FakeEncryptedMedia::KeyMessage, | 51 base::Bind(&FakeEncryptedMedia::KeyMessage, |
43 base::Unretained(this)), | 52 base::Unretained(this)), |
44 base::Bind(&FakeEncryptedMedia::NeedKey, | 53 base::Bind(&FakeEncryptedMedia::NeedKey, |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 311 |
303 // TODO(dalecurtis): Audio decoded in float does not have a consistent hash | 312 // TODO(dalecurtis): Audio decoded in float does not have a consistent hash |
304 // across platforms. Fix this: http://crbug.com/168204 | 313 // across platforms. Fix this: http://crbug.com/168204 |
305 // EXPECT_EQ(GetAudioHash(), ""); | 314 // EXPECT_EQ(GetAudioHash(), ""); |
306 } | 315 } |
307 | 316 |
308 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource) { | 317 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource) { |
309 MockMediaSource source("bear-320x240.webm", kWebM, 219229); | 318 MockMediaSource source("bear-320x240.webm", kWebM, 219229); |
310 StartPipelineWithMediaSource(&source); | 319 StartPipelineWithMediaSource(&source); |
311 source.EndOfStream(); | 320 source.EndOfStream(); |
312 ASSERT_EQ(pipeline_status_, PIPELINE_OK); | |
313 | 321 |
314 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().size(), 1u); | 322 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
315 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); | 323 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
316 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 2737); | 324 EXPECT_EQ(k320WebMFileDurationMs, |
| 325 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
317 | 326 |
318 Play(); | 327 Play(); |
319 | 328 |
320 ASSERT_TRUE(WaitUntilOnEnded()); | 329 ASSERT_TRUE(WaitUntilOnEnded()); |
321 source.Abort(); | 330 source.Abort(); |
322 Stop(); | 331 Stop(); |
323 } | 332 } |
324 | 333 |
325 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) { | 334 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) { |
326 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, | 335 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
327 kAppendWholeFile); | 336 kAppendWholeFile); |
328 StartPipelineWithMediaSource(&source); | 337 StartPipelineWithMediaSource(&source); |
329 | 338 |
330 scoped_refptr<DecoderBuffer> second_file = | 339 scoped_refptr<DecoderBuffer> second_file = |
331 ReadTestDataFile("bear-640x360.webm"); | 340 ReadTestDataFile("bear-640x360.webm"); |
332 | 341 |
333 source.AppendAtTime(base::TimeDelta::FromSeconds(2), | 342 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
334 second_file->GetData(), second_file->GetDataSize()); | 343 second_file->GetData(), second_file->GetDataSize()); |
335 | 344 |
336 source.EndOfStream(); | 345 source.EndOfStream(); |
337 ASSERT_EQ(pipeline_status_, PIPELINE_OK); | |
338 | 346 |
339 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().size(), 1u); | 347 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
340 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); | 348 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
341 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 4763); | 349 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 350 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
342 | 351 |
343 Play(); | 352 Play(); |
344 | 353 |
345 ASSERT_TRUE(WaitUntilOnEnded()); | 354 EXPECT_TRUE(WaitUntilOnEnded()); |
346 source.Abort(); | 355 source.Abort(); |
347 Stop(); | 356 Stop(); |
348 } | 357 } |
349 | 358 |
| 359 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_Encrypted_WebM) { |
| 360 MockMediaSource source("bear-320x240-16x9-aspect-av-enc_av.webm", kWebM, |
| 361 kAppendWholeFile); |
| 362 FakeEncryptedMedia encrypted_media; |
| 363 StartPipelineWithEncryptedMedia(&source, &encrypted_media); |
| 364 |
| 365 scoped_refptr<DecoderBuffer> second_file = |
| 366 ReadTestDataFile("bear-640x360-av-enc_av.webm"); |
| 367 |
| 368 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 369 second_file->GetData(), second_file->GetDataSize()); |
| 370 |
| 371 source.EndOfStream(); |
| 372 |
| 373 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 374 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 375 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 376 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 377 |
| 378 Play(); |
| 379 |
| 380 EXPECT_TRUE(WaitUntilOnEnded()); |
| 381 source.Abort(); |
| 382 Stop(); |
| 383 } |
| 384 |
| 385 // Config changes from encrypted to clear are not currently supported. |
| 386 TEST_F(PipelineIntegrationTest, |
| 387 MediaSource_ConfigChange_ClearThenEncrypted_WebM) { |
| 388 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
| 389 kAppendWholeFile); |
| 390 FakeEncryptedMedia encrypted_media; |
| 391 StartPipelineWithEncryptedMedia(&source, &encrypted_media); |
| 392 |
| 393 scoped_refptr<DecoderBuffer> second_file = |
| 394 ReadTestDataFile("bear-640x360-av-enc_av.webm"); |
| 395 |
| 396 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 397 second_file->GetData(), second_file->GetDataSize()); |
| 398 |
| 399 source.EndOfStream(); |
| 400 |
| 401 message_loop_.Run(); |
| 402 EXPECT_EQ(PIPELINE_ERROR_DECODE, pipeline_status_); |
| 403 |
| 404 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 405 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 406 // The second video was not added, so its time has not been added. |
| 407 EXPECT_EQ(k320WebMFileDurationMs, |
| 408 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 409 |
| 410 Play(); |
| 411 |
| 412 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); |
| 413 source.Abort(); |
| 414 } |
| 415 |
| 416 // Config changes from clear to encrypted are not currently supported. |
| 417 TEST_F(PipelineIntegrationTest, |
| 418 MediaSource_ConfigChange_EncryptedThenClear_WebM) { |
| 419 MockMediaSource source("bear-320x240-16x9-aspect-av-enc_av.webm", kWebM, |
| 420 kAppendWholeFile); |
| 421 FakeEncryptedMedia encrypted_media; |
| 422 StartPipelineWithEncryptedMedia(&source, &encrypted_media); |
| 423 |
| 424 scoped_refptr<DecoderBuffer> second_file = |
| 425 ReadTestDataFile("bear-640x360.webm"); |
| 426 |
| 427 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 428 second_file->GetData(), second_file->GetDataSize()); |
| 429 |
| 430 source.EndOfStream(); |
| 431 |
| 432 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 433 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 434 // The second video was not added, so its time has not been added. |
| 435 EXPECT_EQ(k320WebMFileDurationMs, |
| 436 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 437 |
| 438 Play(); |
| 439 |
| 440 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); |
| 441 source.Abort(); |
| 442 } |
| 443 |
350 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 444 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
351 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { | 445 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { |
352 MockMediaSource source("bear.640x360_dash.mp4", kMP4, kAppendWholeFile); | 446 MockMediaSource source("bear.640x360_dash.mp4", kMP4, kAppendWholeFile); |
353 StartPipelineWithMediaSource(&source); | 447 StartPipelineWithMediaSource(&source); |
354 | 448 |
355 scoped_refptr<DecoderBuffer> second_file = | 449 scoped_refptr<DecoderBuffer> second_file = |
356 ReadTestDataFile("bear.1280x720_dash.mp4"); | 450 ReadTestDataFile("bear.1280x720_dash.mp4"); |
357 | 451 |
358 source.AppendAtTime(base::TimeDelta::FromSeconds(2), | 452 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
359 second_file->GetData(), second_file->GetDataSize()); | 453 second_file->GetData(), second_file->GetDataSize()); |
360 | 454 |
361 source.EndOfStream(); | 455 source.EndOfStream(); |
362 ASSERT_EQ(pipeline_status_, PIPELINE_OK); | |
363 | 456 |
364 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().size(), 1u); | 457 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
365 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); | 458 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
366 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 4736); | 459 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, |
| 460 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
367 | 461 |
368 Play(); | 462 Play(); |
369 | 463 |
370 ASSERT_TRUE(WaitUntilOnEnded()); | 464 EXPECT_TRUE(WaitUntilOnEnded()); |
371 source.Abort(); | 465 source.Abort(); |
372 Stop(); | 466 Stop(); |
373 } | 467 } |
374 #endif | 468 #endif |
375 | 469 |
376 TEST_F(PipelineIntegrationTest, BasicPlayback_16x9AspectRatio) { | 470 TEST_F(PipelineIntegrationTest, BasicPlayback_16x9AspectRatio) { |
377 ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240-16x9-aspect.webm"), | 471 ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240-16x9-aspect.webm"), |
378 PIPELINE_OK)); | 472 PIPELINE_OK)); |
379 Play(); | 473 Play(); |
380 ASSERT_TRUE(WaitUntilOnEnded()); | 474 ASSERT_TRUE(WaitUntilOnEnded()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 // Verify video decoder & renderer can handle aborted demuxer reads. | 545 // Verify video decoder & renderer can handle aborted demuxer reads. |
452 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 546 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
453 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, | 547 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, |
454 32768, | 548 32768, |
455 base::TimeDelta::FromMilliseconds(200), | 549 base::TimeDelta::FromMilliseconds(200), |
456 base::TimeDelta::FromMilliseconds(1668), | 550 base::TimeDelta::FromMilliseconds(1668), |
457 0x1C896, 65536)); | 551 0x1C896, 65536)); |
458 } | 552 } |
459 | 553 |
460 } // namespace media | 554 } // namespace media |
OLD | NEW |