<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6188">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
</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, 37 insertions(+), 7 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 ebda6c7..4a24fa6 100644<br>--- a/channels/chan_pjsip.c<br>+++ b/channels/chan_pjsip.c<br>@@ -797,14 +797,13 @@<br> return f;<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>+ session = channel->session;<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>@@ -831,6 +830,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 d030bdb..3ceac84 100644<br>--- a/include/asterisk/rtp_engine.h<br>+++ b/include/asterisk/rtp_engine.h<br>@@ -120,6 +120,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 77cd807..b082b1d 100644<br>--- a/res/res_pjsip_sdp_rtp.c<br>+++ b/res/res_pjsip_sdp_rtp.c<br>@@ -202,6 +202,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 65ab902..0ff2b55 100644<br>--- a/res/res_rtp_asterisk.c<br>+++ b/res/res_rtp_asterisk.c<br>@@ -313,6 +313,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> struct ast_rtp_instance *bundled; /*!< The RTP instance we are bundled to */<br> int stream_num; /*!< Stream num for this RTP instance */<br>@@ -5113,6 +5114,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>@@ -5797,6 +5815,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/6188">change 6188</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/6188"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </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: 6188 </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>