diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 2b439f157a..9a67cd5e4e 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -55,6 +55,18 @@ SWITCH_BEGIN_EXTERN_C #define switch_is_file_path(file) (file && ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))) #endif + +static inline switch_bool_t switch_is_moh(const char *s) +{ + if (!strcasecmp(s, "silence") || !strcasecmp(s, "indicate_hold")) { + return SWITCH_FALSE; + } + return SWITCH_TRUE; +} + + + + SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size_t ilen, unsigned char *out, switch_size_t olen); SWITCH_DECLARE(switch_size_t) switch_b64_decode(char *in, char *out, switch_size_t olen); SWITCH_DECLARE(char *) switch_amp_encode(char *s, char *buf, switch_size_t len); @@ -73,6 +85,7 @@ static inline switch_bool_t switch_is_digit_string(const char *s) { SWITCH_DECLARE(switch_size_t) switch_fd_read_line(int fd, char *buf, switch_size_t len); + /*! \brief Evaluate the truthfullness of a string expression \param expr a string expression diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index b93ac107e1..54d2854061 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1852,7 +1852,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * stream = tech_pvt->profile->hold_music; } - if (stream && strcasecmp(stream, "silence")) { + if (stream && switch_is_moh(stream)) { if (!strcasecmp(stream, "indicate_hold")) { switch_channel_set_flag(tech_pvt->channel, CF_SUSPEND); switch_channel_set_flag(tech_pvt->channel, CF_HOLD); diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 0f0315abef..4b8257d880 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -321,7 +321,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE); } - if (stream) { + if (stream && switch_is_moh(stream)) { if ((b_session = switch_core_session_locate(b_uuid))) { switch_channel_t *b_channel = switch_core_session_get_channel(b_session); switch_ivr_broadcast(b_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP); @@ -334,10 +334,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se } } for (x = 0; x < loops || loops < 0; x++) { + switch_time_t b4, aftr; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n", switch_channel_get_name(channel), app_name, app_arg); + b4 = switch_timestamp_now(); switch_core_session_exec(session, application_interface, app_arg); - if (!switch_channel_ready(channel) || switch_channel_test_flag(channel, CF_STOP_BROADCAST)) { + aftr = switch_timestamp_now(); + if (!switch_channel_ready(channel) || switch_channel_test_flag(channel, CF_STOP_BROADCAST) || aftr - b4 < 500000) { break; } }