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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 chunk_demuxer_ = NULL; | 279 chunk_demuxer_ = NULL; |
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() { |
289 // This code assumes that |mimetype_| is one of the following forms. | |
scherkus (not reviewing)
2013/09/04 01:25:37
my bad ... didn't realize that this was:
a) test
acolwell GONE FROM CHROMIUM
2013/09/04 01:36:01
no problem. The code now makes it easier to catch
| |
290 // 1. audio/mpeg | |
291 // 2. video/webm;codec="vorbis,vp8". | |
287 size_t semicolon = mimetype_.find(";"); | 292 size_t semicolon = mimetype_.find(";"); |
288 std::string type = mimetype_.substr(0, semicolon); | 293 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; | 294 std::vector<std::string> codecs; |
293 Tokenize(codecStr, ",", &codecs); | 295 if (semicolon != std::string::npos) { |
296 type = mimetype_.substr(0, semicolon); | |
297 size_t codecs_param_start = mimetype_.find("codecs=\"", semicolon); | |
298 | |
299 CHECK_NE(codecs_param_start, std::string::npos); | |
300 | |
301 codecs_param_start += 8; // Skip over the codecs=". | |
302 | |
303 size_t codecs_param_end = mimetype_.find("\"", codecs_param_start); | |
304 | |
305 CHECK_NE(codecs_param_end, std::string::npos); | |
306 | |
307 std::string codecs_param = | |
308 mimetype_.substr(codecs_param_start, | |
309 codecs_param_end - codecs_param_start); | |
310 Tokenize(codecs_param, ",", &codecs); | |
311 } | |
294 | 312 |
295 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); | 313 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); |
296 AppendData(initial_append_size_); | 314 AppendData(initial_append_size_); |
297 } | 315 } |
298 | 316 |
299 void DemuxerNeedKey(const std::string& type, | 317 void DemuxerNeedKey(const std::string& type, |
300 const std::vector<uint8>& init_data) { | 318 const std::vector<uint8>& init_data) { |
301 DCHECK(!init_data.empty()); | 319 DCHECK(!init_data.empty()); |
302 CHECK(!need_key_cb_.is_null()); | 320 CHECK(!need_key_cb_.is_null()); |
303 need_key_cb_.Run(std::string(), type, init_data); | 321 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, | 638 EXPECT_EQ(k320WebMFileDurationMs, |
621 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 639 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
622 | 640 |
623 Play(); | 641 Play(); |
624 | 642 |
625 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); | 643 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); |
626 source.Abort(); | 644 source.Abort(); |
627 } | 645 } |
628 | 646 |
629 #if defined(USE_PROPRIETARY_CODECS) | 647 #if defined(USE_PROPRIETARY_CODECS) |
648 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { | |
649 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); | |
650 StartPipelineWithMediaSource(&source); | |
651 source.EndOfStream(); | |
652 | |
653 Play(); | |
654 | |
655 EXPECT_TRUE(WaitUntilOnEnded()); | |
656 } | |
657 | |
658 | |
659 TEST_F(PipelineIntegrationTest, MediaSource_MP3_Icecast) { | |
660 MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile); | |
661 StartPipelineWithMediaSource(&source); | |
662 source.EndOfStream(); | |
663 | |
664 Play(); | |
665 | |
666 EXPECT_TRUE(WaitUntilOnEnded()); | |
667 } | |
668 | |
630 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { | 669 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { |
631 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4, kAppendWholeFile); | 670 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4, kAppendWholeFile); |
632 StartPipelineWithMediaSource(&source); | 671 StartPipelineWithMediaSource(&source); |
633 | 672 |
634 scoped_refptr<DecoderBuffer> second_file = | 673 scoped_refptr<DecoderBuffer> second_file = |
635 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 674 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
636 | 675 |
637 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | 676 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
638 second_file->data(), second_file->data_size()); | 677 second_file->data(), second_file->data_size()); |
639 | 678 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 | 1012 |
974 // Verify that VP8 video with inband text track can be played back. | 1013 // Verify that VP8 video with inband text track can be played back. |
975 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8_WebVTT_WebM) { | 1014 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8_WebVTT_WebM) { |
976 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), | 1015 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), |
977 PIPELINE_OK)); | 1016 PIPELINE_OK)); |
978 Play(); | 1017 Play(); |
979 ASSERT_TRUE(WaitUntilOnEnded()); | 1018 ASSERT_TRUE(WaitUntilOnEnded()); |
980 } | 1019 } |
981 | 1020 |
982 } // namespace media | 1021 } // namespace media |
OLD | NEW |