<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][17353] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=17353">17353</a></dd>
<dt>Author</dt> <dd>brian</dd>
<dt>Date</dt> <dd>2010-04-20 16:15:53 -0500 (Tue, 20 Apr 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>add rtcp seperate on audio and video and add passthru</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunkconfsip_profilesinternalxml">freeswitch/trunk/conf/sip_profiles/internal.xml</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_rtph">freeswitch/trunk/src/include/switch_rtp.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_typesh">freeswitch/trunk/src/include/switch_types.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiah">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_rtpc">freeswitch/trunk/src/switch_rtp.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkconfsip_profilesinternalxml"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/conf/sip_profiles/internal.xml (17352 => 17353)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/conf/sip_profiles/internal.xml        2010-04-22 18:20:32 UTC (rev 17352)
+++ freeswitch/trunk/conf/sip_profiles/internal.xml        2010-04-20 21:15:53 UTC (rev 17353)
</span><span class="lines">@@ -208,8 +208,9 @@
</span><span class="cx">     &lt;!--all inbound reg will stored in the db using this domain --&gt;
</span><span class="cx">     &lt;param name=&quot;force-register-db-domain&quot; value=&quot;$${domain}&quot;/&gt;
</span><span class="cx"> 
</span><del>-    &lt;!-- enable rtcp on every channel also can be done per leg basis with rtcp_interval_msec variable --&gt;
-    &lt;!--&lt;param name=&quot;rtcp-interval-msec&quot; value=&quot;10000&quot;/&gt;--&gt;
</del><ins>+    &lt;!-- enable rtcp on every channel also can be done per leg basis with rtcp_audio_interval_msec variable set to passthru to pass it across a call--&gt;
+    &lt;!--&lt;param name=&quot;rtcp-audio-interval-msec&quot; value=&quot;10000&quot;/&gt;--&gt;
+    &lt;!--&lt;param name=&quot;rtcp-video-interval-msec&quot; value=&quot;10000&quot;/&gt;--&gt;
</ins><span class="cx"> 
</span><span class="cx">     &lt;!--force suscription expires to a lower value than requested--&gt;
</span><span class="cx">     &lt;!--&lt;param name=&quot;force-subscription-expires&quot; value=&quot;60&quot;/&gt;--&gt;
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_rtph"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_rtp.h (17352 => 17353)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_rtp.h        2010-04-22 18:20:32 UTC (rev 17352)
+++ freeswitch/trunk/src/include/switch_rtp.h        2010-04-20 21:15:53 UTC (rev 17353)
</span><span class="lines">@@ -219,7 +219,7 @@
</span><span class="cx">   \param send_rate interval in milliseconds to send at
</span><span class="cx">   \return SWITCH_STATUS_SUCCESS
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_session, int send_rate);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_session, int send_rate, switch_port_t remote_port);
</ins><span class="cx"> 
</span><span class="cx"> /*! 
</span><span class="cx">   \brief Acvite a jitter buffer on an RTP session
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_typesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_types.h (17352 => 17353)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h        2010-04-22 18:20:32 UTC (rev 17352)
+++ freeswitch/trunk/src/include/switch_types.h        2010-04-20 21:15:53 UTC (rev 17353)
</span><span class="lines">@@ -535,7 +535,9 @@
</span><span class="cx">         SWITCH_RTP_FLAG_DEBUG_RTP_READ = (1 &lt;&lt; 27),
</span><span class="cx">         SWITCH_RTP_FLAG_DEBUG_RTP_WRITE = (1 &lt;&lt; 28),
</span><span class="cx">         SWITCH_RTP_FLAG_VIDEO = (1 &lt;&lt; 29),
</span><del>-        SWITCH_RTP_FLAG_ENABLE_RTCP = (1 &lt;&lt; 30)
</del><ins>+        SWITCH_RTP_FLAG_ENABLE_RTCP = (1 &lt;&lt; 30),
+        SWITCH_RTP_FLAG_RTCP_PASSTHRU = (1 &lt;&lt; 31)
+        /* don't add any more 31 is the limit! gotta chnge to an array to add more */
</ins><span class="cx"> } switch_rtp_flag_enum_t;
</span><span class="cx"> typedef uint32_t switch_rtp_flag_t;
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiamod_sofiah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (17352 => 17353)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2010-04-22 18:20:32 UTC (rev 17352)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2010-04-20 21:15:53 UTC (rev 17353)
</span><span class="lines">@@ -466,7 +466,8 @@
</span><span class="cx">         char *record_path;
</span><span class="cx">         char *presence_hosts;
</span><span class="cx">         char *challenge_realm;
</span><del>-        char *rtcp_interval_msec;
</del><ins>+        char *rtcp_audio_interval_msec;
+        char *rtcp_video_interval_msec;
</ins><span class="cx">         sofia_cid_type_t cid_type;
</span><span class="cx">         sofia_dtmf_t dtmf_type;
</span><span class="cx">         int auto_restart;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (17352 => 17353)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-04-22 18:20:32 UTC (rev 17352)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-04-20 21:15:53 UTC (rev 17353)
</span><span class="lines">@@ -2459,8 +2459,10 @@
</span><span class="cx">                                                 profile-&gt;hold_music = switch_core_strdup(profile-&gt;pool, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;outbound-proxy&quot;)) {
</span><span class="cx">                                                 profile-&gt;outbound_proxy = switch_core_strdup(profile-&gt;pool, val);
</span><del>-                                        } else if (!strcasecmp(var, &quot;rtcp-interval-msec&quot;)) {
-                                                profile-&gt;rtcp_interval_msec = switch_core_strdup(profile-&gt;pool, val);
</del><ins>+                                        } else if (!strcasecmp(var, &quot;rtcp-audio-interval-msec&quot;)) {
+                                                profile-&gt;rtcp_audio_interval_msec = switch_core_strdup(profile-&gt;pool, val);
+                                        } else if (!strcasecmp(var, &quot;rtcp-video-interval-msec&quot;)) {
+                                                profile-&gt;rtcp_video_interval_msec = switch_core_strdup(profile-&gt;pool, val);
</ins><span class="cx">                                         } else if (!strcasecmp(var, &quot;session-timeout&quot;)) {
</span><span class="cx">                                                 int v_session_timeout = atoi(val);
</span><span class="cx">                                                 if (v_session_timeout &gt;= 0) {
</span><span class="lines">@@ -2998,8 +3000,10 @@
</span><span class="cx">                                                 profile-&gt;hold_music = switch_core_strdup(profile-&gt;pool, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;outbound-proxy&quot;)) {
</span><span class="cx">                                                 profile-&gt;outbound_proxy = switch_core_strdup(profile-&gt;pool, val);
</span><del>-                                        } else if (!strcasecmp(var, &quot;rtcp-interval-msec&quot;)) {
-                                                profile-&gt;rtcp_interval_msec = switch_core_strdup(profile-&gt;pool, val);
</del><ins>+                                        } else if (!strcasecmp(var, &quot;rtcp-audio-interval-msec&quot;)) {
+                                                profile-&gt;rtcp_audio_interval_msec = switch_core_strdup(profile-&gt;pool, val);
+                                        } else if (!strcasecmp(var, &quot;rtcp-video-interval-msec&quot;)) {
+                                                profile-&gt;rtcp_video_interval_msec = switch_core_strdup(profile-&gt;pool, val);
</ins><span class="cx">                                         } else if (!strcasecmp(var, &quot;session-timeout&quot;)) {
</span><span class="cx">                                                 int v_session_timeout = atoi(val);
</span><span class="cx">                                                 if (v_session_timeout &gt;= 0) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (17352 => 17353)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-04-22 18:20:32 UTC (rev 17352)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-04-20 21:15:53 UTC (rev 17353)
</span><span class="lines">@@ -691,7 +691,7 @@
</span><span class="cx"> switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt, int force)
</span><span class="cx"> {
</span><span class="cx">         char *lookup_rtpip = tech_pvt-&gt;profile-&gt;rtpip;        /* Pointer to externally looked up address */
</span><del>-        switch_port_t sdp_port;                /* The external port to be sent in the SDP */
</del><ins>+        switch_port_t sdp_port, rtcp_port;                /* The external port to be sent in the SDP */
</ins><span class="cx">         const char *use_ip = NULL;        /* The external IP to be sent in the SDP */
</span><span class="cx"> 
</span><span class="cx">         /* Don't do anything if we're in proxy mode or if a (remote) port already has been found */
</span><span class="lines">@@ -734,6 +734,7 @@
</span><span class="cx">                                 if (!zstr(tech_pvt-&gt;remote_ip) &amp;&amp; sofia_glue_check_nat(tech_pvt-&gt;profile, tech_pvt-&gt;remote_ip)) {
</span><span class="cx">                                         /* Yes, map the port through switch_nat */
</span><span class="cx">                                         switch_nat_add_mapping(tech_pvt-&gt;local_sdp_audio_port, SWITCH_NAT_UDP, &amp;sdp_port, SWITCH_FALSE);
</span><ins>+                                        switch_nat_add_mapping(tech_pvt-&gt;local_sdp_audio_port + 1, SWITCH_NAT_UDP, &amp;rtcp_port, SWITCH_FALSE);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         /* No NAT detected */
</span><span class="cx">                                         use_ip = tech_pvt-&gt;profile-&gt;rtpip;
</span><span class="lines">@@ -2726,12 +2727,23 @@
</span><span class="cx">                                                                                   (tech_pvt-&gt;stun_flags &amp; STUN_FLAG_FUNNY) ? 1 : 0);
</span><span class="cx">                 }
</span><span class="cx">                 
</span><del>-                if ((val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtcp_interval_msec&quot;)) || (val = tech_pvt-&gt;profile-&gt;rtcp_interval_msec)) {
-                        int interval = atoi(val);
-                        if (interval &lt; 100 || interval &gt; 5000) {
-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;Invalid rtcp interval spec [%d] must be between 100 and 5000\n&quot;, interval);
</del><ins>+                printf(&quot;WTF [%s][%s]\n&quot;, switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtcp_audio_interval_msec&quot;), tech_pvt-&gt;profile-&gt;rtcp_audio_interval_msec);
+
+                if ((val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtcp_audio_interval_msec&quot;)) || (val = tech_pvt-&gt;profile-&gt;rtcp_audio_interval_msec)) {
+                        const char *rport = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_remote_audio_rtcp_port&quot;);
+                        switch_port_t remote_port = 0;
+                        if (rport) {
+                                remote_port = atoi(rport);
+                        }
+                        if (!strcasecmp(val, &quot;passthru&quot;)) {
+                                switch_rtp_activate_rtcp(tech_pvt-&gt;rtp_session, -1, remote_port);
</ins><span class="cx">                         } else {
</span><del>-                                switch_rtp_activate_rtcp(tech_pvt-&gt;rtp_session, interval);
</del><ins>+                                int interval = atoi(val);
+                                if (interval &lt; 100 || interval &gt; 5000) {
+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;Invalid rtcp interval spec [%d] must be between 100 and 5000\n&quot;, interval);
+                                } else {
+                                        switch_rtp_activate_rtcp(tech_pvt-&gt;rtp_session, interval, remote_port);
+                                }
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -2949,6 +2961,27 @@
</span><span class="cx">                                 switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;sip_use_video_pt&quot;, &quot;%d&quot;, tech_pvt-&gt;video_agreed_pt);
</span><span class="cx">                                 tech_pvt-&gt;video_ssrc = switch_rtp_get_ssrc(tech_pvt-&gt;rtp_session);
</span><span class="cx">                                 switch_channel_set_variable_printf(tech_pvt-&gt;channel, &quot;rtp_use_video_ssrc&quot;, &quot;%u&quot;, tech_pvt-&gt;ssrc);
</span><ins>+
+
+                                if ((val = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;rtcp_audio_interval_msec&quot;)) || (val = tech_pvt-&gt;profile-&gt;rtcp_audio_interval_msec)) {
+                                        const char *rport = switch_channel_get_variable(tech_pvt-&gt;channel, &quot;sip_remote_video_rtcp_port&quot;);
+                                        switch_port_t remote_port = 0;
+                                        if (rport) {
+                                                remote_port = atoi(rport);
+                                        }
+                                        if (!strcasecmp(val, &quot;passthru&quot;)) {
+                                                switch_rtp_activate_rtcp(tech_pvt-&gt;rtp_session, -1, remote_port);
+                                        } else {
+                                                int interval = atoi(val);
+                                                if (interval &lt; 100 || interval &gt; 5000) {
+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;Invalid rtcp interval spec [%d] must be between 100 and 5000\n&quot;, interval);
+                                                } else {
+                                                        switch_rtp_activate_rtcp(tech_pvt-&gt;rtp_session, interval, remote_port);
+                                                }
+                                        }
+                                }
+
+
</ins><span class="cx">                         } else {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt-&gt;session), SWITCH_LOG_ERROR, &quot;VIDEO RTP REPORTS ERROR: [%s]\n&quot;, switch_str_nil(err));
</span><span class="cx">                                 switch_channel_hangup(tech_pvt-&gt;channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="lines">@@ -3378,6 +3411,11 @@
</span><span class="cx">                 } else if (m-&gt;m_type == sdp_media_audio &amp;&amp; m-&gt;m_port &amp;&amp; !got_audio) {
</span><span class="cx">                         sdp_rtpmap_t *map;
</span><span class="cx">                         for (attr = m-&gt;m_attributes; attr; attr = attr-&gt;a_next) {
</span><ins>+                                
+                                if (!strcasecmp(attr-&gt;a_name, &quot;rtcp&quot;) &amp;&amp; attr-&gt;a_value) {
+                                        switch_channel_set_variable(tech_pvt-&gt;channel, &quot;sip_remote_audio_rtcp_port&quot;, attr-&gt;a_value);
+                                }
+
</ins><span class="cx">                                 if (!strcasecmp(attr-&gt;a_name, &quot;ptime&quot;) &amp;&amp; attr-&gt;a_value) {
</span><span class="cx">                                         ptime = atoi(attr-&gt;a_value);
</span><span class="cx">                                 } else if (!strcasecmp(attr-&gt;a_name, &quot;maxptime&quot;) &amp;&amp; attr-&gt;a_value) {
</span><span class="lines">@@ -3708,6 +3746,9 @@
</span><span class="cx">                                         if (!strcasecmp(attr-&gt;a_name, &quot;framerate&quot;) &amp;&amp; attr-&gt;a_value) {
</span><span class="cx">                                                 framerate = atoi(attr-&gt;a_value);
</span><span class="cx">                                         }
</span><ins>+                                        if (!strcasecmp(attr-&gt;a_name, &quot;rtcp&quot;) &amp;&amp; attr-&gt;a_value) {
+                                                switch_channel_set_variable(tech_pvt-&gt;channel, &quot;sip_remote_video_rtcp_port&quot;, attr-&gt;a_value);
+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!(rm_encoding = map-&gt;rm_encoding)) {
</span><span class="cx">                                         rm_encoding = &quot;&quot;;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_rtpc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_rtp.c (17352 => 17353)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_rtp.c        2010-04-22 18:20:32 UTC (rev 17352)
+++ freeswitch/trunk/src/switch_rtp.c        2010-04-20 21:15:53 UTC (rev 17353)
</span><span class="lines">@@ -195,6 +195,7 @@
</span><span class="cx">         uint32_t ms_per_packet;
</span><span class="cx">         switch_port_t local_port;
</span><span class="cx">         switch_port_t remote_port;
</span><ins>+        switch_port_t remote_rtcp_port;
</ins><span class="cx">         uint32_t stuncount;
</span><span class="cx">         uint32_t funny_stun;
</span><span class="cx">         uint32_t default_stuncount;
</span><span class="lines">@@ -773,10 +774,8 @@
</span><span class="cx"> 
</span><span class="cx">         if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP)) {
</span><span class="cx"> 
</span><del>-                rtp_session-&gt;rtcp_remote_addr = rtp_session-&gt;remote_addr;
-                
</del><span class="cx">                 if (switch_sockaddr_info_get(&amp;rtp_session-&gt;rtcp_remote_addr, rtp_session-&gt;remote_host_str, SWITCH_UNSPEC, 
</span><del>-                                                                         rtp_session-&gt;remote_port + 1, 0, rtp_session-&gt;pool) != SWITCH_STATUS_SUCCESS || !rtp_session-&gt;rtcp_remote_addr) {
</del><ins>+                                                                         rtp_session-&gt;remote_rtcp_port, 0, rtp_session-&gt;pool) != SWITCH_STATUS_SUCCESS || !rtp_session-&gt;rtcp_remote_addr) {
</ins><span class="cx">                         *err = &quot;RTCP Remote Address Error!&quot;;
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><span class="lines">@@ -1248,7 +1247,10 @@
</span><span class="cx"> {
</span><span class="cx">         switch_rtp_t *rtp_session = NULL;
</span><span class="cx">         switch_core_session_t *session = switch_core_memory_pool_get_data(pool, &quot;__session&quot;);
</span><ins>+        switch_channel_t *channel = NULL;
</ins><span class="cx"> 
</span><ins>+        if (session) channel = switch_core_session_get_channel(session);
+
</ins><span class="cx">         *new_rtp_session = NULL;
</span><span class="cx"> 
</span><span class="cx">         if (samples_per_interval &gt; SWITCH_RTP_MAX_BUF_LEN) {
</span><span class="lines">@@ -1303,14 +1305,14 @@
</span><span class="cx"> 
</span><span class="cx">         rtp_session-&gt;payload = payload;
</span><span class="cx"> 
</span><del>-        if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP)) {        
-                rtp_session-&gt;rtcp_send_msg.header.version = 2;
-                rtp_session-&gt;rtcp_send_msg.header.p = 0;
-                rtp_session-&gt;rtcp_send_msg.header.type = 200;
-                rtp_session-&gt;rtcp_send_msg.header.count = 0;
-                rtp_session-&gt;rtcp_send_msg.header.length = htons(6); 
-        }
</del><span class="cx"> 
</span><ins>+        rtp_session-&gt;rtcp_send_msg.header.version = 2;
+        rtp_session-&gt;rtcp_send_msg.header.p = 0;
+        rtp_session-&gt;rtcp_send_msg.header.type = 200;
+        rtp_session-&gt;rtcp_send_msg.header.count = 0;
+        rtp_session-&gt;rtcp_send_msg.header.length = htons(6); 
+
+
</ins><span class="cx">         switch_rtp_set_interval(rtp_session, ms_per_packet, samples_per_interval);
</span><span class="cx">         rtp_session-&gt;conf_samples_per_interval = samples_per_interval;
</span><span class="cx"> 
</span><span class="lines">@@ -1341,12 +1343,13 @@
</span><span class="cx">                 switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        switch_channel_set_private(channel, &quot;__rtcp_audio_rtp_session&quot;, rtp_session);
+
</ins><span class="cx"> #ifdef ENABLE_ZRTP
</span><span class="cx">         if (zrtp_on) {
</span><span class="cx">                 switch_rtp_t *master_rtp_session = NULL;
</span><span class="cx"> 
</span><span class="cx">                 int initiator = 0;
</span><del>-                switch_channel_t *channel = switch_core_session_get_channel(session);
</del><span class="cx">                 const char *zrtp_enabled = switch_channel_get_variable(channel, &quot;zrtp_secure_media&quot;);
</span><span class="cx">                 const char *srtp_enabled = switch_channel_get_variable(channel, &quot;sip_secure_media&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -1531,14 +1534,24 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_session, int send_rate)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_session, int send_rate, switch_port_t remote_port)
</ins><span class="cx"> {
</span><span class="cx">         const char *err = NULL;
</span><span class="cx">         
</span><span class="cx">         switch_set_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP);
</span><span class="cx"> 
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;RTCP send rate is: %d and packet rate is: %d\n&quot;, send_rate, rtp_session-&gt;ms_per_packet);
-        rtp_session-&gt;rtcp_interval = send_rate/(rtp_session-&gt;ms_per_packet/1000);
</del><ins>+        if (!(rtp_session-&gt;remote_rtcp_port = remote_port)) {
+                rtp_session-&gt;remote_rtcp_port = rtp_session-&gt;remote_port + 1;
+        }
+        
+        if (send_rate == -1) {
+                switch_set_flag(rtp_session, SWITCH_RTP_FLAG_RTCP_PASSTHRU);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;RTCP passthru enabled. Remote Port: %d\n&quot;, rtp_session-&gt;remote_rtcp_port);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;RTCP send rate is: %d and packet rate is: %d Remote Port: %d\n&quot;, 
+                                                  send_rate, rtp_session-&gt;ms_per_packet, rtp_session-&gt;remote_rtcp_port);
+                rtp_session-&gt;rtcp_interval = send_rate/(rtp_session-&gt;ms_per_packet/1000);
+        }
</ins><span class="cx"> 
</span><span class="cx">         return enable_local_rtcp_socket(rtp_session, &amp;err) || enable_remote_rtcp_socket(rtp_session, &amp;err);
</span><span class="cx"> 
</span><span class="lines">@@ -2236,6 +2249,68 @@
</span><span class="cx">                                                 
</span><span class="cx">                         if (rtcp_poll_status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 rtcp_status = read_rtcp_packet(rtp_session, &amp;rtcp_bytes, flags);
</span><ins>+                                
+                                if (rtcp_status == SWITCH_STATUS_SUCCESS &amp;&amp; switch_test_flag(rtp_session, SWITCH_RTP_FLAG_RTCP_PASSTHRU)) {
+                                        switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session-&gt;pool, &quot;__session&quot;);
+                                        switch_channel_t *channel = switch_core_session_get_channel(session);
+
+                                        const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
+                                        if (uuid) {
+                                                switch_core_session_t *other_session;
+                                                switch_rtp_t *other_rtp_session = NULL;
+
+                                                if ((other_session = switch_core_session_locate(uuid))) {
+                                                        switch_channel_t *other_channel = switch_core_session_get_channel(other_session);                                        
+                                                        if ((other_rtp_session = switch_channel_get_private(other_channel, &quot;__rtcp_audio_rtp_session&quot;)) &amp;&amp; 
+                                                                switch_test_flag(other_rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP)) {
+                                                                *other_rtp_session-&gt;rtcp_send_msg.body = *rtp_session-&gt;rtcp_recv_msg.body;
+
+                                                                if (switch_test_flag(other_rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) {
+                                                                        int sbytes = (int) rtcp_bytes;
+                                                                        int stat = srtp_protect_rtcp(other_rtp_session-&gt;send_ctx, &amp;other_rtp_session-&gt;rtcp_send_msg.header, &amp;sbytes);
+                                                                        if (stat) {
+                                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error: SRTP RTCP protection failed with code %d\n&quot;, stat);
+                                                                        }
+                                                                        rtcp_bytes = sbytes;
+                                                                }
+
+#ifdef ENABLE_ZRTP
+                                                                /* ZRTP Send */
+                                                                if (1) {
+                                                                        unsigned int sbytes = (int) bytes;
+                                                                        zrtp_status_t stat = zrtp_status_fail;
+
+                                                                        stat = zrtp_process_rtcp(other_rtp_session-&gt;zrtp_stream, (void *) &amp;other_rtp_session-&gt;rtcp_send_msg, &amp;sbytes);
+
+                                                                        switch (stat) {
+                                                                        case zrtp_status_ok:
+                                                                                break;
+                                                                        case zrtp_status_drop:
+                                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error: zRTP protection drop with code %d\n&quot;, stat);
+                                                                                ret = (int) bytes;
+                                                                                goto end;
+                                                                                break;
+                                                                        case zrtp_status_fail:
+                                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error: zRTP protection fail with code %d\n&quot;, stat);
+                                                                                break;
+                                                                        default:
+                                                                                break;
+                                                                        }
+
+                                                                        bytes = sbytes;
+                                                                }
+#endif
+                                                                if (switch_socket_sendto(other_rtp_session-&gt;rtcp_sock_output, other_rtp_session-&gt;rtcp_remote_addr, 0, 
+                                                                                                                 (const char*)&amp;other_rtp_session-&gt;rtcp_send_msg, &amp;rtcp_bytes ) != SWITCH_STATUS_SUCCESS) {
+                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,&quot;RTCP packet not written\n&quot;);
+                                                                }
+                                                                
+                                                                
+                                                        }
+                                                }
+                                        }
+                                        
+                                }
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -3244,7 +3319,7 @@
</span><span class="cx"> 
</span><span class="cx">                 rtp_session-&gt;last_write_ts = this_ts;
</span><span class="cx">                 
</span><del>-                if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP) &amp;&amp; 
</del><ins>+                if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP) &amp;&amp; !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_RTCP_PASSTHRU) &amp;&amp;
</ins><span class="cx">                         rtp_session-&gt;rtcp_interval &amp;&amp; (rtp_session-&gt;stats.outbound.packet_count % rtp_session-&gt;rtcp_interval) == 0) {
</span><span class="cx">                         struct switch_rtcp_senderinfo* sr = (struct switch_rtcp_senderinfo*)rtp_session-&gt;rtcp_send_msg.body;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>