<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6186">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
George Joseph: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_rtp_asterisk: Make P2P bridge Asymmetric codec aware<br><br>Introduce a new property to rtp-engine to make it aware of<br>the desire for assymetric codecs or not. If asymmetric codecs<br>is not allowed, the bridge will compare read/write formats<br>and shut down the p2p bridge if needed<br><br>ASTERISK-26745 #close<br><br>Change-Id: I0d9c83e5356df81661e58d40a8db565833501a6f<br>---<br>M channels/chan_pjsip.c<br>M include/asterisk/rtp_engine.h<br>M res/res_pjsip_sdp_rtp.c<br>M res/res_rtp_asterisk.c<br>4 files changed, 36 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c<br>index 94aca70..8e19dd8 100644<br>--- a/channels/chan_pjsip.c<br>+++ b/channels/chan_pjsip.c<br>@@ -727,14 +727,11 @@<br> <br> session = channel->session;<br> <br>- if (ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {<br>- ast_debug(1, "Oooh, got a frame with format of %s on channel '%s' when it has not been negotiated\n",<br>- ast_format_get_name(f->subclass.format), ast_channel_name(ast));<br>-<br>- ast_frfree(f);<br>- return &ast_null_frame;<br>- }<br>-<br>+ /*<br>+ * Asymmetric RTP only has one native format set at a time.<br>+ * Therefore we need to update the native format to the current<br>+ * raw read format BEFORE the native format check<br>+ */<br> if (!session->endpoint->asymmetric_rtp_codec &&<br> ast_format_cmp(ast_channel_rawwriteformat(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {<br> struct ast_format_cap *caps;<br>@@ -761,6 +758,14 @@<br> }<br> }<br> <br>+ if (ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {<br>+ ast_debug(1, "Oooh, got a frame with format of %s on channel '%s' when it has not been negotiated\n",<br>+ ast_format_get_name(f->subclass.format), ast_channel_name(ast));<br>+<br>+ ast_frfree(f);<br>+ return &ast_null_frame;<br>+ }<br>+<br> if (session->dsp) {<br> int dsp_features;<br> <br>diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h<br>index e08738e..6632261 100644<br>--- a/include/asterisk/rtp_engine.h<br>+++ b/include/asterisk/rtp_engine.h<br>@@ -114,6 +114,8 @@<br> AST_RTP_PROPERTY_STUN,<br> /*! Enable RTCP support */<br> AST_RTP_PROPERTY_RTCP,<br>+ /*! Enable Asymmetric RTP Codecs */<br>+ AST_RTP_PROPERTY_ASYMMETRIC_CODEC,<br> <br> /*!<br> * \brief Maximum number of RTP properties supported<br>diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c<br>index aea30c4..850d04d 100644<br>--- a/res/res_pjsip_sdp_rtp.c<br>+++ b/res/res_pjsip_sdp_rtp.c<br>@@ -242,6 +242,7 @@<br> }<br> <br> ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_NAT, session->endpoint->media.rtp.symmetric);<br>+ ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_ASYMMETRIC_CODEC, session->endpoint->asymmetric_rtp_codec);<br> <br> if (!session->endpoint->media.rtp.ice_support && (ice = ast_rtp_instance_get_ice(session_media->rtp))) {<br> ice->stop(session_media->rtp);<br>diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c<br>index 8121dc9..1a6213c 100644<br>--- a/res/res_rtp_asterisk.c<br>+++ b/res/res_rtp_asterisk.c<br>@@ -302,6 +302,7 @@<br> void *data;<br> struct ast_rtcp *rtcp;<br> struct ast_rtp *bridged; /*!< Who we are Packet bridged to */<br>+ unsigned int asymmetric_codec; /*!< Indicate if asymmetric send/receive codecs are allowed */<br> <br> enum strict_rtp_state strict_rtp_state; /*!< Current state that strict RTP protection is in */<br> struct ast_sockaddr strict_rtp_address; /*!< Remote address information for strict RTP purposes */<br>@@ -4878,6 +4879,23 @@<br> return -1;<br> }<br> <br>+<br>+ ao2_replace(rtp->lastrxformat, payload_type->format);<br>+ ao2_replace(bridged->lasttxformat, payload_type->format);<br>+<br>+ /*<br>+ * If bridged peer has already received rtp, perform the asymmetric codec check<br>+ * if that feature has been activated<br>+ */<br>+ if (!bridged->asymmetric_codec && bridged->lastrxformat != ast_format_none) {<br>+ if (ast_format_cmp(bridged->lasttxformat, bridged->lastrxformat) == AST_FORMAT_CMP_NOT_EQUAL) {<br>+ ast_debug(1, "Asymmetric RTP codecs detected (TX: %s, RX: %s) sending frame to core\n",<br>+ ast_format_get_name(bridged->lasttxformat),<br>+ ast_format_get_name(bridged->lastrxformat));<br>+ return -1;<br>+ }<br>+ }<br>+<br> /* If the marker bit has been explicitly set turn it on */<br> if (ast_test_flag(rtp, FLAG_NEED_MARKER_BIT)) {<br> mark = 1;<br>@@ -5530,6 +5548,8 @@<br> rtp->rtcp = NULL;<br> }<br> }<br>+ } else if (property == AST_RTP_PROPERTY_ASYMMETRIC_CODEC) {<br>+ rtp->asymmetric_codec = value;<br> }<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6186">change 6186</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6186"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 14 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I0d9c83e5356df81661e58d40a8db565833501a6f </div>
<div style="display:none"> Gerrit-Change-Number: 6186 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Torrey Searle <tsearle@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>