]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
1.4 version of the dead PLC code fix.
authorMark Michelson <mmichelson@digium.com>
Thu, 3 Jun 2010 17:39:18 +0000 (17:39 +0000)
committerMark Michelson <mmichelson@digium.com>
Thu, 3 Jun 2010 17:39:18 +0000 (17:39 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@267539 65c4cc65-6c06-0410-ace0-fbb531ad65f3

codecs/codec_adpcm.c
codecs/codec_alaw.c
codecs/codec_dahdi.c
codecs/codec_g726.c
codecs/codec_gsm.c
codecs/codec_lpc10.c
codecs/codec_ulaw.c
include/asterisk/translate.h
main/translate.c

index 7469f056c595f47726bbe91108693bb7c6d20036..fd4784c43599891dfe9c371f3e00fdd06311f2f9 100644 (file)
@@ -335,7 +335,6 @@ static struct ast_translator adpcmtolin = {
        .desc_size = sizeof(struct adpcm_decoder_pvt),
        .buffer_samples = BUFFER_SAMPLES,
        .buf_size = BUFFER_SAMPLES * 2,
-       .plc_samples = 160,
 };
 
 static struct ast_translator lintoadpcm = {
@@ -350,26 +349,9 @@ static struct ast_translator lintoadpcm = {
        .buf_size = BUFFER_SAMPLES/ 2,  /* 2 samples per byte */
 };
 
-static void parse_config(void)
-{
-       struct ast_config *cfg = ast_config_load("codecs.conf");
-       struct ast_variable *var;
-       if (cfg == NULL)
-               return;
-       for (var = ast_variable_browse(cfg, "plc"); var ; var = var->next) {
-               if (!strcasecmp(var->name, "genericplc")) {
-                       adpcmtolin.useplc = ast_true(var->value) ? 1 : 0;
-                       if (option_verbose > 2)
-                               ast_verbose(VERBOSE_PREFIX_3 "codec_adpcm: %susing generic PLC\n", adpcmtolin.useplc ? "" : "not ");
-               }
-       }
-       ast_config_destroy(cfg);
-}
-
 /*! \brief standard module glue */
 static int reload(void)
 {
-       parse_config();
        return 0;
 }
 
@@ -387,7 +369,6 @@ static int load_module(void)
 {
        int res;
 
-       parse_config();
        res = ast_register_translator(&adpcmtolin);
        if (!res)
                res = ast_register_translator(&lintoadpcm);
index de106168733e6fdd0aa39557c6d8e64dba02d9fb..a4d69afb3c079c96d8b3789633647b40be62e0cc 100644 (file)
@@ -121,7 +121,6 @@ static struct ast_translator alawtolin = {
        .sample = alawtolin_sample,
        .buffer_samples = BUFFER_SAMPLES,
        .buf_size = BUFFER_SAMPLES * 2,
-       .plc_samples = 160,
 };
 
 static struct ast_translator lintoalaw = {
@@ -134,27 +133,10 @@ static struct ast_translator lintoalaw = {
        .buf_size = BUFFER_SAMPLES,
 };
 
-static void parse_config(void)
-{
-       struct ast_variable *var;
-       struct ast_config *cfg = ast_config_load("codecs.conf");
-       if (!cfg)
-               return;
-       for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
-               if (!strcasecmp(var->name, "genericplc")) {
-                       alawtolin.useplc = ast_true(var->value) ? 1 : 0;
-                       if (option_verbose > 2)
-                               ast_verbose(VERBOSE_PREFIX_3 "codec_alaw: %susing generic PLC\n", alawtolin.useplc ? "" : "not ");
-               }
-       }
-       ast_config_destroy(cfg);
-}
-
 /*! \brief standard module stuff */
 
 static int reload(void)
 {
-       parse_config();
        return 0;
 }
 
@@ -172,7 +154,6 @@ static int load_module(void)
 {
        int res;
 
-       parse_config();
        res = ast_register_translator(&alawtolin);
        if (!res)
                res = ast_register_translator(&lintoalaw);
index 02b83ea207fc8c015673f11fb76d82ec349be710..5577272db436856025f4cb78324a7832def64eb7 100644 (file)
@@ -65,8 +65,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #define G723_SAMPLES 240
 #define G729_SAMPLES 160
 
-static unsigned int global_useplc = 0;
-
 static struct channel_usage {
        int total;
        int encoders;
@@ -513,29 +511,14 @@ static int register_translator(int dst, int src)
        if (is_encoder(zt)) {
                zt->t.framein = dahdi_encoder_framein;
                zt->t.frameout = dahdi_encoder_frameout;
-#if 0
-               zt->t.buffer_samples = 0;
-#endif
        } else {
                zt->t.framein = dahdi_decoder_framein;
                zt->t.frameout = dahdi_decoder_frameout;
-#if 0
-               if (AST_FORMAT_G723_1 == zt->t.srcfmt) {
-                       zt->t.plc_samples = G723_SAMPLES;
-               } else {
-                       zt->t.plc_samples = G729_SAMPLES;
-               }
-               zt->t.buffer_samples = zt->t.plc_samples * 8;
-#endif
        }
        zt->t.destroy = dahdi_destroy;
        zt->t.buffer_samples = 0;
        zt->t.newpvt = dahdi_new;
        zt->t.sample = fakesrc_sample;
-#if 0
-       zt->t.useplc = global_useplc;
-#endif
-       zt->t.useplc = 0;
        zt->t.native_plc = 0;
 
        zt->t.desc_size = sizeof(struct codec_dahdi_pvt);
@@ -587,26 +570,6 @@ static void unregister_translators(void)
        AST_LIST_UNLOCK(&translators);
 }
 
-static void parse_config(void)
-{
-       struct ast_variable *var;
-       struct ast_config *cfg = ast_config_load("codecs.conf");
-
-       if (!cfg)
-               return;
-
-       for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
-              if (!strcasecmp(var->name, "genericplc")) {
-                      global_useplc = ast_true(var->value);
-                      if (option_verbose > 2)
-                              ast_verbose(VERBOSE_PREFIX_3 "codec_zap: %susing generic PLC\n",
-                                          global_useplc ? "" : "not ");
-              }
-       }
-
-       ast_config_destroy(cfg);
-}
-
 static void build_translators(struct format_map *map, unsigned int dstfmts, unsigned int srcfmts)
 {
        unsigned int src, dst;
@@ -681,15 +644,6 @@ static int find_transcoders(void)
 
 static int reload(void)
 {
-       struct translator *cur;
-
-       parse_config();
-
-       AST_LIST_LOCK(&translators);
-       AST_LIST_TRAVERSE(&translators, cur, entry)
-               cur->t.useplc = global_useplc;
-       AST_LIST_UNLOCK(&translators);
-
        return 0;
 }
 
@@ -704,7 +658,6 @@ static int unload_module(void)
 static int load_module(void)
 {
        ast_ulaw_init();
-       parse_config();
        find_transcoders();
        ast_cli_register_multiple(cli, sizeof(cli) / sizeof(cli[0]));
 
index dade0bdca3cfa5b2560600623a35f80cc0c5147f..a21a9f3dcac5dc1432e7030a85d77acc5b4d342b 100644 (file)
@@ -818,7 +818,6 @@ static struct ast_translator g726tolin = {
        .desc_size = sizeof(struct g726_coder_pvt),
        .buffer_samples = BUFFER_SAMPLES,
        .buf_size = BUFFER_SAMPLES * 2,
-       .plc_samples = 160,
 };
 
 static struct ast_translator lintog726 = {
@@ -843,7 +842,6 @@ static struct ast_translator g726aal2tolin = {
        .desc_size = sizeof(struct g726_coder_pvt),
        .buffer_samples = BUFFER_SAMPLES,
        .buf_size = BUFFER_SAMPLES * 2,
-       .plc_samples = 160,
 };
 
 static struct ast_translator lintog726aal2 = {
@@ -858,28 +856,8 @@ static struct ast_translator lintog726aal2 = {
        .buf_size = BUFFER_SAMPLES / 2,
 };
 
-static void parse_config(void)
-{
-       struct ast_variable *var;
-       struct ast_config *cfg = ast_config_load("codecs.conf");
-
-       if (!cfg)
-               return;
-       for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
-               if (!strcasecmp(var->name, "genericplc")) {
-                       g726tolin.useplc = ast_true(var->value) ? 1 : 0;
-                       if (option_verbose > 2)
-                               ast_verbose(VERBOSE_PREFIX_3 "codec_g726: %susing generic PLC\n",
-                                       g726tolin.useplc ? "" : "not ");
-               }
-       }
-       ast_config_destroy(cfg);
-}
-
 static int reload(void)
 {
-       parse_config();
-
        return 0;
 }
 
@@ -900,9 +878,6 @@ static int load_module(void)
 {
        int res = 0;
 
-
-       parse_config();
-
        res |= ast_register_translator(&g726tolin);
        res |= ast_register_translator(&lintog726);
 
index 8a37493190655e540ddf113ce035d3fdb54c9795..cb4e7596ee050c39105008233ed6754bf8afafce 100644 (file)
@@ -218,7 +218,6 @@ static struct ast_translator gsmtolin = {
        .buffer_samples = BUFFER_SAMPLES,
        .buf_size = BUFFER_SAMPLES * 2,
        .desc_size = sizeof (struct gsm_translator_pvt ),
-       .plc_samples = GSM_SAMPLES,
 };
 
 static struct ast_translator lintogsm = {
@@ -234,27 +233,9 @@ static struct ast_translator lintogsm = {
        .buf_size = (BUFFER_SAMPLES * GSM_FRAME_LEN + GSM_SAMPLES - 1)/GSM_SAMPLES,
 };
 
-
-static void parse_config(void)
-{
-       struct ast_variable *var;
-       struct ast_config *cfg = ast_config_load("codecs.conf");
-       if (!cfg)
-               return;
-       for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
-              if (!strcasecmp(var->name, "genericplc")) {
-                      gsmtolin.useplc = ast_true(var->value) ? 1 : 0;
-                      if (option_verbose > 2)
-                              ast_verbose(VERBOSE_PREFIX_3 "codec_gsm: %susing generic PLC\n", gsmtolin.useplc ? "" : "not ");
-              }
-       }
-       ast_config_destroy(cfg);
-}
-
 /*! \brief standard module glue */
 static int reload(void)
 {
-       parse_config();
        return 0;
 }
 
@@ -273,7 +254,6 @@ static int load_module(void)
 {
        int res;
 
-       parse_config();
        res = ast_register_translator(&gsmtolin);
        if (!res) 
                res=ast_register_translator(&lintogsm);
index 3f46e0af8c42daffdb8927f253d1651212724d5c..0e622da5e893337bb69187314c851f305e0c6959 100644 (file)
@@ -243,7 +243,6 @@ static struct ast_translator lpc10tolin = {
        .sample = lpc10tolin_sample,
        .desc_size = sizeof(struct lpc10_coder_pvt),
        .buffer_samples = BUFFER_SAMPLES,
-       .plc_samples = LPC10_SAMPLES_PER_FRAME,
        .buf_size = BUFFER_SAMPLES * 2,
 };
 
@@ -261,27 +260,8 @@ static struct ast_translator lintolpc10 = {
        .buf_size = LPC10_BYTES_IN_COMPRESSED_FRAME * (1 + BUFFER_SAMPLES / LPC10_SAMPLES_PER_FRAME),
 };
 
-static void parse_config(void)
-{
-        struct ast_variable *var;
-        struct ast_config *cfg = ast_config_load("codecs.conf");
-       if (!cfg)
-               return;
-       for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
-              if (!strcasecmp(var->name, "genericplc")) {
-                       lpc10tolin.useplc = ast_true(var->value) ? 1 : 0;
-                       if (option_verbose > 2)
-                              ast_verbose(VERBOSE_PREFIX_3 "codec_lpc10: %susing generic PLC\n",
-                                       lpc10tolin.useplc ? "" : "not ");
-               }
-        }
-       ast_config_destroy(cfg);
-}
-
 static int reload(void)
 {
-        parse_config();
-
         return 0;
 }
 
@@ -300,7 +280,6 @@ static int load_module(void)
 {
        int res;
 
-       parse_config();
        res=ast_register_translator(&lpc10tolin);
        if (!res) 
                res=ast_register_translator(&lintolpc10);
index 334f8d9ad7638cfe7489003135cb5656466a7c93..36cc1631cb4ab5ba3b285aaedba084fa6adf3a82 100644 (file)
@@ -130,7 +130,6 @@ static struct ast_translator ulawtolin = {
        .sample = ulawtolin_sample,
        .buffer_samples = BUFFER_SAMPLES,
        .buf_size = BUFFER_SAMPLES * 2,
-       .plc_samples = 160,
 };
 
 /*!
@@ -147,26 +146,8 @@ static struct ast_translator lintoulaw = {
        .buffer_samples = BUFFER_SAMPLES,
 };
 
-static void parse_config(void)
-{
-       struct ast_variable *var;
-       struct ast_config *cfg = ast_config_load("codecs.conf");
-       if (!cfg)
-               return;
-       for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
-               if (!strcasecmp(var->name, "genericplc")) {
-                       ulawtolin.useplc = ast_true(var->value) ? 1 : 0;
-                       if (option_verbose > 2)
-                               ast_verbose(VERBOSE_PREFIX_3 "codec_ulaw: %susing generic PLC\n", ulawtolin.useplc ? "" : "not ");
-               }
-       }
-       ast_config_destroy(cfg);
-}
-
 static int reload(void)
 {
-       parse_config();
-
        return 0;
 }
 
@@ -184,7 +165,6 @@ static int load_module(void)
 {
        int res;
 
-       parse_config();
        res = ast_register_translator(&ulawtolin);
        if (!res)
                res = ast_register_translator(&lintoulaw);
index cace23627678f48a8303bf10bf5f9cd60b3064e5..e4368d69ca1543487468b7d74c43c50cefdcf364 100644 (file)
@@ -60,10 +60,6 @@ struct ast_trans_pvt;        /* declared below */
  * or deallocation, nor any locking, because all of this is done in
  * the generic code.
  *
- * Translators using generic plc (packet loss concealment) should
- * supply a non-zero plc_samples indicating the size (in samples)
- * of artificially generated frames and incoming data.
- * Generic plc is only available for dstfmt = SLINEAR
  */
 struct ast_translator {
        const char name[80];            /*!< Name of translator */
@@ -102,8 +98,8 @@ struct ast_translator {
        int buf_size;
 
        int desc_size;                  /*!< size of private descriptor in pvt->pvt, if any */
-       int plc_samples;                /*!< set to the plc block size if used, 0 otherwise */
-       int useplc;                     /*!< current status of plc, changed at runtime */
+       int plc_samples; /* Unused. Kept for ABI purposes */
+       int useplc; /* Unused. Kept for ABI purposes */
        int native_plc;                 /*!< true if the translator can do native plc */
 
        struct ast_module *module;      /* opaque reference to the parent module */
index a928470bf359f0fb44d3881599d2dca37b794e6c..fd6445dde675e9c2a92e9a29fea82e17ed1c155b 100644 (file)
@@ -94,22 +94,19 @@ static force_inline int powerof(unsigned int d)
 
 /*!
  * \brief Allocate the descriptor, required outbuf space,
- * and possibly also plc and desc.
+ * and possibly desc.
  */
 static void *newpvt(struct ast_translator *t)
 {
        struct ast_trans_pvt *pvt;
        int len;
-       int useplc = t->plc_samples > 0 && t->useplc;   /* cache, because it can change on the fly */
        char *ofs;
 
        /*
         * compute the required size adding private descriptor,
-        * plc, buffer, AST_FRIENDLY_OFFSET.
+        * buffer, AST_FRIENDLY_OFFSET.
         */
        len = sizeof(*pvt) + t->desc_size;
-       if (useplc)
-               len += sizeof(plc_state_t);
        if (t->buf_size)
                len += AST_FRIENDLY_OFFSET + t->buf_size;
        pvt = ast_calloc(1, len);
@@ -121,10 +118,6 @@ static void *newpvt(struct ast_translator *t)
                pvt->pvt = ofs;
                ofs += t->desc_size;
        }
-       if (useplc) {                   /* then plc state */
-               pvt->plc = (plc_state_t *)ofs;
-               ofs += sizeof(plc_state_t);
-       }
        if (t->buf_size)                /* finally buffer and header */
                pvt->outbuf = ofs + AST_FRIENDLY_OFFSET;
        /* call local init routine, if present */
@@ -146,10 +139,9 @@ static void destroy(struct ast_trans_pvt *pvt)
        ast_module_unref(t->module);
 }
 
-/*! \brief framein wrapper, deals with plc and bound checks.  */
+/*! \brief framein wrapper, deals with bound checks.  */
 static int framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
 {
-       int16_t *dst = (int16_t *)pvt->outbuf;
        int ret;
        int samples = pvt->samples;     /* initial value */
        
@@ -163,18 +155,8 @@ static int framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
                ast_log(LOG_WARNING, "no samples for %s\n", pvt->t->name);
        }
        if (pvt->t->buffer_samples) {   /* do not pass empty frames to callback */
-               if (f->datalen == 0) { /* perform PLC with nominal framesize of 20ms/160 samples */
-                       if (pvt->plc) {
-                               int l = pvt->t->plc_samples;
-                               if (pvt->samples + l > pvt->t->buffer_samples) {
-                                       ast_log(LOG_WARNING, "Out of buffer space\n");
-                                       return -1;
-                               }
-                               l = plc_fillin(pvt->plc, dst + pvt->samples, l);
-                               pvt->samples += l;
-                               pvt->datalen = pvt->samples * 2;        /* SLIN has 2bytes for 1sample */
-                       }
-                       /* We don't want generic PLC. If the codec has native PLC, then do that */
+               if (f->datalen == 0) { /* perform native PLC if available */
+                       /* If the codec has native PLC, then do that */
                        if (!pvt->t->native_plc)
                                return 0;
                }
@@ -187,13 +169,6 @@ static int framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
         * it otherwise.
         */
        ret = pvt->t->framein(pvt, f);
-       /* possibly store data for plc */
-       if (!ret && pvt->plc) {
-               int l = pvt->t->plc_samples;
-               if (pvt->samples < l)
-                       l = pvt->samples;
-               plc_rx(pvt->plc, dst + pvt->samples - l, l);
-       }
        /* diagnostic ... */
        if (pvt->samples == samples)
                ast_log(LOG_WARNING, "%s did not update samples %d\n",
@@ -690,16 +665,7 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
                ast_log(LOG_WARNING, "Invalid translator path: (%s codec is not valid)\n", t->srcfmt == -1 ? "starting" : "ending");
                return -1;
        }
-       if (t->plc_samples) {
-               if (t->buffer_samples < t->plc_samples) {
-                       ast_log(LOG_WARNING, "plc_samples %d buffer_samples %d\n",
-                               t->plc_samples, t->buffer_samples);
-                       return -1;
-               }
-               if (t->dstfmt != powerof(AST_FORMAT_SLINEAR))
-                       ast_log(LOG_WARNING, "plc_samples %d format %x\n",
-                               t->plc_samples, t->dstfmt);
-       }
+       
        if (t->srcfmt >= MAX_FORMAT) {
                ast_log(LOG_WARNING, "Source format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt));
                return -1;