Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: media/filters/pipeline_integration_test.cc

Issue 11785023: Add unit tests for config changes involving encrypted streams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Converted times to constants to make tests easier to understand; review feedback. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 static const int AppendTimeSec = 2;
ddorwin 2013/01/07 22:19:29 acolwell: Any problems dropping this to 1 to speed
acolwell GONE FROM CHROMIUM 2013/01/07 22:21:57 No. I have no problems w/ that.
ddorwin 2013/01/07 23:34:53 Done.
36 static const int AppendTimeMs = AppendTimeSec * 1000;
37 static const int k320WebMFileDurationMs = 2737;
38 static const int k640WebMFileDurationMs = 2763;
39
40 // Note: Tests using this class only exercise the DecryptingDemuxerStream path.
41 // They do not exercise the Decrypting{Audio|Video}Decoder path.
35 class FakeEncryptedMedia { 42 class FakeEncryptedMedia {
36 public: 43 public:
37 FakeEncryptedMedia() 44 FakeEncryptedMedia()
38 : decryptor_(base::Bind(&FakeEncryptedMedia::KeyAdded, 45 : decryptor_(base::Bind(&FakeEncryptedMedia::KeyAdded,
39 base::Unretained(this)), 46 base::Unretained(this)),
40 base::Bind(&FakeEncryptedMedia::KeyError, 47 base::Bind(&FakeEncryptedMedia::KeyError,
41 base::Unretained(this)), 48 base::Unretained(this)),
42 base::Bind(&FakeEncryptedMedia::KeyMessage, 49 base::Bind(&FakeEncryptedMedia::KeyMessage,
43 base::Unretained(this)), 50 base::Unretained(this)),
44 base::Bind(&FakeEncryptedMedia::NeedKey, 51 base::Bind(&FakeEncryptedMedia::NeedKey,
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 309
303 // TODO(dalecurtis): Audio decoded in float does not have a consistent hash 310 // TODO(dalecurtis): Audio decoded in float does not have a consistent hash
304 // across platforms. Fix this: http://crbug.com/168204 311 // across platforms. Fix this: http://crbug.com/168204
305 // EXPECT_EQ(GetAudioHash(), ""); 312 // EXPECT_EQ(GetAudioHash(), "");
306 } 313 }
307 314
308 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource) { 315 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource) {
309 MockMediaSource source("bear-320x240.webm", kWebM, 219229); 316 MockMediaSource source("bear-320x240.webm", kWebM, 219229);
310 StartPipelineWithMediaSource(&source); 317 StartPipelineWithMediaSource(&source);
311 source.EndOfStream(); 318 source.EndOfStream();
312 ASSERT_EQ(pipeline_status_, PIPELINE_OK);
313 319
314 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().size(), 1u); 320 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
315 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); 321 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
316 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 2737); 322 EXPECT_EQ(k320WebMFileDurationMs,
323 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
317 324
318 Play(); 325 Play();
319 326
320 ASSERT_TRUE(WaitUntilOnEnded()); 327 ASSERT_TRUE(WaitUntilOnEnded());
321 source.Abort(); 328 source.Abort();
322 Stop(); 329 Stop();
323 } 330 }
324 331
325 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) { 332 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) {
326 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, 333 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM,
327 kAppendWholeFile); 334 kAppendWholeFile);
328 StartPipelineWithMediaSource(&source); 335 StartPipelineWithMediaSource(&source);
329 336
330 scoped_refptr<DecoderBuffer> second_file = 337 scoped_refptr<DecoderBuffer> second_file =
331 ReadTestDataFile("bear-640x360.webm"); 338 ReadTestDataFile("bear-640x360.webm");
332 339
333 source.AppendAtTime(base::TimeDelta::FromSeconds(2), 340 source.AppendAtTime(base::TimeDelta::FromSeconds(AppendTimeSec),
334 second_file->GetData(), second_file->GetDataSize()); 341 second_file->GetData(), second_file->GetDataSize());
335 342
336 source.EndOfStream(); 343 source.EndOfStream();
337 ASSERT_EQ(pipeline_status_, PIPELINE_OK);
338 344
339 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().size(), 1u); 345 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
340 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); 346 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
341 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 4763); 347 EXPECT_EQ(AppendTimeMs + k640WebMFileDurationMs,
348 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
342 349
343 Play(); 350 Play();
344 351
345 ASSERT_TRUE(WaitUntilOnEnded()); 352 EXPECT_TRUE(WaitUntilOnEnded());
346 source.Abort(); 353 source.Abort();
347 Stop(); 354 Stop();
348 } 355 }
349 356
357 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_Encrypted_WebM) {
358 MockMediaSource source("bear-320x240-16x9-aspect-av-enc_av.webm", kWebM,
359 kAppendWholeFile);
360 FakeEncryptedMedia encrypted_media;
361 StartPipelineWithEncryptedMedia(&source, &encrypted_media);
362
363 scoped_refptr<DecoderBuffer> second_file =
364 ReadTestDataFile("bear-640x360-av-enc_av.webm");
365
366 source.AppendAtTime(base::TimeDelta::FromSeconds(AppendTimeSec),
367 second_file->GetData(), second_file->GetDataSize());
368
369 source.EndOfStream();
370
371 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
372 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
373 EXPECT_EQ(AppendTimeMs + k640WebMFileDurationMs,
374 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
375
376 Play();
377
378 EXPECT_TRUE(WaitUntilOnEnded());
379 source.Abort();
380 Stop();
381 }
382
383 // Config changes from encrypted to clear are not currently supported.
384 TEST_F(PipelineIntegrationTest,
385 MediaSource_ConfigChange_ClearThenEncrypted_WebM) {
386 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM,
387 kAppendWholeFile);
388 FakeEncryptedMedia encrypted_media;
389 StartPipelineWithEncryptedMedia(&source, &encrypted_media);
390
391 scoped_refptr<DecoderBuffer> second_file =
392 ReadTestDataFile("bear-640x360-av-enc_av.webm");
393
394 source.AppendAtTime(base::TimeDelta::FromSeconds(AppendTimeSec),
395 second_file->GetData(), second_file->GetDataSize());
396
397 source.EndOfStream();
398
399 message_loop_.Run();
400 EXPECT_EQ(PIPELINE_ERROR_DECODE, pipeline_status_);
401
402 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
403 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
404 // The second video was not added, so its time has not been added.
405 EXPECT_EQ(k320WebMFileDurationMs,
406 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
407
408 Play();
409
410 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError());
411 source.Abort();
412 }
413
414 // Config changes from clear to encrypted are not currently supported.
415 TEST_F(PipelineIntegrationTest,
416 MediaSource_ConfigChange_EncryptedThenClear_WebM) {
417 MockMediaSource source("bear-320x240-16x9-aspect-av-enc_av.webm", kWebM,
418 kAppendWholeFile);
419 FakeEncryptedMedia encrypted_media;
420 StartPipelineWithEncryptedMedia(&source, &encrypted_media);
421
422 scoped_refptr<DecoderBuffer> second_file =
423 ReadTestDataFile("bear-640x360.webm");
424
425 source.AppendAtTime(base::TimeDelta::FromSeconds(AppendTimeSec),
426 second_file->GetData(), second_file->GetDataSize());
427
428 source.EndOfStream();
429
430 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
431 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
432 // The second video was not added, so its time has not been added.
433 EXPECT_EQ(k320WebMFileDurationMs,
434 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
435
436 Play();
437
438 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError());
439 source.Abort();
440 }
441
350 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) 442 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
351 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { 443 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) {
352 MockMediaSource source("bear.640x360_dash.mp4", kMP4, kAppendWholeFile); 444 MockMediaSource source("bear.640x360_dash.mp4", kMP4, kAppendWholeFile);
353 StartPipelineWithMediaSource(&source); 445 StartPipelineWithMediaSource(&source);
354 446
355 scoped_refptr<DecoderBuffer> second_file = 447 scoped_refptr<DecoderBuffer> second_file =
356 ReadTestDataFile("bear.1280x720_dash.mp4"); 448 ReadTestDataFile("bear.1280x720_dash.mp4");
357 449
358 source.AppendAtTime(base::TimeDelta::FromSeconds(2), 450 source.AppendAtTime(base::TimeDelta::FromSeconds(AppendTimeSec),
359 second_file->GetData(), second_file->GetDataSize()); 451 second_file->GetData(), second_file->GetDataSize());
360 452
361 source.EndOfStream(); 453 source.EndOfStream();
362 ASSERT_EQ(pipeline_status_, PIPELINE_OK);
363 454
364 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().size(), 1u); 455 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
365 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); 456 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
366 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 4736); 457 EXPECT_EQ(4736, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
367 458
368 Play(); 459 Play();
369 460
370 ASSERT_TRUE(WaitUntilOnEnded()); 461 EXPECT_TRUE(WaitUntilOnEnded());
371 source.Abort(); 462 source.Abort();
372 Stop(); 463 Stop();
373 } 464 }
374 #endif 465 #endif
375 466
376 TEST_F(PipelineIntegrationTest, BasicPlayback_16x9AspectRatio) { 467 TEST_F(PipelineIntegrationTest, BasicPlayback_16x9AspectRatio) {
377 ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240-16x9-aspect.webm"), 468 ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240-16x9-aspect.webm"),
378 PIPELINE_OK)); 469 PIPELINE_OK));
379 Play(); 470 Play();
380 ASSERT_TRUE(WaitUntilOnEnded()); 471 ASSERT_TRUE(WaitUntilOnEnded());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // Verify video decoder & renderer can handle aborted demuxer reads. 542 // Verify video decoder & renderer can handle aborted demuxer reads.
452 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { 543 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) {
453 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, 544 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM,
454 32768, 545 32768,
455 base::TimeDelta::FromMilliseconds(200), 546 base::TimeDelta::FromMilliseconds(200),
456 base::TimeDelta::FromMilliseconds(1668), 547 base::TimeDelta::FromMilliseconds(1668),
457 0x1C896, 65536)); 548 0x1C896, 65536));
458 } 549 }
459 550
460 } // namespace media 551 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698