From b04883041427316ceb5f861914e4ce53ebd3492f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 8 Mar 2018 15:23:20 -0600 Subject: [PATCH] FS-11017: [mod_conference] Add moh controls to conference #resolve --- .../mod_conference/conference_api.c | 36 +++++++++++++++++++ .../mod_conference/conference_loop.c | 6 ++++ .../mod_conference/conference_member.c | 3 +- .../mod_conference/mod_conference.c | 14 ++++++-- .../mod_conference/mod_conference.h | 6 +++- 5 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/mod/applications/mod_conference/conference_api.c b/src/mod/applications/mod_conference/conference_api.c index d8341361b2..0a3aacde3e 100644 --- a/src/mod/applications/mod_conference/conference_api.c +++ b/src/mod/applications/mod_conference/conference_api.c @@ -59,6 +59,7 @@ api_command_t conference_api_sub_commands[] = { {"position", (void_fn_t) & conference_api_sub_position, CONF_API_SUB_MEMBER_TARGET, "position", " ::"}, {"auto-3d-position", (void_fn_t) & conference_api_sub_auto_position, CONF_API_SUB_ARGS_SPLIT, "auto-3d-position", "[on|off]"}, {"play", (void_fn_t) & conference_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "play", " [async| [nomux]]"}, + {"moh", (void_fn_t) & conference_api_sub_moh, CONF_API_SUB_ARGS_SPLIT, "moh", "|toggle|[on|off]"}, {"pause_play", (void_fn_t) & conference_api_sub_pause_play, CONF_API_SUB_ARGS_SPLIT, "pause", "[]"}, {"play_status", (void_fn_t) & conference_api_sub_play_status, CONF_API_SUB_ARGS_SPLIT, "play_status", "[]"}, {"file_seek", (void_fn_t) & conference_api_sub_file_seek, CONF_API_SUB_ARGS_SPLIT, "file_seek", "[+-] []"}, @@ -2471,6 +2472,41 @@ switch_status_t conference_api_sub_file_seek(conference_obj_t *conference, switc return SWITCH_STATUS_GENERR; } +switch_status_t conference_api_set_moh(conference_obj_t *conference, const char *what) +{ + + if (!strcasecmp(what, "toggle")) { + if (conference_utils_test_flag(conference, CFLAG_NO_MOH)) { + conference_utils_clear_flag(conference, CFLAG_NO_MOH); + } else { + conference_utils_set_flag(conference, CFLAG_NO_MOH); + } + } else if (!strcasecmp(what, "on")) { + conference_utils_clear_flag(conference, CFLAG_NO_MOH); + } else if (!strcasecmp(what, "off")) { + conference_utils_set_flag(conference, CFLAG_NO_MOH); + } else if (!strcasecmp(what, "reset")) { + conference->tmp_moh_sound = NULL; + } else { + conference->tmp_moh_sound = switch_core_strdup(conference->pool, what); + } + + if (conference_utils_test_flag(conference, CFLAG_NO_MOH) || conference->tmp_moh_sound) { + conference_file_stop(conference, FILE_STOP_ASYNC); + } + + return SWITCH_STATUS_SUCCESS; +} + + +switch_status_t conference_api_sub_moh(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) +{ + + conference_api_set_moh(conference, argv[2]); + + return SWITCH_STATUS_SUCCESS; +} + switch_status_t conference_api_sub_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) { int ret_status = SWITCH_STATUS_GENERR; diff --git a/src/mod/applications/mod_conference/conference_loop.c b/src/mod/applications/mod_conference/conference_loop.c index 5c6947252b..ef39461ff7 100644 --- a/src/mod/applications/mod_conference/conference_loop.c +++ b/src/mod/applications/mod_conference/conference_loop.c @@ -45,6 +45,7 @@ struct _mapping control_mappings[] = { {"mute", conference_loop_mute_toggle}, {"mute on", conference_loop_mute_on}, {"mute off", conference_loop_mute_off}, + {"moh toggle", conference_loop_moh_toggle}, {"vmute", conference_loop_vmute_toggle}, {"vmute on", conference_loop_vmute_on}, {"vmute off", conference_loop_vmute_off}, @@ -167,6 +168,11 @@ void conference_loop_conference_video_vmute_snapoff(conference_member_t *member, conference_video_vmute_snap(member, SWITCH_TRUE); } +void conference_loop_moh_toggle(conference_member_t *member, caller_control_action_t *action) +{ + conference_api_set_moh(member->conference, "toggle"); +} + void conference_loop_vmute_toggle(conference_member_t *member, caller_control_action_t *action) { if (member == NULL) diff --git a/src/mod/applications/mod_conference/conference_member.c b/src/mod/applications/mod_conference/conference_member.c index 9d3c6d06c8..2ee3af83b8 100644 --- a/src/mod/applications/mod_conference/conference_member.c +++ b/src/mod/applications/mod_conference/conference_member.c @@ -860,10 +860,11 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m } if (conference->count > 1) { - if ((conference->moh_sound && !conference_utils_test_flag(conference, CFLAG_WAIT_MOD)) || + if (((conference->moh_sound || conference->tmp_moh_sound) && !conference_utils_test_flag(conference, CFLAG_WAIT_MOD)) || (conference_utils_test_flag(conference, CFLAG_WAIT_MOD) && !switch_true(switch_channel_get_variable(channel, "conference_permanent_wait_mod_moh")))) { /* stop MoH if any */ conference_file_stop(conference, FILE_STOP_ASYNC); + conference_utils_clear_flag(conference, CFLAG_NO_MOH); } if (!switch_channel_test_app_flag_key("conference_silent", channel, CONF_SILENT_REQ)) { diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 7ca2215e62..eed989dbc5 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -372,15 +372,25 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob conference_member_set_floor_holder(conference, NULL, floor_holder); } + if (conference_utils_test_flag(conference, CFLAG_NO_MOH)) { + nomoh++; + } + if (conference->moh_wait > 0) { conference->moh_wait--; } else { + char *moh_sound = conference->tmp_moh_sound; + + if (!moh_sound) { + moh_sound = conference->moh_sound; + } + if (conference->perpetual_sound && !conference->async_fnode) { moh_status = conference_file_play(conference, conference->perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1); - } else if (conference->moh_sound && ((nomoh == 0 && conference->count == 1) + } else if (moh_sound && ((nomoh == 0 && conference->count == 1) || conference_utils_test_flag(conference, CFLAG_WAIT_MOD)) && !conference->async_fnode && !conference->fnode) { - moh_status = conference_file_play(conference, conference->moh_sound, CONF_DEFAULT_LEADIN, NULL, 1); + moh_status = conference_file_play(conference, moh_sound, CONF_DEFAULT_LEADIN, NULL, 1); } } diff --git a/src/mod/applications/mod_conference/mod_conference.h b/src/mod/applications/mod_conference/mod_conference.h index 45c09d52dc..5b174a58ed 100644 --- a/src/mod/applications/mod_conference/mod_conference.h +++ b/src/mod/applications/mod_conference/mod_conference.h @@ -258,6 +258,7 @@ typedef enum { CFLAG_PERSONAL_CANVAS, CFLAG_REFRESH_LAYOUT, CFLAG_VIDEO_MUTE_EXIT_CANVAS, + CFLAG_NO_MOH, ///////////////////////////////// CFLAG_MAX } conference_flag_t; @@ -609,6 +610,7 @@ typedef struct conference_obj { char *alone_sound; char *perpetual_sound; char *moh_sound; + char *tmp_moh_sound; char *muted_sound; char *mute_detect_sound; char *unmuted_sound; @@ -1191,6 +1193,7 @@ switch_status_t conference_api_sub_dtmf(conference_member_t *member, switch_stre switch_status_t conference_api_sub_pause_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); switch_status_t conference_api_sub_play_status(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); switch_status_t conference_api_sub_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); +switch_status_t conference_api_sub_moh(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); switch_status_t conference_api_sub_say(conference_obj_t *conference, switch_stream_handle_t *stream, const char *text); switch_status_t conference_api_sub_dial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); switch_status_t conference_api_sub_bgdial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); @@ -1249,7 +1252,7 @@ switch_status_t conference_api_sub_vid_personal(conference_obj_t *conference, sw switch_status_t conference_api_dispatch(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv, const char *cmdline, int argn); switch_status_t conference_api_sub_syntax(char **syntax); switch_status_t conference_api_main_real(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream); - +switch_status_t conference_api_set_moh(conference_obj_t *conference, const char *what); void conference_loop_mute_on(conference_member_t *member, caller_control_action_t *action); void conference_loop_mute_toggle(conference_member_t *member, caller_control_action_t *action); @@ -1273,6 +1276,7 @@ void conference_loop_conference_video_vmute_snap(conference_member_t *member, ca void conference_loop_conference_video_vmute_snapoff(conference_member_t *member, caller_control_action_t *action); void conference_loop_vmute_toggle(conference_member_t *member, caller_control_action_t *action); void conference_loop_vmute_on(conference_member_t *member, caller_control_action_t *action); +void conference_loop_moh_toggle(conference_member_t *member, caller_control_action_t *action); void conference_loop_deafmute_toggle(conference_member_t *member, caller_control_action_t *action); void conference_loop_hangup(conference_member_t *member, caller_control_action_t *action); void conference_loop_transfer(conference_member_t *member, caller_control_action_t *action);