4#include "VOAACEncoder.h"
8#ifndef VOAAC_DEFAULT_BITRATE
9#define VOAAC_DEFAULT_BITRATE 128000
12#ifndef VOAAC_DEFAULT_OUTPUT_BUFFER_SIZE
13#define VOAAC_DEFAULT_OUTPUT_BUFFER_SIZE 2048
60 LOGE(
"Output undefined");
63 if (
info.channels < 1 ||
info.channels > 2) {
64 LOGE(
"Invalid channels: %d",
info.channels);
67 if (
info.bits_per_sample != 16) {
68 LOGE(
"bits_per_sample must be 16, got %d",
info.bits_per_sample);
73 VOAACEncoder::kFrameSamplesPerChannel *
info.channels *
sizeof(int16_t);
78 uint32_t effective_bitrate =
82 LOGE(
"VO AAC encoder init failed");
88 size_t write(
const uint8_t *data,
size_t len)
override {
89 if (!
active || data ==
nullptr || len == 0)
93 while (processed < len) {
95 size_t to_copy = (len - processed) < open ? (len - processed) : open;
126 const char *
mime()
override {
return "audio/aac"; }
128 operator bool()
override {
return active &&
enc.isReady(); }
150 ref_bps *= 96.0 / 128.0;
152 return (uint32_t)(ref_bps * sample_rate / 44100.0);
156 size_t out_bytes = 0;
157 bool ok =
enc.encodeFrame((
const int16_t *)
pcm_buffer.data(),
158 VOAACEncoder::kFrameSamplesPerChannel,
161 LOGE(
"VO AAC encodeFrame failed");
166 if (written != out_bytes) {
167 LOGW(
"Output truncated: %d of %d", (
int)written, (
int)out_bytes);
#define VOAAC_DEFAULT_BITRATE
Definition CodecAACVO.h:9
#define VOAAC_DEFAULT_OUTPUT_BUFFER_SIZE
Definition CodecAACVO.h:13