mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
mISDN >= 1.2 provides a dsp pipeline for i.e. echo cancellation modules, make chan_misdn use it.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@59199 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -88,6 +88,10 @@ ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/mISDNuser/mISDNlib.h),)
|
||||
CFLAGS+=-Imisdn
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/mISDNdsp.h),)
|
||||
CFLAGS+=-DMISDN_1_2
|
||||
endif
|
||||
|
||||
CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
|
||||
|
||||
ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/alsa/asoundlib.h),)
|
||||
@@ -238,7 +242,7 @@ chan_h323.so: chan_h323.o h323/libchanh323.a
|
||||
endif
|
||||
|
||||
misdn/chan_misdn_lib.a:
|
||||
make -C misdn
|
||||
make CROSS_COMPILE_TARGET=$(CROSS_COMPILE_TARGET) -C misdn
|
||||
|
||||
chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a
|
||||
$(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN
|
||||
|
@@ -283,9 +283,6 @@ static int tracing = 0 ;
|
||||
|
||||
static int usecnt=0;
|
||||
|
||||
static char **misdn_key_vector=NULL;
|
||||
static int misdn_key_vector_size=0;
|
||||
|
||||
/* Only alaw and mulaw is allowed for now */
|
||||
static int prefformat = AST_FORMAT_ALAW ; /* AST_FORMAT_SLINEAR ; AST_FORMAT_ULAW | */
|
||||
|
||||
@@ -325,7 +322,11 @@ static int misdn_facility_exec(struct ast_channel *chan, void *data);
|
||||
|
||||
int chan_misdn_jb_empty(struct misdn_bchannel *bc, char *buf, int len);
|
||||
|
||||
#ifdef MISDN_1_2
|
||||
static int update_pipeline_config(struct misdn_bchannel *bc);
|
||||
#else
|
||||
static int update_ec_config(struct misdn_bchannel *bc);
|
||||
#endif
|
||||
|
||||
/*************** Helpers *****************/
|
||||
|
||||
@@ -773,7 +774,11 @@ static void print_bc_info (int fd, struct chan_list* help, struct misdn_bchannel
|
||||
" --> activated: %d\n"
|
||||
" --> state: %s\n"
|
||||
" --> capability: %s\n"
|
||||
#ifdef MISDN_1_2
|
||||
" --> pipeline: %s\n"
|
||||
#else
|
||||
" --> echo_cancel: %d\n"
|
||||
#endif
|
||||
" --> notone : rx %d tx:%d\n"
|
||||
" --> bc_hold: %d\n",
|
||||
help->ast->name,
|
||||
@@ -786,7 +791,11 @@ static void print_bc_info (int fd, struct chan_list* help, struct misdn_bchannel
|
||||
bc->active,
|
||||
bc_state2str(bc->bc_state),
|
||||
bearer2str(bc->capability),
|
||||
#ifdef MISDN_1_2
|
||||
bc->pipeline,
|
||||
#else
|
||||
bc->ec_enable,
|
||||
#endif
|
||||
|
||||
help->norxtone,help->notxtone,
|
||||
bc->holded
|
||||
@@ -1005,7 +1014,11 @@ static int misdn_toggle_echocancel (int fd, int argc, char *argv[])
|
||||
tmp->toggle_ec=tmp->toggle_ec?0:1;
|
||||
|
||||
if (tmp->toggle_ec) {
|
||||
#ifdef MISDN_1_2
|
||||
update_pipeline_config(tmp->bc);
|
||||
#else
|
||||
update_ec_config(tmp->bc);
|
||||
#endif
|
||||
manager_ec_enable(tmp->bc);
|
||||
} else {
|
||||
manager_ec_disable(tmp->bc);
|
||||
@@ -1404,9 +1417,25 @@ void debug_numplan(int port, int numplan, char *type)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MISDN_1_2
|
||||
static int update_pipeline_config(struct misdn_bchannel *bc)
|
||||
{
|
||||
int ec;
|
||||
|
||||
misdn_cfg_get(bc->port, MISDN_CFG_PIPELINE, bc->pipeline, sizeof(bc->pipeline));
|
||||
|
||||
if (*bc->pipeline)
|
||||
return 0;
|
||||
|
||||
misdn_cfg_get(bc->port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
|
||||
if (ec == 1)
|
||||
snprintf(bc->pipeline, sizeof(bc->pipeline) - 1, "mg2ec");
|
||||
else if (ec > 1)
|
||||
snprintf(bc->pipeline, sizeof(bc->pipeline) - 1, "mg2ec(deftaps=%d)", ec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int update_ec_config(struct misdn_bchannel *bc)
|
||||
{
|
||||
int ec;
|
||||
@@ -1423,7 +1452,7 @@ static int update_ec_config(struct misdn_bchannel *bc)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int read_config(struct chan_list *ch, int orig) {
|
||||
|
||||
@@ -1493,7 +1522,11 @@ static int read_config(struct chan_list *ch, int orig) {
|
||||
|
||||
ast_copy_string (ast->context,ch->context,sizeof(ast->context));
|
||||
|
||||
#ifdef MISDN_1_2
|
||||
update_pipeline_config(bc);
|
||||
#else
|
||||
update_ec_config(bc);
|
||||
#endif
|
||||
|
||||
{
|
||||
int eb3;
|
||||
@@ -1721,9 +1754,15 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout)
|
||||
int bridging;
|
||||
misdn_cfg_get( 0, MISDN_GEN_BRIDGING, &bridging, sizeof(int));
|
||||
if (bridging && ch->other_ch) {
|
||||
#ifdef MISDN_1_2
|
||||
chan_misdn_log(0, port, "Disabling EC (aka Pipeline) on both Sides\n");
|
||||
*ch->bc->pipeline=0;
|
||||
*ch->other_ch->bc->pipeline=0;
|
||||
#else
|
||||
chan_misdn_log(0, port, "Disabling EC on both Sides\n");
|
||||
ch->bc->ec_enable=0;
|
||||
ch->other_ch->bc->ec_enable=0;
|
||||
#endif
|
||||
}
|
||||
|
||||
r=misdn_lib_send_event( newbc, EVENT_SETUP );
|
||||
@@ -4563,15 +4602,22 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data)
|
||||
|
||||
if (neglect) {
|
||||
chan_misdn_log(1, ch->bc->port, " --> disabled\n");
|
||||
#ifdef MISDN_1_2
|
||||
*ch->bc->pipeline=0;
|
||||
#else
|
||||
ch->bc->ec_enable=0;
|
||||
|
||||
#endif
|
||||
} else {
|
||||
#ifdef MISDN_1_2
|
||||
update_pipeline_config(ch->bc);
|
||||
#else
|
||||
ch->bc->ec_enable=1;
|
||||
ch->bc->orig=ch->orginator;
|
||||
tok++;
|
||||
if (tok) {
|
||||
if (*tok) {
|
||||
ch->bc->ec_deftaps=atoi(tok);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
|
@@ -9,6 +9,9 @@ CFLAGS = -pipe -c -Wall -ggdb
|
||||
ifeq ($(shell uname -m),x86_64)
|
||||
CFLAGS += -fPIC
|
||||
endif
|
||||
ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/mISDNdsp.h),)
|
||||
CFLAGS+=-DMISDN_1_2
|
||||
endif
|
||||
SOURCES = isdn_lib.c isdn_msg_parser.c
|
||||
OBJDIR = .
|
||||
OBJS = isdn_lib.o isdn_msg_parser.o fac.o
|
||||
|
@@ -52,7 +52,9 @@ enum misdn_cfg_elements {
|
||||
MISDN_CFG_EARLY_BCONNECT, /* int (bool) */
|
||||
MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */
|
||||
MISDN_CFG_ECHOCANCEL, /* int */
|
||||
MISDN_CFG_ECHOCANCELWHENBRIDGED, /* int (bool) */
|
||||
#ifdef MISDN_1_2
|
||||
MISDN_CFG_PIPELINE, /* char[] */
|
||||
#endif
|
||||
MISDN_CFG_NEED_MORE_INFOS, /* bool */
|
||||
MISDN_CFG_NTTIMEOUT, /* bool */
|
||||
MISDN_CFG_JITTERBUFFER, /* int */
|
||||
|
@@ -574,12 +574,15 @@ void empty_bc(struct misdn_bchannel *bc)
|
||||
|
||||
bc->early_bconnect = 1;
|
||||
|
||||
#ifdef MISDN_1_2
|
||||
*bc->pipeline = 0;
|
||||
#else
|
||||
bc->ec_enable = 0;
|
||||
bc->ec_deftaps = 128;
|
||||
bc->ec_whenbridged = 0;
|
||||
|
||||
#ifdef EC_TRAIN
|
||||
bc->ec_training = 1;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bc->orig=0;
|
||||
@@ -4240,16 +4243,21 @@ void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone)
|
||||
|
||||
void manager_ec_enable(struct misdn_bchannel *bc)
|
||||
{
|
||||
int ec_arr[2];
|
||||
|
||||
struct misdn_stack *stack=get_stack_by_bc(bc);
|
||||
|
||||
cb_log(4, stack?stack->port:0,"ec_enable\n");
|
||||
|
||||
if (!misdn_cap_is_speech(bc->capability)) {
|
||||
cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
|
||||
return;
|
||||
} else {
|
||||
|
||||
#ifdef MISDN_1_2
|
||||
if (*bc->pipeline) {
|
||||
cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline);
|
||||
manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1);
|
||||
}
|
||||
#else
|
||||
int ec_arr[2];
|
||||
|
||||
if (bc->ec_enable) {
|
||||
cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d training:%d\n",bc->ec_deftaps, bc->ec_training);
|
||||
@@ -4276,6 +4284,8 @@ void manager_ec_enable(struct misdn_bchannel *bc)
|
||||
|
||||
manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4291,10 +4301,14 @@ void manager_ec_disable(struct misdn_bchannel *bc)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MISDN_1_2
|
||||
manager_ph_control_block(bc, PIPELINE_CFG, "", 0);
|
||||
#else
|
||||
if ( ! bc->ec_enable) {
|
||||
cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
|
||||
manager_ph_control(bc, ECHOCAN_OFF, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
struct misdn_stack* get_misdn_stack() {
|
||||
|
@@ -354,10 +354,13 @@ struct misdn_bchannel {
|
||||
|
||||
/** list stuf **/
|
||||
|
||||
#ifdef MISDN_1_2
|
||||
char pipeline[128];
|
||||
#else
|
||||
int ec_enable;
|
||||
int ec_deftaps;
|
||||
int ec_whenbridged;
|
||||
int ec_training;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_BEROEC
|
||||
beroec_t *ec;
|
||||
|
@@ -113,6 +113,9 @@ static const struct misdn_cfg_spec port_spec[] = {
|
||||
{ "early_bconnect", MISDN_CFG_EARLY_BCONNECT, MISDN_CTYPE_BOOL, "yes", NONE },
|
||||
{ "incoming_early_audio", MISDN_CFG_INCOMING_EARLY_AUDIO, MISDN_CTYPE_BOOL, "no", NONE },
|
||||
{ "echocancel", MISDN_CFG_ECHOCANCEL, MISDN_CTYPE_BOOLINT, "0", 128 },
|
||||
#ifdef MISDN_1_2
|
||||
{ "pipeline", MISDN_CFG_PIPELINE, MISDN_CTYPE_STR, NO_DEFAULT, NONE },
|
||||
#endif
|
||||
{ "need_more_infos", MISDN_CFG_NEED_MORE_INFOS, MISDN_CTYPE_BOOL, "0", NONE },
|
||||
{ "nttimeout", MISDN_CFG_NTTIMEOUT, MISDN_CTYPE_BOOL, "no", NONE },
|
||||
{ "jitterbuffer", MISDN_CFG_JITTERBUFFER, MISDN_CTYPE_INT, "4000", NONE },
|
||||
|
Reference in New Issue
Block a user