Expand codec bitfield from 32 bits to 64 bits.
[asterisk/asterisk.git] / codecs / codec_dahdi.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * DAHDI native transcoding support
5  *
6  * Copyright (C) 1999 - 2008, Digium, Inc.
7  *
8  * Mark Spencer <markster@digium.com>
9  * Kevin P. Fleming <kpfleming@digium.com>
10  *
11  * See http://www.asterisk.org for more information about
12  * the Asterisk project. Please do not directly contact
13  * any of the maintainers of this project for assistance;
14  * the project provides a web site, mailing lists and IRC
15  * channels for your use.
16  *
17  * This program is free software, distributed under the terms of
18  * the GNU General Public License Version 2. See the LICENSE file
19  * at the top of the source tree.
20  */
21
22 /*! \file
23  *
24  * \brief Translate between various formats natively through DAHDI transcoding
25  *
26  * \ingroup codecs
27  */
28
29 /*** MODULEINFO
30         <depend>dahdi</depend>
31  ***/
32
33 #include "asterisk.h"
34
35 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
36
37 #include <fcntl.h>
38 #include <netinet/in.h>
39 #include <sys/ioctl.h>
40 #include <sys/mman.h>
41 #include <sys/poll.h>
42 #include <dahdi/user.h>
43
44 #include "asterisk/lock.h"
45 #include "asterisk/translate.h"
46 #include "asterisk/config.h"
47 #include "asterisk/module.h"
48 #include "asterisk/cli.h"
49 #include "asterisk/channel.h"
50 #include "asterisk/utils.h"
51 #include "asterisk/linkedlists.h"
52 #include "asterisk/ulaw.h"
53
54 #define BUFFER_SIZE 8000
55
56 #define G723_SAMPLES 240
57 #define G729_SAMPLES 160
58
59 static unsigned int global_useplc = 0;
60
61 static struct channel_usage {
62         int total;
63         int encoders;
64         int decoders;
65 } channels;
66
67 static char *handle_cli_transcoder_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
68
69 static struct ast_cli_entry cli[] = {
70         AST_CLI_DEFINE(handle_cli_transcoder_show, "Display DAHDI transcoder utilization.")
71 };
72
73 struct format_map {
74         unsigned int map[32][32];
75 };
76
77 static struct format_map global_format_map = { { { 0 } } };
78
79 struct translator {
80         struct ast_translator t;
81         AST_LIST_ENTRY(translator) entry;
82 };
83
84 static AST_LIST_HEAD_STATIC(translators, translator);
85
86 struct codec_dahdi_pvt {
87         int fd;
88         struct dahdi_transcoder_formats fmts;
89         unsigned int softslin:1;
90         unsigned int fake:2;
91         uint16_t required_samples;
92         uint16_t samples_in_buffer;
93         uint8_t ulaw_buffer[1024];
94 };
95
96 /* Only used by a decoder */
97 static int ulawtolin(struct ast_trans_pvt *pvt)
98 {
99         struct codec_dahdi_pvt *dahdip = pvt->pvt;
100         int i = dahdip->required_samples;
101         uint8_t *src = &dahdip->ulaw_buffer[0];
102         int16_t *dst = pvt->outbuf.i16 + pvt->datalen;
103
104         /* convert and copy in outbuf */
105         while (i--) {
106                 *dst++ = AST_MULAW(*src++);
107         }
108
109         return 0;
110 }
111
112 /* Only used by an encoder. */
113 static int lintoulaw(struct ast_trans_pvt *pvt, struct ast_frame *f)
114 {
115         struct codec_dahdi_pvt *dahdip = pvt->pvt;
116         int i = f->samples;
117         uint8_t *dst = &dahdip->ulaw_buffer[dahdip->samples_in_buffer];
118         int16_t *src = f->data.ptr;
119
120         if (dahdip->samples_in_buffer + i > sizeof(dahdip->ulaw_buffer)) {
121                 ast_log(LOG_ERROR, "Out of buffer space!\n");
122                 return -i;
123         }
124
125         while (i--) {
126                 *dst++ = AST_LIN2MU(*src++);
127         }
128
129         dahdip->samples_in_buffer += f->samples;
130         return 0;
131 }
132
133 static char *handle_cli_transcoder_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
134 {
135         struct channel_usage copy;
136
137         switch (cmd) {
138         case CLI_INIT:
139                 e->command = "transcoder show";
140                 e->usage =
141                         "Usage: transcoder show\n"
142                         "       Displays channel utilization of DAHDI transcoder(s).\n";
143                 return NULL;
144         case CLI_GENERATE:
145                 return NULL;
146         }
147
148         if (a->argc != 2)
149                 return CLI_SHOWUSAGE;
150
151         copy = channels;
152
153         if (copy.total == 0)
154                 ast_cli(a->fd, "No DAHDI transcoders found.\n");
155         else
156                 ast_cli(a->fd, "%d/%d encoders/decoders of %d channels are in use.\n", copy.encoders, copy.decoders, copy.total);
157
158         return CLI_SUCCESS;
159 }
160
161 static void dahdi_write_frame(struct codec_dahdi_pvt *dahdip, const uint8_t *buffer, const ssize_t count)
162 {
163         int res;
164         struct pollfd p = {0};
165         if (!count) return;
166         res = write(dahdip->fd, buffer, count);
167         if (option_verbose > 10) {
168                 if (-1 == res) {
169                         ast_log(LOG_ERROR, "Failed to write to transcoder: %s\n", strerror(errno));
170                 }
171                 if (count != res) {
172                         ast_log(LOG_ERROR, "Requested write of %zd bytes, but only wrote %d bytes.\n", count, res);
173                 }
174         }
175         p.fd = dahdip->fd;
176         p.events = POLLOUT;
177         res = poll(&p, 1, 50);
178 }
179
180 static int dahdi_encoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
181 {
182         struct codec_dahdi_pvt *dahdip = pvt->pvt;
183
184         if (!f->subclass.codec) {
185                 /* We're just faking a return for calculation purposes. */
186                 dahdip->fake = 2;
187                 pvt->samples = f->samples;
188                 return 0;
189         }
190
191         /* Buffer up the packets and send them to the hardware if we
192          * have enough samples set up. */
193         if (dahdip->softslin) {
194                 if (lintoulaw(pvt, f)) {
195                          return -1;
196                 }
197         } else {
198                 /* NOTE:  If softslin support is not needed, and the sample
199                  * size is equal to the required sample size, we wouldn't
200                  * need this copy operation.  But at the time this was
201                  * written, only softslin is supported. */
202                 if (dahdip->samples_in_buffer + f->samples > sizeof(dahdip->ulaw_buffer)) {
203                         ast_log(LOG_ERROR, "Out of buffer space.\n");
204                         return -1;
205                 }
206                 memcpy(&dahdip->ulaw_buffer[dahdip->samples_in_buffer], f->data.ptr, f->samples);
207                 dahdip->samples_in_buffer += f->samples;
208         }
209
210         while (dahdip->samples_in_buffer > dahdip->required_samples) {
211                 dahdi_write_frame(dahdip, dahdip->ulaw_buffer, dahdip->required_samples);
212                 dahdip->samples_in_buffer -= dahdip->required_samples;
213                 if (dahdip->samples_in_buffer) {
214                         /* Shift any remaining bytes down. */
215                         memmove(dahdip->ulaw_buffer, &dahdip->ulaw_buffer[dahdip->required_samples],
216                                 dahdip->samples_in_buffer);
217                 }
218         }
219         pvt->samples += f->samples;
220         pvt->datalen = 0;
221         return -1;
222 }
223
224 static struct ast_frame *dahdi_encoder_frameout(struct ast_trans_pvt *pvt)
225 {
226         struct codec_dahdi_pvt *dahdip = pvt->pvt;
227         int res;
228
229         if (2 == dahdip->fake) {
230                 dahdip->fake = 1;
231                 pvt->f.frametype = AST_FRAME_VOICE;
232                 pvt->f.subclass.codec = 0;
233                 pvt->f.samples = dahdip->required_samples;
234                 pvt->f.data.ptr = NULL;
235                 pvt->f.offset = 0;
236                 pvt->f.datalen = 0;
237                 pvt->f.mallocd = 0;
238                 pvt->samples = 0;
239
240                 return ast_frisolate(&pvt->f);
241
242         } else if (1 == dahdip->fake) {
243                 dahdip->fake = 0;
244                 return NULL;
245         }
246
247         res = read(dahdip->fd, pvt->outbuf.c + pvt->datalen, pvt->t->buf_size - pvt->datalen);
248         if (-1 == res) {
249                 if (EWOULDBLOCK == errno) {
250                         /* Nothing waiting... */
251                         return NULL;
252                 } else {
253                         ast_log(LOG_ERROR, "Failed to read from transcoder: %s\n", strerror(errno));
254                         return NULL;
255                 }
256         } else {
257                 pvt->f.datalen = res;
258                 pvt->f.samples = dahdip->required_samples;
259                 pvt->f.frametype = AST_FRAME_VOICE;
260                 pvt->f.subclass.codec = 1 <<  (pvt->t->dstfmt);
261                 pvt->f.mallocd = 0;
262                 pvt->f.offset = AST_FRIENDLY_OFFSET;
263                 pvt->f.src = pvt->t->name;
264                 pvt->f.data.ptr = pvt->outbuf.c;
265
266                 pvt->samples = 0;
267                 pvt->datalen = 0;
268                 return ast_frisolate(&pvt->f);
269         }
270
271         /* Shouldn't get here... */
272         return NULL;
273 }
274
275 static int dahdi_decoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
276 {
277         struct codec_dahdi_pvt *dahdip = pvt->pvt;
278
279         if (!f->subclass.codec) {
280                 /* We're just faking a return for calculation purposes. */
281                 dahdip->fake = 2;
282                 pvt->samples = f->samples;
283                 return 0;
284         }
285
286         if (!f->datalen) {
287                 if (f->samples != dahdip->required_samples) {
288                         ast_log(LOG_ERROR, "%d != %d %d\n", f->samples, dahdip->required_samples, f->datalen);
289                 }
290         }
291         dahdi_write_frame(dahdip, f->data.ptr, f->datalen);
292         pvt->samples += f->samples;
293         pvt->datalen = 0;
294         return -1;
295 }
296
297 static struct ast_frame *dahdi_decoder_frameout(struct ast_trans_pvt *pvt)
298 {
299         int res;
300         struct codec_dahdi_pvt *dahdip = pvt->pvt;
301
302         if (2 == dahdip->fake) {
303                 dahdip->fake = 1;
304                 pvt->f.frametype = AST_FRAME_VOICE;
305                 pvt->f.subclass.codec = 0;
306                 pvt->f.samples = dahdip->required_samples;
307                 pvt->f.data.ptr = NULL;
308                 pvt->f.offset = 0;
309                 pvt->f.datalen = 0;
310                 pvt->f.mallocd = 0;
311                 pvt->samples = 0;
312                 return ast_frisolate(&pvt->f);
313         } else if (1 == dahdip->fake) {
314                 pvt->samples = 0;
315                 dahdip->fake = 0;
316                 return NULL;
317         }
318
319         /* Let's check to see if there is a new frame for us.... */
320         if (dahdip->softslin) {
321                 res = read(dahdip->fd, dahdip->ulaw_buffer, sizeof(dahdip->ulaw_buffer));
322         } else {
323                 res = read(dahdip->fd, pvt->outbuf.c + pvt->datalen, pvt->t->buf_size - pvt->datalen);
324         }
325
326         if (-1 == res) {
327                 if (EWOULDBLOCK == errno) {
328                         /* Nothing waiting... */
329                         return NULL;
330                 } else {
331                         ast_log(LOG_ERROR, "Failed to read from transcoder: %s\n", strerror(errno));
332                         return NULL;
333                 }
334         } else {
335                 if (dahdip->softslin) {
336                         ulawtolin(pvt);
337                         pvt->f.datalen = res * 2;
338                 } else {
339                         pvt->f.datalen = res;
340                 }
341                 pvt->datalen = 0;
342                 pvt->f.frametype = AST_FRAME_VOICE;
343                 pvt->f.subclass.codec = 1 <<  (pvt->t->dstfmt);
344                 pvt->f.mallocd = 0;
345                 pvt->f.offset = AST_FRIENDLY_OFFSET;
346                 pvt->f.src = pvt->t->name;
347                 pvt->f.data.ptr = pvt->outbuf.c;
348                 pvt->f.samples = dahdip->required_samples;
349                 pvt->samples = 0;
350
351                 return ast_frisolate(&pvt->f);
352         }
353
354         /* Shouldn't get here... */
355         return NULL;
356 }
357
358
359 static void dahdi_destroy(struct ast_trans_pvt *pvt)
360 {
361         struct codec_dahdi_pvt *dahdip = pvt->pvt;
362
363         switch (dahdip->fmts.dstfmt) {
364         case AST_FORMAT_G729A:
365         case AST_FORMAT_G723_1:
366                 ast_atomic_fetchadd_int(&channels.encoders, -1);
367                 break;
368         default:
369                 ast_atomic_fetchadd_int(&channels.decoders, -1);
370                 break;
371         }
372
373         close(dahdip->fd);
374 }
375
376 static int dahdi_translate(struct ast_trans_pvt *pvt, int dest, int source)
377 {
378         /* Request translation through zap if possible */
379         int fd;
380         struct codec_dahdi_pvt *dahdip = pvt->pvt;
381         int flags;
382         int tried_once = 0;
383         const char *dev_filename = "/dev/dahdi/transcode";
384
385         if ((fd = open(dev_filename, O_RDWR)) < 0) {
386                 ast_log(LOG_ERROR, "Failed to open %s: %s\n", dev_filename, strerror(errno));
387                 return -1;
388         }
389
390         dahdip->fmts.srcfmt = (1 << source);
391         dahdip->fmts.dstfmt = (1 << dest);
392
393         ast_debug(1, "Opening transcoder channel from %d to %d.\n", source, dest);
394
395 retry:
396         if (ioctl(fd, DAHDI_TC_ALLOCATE, &dahdip->fmts)) {
397                 if ((ENODEV == errno) && !tried_once) {
398                         /* We requested to translate to/from an unsupported
399                          * format.  Most likely this is because signed linear
400                          * was not supported by any hardware devices even
401                          * though this module always registers signed linear
402                          * support. In this case we'll retry, requesting
403                          * support for ULAW instead of signed linear and then
404                          * we'll just convert from ulaw to signed linear in
405                          * software. */
406                         if (AST_FORMAT_SLINEAR == dahdip->fmts.srcfmt) {
407                                 ast_debug(1, "Using soft_slin support on source\n");
408                                 dahdip->softslin = 1;
409                                 dahdip->fmts.srcfmt = AST_FORMAT_ULAW;
410                         } else if (AST_FORMAT_SLINEAR == dahdip->fmts.dstfmt) {
411                                 ast_debug(1, "Using soft_slin support on destination\n");
412                                 dahdip->softslin = 1;
413                                 dahdip->fmts.dstfmt = AST_FORMAT_ULAW;
414                         }
415                         tried_once = 1;
416                         goto retry;
417                 }
418                 ast_log(LOG_ERROR, "Unable to attach to transcoder: %s\n", strerror(errno));
419                 close(fd);
420
421                 return -1;
422         }
423
424         flags = fcntl(fd, F_GETFL);
425         if (flags > - 1) {
426                 if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
427                         ast_log(LOG_WARNING, "Could not set non-block mode!\n");
428         }
429
430         dahdip->fd = fd;
431
432         dahdip->required_samples = ((dahdip->fmts.dstfmt|dahdip->fmts.srcfmt)&AST_FORMAT_G723_1) ? G723_SAMPLES : G729_SAMPLES;
433
434         switch (dahdip->fmts.dstfmt) {
435         case AST_FORMAT_G729A:
436                 ast_atomic_fetchadd_int(&channels.encoders, +1);
437                 break;
438         case AST_FORMAT_G723_1:
439                 ast_atomic_fetchadd_int(&channels.encoders, +1);
440                 break;
441         default:
442                 ast_atomic_fetchadd_int(&channels.decoders, +1);
443                 break;
444         }
445
446         return 0;
447 }
448
449 static int dahdi_new(struct ast_trans_pvt *pvt)
450 {
451         return dahdi_translate(pvt, pvt->t->dstfmt, pvt->t->srcfmt);
452 }
453
454 static struct ast_frame *fakesrc_sample(void)
455 {
456         /* Don't bother really trying to test hardware ones. */
457         static struct ast_frame f = {
458                 .frametype = AST_FRAME_VOICE,
459                 .samples = 160,
460                 .src = __PRETTY_FUNCTION__
461         };
462
463         return &f;
464 }
465
466 static int is_encoder(struct translator *zt)
467 {
468         if (zt->t.srcfmt&(AST_FORMAT_ULAW|AST_FORMAT_ALAW|AST_FORMAT_SLINEAR)) {
469                 return 1;
470         } else {
471                 return 0;
472         }
473 }
474
475 static int register_translator(int dst, int src)
476 {
477         struct translator *zt;
478         int res;
479
480         if (!(zt = ast_calloc(1, sizeof(*zt)))) {
481                 return -1;
482         }
483
484         snprintf((char *) (zt->t.name), sizeof(zt->t.name), "zap%sto%s",
485                  ast_getformatname((1 << src)), ast_getformatname((1 << dst)));
486         zt->t.srcfmt = (1 << src);
487         zt->t.dstfmt = (1 << dst);
488         zt->t.buf_size = BUFFER_SIZE;
489         if (is_encoder(zt)) {
490                 zt->t.framein = dahdi_encoder_framein;
491                 zt->t.frameout = dahdi_encoder_frameout;
492 #if 0
493                 zt->t.buffer_samples = 0;
494 #endif
495         } else {
496                 zt->t.framein = dahdi_decoder_framein;
497                 zt->t.frameout = dahdi_decoder_frameout;
498 #if 0
499                 if (AST_FORMAT_G723_1 == zt->t.srcfmt) {
500                         zt->t.plc_samples = G723_SAMPLES;
501                 } else {
502                         zt->t.plc_samples = G729_SAMPLES;
503                 }
504                 zt->t.buffer_samples = zt->t.plc_samples * 8;
505 #endif
506         }
507         zt->t.destroy = dahdi_destroy;
508         zt->t.buffer_samples = 0;
509         zt->t.newpvt = dahdi_new;
510         zt->t.sample = fakesrc_sample;
511 #if 0
512         zt->t.useplc = global_useplc;
513 #endif
514         zt->t.useplc = 0;
515         zt->t.native_plc = 0;
516
517         zt->t.desc_size = sizeof(struct codec_dahdi_pvt);
518         if ((res = ast_register_translator(&zt->t))) {
519                 ast_free(zt);
520                 return -1;
521         }
522
523         AST_LIST_LOCK(&translators);
524         AST_LIST_INSERT_HEAD(&translators, zt, entry);
525         AST_LIST_UNLOCK(&translators);
526
527         global_format_map.map[dst][src] = 1;
528
529         return res;
530 }
531
532 static void drop_translator(int dst, int src)
533 {
534         struct translator *cur;
535
536         AST_LIST_LOCK(&translators);
537         AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, cur, entry) {
538                 if (cur->t.srcfmt != src)
539                         continue;
540
541                 if (cur->t.dstfmt != dst)
542                         continue;
543
544                 AST_LIST_REMOVE_CURRENT(entry);
545                 ast_unregister_translator(&cur->t);
546                 ast_free(cur);
547                 global_format_map.map[dst][src] = 0;
548                 break;
549         }
550         AST_LIST_TRAVERSE_SAFE_END;
551         AST_LIST_UNLOCK(&translators);
552 }
553
554 static void unregister_translators(void)
555 {
556         struct translator *cur;
557
558         AST_LIST_LOCK(&translators);
559         while ((cur = AST_LIST_REMOVE_HEAD(&translators, entry))) {
560                 ast_unregister_translator(&cur->t);
561                 ast_free(cur);
562         }
563         AST_LIST_UNLOCK(&translators);
564 }
565
566 static int parse_config(int reload)
567 {
568         struct ast_variable *var;
569         struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
570         struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
571
572         if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
573                 return 0;
574
575         for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
576                if (!strcasecmp(var->name, "genericplc")) {
577                        global_useplc = ast_true(var->value);
578                        ast_verb(3, "codec_dahdi: %susing generic PLC\n",
579                                 global_useplc ? "" : "not ");
580                }
581         }
582
583         ast_config_destroy(cfg);
584         return 0;
585 }
586
587 static void build_translators(struct format_map *map, unsigned int dstfmts, unsigned int srcfmts)
588 {
589         unsigned int src, dst;
590
591         for (src = 0; src < 32; src++) {
592                 for (dst = 0; dst < 32; dst++) {
593                         if (!(srcfmts & (1 << src)))
594                                 continue;
595
596                         if (!(dstfmts & (1 << dst)))
597                                 continue;
598
599                         if (global_format_map.map[dst][src])
600                                 continue;
601
602                         if (!register_translator(dst, src))
603                                 map->map[dst][src] = 1;
604                 }
605         }
606 }
607
608 static int find_transcoders(void)
609 {
610         struct dahdi_transcoder_info info = { 0, };
611         struct format_map map = { { { 0 } } };
612         int fd, res;
613         unsigned int x, y;
614
615         if ((fd = open("/dev/dahdi/transcode", O_RDWR)) < 0) {
616                 ast_log(LOG_ERROR, "Failed to open /dev/dahdi/transcode: %s\n", strerror(errno));
617                 return 0;
618         }
619
620         for (info.tcnum = 0; !(res = ioctl(fd, DAHDI_TC_GETINFO, &info)); info.tcnum++) {
621                 if (option_verbose > 1)
622                         ast_verbose(VERBOSE_PREFIX_2 "Found transcoder '%s'.\n", info.name);
623
624                 /* Complex codecs need to support signed linear.  If the
625                  * hardware transcoder does not natively support signed linear
626                  * format, we will emulate it in software directly in this
627                  * module. Also, do not allow direct ulaw/alaw to complex
628                  * codec translation, since that will prevent the generic PLC
629                  * functions from working. */
630                 if (info.dstfmts & (AST_FORMAT_ULAW | AST_FORMAT_ALAW)) {
631                         info.dstfmts |= AST_FORMAT_SLINEAR;
632                         info.dstfmts &= ~(AST_FORMAT_ULAW | AST_FORMAT_ALAW);
633                 }
634                 if (info.srcfmts & (AST_FORMAT_ULAW | AST_FORMAT_ALAW)) {
635                         info.srcfmts |= AST_FORMAT_SLINEAR;
636                         info.srcfmts &= ~(AST_FORMAT_ULAW | AST_FORMAT_ALAW);
637                 }
638
639                 build_translators(&map, info.dstfmts, info.srcfmts);
640                 ast_atomic_fetchadd_int(&channels.total, info.numchannels / 2);
641
642         }
643
644         close(fd);
645
646         if (!info.tcnum && (option_verbose > 1))
647                 ast_verbose(VERBOSE_PREFIX_2 "No hardware transcoders found.\n");
648
649         for (x = 0; x < 32; x++) {
650                 for (y = 0; y < 32; y++) {
651                         if (!map.map[x][y] && global_format_map.map[x][y])
652                                 drop_translator(x, y);
653                 }
654         }
655
656         return 0;
657 }
658
659 static int reload(void)
660 {
661         struct translator *cur;
662
663         if (parse_config(1))
664                 return AST_MODULE_LOAD_DECLINE;
665
666         AST_LIST_LOCK(&translators);
667         AST_LIST_TRAVERSE(&translators, cur, entry)
668                 cur->t.useplc = global_useplc;
669         AST_LIST_UNLOCK(&translators);
670
671         return AST_MODULE_LOAD_SUCCESS;
672 }
673
674 static int unload_module(void)
675 {
676         ast_cli_unregister_multiple(cli, ARRAY_LEN(cli));
677         unregister_translators();
678
679         return 0;
680 }
681
682 static int load_module(void)
683 {
684         ast_ulaw_init();
685         if (parse_config(0))
686                 return AST_MODULE_LOAD_DECLINE;
687         find_transcoders();
688         ast_cli_register_multiple(cli, ARRAY_LEN(cli));
689         return AST_MODULE_LOAD_SUCCESS;
690 }
691
692 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generic DAHDI Transcoder Codec Translator",
693                 .load = load_module,
694                 .unload = unload_module,
695                 .reload = reload,
696                );