Asterisk - The Open Source Telephony Project GIT-master-0bf3178
|
Translate between various formats natively through DAHDI transcoding. More...
#include "asterisk.h"
#include <stdbool.h>
#include <poll.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <dahdi/user.h>
#include "asterisk/lock.h"
#include "asterisk/translate.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/cli.h"
#include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/ulaw.h"
#include "asterisk/format_compatibility.h"
Go to the source code of this file.
Data Structures | |
struct | channel_usage |
struct | codec_dahdi_pvt |
struct | translator |
struct | translators |
the list of translators More... | |
Macros | |
#define | BUFFER_SIZE 8000 |
#define | container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member))) |
#define | DAHDI_FORMAT_ADPCM (1 << 5) |
#define | DAHDI_FORMAT_ALAW (1 << 3) |
#define | DAHDI_FORMAT_G723_1 (1 << 0) |
#define | DAHDI_FORMAT_G726 (1 << 4) |
#define | DAHDI_FORMAT_G729A (1 << 8) |
#define | DAHDI_FORMAT_GSM (1 << 1) |
#define | DAHDI_FORMAT_ILBC (1 << 10) |
#define | DAHDI_FORMAT_LPC10 (1 << 7) |
#define | DAHDI_FORMAT_SLINEAR (1 << 6) |
#define | DAHDI_FORMAT_SPEEX (1 << 9) |
#define | DAHDI_FORMAT_ULAW (1 << 2) |
#define | G723_SAMPLES 240 |
#define | G729_SAMPLES 160 |
#define | ULAW_SAMPLES 160 |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static void | build_translators (uint32_t dstfmts, uint32_t srcfmts) |
static int | dahdi_decoder_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
static struct ast_frame * | dahdi_decoder_frameout (struct ast_trans_pvt *pvt) |
static void | dahdi_destroy (struct ast_trans_pvt *pvt) |
static int | dahdi_encoder_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
static struct ast_frame * | dahdi_encoder_frameout (struct ast_trans_pvt *pvt) |
static struct ast_format * | dahdi_format_to_cached (int format) |
static int | dahdi_new (struct ast_trans_pvt *pvt) |
static int | dahdi_translate (struct ast_trans_pvt *pvt, uint32_t dst_dahdi_fmt, uint32_t src_dahdi_fmt) |
static void | dahdi_wait_for_packet (int fd) |
static void | dahdi_write_frame (struct codec_dahdi_pvt *dahdip, const uint8_t *buffer, const ssize_t count) |
static struct ast_frame * | fakesrc_sample (void) |
static int | find_transcoders (void) |
static const struct ast_codec * | get_dahdi_codec (uint32_t dahdi_fmt) |
static char * | handle_cli_transcoder_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static bool | is_already_registered (uint32_t dstfmt, uint32_t srcfmt) |
static bool | is_encoder (uint32_t src_dahdi_fmt) |
static int | lintoulaw (struct ast_trans_pvt *pvt, struct ast_frame *f) |
static int | load_module (void) |
static int | register_translator (uint32_t dst_dahdi_fmt, uint32_t src_dahdi_fmt) |
static int | reload (void) |
static int | ulawtolin (struct ast_trans_pvt *pvt, int samples) |
static int | unload_module (void) |
static void | unregister_translators (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Generic DAHDI Transcoder Codec Translator" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct channel_usage | channels |
static struct ast_cli_entry | cli [] |
static struct translators | translators = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , } |
Translate between various formats natively through DAHDI transcoding.
Definition in file codec_dahdi.c.
#define BUFFER_SIZE 8000 |
Definition at line 55 of file codec_dahdi.c.
Definition at line 277 of file codec_dahdi.c.
#define DAHDI_FORMAT_ADPCM (1 << 5) |
ADPCM (IMA)
Definition at line 74 of file codec_dahdi.c.
#define DAHDI_FORMAT_ALAW (1 << 3) |
Raw A-law data (G.711)
Definition at line 70 of file codec_dahdi.c.
#define DAHDI_FORMAT_G723_1 (1 << 0) |
G.723.1 compression
Definition at line 64 of file codec_dahdi.c.
#define DAHDI_FORMAT_G726 (1 << 4) |
ADPCM (G.726, 32kbps)
Definition at line 72 of file codec_dahdi.c.
#define DAHDI_FORMAT_G729A (1 << 8) |
G.729A audio
Definition at line 80 of file codec_dahdi.c.
#define DAHDI_FORMAT_GSM (1 << 1) |
GSM compression
Definition at line 66 of file codec_dahdi.c.
#define DAHDI_FORMAT_ILBC (1 << 10) |
iLBC Free Compression
Definition at line 84 of file codec_dahdi.c.
#define DAHDI_FORMAT_LPC10 (1 << 7) |
LPC10, 180 samples/frame
Definition at line 78 of file codec_dahdi.c.
#define DAHDI_FORMAT_SLINEAR (1 << 6) |
Raw 16-bit Signed Linear (8000 Hz) PCM
Definition at line 76 of file codec_dahdi.c.
#define DAHDI_FORMAT_SPEEX (1 << 9) |
SpeeX Free Compression
Definition at line 82 of file codec_dahdi.c.
#define DAHDI_FORMAT_ULAW (1 << 2) |
Raw mu-law data (G.711)
Definition at line 68 of file codec_dahdi.c.
#define G723_SAMPLES 240 |
Definition at line 57 of file codec_dahdi.c.
#define G729_SAMPLES 160 |
Definition at line 58 of file codec_dahdi.c.
#define ULAW_SAMPLES 160 |
Definition at line 59 of file codec_dahdi.c.
|
static |
Definition at line 873 of file codec_dahdi.c.
|
static |
Definition at line 873 of file codec_dahdi.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 873 of file codec_dahdi.c.
|
static |
Definition at line 785 of file codec_dahdi.c.
References AST_LIST_LOCK, AST_LIST_UNLOCK, is_already_registered(), and register_translator().
Referenced by find_transcoders().
|
static |
Definition at line 476 of file codec_dahdi.c.
References ast_log, dahdi_write_frame(), ast_frame::data, ast_frame::datalen, ast_trans_pvt::datalen, codec_dahdi_pvt::fake, ast_frame_subclass::format, LOG_ERROR, ast_frame::ptr, ast_trans_pvt::pvt, codec_dahdi_pvt::required_samples, ast_frame::samples, ast_trans_pvt::samples, codec_dahdi_pvt::samples_written_to_hardware, and ast_frame::subclass.
Referenced by register_translator().
|
static |
Definition at line 499 of file codec_dahdi.c.
References AST_FRAME_VOICE, ast_frisolate, ast_log, ast_translator::buf_size, ast_trans_pvt::c, dahdi_wait_for_packet(), ast_frame::datalen, ast_trans_pvt::datalen, errno, ast_trans_pvt::f, codec_dahdi_pvt::fake, codec_dahdi_pvt::fd, ast_frame::frametype, LOG_ERROR, ast_translator::name, NULL, ast_trans_pvt::outbuf, ast_trans_pvt::pvt, codec_dahdi_pvt::required_samples, ast_frame::samples, ast_trans_pvt::samples, codec_dahdi_pvt::samples_written_to_hardware, codec_dahdi_pvt::softslin, ast_trans_pvt::t, codec_dahdi_pvt::ulaw_buffer, ULAW_SAMPLES, and ulawtolin().
Referenced by register_translator().
|
static |
Definition at line 562 of file codec_dahdi.c.
References ast_atomic_fetchadd_int(), channels, DAHDI_FORMAT_G723_1, DAHDI_FORMAT_G729A, channel_usage::decoders, channel_usage::encoders, codec_dahdi_pvt::fd, codec_dahdi_pvt::fmts, and ast_trans_pvt::pvt.
Referenced by register_translator().
|
static |
Definition at line 372 of file codec_dahdi.c.
References ast_log, dahdi_write_frame(), ast_frame::data, ast_trans_pvt::datalen, codec_dahdi_pvt::fake, ast_frame_subclass::format, lintoulaw(), LOG_ERROR, ast_frame::ptr, ast_trans_pvt::pvt, codec_dahdi_pvt::required_samples, ast_frame::samples, ast_trans_pvt::samples, codec_dahdi_pvt::samples_in_buffer, codec_dahdi_pvt::samples_written_to_hardware, codec_dahdi_pvt::softslin, ast_frame::subclass, and codec_dahdi_pvt::ulaw_buffer.
Referenced by register_translator().
|
static |
Definition at line 425 of file codec_dahdi.c.
References ast_codec_samples_count(), AST_FRAME_VOICE, ast_frisolate, ast_log, ast_translator::buf_size, ast_trans_pvt::c, dahdi_wait_for_packet(), ast_frame::datalen, ast_trans_pvt::datalen, errno, ast_trans_pvt::f, codec_dahdi_pvt::fake, codec_dahdi_pvt::fd, ast_frame::frametype, LOG_ERROR, ast_translator::name, NULL, ast_trans_pvt::outbuf, ast_trans_pvt::pvt, codec_dahdi_pvt::required_samples, ast_frame::samples, ast_trans_pvt::samples, codec_dahdi_pvt::samples_written_to_hardware, and ast_trans_pvt::t.
Referenced by register_translator().
|
static |
Definition at line 579 of file codec_dahdi.c.
References ast_assert, ast_format_adpcm, ast_format_alaw, ast_format_g723, ast_format_g726, ast_format_g729, ast_format_gsm, ast_format_ilbc, ast_format_lpc10, ast_format_slin, ast_format_speex, ast_format_ulaw, DAHDI_FORMAT_ADPCM, DAHDI_FORMAT_ALAW, DAHDI_FORMAT_G723_1, DAHDI_FORMAT_G726, DAHDI_FORMAT_G729A, DAHDI_FORMAT_GSM, DAHDI_FORMAT_ILBC, DAHDI_FORMAT_LPC10, DAHDI_FORMAT_SLINEAR, DAHDI_FORMAT_SPEEX, DAHDI_FORMAT_ULAW, and NULL.
Referenced by dahdi_translate().
|
static |
Definition at line 682 of file codec_dahdi.c.
References container_of, dahdi_translate(), translator::dst_dahdi_fmt, translator::src_dahdi_fmt, translator::t, and ast_trans_pvt::t.
Referenced by register_translator().
|
static |
Definition at line 611 of file codec_dahdi.c.
References ao2_bump, ast_assert, ast_atomic_fetchadd_int(), ast_debug, ast_fd_set_flags, ast_log, channels, DAHDI_FORMAT_G723_1, DAHDI_FORMAT_G729A, DAHDI_FORMAT_SLINEAR, dahdi_format_to_cached(), DAHDI_FORMAT_ULAW, channel_usage::decoders, ast_translator::dst_codec, channel_usage::encoders, errno, ast_trans_pvt::f, codec_dahdi_pvt::fd, codec_dahdi_pvt::fmts, ast_frame_subclass::format, G723_SAMPLES, G729_SAMPLES, LOG_ERROR, ast_codec::name, NULL, ast_trans_pvt::pvt, codec_dahdi_pvt::required_samples, codec_dahdi_pvt::softslin, ast_translator::src_codec, ast_frame::subclass, and ast_trans_pvt::t.
Referenced by dahdi_new().
|
static |
Definition at line 417 of file codec_dahdi.c.
Referenced by dahdi_decoder_frameout(), and dahdi_encoder_frameout().
|
static |
Definition at line 359 of file codec_dahdi.c.
References ast_log, errno, codec_dahdi_pvt::fd, and LOG_ERROR.
Referenced by dahdi_decoder_framein(), and dahdi_encoder_framein().
|
static |
Definition at line 689 of file codec_dahdi.c.
References AST_FRAME_VOICE, and ast_frame::frametype.
Referenced by register_translator().
|
static |
Definition at line 807 of file codec_dahdi.c.
References ast_atomic_fetchadd_int(), ast_log, ast_verb, build_translators(), channels, DAHDI_FORMAT_ALAW, DAHDI_FORMAT_SLINEAR, DAHDI_FORMAT_ULAW, errno, sip_to_pjsip::info(), LOG_ERROR, and channel_usage::total.
Referenced by load_module().
|
static |
Definition at line 161 of file codec_dahdi.c.
References AST_MEDIA_TYPE_AUDIO, DAHDI_FORMAT_ADPCM, DAHDI_FORMAT_ALAW, DAHDI_FORMAT_G723_1, DAHDI_FORMAT_G726, DAHDI_FORMAT_G729A, DAHDI_FORMAT_GSM, DAHDI_FORMAT_ILBC, DAHDI_FORMAT_LPC10, DAHDI_FORMAT_SLINEAR, DAHDI_FORMAT_SPEEX, DAHDI_FORMAT_ULAW, ast_codec::name, and NULL.
Referenced by register_translator().
|
static |
Definition at line 331 of file codec_dahdi.c.
References a, ast_cli(), channels, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, copy(), NULL, and ast_cli_entry::usage.
|
static |
Definition at line 770 of file codec_dahdi.c.
References AST_LIST_TRAVERSE, translator::dst_dahdi_fmt, and translator::src_dahdi_fmt.
Referenced by build_translators().
|
static |
Definition at line 701 of file codec_dahdi.c.
References DAHDI_FORMAT_ALAW, DAHDI_FORMAT_SLINEAR, and DAHDI_FORMAT_ULAW.
Referenced by register_translator().
|
static |
Definition at line 311 of file codec_dahdi.c.
References AST_LIN2MU, ast_log, ast_frame::data, LOG_ERROR, ast_frame::ptr, ast_trans_pvt::pvt, ast_frame::samples, codec_dahdi_pvt::samples_in_buffer, and codec_dahdi_pvt::ulaw_buffer.
Referenced by dahdi_encoder_framein().
|
static |
Definition at line 861 of file codec_dahdi.c.
References ARRAY_LEN, ast_cli_register_multiple, AST_MODULE_LOAD_SUCCESS, cli, and find_transcoders().
|
static |
Definition at line 707 of file codec_dahdi.c.
References ast_calloc, ast_free, AST_LIST_INSERT_HEAD, ast_register_translator, ast_translator::buf_size, ast_translator::buffer_samples, BUFFER_SIZE, dahdi_decoder_framein(), dahdi_decoder_frameout(), dahdi_destroy(), dahdi_encoder_framein(), dahdi_encoder_frameout(), dahdi_new(), ast_translator::desc_size, ast_translator::destroy, ast_translator::dst_codec, translator::dst_dahdi_fmt, fakesrc_sample(), ast_translator::framein, ast_translator::frameout, get_dahdi_codec(), is_encoder(), ast_codec::name, ast_translator::name, ast_translator::native_plc, ast_translator::newpvt, ast_translator::sample, ast_translator::src_codec, translator::src_dahdi_fmt, and translator::t.
Referenced by build_translators().
|
static |
Definition at line 848 of file codec_dahdi.c.
References AST_MODULE_LOAD_SUCCESS.
|
static |
Definition at line 295 of file codec_dahdi.c.
References AST_MULAW, ast_trans_pvt::datalen, ast_trans_pvt::i16, ast_trans_pvt::outbuf, ast_trans_pvt::pvt, and codec_dahdi_pvt::ulaw_buffer.
Referenced by dahdi_decoder_frameout().
|
static |
Definition at line 853 of file codec_dahdi.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), cli, and unregister_translators().
|
static |
Definition at line 757 of file codec_dahdi.c.
References ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_unregister_translator(), and translator::t.
Referenced by unload_module().
|
static |
Definition at line 873 of file codec_dahdi.c.
|
static |
Definition at line 873 of file codec_dahdi.c.
|
static |
Referenced by action_coreshowchannels(), action_dahdishowchannels(), action_status(), app_to_json(), ast_bridge_peers(), ast_bridge_peers_nolock(), ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), broadcast_exec(), channels_scrape_cb(), check_header(), control_list_create(), dahdi_destroy(), dahdi_translate(), do_broadcast(), find_transcoders(), get_transferee(), handle_chanlist(), handle_cli_transcoder_show(), main(), manage_calls(), set_transfer_variables_all(), stasis_app_to_cli(), and two_bridge_attended_transfer().
|
static |
Definition at line 265 of file codec_dahdi.c.
Referenced by cli_complete_subscription_callid(), cli_complete_subscription_common(), cli_list_subscriptions_detail(), cli_list_subscriptions_inout(), cli_show_subscription_common(), cli_show_subscription_inout(), cli_show_subscriptions_detail(), cli_show_subscriptions_inout(), load_module(), and unload_module().
|
static |