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/media_switches.h" | |
14 #include "media/base/test_data_util.h" | 15 #include "media/base/test_data_util.h" |
15 #include "media/cdm/aes_decryptor.h" | 16 #include "media/cdm/aes_decryptor.h" |
16 #include "media/filters/chunk_demuxer.h" | 17 #include "media/filters/chunk_demuxer.h" |
17 | 18 |
18 using testing::AnyNumber; | 19 using testing::AnyNumber; |
19 using testing::AtMost; | 20 using testing::AtMost; |
20 | 21 |
21 namespace media { | 22 namespace media { |
22 | 23 |
23 static const char kSourceId[] = "SourceId"; | 24 static const char kSourceId[] = "SourceId"; |
24 static const char kClearKeySystem[] = "org.w3.clearkey"; | 25 static const char kClearKeySystem[] = "org.w3.clearkey"; |
25 static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; | 26 static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; |
26 | 27 |
27 static const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; | 28 static const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; |
28 static const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; | 29 static const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; |
29 static const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\""; | 30 static const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\""; |
30 static const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; | 31 static const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; |
31 static const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; | 32 static const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; |
32 static const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; | 33 static const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; |
33 static const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; | 34 static const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
34 static const char kMP4AudioType[] = "audio/mp4"; | 35 static const char kMP4AudioType[] = "audio/mp4"; |
35 static const char kMP4VideoType[] = "video/mp4"; | 36 static const char kMP4VideoType[] = "video/mp4"; |
37 static const char kMP3[] = "audio/mpeg"; | |
36 | 38 |
37 // Key used to encrypt test files. | 39 // Key used to encrypt test files. |
38 static const uint8 kSecretKey[] = { | 40 static const uint8 kSecretKey[] = { |
39 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, | 41 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, |
40 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c | 42 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c |
41 }; | 43 }; |
42 | 44 |
43 // The key ID for all encrypted files. | 45 // The key ID for all encrypted files. |
44 static const uint8 kKeyId[] = { | 46 static const uint8 kKeyId[] = { |
45 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, | 47 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 } | 280 } |
279 | 281 |
280 void DemuxerOpened() { | 282 void DemuxerOpened() { |
281 base::MessageLoop::current()->PostTask( | 283 base::MessageLoop::current()->PostTask( |
282 FROM_HERE, base::Bind(&MockMediaSource::DemuxerOpenedTask, | 284 FROM_HERE, base::Bind(&MockMediaSource::DemuxerOpenedTask, |
283 base::Unretained(this))); | 285 base::Unretained(this))); |
284 } | 286 } |
285 | 287 |
286 void DemuxerOpenedTask() { | 288 void DemuxerOpenedTask() { |
287 size_t semicolon = mimetype_.find(";"); | 289 size_t semicolon = mimetype_.find(";"); |
288 std::string type = mimetype_.substr(0, semicolon); | 290 std::string type = mimetype_; |
289 size_t quote1 = mimetype_.find("\""); | |
290 size_t quote2 = mimetype_.find("\"", quote1 + 1); | |
291 std::string codecStr = mimetype_.substr(quote1 + 1, quote2 - quote1 - 1); | |
292 std::vector<std::string> codecs; | 291 std::vector<std::string> codecs; |
293 Tokenize(codecStr, ",", &codecs); | 292 if (semicolon != std::string::npos) { |
293 type = mimetype_.substr(0, semicolon); | |
294 size_t quote1 = mimetype_.find("\""); | |
295 size_t quote2 = mimetype_.find("\"", quote1 + 1); | |
296 std::string codecStr = mimetype_.substr(quote1 + 1, quote2 - quote1 - 1); | |
297 Tokenize(codecStr, ",", &codecs); | |
298 } | |
294 | 299 |
295 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); | 300 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); |
296 AppendData(initial_append_size_); | 301 AppendData(initial_append_size_); |
297 } | 302 } |
298 | 303 |
299 void DemuxerNeedKey(const std::string& type, | 304 void DemuxerNeedKey(const std::string& type, |
300 const std::vector<uint8>& init_data) { | 305 const std::vector<uint8>& init_data) { |
301 DCHECK(!init_data.empty()); | 306 DCHECK(!init_data.empty()); |
302 CHECK(!need_key_cb_.is_null()); | 307 CHECK(!need_key_cb_.is_null()); |
303 need_key_cb_.Run(std::string(), type, init_data); | 308 need_key_cb_.Run(std::string(), type, init_data); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 EXPECT_EQ(k320WebMFileDurationMs, | 625 EXPECT_EQ(k320WebMFileDurationMs, |
621 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 626 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
622 | 627 |
623 Play(); | 628 Play(); |
624 | 629 |
625 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); | 630 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); |
626 source.Abort(); | 631 source.Abort(); |
627 } | 632 } |
628 | 633 |
629 #if defined(USE_PROPRIETARY_CODECS) | 634 #if defined(USE_PROPRIETARY_CODECS) |
635 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { | |
636 CommandLine::ForCurrentProcess()->AppendSwitch( | |
637 switches::kEnableMP3StreamParser); | |
scherkus (not reviewing)
2013/08/30 00:06:11
this is modifying global state mid-test-suite
it'
acolwell GONE FROM CHROMIUM
2013/08/30 01:42:22
Done.
| |
638 | |
639 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); | |
640 StartPipelineWithMediaSource(&source); | |
641 source.EndOfStream(); | |
642 | |
643 Play(); | |
644 | |
645 EXPECT_TRUE(WaitUntilOnEnded()); | |
646 } | |
647 | |
630 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { | 648 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { |
631 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4, kAppendWholeFile); | 649 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4, kAppendWholeFile); |
632 StartPipelineWithMediaSource(&source); | 650 StartPipelineWithMediaSource(&source); |
633 | 651 |
634 scoped_refptr<DecoderBuffer> second_file = | 652 scoped_refptr<DecoderBuffer> second_file = |
635 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 653 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
636 | 654 |
637 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | 655 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
638 second_file->data(), second_file->data_size()); | 656 second_file->data(), second_file->data_size()); |
639 | 657 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 | 991 |
974 // Verify that VP8 video with inband text track can be played back. | 992 // Verify that VP8 video with inband text track can be played back. |
975 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8_WebVTT_WebM) { | 993 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8_WebVTT_WebM) { |
976 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), | 994 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), |
977 PIPELINE_OK)); | 995 PIPELINE_OK)); |
978 Play(); | 996 Play(); |
979 ASSERT_TRUE(WaitUntilOnEnded()); | 997 ASSERT_TRUE(WaitUntilOnEnded()); |
980 } | 998 } |
981 | 999 |
982 } // namespace media | 1000 } // namespace media |
OLD | NEW |