[Freeswitch-svn] [commit] r3351 - freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference
Freeswitch SVN
knhor at freeswitch.org
Mon Nov 13 20:36:51 EST 2006
Author: knhor
Date: Mon Nov 13 20:36:51 2006
New Revision: 3351
Modified:
freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
rescope the default caller control digits table.
use pointers to the default caller control actions instead of casting to/from int when passing through switch_ivr_digit_stream_parser_xxx
Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c Mon Nov 13 20:36:51 2006
@@ -72,6 +72,26 @@
CALLER_CONTROL_HANGUP,
} caller_control_t;
+static struct _caller_control_actions_struct {
+ char *key;
+ char *default_digits;
+ caller_control_t action;
+} caller_control_actions[] = {
+ {"mute", "0", CALLER_CONTROL_MUTE},
+ {"deaf mute", "*", CALLER_CONTROL_DEAF_MUTE},
+ {"energy up", "9", CALLER_CONTROL_ENERGY_UP},
+ {"energy equ", "8", CALLER_CONTROL_ENERGY_EQU_CONFERENCE},
+ {"energy dn", "7", CALLER_CONTROL_ENERGEY_DN},
+ {"vol talk up", "3", CALLER_CONTROL_VOL_TALK_UP},
+ {"vol talk zero", "2", CALLER_CONTROL_VOL_TALK_ZERO},
+ {"vol talk dn", "1", CALLER_CONTROL_VOL_TALK_DN},
+ {"vol listen up", "6", CALLER_CONTROL_VOL_LISTEN_UP},
+ {"vol listen zero", "5", CALLER_CONTROL_VOL_LISTEN_ZERO},
+ {"vol listen dn", "4", CALLER_CONTROL_VOL_LISTEN_DN},
+ {"hangup", "#", CALLER_CONTROL_HANGUP},
+};
+#define CALLER_CONTROL_ACTIONS_QTY (sizeof(caller_control_actions)/sizeof(caller_control_actions[0]))
+
/* Global Values */
static struct {
switch_memory_pool_t *conference_pool;
@@ -1019,46 +1039,50 @@
if(member->conference->dtmf_parser != NULL) {
for (digit = dtmf; *digit; digit++) {
- switch((int)switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, *digit)) {
- case CALLER_CONTROL_NOEVENT:
- // the digit string collected so far has not been recognized
+ int *action = (int *)switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, *digit);
+
+ if (action != NULL) {
+ switch(*action) {
+ case CALLER_CONTROL_NOEVENT:
+ // the digit string collected so far has not been recognized
+ break;
+ case CALLER_CONTROL_MUTE:
+ conference_loop_fn_mute_toggle(member);
+ break;
+ case CALLER_CONTROL_DEAF_MUTE:
+ conference_loop_fn_deafmute_toggle(member);
+ break;
+ case CALLER_CONTROL_ENERGY_UP:
+ conference_loop_fn_energy_up(member);
+ break;
+ case CALLER_CONTROL_ENERGY_EQU_CONFERENCE:
+ conference_loop_fn_energy_equ_conference(member);
+ break;
+ case CALLER_CONTROL_ENERGEY_DN:
+ conference_loop_fn_energy_dn(member);
+ break;
+ case CALLER_CONTROL_VOL_TALK_UP:
+ conference_loop_fn_volume_talk_up(member);
+ break;
+ case CALLER_CONTROL_VOL_TALK_ZERO:
+ conference_loop_fn_volume_talk_zero(member);
+ break;
+ case CALLER_CONTROL_VOL_TALK_DN:
+ conference_loop_fn_volume_talk_dn(member);
+ break;
+ case CALLER_CONTROL_VOL_LISTEN_UP:
+ conference_loop_fn_volume_listen_up(member);
+ break;
+ case CALLER_CONTROL_VOL_LISTEN_ZERO:
+ conference_loop_fn_volume_listen_zero(member);
+ break;
+ case CALLER_CONTROL_VOL_LISTEN_DN:
+ conference_loop_fn_volume_listen_dn(member);
+ break;
+ case CALLER_CONTROL_HANGUP:
+ conference_loop_fn_hangup(member);
break;
- case CALLER_CONTROL_MUTE:
- conference_loop_fn_mute_toggle(member);
- break;
- case CALLER_CONTROL_DEAF_MUTE:
- conference_loop_fn_deafmute_toggle(member);
- break;
- case CALLER_CONTROL_ENERGY_UP:
- conference_loop_fn_energy_up(member);
- break;
- case CALLER_CONTROL_ENERGY_EQU_CONFERENCE:
- conference_loop_fn_energy_equ_conference(member);
- break;
- case CALLER_CONTROL_ENERGEY_DN:
- conference_loop_fn_energy_dn(member);
- break;
- case CALLER_CONTROL_VOL_TALK_UP:
- conference_loop_fn_volume_talk_up(member);
- break;
- case CALLER_CONTROL_VOL_TALK_ZERO:
- conference_loop_fn_volume_talk_zero(member);
- break;
- case CALLER_CONTROL_VOL_TALK_DN:
- conference_loop_fn_volume_talk_dn(member);
- break;
- case CALLER_CONTROL_VOL_LISTEN_UP:
- conference_loop_fn_volume_listen_up(member);
- break;
- case CALLER_CONTROL_VOL_LISTEN_ZERO:
- conference_loop_fn_volume_listen_zero(member);
- break;
- case CALLER_CONTROL_VOL_LISTEN_DN:
- conference_loop_fn_volume_listen_dn(member);
- break;
- case CALLER_CONTROL_HANGUP:
- conference_loop_fn_hangup(member);
- break;
+ }
}
}
}
@@ -3447,25 +3471,6 @@
conference->interval = interval;
if(switch_ivr_digit_stream_parser_new(conference->pool,&conference->dtmf_parser) == SWITCH_STATUS_SUCCESS) {
- struct _ccds {
- char *key;
- char *digits;
- caller_control_t action;
- } ccds[] = {
- {"mute", "0", CALLER_CONTROL_MUTE},
- {"deaf mute", "*", CALLER_CONTROL_DEAF_MUTE},
- {"energy up", "9", CALLER_CONTROL_ENERGY_UP},
- {"energy equ", "8", CALLER_CONTROL_ENERGY_EQU_CONFERENCE},
- {"energy dn", "7", CALLER_CONTROL_ENERGEY_DN},
- {"vol talk up", "3", CALLER_CONTROL_VOL_TALK_UP},
- {"vol talk zero", "2", CALLER_CONTROL_VOL_TALK_ZERO},
- {"vol talk dn", "1", CALLER_CONTROL_VOL_TALK_DN},
- {"vol listen up", "6", CALLER_CONTROL_VOL_LISTEN_UP},
- {"vol listen zero", "5", CALLER_CONTROL_VOL_LISTEN_ZERO},
- {"vol listen dn", "4", CALLER_CONTROL_VOL_LISTEN_DN},
- {"hangup", "#", CALLER_CONTROL_HANGUP},
- };
- int ccds_qty = sizeof(ccds)/sizeof(ccds[0]);
int i;
// count the number of caller control definitons in the profile
@@ -3474,8 +3479,10 @@
}
// map in the default control handler strings only if the profile has no caller control definitions
if (i == 0) {
- for(i=0,status=SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i<ccds_qty; i++) {
- status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,ccds[i].digits,(void *)ccds[i].action);
+ for(i=0,status=SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i<CALLER_CONTROL_ACTIONS_QTY; i++) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Installing default caller control action name '%s' bound to '%s' digits.\n",
+ caller_control_actions[i].key,caller_control_actions[i].default_digits);
+ status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,caller_control_actions[i].default_digits,(void *)&(caller_control_actions[i].action));
}
}
@@ -3488,9 +3495,10 @@
// scan through all of the valid actions, and if found,
// set the new caller control action digit string, then
// stop scanning the table, and go to the next xml kvp.
- for(i=0,status=SWITCH_STATUS_NOOP; i<ccds_qty && status == SWITCH_STATUS_NOOP; i++) {
- if(strcasecmp(ccds[i].key,key) == 0) {
- status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,val,(void *)ccds[i].action);
+ for(i=0,status=SWITCH_STATUS_NOOP; i<CALLER_CONTROL_ACTIONS_QTY && status == SWITCH_STATUS_NOOP; i++) {
+ if(strcasecmp(caller_control_actions[i].key,key) == 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Installing caller control action name '%s' bound to '%s' digits.\n",key,val);
+ status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,val,(void *)&caller_control_actions[i].action);
}
}
if(status == SWITCH_STATUS_NOOP) {
More information about the Freeswitch-svn
mailing list