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 "media/base/decoder_buffer.h" | 8 #include "media/base/decoder_buffer.h" |
9 #include "media/base/decryptor_client.h" | 9 #include "media/base/decryptor_client.h" |
10 #include "media/base/mock_filters.h" | 10 #include "media/base/mock_filters.h" |
11 #include "media/base/test_data_util.h" | 11 #include "media/base/test_data_util.h" |
12 #include "media/crypto/aes_decryptor.h" | 12 #include "media/crypto/aes_decryptor.h" |
13 #include "media/filters/chunk_demuxer_client.h" | 13 #include "media/filters/chunk_demuxer_client.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 static const char kSourceId[] = "SourceId"; | 17 static const char kSourceId[] = "SourceId"; |
18 static const char kClearKeySystem[] = "org.w3.clearkey"; | 18 static const char kClearKeySystem[] = "org.w3.clearkey"; |
19 static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; | 19 static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; |
20 | 20 |
21 // Key used to encrypt video track in test file "bear-320x240-encrypted.webm". | |
22 static const uint8 kSecretKey[] = { | |
23 0xfb, 0x67, 0x8a, 0x91, 0x19, 0x12, 0x7b, 0x6b, | |
24 0x0b, 0x63, 0x11, 0xf8, 0x6f, 0xe1, 0xc4, 0x2d | |
25 }; | |
26 | |
27 // Helper class that emulates calls made on the ChunkDemuxer by the | 21 // Helper class that emulates calls made on the ChunkDemuxer by the |
28 // Media Source API. | 22 // Media Source API. |
29 class MockMediaSource : public ChunkDemuxerClient { | 23 class MockMediaSource : public ChunkDemuxerClient { |
30 public: | 24 public: |
31 MockMediaSource(const std::string& filename, int initial_append_size, | 25 MockMediaSource(const std::string& filename, int initial_append_size, |
32 bool has_audio, bool has_video) | 26 bool has_audio, bool has_video) |
33 : url_(GetTestDataURL(filename)), | 27 : url_(GetTestDataURL(filename)), |
34 current_position_(0), | 28 current_position_(0), |
35 initial_append_size_(initial_append_size), | 29 initial_append_size_(initial_append_size), |
36 has_audio_(has_audio), | 30 has_audio_(has_audio), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 AppendData(initial_append_size_); | 89 AppendData(initial_append_size_); |
96 } | 90 } |
97 | 91 |
98 virtual void DemuxerClosed() { | 92 virtual void DemuxerClosed() { |
99 chunk_demuxer_ = NULL; | 93 chunk_demuxer_ = NULL; |
100 } | 94 } |
101 | 95 |
102 virtual void DemuxerNeedKey(scoped_array<uint8> init_data, | 96 virtual void DemuxerNeedKey(scoped_array<uint8> init_data, |
103 int init_data_size) { | 97 int init_data_size) { |
104 DCHECK(init_data.get()); | 98 DCHECK(init_data.get()); |
105 DCHECK_GT(init_data_size, 0); | 99 DCHECK_EQ(init_data_size, 16); |
106 DCHECK(decryptor_client_); | 100 DCHECK(decryptor_client_); |
107 decryptor_client_->NeedKey("", "", init_data.Pass(), init_data_size); | 101 decryptor_client_->NeedKey("", "", init_data.Pass(), init_data_size); |
108 } | 102 } |
109 | 103 |
110 private: | 104 private: |
111 std::string url_; | 105 std::string url_; |
112 scoped_refptr<DecoderBuffer> file_data_; | 106 scoped_refptr<DecoderBuffer> file_data_; |
113 int current_position_; | 107 int current_position_; |
114 int initial_append_size_; | 108 int initial_append_size_; |
115 bool has_audio_; | 109 bool has_audio_; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // In this case, we need to call GenerateKeyRequest() to initialize a | 159 // In this case, we need to call GenerateKeyRequest() to initialize a |
166 // session (which will call KeyMessage). | 160 // session (which will call KeyMessage). |
167 if (current_key_system_.empty()) { | 161 if (current_key_system_.empty()) { |
168 DCHECK(current_session_id_.empty()); | 162 DCHECK(current_session_id_.empty()); |
169 decryptor_.GenerateKeyRequest(kClearKeySystem, | 163 decryptor_.GenerateKeyRequest(kClearKeySystem, |
170 kInitData, arraysize(kInitData)); | 164 kInitData, arraysize(kInitData)); |
171 } | 165 } |
172 | 166 |
173 EXPECT_FALSE(current_key_system_.empty()); | 167 EXPECT_FALSE(current_key_system_.empty()); |
174 EXPECT_FALSE(current_session_id_.empty()); | 168 EXPECT_FALSE(current_session_id_.empty()); |
175 decryptor_.AddKey(current_key_system_, kSecretKey, arraysize(kSecretKey), | 169 // In test file bear-320x240-encrypted.webm, the decryption key is equal to |
| 170 // |init_data|. |
| 171 decryptor_.AddKey(current_key_system_, init_data.get(), init_data_length, |
176 init_data.get(), init_data_length, current_session_id_); | 172 init_data.get(), init_data_length, current_session_id_); |
177 } | 173 } |
178 | 174 |
179 private: | 175 private: |
180 AesDecryptor decryptor_; | 176 AesDecryptor decryptor_; |
181 std::string current_key_system_; | 177 std::string current_key_system_; |
182 std::string current_session_id_; | 178 std::string current_session_id_; |
183 }; | 179 }; |
184 | 180 |
185 class PipelineIntegrationTest | 181 class PipelineIntegrationTest |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); | 273 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds(), 0); |
278 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 2737); | 274 EXPECT_EQ(pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds(), 2737); |
279 | 275 |
280 Play(); | 276 Play(); |
281 | 277 |
282 ASSERT_TRUE(WaitUntilOnEnded()); | 278 ASSERT_TRUE(WaitUntilOnEnded()); |
283 source.Abort(); | 279 source.Abort(); |
284 Stop(); | 280 Stop(); |
285 } | 281 } |
286 | 282 |
287 // TODO(fgalligan): Enable test when encrypted test data is updated and new | 283 TEST_F(PipelineIntegrationTest, EncryptedPlayback) { |
288 // decryption code is landed. http://crbug.com/132801 | |
289 TEST_F(PipelineIntegrationTest, DISABLED_EncryptedPlayback) { | |
290 MockMediaSource source("bear-320x240-encrypted.webm", 219726, true, true); | 284 MockMediaSource source("bear-320x240-encrypted.webm", 219726, true, true); |
291 FakeDecryptorClient encrypted_media; | 285 FakeDecryptorClient encrypted_media; |
292 StartPipelineWithEncryptedMedia(&source, &encrypted_media); | 286 StartPipelineWithEncryptedMedia(&source, &encrypted_media); |
293 | 287 |
294 source.EndOfStream(); | 288 source.EndOfStream(); |
295 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 289 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
296 | 290 |
297 Play(); | 291 Play(); |
298 | 292 |
299 ASSERT_TRUE(WaitUntilOnEnded()); | 293 ASSERT_TRUE(WaitUntilOnEnded()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 349 |
356 // Verify video decoder & renderer can handle aborted demuxer reads. | 350 // Verify video decoder & renderer can handle aborted demuxer reads. |
357 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 351 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
358 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, | 352 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, |
359 base::TimeDelta::FromMilliseconds(200), | 353 base::TimeDelta::FromMilliseconds(200), |
360 base::TimeDelta::FromMilliseconds(1668), | 354 base::TimeDelta::FromMilliseconds(1668), |
361 0x1C896, 65536, false, true)); | 355 0x1C896, 65536, false, true)); |
362 } | 356 } |
363 | 357 |
364 } // namespace media | 358 } // namespace media |
OLD | NEW |