| 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" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "media/base/cdm_callback_promise.h" | 10 #include "media/base/cdm_callback_promise.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // They do not exercise the Decrypting{Audio|Video}Decoder path. | 141 // They do not exercise the Decrypting{Audio|Video}Decoder path. |
| 142 class FakeEncryptedMedia { | 142 class FakeEncryptedMedia { |
| 143 public: | 143 public: |
| 144 // Defines the behavior of the "app" that responds to EME events. | 144 // Defines the behavior of the "app" that responds to EME events. |
| 145 class AppBase { | 145 class AppBase { |
| 146 public: | 146 public: |
| 147 virtual ~AppBase() {} | 147 virtual ~AppBase() {} |
| 148 | 148 |
| 149 virtual void OnSessionMessage(const std::string& web_session_id, | 149 virtual void OnSessionMessage(const std::string& web_session_id, |
| 150 MediaKeys::MessageType message_type, | 150 MediaKeys::MessageType message_type, |
| 151 const std::vector<uint8>& message) = 0; | 151 const std::vector<uint8>& message, |
| 152 const GURL& legacy_destination_url) = 0; |
| 152 | 153 |
| 153 virtual void OnSessionClosed(const std::string& web_session_id) = 0; | 154 virtual void OnSessionClosed(const std::string& web_session_id) = 0; |
| 154 | 155 |
| 155 virtual void OnSessionKeysChange(const std::string& web_session_id, | 156 virtual void OnSessionKeysChange(const std::string& web_session_id, |
| 156 bool has_additional_usable_key, | 157 bool has_additional_usable_key, |
| 157 CdmKeysInfo keys_info) = 0; | 158 CdmKeysInfo keys_info) = 0; |
| 158 | 159 |
| 159 // Errors are not expected unless overridden. | 160 // Errors are not expected unless overridden. |
| 160 virtual void OnSessionError(const std::string& web_session_id, | 161 virtual void OnSessionError(const std::string& web_session_id, |
| 161 const std::string& error_name, | 162 const std::string& error_name, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 177 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange, | 178 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange, |
| 178 base::Unretained(this))), | 179 base::Unretained(this))), |
| 179 cdm_context_(&decryptor_), | 180 cdm_context_(&decryptor_), |
| 180 app_(app) {} | 181 app_(app) {} |
| 181 | 182 |
| 182 CdmContext* GetCdmContext() { return &cdm_context_; } | 183 CdmContext* GetCdmContext() { return &cdm_context_; } |
| 183 | 184 |
| 184 // Callbacks for firing session events. Delegate to |app_|. | 185 // Callbacks for firing session events. Delegate to |app_|. |
| 185 void OnSessionMessage(const std::string& web_session_id, | 186 void OnSessionMessage(const std::string& web_session_id, |
| 186 MediaKeys::MessageType message_type, | 187 MediaKeys::MessageType message_type, |
| 187 const std::vector<uint8>& message) { | 188 const std::vector<uint8>& message, |
| 188 app_->OnSessionMessage(web_session_id, message_type, message); | 189 const GURL& legacy_destination_url) { |
| 190 app_->OnSessionMessage(web_session_id, message_type, message, |
| 191 legacy_destination_url); |
| 189 } | 192 } |
| 190 | 193 |
| 191 void OnSessionClosed(const std::string& web_session_id) { | 194 void OnSessionClosed(const std::string& web_session_id) { |
| 192 app_->OnSessionClosed(web_session_id); | 195 app_->OnSessionClosed(web_session_id); |
| 193 } | 196 } |
| 194 | 197 |
| 195 void OnSessionKeysChange(const std::string& web_session_id, | 198 void OnSessionKeysChange(const std::string& web_session_id, |
| 196 bool has_additional_usable_key, | 199 bool has_additional_usable_key, |
| 197 CdmKeysInfo keys_info) { | 200 CdmKeysInfo keys_info) { |
| 198 app_->OnSessionKeysChange(web_session_id, has_additional_usable_key, | 201 app_->OnSessionKeysChange(web_session_id, has_additional_usable_key, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 base::Bind(&KeyProvidingApp::OnResolveWithSession, | 276 base::Bind(&KeyProvidingApp::OnResolveWithSession, |
| 274 base::Unretained(this), | 277 base::Unretained(this), |
| 275 expected), | 278 expected), |
| 276 base::Bind( | 279 base::Bind( |
| 277 &KeyProvidingApp::OnReject, base::Unretained(this), expected))); | 280 &KeyProvidingApp::OnReject, base::Unretained(this), expected))); |
| 278 return promise.Pass(); | 281 return promise.Pass(); |
| 279 } | 282 } |
| 280 | 283 |
| 281 void OnSessionMessage(const std::string& web_session_id, | 284 void OnSessionMessage(const std::string& web_session_id, |
| 282 MediaKeys::MessageType message_type, | 285 MediaKeys::MessageType message_type, |
| 283 const std::vector<uint8>& message) override { | 286 const std::vector<uint8>& message, |
| 287 const GURL& legacy_destination_url) override { |
| 284 EXPECT_FALSE(web_session_id.empty()); | 288 EXPECT_FALSE(web_session_id.empty()); |
| 285 EXPECT_FALSE(message.empty()); | 289 EXPECT_FALSE(message.empty()); |
| 286 EXPECT_EQ(current_session_id_, web_session_id); | 290 EXPECT_EQ(current_session_id_, web_session_id); |
| 287 } | 291 } |
| 288 | 292 |
| 289 void OnSessionClosed(const std::string& web_session_id) override { | 293 void OnSessionClosed(const std::string& web_session_id) override { |
| 290 EXPECT_EQ(current_session_id_, web_session_id); | 294 EXPECT_EQ(current_session_id_, web_session_id); |
| 291 } | 295 } |
| 292 | 296 |
| 293 void OnSessionKeysChange(const std::string& web_session_id, | 297 void OnSessionKeysChange(const std::string& web_session_id, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 403 |
| 400 std::vector<uint8> prev_init_data_; | 404 std::vector<uint8> prev_init_data_; |
| 401 uint32 num_distint_need_key_calls_; | 405 uint32 num_distint_need_key_calls_; |
| 402 }; | 406 }; |
| 403 | 407 |
| 404 // Ignores needkey and does not perform a license request | 408 // Ignores needkey and does not perform a license request |
| 405 class NoResponseApp : public FakeEncryptedMedia::AppBase { | 409 class NoResponseApp : public FakeEncryptedMedia::AppBase { |
| 406 public: | 410 public: |
| 407 void OnSessionMessage(const std::string& web_session_id, | 411 void OnSessionMessage(const std::string& web_session_id, |
| 408 MediaKeys::MessageType message_type, | 412 MediaKeys::MessageType message_type, |
| 409 const std::vector<uint8>& message) override { | 413 const std::vector<uint8>& message, |
| 414 const GURL& legacy_destination_url) override { |
| 410 EXPECT_FALSE(web_session_id.empty()); | 415 EXPECT_FALSE(web_session_id.empty()); |
| 411 EXPECT_FALSE(message.empty()); | 416 EXPECT_FALSE(message.empty()); |
| 412 FAIL() << "Unexpected Message"; | 417 FAIL() << "Unexpected Message"; |
| 413 } | 418 } |
| 414 | 419 |
| 415 void OnSessionClosed(const std::string& web_session_id) override { | 420 void OnSessionClosed(const std::string& web_session_id) override { |
| 416 EXPECT_FALSE(web_session_id.empty()); | 421 EXPECT_FALSE(web_session_id.empty()); |
| 417 FAIL() << "Unexpected Closed"; | 422 FAIL() << "Unexpected Closed"; |
| 418 } | 423 } |
| 419 | 424 |
| (...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 | 1695 |
| 1691 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 1696 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 1692 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 1697 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 1693 Play(); | 1698 Play(); |
| 1694 ASSERT_TRUE(WaitUntilOnEnded()); | 1699 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1695 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 1700 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 1696 demuxer_->GetStartTime()); | 1701 demuxer_->GetStartTime()); |
| 1697 } | 1702 } |
| 1698 | 1703 |
| 1699 } // namespace media | 1704 } // namespace media |
| OLD | NEW |