Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(799)

Side by Side Diff: media/test/pipeline_integration_test.cc

Issue 1517473002: Support HLS MPEG2 TS with SAMPLE-AES encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@encryption_scheme
Patch Set: ddorwin comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; 104 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\"";
105 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\""; 105 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\"";
106 #if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING) 106 #if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
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 #endif 108 #endif
109 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; 109 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\"";
110 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; 110 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\"";
111 const char kMP3[] = "audio/mpeg"; 111 const char kMP3[] = "audio/mpeg";
112 #endif // defined(USE_PROPRIETARY_CODECS) 112 #endif // defined(USE_PROPRIETARY_CODECS)
113 113
114 // Key used to encrypt test files.
115 const uint8_t kSecretKey[] = {0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
116 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c};
117
118 // The key ID for all encrypted files.
119 const uint8_t kKeyId[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
120 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35};
121
122 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); 114 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max();
123 115
124 // Constants for the Media Source config change tests. 116 // Constants for the Media Source config change tests.
125 const int kAppendTimeSec = 1; 117 const int kAppendTimeSec = 1;
126 const int kAppendTimeMs = kAppendTimeSec * 1000; 118 const int kAppendTimeMs = kAppendTimeSec * 1000;
127 const int k320WebMFileDurationMs = 2736; 119 const int k320WebMFileDurationMs = 2736;
128 const int k320EncWebMFileDurationMs = 2737; 120 const int k320EncWebMFileDurationMs = 2737;
129 const int k640WebMFileDurationMs = 2749; 121 const int k640WebMFileDurationMs = 2749;
130 const int kOpusEndTrimmingWebMFileDurationMs = 2741; 122 const int kOpusEndTrimmingWebMFileDurationMs = 2741;
131 const int kVP9WebMFileDurationMs = 2736; 123 const int kVP9WebMFileDurationMs = 2736;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 Decryptor* decryptor_; 275 Decryptor* decryptor_;
284 }; 276 };
285 277
286 scoped_refptr<AesDecryptor> decryptor_; 278 scoped_refptr<AesDecryptor> decryptor_;
287 TestCdmContext cdm_context_; 279 TestCdmContext cdm_context_;
288 std::unique_ptr<AppBase> app_; 280 std::unique_ptr<AppBase> app_;
289 }; 281 };
290 282
291 enum PromiseResult { RESOLVED, REJECTED }; 283 enum PromiseResult { RESOLVED, REJECTED };
292 284
293 // Provides |kSecretKey| in response to the encrypted event. 285 // Provides the test key in response to the encrypted event.
294 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { 286 class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
295 public: 287 public:
296 KeyProvidingApp() {} 288 KeyProvidingApp() {}
297 289
298 void OnResolveWithSession(PromiseResult expected, 290 void OnResolveWithSession(PromiseResult expected,
299 const std::string& session_id) { 291 const std::string& session_id) {
300 EXPECT_EQ(expected, RESOLVED); 292 EXPECT_EQ(expected, RESOLVED);
301 EXPECT_GT(session_id.length(), 0ul); 293 EXPECT_GT(session_id.length(), 0ul);
302 current_session_id_ = session_id; 294 current_session_id_ = session_id;
303 } 295 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 if (current_session_id_.empty()) { 379 if (current_session_id_.empty()) {
388 decryptor->CreateSessionAndGenerateRequest( 380 decryptor->CreateSessionAndGenerateRequest(
389 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data, 381 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data,
390 CreateSessionPromise(RESOLVED)); 382 CreateSessionPromise(RESOLVED));
391 EXPECT_FALSE(current_session_id_.empty()); 383 EXPECT_FALSE(current_session_id_.empty());
392 } 384 }
393 } 385 }
394 386
395 virtual bool LookupKey(const std::vector<uint8_t>& key_id, 387 virtual bool LookupKey(const std::vector<uint8_t>& key_id,
396 std::vector<uint8_t>* key) { 388 std::vector<uint8_t>* key) {
397 // As there is no key rotation, the key ID provided should be |kKeyId| 389 // No key rotation.
398 // which uses |kSecretKey| as the key. 390 return LookupTestKeyVector(key_id, false, key);
399 EXPECT_EQ(std::vector<uint8_t>(kKeyId, kKeyId + arraysize(kKeyId)), key_id);
400 key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey));
401 return true;
402 } 391 }
403 392
404 std::string current_session_id_; 393 std::string current_session_id_;
405 std::vector<uint8_t> prev_init_data_; 394 std::vector<uint8_t> prev_init_data_;
406 }; 395 };
407 396
408 class RotatingKeyProvidingApp : public KeyProvidingApp { 397 class RotatingKeyProvidingApp : public KeyProvidingApp {
409 public: 398 public:
410 RotatingKeyProvidingApp() : num_distinct_need_key_calls_(0) {} 399 RotatingKeyProvidingApp() : num_distinct_need_key_calls_(0) {}
411 ~RotatingKeyProvidingApp() override { 400 ~RotatingKeyProvidingApp() override {
(...skipping 11 matching lines...) Expand all
423 prev_init_data_ = init_data; 412 prev_init_data_ = init_data;
424 ++num_distinct_need_key_calls_; 413 ++num_distinct_need_key_calls_;
425 414
426 decryptor->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, 415 decryptor->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION,
427 init_data_type, init_data, 416 init_data_type, init_data,
428 CreateSessionPromise(RESOLVED)); 417 CreateSessionPromise(RESOLVED));
429 } 418 }
430 419
431 bool LookupKey(const std::vector<uint8_t>& key_id, 420 bool LookupKey(const std::vector<uint8_t>& key_id,
432 std::vector<uint8_t>* key) override { 421 std::vector<uint8_t>* key) override {
433 // The Key and KeyId for this testing key provider are created by left 422 // With key rotation.
434 // rotating |kSecretKey| and |kKeyId|. Note that this implementation is 423 return LookupTestKeyVector(key_id, true, key);
435 // only intended for testing purpose. The actual key rotation algorithm
436 // can be much more complicated.
437 // Find out the rotating position from |starting_key_id| and apply on |key|.
438 std::vector<uint8_t> starting_key_id(kKeyId, kKeyId + arraysize(kKeyId));
439 for (size_t pos = 0; pos < starting_key_id.size(); ++pos) {
440 std::rotate(starting_key_id.begin(), starting_key_id.begin() + pos,
441 starting_key_id.end());
442 if (key_id == starting_key_id) {
443 key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey));
444 std::rotate(key->begin(), key->begin() + pos, key->end());
445 return true;
446 }
447 }
448 return false;
449 } 424 }
450 425
451 uint32_t num_distinct_need_key_calls_; 426 uint32_t num_distinct_need_key_calls_;
452 }; 427 };
453 428
454 // Ignores the encrypted event and does not perform a license request. 429 // Ignores the encrypted event and does not perform a license request.
455 class NoResponseApp : public FakeEncryptedMedia::AppBase { 430 class NoResponseApp : public FakeEncryptedMedia::AppBase {
456 public: 431 public:
457 void OnSessionMessage(const std::string& session_id, 432 void OnSessionMessage(const std::string& session_id,
458 MediaKeys::MessageType message_type, 433 MediaKeys::MessageType message_type,
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 2131
2157 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2132 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
2158 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2133 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
2159 Play(); 2134 Play();
2160 ASSERT_TRUE(WaitUntilOnEnded()); 2135 ASSERT_TRUE(WaitUntilOnEnded());
2161 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2136 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
2162 demuxer_->GetStartTime()); 2137 demuxer_->GetStartTime());
2163 } 2138 }
2164 2139
2165 } // namespace media 2140 } // namespace media
OLDNEW
« media/formats/mp2t/ts_section_cets_pssh.cc ('K') | « media/test/data/bear-1280x720-hls-sample-aes.ts ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698