#include "media/cdm/aes_decryptor.h"
#include <stddef.h>
#include <list>
#include <memory>
#include <utility>
#include <vector>
#include "base/logging.h"
#include "base/not_fatal_until.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "crypto/symmetric_key.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/cdm_promise.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decrypt_config.h"
#include "media/base/limits.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_frame.h"
#include "media/cdm/cbcs_decryptor.h"
#include "media/cdm/cenc_decryptor.h"
#include "media/cdm/cenc_utils.h"
#include "media/cdm/json_web_key.h"
namespace media {
namespace {
uint32_t Rand(uint32_t seed) { … }
std::string GenerateSessionId() { … }
}
class AesDecryptor::SessionIdDecryptionKeyMap { … };
void AesDecryptor::SessionIdDecryptionKeyMap::Insert(
const std::string& session_id,
std::unique_ptr<DecryptionKey> decryption_key) { … }
void AesDecryptor::SessionIdDecryptionKeyMap::Erase(
const std::string& session_id) { … }
AesDecryptor::SessionIdDecryptionKeyMap::KeyList::iterator
AesDecryptor::SessionIdDecryptionKeyMap::Find(const std::string& session_id) { … }
void AesDecryptor::SessionIdDecryptionKeyMap::Erase(
KeyList::iterator position) { … }
static scoped_refptr<DecoderBuffer> DecryptData(
const DecoderBuffer& input,
const crypto::SymmetricKey& key) { … }
AesDecryptor::AesDecryptor(
const SessionMessageCB& session_message_cb,
const SessionClosedCB& session_closed_cb,
const SessionKeysChangeCB& session_keys_change_cb,
const SessionExpirationUpdateCB& )
: … { … }
AesDecryptor::~AesDecryptor() { … }
void AesDecryptor::SetServerCertificate(
const std::vector<uint8_t>& certificate,
std::unique_ptr<SimpleCdmPromise> promise) { … }
void AesDecryptor::CreateSessionAndGenerateRequest(
CdmSessionType session_type,
EmeInitDataType init_data_type,
const std::vector<uint8_t>& init_data,
std::unique_ptr<NewSessionCdmPromise> promise) { … }
void AesDecryptor::LoadSession(CdmSessionType session_type,
const std::string& session_id,
std::unique_ptr<NewSessionCdmPromise> promise) { … }
void AesDecryptor::UpdateSession(const std::string& session_id,
const std::vector<uint8_t>& response,
std::unique_ptr<SimpleCdmPromise> promise) { … }
bool AesDecryptor::UpdateSessionWithJWK(const std::string& session_id,
const std::string& json_web_key_set,
bool* key_added,
CdmPromise::Exception* exception,
std::string* error_message) { … }
void AesDecryptor::FinishUpdate(const std::string& session_id,
bool key_added,
std::unique_ptr<SimpleCdmPromise> promise) { … }
void AesDecryptor::CloseSession(const std::string& session_id,
std::unique_ptr<SimpleCdmPromise> promise) { … }
void AesDecryptor::RemoveSession(const std::string& session_id,
std::unique_ptr<SimpleCdmPromise> promise) { … }
CdmContext* AesDecryptor::GetCdmContext() { … }
std::unique_ptr<CallbackRegistration> AesDecryptor::RegisterEventCB(
EventCB event_cb) { … }
Decryptor* AesDecryptor::GetDecryptor() { … }
void AesDecryptor::Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted,
DecryptCB decrypt_cb) { … }
void AesDecryptor::CancelDecrypt(StreamType stream_type) { … }
void AesDecryptor::InitializeAudioDecoder(const AudioDecoderConfig& config,
DecoderInitCB init_cb) { … }
void AesDecryptor::InitializeVideoDecoder(const VideoDecoderConfig& config,
DecoderInitCB init_cb) { … }
void AesDecryptor::DecryptAndDecodeAudio(scoped_refptr<DecoderBuffer> encrypted,
AudioDecodeCB audio_decode_cb) { … }
void AesDecryptor::DecryptAndDecodeVideo(scoped_refptr<DecoderBuffer> encrypted,
VideoDecodeCB video_decode_cb) { … }
void AesDecryptor::ResetDecoder(StreamType stream_type) { … }
void AesDecryptor::DeinitializeDecoder(StreamType stream_type) { … }
bool AesDecryptor::CanAlwaysDecrypt() { … }
bool AesDecryptor::CreateSession(const std::string& session_id,
CdmSessionType session_type) { … }
std::string AesDecryptor::GetSessionStateAsJWK(const std::string& session_id) { … }
bool AesDecryptor::AddDecryptionKey(const std::string& session_id,
const std::string& key_id,
const std::string& key_string) { … }
AesDecryptor::DecryptionKey* AesDecryptor::GetKey_Locked(
const std::string& key_id) const { … }
bool AesDecryptor::HasKey(const std::string& session_id,
const std::string& key_id) { … }
void AesDecryptor::DeleteKeysForSession(const std::string& session_id) { … }
CdmKeysInfo AesDecryptor::GenerateKeysInfoList(
const std::string& session_id,
CdmKeyInformation::KeyStatus status) { … }
AesDecryptor::DecryptionKey::DecryptionKey(const std::string& secret)
: … { … }
AesDecryptor::DecryptionKey::~DecryptionKey() = default;
bool AesDecryptor::DecryptionKey::Init() { … }
}