<p>Torrey Searle has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6117">View Change</a></p><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 assymetric 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, 33 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/17/6117/1</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 db0a697..7a2ffbc 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 f9bdc50..0b29f34 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 a7c1b7c..e973d34 100644<br>--- a/res/res_pjsip_sdp_rtp.c<br>+++ b/res/res_pjsip_sdp_rtp.c<br>@@ -241,6 +241,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 a93bb77..7889eee 100644<br>--- a/res/res_rtp_asterisk.c<br>+++ b/res/res_rtp_asterisk.c<br>@@ -4879,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 (!ast_rtp_instance_get_prop(instance1, AST_RTP_PROPERTY_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></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6117">change 6117</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/6117"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I0d9c83e5356df81661e58d40a8db565833501a6f </div>
<div style="display:none"> Gerrit-Change-Number: 6117 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Torrey Searle <tsearle@gmail.com> </div>