diff options
Diffstat (limited to 'modules/l16/l16.c')
-rw-r--r-- | modules/l16/l16.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/modules/l16/l16.c b/modules/l16/l16.c index 204a8f5..3f324c9 100644 --- a/modules/l16/l16.c +++ b/modules/l16/l16.c @@ -4,6 +4,7 @@ * Copyright (C) 2010 - 2015 Creytiv.com */ #include <re.h> +#include <rem.h> #include <baresip.h> @@ -18,9 +19,10 @@ enum {NR_CODECS = 8}; static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { int16_t *p = (void *)buf; + const int16_t *sampv16 = sampv; (void)st; if (!buf || !len || !sampv) @@ -29,19 +31,23 @@ static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, if (*len < sampc*2) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *len = sampc*2; while (sampc--) - *p++ = htons(*sampv++); + *p++ = htons(*sampv16++); return 0; } -static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, +static int decode(struct audec_state *st, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { int16_t *p = (void *)buf; + int16_t *sampv16 = sampv; (void)st; if (!buf || !len || !sampv) @@ -50,11 +56,14 @@ static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, if (*sampc < len/2) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *sampc = len/2; len /= 2; while (len--) - *sampv++ = ntohs(*p++); + *sampv16++ = ntohs(*p++); return 0; } |