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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "media/base/decoder_buffer.h" | 12 #include "media/base/decoder_buffer.h" |
13 #include "media/base/media_keys.h" | 13 #include "media/base/media_keys.h" |
14 #include "media/base/test_data_util.h" | 14 #include "media/base/test_data_util.h" |
15 #include "media/cdm/aes_decryptor.h" | 15 #include "media/cdm/aes_decryptor.h" |
16 #include "media/filters/chunk_demuxer.h" | 16 #include "media/filters/chunk_demuxer.h" |
17 | 17 |
18 using testing::AnyNumber; | 18 using testing::AnyNumber; |
19 using testing::AtMost; | 19 using testing::AtMost; |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 | 22 |
23 static const char kSourceId[] = "SourceId"; | 23 static const char kSourceId[] = "SourceId"; |
24 static const char kClearKeySystem[] = "org.w3.clearkey"; | 24 static const char kClearKeySystem[] = "org.w3.clearkey"; |
25 static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; | 25 static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; |
26 | 26 |
27 static const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; | 27 static const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; |
28 static const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; | 28 static const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; |
29 static const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\""; | 29 static const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis,opus\""; |
acolwell GONE FROM CHROMIUM
2013/08/28 20:44:47
nit: Use a separate constant for Opus. This signal
vignesh
2013/08/29 21:37:31
Done.
| |
30 static const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; | 30 static const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; |
31 static const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; | 31 static const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; |
32 static const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; | 32 static const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; |
33 static const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; | 33 static const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
34 static const char kMP4AudioType[] = "audio/mp4"; | 34 static const char kMP4AudioType[] = "audio/mp4"; |
35 static const char kMP4VideoType[] = "video/mp4"; | 35 static const char kMP4VideoType[] = "video/mp4"; |
36 | 36 |
37 // Key used to encrypt test files. | 37 // Key used to encrypt test files. |
38 static const uint8 kSecretKey[] = { | 38 static const uint8 kSecretKey[] = { |
39 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, | 39 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, |
40 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c | 40 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c |
41 }; | 41 }; |
42 | 42 |
43 // The key ID for all encrypted files. | 43 // The key ID for all encrypted files. |
44 static const uint8 kKeyId[] = { | 44 static const uint8 kKeyId[] = { |
45 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, | 45 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, |
46 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35 | 46 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35 |
47 }; | 47 }; |
48 | 48 |
49 static const int kAppendWholeFile = -1; | 49 static const int kAppendWholeFile = -1; |
50 | 50 |
51 // Constants for the Media Source config change tests. | 51 // Constants for the Media Source config change tests. |
52 static const int kAppendTimeSec = 1; | 52 static const int kAppendTimeSec = 1; |
53 static const int kAppendTimeMs = kAppendTimeSec * 1000; | 53 static const int kAppendTimeMs = kAppendTimeSec * 1000; |
54 static const int k320WebMFileDurationMs = 2737; | 54 static const int k320WebMFileDurationMs = 2737; |
55 static const int k640WebMFileDurationMs = 2763; | 55 static const int k640WebMFileDurationMs = 2763; |
56 static const int k640IsoFileDurationMs = 2737; | 56 static const int k640IsoFileDurationMs = 2737; |
57 static const int k640IsoCencFileDurationMs = 2736; | 57 static const int k640IsoCencFileDurationMs = 2736; |
58 static const int k1280IsoFileDurationMs = 2736; | 58 static const int k1280IsoFileDurationMs = 2736; |
59 static const int kOpusEndTrimmingWebMFileDurationMs = 2771; | |
60 static const uint32 kOpusEndTrimmingWebMFileAudioBytes = 529924; | |
59 static const int kVP9WebMFileDurationMs = 2735; | 61 static const int kVP9WebMFileDurationMs = 2735; |
60 static const int kVP8AWebMFileDurationMs = 2700; | 62 static const int kVP8AWebMFileDurationMs = 2700; |
61 | 63 |
62 // Command line switch for runtime adjustment of audio file to be benchmarked. | 64 // Command line switch for runtime adjustment of audio file to be benchmarked. |
63 static const char kBenchmarkAudioFile[] = "benchmark-audio-file"; | 65 static const char kBenchmarkAudioFile[] = "benchmark-audio-file"; |
64 | 66 |
65 // Note: Tests using this class only exercise the DecryptingDemuxerStream path. | 67 // Note: Tests using this class only exercise the DecryptingDemuxerStream path. |
66 // They do not exercise the Decrypting{Audio|Video}Decoder path. | 68 // They do not exercise the Decrypting{Audio|Video}Decoder path. |
67 class FakeEncryptedMedia { | 69 class FakeEncryptedMedia { |
68 public: | 70 public: |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 EXPECT_EQ(kVP8AWebMFileDurationMs, | 511 EXPECT_EQ(kVP8AWebMFileDurationMs, |
510 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 512 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
511 | 513 |
512 Play(); | 514 Play(); |
513 | 515 |
514 ASSERT_TRUE(WaitUntilOnEnded()); | 516 ASSERT_TRUE(WaitUntilOnEnded()); |
515 source.Abort(); | 517 source.Abort(); |
516 Stop(); | 518 Stop(); |
517 } | 519 } |
518 | 520 |
521 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Opus_WebM) { | |
522 EXPECT_CALL(*this, OnSetOpaque(false)).Times(AnyNumber()); | |
523 MockMediaSource source("bear-opus-end-trimming.webm", kAudioOnlyWebM, | |
524 kAppendWholeFile); | |
525 StartPipelineWithMediaSource(&source); | |
526 source.EndOfStream(); | |
527 | |
528 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
529 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
530 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, | |
531 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
532 Play(); | |
533 | |
534 ASSERT_TRUE(WaitUntilOnEnded()); | |
535 EXPECT_EQ(kOpusEndTrimmingWebMFileAudioBytes, | |
536 pipeline_->GetStatistics().audio_bytes_decoded); | |
537 source.Abort(); | |
538 Stop(); | |
539 } | |
540 | |
519 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) { | 541 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) { |
520 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, | 542 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
521 kAppendWholeFile); | 543 kAppendWholeFile); |
522 StartPipelineWithMediaSource(&source); | 544 StartPipelineWithMediaSource(&source); |
523 | 545 |
524 scoped_refptr<DecoderBuffer> second_file = | 546 scoped_refptr<DecoderBuffer> second_file = |
525 ReadTestDataFile("bear-640x360.webm"); | 547 ReadTestDataFile("bear-640x360.webm"); |
526 | 548 |
527 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | 549 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
528 second_file->data(), second_file->data_size()); | 550 second_file->data(), second_file->data_size()); |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 | 995 |
974 // Verify that VP8 video with inband text track can be played back. | 996 // Verify that VP8 video with inband text track can be played back. |
975 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8_WebVTT_WebM) { | 997 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8_WebVTT_WebM) { |
976 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), | 998 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), |
977 PIPELINE_OK)); | 999 PIPELINE_OK)); |
978 Play(); | 1000 Play(); |
979 ASSERT_TRUE(WaitUntilOnEnded()); | 1001 ASSERT_TRUE(WaitUntilOnEnded()); |
980 } | 1002 } |
981 | 1003 |
982 } // namespace media | 1004 } // namespace media |
OLD | NEW |