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 // Note: Tests using this class only exercise the DecryptingDemuxerStream path. | |
36 // They do not exercise the Decrypting{Audio|Video}Decoder path. | |
acolwell GONE FROM CHROMIUM
2013/01/07 21:17:50
nit: Add a TODO for exercising the decrypting deco
ddorwin
2013/01/07 22:19:29
shadi@ is working on browser tests that will do th
| |
35 class FakeEncryptedMedia { | 37 class FakeEncryptedMedia { |
36 public: | 38 public: |
37 FakeEncryptedMedia() | 39 FakeEncryptedMedia() |
38 : decryptor_(base::Bind(&FakeEncryptedMedia::KeyAdded, | 40 : decryptor_(base::Bind(&FakeEncryptedMedia::KeyAdded, |
39 base::Unretained(this)), | 41 base::Unretained(this)), |
40 base::Bind(&FakeEncryptedMedia::KeyError, | 42 base::Bind(&FakeEncryptedMedia::KeyError, |
41 base::Unretained(this)), | 43 base::Unretained(this)), |
42 base::Bind(&FakeEncryptedMedia::KeyMessage, | 44 base::Bind(&FakeEncryptedMedia::KeyMessage, |
43 base::Unretained(this)), | 45 base::Unretained(this)), |
44 base::Bind(&FakeEncryptedMedia::NeedKey, | 46 base::Bind(&FakeEncryptedMedia::NeedKey, |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 | 304 |
303 // TODO(dalecurtis): Audio decoded in float does not have a consistent hash | 305 // TODO(dalecurtis): Audio decoded in float does not have a consistent hash |
304 // across platforms. Fix this: http://crbug.com/168204 | 306 // across platforms. Fix this: http://crbug.com/168204 |
305 // EXPECT_EQ(GetAudioHash(), ""); | 307 // EXPECT_EQ(GetAudioHash(), ""); |
306 } | 308 } |
307 | 309 |
308 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource) { | 310 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource) { |
309 MockMediaSource source("bear-320x240.webm", kWebM, 219229); | 311 MockMediaSource source("bear-320x240.webm", kWebM, 219229); |
310 StartPipelineWithMediaSource(&source); | 312 StartPipelineWithMediaSource(&source); |
311 source.EndOfStream(); | 313 source.EndOfStream(); |
312 ASSERT_EQ(pipeline_status_, PIPELINE_OK); | |
ddorwin
2013/01/07 18:54:39
This check was meaningless since any error would p
| |
313 | 314 |
314 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().size(), 1u); | 315 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
315 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); | 316 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
316 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 2737); | 317 EXPECT_EQ(2737, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
317 | 318 |
318 Play(); | 319 Play(); |
319 | 320 |
320 ASSERT_TRUE(WaitUntilOnEnded()); | 321 ASSERT_TRUE(WaitUntilOnEnded()); |
321 source.Abort(); | 322 source.Abort(); |
322 Stop(); | 323 Stop(); |
323 } | 324 } |
324 | 325 |
325 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) { | 326 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) { |
326 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, | 327 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
327 kAppendWholeFile); | 328 kAppendWholeFile); |
328 StartPipelineWithMediaSource(&source); | 329 StartPipelineWithMediaSource(&source); |
329 | 330 |
330 scoped_refptr<DecoderBuffer> second_file = | 331 scoped_refptr<DecoderBuffer> second_file = |
331 ReadTestDataFile("bear-640x360.webm"); | 332 ReadTestDataFile("bear-640x360.webm"); |
332 | 333 |
333 source.AppendAtTime(base::TimeDelta::FromSeconds(2), | 334 source.AppendAtTime(base::TimeDelta::FromSeconds(2), |
334 second_file->GetData(), second_file->GetDataSize()); | 335 second_file->GetData(), second_file->GetDataSize()); |
335 | 336 |
336 source.EndOfStream(); | 337 source.EndOfStream(); |
337 ASSERT_EQ(pipeline_status_, PIPELINE_OK); | |
338 | 338 |
339 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().size(), 1u); | 339 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
340 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); | 340 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
341 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 4763); | 341 EXPECT_EQ(4763, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
342 | 342 |
343 Play(); | 343 Play(); |
344 | 344 |
345 ASSERT_TRUE(WaitUntilOnEnded()); | 345 EXPECT_TRUE(WaitUntilOnEnded()); |
346 source.Abort(); | 346 source.Abort(); |
347 Stop(); | 347 Stop(); |
348 } | 348 } |
349 | 349 |
350 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_Encrypted_WebM) { | |
351 MockMediaSource source("bear-320x240-16x9-aspect-av-enc_av.webm", kWebM, | |
352 kAppendWholeFile); | |
353 FakeEncryptedMedia encrypted_media; | |
354 StartPipelineWithEncryptedMedia(&source, &encrypted_media); | |
355 | |
356 scoped_refptr<DecoderBuffer> second_file = | |
357 ReadTestDataFile("bear-640x360-av-enc_av.webm"); | |
358 | |
359 source.AppendAtTime(base::TimeDelta::FromSeconds(2), | |
360 second_file->GetData(), second_file->GetDataSize()); | |
361 | |
362 source.EndOfStream(); | |
363 | |
364 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
365 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
366 EXPECT_EQ(4763, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
367 | |
368 Play(); | |
369 | |
370 EXPECT_TRUE(WaitUntilOnEnded()); | |
371 source.Abort(); | |
372 Stop(); | |
373 } | |
374 | |
375 // Config changes from encrypted to clear are not currently supported. | |
376 TEST_F(PipelineIntegrationTest, | |
377 MediaSource_ConfigChange_EncryptedThenClear_WebM) { | |
acolwell GONE FROM CHROMIUM
2013/01/07 21:17:50
nit: Isn't this testing "clear then encrypted" and
ddorwin
2013/01/07 22:19:29
Done. Copy-paste-edit mistake. Thanks.
| |
378 const int k320FileDuration = 2737; | |
379 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, | |
380 kAppendWholeFile); | |
381 FakeEncryptedMedia encrypted_media; | |
382 StartPipelineWithEncryptedMedia(&source, &encrypted_media); | |
383 | |
384 scoped_refptr<DecoderBuffer> second_file = | |
385 ReadTestDataFile("bear-640x360-av-enc_av.webm"); | |
386 | |
387 source.AppendAtTime(base::TimeDelta::FromSeconds(2), | |
388 second_file->GetData(), second_file->GetDataSize()); | |
389 | |
390 source.EndOfStream(); | |
391 | |
392 message_loop_.Run(); | |
393 EXPECT_EQ(PIPELINE_ERROR_DECODE, pipeline_status_); | |
394 | |
395 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
396 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
397 // The second video was not added, so its time has not been added. | |
398 EXPECT_EQ(k320FileDuration, | |
399 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
400 | |
401 Play(); | |
402 | |
403 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); | |
404 source.Abort(); | |
405 } | |
406 | |
407 // Config changes from clear to encrypted are not currently supported. | |
408 TEST_F(PipelineIntegrationTest, | |
409 MediaSource_ConfigChange_ClearThenEncrypted_WebM) { | |
acolwell GONE FROM CHROMIUM
2013/01/07 21:17:50
ditto. Isn't this name backwards?
ddorwin
2013/01/07 22:19:29
Done.
| |
410 const int k320FileDuration = 2737; | |
411 MockMediaSource source("bear-320x240-16x9-aspect-av-enc_av.webm", kWebM, | |
412 kAppendWholeFile); | |
413 FakeEncryptedMedia encrypted_media; | |
414 StartPipelineWithEncryptedMedia(&source, &encrypted_media); | |
415 | |
416 scoped_refptr<DecoderBuffer> second_file = | |
417 ReadTestDataFile("bear-640x360.webm"); | |
418 | |
419 source.AppendAtTime(base::TimeDelta::FromSeconds(2), | |
420 second_file->GetData(), second_file->GetDataSize()); | |
421 | |
422 source.EndOfStream(); | |
423 | |
424 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
425 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
426 // The second video was not added, so its time has not been added. | |
427 EXPECT_EQ(k320FileDuration, | |
428 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
429 | |
430 Play(); | |
431 | |
432 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); | |
433 source.Abort(); | |
434 } | |
435 | |
350 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 436 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
351 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { | 437 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { |
352 MockMediaSource source("bear.640x360_dash.mp4", kMP4, kAppendWholeFile); | 438 MockMediaSource source("bear.640x360_dash.mp4", kMP4, kAppendWholeFile); |
353 StartPipelineWithMediaSource(&source); | 439 StartPipelineWithMediaSource(&source); |
354 | 440 |
355 scoped_refptr<DecoderBuffer> second_file = | 441 scoped_refptr<DecoderBuffer> second_file = |
356 ReadTestDataFile("bear.1280x720_dash.mp4"); | 442 ReadTestDataFile("bear.1280x720_dash.mp4"); |
357 | 443 |
358 source.AppendAtTime(base::TimeDelta::FromSeconds(2), | 444 source.AppendAtTime(base::TimeDelta::FromSeconds(2), |
359 second_file->GetData(), second_file->GetDataSize()); | 445 second_file->GetData(), second_file->GetDataSize()); |
360 | 446 |
361 source.EndOfStream(); | 447 source.EndOfStream(); |
362 ASSERT_EQ(pipeline_status_, PIPELINE_OK); | |
363 | 448 |
364 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().size(), 1u); | 449 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
365 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); | 450 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
366 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 4736); | 451 EXPECT_EQ(4736, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
367 | 452 |
368 Play(); | 453 Play(); |
369 | 454 |
370 ASSERT_TRUE(WaitUntilOnEnded()); | 455 EXPECT_TRUE(WaitUntilOnEnded()); |
371 source.Abort(); | 456 source.Abort(); |
372 Stop(); | 457 Stop(); |
373 } | 458 } |
374 #endif | 459 #endif |
375 | 460 |
376 TEST_F(PipelineIntegrationTest, BasicPlayback_16x9AspectRatio) { | 461 TEST_F(PipelineIntegrationTest, BasicPlayback_16x9AspectRatio) { |
377 ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240-16x9-aspect.webm"), | 462 ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240-16x9-aspect.webm"), |
378 PIPELINE_OK)); | 463 PIPELINE_OK)); |
379 Play(); | 464 Play(); |
380 ASSERT_TRUE(WaitUntilOnEnded()); | 465 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. | 536 // Verify video decoder & renderer can handle aborted demuxer reads. |
452 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 537 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
453 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, | 538 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, |
454 32768, | 539 32768, |
455 base::TimeDelta::FromMilliseconds(200), | 540 base::TimeDelta::FromMilliseconds(200), |
456 base::TimeDelta::FromMilliseconds(1668), | 541 base::TimeDelta::FromMilliseconds(1668), |
457 0x1C896, 65536)); | 542 0x1C896, 65536)); |
458 } | 543 } |
459 | 544 |
460 } // namespace media | 545 } // namespace media |
OLD | NEW |