]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Preserve value of send_silence_when_idle if possible
authorTravis Cross <tc@traviscross.com>
Mon, 3 Mar 2014 18:26:44 +0000 (18:26 +0000)
committerTravis Cross <tc@traviscross.com>
Tue, 4 Mar 2014 02:07:24 +0000 (02:07 +0000)
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

index b6c52c4ae335a3913530a246f945884b5d30587b..fc4b6a601931e8abc3a409f9ef81fb8f17538d13 100644 (file)
@@ -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: