summaryrefslogtreecommitdiff
path: root/modules/amr/amr.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2015-06-14 12:05:01 +0200
committerAlfred E. Heggestad <aeh@db.org>2015-06-14 12:05:01 +0200
commit2753cdfc7c3574a2d32f5b251cb857027074d3d7 (patch)
tree2e24aaf5044a9e721cdd82289020be46ca656fd7 /modules/amr/amr.c
parente347c366253d74ffcd282c6c76e2f459f8ea7714 (diff)
amr: add support for octet-align mode
- this fixes compliance with RFC 4867 - this will break interop with older versions of baresip - Bandwidth-Efficient Mode can be added later fixes issue #37
Diffstat (limited to 'modules/amr/amr.c')
-rw-r--r--modules/amr/amr.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/modules/amr/amr.c b/modules/amr/amr.c
index 1e698d1..74e353a 100644
--- a/modules/amr/amr.c
+++ b/modules/amr/amr.c
@@ -17,6 +17,7 @@
#endif
#include <re.h>
#include <baresip.h>
+#include "amr.h"
#ifdef VO_AMRWBENC_ENC_IF_H
@@ -25,10 +26,15 @@
#endif
-/*
+/**
+ * @defgroup amr amr
+ *
* This module supports both AMR Narrowband (8000 Hz) and
* AMR Wideband (16000 Hz) audio codecs.
*
+ * NOTE: only octet-align mode is supported.
+ *
+ *
* Reference:
*
* http://tools.ietf.org/html/rfc4867
@@ -209,11 +215,14 @@ static int encode_wb(struct auenc_state *st, uint8_t *buf, size_t *len,
if (*len < NB_SERIAL_MAX)
return ENOMEM;
- n = IF2E_IF_encode(st->enc, 8, sampv, buf, 0);
+ /* CMR value 15 indicates that no mode request is present */
+ buf[0] = 15 << 4;
+
+ n = IF2E_IF_encode(st->enc, 8, sampv, &buf[1], 0);
if (n <= 0)
return EPROTO;
- *len = n;
+ *len = (1 + n);
return 0;
}
@@ -227,7 +236,7 @@ static int decode_wb(struct audec_state *st, int16_t *sampv, size_t *sampc,
if (len > NB_SERIAL_MAX)
return EINVAL;
- IF2D_IF_decode(st->dec, buf, sampv, 0);
+ IF2D_IF_decode(st->dec, &buf[1], sampv, 0);
*sampc = L_FRAME16k;
@@ -247,11 +256,14 @@ static int encode_nb(struct auenc_state *st, uint8_t *buf,
if (*len < NB_SERIAL_MAX)
return ENOMEM;
- r = Encoder_Interface_Encode(st->enc, MR475, sampv, buf, 0);
+ /* CMR value 15 indicates that no mode request is present */
+ buf[0] = 15 << 4;
+
+ r = Encoder_Interface_Encode(st->enc, MR122, sampv, &buf[1], 0);
if (r <= 0)
return EPROTO;
- *len = r;
+ *len = (1 + r);
return 0;
}
@@ -269,7 +281,7 @@ static int decode_nb(struct audec_state *st, int16_t *sampv,
if (*sampc < L_FRAME16k)
return ENOMEM;
- Decoder_Interface_Decode(st->dec, buf, sampv, 0);
+ Decoder_Interface_Decode(st->dec, &buf[1], sampv, 0);
*sampc = FRAMESIZE_NB;
@@ -283,7 +295,7 @@ static struct aucodec amr_wb = {
LE_INIT, NULL, "AMR-WB", 16000, 1, NULL,
encode_update, encode_wb,
decode_update, decode_wb,
- NULL, NULL, NULL
+ NULL, amr_fmtp_enc, amr_fmtp_cmp
};
#endif
#ifdef AMR_NB
@@ -291,7 +303,7 @@ static struct aucodec amr_nb = {
LE_INIT, NULL, "AMR", 8000, 1, NULL,
encode_update, encode_nb,
decode_update, decode_nb,
- NULL, NULL, NULL
+ NULL, amr_fmtp_enc, amr_fmtp_cmp
};
#endif