#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/audio/audio_opus_encoder.h"
#include <utility>
#include "base/containers/heap_array.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/checked_math.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "media/base/audio_encoder.h"
#include "media/base/channel_mixer.h"
#include "media/base/converting_audio_fifo.h"
#include "media/base/encoder_status.h"
#include "media/base/timestamp_constants.h"
namespace media {
namespace {
constexpr int kOpusPreferredSamplingRate = …;
constexpr base::TimeDelta kDefaultOpusBufferDuration = …;
inline void OpusEncoderDeleter(OpusEncoder* encoder_ptr) { … }
base::TimeDelta GetFrameDuration(
const std::optional<AudioEncoder::OpusOptions> opus_options) { … }
AudioParameters CreateInputParams(const AudioEncoder::Options& options,
base::TimeDelta frame_duration) { … }
AudioParameters CreateOpusCompatibleParams(const AudioParameters& params,
base::TimeDelta frame_duration) { … }
}
AudioOpusEncoder::AudioOpusEncoder()
: … { … }
void AudioOpusEncoder::Initialize(const Options& options,
OutputCB output_callback,
EncoderStatusCB done_cb) { … }
AudioOpusEncoder::~AudioOpusEncoder() = default;
AudioOpusEncoder::CodecDescription AudioOpusEncoder::PrepareExtraData() { … }
void AudioOpusEncoder::Encode(std::unique_ptr<AudioBus> audio_bus,
base::TimeTicks capture_time,
EncoderStatusCB done_cb) { … }
void AudioOpusEncoder::Flush(EncoderStatusCB done_cb) { … }
void AudioOpusEncoder::DrainFifoOutput() { … }
void AudioOpusEncoder::DoEncode(const AudioBus* audio_bus) { … }
EncoderStatus::Or<OwnedOpusEncoder> AudioOpusEncoder::CreateOpusEncoder(
const std::optional<AudioEncoder::OpusOptions>& opus_options) { … }
}