From 3072573c8414ce8bcdd878932792cbb4695088dc Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Mon, 3 Mar 2014 19:01:28 -0500 Subject: [PATCH 1/6] FS-6296 --resolve mod_rayo: fixed crash on bad request --- src/mod/event_handlers/mod_rayo/rayo_prompt_component.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c b/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c index 654f574728..9cd946fc43 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_prompt_component.c @@ -312,7 +312,7 @@ static iks *prompt_component_handle_input_error(struct rayo_actor *prompt, struc iks_insert_attrib(iq, "from", RAYO_JID(RAYO_COMPONENT(prompt)->parent)); iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid); iks_insert_node(iq, iks_copy_within(error, iks_stack(iq))); - PROMPT_COMPONENT(prompt)->complete = iq; + PROMPT_COMPONENT(prompt)->complete = iks_copy(iq); rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output_jid); break; From 5d6b7936238774411f064b9ec5f3e3f3cfc4731f Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 3 Mar 2014 23:21:58 +0000 Subject: [PATCH 2/6] Fix handling of send_silence_when_idle==0 in switch_ivr_sleep When the channel variable send_silence_when_idle was set to zero, switch_ivr_sleep was calling SWITCH_IVR_VERIFY_SILENCE_DIVISOR on it anyway, causing it to be set to 400. The only way to get the behavior of not sending silence when idle was to unset the variable completely. This corrects the behavior such that setting the value to zero has the same effect as leaving it unset. --- src/switch_ivr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 3090942df5..987796941b 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -166,9 +166,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, switch_goto_status(SWITCH_STATUS_SUCCESS, end); } - var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE); - if (var) { - sval = atoi(var); + if ((var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) + && (sval = atoi(var))) { SWITCH_IVR_VERIFY_SILENCE_DIVISOR(sval); } From 8fe324c4047234523c517199aa1405df6399be1f Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 3 Mar 2014 18:26:44 +0000 Subject: [PATCH 3/6] Preserve value of send_silence_when_idle if possible In commit 55d01d3defed4bfdc74704dbea0da9548a97a979 we set send_silence_when_idle to -1 rather than 400 when SRTP is engaged. But this left no way to enable white noise silence when desired. When SRTP is engaged we can't simply not send RTP because it breaks too many devices. So we need to prevent send_silence_when_idle from being unset or being set to zero. This change allows it to be set to other values so as to feed white noise rather than all zeros into the codec. --- src/switch_rtp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index b6c52c4ae3..fc4b6a6019 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -1773,6 +1773,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session"); switch_channel_t *channel = switch_core_session_get_channel(session); switch_event_t *fsevent = NULL; + const char *var; if (direction >= SWITCH_RTP_CRYPTO_MAX || keylen > SWITCH_RTP_MAX_CRYPTO_LEN) { return SWITCH_STATUS_FALSE; @@ -1794,7 +1795,11 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess memset(policy, 0, sizeof(*policy)); - switch_channel_set_variable(channel, "send_silence_when_idle", "-1"); + /* many devices can't handle gaps in SRTP streams */ + if (!(var = switch_channel_get_variable(channel, "send_silence_when_idle")) + || !(atoi(var))) { + switch_channel_set_variable(channel, "send_silence_when_idle", "-1"); + } switch (crypto_key->type) { case AES_CM_128_HMAC_SHA1_80: From 6f11c1636bb67c1a1986e0facfb07f1a11e54cb1 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 3 Mar 2014 18:33:25 +0000 Subject: [PATCH 4/6] Add force_send_silence_when_idle channel variable If set to true, this prevents us from overriding the value of send_silence_when_idle. When that is unset or set to zero and SRTP is engaged, we typically override the value because many devices can't handle gaps in the SRTP stream. This variable is mostly for testing whether particular devices can handle this behavior. Use at your own risk. --- src/switch_rtp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index fc4b6a6019..7cbfb7089e 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -1796,8 +1796,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess memset(policy, 0, sizeof(*policy)); /* many devices can't handle gaps in SRTP streams */ - if (!(var = switch_channel_get_variable(channel, "send_silence_when_idle")) - || !(atoi(var))) { + if (!((var = switch_channel_get_variable(channel, "force_send_silence_when_idle")) + && switch_true(var)) + && (!(var = switch_channel_get_variable(channel, "send_silence_when_idle")) + || !(atoi(var)))) { switch_channel_set_variable(channel, "send_silence_when_idle", "-1"); } From b6a10585bb53380868f41bc44df8d5f4e26a9564 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Mon, 3 Mar 2014 20:03:22 +0000 Subject: [PATCH 5/6] Avoid repeating ourselves in generating silence We were handling the "send silence but not comfort noise" case in both silence_stream_file_read and switch_generate_sln_silence. This changes the former to rely on the latter. --- src/mod/formats/mod_tone_stream/mod_tone_stream.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/mod/formats/mod_tone_stream/mod_tone_stream.c b/src/mod/formats/mod_tone_stream/mod_tone_stream.c index 2aafff129f..3495d0578f 100644 --- a/src/mod/formats/mod_tone_stream/mod_tone_stream.c +++ b/src/mod/formats/mod_tone_stream/mod_tone_stream.c @@ -93,11 +93,8 @@ static switch_status_t silence_stream_file_read(switch_file_handle_t *handle, vo sh->samples -= *len; } - if (sh->silence) { - switch_generate_sln_silence((int16_t *) data, *len, sh->silence); - } else { - memset(data, 0, *len * 2); - } + switch_generate_sln_silence((int16_t *) data, *len, + sh->silence ? sh->silence : (uint32_t)-1); return SWITCH_STATUS_SUCCESS; } From a7ef0919e7fbd2b387f470b332d3ee80a5ec589e Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 4 Mar 2014 01:51:04 +0000 Subject: [PATCH 6/6] Improve channel variable name to srtp_allow_idle_gaps This was momentarily called force_send_silence_when_idle, but that was non-obvious as you had to set that value to true to be able to not send silence when idle. This name describes the purpose much better. --- src/switch_rtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 7cbfb7089e..acc99466eb 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -1796,7 +1796,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess memset(policy, 0, sizeof(*policy)); /* many devices can't handle gaps in SRTP streams */ - if (!((var = switch_channel_get_variable(channel, "force_send_silence_when_idle")) + if (!((var = switch_channel_get_variable(channel, "srtp_allow_idle_gaps")) && switch_true(var)) && (!(var = switch_channel_get_variable(channel, "send_silence_when_idle")) || !(atoi(var)))) {