28 switch (bits_per_second) {
30 return CODEC2_MODE_3200;
32 return CODEC2_MODE_2400;
34 return CODEC2_MODE_1600;
36 return CODEC2_MODE_1400;
38 return CODEC2_MODE_1300;
40 return CODEC2_MODE_1200;
42 return CODEC2_MODE_700C;
44 return CODEC2_MODE_450;
47 "Unsupported sample rate: use 3200, 2400, 1600, 1400, 1300, 1200, "
64 info.sample_rate = 8000;
66 info.bits_per_sample = 16;
70 virtual const char *
mime()
override {
return "audio/codec2"; }
83 LOGE(
"invalid bits_per_second")
86 if (
info.channels != 1) {
87 LOGE(
"Only 1 channel supported")
90 if (
info.bits_per_sample != 16) {
91 LOGE(
"Only 16 bps are supported")
94 if (
info.sample_rate != 8000) {
95 LOGW(
"Sample rate should be 8000: %d",
info.sample_rate);
100 LOGE(
"codec2_create");
123 ? codec2_samples_per_frame(
p_codec2) *
sizeof(int16_t)
138 size_t write(
const uint8_t *data,
size_t len)
override {
139 LOGD(
"write: %d", len);
145 uint8_t *p_byte = (uint8_t *)data;
146 for (
int j = 0; j < len; j++) {
193 info.sample_rate = 8000;
195 info.bits_per_sample = 16;
211 ? codec2_samples_per_frame(
p_codec2) *
sizeof(int16_t)
220 LOGE(
"invalid bits_per_second")
223 if (
info.channels != 1) {
224 LOGE(
"Only 1 channel supported")
227 if (
info.bits_per_sample != 16) {
228 LOGE(
"Only 16 bps are supported")
231 if (
info.sample_rate != 8000) {
232 LOGW(
"Sample rate should be 8000: %d",
info.sample_rate);
237 LOGE(
"codec2_create");
257 virtual const char *
mime() {
return "audio/codec2"; }
263 size_t write(
const uint8_t *in_ptr,
size_t in_size)
override {
264 LOGD(
"write: %d", in_size);
270 uint8_t *p_byte = (uint8_t *)in_ptr;
271 for (
int j = 0; j < in_size; j++) {