#include "media/cdm/library_cdm/clear_key_cdm/clear_key_persistent_session_cdm.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/ref_counted.h"
#include "media/base/cdm_promise.h"
#include "media/cdm/json_web_key.h"
namespace media {
namespace {
class NewPersistentSessionCdmPromise : public NewSessionCdmPromise { … };
class FinishLoadCdmPromise : public SimpleCdmPromise { … };
}
ClearKeyPersistentSessionCdm::ClearKeyPersistentSessionCdm(
CdmHostProxy* cdm_host_proxy,
const SessionMessageCB& session_message_cb,
const SessionClosedCB& session_closed_cb,
const SessionKeysChangeCB& session_keys_change_cb,
const SessionExpirationUpdateCB& session_expiration_update_cb)
: … { … }
ClearKeyPersistentSessionCdm::~ClearKeyPersistentSessionCdm() = default;
void ClearKeyPersistentSessionCdm::SetServerCertificate(
const std::vector<uint8_t>& certificate,
std::unique_ptr<SimpleCdmPromise> promise) { … }
void ClearKeyPersistentSessionCdm::CreateSessionAndGenerateRequest(
CdmSessionType session_type,
EmeInitDataType init_data_type,
const std::vector<uint8_t>& init_data,
std::unique_ptr<NewSessionCdmPromise> promise) { … }
void ClearKeyPersistentSessionCdm::LoadSession(
CdmSessionType session_type,
const std::string& session_id,
std::unique_ptr<NewSessionCdmPromise> promise) { … }
void ClearKeyPersistentSessionCdm::OnFileOpenedForLoadSession(
const std::string& session_id,
std::unique_ptr<CdmFileAdapter> file,
std::unique_ptr<NewSessionCdmPromise> promise,
CdmFileAdapter::Status status) { … }
void ClearKeyPersistentSessionCdm::OnFileReadForLoadSession(
const std::string& session_id,
std::unique_ptr<CdmFileAdapter> file,
std::unique_ptr<NewSessionCdmPromise> promise,
bool success,
const std::vector<uint8_t>& data) { … }
void ClearKeyPersistentSessionCdm::UpdateSession(
const std::string& session_id,
const std::vector<uint8_t>& response,
std::unique_ptr<SimpleCdmPromise> promise) { … }
void ClearKeyPersistentSessionCdm::OnFileOpenedForUpdateSession(
const std::string& session_id,
bool key_added,
std::unique_ptr<CdmFileAdapter> file,
std::unique_ptr<SimpleCdmPromise> promise,
CdmFileAdapter::Status status) { … }
void ClearKeyPersistentSessionCdm::OnFileWrittenForUpdateSession(
const std::string& session_id,
bool key_added,
std::unique_ptr<CdmFileAdapter> file,
std::unique_ptr<SimpleCdmPromise> promise,
bool success) { … }
void ClearKeyPersistentSessionCdm::CloseSession(
const std::string& session_id,
std::unique_ptr<SimpleCdmPromise> promise) { … }
void ClearKeyPersistentSessionCdm::RemoveSession(
const std::string& session_id,
std::unique_ptr<SimpleCdmPromise> promise) { … }
void ClearKeyPersistentSessionCdm::OnFileOpenedForRemoveSession(
const std::string& session_id,
std::unique_ptr<CdmFileAdapter> file,
std::unique_ptr<SimpleCdmPromise> promise,
CdmFileAdapter::Status status) { … }
void ClearKeyPersistentSessionCdm::OnFileWrittenForRemoveSession(
const std::string& session_id,
std::unique_ptr<CdmFileAdapter> file,
std::unique_ptr<SimpleCdmPromise> promise,
bool success) { … }
CdmContext* ClearKeyPersistentSessionCdm::GetCdmContext() { … }
void ClearKeyPersistentSessionCdm::AddPersistentSession(
const std::string& session_id) { … }
void ClearKeyPersistentSessionCdm::OnSessionClosed(
const std::string& session_id,
CdmSessionClosedReason reason) { … }
void ClearKeyPersistentSessionCdm::OnSessionMessage(
const std::string& session_id,
CdmMessageType message_type,
const std::vector<uint8_t>& message) { … }
}