diff options
Diffstat (limited to 'modules/g711/g711.c')
-rw-r--r-- | modules/g711/g711.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/modules/g711/g711.c b/modules/g711/g711.c index d264153..e72f117 100644 --- a/modules/g711/g711.c +++ b/modules/g711/g711.c @@ -17,8 +17,10 @@ static int pcmu_encode(struct auenc_state *aes, uint8_t *buf, - size_t *len, const int16_t *sampv, size_t sampc) + size_t *len, int fmt, const void *sampv, size_t sampc) { + const int16_t *p = sampv; + (void)aes; if (!buf || !len || !sampv) @@ -27,18 +29,23 @@ static int pcmu_encode(struct auenc_state *aes, uint8_t *buf, if (*len < sampc) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *len = sampc; while (sampc--) - *buf++ = g711_pcm2ulaw(*sampv++); + *buf++ = g711_pcm2ulaw(*p++); return 0; } -static int pcmu_decode(struct audec_state *ads, int16_t *sampv, +static int pcmu_decode(struct audec_state *ads, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { + int16_t *p = sampv; + (void)ads; if (!sampv || !sampc || !buf) @@ -47,18 +54,23 @@ static int pcmu_decode(struct audec_state *ads, int16_t *sampv, if (*sampc < len) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *sampc = len; while (len--) - *sampv++ = g711_ulaw2pcm(*buf++); + *p++ = g711_ulaw2pcm(*buf++); return 0; } static int pcma_encode(struct auenc_state *aes, uint8_t *buf, - size_t *len, const int16_t *sampv, size_t sampc) + size_t *len, int fmt, const void *sampv, size_t sampc) { + const int16_t *p = sampv; + (void)aes; if (!buf || !len || !sampv) @@ -67,18 +79,23 @@ static int pcma_encode(struct auenc_state *aes, uint8_t *buf, if (*len < sampc) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *len = sampc; while (sampc--) - *buf++ = g711_pcm2alaw(*sampv++); + *buf++ = g711_pcm2alaw(*p++); return 0; } -static int pcma_decode(struct audec_state *ads, int16_t *sampv, +static int pcma_decode(struct audec_state *ads, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { + int16_t *p = sampv; + (void)ads; if (!sampv || !sampc || !buf) @@ -87,10 +104,13 @@ static int pcma_decode(struct audec_state *ads, int16_t *sampv, if (*sampc < len) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *sampc = len; while (len--) - *sampv++ = g711_alaw2pcm(*buf++); + *p++ = g711_alaw2pcm(*buf++); return 0; } @@ -98,12 +118,12 @@ static int pcma_decode(struct audec_state *ads, int16_t *sampv, static struct aucodec pcmu = { LE_INIT, "0", "PCMU", 8000, 8000, 1, NULL, - NULL, pcmu_encode, NULL, pcmu_decode, NULL, NULL, NULL, NULL, NULL + NULL, pcmu_encode, NULL, pcmu_decode, NULL, NULL, NULL }; static struct aucodec pcma = { LE_INIT, "8", "PCMA", 8000, 8000, 1, NULL, - NULL, pcma_encode, NULL, pcma_decode, NULL, NULL, NULL, NULL, NULL + NULL, pcma_encode, NULL, pcma_decode, NULL, NULL, NULL }; |