aboutsummaryrefslogtreecommitdiffstats
path: root/codecs/codec_lpc10.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-03-17 21:30:19 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-03-17 21:30:19 +0000
commit235a6486c3ca01b9bdac577774cc90fa4f06a58f (patch)
tree2ff53ca559c15101655e44ad4281225c8aae6685 /codecs/codec_lpc10.c
parent98aa637d27b5ac36a35fc85b596f00d1104398e3 (diff)
Add PLC and jitter buffer and iax2 meta trunk with timestamps (bug #2532, #3400)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5192 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'codecs/codec_lpc10.c')
-rwxr-xr-xcodecs/codec_lpc10.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/codecs/codec_lpc10.c b/codecs/codec_lpc10.c
index 4a6925949..904f0266a 100755
--- a/codecs/codec_lpc10.c
+++ b/codecs/codec_lpc10.c
@@ -19,6 +19,8 @@
#include <asterisk/lock.h>
#include <asterisk/translate.h>
+#include <asterisk/config.h>
+#include <asterisk/options.h>
#include <asterisk/module.h>
#include <asterisk/logger.h>
#include <asterisk/channel.h>
@@ -47,6 +49,8 @@ static int localusecnt=0;
static char *tdesc = "LPC10 2.4kbps (signed linear) Voice Coder";
+static int useplc = 0;
+
struct ast_translator_pvt {
union {
struct lpc10_encoder_state *enc;
@@ -61,6 +65,7 @@ struct ast_translator_pvt {
short buf[8000];
int tail;
int longer;
+ plc_state_t plc; /* god only knows why I bothered to implement PLC for LPC10 :) */
};
#define lpc10_coder_pvt ast_translator_pvt
@@ -92,6 +97,7 @@ static struct ast_translator_pvt *lpc10_dec_new(void)
}
tmp->tail = 0;
tmp->longer = 0;
+ plc_init(&tmp->plc);
localusecnt++;
}
return tmp;
@@ -199,6 +205,19 @@ static int lpc10tolin_framein(struct ast_translator_pvt *tmp, struct ast_frame *
float tmpbuf[LPC10_SAMPLES_PER_FRAME];
short *sd;
INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME];
+
+ if(f->datalen == 0) { /* perform PLC with nominal framesize of LPC10_SAMPLES_PER_FRAME */
+ if((tmp->tail + LPC10_SAMPLES_PER_FRAME) > sizeof(tmp->buf)/2) {
+ ast_log(LOG_WARNING, "Out of buffer space\n");
+ return -1;
+ }
+ if(useplc) {
+ plc_fillin(&tmp->plc, tmp->buf+tmp->tail, LPC10_SAMPLES_PER_FRAME);
+ tmp->tail += LPC10_SAMPLES_PER_FRAME;
+ }
+ return 0;
+ }
+
while(len + LPC10_BYTES_IN_COMPRESSED_FRAME <= f->datalen) {
if (tmp->tail + LPC10_SAMPLES_PER_FRAME < sizeof(tmp->buf)/2) {
sd = tmp->buf + tmp->tail;
@@ -211,6 +230,8 @@ static int lpc10tolin_framein(struct ast_translator_pvt *tmp, struct ast_frame *
/* Convert to a real between -1.0 and 1.0 */
sd[x] = 32768.0 * tmpbuf[x];
}
+
+ if(useplc) plc_rx(&tmp->plc, tmp->buf + tmp->tail, LPC10_SAMPLES_PER_FRAME);
tmp->tail+=LPC10_SAMPLES_PER_FRAME;
} else {
@@ -326,6 +347,31 @@ static struct ast_translator lintolpc10 =
lintolpc10_sample
};
+static void parse_config(void)
+{
+ struct ast_config *cfg;
+ struct ast_variable *var;
+ if ((cfg = ast_config_load("codecs.conf"))) {
+ if ((var = ast_variable_browse(cfg, "plc"))) {
+ while (var) {
+ if (!strcasecmp(var->name, "genericplc")) {
+ useplc = ast_true(var->value) ? 1 : 0;
+ if (option_verbose > 2)
+ ast_verbose(VERBOSE_PREFIX_3 "CODEC ULAW: %susing generic PLC\n", useplc ? "" : "not ");
+ }
+ var = var->next;
+ }
+ }
+ }
+}
+
+int reload(void)
+{
+ parse_config();
+ return 0;
+}
+
+
int unload_module(void)
{
int res;
@@ -342,6 +388,7 @@ int unload_module(void)
int load_module(void)
{
int res;
+ parse_config();
res=ast_register_translator(&lpc10tolin);
if (!res)
res=ast_register_translator(&lintolpc10);