<p>Richard Mudgett <strong>uploaded patch set #3</strong> to this change.</p><p><a href="https://gerrit.asterisk.org/5819">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">SDP: Rework SDP offer/answer model and update capabilities merges.<br><br>The SDP offer/answer model requires an answer to an offer before a new SDP<br>can be processed.  This allows our local SDP creation to be deferred until<br>we know that we need to create an offer or an answer SDP.  Once the local<br>SDP is created it won't change until the SDP negotiation is restarted.<br><br>An offer SDP in an initial SIP INVITE can receive more than one answer<br>SDP.  In this case, we need to merge each answer SDP with our original<br>offer capabilities to get the currently negotiated capabilities.  To<br>satisfy this requirement means that we cannot update our proposed<br>capabilities until the negotiations are restarted.<br><br>Local topology updates from ast_sdp_state_update_local_topology() are<br>merged together until the next offer SDP is created.  These accumulated<br>updates are then merged with the current negotiated capabilities to create<br>the new proposed capabilities that the offer SDP is built.<br><br>Local topology updates are merged in several passes to attempt to be smart<br>about how streams from the system are matched with the previously<br>negotiated stream slots.  To allow for T.38 support when merging, type<br>matching considers audio and image types to be equivalent.  First streams<br>are matched by stream name and type.  Then streams are matched by stream<br>type only.  Any remaining unmatched existing streams are declined.  Any<br>new active streams are either backfilled into pre-merge declined slots or<br>appended onto the end of the merged topology.  Any excess new streams<br>above the maximum supported number of streams are simply discarded.<br><br>Remote topology negotiation merges depend if the topology is an offer or<br>answer.  An offer remote topology negotiation dictates the stream slot<br>ordering and new streams can be added.  A remote offer can do anything to<br>the previously negotiated streams except reduce the number of stream<br>slots.  An answer remote topology negotiation is limited to what our offer<br>requested.  The answer can only decline streams, pick codecs from the<br>offered list, or indicate the remote's stream hold state.<br><br>I had originally kept the RTP instance if the remote offer SDP changed a<br>stream type between audio and video since they both use RTP.  However, I<br>later removed this support in favor of simply creating a new RTP instance<br>since the stream's purpose has to be changing anyway.  Any RTP packets<br>from the old stream type might cause mischief for the bridged peer.<br><br>* Added ast_sdp_state_restart_negotiations() to restart the SDP<br>offer/answer negotiations.  We will thus know to create a new local SDP<br>when it is time to create an offer or answer.<br><br>* Removed ast_sdp_state_reset().  Save the current topology before<br>starting T.38.  To recover from T.38 simply update the local topology to<br>the saved topology and restart the SDP negotiations to get the offer SDP<br>renegotiating the previous configuration.<br><br>* Allow initial topology for ast_sdp_state_alloc() to be NULL so an<br>initial remote offer SDP can dictate the streams we start with.  We can<br>always update the local topology later if it turns out we need to offer<br>SDP first because the remote chose to defer sending us a SDP.<br><br>* Made the ast_sdp_state_alloc() initial topology limit to max_streams,<br>limit to configured codecs, handle declined streams, and discard<br>unsupported types.<br><br>* Convert struct ast_sdp to ao2 object.  Needed to easily save off a<br>remote SDP to refer to later for various reasons such as generating<br>declined m= lines in the local SDP.<br><br>* Improve converting remote SDP streams to a topology including stream<br>state.  A stream state of AST_STREAM_STATE_REMOVED indicates the stream is<br>declined/dead.<br><br>* Improve merging streams to take into account the stream state.<br><br>* Added query for remote hold state.<br><br>* Added maximum streams allowed SDP config option.<br><br>* Added ability to create new streams as needed.  New streams are created<br>with configured default audio, video, or image codecs depending on stream<br>type.<br><br>* Added global locally_held state along with a per stream local hold<br>state.  Historically, Asterisk only has a global locally held state<br>because when the we put the remote on hold we do it for all active<br>streams.<br><br>* Added queries for a rejected offer and current SDP negotiation role.<br>The rejected query allows the using module to know how to respond to a<br>failed remote SDP set.  Should the using module respond with a 488 Not<br>Acceptable Here or 500 Internal Error to the offer SDP?<br><br>* Moved sdp_state_capabilities.connection_address to ast_sdp_state.  There<br>seems no reason to keep it in the sdp_state_capabilities struct since it<br>was only used by the ast_sdp_state.proposed_capabilities instance.<br><br>* Callbacks are now available to allow the using module some customization<br>of negotiated streams and to complete setting up streams for use.  See the<br>typedef doxygen for each callback for what is allowable and when they are<br>called.<br>    * Added topology answerer modify callback.<br>    * Added topology pre and post apply callbacks.<br>    * Added topology offerer modify callback.<br>    * Added topology offerer configure callback.<br><br>* Had to rework the unit tests because I changed how SDP topologies are<br>merged.  Replaced several unit tests with new negotiation tests.<br><br>Change-Id: If07fe6d79fbdce33968a9401d41d908385043a06<br>---<br>M include/asterisk/sdp.h<br>M include/asterisk/sdp_options.h<br>M include/asterisk/sdp_state.h<br>M include/asterisk/stream.h<br>M main/sdp.c<br>M main/sdp_options.c<br>M main/sdp_private.h<br>M main/sdp_state.c<br>M main/stream.c<br>M res/res_sdp_translator_pjmedia.c<br>M tests/test_sdp.c<br>11 files changed, 3,400 insertions(+), 612 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/19/5819/3</pre><p>To view, visit <a href="https://gerrit.asterisk.org/5819">change 5819</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/5819"/><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: newpatchset </div>
<div style="display:none"> Gerrit-Change-Id: If07fe6d79fbdce33968a9401d41d908385043a06 </div>
<div style="display:none"> Gerrit-Change-Number: 5819 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>