#include "media/mojo/services/mojo_decryptor_service.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/numerics/safe_conversions.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/cdm_context.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decryptor.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_frame.h"
#include "media/mojo/common/media_type_converters.h"
#include "media/mojo/common/mojo_decoder_buffer_converter.h"
#include "media/mojo/mojom/demuxer_stream.mojom.h"
#include "media/mojo/services/mojo_cdm_service_context.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace media {
namespace {
class FrameResourceReleaserImpl final : public mojom::FrameResourceReleaser { … };
const char kInvalidStateMessage[] = …;
}
MojoDecryptorService::MojoDecryptorService(
media::Decryptor* decryptor,
std::unique_ptr<CdmContextRef> cdm_context_ref)
: … { … }
MojoDecryptorService::~MojoDecryptorService() { … }
void MojoDecryptorService::Initialize(
mojo::ScopedDataPipeConsumerHandle audio_pipe,
mojo::ScopedDataPipeConsumerHandle video_pipe,
mojo::ScopedDataPipeConsumerHandle decrypt_pipe,
mojo::ScopedDataPipeProducerHandle decrypted_pipe) { … }
void MojoDecryptorService::Decrypt(StreamType stream_type,
mojom::DecoderBufferPtr encrypted,
DecryptCallback callback) { … }
void MojoDecryptorService::CancelDecrypt(StreamType stream_type) { … }
void MojoDecryptorService::InitializeAudioDecoder(
const AudioDecoderConfig& config,
InitializeAudioDecoderCallback callback) { … }
void MojoDecryptorService::InitializeVideoDecoder(
const VideoDecoderConfig& config,
InitializeVideoDecoderCallback callback) { … }
void MojoDecryptorService::DecryptAndDecodeAudio(
mojom::DecoderBufferPtr encrypted,
DecryptAndDecodeAudioCallback callback) { … }
void MojoDecryptorService::DecryptAndDecodeVideo(
mojom::DecoderBufferPtr encrypted,
DecryptAndDecodeVideoCallback callback) { … }
void MojoDecryptorService::ResetDecoder(StreamType stream_type) { … }
void MojoDecryptorService::DeinitializeDecoder(StreamType stream_type) { … }
void MojoDecryptorService::OnReadDone(StreamType stream_type,
DecryptCallback callback,
scoped_refptr<DecoderBuffer> buffer) { … }
void MojoDecryptorService::OnDecryptDone(DecryptCallback callback,
Status status,
scoped_refptr<DecoderBuffer> buffer) { … }
void MojoDecryptorService::OnAudioDecoderInitialized(
InitializeAudioDecoderCallback callback,
bool success) { … }
void MojoDecryptorService::OnVideoDecoderInitialized(
InitializeVideoDecoderCallback callback,
bool success) { … }
void MojoDecryptorService::OnAudioRead(DecryptAndDecodeAudioCallback callback,
scoped_refptr<DecoderBuffer> buffer) { … }
void MojoDecryptorService::OnVideoRead(DecryptAndDecodeVideoCallback callback,
scoped_refptr<DecoderBuffer> buffer) { … }
void MojoDecryptorService::OnReaderFlushDone(StreamType stream_type) { … }
void MojoDecryptorService::OnAudioDecoded(
DecryptAndDecodeAudioCallback callback,
Status status,
const media::Decryptor::AudioFrames& frames) { … }
void MojoDecryptorService::OnVideoDecoded(
DecryptAndDecodeVideoCallback callback,
Status status,
scoped_refptr<VideoFrame> frame) { … }
MojoDecoderBufferReader* MojoDecryptorService::GetBufferReader(
StreamType stream_type) const { … }
}