Chromium Code Reviews| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
|
jrummell
2015/10/29 21:05:17
#include "base/memory/ref_counted.h"?
xhwang
2015/10/30 16:20:59
Done.
| |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.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/cdm_callback_promise.h" | 12 #include "media/base/cdm_callback_promise.h" |
| 13 #include "media/base/cdm_context.h" | 13 #include "media/base/cdm_context.h" |
| 14 #include "media/base/cdm_key_information.h" | 14 #include "media/base/cdm_key_information.h" |
| 15 #include "media/base/decoder_buffer.h" | 15 #include "media/base/decoder_buffer.h" |
| 16 #include "media/base/media.h" | 16 #include "media/base/media.h" |
| 17 #include "media/base/media_keys.h" | 17 #include "media/base/media_keys.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 const std::string& error_message) { | 195 const std::string& error_message) { |
| 196 FAIL() << "Unexpected Key Error"; | 196 FAIL() << "Unexpected Key Error"; |
| 197 } | 197 } |
| 198 | 198 |
| 199 virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 199 virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
| 200 const std::vector<uint8_t>& init_data, | 200 const std::vector<uint8_t>& init_data, |
| 201 AesDecryptor* decryptor) = 0; | 201 AesDecryptor* decryptor) = 0; |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 FakeEncryptedMedia(AppBase* app) | 204 FakeEncryptedMedia(AppBase* app) |
| 205 : decryptor_(GURL::EmptyGURL(), | 205 : decryptor_(new AesDecryptor( |
| 206 base::Bind(&FakeEncryptedMedia::OnSessionMessage, | 206 GURL::EmptyGURL(), |
| 207 base::Unretained(this)), | 207 base::Bind(&FakeEncryptedMedia::OnSessionMessage, |
| 208 base::Bind(&FakeEncryptedMedia::OnSessionClosed, | 208 base::Unretained(this)), |
| 209 base::Unretained(this)), | 209 base::Bind(&FakeEncryptedMedia::OnSessionClosed, |
| 210 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange, | 210 base::Unretained(this)), |
| 211 base::Unretained(this))), | 211 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange, |
| 212 cdm_context_(&decryptor_), | 212 base::Unretained(this)))), |
| 213 cdm_context_(decryptor_.get()), | |
| 213 app_(app) {} | 214 app_(app) {} |
| 214 | 215 |
| 215 CdmContext* GetCdmContext() { return &cdm_context_; } | 216 CdmContext* GetCdmContext() { return &cdm_context_; } |
| 216 | 217 |
| 217 // Callbacks for firing session events. Delegate to |app_|. | 218 // Callbacks for firing session events. Delegate to |app_|. |
| 218 void OnSessionMessage(const std::string& session_id, | 219 void OnSessionMessage(const std::string& session_id, |
| 219 MediaKeys::MessageType message_type, | 220 MediaKeys::MessageType message_type, |
| 220 const std::vector<uint8_t>& message, | 221 const std::vector<uint8_t>& message, |
| 221 const GURL& legacy_destination_url) { | 222 const GURL& legacy_destination_url) { |
| 222 app_->OnSessionMessage(session_id, message_type, message, | 223 app_->OnSessionMessage(session_id, message_type, message, |
| 223 legacy_destination_url, &decryptor_); | 224 legacy_destination_url, decryptor_.get()); |
| 224 } | 225 } |
| 225 | 226 |
| 226 void OnSessionClosed(const std::string& session_id) { | 227 void OnSessionClosed(const std::string& session_id) { |
| 227 app_->OnSessionClosed(session_id); | 228 app_->OnSessionClosed(session_id); |
| 228 } | 229 } |
| 229 | 230 |
| 230 void OnSessionKeysChange(const std::string& session_id, | 231 void OnSessionKeysChange(const std::string& session_id, |
| 231 bool has_additional_usable_key, | 232 bool has_additional_usable_key, |
| 232 CdmKeysInfo keys_info) { | 233 CdmKeysInfo keys_info) { |
| 233 app_->OnSessionKeysChange(session_id, has_additional_usable_key, | 234 app_->OnSessionKeysChange(session_id, has_additional_usable_key, |
| 234 keys_info.Pass()); | 235 keys_info.Pass()); |
| 235 } | 236 } |
| 236 | 237 |
| 237 void OnLegacySessionError(const std::string& session_id, | 238 void OnLegacySessionError(const std::string& session_id, |
| 238 const std::string& error_name, | 239 const std::string& error_name, |
| 239 uint32_t system_code, | 240 uint32_t system_code, |
| 240 const std::string& error_message) { | 241 const std::string& error_message) { |
| 241 app_->OnLegacySessionError(session_id, error_name, system_code, | 242 app_->OnLegacySessionError(session_id, error_name, system_code, |
| 242 error_message); | 243 error_message); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 246 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
| 246 const std::vector<uint8_t>& init_data) { | 247 const std::vector<uint8_t>& init_data) { |
| 247 app_->OnEncryptedMediaInitData(init_data_type, init_data, &decryptor_); | 248 app_->OnEncryptedMediaInitData(init_data_type, init_data, decryptor_.get()); |
| 248 } | 249 } |
| 249 | 250 |
| 250 private: | 251 private: |
| 251 class TestCdmContext : public CdmContext { | 252 class TestCdmContext : public CdmContext { |
| 252 public: | 253 public: |
| 253 TestCdmContext(Decryptor* decryptor) : decryptor_(decryptor) {} | 254 TestCdmContext(Decryptor* decryptor) : decryptor_(decryptor) {} |
| 254 | 255 |
| 255 Decryptor* GetDecryptor() final { return decryptor_; } | 256 Decryptor* GetDecryptor() final { return decryptor_; } |
| 256 int GetCdmId() const final { return kInvalidCdmId; } | 257 int GetCdmId() const final { return kInvalidCdmId; } |
| 257 | 258 |
| 258 private: | 259 private: |
| 259 Decryptor* decryptor_; | 260 Decryptor* decryptor_; |
| 260 }; | 261 }; |
| 261 | 262 |
| 262 AesDecryptor decryptor_; | 263 scoped_refptr<AesDecryptor> decryptor_; |
| 263 TestCdmContext cdm_context_; | 264 TestCdmContext cdm_context_; |
| 264 scoped_ptr<AppBase> app_; | 265 scoped_ptr<AppBase> app_; |
| 265 }; | 266 }; |
| 266 | 267 |
| 267 enum PromiseResult { RESOLVED, REJECTED }; | 268 enum PromiseResult { RESOLVED, REJECTED }; |
| 268 | 269 |
| 269 // Provides |kSecretKey| in response to needkey. | 270 // Provides |kSecretKey| in response to needkey. |
| 270 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { | 271 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { |
| 271 public: | 272 public: |
| 272 KeyProvidingApp() {} | 273 KeyProvidingApp() {} |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1839 | 1840 |
| 1840 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 1841 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 1841 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 1842 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 1842 Play(); | 1843 Play(); |
| 1843 ASSERT_TRUE(WaitUntilOnEnded()); | 1844 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1844 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 1845 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 1845 demuxer_->GetStartTime()); | 1846 demuxer_->GetStartTime()); |
| 1846 } | 1847 } |
| 1847 | 1848 |
| 1848 } // namespace media | 1849 } // namespace media |
| OLD | NEW |