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

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

Issue 1072403009: Use std::vector<uint8_t> instead of uint8*/int for MediaKeys interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« media/cdm/aes_decryptor.cc ('K') | « media/cdm/proxy_decryptor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 return; 310 return;
311 prev_init_data_ = init_data; 311 prev_init_data_ = init_data;
312 312
313 if (current_session_id_.empty()) { 313 if (current_session_id_.empty()) {
314 if (init_data_type == EmeInitDataType::CENC) { 314 if (init_data_type == EmeInitDataType::CENC) {
315 // Since the 'cenc' files are not created with proper 'pssh' boxes, 315 // Since the 'cenc' files are not created with proper 'pssh' boxes,
316 // simply pretend that this is a webm file and pass the expected 316 // simply pretend that this is a webm file and pass the expected
317 // key ID as the init_data. 317 // key ID as the init_data.
318 // http://crbug.com/460308 318 // http://crbug.com/460308
319 decryptor->CreateSessionAndGenerateRequest( 319 decryptor->CreateSessionAndGenerateRequest(
320 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, kKeyId, 320 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM,
321 arraysize(kKeyId), CreateSessionPromise(RESOLVED)); 321 std::vector<uint8>(kKeyId, kKeyId + arraysize(kKeyId)),
322 CreateSessionPromise(RESOLVED));
322 } else { 323 } else {
323 decryptor->CreateSessionAndGenerateRequest( 324 decryptor->CreateSessionAndGenerateRequest(
324 MediaKeys::TEMPORARY_SESSION, init_data_type, 325 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data,
325 vector_as_array(&init_data), init_data.size(),
326 CreateSessionPromise(RESOLVED)); 326 CreateSessionPromise(RESOLVED));
327 } 327 }
328 EXPECT_FALSE(current_session_id_.empty()); 328 EXPECT_FALSE(current_session_id_.empty());
329 } 329 }
330 330
331 // Clear Key really needs the key ID from |init_data|. For WebM, they are 331 // Clear Key really needs the key ID from |init_data|. For WebM, they are
332 // the same, but this is not the case for ISO CENC (key ID embedded in a 332 // the same, but this is not the case for ISO CENC (key ID embedded in a
333 // 'pssh' box). Therefore, provide the correct key ID. 333 // 'pssh' box). Therefore, provide the correct key ID.
334 const uint8* key_id = vector_as_array(&init_data); 334 const uint8* key_id = vector_as_array(&init_data);
335 size_t key_id_length = init_data.size(); 335 size_t key_id_length = init_data.size();
336 if (init_data_type == EmeInitDataType::CENC) { 336 if (init_data_type == EmeInitDataType::CENC) {
337 key_id = kKeyId; 337 key_id = kKeyId;
338 key_id_length = arraysize(kKeyId); 338 key_id_length = arraysize(kKeyId);
339 } 339 }
340 340
341 // Convert key into a JSON structure and then add it. 341 // Convert key into a JSON structure and then add it.
342 std::string jwk = GenerateJWKSet( 342 std::string jwk = GenerateJWKSet(
343 kSecretKey, arraysize(kSecretKey), key_id, key_id_length); 343 kSecretKey, arraysize(kSecretKey), key_id, key_id_length);
344 decryptor->UpdateSession(current_session_id_, 344 decryptor->UpdateSession(current_session_id_,
345 reinterpret_cast<const uint8*>(jwk.data()), 345 std::vector<uint8>(jwk.begin(), jwk.end()),
346 jwk.size(),
347 CreatePromise(RESOLVED)); 346 CreatePromise(RESOLVED));
348 } 347 }
349 348
350 std::string current_session_id_; 349 std::string current_session_id_;
351 std::vector<uint8> prev_init_data_; 350 std::vector<uint8> prev_init_data_;
352 }; 351 };
353 352
354 class RotatingKeyProvidingApp : public KeyProvidingApp { 353 class RotatingKeyProvidingApp : public KeyProvidingApp {
355 public: 354 public:
356 RotatingKeyProvidingApp() : num_distint_need_key_calls_(0) {} 355 RotatingKeyProvidingApp() : num_distint_need_key_calls_(0) {}
(...skipping 15 matching lines...) Expand all
372 std::vector<uint8> key_id; 371 std::vector<uint8> key_id;
373 std::vector<uint8> key; 372 std::vector<uint8> key;
374 EXPECT_TRUE(GetKeyAndKeyId(init_data, &key, &key_id)); 373 EXPECT_TRUE(GetKeyAndKeyId(init_data, &key, &key_id));
375 374
376 if (init_data_type == EmeInitDataType::CENC) { 375 if (init_data_type == EmeInitDataType::CENC) {
377 // Since the 'cenc' files are not created with proper 'pssh' boxes, 376 // Since the 'cenc' files are not created with proper 'pssh' boxes,
378 // simply pretend that this is a webm file and pass the expected 377 // simply pretend that this is a webm file and pass the expected
379 // key ID as the init_data. 378 // key ID as the init_data.
380 // http://crbug.com/460308 379 // http://crbug.com/460308
381 decryptor->CreateSessionAndGenerateRequest( 380 decryptor->CreateSessionAndGenerateRequest(
382 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, 381 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, key_id,
383 vector_as_array(&key_id), key_id.size(),
384 CreateSessionPromise(RESOLVED)); 382 CreateSessionPromise(RESOLVED));
385 } else { 383 } else {
386 decryptor->CreateSessionAndGenerateRequest( 384 decryptor->CreateSessionAndGenerateRequest(
387 MediaKeys::TEMPORARY_SESSION, init_data_type, 385 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data,
388 vector_as_array(&init_data), init_data.size(),
389 CreateSessionPromise(RESOLVED)); 386 CreateSessionPromise(RESOLVED));
390 } 387 }
391 388
392 // Convert key into a JSON structure and then add it. 389 // Convert key into a JSON structure and then add it.
393 std::string jwk = GenerateJWKSet(vector_as_array(&key), 390 std::string jwk = GenerateJWKSet(vector_as_array(&key),
394 key.size(), 391 key.size(),
395 vector_as_array(&key_id), 392 vector_as_array(&key_id),
396 key_id.size()); 393 key_id.size());
397 decryptor->UpdateSession(current_session_id_, 394 decryptor->UpdateSession(current_session_id_,
398 reinterpret_cast<const uint8*>(jwk.data()), 395 std::vector<uint8>(jwk.begin(), jwk.end()),
399 jwk.size(),
400 CreatePromise(RESOLVED)); 396 CreatePromise(RESOLVED));
401 } 397 }
402 398
403 private: 399 private:
404 bool GetKeyAndKeyId(std::vector<uint8> init_data, 400 bool GetKeyAndKeyId(std::vector<uint8> init_data,
405 std::vector<uint8>* key, 401 std::vector<uint8>* key,
406 std::vector<uint8>* key_id) { 402 std::vector<uint8>* key_id) {
407 // For WebM, init_data is key_id; for ISO CENC, init_data should contain 403 // For WebM, init_data is key_id; for ISO CENC, init_data should contain
408 // the key_id. We assume key_id is in the end of init_data here (that is 404 // the key_id. We assume key_id is in the end of init_data here (that is
409 // only a reasonable assumption for WebM and clear key ISO CENC). 405 // only a reasonable assumption for WebM and clear key ISO CENC).
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 1733
1738 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 1734 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
1739 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 1735 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
1740 Play(); 1736 Play();
1741 ASSERT_TRUE(WaitUntilOnEnded()); 1737 ASSERT_TRUE(WaitUntilOnEnded());
1742 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 1738 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
1743 demuxer_->GetStartTime()); 1739 demuxer_->GetStartTime());
1744 } 1740 }
1745 1741
1746 } // namespace media 1742 } // namespace media
OLDNEW
« media/cdm/aes_decryptor.cc ('K') | « media/cdm/proxy_decryptor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698