codec_dahdi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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. /*! \file
  22. *
  23. * \brief Translate between various formats natively through DAHDI transcoding
  24. *
  25. * \ingroup codecs
  26. */
  27. /*** MODULEINFO
  28. <depend>dahdi_transcode</depend>
  29. <depend>dahdi</depend>
  30. ***/
  31. #include "asterisk.h"
  32. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  33. #include <fcntl.h>
  34. #include <stdlib.h>
  35. #include <unistd.h>
  36. #include <netinet/in.h>
  37. #include <string.h>
  38. #include <stdio.h>
  39. #include <sys/ioctl.h>
  40. #include <errno.h>
  41. #include <sys/mman.h>
  42. #include <sys/poll.h>
  43. #include "asterisk/lock.h"
  44. #include "asterisk/translate.h"
  45. #include "asterisk/config.h"
  46. #include "asterisk/options.h"
  47. #include "asterisk/module.h"
  48. #include "asterisk/cli.h"
  49. #include "asterisk/logger.h"
  50. #include "asterisk/channel.h"
  51. #include "asterisk/utils.h"
  52. #include "asterisk/linkedlists.h"
  53. #include "asterisk/dahdi_compat.h"
  54. #include "asterisk/frame.h"
  55. #include "asterisk/ulaw.h"
  56. #define BUFFER_SIZE 8000
  57. #define G723_SAMPLES 240
  58. #define G729_SAMPLES 160
  59. static struct channel_usage {
  60. int total;
  61. int encoders;
  62. int decoders;
  63. } channels;
  64. static char show_transcoder_usage[] =
  65. "Usage: show transcoder\n"
  66. " Displays channel utilization of DAHDI transcoder(s).\n";
  67. static char transcoder_show_usage[] =
  68. "Usage: transcoder show\n"
  69. " Displays channel utilization of DAHDI transcoder(s).\n";
  70. static int transcoder_show(int fd, int argc, char **argv);
  71. static struct ast_cli_entry cli_deprecated[] = {
  72. { { "show", "transcoder", NULL },
  73. transcoder_show,
  74. "Display DAHDI transcoder utilization.",
  75. show_transcoder_usage}
  76. };
  77. static struct ast_cli_entry cli[] = {
  78. { { "transcoder", "show", NULL },
  79. transcoder_show,
  80. "Display DAHDI transcoder utilization.",
  81. transcoder_show_usage, NULL,
  82. &cli_deprecated[0]}
  83. };
  84. struct format_map {
  85. unsigned int map[32][32];
  86. };
  87. static struct format_map global_format_map = { { { 0 } } };
  88. struct translator {
  89. struct ast_translator t;
  90. AST_LIST_ENTRY(translator) entry;
  91. };
  92. static AST_LIST_HEAD_STATIC(translators, translator);
  93. struct codec_dahdi_pvt {
  94. int fd;
  95. struct dahdi_transcoder_formats fmts;
  96. unsigned int softslin:1;
  97. unsigned int fake:2;
  98. uint16_t required_samples;
  99. uint16_t samples_in_buffer;
  100. uint8_t ulaw_buffer[1024];
  101. };
  102. /* Only used by a decoder */
  103. static int ulawtolin(struct ast_trans_pvt *pvt, int samples)
  104. {
  105. struct codec_dahdi_pvt *ztp = pvt->pvt;
  106. int i = samples;
  107. uint8_t *src = &ztp->ulaw_buffer[0];
  108. int16_t *dst = (int16_t *)pvt->outbuf + pvt->datalen;
  109. /* convert and copy in outbuf */
  110. while (i--) {
  111. *dst++ = AST_MULAW(*src++);
  112. }
  113. return 0;
  114. }
  115. /* Only used by an encoder. */
  116. static int lintoulaw(struct ast_trans_pvt *pvt, struct ast_frame *f)
  117. {
  118. struct codec_dahdi_pvt *ztp = pvt->pvt;
  119. int i = f->samples;
  120. uint8_t *dst = &ztp->ulaw_buffer[ztp->samples_in_buffer];
  121. int16_t *src = (int16_t*)f->data;
  122. if (ztp->samples_in_buffer + i > sizeof(ztp->ulaw_buffer)) {
  123. ast_log(LOG_ERROR, "Out of buffer space!\n");
  124. return -i;
  125. }
  126. while (i--) {
  127. *dst++ = AST_LIN2MU(*src++);
  128. }
  129. ztp->samples_in_buffer += f->samples;
  130. return 0;
  131. }
  132. static int transcoder_show(int fd, int argc, char **argv)
  133. {
  134. struct channel_usage copy;
  135. copy = channels;
  136. if (copy.total == 0)
  137. ast_cli(fd, "No DAHDI transcoders found.\n");
  138. else
  139. ast_cli(fd, "%d/%d encoders/decoders of %d channels are in use.\n", copy.encoders, copy.decoders, copy.total);
  140. return RESULT_SUCCESS;
  141. }
  142. static void dahdi_write_frame(struct codec_dahdi_pvt *ztp, const uint8_t *buffer, const ssize_t count)
  143. {
  144. int res;
  145. struct pollfd p = {0};
  146. if (!count) return;
  147. res = write(ztp->fd, buffer, count);
  148. if (option_verbose > 10) {
  149. if (-1 == res) {
  150. ast_log(LOG_ERROR, "Failed to write to transcoder: %s\n", strerror(errno));
  151. }
  152. if (count != res) {
  153. ast_log(LOG_ERROR, "Requested write of %zd bytes, but only wrote %d bytes.\n", count, res);
  154. }
  155. }
  156. p.fd = ztp->fd;
  157. p.events = POLLOUT;
  158. res = poll(&p, 1, 50);
  159. }
  160. static int dahdi_encoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
  161. {
  162. struct codec_dahdi_pvt *ztp = pvt->pvt;
  163. if (!f->subclass) {
  164. /* We're just faking a return for calculation purposes. */
  165. ztp->fake = 2;
  166. pvt->samples = f->samples;
  167. return 0;
  168. }
  169. /* Buffer up the packets and send them to the hardware if we
  170. * have enough samples set up. */
  171. if (ztp->softslin) {
  172. if (lintoulaw(pvt, f)) {
  173. return -1;
  174. }
  175. } else {
  176. /* NOTE: If softslin support is not needed, and the sample
  177. * size is equal to the required sample size, we wouldn't
  178. * need this copy operation. But at the time this was
  179. * written, only softslin is supported. */
  180. if (ztp->samples_in_buffer + f->samples > sizeof(ztp->ulaw_buffer)) {
  181. ast_log(LOG_ERROR, "Out of buffer space.\n");
  182. return -1;
  183. }
  184. memcpy(&ztp->ulaw_buffer[ztp->samples_in_buffer], f->data, f->samples);
  185. ztp->samples_in_buffer += f->samples;
  186. }
  187. while (ztp->samples_in_buffer > ztp->required_samples) {
  188. dahdi_write_frame(ztp, ztp->ulaw_buffer, ztp->required_samples);
  189. ztp->samples_in_buffer -= ztp->required_samples;
  190. if (ztp->samples_in_buffer) {
  191. /* Shift any remaining bytes down. */
  192. memmove(ztp->ulaw_buffer, &ztp->ulaw_buffer[ztp->required_samples],
  193. ztp->samples_in_buffer);
  194. }
  195. }
  196. pvt->samples += f->samples;
  197. pvt->datalen = 0;
  198. return -1;
  199. }
  200. static struct ast_frame *dahdi_encoder_frameout(struct ast_trans_pvt *pvt)
  201. {
  202. struct codec_dahdi_pvt *ztp = pvt->pvt;
  203. int res;
  204. if (2 == ztp->fake) {
  205. ztp->fake = 1;
  206. pvt->f.frametype = AST_FRAME_VOICE;
  207. pvt->f.subclass = 0;
  208. pvt->f.samples = ztp->required_samples;
  209. pvt->f.data = NULL;
  210. pvt->f.offset = 0;
  211. pvt->f.datalen = 0;
  212. pvt->f.mallocd = 0;
  213. pvt->samples = 0;
  214. return ast_frisolate(&pvt->f);
  215. } else if (1 == ztp->fake) {
  216. ztp->fake = 0;
  217. return NULL;
  218. }
  219. res = read(ztp->fd, pvt->outbuf + pvt->datalen, pvt->t->buf_size - pvt->datalen);
  220. if (-1 == res) {
  221. if (EWOULDBLOCK == errno) {
  222. /* Nothing waiting... */
  223. return NULL;
  224. } else {
  225. ast_log(LOG_ERROR, "Failed to read from transcoder: %s\n", strerror(errno));
  226. return NULL;
  227. }
  228. } else {
  229. pvt->f.datalen = res;
  230. pvt->f.samples = ztp->required_samples;
  231. pvt->f.frametype = AST_FRAME_VOICE;
  232. pvt->f.subclass = 1 << (pvt->t->dstfmt);
  233. pvt->f.mallocd = 0;
  234. pvt->f.offset = AST_FRIENDLY_OFFSET;
  235. pvt->f.src = pvt->t->name;
  236. pvt->f.data = pvt->outbuf;
  237. pvt->samples = 0;
  238. pvt->datalen = 0;
  239. return ast_frisolate(&pvt->f);
  240. }
  241. /* Shouldn't get here... */
  242. return NULL;
  243. }
  244. static int dahdi_decoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
  245. {
  246. struct codec_dahdi_pvt *ztp = pvt->pvt;
  247. if (!f->subclass) {
  248. /* We're just faking a return for calculation purposes. */
  249. ztp->fake = 2;
  250. pvt->samples = f->samples;
  251. return 0;
  252. }
  253. if (!f->datalen) {
  254. if (f->samples != ztp->required_samples) {
  255. ast_log(LOG_ERROR, "%d != %d %d\n", f->samples, ztp->required_samples, f->datalen);
  256. }
  257. }
  258. dahdi_write_frame(ztp, f->data, f->datalen);
  259. pvt->samples += f->samples;
  260. pvt->datalen = 0;
  261. return -1;
  262. }
  263. static struct ast_frame *dahdi_decoder_frameout(struct ast_trans_pvt *pvt)
  264. {
  265. int res;
  266. struct codec_dahdi_pvt *ztp = pvt->pvt;
  267. if (2 == ztp->fake) {
  268. ztp->fake = 1;
  269. pvt->f.frametype = AST_FRAME_VOICE;
  270. pvt->f.subclass = 0;
  271. pvt->f.samples = ztp->required_samples;
  272. pvt->f.data = NULL;
  273. pvt->f.offset = 0;
  274. pvt->f.datalen = 0;
  275. pvt->f.mallocd = 0;
  276. pvt->samples = 0;
  277. return ast_frisolate(&pvt->f);
  278. } else if (1 == ztp->fake) {
  279. pvt->samples = 0;
  280. ztp->fake = 0;
  281. return NULL;
  282. }
  283. /* Let's check to see if there is a new frame for us.... */
  284. if (ztp->softslin) {
  285. res = read(ztp->fd, ztp->ulaw_buffer, sizeof(ztp->ulaw_buffer));
  286. } else {
  287. res = read(ztp->fd, pvt->outbuf + pvt->datalen, pvt->t->buf_size - pvt->datalen);
  288. }
  289. if (-1 == res) {
  290. if (EWOULDBLOCK == errno) {
  291. /* Nothing waiting... */
  292. return NULL;
  293. } else {
  294. ast_log(LOG_ERROR, "Failed to read from transcoder: %s\n", strerror(errno));
  295. return NULL;
  296. }
  297. } else {
  298. if (ztp->softslin) {
  299. ulawtolin(pvt, res);
  300. pvt->f.datalen = res * 2;
  301. } else {
  302. pvt->f.datalen = res;
  303. }
  304. pvt->datalen = 0;
  305. pvt->f.frametype = AST_FRAME_VOICE;
  306. pvt->f.subclass = 1 << (pvt->t->dstfmt);
  307. pvt->f.mallocd = 0;
  308. pvt->f.offset = AST_FRIENDLY_OFFSET;
  309. pvt->f.src = pvt->t->name;
  310. pvt->f.data = pvt->outbuf;
  311. pvt->f.samples = res;
  312. pvt->samples = 0;
  313. return ast_frisolate(&pvt->f);
  314. }
  315. /* Shouldn't get here... */
  316. return NULL;
  317. }
  318. static void dahdi_destroy(struct ast_trans_pvt *pvt)
  319. {
  320. struct codec_dahdi_pvt *ztp = pvt->pvt;
  321. switch (ztp->fmts.dstfmt) {
  322. case AST_FORMAT_G729A:
  323. case AST_FORMAT_G723_1:
  324. ast_atomic_fetchadd_int(&channels.encoders, -1);
  325. break;
  326. default:
  327. ast_atomic_fetchadd_int(&channels.decoders, -1);
  328. break;
  329. }
  330. close(ztp->fd);
  331. }
  332. static int dahdi_translate(struct ast_trans_pvt *pvt, int dest, int source)
  333. {
  334. /* Request translation through zap if possible */
  335. int fd;
  336. struct codec_dahdi_pvt *ztp = pvt->pvt;
  337. int flags;
  338. int tried_once = 0;
  339. #ifdef HAVE_ZAPTEL
  340. const char *dev_filename = "/dev/zap/transcode";
  341. #else
  342. const char *dev_filename = "/dev/dahdi/transcode";
  343. #endif
  344. if ((fd = open(dev_filename, O_RDWR)) < 0) {
  345. ast_log(LOG_ERROR, "Failed to open %s: %s\n", dev_filename, strerror(errno));
  346. return -1;
  347. }
  348. ztp->fmts.srcfmt = (1 << source);
  349. ztp->fmts.dstfmt = (1 << dest);
  350. if (option_debug) {
  351. ast_log(LOG_DEBUG, "Opening transcoder channel from %d to %d.\n", source, dest);
  352. }
  353. retry:
  354. if (ioctl(fd, DAHDI_TC_ALLOCATE, &ztp->fmts)) {
  355. if ((ENODEV == errno) && !tried_once) {
  356. /* We requested to translate to/from an unsupported
  357. * format. Most likely this is because signed linear
  358. * was not supported by any hardware devices even
  359. * though this module always registers signed linear
  360. * support. In this case we'll retry, requesting
  361. * support for ULAW instead of signed linear and then
  362. * we'll just convert from ulaw to signed linear in
  363. * software. */
  364. if (AST_FORMAT_SLINEAR == ztp->fmts.srcfmt) {
  365. if (option_debug) {
  366. ast_log(LOG_DEBUG, "Using soft_slin support on source\n");
  367. }
  368. ztp->softslin = 1;
  369. ztp->fmts.srcfmt = AST_FORMAT_ULAW;
  370. } else if (AST_FORMAT_SLINEAR == ztp->fmts.dstfmt) {
  371. if (option_debug) {
  372. ast_log(LOG_DEBUG, "Using soft_slin support on destination\n");
  373. }
  374. ztp->softslin = 1;
  375. ztp->fmts.dstfmt = AST_FORMAT_ULAW;
  376. }
  377. tried_once = 1;
  378. goto retry;
  379. }
  380. ast_log(LOG_ERROR, "Unable to attach to transcoder: %s\n", strerror(errno));
  381. close(fd);
  382. return -1;
  383. }
  384. flags = fcntl(fd, F_GETFL);
  385. if (flags > - 1) {
  386. if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
  387. ast_log(LOG_WARNING, "Could not set non-block mode!\n");
  388. }
  389. ztp->fd = fd;
  390. ztp->required_samples = ((ztp->fmts.dstfmt|ztp->fmts.srcfmt)&AST_FORMAT_G723_1) ? G723_SAMPLES : G729_SAMPLES;
  391. switch (ztp->fmts.dstfmt) {
  392. case AST_FORMAT_G729A:
  393. ast_atomic_fetchadd_int(&channels.encoders, +1);
  394. break;
  395. case AST_FORMAT_G723_1:
  396. ast_atomic_fetchadd_int(&channels.encoders, +1);
  397. break;
  398. default:
  399. ast_atomic_fetchadd_int(&channels.decoders, +1);
  400. break;
  401. }
  402. return 0;
  403. }
  404. static int dahdi_new(struct ast_trans_pvt *pvt)
  405. {
  406. return dahdi_translate(pvt, pvt->t->dstfmt, pvt->t->srcfmt);
  407. }
  408. static struct ast_frame *fakesrc_sample(void)
  409. {
  410. /* Don't bother really trying to test hardware ones. */
  411. static struct ast_frame f = {
  412. .frametype = AST_FRAME_VOICE,
  413. .samples = 160,
  414. .src = __PRETTY_FUNCTION__
  415. };
  416. return &f;
  417. }
  418. static int is_encoder(struct translator *zt)
  419. {
  420. if (zt->t.srcfmt&(AST_FORMAT_ULAW|AST_FORMAT_ALAW|AST_FORMAT_SLINEAR)) {
  421. return 1;
  422. } else {
  423. return 0;
  424. }
  425. }
  426. static int register_translator(int dst, int src)
  427. {
  428. struct translator *zt;
  429. int res;
  430. if (!(zt = ast_calloc(1, sizeof(*zt)))) {
  431. return -1;
  432. }
  433. snprintf((char *) (zt->t.name), sizeof(zt->t.name), "zap%sto%s",
  434. ast_getformatname((1 << src)), ast_getformatname((1 << dst)));
  435. zt->t.srcfmt = (1 << src);
  436. zt->t.dstfmt = (1 << dst);
  437. zt->t.buf_size = BUFFER_SIZE;
  438. if (is_encoder(zt)) {
  439. zt->t.framein = dahdi_encoder_framein;
  440. zt->t.frameout = dahdi_encoder_frameout;
  441. } else {
  442. zt->t.framein = dahdi_decoder_framein;
  443. zt->t.frameout = dahdi_decoder_frameout;
  444. }
  445. zt->t.destroy = dahdi_destroy;
  446. zt->t.buffer_samples = 0;
  447. zt->t.newpvt = dahdi_new;
  448. zt->t.sample = fakesrc_sample;
  449. zt->t.native_plc = 0;
  450. zt->t.desc_size = sizeof(struct codec_dahdi_pvt);
  451. if ((res = ast_register_translator(&zt->t))) {
  452. free(zt);
  453. return -1;
  454. }
  455. AST_LIST_LOCK(&translators);
  456. AST_LIST_INSERT_HEAD(&translators, zt, entry);
  457. AST_LIST_UNLOCK(&translators);
  458. global_format_map.map[dst][src] = 1;
  459. return res;
  460. }
  461. static void drop_translator(int dst, int src)
  462. {
  463. struct translator *cur;
  464. AST_LIST_LOCK(&translators);
  465. AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, cur, entry) {
  466. if (cur->t.srcfmt != src)
  467. continue;
  468. if (cur->t.dstfmt != dst)
  469. continue;
  470. AST_LIST_REMOVE_CURRENT(&translators, entry);
  471. ast_unregister_translator(&cur->t);
  472. free(cur);
  473. global_format_map.map[dst][src] = 0;
  474. break;
  475. }
  476. AST_LIST_TRAVERSE_SAFE_END;
  477. AST_LIST_UNLOCK(&translators);
  478. }
  479. static void unregister_translators(void)
  480. {
  481. struct translator *cur;
  482. AST_LIST_LOCK(&translators);
  483. while ((cur = AST_LIST_REMOVE_HEAD(&translators, entry))) {
  484. ast_unregister_translator(&cur->t);
  485. free(cur);
  486. }
  487. AST_LIST_UNLOCK(&translators);
  488. }
  489. static void build_translators(struct format_map *map, unsigned int dstfmts, unsigned int srcfmts)
  490. {
  491. unsigned int src, dst;
  492. for (src = 0; src < 32; src++) {
  493. for (dst = 0; dst < 32; dst++) {
  494. if (!(srcfmts & (1 << src)))
  495. continue;
  496. if (!(dstfmts & (1 << dst)))
  497. continue;
  498. if (global_format_map.map[dst][src])
  499. continue;
  500. if (!register_translator(dst, src))
  501. map->map[dst][src] = 1;
  502. }
  503. }
  504. }
  505. static int find_transcoders(void)
  506. {
  507. struct dahdi_transcoder_info info = { 0, };
  508. struct format_map map = { { { 0 } } };
  509. int fd, res;
  510. unsigned int x, y;
  511. if ((fd = open(DAHDI_FILE_TRANSCODE, O_RDWR)) < 0) {
  512. ast_log(LOG_ERROR, "Failed to open " DAHDI_FILE_TRANSCODE ": %s\n", strerror(errno));
  513. return 0;
  514. }
  515. for (info.tcnum = 0; !(res = ioctl(fd, DAHDI_TC_GETINFO, &info)); info.tcnum++) {
  516. if (option_verbose > 1)
  517. ast_verbose(VERBOSE_PREFIX_2 "Found transcoder '%s'.\n", info.name);
  518. /* Complex codecs need to support signed linear. If the
  519. * hardware transcoder does not natively support signed linear
  520. * format, we will emulate it in software directly in this
  521. * module. Also, do not allow direct ulaw/alaw to complex
  522. * codec translation, since that will prevent the generic PLC
  523. * functions from working. */
  524. if (info.dstfmts & (AST_FORMAT_ULAW | AST_FORMAT_ALAW)) {
  525. info.dstfmts |= AST_FORMAT_SLINEAR;
  526. info.dstfmts &= ~(AST_FORMAT_ULAW | AST_FORMAT_ALAW);
  527. }
  528. if (info.srcfmts & (AST_FORMAT_ULAW | AST_FORMAT_ALAW)) {
  529. info.srcfmts |= AST_FORMAT_SLINEAR;
  530. info.srcfmts &= ~(AST_FORMAT_ULAW | AST_FORMAT_ALAW);
  531. }
  532. build_translators(&map, info.dstfmts, info.srcfmts);
  533. ast_atomic_fetchadd_int(&channels.total, info.numchannels / 2);
  534. }
  535. close(fd);
  536. if (!info.tcnum && (option_verbose > 1))
  537. ast_verbose(VERBOSE_PREFIX_2 "No hardware transcoders found.\n");
  538. for (x = 0; x < 32; x++) {
  539. for (y = 0; y < 32; y++) {
  540. if (!map.map[x][y] && global_format_map.map[x][y])
  541. drop_translator(x, y);
  542. }
  543. }
  544. return 0;
  545. }
  546. static int reload(void)
  547. {
  548. return 0;
  549. }
  550. static int unload_module(void)
  551. {
  552. ast_cli_unregister_multiple(cli, sizeof(cli) / sizeof(cli[0]));
  553. unregister_translators();
  554. return 0;
  555. }
  556. static int load_module(void)
  557. {
  558. ast_ulaw_init();
  559. find_transcoders();
  560. ast_cli_register_multiple(cli, sizeof(cli) / sizeof(cli[0]));
  561. return 0;
  562. }
  563. AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generic DAHDI Transcoder Codec Translator",
  564. .load = load_module,
  565. .unload = unload_module,
  566. .reload = reload,
  567. );