| 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/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "media/base/decoder_buffer.h" | 9 #include "media/base/decoder_buffer.h" |
| 10 #include "media/base/decryptor_client.h" | 10 #include "media/base/decryptor_client.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 size_t quote1 = mimetype_.find("\""); | 113 size_t quote1 = mimetype_.find("\""); |
| 114 size_t quote2 = mimetype_.find("\"", quote1 + 1); | 114 size_t quote2 = mimetype_.find("\"", quote1 + 1); |
| 115 std::string codecStr = mimetype_.substr(quote1 + 1, quote2 - quote1 - 1); | 115 std::string codecStr = mimetype_.substr(quote1 + 1, quote2 - quote1 - 1); |
| 116 std::vector<std::string> codecs; | 116 std::vector<std::string> codecs; |
| 117 Tokenize(codecStr, ",", &codecs); | 117 Tokenize(codecStr, ",", &codecs); |
| 118 | 118 |
| 119 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); | 119 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); |
| 120 AppendData(initial_append_size_); | 120 AppendData(initial_append_size_); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void DemuxerNeedKey(scoped_array<uint8> init_data, int init_data_size) { | 123 void DemuxerNeedKey(const std::string& type, |
| 124 scoped_array<uint8> init_data, int init_data_size) { |
| 124 DCHECK(init_data.get()); | 125 DCHECK(init_data.get()); |
| 125 DCHECK_GT(init_data_size, 0); | 126 DCHECK_GT(init_data_size, 0); |
| 126 DCHECK(decryptor_client_); | 127 DCHECK(decryptor_client_); |
| 127 decryptor_client_->NeedKey("", "", init_data.Pass(), init_data_size); | 128 decryptor_client_->NeedKey("", "", type, init_data.Pass(), init_data_size); |
| 128 } | 129 } |
| 129 | 130 |
| 130 private: | 131 private: |
| 131 std::string url_; | 132 std::string url_; |
| 132 scoped_refptr<DecoderBuffer> file_data_; | 133 scoped_refptr<DecoderBuffer> file_data_; |
| 133 int current_position_; | 134 int current_position_; |
| 134 int initial_append_size_; | 135 int initial_append_size_; |
| 135 std::string mimetype_; | 136 std::string mimetype_; |
| 136 scoped_refptr<ChunkDemuxer> chunk_demuxer_; | 137 scoped_refptr<ChunkDemuxer> chunk_demuxer_; |
| 137 DecryptorClient* decryptor_client_; | 138 DecryptorClient* decryptor_client_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 168 EXPECT_FALSE(session_id.empty()); | 169 EXPECT_FALSE(session_id.empty()); |
| 169 EXPECT_TRUE(message.get()); | 170 EXPECT_TRUE(message.get()); |
| 170 EXPECT_GT(message_length, 0); | 171 EXPECT_GT(message_length, 0); |
| 171 | 172 |
| 172 current_key_system_ = key_system; | 173 current_key_system_ = key_system; |
| 173 current_session_id_ = session_id; | 174 current_session_id_ = session_id; |
| 174 } | 175 } |
| 175 | 176 |
| 176 virtual void NeedKey(const std::string& key_system, | 177 virtual void NeedKey(const std::string& key_system, |
| 177 const std::string& session_id, | 178 const std::string& session_id, |
| 179 const std::string& type, |
| 178 scoped_array<uint8> init_data, | 180 scoped_array<uint8> init_data, |
| 179 int init_data_length) { | 181 int init_data_length) { |
| 180 current_key_system_ = key_system; | 182 current_key_system_ = key_system; |
| 181 current_session_id_ = session_id; | 183 current_session_id_ = session_id; |
| 182 | 184 |
| 183 // When NeedKey is called from the demuxer, the |key_system| will be empty. | 185 // When NeedKey is called from the demuxer, the |key_system| will be empty. |
| 184 // In this case, we need to call GenerateKeyRequest() to initialize a | 186 // In this case, we need to call GenerateKeyRequest() to initialize a |
| 185 // session (which will call KeyMessage). | 187 // session (which will call KeyMessage). |
| 186 if (current_key_system_.empty()) { | 188 if (current_key_system_.empty()) { |
| 187 DCHECK(current_session_id_.empty()); | 189 DCHECK(current_session_id_.empty()); |
| 188 EXPECT_TRUE(decryptor_.GenerateKeyRequest( | 190 EXPECT_TRUE(decryptor_.GenerateKeyRequest( |
| 189 kClearKeySystem, kInitData, arraysize(kInitData))); | 191 kClearKeySystem, type, kInitData, arraysize(kInitData))); |
| 190 } | 192 } |
| 191 | 193 |
| 192 EXPECT_FALSE(current_key_system_.empty()); | 194 EXPECT_FALSE(current_key_system_.empty()); |
| 193 EXPECT_FALSE(current_session_id_.empty()); | 195 EXPECT_FALSE(current_session_id_.empty()); |
| 194 decryptor_.AddKey(current_key_system_, kSecretKey, arraysize(kSecretKey), | 196 decryptor_.AddKey(current_key_system_, kSecretKey, arraysize(kSecretKey), |
| 195 init_data.get(), init_data_length, current_session_id_); | 197 init_data.get(), init_data_length, current_session_id_); |
| 196 } | 198 } |
| 197 | 199 |
| 198 private: | 200 private: |
| 199 AesDecryptor decryptor_; | 201 AesDecryptor decryptor_; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 // Verify video decoder & renderer can handle aborted demuxer reads. | 441 // Verify video decoder & renderer can handle aborted demuxer reads. |
| 440 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 442 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
| 441 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, | 443 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, |
| 442 32768, | 444 32768, |
| 443 base::TimeDelta::FromMilliseconds(200), | 445 base::TimeDelta::FromMilliseconds(200), |
| 444 base::TimeDelta::FromMilliseconds(1668), | 446 base::TimeDelta::FromMilliseconds(1668), |
| 445 0x1C896, 65536)); | 447 0x1C896, 65536)); |
| 446 } | 448 } |
| 447 | 449 |
| 448 } // namespace media | 450 } // namespace media |
| OLD | NEW |