#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/cdm/library_cdm/clear_key_cdm/ffmpeg_cdm_audio_decoder.h"
#include <stddef.h>
#include <algorithm>
#include <memory>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "media/base/audio_bus.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/data_buffer.h"
#include "media/base/limits.h"
#include "media/cdm/library_cdm/cdm_host_proxy.h"
#include "media/ffmpeg/ffmpeg_common.h"
#include "media/ffmpeg/ffmpeg_decoding_loop.h"
namespace media {
namespace {
static const int kMaxChannels = …;
bool IsValidConfig(const cdm::AudioDecoderConfig_2& config) { … }
AVCodecID CdmAudioCodecToCodecID(cdm::AudioCodec audio_codec) { … }
void CdmAudioDecoderConfigToAVCodecContext(
const cdm::AudioDecoderConfig_2& config,
AVCodecContext* codec_context) { … }
cdm::AudioFormat AVSampleFormatToCdmAudioFormat(AVSampleFormat sample_format) { … }
void CopySamples(cdm::AudioFormat cdm_format,
int decoded_audio_size,
const AVFrame& av_frame,
uint8_t* output_buffer) { … }
}
FFmpegCdmAudioDecoder::FFmpegCdmAudioDecoder(CdmHostProxy* cdm_host_proxy)
: … { … }
FFmpegCdmAudioDecoder::~FFmpegCdmAudioDecoder() { … }
bool FFmpegCdmAudioDecoder::Initialize(
const cdm::AudioDecoderConfig_2& config) { … }
void FFmpegCdmAudioDecoder::Deinitialize() { … }
void FFmpegCdmAudioDecoder::Reset() { … }
cdm::Status FFmpegCdmAudioDecoder::DecodeBuffer(
const uint8_t* compressed_buffer,
int32_t compressed_buffer_size,
int64_t input_timestamp,
cdm::AudioFrames* decoded_frames) { … }
bool FFmpegCdmAudioDecoder::OnNewFrame(
size_t* total_size,
std::vector<std::unique_ptr<AVFrame, ScopedPtrAVFreeFrame>>* audio_frames,
AVFrame* frame) { … }
void FFmpegCdmAudioDecoder::ResetTimestampState() { … }
void FFmpegCdmAudioDecoder::ReleaseFFmpegResources() { … }
void FFmpegCdmAudioDecoder::SerializeInt64(int64_t value, uint8_t* dest) { … }
}