enable DTMF monitoring when DYNAMIC_FEATURES are specified for a brige (issue #5153)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6541 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming 2005-09-07 21:36:30 +00:00
parent 1e854ea773
commit 9a4c8f8c9c
1 changed files with 53 additions and 29 deletions

View File

@ -898,8 +898,9 @@ static struct ast_call_feature *find_feature(char *name)
struct ast_call_feature *tmp; struct ast_call_feature *tmp;
AST_LIST_LOCK(&feature_list); AST_LIST_LOCK(&feature_list);
AST_LIST_TRAVERSE(&feature_list,tmp,feature_entry) { AST_LIST_TRAVERSE(&feature_list, tmp, feature_entry) {
if (!strcasecmp(tmp->sname,name)) break; if (!strcasecmp(tmp->sname, name))
break;
} }
AST_LIST_UNLOCK(&feature_list); AST_LIST_UNLOCK(&feature_list);
@ -974,6 +975,7 @@ static int ast_feature_interpret(struct ast_channel *chan, struct ast_channel *p
else else
ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL); ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL);
ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags); ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags);
for (x=0; x < FEATURES_COUNT; x++) { for (x=0; x < FEATURES_COUNT; x++) {
if ((ast_test_flag(&features, builtin_features[x].feature_mask)) && if ((ast_test_flag(&features, builtin_features[x].feature_mask)) &&
!ast_strlen_zero(builtin_features[x].exten)) { !ast_strlen_zero(builtin_features[x].exten)) {
@ -983,31 +985,23 @@ static int ast_feature_interpret(struct ast_channel *chan, struct ast_channel *p
break; break;
} else if (!strncmp(builtin_features[x].exten, code, strlen(code))) { } else if (!strncmp(builtin_features[x].exten, code, strlen(code))) {
if (res == FEATURE_RETURN_PASSDIGITS) if (res == FEATURE_RETURN_PASSDIGITS)
res = FEATURE_RETURN_STOREDIGITS; res = FEATURE_RETURN_STOREDIGITS;
} }
} }
} }
if (dynamic_features) { if (dynamic_features && !ast_strlen_zero(dynamic_features)) {
char *tmp=strdup(dynamic_features); char *tmp = ast_strdupa(dynamic_features);
char *tok; char *tok;
char *begin=tmp;
if (!tmp)
if (!tmp) {
ast_log(LOG_ERROR,"strdup failed");
return res; return res;
}
while ( (tok=strsep(&tmp,"#")) != NULL) { while ((tok = strsep(&tmp, "#")) != NULL) {
AST_LIST_LOCK(&feature_list); feature = find_feature(tok);
AST_LIST_TRAVERSE(&feature_list, feature, feature_entry) {
if ( ! strcasecmp(tok,feature->sname))
break;
}
AST_LIST_UNLOCK(&feature_list);
if ( feature ) { if (feature) {
/* Feature is up for consideration */ /* Feature is up for consideration */
if (!strcmp(feature->exten, code)) { if (!strcmp(feature->exten, code)) {
if (option_verbose > 2) if (option_verbose > 2)
@ -1019,28 +1013,53 @@ static int ast_feature_interpret(struct ast_channel *chan, struct ast_channel *p
} }
} }
} }
free(begin);
} }
return res; return res;
} }
static void set_config_flags(struct ast_bridge_config *config) static void set_config_flags(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config)
{ {
int x; int x;
ast_clear_flag(config, AST_FLAGS_ALL); ast_clear_flag(config, AST_FLAGS_ALL);
for (x = 0; x < FEATURES_COUNT; x++) { for (x = 0; x < FEATURES_COUNT; x++) {
if (ast_test_flag(&(config->features_caller), builtin_features[x].feature_mask)) { if (ast_test_flag(builtin_features + x, AST_FEATURE_FLAG_NEEDSDTMF)) {
if (ast_test_flag(builtin_features + x, AST_FEATURE_FLAG_NEEDSDTMF)) if (ast_test_flag(&(config->features_caller), builtin_features[x].feature_mask))
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0); ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
}
if (ast_test_flag(&(config->features_callee), builtin_features[x].feature_mask)) { if (ast_test_flag(&(config->features_callee), builtin_features[x].feature_mask))
if (ast_test_flag(builtin_features + x, AST_FEATURE_FLAG_NEEDSDTMF))
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1); ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
} }
} }
if (chan && peer && !(ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_0) && ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_1))) {
char *dynamic_features;
dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES");
if (dynamic_features) {
char *tmp = ast_strdupa(dynamic_features);
char *tok;
struct ast_call_feature *feature;
if (!tmp) {
return;
}
/* while we have a feature */
while (NULL != (tok = strsep(&tmp, "#"))) {
if ((feature = find_feature(tok))) {
if (ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLER))
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLEE))
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
}
}
}
}
}
} }
@ -1257,7 +1276,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
allowdisconnect_out = ast_test_flag(&(config->features_caller), AST_FEATURE_DISCONNECT); allowdisconnect_out = ast_test_flag(&(config->features_caller), AST_FEATURE_DISCONNECT);
allowredirect_in = ast_test_flag(&(config->features_callee), AST_FEATURE_REDIRECT); allowredirect_in = ast_test_flag(&(config->features_callee), AST_FEATURE_REDIRECT);
allowredirect_out = ast_test_flag(&(config->features_caller), AST_FEATURE_REDIRECT); allowredirect_out = ast_test_flag(&(config->features_caller), AST_FEATURE_REDIRECT);
set_config_flags(config); set_config_flags(chan, peer, config);
config->firstpass = 1; config->firstpass = 1;
/* Answer if need be */ /* Answer if need be */
@ -2038,8 +2057,13 @@ static int load_config(void)
if (!strcasecmp(party,"caller")) if (!strcasecmp(party,"caller"))
ast_set_flag(feature,AST_FEATURE_FLAG_CALLER); ast_set_flag(feature,AST_FEATURE_FLAG_CALLER);
else else if (!strcasecmp(party, "callee"))
ast_set_flag(feature,AST_FEATURE_FLAG_CALLEE); ast_set_flag(feature,AST_FEATURE_FLAG_CALLEE);
else {
ast_log(LOG_NOTICE, "Invalid party specification for feature '%s', must be caller, or callee\n", var->name);
var = var->next;
continue;
}
ast_register_feature(feature); ast_register_feature(feature);