Commit 2d420f7c authored by Xiaohan Wang's avatar Xiaohan Wang

media: Rename MediaDrmBridgeCdmContext to MediaCryptoContext

The new name is shorter and better reflects what the class does:
providing the MediaCrypto object.

Bug: 821114
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I5226a8280a1342fb47a0847755b82a8be8ed52e4
Reviewed-on: https://chromium-review.googlesource.com/959698Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542916}
parent cbcb5ba6
......@@ -35,11 +35,11 @@ if (is_android) {
"media_codec_loop.h",
"media_codec_util.cc",
"media_codec_util.h",
"media_crypto_context.h",
"media_crypto_context_impl.cc",
"media_crypto_context_impl.h",
"media_drm_bridge.cc",
"media_drm_bridge.h",
"media_drm_bridge_cdm_context.h",
"media_drm_bridge_cdm_context_impl.cc",
"media_drm_bridge_cdm_context_impl.h",
"media_drm_bridge_client.cc",
"media_drm_bridge_client.h",
"media_drm_bridge_delegate.cc",
......@@ -115,8 +115,8 @@ if (is_android) {
"mock_android_overlay.h",
"mock_media_codec_bridge.cc",
"mock_media_codec_bridge.h",
"mock_media_drm_bridge_cdm_context.cc",
"mock_media_drm_bridge_cdm_context.h",
"mock_media_crypto_context.cc",
"mock_media_crypto_context.h",
"test_destruction_observable.cc",
"test_destruction_observable.h",
]
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_
#define MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_
#ifndef MEDIA_BASE_ANDROID_MEDIA_CRYPTO_CONTEXT_H_
#define MEDIA_BASE_ANDROID_MEDIA_CRYPTO_CONTEXT_H_
#include <memory>
......@@ -23,7 +23,7 @@ namespace media {
// the correct thread.
//
// TODO(xhwang): Remove PlayerTracker interface.
class MEDIA_EXPORT MediaDrmBridgeCdmContext : public PlayerTracker {
class MEDIA_EXPORT MediaCryptoContext : public PlayerTracker {
public:
// Notification called when MediaCrypto object is ready.
// Parameters:
......@@ -37,15 +37,15 @@ class MEDIA_EXPORT MediaDrmBridgeCdmContext : public PlayerTracker {
base::Callback<void(JavaObjectPtr media_crypto,
bool requires_secure_video_codec)>;
MediaDrmBridgeCdmContext() {}
~MediaDrmBridgeCdmContext() override {}
MediaCryptoContext() {}
~MediaCryptoContext() override {}
virtual void SetMediaCryptoReadyCB(
const MediaCryptoReadyCB& media_crypto_ready_cb) = 0;
DISALLOW_COPY_AND_ASSIGN(MediaDrmBridgeCdmContext);
DISALLOW_COPY_AND_ASSIGN(MediaCryptoContext);
};
} // namespace media
#endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_
#endif // MEDIA_BASE_ANDROID_MEDIA_CRYPTO_CONTEXT_H_
......@@ -2,31 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/android/media_drm_bridge_cdm_context_impl.h"
#include "media/base/android/media_crypto_context_impl.h"
#include "media/base/android/media_drm_bridge.h"
namespace media {
MediaDrmBridgeCdmContextImpl::MediaDrmBridgeCdmContextImpl(
MediaDrmBridge* media_drm_bridge)
MediaCryptoContextImpl::MediaCryptoContextImpl(MediaDrmBridge* media_drm_bridge)
: media_drm_bridge_(media_drm_bridge) {
DCHECK(media_drm_bridge_);
}
MediaDrmBridgeCdmContextImpl::~MediaDrmBridgeCdmContextImpl() {}
MediaCryptoContextImpl::~MediaCryptoContextImpl() {}
int MediaDrmBridgeCdmContextImpl::RegisterPlayer(
const base::Closure& new_key_cb,
const base::Closure& cdm_unset_cb) {
int MediaCryptoContextImpl::RegisterPlayer(const base::Closure& new_key_cb,
const base::Closure& cdm_unset_cb) {
return media_drm_bridge_->RegisterPlayer(new_key_cb, cdm_unset_cb);
}
void MediaDrmBridgeCdmContextImpl::UnregisterPlayer(int registration_id) {
void MediaCryptoContextImpl::UnregisterPlayer(int registration_id) {
media_drm_bridge_->UnregisterPlayer(registration_id);
}
void MediaDrmBridgeCdmContextImpl::SetMediaCryptoReadyCB(
void MediaCryptoContextImpl::SetMediaCryptoReadyCB(
const MediaCryptoReadyCB& media_crypto_ready_cb) {
media_drm_bridge_->SetMediaCryptoReadyCB(media_crypto_ready_cb);
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_IMPL_H_
#define MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_IMPL_H_
#ifndef MEDIA_BASE_ANDROID_MEDIA_CRYPTO_CONTEXT_IMPL_H_
#define MEDIA_BASE_ANDROID_MEDIA_CRYPTO_CONTEXT_IMPL_H_
#include <jni.h>
......@@ -11,24 +11,23 @@
#include "base/android/scoped_java_ref.h"
#include "base/macros.h"
#include "media/base/android/media_drm_bridge_cdm_context.h"
#include "media/base/android/media_crypto_context.h"
#include "media/base/media_export.h"
namespace media {
class MediaDrmBridge;
// Implementation of MediaDrmBridgeCdmContext.
// Implementation of MediaCryptoContext.
//
// The registered callbacks will be fired on the thread |media_drm_bridge_| is
// running on.
class MEDIA_EXPORT MediaDrmBridgeCdmContextImpl
: public MediaDrmBridgeCdmContext {
class MEDIA_EXPORT MediaCryptoContextImpl : public MediaCryptoContext {
public:
// The |media_drm_bridge| owns |this| and is guaranteed to outlive |this|.
explicit MediaDrmBridgeCdmContextImpl(MediaDrmBridge* media_drm_bridge);
explicit MediaCryptoContextImpl(MediaDrmBridge* media_drm_bridge);
~MediaDrmBridgeCdmContextImpl() final;
~MediaCryptoContextImpl() final;
// PlayerTracker implementation.
// Methods can be called on any thread. The registered callbacks will be fired
......@@ -41,16 +40,16 @@ class MEDIA_EXPORT MediaDrmBridgeCdmContextImpl
const base::Closure& cdm_unset_cb) final;
void UnregisterPlayer(int registration_id) final;
// MediaDrmBridgeCdmContext implementation.
// MediaCryptoContext implementation.
void SetMediaCryptoReadyCB(
const MediaCryptoReadyCB& media_crypto_ready_cb) final;
private:
MediaDrmBridge* const media_drm_bridge_;
DISALLOW_COPY_AND_ASSIGN(MediaDrmBridgeCdmContextImpl);
DISALLOW_COPY_AND_ASSIGN(MediaCryptoContextImpl);
};
} // namespace media
#endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_CDM_CONTEXT_IMPL_H_
#endif // MEDIA_BASE_ANDROID_MEDIA_CRYPTO_CONTEXT_IMPL_H_
......@@ -585,9 +585,9 @@ void MediaDrmBridge::DeleteOnCorrectThread() const {
}
}
MediaDrmBridgeCdmContext* MediaDrmBridge::GetMediaDrmBridgeCdmContext() {
MediaCryptoContext* MediaDrmBridge::GetMediaCryptoContext() {
DVLOG(2) << __func__;
return &media_drm_bridge_cdm_context_;
return &media_crypto_context_;
}
int MediaDrmBridge::RegisterPlayer(const base::Closure& new_key_cb,
......@@ -871,7 +871,7 @@ MediaDrmBridge::MediaDrmBridge(
session_keys_change_cb_(session_keys_change_cb),
session_expiration_update_cb_(session_expiration_update_cb),
task_runner_(base::ThreadTaskRunnerHandle::Get()),
media_drm_bridge_cdm_context_(this),
media_crypto_context_(this),
weak_factory_(this) {
DVLOG(1) << __func__;
......
......@@ -19,8 +19,8 @@
#include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner_helpers.h"
#include "media/base/android/android_util.h"
#include "media/base/android/media_drm_bridge_cdm_context.h"
#include "media/base/android/media_drm_bridge_cdm_context_impl.h"
#include "media/base/android/media_crypto_context.h"
#include "media/base/android/media_crypto_context_impl.h"
#include "media/base/android/media_drm_storage.h"
#include "media/base/android/media_drm_storage_bridge.h"
#include "media/base/cdm_context.h"
......@@ -59,7 +59,7 @@ class MEDIA_EXPORT MediaDrmBridge : public ContentDecryptionModule,
};
using ResetCredentialsCB = base::Callback<void(bool)>;
using MediaCryptoReadyCB = MediaDrmBridgeCdmContext::MediaCryptoReadyCB;
using MediaCryptoReadyCB = MediaCryptoContext::MediaCryptoReadyCB;
using CreatedCB = base::OnceCallback<void(scoped_refptr<MediaDrmBridge>)>;
// Checks whether MediaDRM is available and usable, including for decoding.
......@@ -132,7 +132,7 @@ class MEDIA_EXPORT MediaDrmBridge : public ContentDecryptionModule,
void DeleteOnCorrectThread() const override;
// CdmContext implementation.
MediaDrmBridgeCdmContext* GetMediaDrmBridgeCdmContext() override;
MediaCryptoContext* GetMediaCryptoContext() override;
// Unprovision the origin bound with |this|. This will remove the cert for
// current origin and leave the offline licenses in invalid state (offline
......@@ -340,7 +340,7 @@ class MEDIA_EXPORT MediaDrmBridge : public ContentDecryptionModule,
// Default task runner.
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
MediaDrmBridgeCdmContextImpl media_drm_bridge_cdm_context_;
MediaCryptoContextImpl media_crypto_context_;
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<MediaDrmBridge> weak_factory_;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/android/mock_media_drm_bridge_cdm_context.h"
#include "media/base/android/mock_media_crypto_context.h"
#include "base/bind.h"
#include "base/callback.h"
......@@ -17,7 +17,7 @@ using ::testing::_;
namespace media {
MockMediaDrmBridgeCdmContext::MockMediaDrmBridgeCdmContext() {
MockMediaCryptoContext::MockMediaCryptoContext() {
// Provide some sane defaults.
ON_CALL(*this, RegisterPlayer(_, _))
.WillByDefault(DoAll(SaveArg<0>(&new_key_cb), SaveArg<1>(&cdm_unset_cb),
......@@ -30,10 +30,9 @@ MockMediaDrmBridgeCdmContext::MockMediaDrmBridgeCdmContext() {
EXPECT_CALL(*this, UnregisterPlayer(Not(kRegistrationId))).Times(0);
}
MockMediaDrmBridgeCdmContext::~MockMediaDrmBridgeCdmContext() {}
MockMediaCryptoContext::~MockMediaCryptoContext() {}
MediaDrmBridgeCdmContext*
MockMediaDrmBridgeCdmContext::GetMediaDrmBridgeCdmContext() {
MediaCryptoContext* MockMediaCryptoContext::GetMediaCryptoContext() {
return this;
}
......
......@@ -2,30 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_ANDROID_MOCK_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_
#define MEDIA_BASE_ANDROID_MOCK_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_
#ifndef MEDIA_BASE_ANDROID_MOCK_MEDIA_CRYPTO_CONTEXT_H_
#define MEDIA_BASE_ANDROID_MOCK_MEDIA_CRYPTO_CONTEXT_H_
#include <memory>
#include "base/macros.h"
#include "media/base/android/media_drm_bridge_cdm_context.h"
#include "media/base/android/media_crypto_context.h"
#include "media/base/cdm_context.h"
#include "media/base/media_export.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace media {
class MEDIA_EXPORT MockMediaDrmBridgeCdmContext
class MEDIA_EXPORT MockMediaCryptoContext
: public CdmContext,
public testing::NiceMock<MediaDrmBridgeCdmContext> {
public testing::NiceMock<MediaCryptoContext> {
public:
MockMediaDrmBridgeCdmContext();
~MockMediaDrmBridgeCdmContext() override;
MockMediaCryptoContext();
~MockMediaCryptoContext() override;
// CdmContext implementation.
MediaDrmBridgeCdmContext* GetMediaDrmBridgeCdmContext() override;
MediaCryptoContext* GetMediaCryptoContext() override;
// MediaDrmBridgeCdmContext implementation.
// MediaCryptoContext implementation.
MOCK_METHOD2(RegisterPlayer,
int(const base::Closure& new_key_cb,
const base::Closure& cdm_unset_cb));
......@@ -40,9 +40,9 @@ class MEDIA_EXPORT MockMediaDrmBridgeCdmContext
MediaCryptoReadyCB media_crypto_ready_cb;
private:
DISALLOW_COPY_AND_ASSIGN(MockMediaDrmBridgeCdmContext);
DISALLOW_COPY_AND_ASSIGN(MockMediaCryptoContext);
};
} // namespace media
#endif // MEDIA_BASE_ANDROID_MOCK_MEDIA_DRM_BRIDGE_CDM_CONTEXT_H_
#endif // MEDIA_BASE_ANDROID_MOCK_MEDIA_CRYPTO_CONTEXT_H_
......@@ -25,7 +25,7 @@ CdmProxyContext* CdmContext::GetCdmProxyContext() {
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
#if defined(OS_ANDROID)
MediaDrmBridgeCdmContext* CdmContext::GetMediaDrmBridgeCdmContext() {
MediaCryptoContext* CdmContext::GetMediaCryptoContext() {
return nullptr;
}
#endif
......
......@@ -15,7 +15,7 @@ namespace media {
class CdmProxyContext;
class Decryptor;
class MediaDrmBridgeCdmContext;
class MediaCryptoContext;
// An interface representing the context that a media player needs from a
// content decryption module (CDM) to decrypt (and decode) encrypted buffers.
......@@ -47,10 +47,10 @@ class MEDIA_EXPORT CdmContext {
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
#if defined(OS_ANDROID)
// Returns a MediaDrmBridgeCdmContext that can be used by MediaCodec based
// decoders. The returned object is only guaranteed to be valid during the
// CDM's lifetime.
virtual MediaDrmBridgeCdmContext* GetMediaDrmBridgeCdmContext();
// Returns a MediaCryptoContext that can be used by MediaCodec based decoders.
// The returned object is only guaranteed to be valid during the CDM's
// lifetime.
virtual MediaCryptoContext* GetMediaCryptoContext();
#endif
// Returns a unique class identifier. Some subclasses override and use this
......
......@@ -31,7 +31,7 @@ MediaCodecAudioDecoder::MediaCodecAudioDecoder(
channel_count_(0),
channel_layout_(CHANNEL_LAYOUT_NONE),
sample_rate_(0),
media_drm_bridge_cdm_context_(nullptr),
media_crypto_context_(nullptr),
cdm_registration_id_(0),
pool_(new AudioBufferMemoryPool()),
weak_factory_(this) {
......@@ -43,14 +43,14 @@ MediaCodecAudioDecoder::~MediaCodecAudioDecoder() {
codec_loop_.reset();
if (media_drm_bridge_cdm_context_) {
if (media_crypto_context_) {
DCHECK(cdm_registration_id_);
// Cancel previously registered callback (if any).
media_drm_bridge_cdm_context_->SetMediaCryptoReadyCB(
MediaDrmBridgeCdmContext::MediaCryptoReadyCB());
media_crypto_context_->SetMediaCryptoReadyCB(
MediaCryptoContext::MediaCryptoReadyCB());
media_drm_bridge_cdm_context_->UnregisterPlayer(cdm_registration_id_);
media_crypto_context_->UnregisterPlayer(cdm_registration_id_);
}
ClearInputQueue(DecodeStatus::ABORTED);
......@@ -106,11 +106,11 @@ void MediaCodecAudioDecoder::Initialize(
SetInitialConfiguration();
if (config_.is_encrypted() && !media_crypto_) {
media_drm_bridge_cdm_context_ =
cdm_context ? cdm_context->GetMediaDrmBridgeCdmContext() : nullptr;
if (!media_drm_bridge_cdm_context_) {
media_crypto_context_ =
cdm_context ? cdm_context->GetMediaCryptoContext() : nullptr;
if (!media_crypto_context_) {
LOG(ERROR) << "The stream is encrypted but there is no CdmContext or "
"MediaDrmBridgeCdmContext is not supported";
"MediaCryptoContext is not supported";
SetState(STATE_ERROR);
bound_init_cb.Run(false);
return;
......@@ -215,7 +215,7 @@ bool MediaCodecAudioDecoder::NeedsBitstreamConversion() const {
}
void MediaCodecAudioDecoder::SetCdm(const InitCB& init_cb) {
DCHECK(media_drm_bridge_cdm_context_);
DCHECK(media_crypto_context_);
// Register CDM callbacks. The callbacks registered will be posted back to
// this thread via BindToCurrentLoop.
......@@ -225,12 +225,12 @@ void MediaCodecAudioDecoder::SetCdm(const InitCB& init_cb) {
// destructed as well. So the |cdm_unset_cb| will never have a chance to be
// called.
// TODO(xhwang): Remove |cdm_unset_cb| after it's not used on all platforms.
cdm_registration_id_ = media_drm_bridge_cdm_context_->RegisterPlayer(
cdm_registration_id_ = media_crypto_context_->RegisterPlayer(
media::BindToCurrentLoop(base::Bind(&MediaCodecAudioDecoder::OnKeyAdded,
weak_factory_.GetWeakPtr())),
base::DoNothing());
media_drm_bridge_cdm_context_->SetMediaCryptoReadyCB(media::BindToCurrentLoop(
media_crypto_context_->SetMediaCryptoReadyCB(media::BindToCurrentLoop(
base::Bind(&MediaCodecAudioDecoder::OnMediaCryptoReady,
weak_factory_.GetWeakPtr(), init_cb)));
}
......
......@@ -15,7 +15,7 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "media/base/android/media_codec_loop.h"
#include "media/base/android/media_drm_bridge_cdm_context.h"
#include "media/base/android/media_crypto_context.h"
#include "media/base/audio_buffer.h"
#include "media/base/audio_decoder.h"
#include "media/base/audio_decoder_config.h"
......@@ -192,9 +192,8 @@ class MEDIA_EXPORT MediaCodecAudioDecoder : public AudioDecoder,
// CDM related stuff.
// CDM context that knowns about MediaCrypto. Owned by CDM which is external
// to this decoder.
MediaDrmBridgeCdmContext* media_drm_bridge_cdm_context_;
// Owned by CDM which is external to this decoder.
MediaCryptoContext* media_crypto_context_;
// MediaDrmBridge requires registration/unregistration of the player, this
// registration id is used for this.
......
......@@ -242,7 +242,7 @@ AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
state_(BEFORE_OVERLAY_INIT),
picturebuffers_requested_(false),
picture_buffer_manager_(this),
media_drm_bridge_cdm_context_(nullptr),
media_crypto_context_(nullptr),
cdm_registration_id_(0),
pending_input_buf_index_(-1),
during_initialize_(false),
......@@ -265,16 +265,16 @@ AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() {
codec_allocator_->StopThread(this);
#if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
if (!media_drm_bridge_cdm_context_)
if (!media_crypto_context_)
return;
DCHECK(cdm_registration_id_);
// Cancel previously registered callback (if any).
media_drm_bridge_cdm_context_->SetMediaCryptoReadyCB(
MediaDrmBridgeCdmContext::MediaCryptoReadyCB());
media_crypto_context_->SetMediaCryptoReadyCB(
MediaCryptoContext::MediaCryptoReadyCB());
media_drm_bridge_cdm_context_->UnregisterPlayer(cdm_registration_id_);
media_crypto_context_->UnregisterPlayer(cdm_registration_id_);
#endif // BUILDFLAG(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
}
......@@ -1459,10 +1459,10 @@ void AndroidVideoDecodeAccelerator::InitializeCdm() {
DCHECK(cdm_for_reference_holding_only_);
auto* cdm_context = cdm_for_reference_holding_only_->GetCdmContext();
media_drm_bridge_cdm_context_ =
cdm_context ? cdm_context->GetMediaDrmBridgeCdmContext() : nullptr;
if (!media_drm_bridge_cdm_context_) {
NOTIFY_ERROR(PLATFORM_FAILURE, "MediaDrmBridgeCdmContext not available.");
media_crypto_context_ =
cdm_context ? cdm_context->GetMediaCryptoContext() : nullptr;
if (!media_crypto_context_) {
NOTIFY_ERROR(PLATFORM_FAILURE, "MediaCryptoContext not available.");
return;
}
......@@ -1474,13 +1474,13 @@ void AndroidVideoDecodeAccelerator::InitializeCdm() {
// destructed as well. So the |cdm_unset_cb| will never have a chance to be
// called.
// TODO(xhwang): Remove |cdm_unset_cb| after it's not used on all platforms.
cdm_registration_id_ = media_drm_bridge_cdm_context_->RegisterPlayer(
cdm_registration_id_ = media_crypto_context_->RegisterPlayer(
BindToCurrentLoop(base::Bind(&AndroidVideoDecodeAccelerator::OnKeyAdded,
weak_this_factory_.GetWeakPtr())),
base::DoNothing());
// Deferred initialization will continue in OnMediaCryptoReady().
media_drm_bridge_cdm_context_->SetMediaCryptoReadyCB(BindToCurrentLoop(
media_crypto_context_->SetMediaCryptoReadyCB(BindToCurrentLoop(
base::Bind(&AndroidVideoDecodeAccelerator::OnMediaCryptoReady,
weak_this_factory_.GetWeakPtr())));
#endif // !BUILDFLAG(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
......@@ -1496,7 +1496,7 @@ void AndroidVideoDecodeAccelerator::OnMediaCryptoReady(
if (media_crypto->is_null()) {
LOG(ERROR) << "MediaCrypto is not available, can't play encrypted stream.";
cdm_for_reference_holding_only_ = nullptr;
media_drm_bridge_cdm_context_ = nullptr;
media_crypto_context_ = nullptr;
NOTIFY_ERROR(PLATFORM_FAILURE, "MediaCrypto is not available");
return;
}
......
......@@ -19,7 +19,7 @@
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/gpu_preferences.h"
#include "media/base/android/media_codec_bridge_impl.h"
#include "media/base/android/media_drm_bridge_cdm_context.h"
#include "media/base/android/media_crypto_context.h"
#include "media/base/android_overlay_mojo_factory.h"
#include "media/base/content_decryption_module.h"
#include "media/gpu/android/avda_codec_allocator.h"
......@@ -334,7 +334,8 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
// Holds a ref-count to the CDM to avoid using the CDM after it's destroyed.
scoped_refptr<ContentDecryptionModule> cdm_for_reference_holding_only_;
MediaDrmBridgeCdmContext* media_drm_bridge_cdm_context_;
// Owned by CDM which is external to this decoder.
MediaCryptoContext* media_crypto_context_;
// MediaDrmBridge requires registration/unregistration of the player, this
// registration id is used for this.
......
......@@ -22,7 +22,7 @@
#include "base/trace_event/trace_event.h"
#include "media/base/android/android_overlay.h"
#include "media/base/android/media_codec_bridge_impl.h"
#include "media/base/android/media_drm_bridge_cdm_context.h"
#include "media/base/android/media_crypto_context.h"
#include "media/base/media.h"
#include "media/base/surface_manager.h"
#include "media/base/video_codecs.h"
......
......@@ -133,16 +133,16 @@ MediaCodecVideoDecoder::~MediaCodecVideoDecoder() {
ReleaseCodec();
codec_allocator_->StopThread(this);
if (!media_drm_bridge_cdm_context_)
if (!media_crypto_context_)
return;
DCHECK(cdm_registration_id_);
// Cancel previously registered callback (if any).
media_drm_bridge_cdm_context_->SetMediaCryptoReadyCB(
MediaDrmBridgeCdmContext::MediaCryptoReadyCB());
media_crypto_context_->SetMediaCryptoReadyCB(
MediaCryptoContext::MediaCryptoReadyCB());
media_drm_bridge_cdm_context_->UnregisterPlayer(cdm_registration_id_);
media_crypto_context_->UnregisterPlayer(cdm_registration_id_);
}
void MediaCodecVideoDecoder::Destroy() {
......@@ -207,9 +207,9 @@ void MediaCodecVideoDecoder::SetCdm(CdmContext* cdm_context,
return;
}
media_drm_bridge_cdm_context_ = cdm_context->GetMediaDrmBridgeCdmContext();
if (!media_drm_bridge_cdm_context_) {
LOG(ERROR) << "MediaDrmBridgeCdmContext not supported";
media_crypto_context_ = cdm_context->GetMediaCryptoContext();
if (!media_crypto_context_) {
LOG(ERROR) << "MediaCryptoContext not supported";
EnterTerminalState(State::kError);
init_cb.Run(false);
return;
......@@ -223,12 +223,12 @@ void MediaCodecVideoDecoder::SetCdm(CdmContext* cdm_context,
// destructed as well. So the |cdm_unset_cb| will never have a chance to be
// called.
// TODO(xhwang): Remove |cdm_unset_cb| after it's not used on all platforms.
cdm_registration_id_ = media_drm_bridge_cdm_context_->RegisterPlayer(
cdm_registration_id_ = media_crypto_context_->RegisterPlayer(
media::BindToCurrentLoop(base::Bind(&MediaCodecVideoDecoder::OnKeyAdded,
weak_factory_.GetWeakPtr())),
base::DoNothing());
media_drm_bridge_cdm_context_->SetMediaCryptoReadyCB(media::BindToCurrentLoop(
media_crypto_context_->SetMediaCryptoReadyCB(media::BindToCurrentLoop(
base::Bind(&MediaCodecVideoDecoder::OnMediaCryptoReady,
weak_factory_.GetWeakPtr(), init_cb)));
}
......
......@@ -271,9 +271,8 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder
// CDM related stuff.
// CDM context that knowns about MediaCrypto. Owned by CDM which is external
// to this decoder.
MediaDrmBridgeCdmContext* media_drm_bridge_cdm_context_ = nullptr;
// Owned by CDM which is external to this decoder.
MediaCryptoContext* media_crypto_context_ = nullptr;
// MediaDrmBridge requires registration/unregistration of the player, this
// registration id is used for this.
......
......@@ -12,7 +12,7 @@
#include "gpu/command_buffer/service/gpu_preferences.h"
#include "media/base/android/media_codec_util.h"
#include "media/base/android/mock_android_overlay.h"
#include "media/base/android/mock_media_drm_bridge_cdm_context.h"
#include "media/base/android/mock_media_crypto_context.h"
#include "media/base/decoder_buffer.h"
#include "media/base/gmock_callback_support.h"
#include "media/base/test_helpers.h"
......@@ -150,7 +150,7 @@ class MediaCodecVideoDecoderTest : public testing::Test {
}
void CreateCdm(bool require_secure_video_decoder) {
cdm_ = std::make_unique<MockMediaDrmBridgeCdmContext>();
cdm_ = std::make_unique<MockMediaCryptoContext>();
require_secure_video_decoder_ = require_secure_video_decoder;
// We need to send an object as the media crypto, but MCVD shouldn't
......@@ -255,7 +255,7 @@ class MediaCodecVideoDecoderTest : public testing::Test {
MediaCodecVideoDecoder* mcvd_raw_;
std::unique_ptr<MediaCodecVideoDecoder> mcvd_;
// This must outlive |mcvd_| .
std::unique_ptr<MockMediaDrmBridgeCdmContext> cdm_;
std::unique_ptr<MockMediaCryptoContext> cdm_;
};
TEST_F(MediaCodecVideoDecoderTest, UnknownCodecIsRejected) {
......@@ -735,8 +735,7 @@ TEST_F(MediaCodecVideoDecoderTest, CdmInitializationWorksForL3) {
ASSERT_TRUE(codec_allocator_->most_recent_config->media_crypto->obj());
// When |mcvd_| is destroyed, expect that it will unregister itself.
EXPECT_CALL(*cdm_,
UnregisterPlayer(MockMediaDrmBridgeCdmContext::kRegistrationId));
EXPECT_CALL(*cdm_, UnregisterPlayer(MockMediaCryptoContext::kRegistrationId));
}
TEST_F(MediaCodecVideoDecoderTest, CdmInitializationWorksForL1) {
......@@ -754,16 +753,14 @@ TEST_F(MediaCodecVideoDecoderTest, CdmInitializationWorksForL1) {
ASSERT_TRUE(codec_allocator_->most_recent_config->media_crypto->obj());
// When |mcvd_| is destroyed, expect that it will unregister itself.
EXPECT_CALL(*cdm_,
UnregisterPlayer(MockMediaDrmBridgeCdmContext::kRegistrationId));
EXPECT_CALL(*cdm_, UnregisterPlayer(MockMediaCryptoContext::kRegistrationId));
}
TEST_F(MediaCodecVideoDecoderTest, CdmIsIgnoredIfNotEncrypted) {
CreateCdm(true);
// It should not register or unregister.
EXPECT_CALL(*cdm_, RegisterPlayer(_, _)).Times(0);
EXPECT_CALL(*cdm_,
UnregisterPlayer(MockMediaDrmBridgeCdmContext::kRegistrationId))
EXPECT_CALL(*cdm_, UnregisterPlayer(MockMediaCryptoContext::kRegistrationId))
.Times(0);
ASSERT_TRUE(Initialize(TestVideoConfig::NormalH264()));
ASSERT_TRUE(!cdm_->new_key_cb);
......@@ -779,8 +776,7 @@ TEST_F(MediaCodecVideoDecoderTest, MissingMediaCryptoFailsInit) {
media_crypto_ = nullptr;
EXPECT_CALL(*cdm_, RegisterPlayer(_, _));
ASSERT_FALSE(Initialize(TestVideoConfig::NormalEncrypted(kCodecH264)));
EXPECT_CALL(*cdm_,
UnregisterPlayer(MockMediaDrmBridgeCdmContext::kRegistrationId));
EXPECT_CALL(*cdm_, UnregisterPlayer(MockMediaCryptoContext::kRegistrationId));
}
TEST_F(MediaCodecVideoDecoderTest, MissingCdmFailsInit) {
......
......@@ -227,11 +227,11 @@ calls to the `Decryptor` in the remote CDM.
In some cases the media component is set to work with a specific CDM. For
example, on Android, MediaCodec-based decoders (e.g. `MediaCodecAudioDecoder`
and `AndroidVideoDecodeAccelerator`) can only use MediaDrm-based CDM via
`MediaDrmBridgeCdmContext`. The media component and the CDM must live in the
same process because the interaction of these two are typically happening deep
at the OS level. In theory, they can both live in the render process. But in
practice, typically both the CDM and the media component are hosted by the
MediaService in a remote (e.g. GPU) process.
`MediaCryptoContext`. The media component and the CDM must live in the same
process because the interaction of these two are typically happening deep at the
OS level. In theory, they can both live in the render process. But in practice,
typically both the CDM and the media component are hosted by the MediaService in
a remote (e.g. GPU) process.
To be able to attach a remote CDM with a remote media component, each
`InterfaceFactoryImpl` instance (corresponding to one `RenderFrame`) in the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment