Commit fa26b632 authored by xhwang's avatar xhwang Committed by Commit bot

Add MediaKeys::GetCdmId().

BUG=422730

Review URL: https://codereview.chromium.org/665563002

Cr-Commit-Position: refs/heads/master@{#300401}
parent 34989288
......@@ -261,7 +261,7 @@ void RendererMediaPlayerManager::ExitFullscreen(int player_id) {
}
void RendererMediaPlayerManager::SetCdm(int player_id, int cdm_id) {
if (cdm_id == RendererCdmManager::kInvalidCdmId) {
if (cdm_id == media::MediaKeys::kInvalidCdmId) {
NOTREACHED();
return;
}
......
......@@ -36,7 +36,6 @@
#include "media/base/android/media_common_android.h"
#include "media/base/android/media_player_android.h"
#include "media/base/bind_to_current_loop.h"
// TODO(xhwang): Remove when we remove prefixed EME implementation.
#include "media/base/media_keys.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
......@@ -179,7 +178,7 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
// Set the initial CDM, if specified.
if (initial_cdm) {
web_cdm_ = ToWebContentDecryptionModuleImpl(initial_cdm);
if (web_cdm_->GetCdmId() != RendererCdmManager::kInvalidCdmId)
if (web_cdm_->GetCdmId() != media::MediaKeys::kInvalidCdmId)
player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId());
}
}
......@@ -1538,7 +1537,7 @@ WebMediaPlayerAndroid::GenerateKeyRequestInternal(
// Only browser CDMs have CDM ID. Render side CDMs (e.g. ClearKey CDM) do
// not have a CDM ID and there is no need to call player_manager_->SetCdm().
if (proxy_decryptor_->GetCdmId() != RendererCdmManager::kInvalidCdmId)
if (proxy_decryptor_->GetCdmId() != media::MediaKeys::kInvalidCdmId)
player_manager_->SetCdm(player_id_, proxy_decryptor_->GetCdmId());
current_key_system_ = key_system;
......@@ -1657,7 +1656,7 @@ void WebMediaPlayerAndroid::setContentDecryptionModule(
.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing));
}
if (web_cdm_->GetCdmId() != RendererCdmManager::kInvalidCdmId)
if (web_cdm_->GetCdmId() != media::MediaKeys::kInvalidCdmId)
player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId());
}
......@@ -1691,7 +1690,7 @@ void WebMediaPlayerAndroid::setContentDecryptionModule(
ContentDecryptionModuleAttached(result, true);
}
if (web_cdm_->GetCdmId() != RendererCdmManager::kInvalidCdmId)
if (web_cdm_->GetCdmId() != media::MediaKeys::kInvalidCdmId)
player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId());
}
......
......@@ -15,21 +15,13 @@
#include "media/base/media_keys.h"
#include "url/gurl.h"
#if defined(ENABLE_BROWSER_CDMS)
#include "content/renderer/media/crypto/renderer_cdm_manager.h"
#endif // defined(ENABLE_BROWSER_CDMS)
namespace content {
const char kMediaEME[] = "Media.EME.";
const char kDot[] = ".";
CdmSessionAdapter::CdmSessionAdapter() :
#if defined(ENABLE_BROWSER_CDMS)
// TODO(xhwang): Move kInvalidCdmId to src/media.
cdm_id_(RendererCdmManager::kInvalidCdmId),
#endif
weak_ptr_factory_(this) {}
CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) {
}
CdmSessionAdapter::~CdmSessionAdapter() {}
......@@ -45,9 +37,6 @@ bool CdmSessionAdapter::Initialize(media::CdmFactory* cdm_factory,
media_keys_ = cdm_factory->Create(
key_system,
security_origin,
#if defined(ENABLE_BROWSER_CDMS)
&cdm_id_,
#endif // defined(ENABLE_PEPPER_CDMS)
base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this),
base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
......@@ -143,7 +132,7 @@ const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const {
#if defined(ENABLE_BROWSER_CDMS)
int CdmSessionAdapter::GetCdmId() const {
return cdm_id_;
return media_keys_->GetCdmId();
}
#endif // defined(ENABLE_BROWSER_CDMS)
......
......@@ -137,10 +137,6 @@ class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> {
SessionMap sessions_;
#if defined(ENABLE_BROWSER_CDMS)
int cdm_id_;
#endif
std::string key_system_uma_prefix_;
// NOTE: Weak pointers must be invalidated before all other member variables.
......
......@@ -15,10 +15,6 @@
#include "media/cdm/json_web_key.h"
#include "media/cdm/key_system_names.h"
#if defined(ENABLE_BROWSER_CDMS)
#include "content/renderer/media/crypto/renderer_cdm_manager.h"
#endif // defined(ENABLE_BROWSER_CDMS)
namespace content {
// Special system code to signal a closed persistent session in a SessionError()
......@@ -33,9 +29,6 @@ ProxyDecryptor::ProxyDecryptor(const KeyAddedCB& key_added_cb,
key_error_cb_(key_error_cb),
key_message_cb_(key_message_cb),
is_clear_key_(false),
#if defined(ENABLE_BROWSER_CDMS)
cdm_id_(RendererCdmManager::kInvalidCdmId),
#endif // defined(ENABLE_PEPPER_CDMS)
weak_ptr_factory_(this) {
DCHECK(!key_added_cb_.is_null());
DCHECK(!key_error_cb_.is_null());
......@@ -53,7 +46,7 @@ media::Decryptor* ProxyDecryptor::GetDecryptor() {
#if defined(ENABLE_BROWSER_CDMS)
int ProxyDecryptor::GetCdmId() {
return cdm_id_;
return media_keys_->GetCdmId();
}
#endif
......@@ -214,9 +207,6 @@ scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys(
return cdm_factory->Create(
key_system,
security_origin,
#if defined(ENABLE_BROWSER_CDMS)
&cdm_id_,
#endif
base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this),
base::Bind(&ProxyDecryptor::OnSessionReady, weak_this),
base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this),
......
......@@ -23,10 +23,6 @@ class CdmFactory;
namespace content {
#if defined(ENABLE_BROWSER_CDMS)
class RendererCdmManager;
#endif // defined(ENABLE_BROWSER_CDMS)
// ProxyDecryptor is for EME v0.1b only. It should not be used for the WD API.
// A decryptor proxy that creates a real decryptor object on demand and
// forwards decryptor calls to it.
......
......@@ -142,6 +142,10 @@ void ProxyMediaKeys::GetUsableKeyIds(const std::string& web_session_id,
promise->reject(NOT_SUPPORTED_ERROR, 0, "Not yet implemented.");
}
int ProxyMediaKeys::GetCdmId() const {
return cdm_id_;
}
void ProxyMediaKeys::OnSessionCreated(uint32 session_id,
const std::string& web_session_id) {
AssignWebSessionId(session_id, web_session_id);
......@@ -218,10 +222,6 @@ void ProxyMediaKeys::OnSessionError(uint32 session_id,
web_session_id, exception_code, system_code, std::string());
}
int ProxyMediaKeys::GetCdmId() const {
return cdm_id_;
}
ProxyMediaKeys::ProxyMediaKeys(
RendererCdmManager* manager,
const media::SessionMessageCB& session_message_cb,
......
......@@ -64,6 +64,7 @@ class ProxyMediaKeys : public media::MediaKeys {
virtual void GetUsableKeyIds(
const std::string& web_session_id,
scoped_ptr<media::KeyIdsPromise> promise) override;
virtual int GetCdmId() const override;
// Callbacks.
void OnSessionCreated(uint32 session_id, const std::string& web_session_id);
......@@ -76,8 +77,6 @@ class ProxyMediaKeys : public media::MediaKeys {
media::MediaKeys::KeyError error_code,
uint32 system_code);
int GetCdmId() const;
private:
// The Android-specific code that handles sessions uses integer session ids
// (basically a reference id), but media::MediaKeys bases everything on
......
......@@ -13,7 +13,6 @@
#include "content/renderer/media/crypto/ppapi_decryptor.h"
#elif defined(ENABLE_BROWSER_CDMS)
#include "content/renderer/media/crypto/proxy_media_keys.h"
#include "content/renderer/media/crypto/renderer_cdm_manager.h"
#endif // defined(ENABLE_PEPPER_CDMS)
namespace content {
......@@ -38,9 +37,6 @@ RenderCdmFactory::~RenderCdmFactory() {
scoped_ptr<media::MediaKeys> RenderCdmFactory::Create(
const std::string& key_system,
const GURL& security_origin,
#if defined(ENABLE_BROWSER_CDMS)
int* cdm_id,
#endif
const media::SessionMessageCB& session_message_cb,
const media::SessionReadyCB& session_ready_cb,
const media::SessionClosedCB& session_closed_cb,
......@@ -52,10 +48,6 @@ scoped_ptr<media::MediaKeys> RenderCdmFactory::Create(
// check the security origin before calling.
// DCHECK(security_origin.is_valid());
#if defined(ENABLE_BROWSER_CDMS)
*cdm_id = RendererCdmManager::kInvalidCdmId;
#endif
if (CanUseAesDecryptor(key_system)) {
return scoped_ptr<media::MediaKeys>(new media::AesDecryptor(
session_message_cb, session_closed_cb, session_keys_change_cb));
......@@ -73,7 +65,7 @@ scoped_ptr<media::MediaKeys> RenderCdmFactory::Create(
session_keys_change_cb,
session_expiration_update_cb));
#elif defined(ENABLE_BROWSER_CDMS)
scoped_ptr<ProxyMediaKeys> proxy_media_keys =
return scoped_ptr<media::MediaKeys>(
ProxyMediaKeys::Create(key_system,
security_origin,
manager_,
......@@ -82,10 +74,7 @@ scoped_ptr<media::MediaKeys> RenderCdmFactory::Create(
session_closed_cb,
session_error_cb,
session_keys_change_cb,
session_expiration_update_cb);
if (proxy_media_keys)
*cdm_id = proxy_media_keys->GetCdmId();
return proxy_media_keys.Pass();
session_expiration_update_cb));
#else
return nullptr;
#endif // defined(ENABLE_PEPPER_CDMS)
......
......@@ -38,9 +38,6 @@ class RenderCdmFactory : public media::CdmFactory {
virtual scoped_ptr<media::MediaKeys> Create(
const std::string& key_system,
const GURL& security_origin,
#if defined(ENABLE_BROWSER_CDMS)
int* cdm_id,
#endif
const media::SessionMessageCB& session_message_cb,
const media::SessionReadyCB& session_ready_cb,
const media::SessionClosedCB& session_closed_cb,
......
......@@ -18,7 +18,7 @@ const size_t kMaxSessionMessageLength = 10240; // 10 KB
RendererCdmManager::RendererCdmManager(RenderFrame* render_frame)
: RenderFrameObserver(render_frame),
next_cdm_id_(kInvalidCdmId + 1) {
next_cdm_id_(media::MediaKeys::kInvalidCdmId + 1) {
}
RendererCdmManager::~RendererCdmManager() {
......@@ -127,7 +127,7 @@ void RendererCdmManager::OnSessionError(int cdm_id,
int RendererCdmManager::RegisterMediaKeys(ProxyMediaKeys* media_keys) {
int cdm_id = next_cdm_id_++;
DCHECK_NE(cdm_id, kInvalidCdmId);
DCHECK_NE(cdm_id, media::MediaKeys::kInvalidCdmId);
DCHECK(!ContainsKey(proxy_media_keys_map_, cdm_id));
proxy_media_keys_map_[cdm_id] = media_keys;
return cdm_id;
......
......@@ -26,8 +26,6 @@ class ProxyMediaKeys;
// Class for managing all the CDM objects in the same RenderFrame.
class RendererCdmManager : public RenderFrameObserver {
public:
static const int kInvalidCdmId = 0;
// Constructs a RendererCdmManager object for the |render_frame|.
explicit RendererCdmManager(RenderFrame* render_frame);
virtual ~RendererCdmManager();
......
......@@ -23,9 +23,6 @@ class MEDIA_EXPORT CdmFactory {
virtual scoped_ptr<MediaKeys> Create(
const std::string& key_system,
const GURL& security_origin,
#if defined(ENABLE_BROWSER_CDMS)
int* cdm_id, // Output parameter indicating the CDM ID of the MediaKeys.
#endif
const SessionMessageCB& session_message_cb,
const SessionReadyCB& session_ready_cb,
const SessionClosedCB& session_closed_cb,
......
......@@ -10,6 +10,8 @@ MediaKeys::MediaKeys() {}
MediaKeys::~MediaKeys() {}
Decryptor* MediaKeys::GetDecryptor() { return NULL; }
Decryptor* MediaKeys::GetDecryptor() {
return NULL;
}
} // namespace media
......@@ -71,7 +71,10 @@ class MEDIA_EXPORT MediaKeys {
PERSISTENT_SESSION
};
const static uint32 kInvalidSessionId = 0;
static const uint32 kInvalidSessionId = 0;
#if defined(ENABLE_BROWSER_CDMS)
static const int kInvalidCdmId = 0;
#endif
MediaKeys();
virtual ~MediaKeys();
......@@ -123,6 +126,12 @@ class MEDIA_EXPORT MediaKeys {
// to be valid during the MediaKeys' lifetime.
virtual Decryptor* GetDecryptor();
#if defined(ENABLE_BROWSER_CDMS)
// Returns the CDM ID associated with |this|. May be kInvalidCdmId if no CDM
// ID is associated.
virtual int GetCdmId() const = 0;
#endif
private:
DISALLOW_COPY_AND_ASSIGN(MediaKeys);
};
......
......@@ -388,6 +388,12 @@ Decryptor* AesDecryptor::GetDecryptor() {
return this;
}
#if defined(ENABLE_BROWSER_CDMS)
int AesDecryptor::GetCdmId() const {
return kInvalidCdmId;
}
#endif // defined(ENABLE_BROWSER_CDMS)
void AesDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& new_key_cb) {
base::AutoLock auto_lock(new_key_cb_lock_);
......
......@@ -55,6 +55,9 @@ class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor {
virtual void GetUsableKeyIds(const std::string& web_session_id,
scoped_ptr<KeyIdsPromise> promise) override;
virtual Decryptor* GetDecryptor() override;
#if defined(ENABLE_BROWSER_CDMS)
virtual int GetCdmId() const override;
#endif // defined(ENABLE_BROWSER_CDMS)
// Decryptor implementation.
virtual void RegisterNewKeyCB(StreamType stream_type,
......
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