FS-11017: [mod_conference] Add moh controls to conference #resolve

This commit is contained in:
Anthony Minessale 2018-03-08 15:23:20 -06:00 committed by Muteesa Fred
parent ada117fb73
commit b048830414
5 changed files with 61 additions and 4 deletions

View File

@ -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", "<member_id> <x>:<y>:<z>"},
{"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", "<file_path> [async|<member_id> [nomux]]"},
{"moh", (void_fn_t) & conference_api_sub_moh, CONF_API_SUB_ARGS_SPLIT, "moh", "<file_path>|toggle|[on|off]"},
{"pause_play", (void_fn_t) & conference_api_sub_pause_play, CONF_API_SUB_ARGS_SPLIT, "pause", "[<member_id>]"},
{"play_status", (void_fn_t) & conference_api_sub_play_status, CONF_API_SUB_ARGS_SPLIT, "play_status", "[<member_id>]"},
{"file_seek", (void_fn_t) & conference_api_sub_file_seek, CONF_API_SUB_ARGS_SPLIT, "file_seek", "[+-]<val> [<member_id>]"},
@ -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;

View File

@ -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)

View File

@ -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)) {

View File

@ -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);
}
}

View File

@ -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);