Merged revisions 59202 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r59202 | nadi | 2007-03-26 17:25:53 +0200 (Mo, 26 Mär 2007) | 4 lines

* mISDN >= 1.2 provides a dsp pipeline for i.e. echo cancellation modules, make chan_misdn use it.
* add a check for linux/mISDNdsp.h to configure.ac and update the autogenerated files: 'configure', 'autoconfig.h.in'
  (the 'configure' script was not in sync with the latest configure.ac, so the diff is a bit bigger than expected).

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@59203 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Nadi Sarrar
2007-03-26 15:59:56 +00:00
parent 133f26f977
commit 24d8595d00
9 changed files with 280 additions and 42 deletions

View File

@@ -351,7 +351,11 @@ int add_out_calls(int port);
int add_in_calls(int port);
#ifdef MISDN_1_2
static int update_pipeline_config(struct misdn_bchannel *bc);
#else
static int update_ec_config(struct misdn_bchannel *bc);
#endif
@@ -1019,7 +1023,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,
@@ -1032,7 +1040,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),
bc->ec_enable,
#ifdef MISDN_1_2
bc->pipeline,
#else
bc->ec_enable,
#endif
help->norxtone,help->notxtone,
bc->holded
@@ -1260,7 +1272,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);
@@ -1598,6 +1614,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;
@@ -1611,17 +1646,10 @@ static int update_ec_config(struct misdn_bchannel *bc)
bc->ec_enable=1;
bc->ec_deftaps=ec;
}
#ifdef WITH_ECHOTRAINING
int ectr;
misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
if ( ectr >= 0 ) {
bc->ec_training=ectr;
}
#endif
return 0;
}
#endif
static int read_config(struct chan_list *ch, int orig) {
@@ -1696,7 +1724,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;
@@ -1966,9 +1998,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) {
chan_misdn_log(0, port, "Disabling EC on both Sides\n");
#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 );
@@ -2466,7 +2504,11 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
isdn_lib_update_rxgain(tmp->bc);
tmp->bc->txgain = 0;
isdn_lib_update_txgain(tmp->bc);
#ifdef MISDN_1_2
*tmp->bc->pipeline = 0;
#else
tmp->bc->ec_enable = 0;
#endif
isdn_lib_update_ec(tmp->bc);
isdn_lib_stop_dtmf(tmp->bc);
switch (tmp->faxdetect) {
@@ -4922,16 +4964,22 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data)
case 'c':
keyidx=atoi(++tok);
if (keyidx > misdn_key_vector_size || keyidx < 0 ) {
ast_log(LOG_WARNING, "You entered the keyidx: %d but we have only %d keys\n",keyidx, misdn_key_vector_size );
continue;
char keys[4096];
char *key=NULL, *tmp;
int i;
misdn_cfg_get( 0, MISDN_GEN_CRYPT_KEYS, keys, sizeof(keys));
tmp=keys;
for (i=0; i<keyidx; i++) {
key=strsep(&tmp,",");
}
{
ast_copy_string(ch->bc->crypt_key, misdn_key_vector[keyidx], sizeof(ch->bc->crypt_key));
if (key) {
ast_copy_string(ch->bc->crypt_key, key, sizeof(ch->bc->crypt_key));
}
chan_misdn_log(0, ch->bc->port, "SETOPT: crypt with key:%s\n",misdn_key_vector[keyidx]);
chan_misdn_log(0, ch->bc->port, "SETOPT: crypt with key:%s\n",ch->bc->crypt_key);
break;
case 'e':
@@ -4939,14 +4987,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;

View File

@@ -1,6 +1,10 @@
#
# Makefile for chan_misdn support
#
ifneq ($(wildcard /usr/include/linux/mISDNdsp.h),)
CFLAGS+=-DMISDN_1_2
endif
all:
%.o: %.c

View File

@@ -52,9 +52,8 @@ 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 WITH_ECHOTRAINGING
MISDN_CFG_ECHOTRAINING, /* int (bool) */
#ifdef MISDN_1_2
MISDN_CFG_PIPELINE, /* char[] */
#endif
#ifdef WITH_BEROEC

View File

@@ -578,14 +578,13 @@ static 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
bc->orig=0;
bc->cause=16;
@@ -4028,7 +4027,11 @@ void isdn_lib_update_txgain (struct misdn_bchannel *bc)
void isdn_lib_update_ec (struct misdn_bchannel *bc)
{
#ifdef MISDN_1_2
if (*bc->pipeline)
#else
if (bc->ec_enable)
#endif
manager_ec_enable(bc);
else
manager_ec_disable(bc);
@@ -4207,19 +4210,24 @@ 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);
cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps);
switch (bc->ec_deftaps) {
case 4:
@@ -4239,14 +4247,12 @@ void manager_ec_enable(struct misdn_bchannel *bc)
}
ec_arr[0]=bc->ec_deftaps;
#ifdef EC_TRAIN
ec_arr[1]=bc->ec_training;
#else
ec_arr[1]=0;
#endif
manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr));
}
#endif
}
}
@@ -4262,10 +4268,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() {

View File

@@ -343,10 +343,12 @@ 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;

View File

@@ -235,9 +235,14 @@ static const struct misdn_cfg_spec port_spec[] = {
"\tA value of zero turns echocancellation off.\n"
"\n"
"\tPossible values are: 0,32,64,128,256,yes(=128),no(=0)" },
{ "echocancelwhenbridged", MISDN_CFG_ECHOCANCELWHENBRIDGED, MISDN_CTYPE_BOOL, "no", NONE,
"This disables echocancellation when the call is bridged between\n"
"\tmISDN channels" },
#ifdef MISDN_1_2
{ "pipeline", MISDN_CFG_PIPELINE, MISDN_CTYPE_STR, NO_DEFAULT, NONE,
"Set the configuration string for the mISDN dsp pipeline.\n"
"\n"
"\tExample for enabling the mg2 echo cancellation module with deftaps\n"
"\tset to 128:\n"
"\t\tmg2ec(deftaps=128)" },
#endif
#ifdef WITH_BEROEC
{ "bnechocancel", MISDN_CFG_BNECHOCANCEL, MISDN_CTYPE_BOOLINT, "yes", 64,
"echotail in ms (1-200)\n"},