diff options
Diffstat (limited to 'modules/opus/encode.c')
-rw-r--r-- | modules/opus/encode.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/opus/encode.c b/modules/opus/encode.c index 6723ac8..7450d92 100644 --- a/modules/opus/encode.c +++ b/modules/opus/encode.c @@ -5,6 +5,7 @@ */ #include <re.h> +#include <rem.h> #include <baresip.h> #include <opus/opus.h> #include "opus.h" @@ -189,3 +190,27 @@ int opus_encode_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, return 0; } + + +int opus_encode_format_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, + int fmt, const void *sampv, size_t sampc) +{ + opus_int32 n; + + if (!aes || !buf || !len || !sampv) + return EINVAL; + + if (fmt != AUFMT_FLOAT) + return ENOTSUP; + + n = opus_encode_float(aes->enc, sampv, (int)(sampc/aes->ch), + buf, (opus_int32)(*len)); + if (n < 0) { + warning("opus: encode error: %s\n", opus_strerror((int)n)); + return EPROTO; + } + + *len = n; + + return 0; +} |