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

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: move some gn defs Created 4 years, 8 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 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; 98 const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\"";
99 #if defined(USE_PROPRIETARY_CODECS) 99 #if defined(USE_PROPRIETARY_CODECS)
100 const char kADTS[] = "audio/aac"; 100 const char kADTS[] = "audio/aac";
101 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; 101 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\"";
102 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\""; 102 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\"";
103 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; 103 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\"";
104 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; 104 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\"";
105 const char kMP3[] = "audio/mpeg"; 105 const char kMP3[] = "audio/mpeg";
106 #endif // defined(USE_PROPRIETARY_CODECS) 106 #endif // defined(USE_PROPRIETARY_CODECS)
107 107
108 // Key used to encrypt test files.
109 const uint8_t kSecretKey[] = {0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
110 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c};
111
112 // The key ID for all encrypted files.
113 const uint8_t kKeyId[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
114 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35};
115
116 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); 108 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max();
117 109
118 // Constants for the Media Source config change tests. 110 // Constants for the Media Source config change tests.
119 const int kAppendTimeSec = 1; 111 const int kAppendTimeSec = 1;
120 const int kAppendTimeMs = kAppendTimeSec * 1000; 112 const int kAppendTimeMs = kAppendTimeSec * 1000;
121 const int k320WebMFileDurationMs = 2736; 113 const int k320WebMFileDurationMs = 2736;
122 const int k320EncWebMFileDurationMs = 2737; 114 const int k320EncWebMFileDurationMs = 2737;
123 const int k640WebMFileDurationMs = 2749; 115 const int k640WebMFileDurationMs = 2749;
124 const int kOpusEndTrimmingWebMFileDurationMs = 2741; 116 const int kOpusEndTrimmingWebMFileDurationMs = 2741;
125 const int kVP9WebMFileDurationMs = 2736; 117 const int kVP9WebMFileDurationMs = 2736;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 Decryptor* decryptor_; 269 Decryptor* decryptor_;
278 }; 270 };
279 271
280 scoped_refptr<AesDecryptor> decryptor_; 272 scoped_refptr<AesDecryptor> decryptor_;
281 TestCdmContext cdm_context_; 273 TestCdmContext cdm_context_;
282 scoped_ptr<AppBase> app_; 274 scoped_ptr<AppBase> app_;
283 }; 275 };
284 276
285 enum PromiseResult { RESOLVED, REJECTED }; 277 enum PromiseResult { RESOLVED, REJECTED };
286 278
287 // Provides |kSecretKey| in response to the encrypted event. 279 // Provides test key in response to the encrypted event.
ddorwin 2016/04/12 00:40:48 nit: insert "the"
dougsteed 2016/05/08 23:18:45 Done.
288 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { 280 class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
289 public: 281 public:
290 KeyProvidingApp() {} 282 KeyProvidingApp() {}
291 283
292 void OnResolveWithSession(PromiseResult expected, 284 void OnResolveWithSession(PromiseResult expected,
293 const std::string& session_id) { 285 const std::string& session_id) {
294 EXPECT_EQ(expected, RESOLVED); 286 EXPECT_EQ(expected, RESOLVED);
295 EXPECT_GT(session_id.length(), 0ul); 287 EXPECT_GT(session_id.length(), 0ul);
296 current_session_id_ = session_id; 288 current_session_id_ = session_id;
297 } 289 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 if (current_session_id_.empty()) { 372 if (current_session_id_.empty()) {
381 decryptor->CreateSessionAndGenerateRequest( 373 decryptor->CreateSessionAndGenerateRequest(
382 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data, 374 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data,
383 CreateSessionPromise(RESOLVED)); 375 CreateSessionPromise(RESOLVED));
384 EXPECT_FALSE(current_session_id_.empty()); 376 EXPECT_FALSE(current_session_id_.empty());
385 } 377 }
386 } 378 }
387 379
388 virtual bool LookupKey(const std::vector<uint8_t>& key_id, 380 virtual bool LookupKey(const std::vector<uint8_t>& key_id,
389 std::vector<uint8_t>* key) { 381 std::vector<uint8_t>* key) {
390 // As there is no key rotation, the key ID provided should be |kKeyId| 382 // No key rotation.
391 // which uses |kSecretKey| as the key. 383 return LookupTestKey(key_id, key, false);
392 EXPECT_EQ(std::vector<uint8_t>(kKeyId, kKeyId + arraysize(kKeyId)), key_id);
393 key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey));
394 return true;
395 } 384 }
396 385
397 std::string current_session_id_; 386 std::string current_session_id_;
398 std::vector<uint8_t> prev_init_data_; 387 std::vector<uint8_t> prev_init_data_;
399 }; 388 };
400 389
401 class RotatingKeyProvidingApp : public KeyProvidingApp { 390 class RotatingKeyProvidingApp : public KeyProvidingApp {
402 public: 391 public:
403 RotatingKeyProvidingApp() : num_distinct_need_key_calls_(0) {} 392 RotatingKeyProvidingApp() : num_distinct_need_key_calls_(0) {}
404 ~RotatingKeyProvidingApp() override { 393 ~RotatingKeyProvidingApp() override {
(...skipping 11 matching lines...) Expand all
416 prev_init_data_ = init_data; 405 prev_init_data_ = init_data;
417 ++num_distinct_need_key_calls_; 406 ++num_distinct_need_key_calls_;
418 407
419 decryptor->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, 408 decryptor->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION,
420 init_data_type, init_data, 409 init_data_type, init_data,
421 CreateSessionPromise(RESOLVED)); 410 CreateSessionPromise(RESOLVED));
422 } 411 }
423 412
424 bool LookupKey(const std::vector<uint8_t>& key_id, 413 bool LookupKey(const std::vector<uint8_t>& key_id,
425 std::vector<uint8_t>* key) override { 414 std::vector<uint8_t>* key) override {
426 // The Key and KeyId for this testing key provider are created by left 415 // With key rotation.
427 // rotating |kSecretKey| and |kKeyId|. Note that this implementation is 416 return LookupTestKey(key_id, key, true);
428 // only intended for testing purpose. The actual key rotation algorithm
429 // can be much more complicated.
430 // Find out the rotating position from |starting_key_id| and apply on |key|.
431 std::vector<uint8_t> starting_key_id(kKeyId, kKeyId + arraysize(kKeyId));
432 for (size_t pos = 0; pos < starting_key_id.size(); ++pos) {
433 std::rotate(starting_key_id.begin(), starting_key_id.begin() + pos,
434 starting_key_id.end());
435 if (key_id == starting_key_id) {
436 key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey));
437 std::rotate(key->begin(), key->begin() + pos, key->end());
438 return true;
439 }
440 }
441 return false;
442 } 417 }
443 418
444 uint32_t num_distinct_need_key_calls_; 419 uint32_t num_distinct_need_key_calls_;
445 }; 420 };
446 421
447 // Ignores the encrypted event and does not perform a license request. 422 // Ignores the encrypted event and does not perform a license request.
448 class NoResponseApp : public FakeEncryptedMedia::AppBase { 423 class NoResponseApp : public FakeEncryptedMedia::AppBase {
449 public: 424 public:
450 void OnSessionMessage(const std::string& session_id, 425 void OnSessionMessage(const std::string& session_id,
451 MediaKeys::MessageType message_type, 426 MediaKeys::MessageType message_type,
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 2015
2041 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2016 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
2042 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2017 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
2043 Play(); 2018 Play();
2044 ASSERT_TRUE(WaitUntilOnEnded()); 2019 ASSERT_TRUE(WaitUntilOnEnded());
2045 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2020 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
2046 demuxer_->GetStartTime()); 2021 demuxer_->GetStartTime());
2047 } 2022 }
2048 2023
2049 } // namespace media 2024 } // namespace media
OLDNEW
« media/media_options.gni ('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