From 0071cedcd0bc28a38f28b740c66796d936973cf9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 23 Apr 2009 13:15:03 +0000 Subject: [PATCH] only pass 2833 while bridged and while bridged to another channel that uses our RTP stack git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13131 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_channel.h | 2 ++ src/include/switch_types.h | 1 + src/mod/endpoints/mod_sofia/mod_sofia.c | 9 +++++++++ src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia_glue.c | 4 +++- src/switch_channel.c | 18 ++++++++++++++++++ 6 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index f70abba5fc..9c35f1f198 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -301,6 +301,8 @@ SWITCH_DECLARE(switch_bool_t) switch_channel_set_flag_partner(switch_channel_t * */ SWITCH_DECLARE(switch_bool_t) switch_channel_clear_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag); +SWITCH_DECLARE(uint32_t) switch_channel_test_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag); + /*! \brief Set given flag(s) on a given channel to be applied on the next state change \param channel channel on which to set flag(s) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 78bf3a096d..660040f178 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -883,6 +883,7 @@ typedef enum { CF_PAUSE_BUGS, CF_DIVERT_EVENTS, CF_BLOCK_STATE, + CF_FS_RTP, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ CF_FLAG_MAX } switch_channel_flag_t; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 99ed6a740b..de696f70aa 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1024,11 +1024,20 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_BRIDGE: if (switch_rtp_ready(tech_pvt->rtp_session)) { + if (sofia_test_flag(tech_pvt, TFLAG_PASS_RFC2833) && switch_channel_test_flag_partner(channel, CF_FS_RTP)) { + switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s activate passthru 2833 mode.\n", switch_channel_get_name(channel)); + } + rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_STICK); } goto end; case SWITCH_MESSAGE_INDICATE_UNBRIDGE: if (switch_rtp_ready(tech_pvt->rtp_session)) { + if (switch_rtp_test_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s deactivate passthru 2833 mode.\n", switch_channel_get_name(channel)); + switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833); + } rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_UNSTICK); } goto end; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index c1048bde6a..b306a6799c 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -233,6 +233,7 @@ typedef enum { TFLAG_PROXY_MEDIA, TFLAG_HOLD_LOCK, TFLAG_3PCC_HAS_ACK, + TFLAG_PASS_RFC2833, /* No new flags below this line */ TFLAG_MAX diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index bfd4cc2bc4..e2a6ac7abd 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -2106,7 +2106,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f if (sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_RFC2833) || ((val = switch_channel_get_variable(tech_pvt->channel, "pass_rfc2833")) && switch_true(val))) { - flags |= SWITCH_RTP_FLAG_PASS_RFC2833; + sofia_set_flag(tech_pvt, TFLAG_PASS_RFC2833); } @@ -2219,6 +2219,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f uint8_t vad_out = sofia_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0; uint8_t inb = sofia_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1; uint32_t stun_ping = 0; + + switch_channel_set_flag(tech_pvt->channel, CF_FS_RTP); if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_enable_vad_in")) && switch_true(val)) { vad_in = 1; diff --git a/src/switch_channel.c b/src/switch_channel.c index a6d1f182bb..b1beb3a55e 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -719,6 +719,24 @@ SWITCH_DECLARE(switch_bool_t) switch_channel_set_flag_partner(switch_channel_t * return SWITCH_FALSE; } +SWITCH_DECLARE(uint32_t) switch_channel_test_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag) +{ + const char *uuid; + int r = 0; + + switch_assert(channel != NULL); + + if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + switch_core_session_t *session; + if ((session = switch_core_session_locate(uuid))) { + r = switch_channel_test_flag(switch_core_session_get_channel(session), flag); + switch_core_session_rwunlock(session); + } + } + + return r; +} + SWITCH_DECLARE(switch_bool_t) switch_channel_clear_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag) { const char *uuid;