<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14009">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Joshua Colp: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_session: Apply intention behind requested formats.<br><br>When an outgoing channel is created a list of formats may<br>optionally be provided which is used as a request that the<br>formats be used if possible. If an endpoint is not configured<br>for any of the formats we ignore this request and use what is<br>configured. This has the side effect of also including other<br>stream types (such as video) that were not present in the<br>requested formats.<br><br>This change makes it so that the intention of the request is<br>preserved - that is if only an audio format is requested then<br>even if there is no joint audio format between the request and<br>the configuration we will still only place an audio stream in<br>the outgoing call.<br><br>ASTERISK-28787<br><br>Change-Id: Ia54c0c63e94aca176169b9bae4bb8a8380ea245f<br>---<br>A doc/CHANGES-staging/res_pjsip_session_codecs.md<br>M res/res_pjsip_session.c<br>2 files changed, 19 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/res_pjsip_session_codecs.md b/doc/CHANGES-staging/res_pjsip_session_codecs.md</span><br><span>new file mode 100644</span><br><span>index 0000000..847eb41</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_pjsip_session_codecs.md</span><br><span>@@ -0,0 +1,8 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_pjsip_session</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+When placing an outgoing call to a PJSIP endpoint the intent</span><br><span style="color: hsl(120, 100%, 40%);">+of any requested formats will now be respected. If only an audio</span><br><span style="color: hsl(120, 100%, 40%);">+format is requested (such as ulaw) but the underlying endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+does not support the format the resulting SDP will still only</span><br><span style="color: hsl(120, 100%, 40%);">+contain an audio stream, and not any additional streams such as</span><br><span style="color: hsl(120, 100%, 40%);">+video.</span><br><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index 4ce5a24..31b0d0c 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -2727,16 +2727,6 @@</span><br><span> }</span><br><span> </span><br><span> ast_format_cap_get_compatible(req_cap, endpoint->media.codecs, joint_cap);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_format_cap_count(joint_cap)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(joint_cap, -1);</span><br><span style="color: hsl(0, 100%, 40%);">- continue;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- clone_stream = ast_stream_clone(req_stream, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!clone_stream) {</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(joint_cap, -1);</span><br><span style="color: hsl(0, 100%, 40%);">- continue;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span> </span><br><span> if (ast_stream_get_type(req_stream) == AST_MEDIA_TYPE_AUDIO) {</span><br><span> /*</span><br><span>@@ -2748,6 +2738,17 @@</span><br><span> endpoint->media.codecs, AST_MEDIA_TYPE_AUDIO);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_format_cap_count(joint_cap)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(joint_cap, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ clone_stream = ast_stream_clone(req_stream, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!clone_stream) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(joint_cap, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_stream_set_formats(clone_stream, joint_cap);</span><br><span> ao2_ref(joint_cap, -1);</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14009">change 14009</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/14009"/><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-Change-Id: Ia54c0c63e94aca176169b9bae4bb8a8380ea245f </div>
<div style="display:none"> Gerrit-Change-Number: 14009 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>