#include "third_party/blink/renderer/platform/media/cdm_session_adapter.h"
#include <memory>
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_functions.h"
#include "base/trace_event/trace_event.h"
#include "base/types/pass_key.h"
#include "media/base/cdm_factory.h"
#include "media/base/cdm_key_information.h"
#include "media/base/cdm_promise.h"
#include "media/base/key_systems.h"
#include "media/cdm/cdm_context_ref_impl.h"
#include "third_party/blink/renderer/platform/media/web_content_decryption_module_session_impl.h"
namespace blink {
namespace {
const char kMediaEME[] = …;
const char kDot[] = …;
const char kCreateCdmUMAName[] = …;
const char kCreateCdmStatusUMAName[] = …;
const char kTimeToCreateCdmUMAName[] = …;
}
CdmSessionAdapter::CdmSessionAdapter(media::KeySystems* key_systems)
: … { … }
CdmSessionAdapter::~CdmSessionAdapter() = default;
void CdmSessionAdapter::CreateCdm(media::CdmFactory* cdm_factory,
const media::CdmConfig& cdm_config,
WebCdmCreatedCB web_cdm_created_cb) { … }
void CdmSessionAdapter::SetServerCertificate(
const std::vector<uint8_t>& certificate,
std::unique_ptr<media::SimpleCdmPromise> promise) { … }
void CdmSessionAdapter::GetStatusForPolicy(
media::HdcpVersion min_hdcp_version,
std::unique_ptr<media::KeyStatusCdmPromise> promise) { … }
std::unique_ptr<WebContentDecryptionModuleSessionImpl>
CdmSessionAdapter::CreateSession(WebEncryptedMediaSessionType session_type) { … }
bool CdmSessionAdapter::RegisterSession(
const std::string& session_id,
base::WeakPtr<WebContentDecryptionModuleSessionImpl> session) { … }
void CdmSessionAdapter::UnregisterSession(const std::string& session_id) { … }
void CdmSessionAdapter::InitializeNewSession(
media::EmeInitDataType init_data_type,
const std::vector<uint8_t>& init_data,
media::CdmSessionType session_type,
std::unique_ptr<media::NewSessionCdmPromise> promise) { … }
void CdmSessionAdapter::LoadSession(
media::CdmSessionType session_type,
const std::string& session_id,
std::unique_ptr<media::NewSessionCdmPromise> promise) { … }
void CdmSessionAdapter::UpdateSession(
const std::string& session_id,
const std::vector<uint8_t>& response,
std::unique_ptr<media::SimpleCdmPromise> promise) { … }
void CdmSessionAdapter::CloseSession(
const std::string& session_id,
std::unique_ptr<media::SimpleCdmPromise> promise) { … }
void CdmSessionAdapter::RemoveSession(
const std::string& session_id,
std::unique_ptr<media::SimpleCdmPromise> promise) { … }
std::unique_ptr<media::CdmContextRef> CdmSessionAdapter::GetCdmContextRef() { … }
const std::string& CdmSessionAdapter::GetKeySystem() const { … }
const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const { … }
const media::CdmConfig& CdmSessionAdapter::GetCdmConfig() const { … }
void CdmSessionAdapter::OnCdmCreated(
const media::CdmConfig& cdm_config,
base::TimeTicks start_time,
const scoped_refptr<media::ContentDecryptionModule>& cdm,
media::CreateCdmStatus status) { … }
void CdmSessionAdapter::OnSessionMessage(const std::string& session_id,
media::CdmMessageType message_type,
const std::vector<uint8_t>& message) { … }
void CdmSessionAdapter::OnSessionKeysChange(const std::string& session_id,
bool has_additional_usable_key,
media::CdmKeysInfo keys_info) { … }
void CdmSessionAdapter::OnSessionExpirationUpdate(const std::string& session_id,
base::Time new_expiry_time) { … }
void CdmSessionAdapter::OnSessionClosed(const std::string& session_id,
media::CdmSessionClosedReason reason) { … }
WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession(
const std::string& session_id) { … }
}