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