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

Side by Side Diff: media/base/android/media_drm_bridge.cc

Issue 1906423005: Replace scoped_ptr with std::unique_ptr in //media/base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-media-base: android 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/base/android/media_drm_bridge.h" 5 #include "media/base/android/media_drm_bridge.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 return nullptr; 338 return nullptr;
339 339
340 return MediaDrmBridge::Create(key_system, security_level, create_fetcher_cb, 340 return MediaDrmBridge::Create(key_system, security_level, create_fetcher_cb,
341 SessionMessageCB(), SessionClosedCB(), 341 SessionMessageCB(), SessionClosedCB(),
342 LegacySessionErrorCB(), SessionKeysChangeCB(), 342 LegacySessionErrorCB(), SessionKeysChangeCB(),
343 SessionExpirationUpdateCB()); 343 SessionExpirationUpdateCB());
344 } 344 }
345 345
346 void MediaDrmBridge::SetServerCertificate( 346 void MediaDrmBridge::SetServerCertificate(
347 const std::vector<uint8_t>& certificate, 347 const std::vector<uint8_t>& certificate,
348 scoped_ptr<media::SimpleCdmPromise> promise) { 348 std::unique_ptr<media::SimpleCdmPromise> promise) {
349 DCHECK(task_runner_->BelongsToCurrentThread()); 349 DCHECK(task_runner_->BelongsToCurrentThread());
350 DVLOG(2) << __FUNCTION__ << "(" << certificate.size() << " bytes)"; 350 DVLOG(2) << __FUNCTION__ << "(" << certificate.size() << " bytes)";
351 351
352 DCHECK(!certificate.empty()); 352 DCHECK(!certificate.empty());
353 353
354 JNIEnv* env = AttachCurrentThread(); 354 JNIEnv* env = AttachCurrentThread();
355 ScopedJavaLocalRef<jbyteArray> j_certificate = base::android::ToJavaByteArray( 355 ScopedJavaLocalRef<jbyteArray> j_certificate = base::android::ToJavaByteArray(
356 env, certificate.data(), certificate.size()); 356 env, certificate.data(), certificate.size());
357 if (Java_MediaDrmBridge_setServerCertificate(env, j_media_drm_.obj(), 357 if (Java_MediaDrmBridge_setServerCertificate(env, j_media_drm_.obj(),
358 j_certificate.obj())) { 358 j_certificate.obj())) {
359 promise->resolve(); 359 promise->resolve();
360 } else { 360 } else {
361 promise->reject(INVALID_ACCESS_ERROR, 0, "Set server certificate failed."); 361 promise->reject(INVALID_ACCESS_ERROR, 0, "Set server certificate failed.");
362 } 362 }
363 } 363 }
364 364
365 void MediaDrmBridge::CreateSessionAndGenerateRequest( 365 void MediaDrmBridge::CreateSessionAndGenerateRequest(
366 SessionType session_type, 366 SessionType session_type,
367 media::EmeInitDataType init_data_type, 367 media::EmeInitDataType init_data_type,
368 const std::vector<uint8_t>& init_data, 368 const std::vector<uint8_t>& init_data,
369 scoped_ptr<media::NewSessionCdmPromise> promise) { 369 std::unique_ptr<media::NewSessionCdmPromise> promise) {
370 DCHECK(task_runner_->BelongsToCurrentThread()); 370 DCHECK(task_runner_->BelongsToCurrentThread());
371 DVLOG(2) << __FUNCTION__; 371 DVLOG(2) << __FUNCTION__;
372 372
373 if (session_type != media::MediaKeys::TEMPORARY_SESSION) { 373 if (session_type != media::MediaKeys::TEMPORARY_SESSION) {
374 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android."; 374 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android.";
375 promise->reject(NOT_SUPPORTED_ERROR, 0, 375 promise->reject(NOT_SUPPORTED_ERROR, 0,
376 "Only the temporary session type is supported."); 376 "Only the temporary session type is supported.");
377 return; 377 return;
378 } 378 }
379 379
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 ConvertUTF8ToJavaString(env, ConvertInitDataType(init_data_type)); 415 ConvertUTF8ToJavaString(env, ConvertInitDataType(init_data_type));
416 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); 416 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise));
417 Java_MediaDrmBridge_createSessionFromNative( 417 Java_MediaDrmBridge_createSessionFromNative(
418 env, j_media_drm_.obj(), j_init_data.obj(), j_mime.obj(), 418 env, j_media_drm_.obj(), j_init_data.obj(), j_mime.obj(),
419 j_optional_parameters.obj(), promise_id); 419 j_optional_parameters.obj(), promise_id);
420 } 420 }
421 421
422 void MediaDrmBridge::LoadSession( 422 void MediaDrmBridge::LoadSession(
423 SessionType session_type, 423 SessionType session_type,
424 const std::string& session_id, 424 const std::string& session_id,
425 scoped_ptr<media::NewSessionCdmPromise> promise) { 425 std::unique_ptr<media::NewSessionCdmPromise> promise) {
426 DCHECK(task_runner_->BelongsToCurrentThread()); 426 DCHECK(task_runner_->BelongsToCurrentThread());
427 DVLOG(2) << __FUNCTION__; 427 DVLOG(2) << __FUNCTION__;
428 428
429 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android."; 429 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android.";
430 promise->reject(NOT_SUPPORTED_ERROR, 0, "LoadSession() is not supported."); 430 promise->reject(NOT_SUPPORTED_ERROR, 0, "LoadSession() is not supported.");
431 } 431 }
432 432
433 void MediaDrmBridge::UpdateSession( 433 void MediaDrmBridge::UpdateSession(
434 const std::string& session_id, 434 const std::string& session_id,
435 const std::vector<uint8_t>& response, 435 const std::vector<uint8_t>& response,
436 scoped_ptr<media::SimpleCdmPromise> promise) { 436 std::unique_ptr<media::SimpleCdmPromise> promise) {
437 DCHECK(task_runner_->BelongsToCurrentThread()); 437 DCHECK(task_runner_->BelongsToCurrentThread());
438 DVLOG(2) << __FUNCTION__; 438 DVLOG(2) << __FUNCTION__;
439 439
440 JNIEnv* env = AttachCurrentThread(); 440 JNIEnv* env = AttachCurrentThread();
441 ScopedJavaLocalRef<jbyteArray> j_response = 441 ScopedJavaLocalRef<jbyteArray> j_response =
442 base::android::ToJavaByteArray(env, response.data(), response.size()); 442 base::android::ToJavaByteArray(env, response.data(), response.size());
443 ScopedJavaLocalRef<jbyteArray> j_session_id = base::android::ToJavaByteArray( 443 ScopedJavaLocalRef<jbyteArray> j_session_id = base::android::ToJavaByteArray(
444 env, reinterpret_cast<const uint8_t*>(session_id.data()), 444 env, reinterpret_cast<const uint8_t*>(session_id.data()),
445 session_id.size()); 445 session_id.size());
446 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); 446 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise));
447 Java_MediaDrmBridge_updateSession(env, j_media_drm_.obj(), j_session_id.obj(), 447 Java_MediaDrmBridge_updateSession(env, j_media_drm_.obj(), j_session_id.obj(),
448 j_response.obj(), promise_id); 448 j_response.obj(), promise_id);
449 } 449 }
450 450
451 void MediaDrmBridge::CloseSession(const std::string& session_id, 451 void MediaDrmBridge::CloseSession(
452 scoped_ptr<media::SimpleCdmPromise> promise) { 452 const std::string& session_id,
453 std::unique_ptr<media::SimpleCdmPromise> promise) {
453 DCHECK(task_runner_->BelongsToCurrentThread()); 454 DCHECK(task_runner_->BelongsToCurrentThread());
454 DVLOG(2) << __FUNCTION__; 455 DVLOG(2) << __FUNCTION__;
455 456
456 JNIEnv* env = AttachCurrentThread(); 457 JNIEnv* env = AttachCurrentThread();
457 ScopedJavaLocalRef<jbyteArray> j_session_id = base::android::ToJavaByteArray( 458 ScopedJavaLocalRef<jbyteArray> j_session_id = base::android::ToJavaByteArray(
458 env, reinterpret_cast<const uint8_t*>(session_id.data()), 459 env, reinterpret_cast<const uint8_t*>(session_id.data()),
459 session_id.size()); 460 session_id.size());
460 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); 461 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise));
461 Java_MediaDrmBridge_closeSession(env, j_media_drm_.obj(), j_session_id.obj(), 462 Java_MediaDrmBridge_closeSession(env, j_media_drm_.obj(), j_session_id.obj(),
462 promise_id); 463 promise_id);
463 } 464 }
464 465
465 void MediaDrmBridge::RemoveSession( 466 void MediaDrmBridge::RemoveSession(
466 const std::string& session_id, 467 const std::string& session_id,
467 scoped_ptr<media::SimpleCdmPromise> promise) { 468 std::unique_ptr<media::SimpleCdmPromise> promise) {
468 DCHECK(task_runner_->BelongsToCurrentThread()); 469 DCHECK(task_runner_->BelongsToCurrentThread());
469 DVLOG(2) << __FUNCTION__; 470 DVLOG(2) << __FUNCTION__;
470 471
471 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android."; 472 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android.";
472 promise->reject(NOT_SUPPORTED_ERROR, 0, "RemoveSession() is not supported."); 473 promise->reject(NOT_SUPPORTED_ERROR, 0, "RemoveSession() is not supported.");
473 } 474 }
474 475
475 CdmContext* MediaDrmBridge::GetCdmContext() { 476 CdmContext* MediaDrmBridge::GetCdmContext() {
476 DVLOG(2) << __FUNCTION__; 477 DVLOG(2) << __FUNCTION__;
477 478
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 898 }
898 899
899 void MediaDrmBridge::OnHasAdditionalUsableKey() { 900 void MediaDrmBridge::OnHasAdditionalUsableKey() {
900 DCHECK(task_runner_->BelongsToCurrentThread()); 901 DCHECK(task_runner_->BelongsToCurrentThread());
901 DVLOG(1) << __FUNCTION__; 902 DVLOG(1) << __FUNCTION__;
902 903
903 player_tracker_.NotifyNewKey(); 904 player_tracker_.NotifyNewKey();
904 } 905 }
905 906
906 } // namespace media 907 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_drm_bridge.h ('k') | media/base/android/media_drm_bridge_cdm_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698