From ffe5fde0b533ff4df49f51967c945b2545c92e2f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 29 Apr 2009 17:07:51 +0000 Subject: [PATCH] dist-dtmf flag in conference git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13191 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_conference/mod_conference.c | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index df01681b59..5d2bd7d512 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -144,7 +144,8 @@ typedef enum { MFLAG_TALKING = (1 << 11), MFLAG_RESTART = (1 << 12), MFLAG_MINTWO = (1 << 13), - MFLAG_MUTE_DETECT = (1 << 14) + MFLAG_MUTE_DETECT = (1 << 14), + MFLAG_DIST_DTMF = (1 << 15) } member_flag_t; typedef enum { @@ -153,7 +154,7 @@ typedef enum { CFLAG_ENFORCE_MIN = (1 << 2), CFLAG_DESTRUCT = (1 << 3), CFLAG_LOCKED = (1 << 4), - CFLAG_ANSWERED = (1 << 5) + CFLAG_ANSWERED = (1 << 5), } conf_flag_t; typedef enum { @@ -358,6 +359,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr static void conference_loop_output(conference_member_t *member); static uint32_t conference_stop_file(conference_obj_t *conference, file_stop_t stop); static switch_status_t conference_play_file(conference_obj_t *conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async); +static void conference_send_all_dtmf(conference_obj_t *conference, const char *dtmf); static switch_status_t conference_say(conference_obj_t *conference, const char *text, uint32_t leadin); static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim); static conference_obj_t *conference_find(char *name); @@ -1999,11 +2001,14 @@ static void conference_loop_output(conference_member_t *member) if (switch_channel_has_dtmf(channel)) { switch_channel_dequeue_dtmf_string(channel, dtmf, sizeof(dtmf)); - if (member->conference->dtmf_parser != NULL) { - - for (digit = dtmf; *digit && caller_action == NULL; digit++) { - caller_action = (caller_control_action_t *) - switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, *digit); + if (switch_test_flag(member, MFLAG_DIST_DTMF)) { + conference_send_all_dtmf(member->conference, dtmf); + } else { + if (member->conference->dtmf_parser != NULL) { + for (digit = dtmf; *digit && caller_action == NULL; digit++) { + caller_action = (caller_control_action_t *) + switch_ivr_digit_stream_parser_feed(member->conference->dtmf_parser, member->digit_stream, *digit); + } } } /* otherwise, clock the parser so that it can handle digit timeout detection */ @@ -2414,6 +2419,27 @@ static uint32_t conference_member_stop_file(conference_member_t *member, file_st return count; } +static void conference_send_all_dtmf(conference_obj_t *conference, const char *dtmf) +{ + conference_member_t *imember; + + switch_mutex_lock(conference->mutex); + switch_mutex_lock(conference->member_mutex); + + for (imember = conference->members; imember; imember = imember->next) { + if (imember->session) { + const char *p; + for (p = dtmf; p && *p; p++) { + switch_dtmf_t dtmf = { *p, SWITCH_DEFAULT_DTMF_DURATION}; + switch_channel_queue_dtmf(switch_core_session_get_channel(imember->session), &dtmf); + } + } + } + + switch_mutex_unlock(conference->member_mutex); + switch_mutex_unlock(conference->mutex); +} + /* Play a file in the conference room */ static switch_status_t conference_play_file(conference_obj_t *conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async) { @@ -4431,6 +4457,8 @@ static void set_mflags(char *flags, member_flag_t *f) *f |= MFLAG_WASTE_BANDWIDTH; } else if (!strcasecmp(argv[i], "mute-detect")) { *f |= MFLAG_MUTE_DETECT; + } else if (!strcasecmp(argv[i], "dist-dtmf")) { + *f |= MFLAG_DIST_DTMF; } else if (!strcasecmp(argv[i], "endconf")) { *f |= MFLAG_ENDCONF; } else if (!strcasecmp(argv[i], "mintwo")) {