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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 void OnSessionKeysChange(const std::string& session_id, | 295 void OnSessionKeysChange(const std::string& session_id, |
296 bool has_additional_usable_key, | 296 bool has_additional_usable_key, |
297 CdmKeysInfo keys_info) override { | 297 CdmKeysInfo keys_info) override { |
298 EXPECT_EQ(current_session_id_, session_id); | 298 EXPECT_EQ(current_session_id_, session_id); |
299 EXPECT_EQ(has_additional_usable_key, true); | 299 EXPECT_EQ(has_additional_usable_key, true); |
300 } | 300 } |
301 | 301 |
302 void OnEncryptedMediaInitData(const std::string& init_data_type, | 302 void OnEncryptedMediaInitData(const std::string& init_data_type, |
303 const std::vector<uint8>& init_data, | 303 const std::vector<uint8>& init_data, |
304 AesDecryptor* decryptor) override { | 304 AesDecryptor* decryptor) override { |
| 305 // Since only 1 session is created, skip the request if the |init_data| |
| 306 // has been seen before (no need to add the same key again). |
| 307 if (init_data == prev_init_data_) |
| 308 return; |
| 309 prev_init_data_ = init_data; |
| 310 |
305 if (current_session_id_.empty()) { | 311 if (current_session_id_.empty()) { |
306 if (init_data_type == kCencInitDataType) { | 312 if (init_data_type == kCencInitDataType) { |
307 // Since the 'cenc' files are not created with proper 'pssh' boxes, | 313 // Since the 'cenc' files are not created with proper 'pssh' boxes, |
308 // simply pretend that this is a webm file and pass the expected | 314 // simply pretend that this is a webm file and pass the expected |
309 // key ID as the init_data. | 315 // key ID as the init_data. |
310 // http://crbug.com/460308 | 316 // http://crbug.com/460308 |
311 decryptor->CreateSessionAndGenerateRequest( | 317 decryptor->CreateSessionAndGenerateRequest( |
312 MediaKeys::TEMPORARY_SESSION, "webm", kKeyId, arraysize(kKeyId), | 318 MediaKeys::TEMPORARY_SESSION, "webm", kKeyId, arraysize(kKeyId), |
313 CreateSessionPromise(RESOLVED)); | 319 CreateSessionPromise(RESOLVED)); |
314 } else { | 320 } else { |
(...skipping 18 matching lines...) Expand all Loading... |
333 // Convert key into a JSON structure and then add it. | 339 // Convert key into a JSON structure and then add it. |
334 std::string jwk = GenerateJWKSet( | 340 std::string jwk = GenerateJWKSet( |
335 kSecretKey, arraysize(kSecretKey), key_id, key_id_length); | 341 kSecretKey, arraysize(kSecretKey), key_id, key_id_length); |
336 decryptor->UpdateSession(current_session_id_, | 342 decryptor->UpdateSession(current_session_id_, |
337 reinterpret_cast<const uint8*>(jwk.data()), | 343 reinterpret_cast<const uint8*>(jwk.data()), |
338 jwk.size(), | 344 jwk.size(), |
339 CreatePromise(RESOLVED)); | 345 CreatePromise(RESOLVED)); |
340 } | 346 } |
341 | 347 |
342 std::string current_session_id_; | 348 std::string current_session_id_; |
| 349 std::vector<uint8> prev_init_data_; |
343 }; | 350 }; |
344 | 351 |
345 class RotatingKeyProvidingApp : public KeyProvidingApp { | 352 class RotatingKeyProvidingApp : public KeyProvidingApp { |
346 public: | 353 public: |
347 RotatingKeyProvidingApp() : num_distint_need_key_calls_(0) {} | 354 RotatingKeyProvidingApp() : num_distint_need_key_calls_(0) {} |
348 ~RotatingKeyProvidingApp() override { | 355 ~RotatingKeyProvidingApp() override { |
349 // Expect that OnEncryptedMediaInitData is fired multiple times with | 356 // Expect that OnEncryptedMediaInitData is fired multiple times with |
350 // different |init_data|. | 357 // different |init_data|. |
351 EXPECT_GT(num_distint_need_key_calls_, 1u); | 358 EXPECT_GT(num_distint_need_key_calls_, 1u); |
352 } | 359 } |
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 | 1742 |
1736 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 1743 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
1737 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 1744 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
1738 Play(); | 1745 Play(); |
1739 ASSERT_TRUE(WaitUntilOnEnded()); | 1746 ASSERT_TRUE(WaitUntilOnEnded()); |
1740 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 1747 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
1741 demuxer_->GetStartTime()); | 1748 demuxer_->GetStartTime()); |
1742 } | 1749 } |
1743 | 1750 |
1744 } // namespace media | 1751 } // namespace media |
OLD | NEW |