| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 ASSERT_TRUE(Start(GetTestDataURL("bear-320x240.webm"), PIPELINE_OK, true)); | 260 ASSERT_TRUE(Start(GetTestDataURL("bear-320x240.webm"), PIPELINE_OK, true)); |
| 257 | 261 |
| 258 Play(); | 262 Play(); |
| 259 | 263 |
| 260 ASSERT_TRUE(WaitUntilOnEnded()); | 264 ASSERT_TRUE(WaitUntilOnEnded()); |
| 261 | 265 |
| 262 EXPECT_EQ(GetVideoHash(), "f0be120a90a811506777c99a2cdf7cc1"); | 266 EXPECT_EQ(GetVideoHash(), "f0be120a90a811506777c99a2cdf7cc1"); |
| 263 EXPECT_EQ(GetAudioHash(), "6138555be3389e6aba4c8e6f70195d50"); | 267 EXPECT_EQ(GetAudioHash(), "6138555be3389e6aba4c8e6f70195d50"); |
| 264 } | 268 } |
| 265 | 269 |
| 266 TEST_F(PipelineIntegrationTest, EncryptedPlayback) { | 270 // TODO(fgalligan): Enable test when encrypted test data is updated and new |
| 271 // decryption code is landed. http://crbug.com/132801 |
| 272 TEST_F(PipelineIntegrationTest, DISABLED_EncryptedPlayback) { |
| 267 MockMediaSource source("bear-320x240-encrypted.webm", 219726, true, true); | 273 MockMediaSource source("bear-320x240-encrypted.webm", 219726, true, true); |
| 268 FakeDecryptorClient encrypted_media; | 274 FakeDecryptorClient encrypted_media; |
| 269 StartPipelineWithEncryptedMedia(&source, &encrypted_media); | 275 StartPipelineWithEncryptedMedia(&source, &encrypted_media); |
| 270 | 276 |
| 271 source.EndOfStream(); | 277 source.EndOfStream(); |
| 272 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 278 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
| 273 | 279 |
| 274 Play(); | 280 Play(); |
| 275 | 281 |
| 276 ASSERT_TRUE(WaitUntilOnEnded()); | 282 ASSERT_TRUE(WaitUntilOnEnded()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 338 |
| 333 // Verify video decoder & renderer can handle aborted demuxer reads. | 339 // Verify video decoder & renderer can handle aborted demuxer reads. |
| 334 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 340 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
| 335 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, | 341 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, |
| 336 base::TimeDelta::FromMilliseconds(200), | 342 base::TimeDelta::FromMilliseconds(200), |
| 337 base::TimeDelta::FromMilliseconds(1668), | 343 base::TimeDelta::FromMilliseconds(1668), |
| 338 0x1C896, 65536, false, true)); | 344 0x1C896, 65536, false, true)); |
| 339 } | 345 } |
| 340 | 346 |
| 341 } // namespace media | 347 } // namespace media |
| OLD | NEW |