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

Side by Side Diff: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « media/cdm/ppapi/external_clear_key/cdm_video_decoder.cc ('k') | media/cdm/proxy_decryptor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" 5 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <sstream> 9 #include <sstream>
10 #include <utility>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
16 #include "media/base/cdm_callback_promise.h" 17 #include "media/base/cdm_callback_promise.h"
17 #include "media/base/cdm_key_information.h" 18 #include "media/base/cdm_key_information.h"
18 #include "media/base/decoder_buffer.h" 19 #include "media/base/decoder_buffer.h"
19 #include "media/base/decrypt_config.h" 20 #include "media/base/decrypt_config.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 input_buffer.subsamples[i].cipher_bytes)); 106 input_buffer.subsamples[i].cipher_bytes));
106 } 107 }
107 108
108 scoped_ptr<media::DecryptConfig> decrypt_config(new media::DecryptConfig( 109 scoped_ptr<media::DecryptConfig> decrypt_config(new media::DecryptConfig(
109 std::string(reinterpret_cast<const char*>(input_buffer.key_id), 110 std::string(reinterpret_cast<const char*>(input_buffer.key_id),
110 input_buffer.key_id_size), 111 input_buffer.key_id_size),
111 std::string(reinterpret_cast<const char*>(input_buffer.iv), 112 std::string(reinterpret_cast<const char*>(input_buffer.iv),
112 input_buffer.iv_size), 113 input_buffer.iv_size),
113 subsamples)); 114 subsamples));
114 115
115 output_buffer->set_decrypt_config(decrypt_config.Pass()); 116 output_buffer->set_decrypt_config(std::move(decrypt_config));
116 output_buffer->set_timestamp( 117 output_buffer->set_timestamp(
117 base::TimeDelta::FromMicroseconds(input_buffer.timestamp)); 118 base::TimeDelta::FromMicroseconds(input_buffer.timestamp));
118 119
119 return output_buffer; 120 return output_buffer;
120 } 121 }
121 122
122 static std::string GetFileIOTestResultMessage(bool success) { 123 static std::string GetFileIOTestResultMessage(bool success) {
123 std::string message(kFileIOTestResultHeader); 124 std::string message(kFileIOTestResultHeader);
124 message += success ? '1' : '0'; 125 message += success ? '1' : '0';
125 return message; 126 return message;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 new media::CdmCallbackPromise<std::string>( 300 new media::CdmCallbackPromise<std::string>(
300 base::Bind(&ClearKeyCdm::OnSessionCreated, 301 base::Bind(&ClearKeyCdm::OnSessionCreated,
301 base::Unretained(this), 302 base::Unretained(this),
302 promise_id), 303 promise_id),
303 base::Bind(&ClearKeyCdm::OnPromiseFailed, 304 base::Bind(&ClearKeyCdm::OnPromiseFailed,
304 base::Unretained(this), 305 base::Unretained(this),
305 promise_id))); 306 promise_id)));
306 decryptor_->CreateSessionAndGenerateRequest( 307 decryptor_->CreateSessionAndGenerateRequest(
307 ConvertSessionType(session_type), ConvertInitDataType(init_data_type), 308 ConvertSessionType(session_type), ConvertInitDataType(init_data_type),
308 std::vector<uint8_t>(init_data, init_data + init_data_size), 309 std::vector<uint8_t>(init_data, init_data + init_data_size),
309 promise.Pass()); 310 std::move(promise));
310 311
311 if (key_system_ == kExternalClearKeyFileIOTestKeySystem) 312 if (key_system_ == kExternalClearKeyFileIOTestKeySystem)
312 StartFileIOTest(); 313 StartFileIOTest();
313 } 314 }
314 315
315 // Loads a emulated stored session. Currently only |kLoadableSessionId| 316 // Loads a emulated stored session. Currently only |kLoadableSessionId|
316 // (containing a |kLoadableSessionKey| for |kLoadableSessionKeyId|) is 317 // (containing a |kLoadableSessionKey| for |kLoadableSessionKeyId|) is
317 // supported. 318 // supported.
318 void ClearKeyCdm::LoadSession(uint32_t promise_id, 319 void ClearKeyCdm::LoadSession(uint32_t promise_id,
319 cdm::SessionType session_type, 320 cdm::SessionType session_type,
(...skipping 14 matching lines...) Expand all
334 scoped_ptr<media::NewSessionCdmPromise> promise( 335 scoped_ptr<media::NewSessionCdmPromise> promise(
335 new media::CdmCallbackPromise<std::string>( 336 new media::CdmCallbackPromise<std::string>(
336 base::Bind(&ClearKeyCdm::OnSessionLoaded, 337 base::Bind(&ClearKeyCdm::OnSessionLoaded,
337 base::Unretained(this), 338 base::Unretained(this),
338 promise_id), 339 promise_id),
339 base::Bind(&ClearKeyCdm::OnPromiseFailed, 340 base::Bind(&ClearKeyCdm::OnPromiseFailed,
340 base::Unretained(this), 341 base::Unretained(this),
341 promise_id))); 342 promise_id)));
342 decryptor_->CreateSessionAndGenerateRequest( 343 decryptor_->CreateSessionAndGenerateRequest(
343 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, 344 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM,
344 std::vector<uint8_t>(), promise.Pass()); 345 std::vector<uint8_t>(), std::move(promise));
345 } 346 }
346 347
347 void ClearKeyCdm::UpdateSession(uint32_t promise_id, 348 void ClearKeyCdm::UpdateSession(uint32_t promise_id,
348 const char* session_id, 349 const char* session_id,
349 uint32_t session_id_length, 350 uint32_t session_id_length,
350 const uint8_t* response, 351 const uint8_t* response,
351 uint32_t response_size) { 352 uint32_t response_size) {
352 DVLOG(1) << __FUNCTION__; 353 DVLOG(1) << __FUNCTION__;
353 std::string web_session_str(session_id, session_id_length); 354 std::string web_session_str(session_id, session_id_length);
354 355
355 // If updating the loadable session, use the actual session id generated. 356 // If updating the loadable session, use the actual session id generated.
356 if (web_session_str == std::string(kLoadableSessionId)) 357 if (web_session_str == std::string(kLoadableSessionId))
357 web_session_str = session_id_for_emulated_loadsession_; 358 web_session_str = session_id_for_emulated_loadsession_;
358 359
359 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>( 360 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>(
360 base::Bind(&ClearKeyCdm::OnPromiseResolved, base::Unretained(this), 361 base::Bind(&ClearKeyCdm::OnPromiseResolved, base::Unretained(this),
361 promise_id), 362 promise_id),
362 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this), 363 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this),
363 promise_id))); 364 promise_id)));
364 decryptor_->UpdateSession( 365 decryptor_->UpdateSession(
365 web_session_str, std::vector<uint8_t>(response, response + response_size), 366 web_session_str, std::vector<uint8_t>(response, response + response_size),
366 promise.Pass()); 367 std::move(promise));
367 368
368 if (!renewal_timer_set_) { 369 if (!renewal_timer_set_) {
369 ScheduleNextRenewal(); 370 ScheduleNextRenewal();
370 renewal_timer_set_ = true; 371 renewal_timer_set_ = true;
371 } 372 }
372 } 373 }
373 374
374 void ClearKeyCdm::CloseSession(uint32_t promise_id, 375 void ClearKeyCdm::CloseSession(uint32_t promise_id,
375 const char* session_id, 376 const char* session_id,
376 uint32_t session_id_length) { 377 uint32_t session_id_length) {
377 DVLOG(1) << __FUNCTION__; 378 DVLOG(1) << __FUNCTION__;
378 std::string web_session_str(session_id, session_id_length); 379 std::string web_session_str(session_id, session_id_length);
379 380
380 // If closing the loadable session, use the actual session id generated. 381 // If closing the loadable session, use the actual session id generated.
381 if (web_session_str == std::string(kLoadableSessionId)) 382 if (web_session_str == std::string(kLoadableSessionId))
382 web_session_str = session_id_for_emulated_loadsession_; 383 web_session_str = session_id_for_emulated_loadsession_;
383 384
384 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>( 385 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>(
385 base::Bind( 386 base::Bind(
386 &ClearKeyCdm::OnPromiseResolved, base::Unretained(this), promise_id), 387 &ClearKeyCdm::OnPromiseResolved, base::Unretained(this), promise_id),
387 base::Bind( 388 base::Bind(
388 &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id))); 389 &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id)));
389 decryptor_->CloseSession(web_session_str, promise.Pass()); 390 decryptor_->CloseSession(web_session_str, std::move(promise));
390 } 391 }
391 392
392 void ClearKeyCdm::RemoveSession(uint32_t promise_id, 393 void ClearKeyCdm::RemoveSession(uint32_t promise_id,
393 const char* session_id, 394 const char* session_id,
394 uint32_t session_id_length) { 395 uint32_t session_id_length) {
395 DVLOG(1) << __FUNCTION__; 396 DVLOG(1) << __FUNCTION__;
396 std::string web_session_str(session_id, session_id_length); 397 std::string web_session_str(session_id, session_id_length);
397 398
398 // RemoveSession only allowed for the loadable session. 399 // RemoveSession only allowed for the loadable session.
399 if (web_session_str == std::string(kLoadableSessionId)) { 400 if (web_session_str == std::string(kLoadableSessionId)) {
400 web_session_str = session_id_for_emulated_loadsession_; 401 web_session_str = session_id_for_emulated_loadsession_;
401 } else { 402 } else {
402 // TODO(jrummell): This should be a DCHECK once blink does the proper 403 // TODO(jrummell): This should be a DCHECK once blink does the proper
403 // checks. 404 // checks.
404 std::string message("Not supported for non-persistent sessions."); 405 std::string message("Not supported for non-persistent sessions.");
405 host_->OnRejectPromise(promise_id, 406 host_->OnRejectPromise(promise_id,
406 cdm::kInvalidAccessError, 407 cdm::kInvalidAccessError,
407 0, 408 0,
408 message.data(), 409 message.data(),
409 message.length()); 410 message.length());
410 return; 411 return;
411 } 412 }
412 413
413 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>( 414 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>(
414 base::Bind(&ClearKeyCdm::OnPromiseResolved, base::Unretained(this), 415 base::Bind(&ClearKeyCdm::OnPromiseResolved, base::Unretained(this),
415 promise_id), 416 promise_id),
416 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this), 417 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this),
417 promise_id))); 418 promise_id)));
418 decryptor_->RemoveSession(web_session_str, promise.Pass()); 419 decryptor_->RemoveSession(web_session_str, std::move(promise));
419 } 420 }
420 421
421 void ClearKeyCdm::SetServerCertificate(uint32_t promise_id, 422 void ClearKeyCdm::SetServerCertificate(uint32_t promise_id,
422 const uint8_t* server_certificate_data, 423 const uint8_t* server_certificate_data,
423 uint32_t server_certificate_data_size) { 424 uint32_t server_certificate_data_size) {
424 // ClearKey doesn't use a server certificate. 425 // ClearKey doesn't use a server certificate.
425 host_->OnResolvePromise(promise_id); 426 host_->OnResolvePromise(promise_id);
426 } 427 }
427 428
428 void ClearKeyCdm::TimerExpired(void* context) { 429 void ClearKeyCdm::TimerExpired(void* context) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 std::string jwk_set = GenerateJWKSet(kLoadableSessionKey, 694 std::string jwk_set = GenerateJWKSet(kLoadableSessionKey,
694 sizeof(kLoadableSessionKey), 695 sizeof(kLoadableSessionKey),
695 kLoadableSessionKeyId, 696 kLoadableSessionKeyId,
696 sizeof(kLoadableSessionKeyId) - 1); 697 sizeof(kLoadableSessionKeyId) - 1);
697 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>( 698 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>(
698 base::Bind(&ClearKeyCdm::OnLoadSessionUpdated, base::Unretained(this)), 699 base::Bind(&ClearKeyCdm::OnLoadSessionUpdated, base::Unretained(this)),
699 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this), 700 base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this),
700 promise_id_for_emulated_loadsession_))); 701 promise_id_for_emulated_loadsession_)));
701 decryptor_->UpdateSession( 702 decryptor_->UpdateSession(
702 session_id_for_emulated_loadsession_, 703 session_id_for_emulated_loadsession_,
703 std::vector<uint8_t>(jwk_set.begin(), jwk_set.end()), promise.Pass()); 704 std::vector<uint8_t>(jwk_set.begin(), jwk_set.end()), std::move(promise));
704 } 705 }
705 706
706 void ClearKeyCdm::OnSessionMessage(const std::string& session_id, 707 void ClearKeyCdm::OnSessionMessage(const std::string& session_id,
707 MediaKeys::MessageType message_type, 708 MediaKeys::MessageType message_type,
708 const std::vector<uint8_t>& message, 709 const std::vector<uint8_t>& message,
709 const GURL& legacy_destination_url) { 710 const GURL& legacy_destination_url) {
710 DVLOG(1) << "OnSessionMessage: " << message.size(); 711 DVLOG(1) << "OnSessionMessage: " << message.size();
711 712
712 // Ignore the message when we are waiting to update the loadable session. 713 // Ignore the message when we are waiting to update the loadable session.
713 if (session_id == session_id_for_emulated_loadsession_) 714 if (session_id == session_id_for_emulated_loadsession_)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 void ClearKeyCdm::OnFileIOTestComplete(bool success) { 904 void ClearKeyCdm::OnFileIOTestComplete(bool success) {
904 DVLOG(1) << __FUNCTION__ << ": " << success; 905 DVLOG(1) << __FUNCTION__ << ": " << success;
905 std::string message = GetFileIOTestResultMessage(success); 906 std::string message = GetFileIOTestResultMessage(success);
906 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(), 907 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(),
907 cdm::kLicenseRequest, message.data(), 908 cdm::kLicenseRequest, message.data(),
908 message.length(), NULL, 0); 909 message.length(), NULL, 0);
909 file_io_test_runner_.reset(); 910 file_io_test_runner_.reset();
910 } 911 }
911 912
912 } // namespace media 913 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/ppapi/external_clear_key/cdm_video_decoder.cc ('k') | media/cdm/proxy_decryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698