| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\""; | 106 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\""; |
| 107 const char kMP4VideoVP9[] = "video/mp4; codecs=\"vp09.00.00.08.01.01.00.00\""; | 107 const char kMP4VideoVP9[] = "video/mp4; codecs=\"vp09.00.00.08.01.01.00.00\""; |
| 108 const char kMP4VideoHEVC1[] = "video/mp4; codecs=\"hvc1.1.6.L93.B0\""; | 108 const char kMP4VideoHEVC1[] = "video/mp4; codecs=\"hvc1.1.6.L93.B0\""; |
| 109 const char kMP4VideoHEVC2[] = "video/mp4; codecs=\"hev1.1.6.L93.B0\""; | 109 const char kMP4VideoHEVC2[] = "video/mp4; codecs=\"hev1.1.6.L93.B0\""; |
| 110 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; | 110 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; |
| 111 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; | 111 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
| 112 const char kMP3[] = "audio/mpeg"; | 112 const char kMP3[] = "audio/mpeg"; |
| 113 const char kMP2AudioSBR[] = "video/mp2t; codecs=\"avc1.4D4041,mp4a.40.5\""; | 113 const char kMP2AudioSBR[] = "video/mp2t; codecs=\"avc1.4D4041,mp4a.40.5\""; |
| 114 #endif // defined(USE_PROPRIETARY_CODECS) | 114 #endif // defined(USE_PROPRIETARY_CODECS) |
| 115 | 115 |
| 116 // Key used to encrypt test files. | |
| 117 const uint8_t kSecretKey[] = {0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, | |
| 118 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c}; | |
| 119 | |
| 120 // The key ID for all encrypted files. | |
| 121 const uint8_t kKeyId[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, | |
| 122 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35}; | |
| 123 | |
| 124 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); | 116 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); |
| 125 | 117 |
| 126 // Constants for the Media Source config change tests. | 118 // Constants for the Media Source config change tests. |
| 127 const int kAppendTimeSec = 1; | 119 const int kAppendTimeSec = 1; |
| 128 const int kAppendTimeMs = kAppendTimeSec * 1000; | 120 const int kAppendTimeMs = kAppendTimeSec * 1000; |
| 129 const int k320WebMFileDurationMs = 2736; | 121 const int k320WebMFileDurationMs = 2736; |
| 130 const int k320EncWebMFileDurationMs = 2737; | 122 const int k320EncWebMFileDurationMs = 2737; |
| 131 const int k640WebMFileDurationMs = 2749; | 123 const int k640WebMFileDurationMs = 2749; |
| 132 const int kOpusEndTrimmingWebMFileDurationMs = 2741; | 124 const int kOpusEndTrimmingWebMFileDurationMs = 2741; |
| 133 const int kVP9WebMFileDurationMs = 2736; | 125 const int kVP9WebMFileDurationMs = 2736; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 Decryptor* decryptor_; | 250 Decryptor* decryptor_; |
| 259 }; | 251 }; |
| 260 | 252 |
| 261 scoped_refptr<AesDecryptor> decryptor_; | 253 scoped_refptr<AesDecryptor> decryptor_; |
| 262 TestCdmContext cdm_context_; | 254 TestCdmContext cdm_context_; |
| 263 std::unique_ptr<AppBase> app_; | 255 std::unique_ptr<AppBase> app_; |
| 264 }; | 256 }; |
| 265 | 257 |
| 266 enum PromiseResult { RESOLVED, REJECTED }; | 258 enum PromiseResult { RESOLVED, REJECTED }; |
| 267 | 259 |
| 268 // Provides |kSecretKey| in response to the encrypted event. | 260 // Provides the test key in response to the encrypted event. |
| 269 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { | 261 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { |
| 270 public: | 262 public: |
| 271 KeyProvidingApp() {} | 263 KeyProvidingApp() {} |
| 272 | 264 |
| 273 void OnResolveWithSession(PromiseResult expected, | 265 void OnResolveWithSession(PromiseResult expected, |
| 274 const std::string& session_id) { | 266 const std::string& session_id) { |
| 275 EXPECT_EQ(expected, RESOLVED); | 267 EXPECT_EQ(expected, RESOLVED); |
| 276 EXPECT_GT(session_id.length(), 0ul); | 268 EXPECT_GT(session_id.length(), 0ul); |
| 277 current_session_id_ = session_id; | 269 current_session_id_ = session_id; |
| 278 } | 270 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 if (current_session_id_.empty()) { | 353 if (current_session_id_.empty()) { |
| 362 decryptor->CreateSessionAndGenerateRequest( | 354 decryptor->CreateSessionAndGenerateRequest( |
| 363 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data, | 355 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data, |
| 364 CreateSessionPromise(RESOLVED)); | 356 CreateSessionPromise(RESOLVED)); |
| 365 EXPECT_FALSE(current_session_id_.empty()); | 357 EXPECT_FALSE(current_session_id_.empty()); |
| 366 } | 358 } |
| 367 } | 359 } |
| 368 | 360 |
| 369 virtual bool LookupKey(const std::vector<uint8_t>& key_id, | 361 virtual bool LookupKey(const std::vector<uint8_t>& key_id, |
| 370 std::vector<uint8_t>* key) { | 362 std::vector<uint8_t>* key) { |
| 371 // As there is no key rotation, the key ID provided should be |kKeyId| | 363 // No key rotation. |
| 372 // which uses |kSecretKey| as the key. | 364 return LookupTestKeyVector(key_id, false, key); |
| 373 EXPECT_EQ(std::vector<uint8_t>(kKeyId, kKeyId + arraysize(kKeyId)), key_id); | |
| 374 key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey)); | |
| 375 return true; | |
| 376 } | 365 } |
| 377 | 366 |
| 378 std::string current_session_id_; | 367 std::string current_session_id_; |
| 379 std::vector<uint8_t> prev_init_data_; | 368 std::vector<uint8_t> prev_init_data_; |
| 380 }; | 369 }; |
| 381 | 370 |
| 382 class RotatingKeyProvidingApp : public KeyProvidingApp { | 371 class RotatingKeyProvidingApp : public KeyProvidingApp { |
| 383 public: | 372 public: |
| 384 RotatingKeyProvidingApp() : num_distinct_need_key_calls_(0) {} | 373 RotatingKeyProvidingApp() : num_distinct_need_key_calls_(0) {} |
| 385 ~RotatingKeyProvidingApp() override { | 374 ~RotatingKeyProvidingApp() override { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 397 prev_init_data_ = init_data; | 386 prev_init_data_ = init_data; |
| 398 ++num_distinct_need_key_calls_; | 387 ++num_distinct_need_key_calls_; |
| 399 | 388 |
| 400 decryptor->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, | 389 decryptor->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, |
| 401 init_data_type, init_data, | 390 init_data_type, init_data, |
| 402 CreateSessionPromise(RESOLVED)); | 391 CreateSessionPromise(RESOLVED)); |
| 403 } | 392 } |
| 404 | 393 |
| 405 bool LookupKey(const std::vector<uint8_t>& key_id, | 394 bool LookupKey(const std::vector<uint8_t>& key_id, |
| 406 std::vector<uint8_t>* key) override { | 395 std::vector<uint8_t>* key) override { |
| 407 // The Key and KeyId for this testing key provider are created by left | 396 // With key rotation. |
| 408 // rotating |kSecretKey| and |kKeyId|. Note that this implementation is | 397 return LookupTestKeyVector(key_id, true, key); |
| 409 // only intended for testing purpose. The actual key rotation algorithm | |
| 410 // can be much more complicated. | |
| 411 // Find out the rotating position from |starting_key_id| and apply on |key|. | |
| 412 std::vector<uint8_t> starting_key_id(kKeyId, kKeyId + arraysize(kKeyId)); | |
| 413 for (size_t pos = 0; pos < starting_key_id.size(); ++pos) { | |
| 414 std::rotate(starting_key_id.begin(), starting_key_id.begin() + pos, | |
| 415 starting_key_id.end()); | |
| 416 if (key_id == starting_key_id) { | |
| 417 key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey)); | |
| 418 std::rotate(key->begin(), key->begin() + pos, key->end()); | |
| 419 return true; | |
| 420 } | |
| 421 } | |
| 422 return false; | |
| 423 } | 398 } |
| 424 | 399 |
| 425 uint32_t num_distinct_need_key_calls_; | 400 uint32_t num_distinct_need_key_calls_; |
| 426 }; | 401 }; |
| 427 | 402 |
| 428 // Ignores the encrypted event and does not perform a license request. | 403 // Ignores the encrypted event and does not perform a license request. |
| 429 class NoResponseApp : public FakeEncryptedMedia::AppBase { | 404 class NoResponseApp : public FakeEncryptedMedia::AppBase { |
| 430 public: | 405 public: |
| 431 void OnSessionMessage(const std::string& session_id, | 406 void OnSessionMessage(const std::string& session_id, |
| 432 MediaKeys::MessageType message_type, | 407 MediaKeys::MessageType message_type, |
| (...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2508 | 2483 |
| 2509 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2484 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 2510 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2485 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 2511 Play(); | 2486 Play(); |
| 2512 ASSERT_TRUE(WaitUntilOnEnded()); | 2487 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2513 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2488 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 2514 demuxer_->GetStartTime()); | 2489 demuxer_->GetStartTime()); |
| 2515 } | 2490 } |
| 2516 | 2491 |
| 2517 } // namespace media | 2492 } // namespace media |
| OLD | NEW |