<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=TOP&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/TOP/Media+Negotiator+Design">Media Negotiator Design</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~khunt">Ken Hunt</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{warning}This page describes design details of a component not yet developed. In fact, the Service Locator will probably actually be the component that implements the services that were previously envisioned here. {warning} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. Overview <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This page describes design details of a component not yet developed. In fact, the Service Locator will probably actually be the component that implements the services that were previously envisioned here.</td></tr></table></div>

<h3><a name="MediaNegotiatorDesign-Overview"></a>Overview</h3>

<p>The Media Negotiator provides a central facility for registration of media operation components and for creation of paths to fulfill requested media operations. Any component wishing to have operations performed on media using available media operations components must contact the media negotiator which will determine the components to use.</p>

<p>If you are interested in the original UML file it is available <a href="/wiki/download/attachments/2129955/Media+Negotiator+Design.uml?version=4&amp;modificationDate=1278616105012">here</a>.</p>

<p>Events for the media negotiator are listed in the slice definition for events <a href="/wiki/download/attachments/2129955/media_negotiator_events.ice?version=1&amp;modificationDate=1278431351498">here</a>.</p>

<h3><a name="MediaNegotiatorDesign-Interfaces"></a>Interfaces</h3>

<p>The MediaOperationService interface is implemented by the media negotiator, media components, and media component comparators for purposes of allocating a media operation session using specific operations or for seeing what operations of a given sequence are supported.</p>

<p>The MediaNegotiatorManagement interface is implemented by the media negotiator and is used by media components and media component comparators to register themselves.</p>

<p>The MediaNegotiatorOperationManagement interface is implemented by the media negotiator and is used by a media component to manage itself in the media negotiator. It is used by the media component to add supported operations, suspend itself, unsuspend itself, and unregister itself.</p>

<p>The MediaNegotiatorComparatorManagement interface is implemented by the media negotiator and is used by a media component comparator to unregister itself from the media negotiator.</p>

<h3><a name="MediaNegotiatorDesign-PublicClasses"></a>Public Classes</h3>

<p>The MediaOperation class is meant to be used as a concrete class that is extended with lower level knowledge of a requested operation. The media negotiator will do a comparison as best it can before passing this unaltered to the comparator if one was specified when the operations were added.</p>

<p>The MediaOperationQueryResult class is meant to be used as a concrete class containing an operation and a score (between 1 and 100) that the media negotiator can use when sorting paths and choosing the "best" one.</p>

<h3><a name="MediaNegotiatorDesign-PrivateClasses"></a>Private Classes</h3>

<p>The MediaNegotiatorOperationSpec class is internal to the media negotiator and is used to store operations that a media component supports.</p>

<h3><a name="MediaNegotiatorDesign-Design"></a>Design</h3>

<p><span class="image-wrap" style=""><img src="/wiki/download/attachments/2129955/Media_Negotiator_Design.jpg?version=6&amp;modificationDate=1278682779606" style="border: 1px solid black" /></span></p>

<p>The media negotiator is based around the premise of having media components register to a central component that performs the decision making of how to build paths of operations. The downside of this approach is that the central component may need to contact a specialized component to determine if an operation is supported by the media component. This is accomplished in this design by allowing additional components that perform this comparison to register with the media negotiator using an identifier. This identifier will need to be specified somehow in both the media component and specialized component configuration.</p>

<p>When a component needs to have media operations performed it contacts the media negotiator giving it an ordered list of operations it wants done. The media negotiator takes this list, iterates through available media components checking to see what is supported (including potentially contacting another component to do the comparison), determines the possible paths to accomplish the requested operations, and then sorts them based on criteria (such as best supported, least number of media<br/>
components involved, etc). Once sorted it picks the best one and allocates as needed. If allocation fails each previously allocated operation is freed and an alternate path is chosen.</p>

<p>Once a component shuts down it needs to call into the media negotiator to unregister itself.</p>

<p>This design also has API calls which permit a media component to suspend and unsuspend itself. This could prove useful for media components that only support a finite number of concurrent operations.</p>

<p>Finding the media negotiator will be left up to component discovery.</p>

<h3><a name="MediaNegotiatorDesign-MediaComponentRegistrationDiagram"></a>Media Component Registration Diagram</h3>

<p><span class="image-wrap" style=""><img src="/wiki/download/attachments/2129955/Media+Handler+Registration.jpg?version=3&amp;modificationDate=1278616104946" style="border: 1px solid black" /></span></p>

<p>This diagram shows a media component registering to the media negotiator and providing supported operations.</p>

<ol>
        <li>The initial step is to get a proxy to the media negotiator using service discovery.</li>
        <li>The media component then calls the addService method with a proxy to its own media operation service.</li>
        <li>The media negotiator instantiates a MediaNegotiatorOperationManagementImpl object and adds it to a vector.</li>
        <li>The media negotiator returns a proxy to the MediaNegotiatorOperationManagementImpl object to the media component.</li>
        <li>The media component populates a sequence with supported operations.</li>
        <li>The media component calls addSupported on the MediaNegotiatorOperationManagementImpl object proxy with the sequence and a comparator unique identifier.</li>
        <li>The media negotiator instantiates a MediaNegotiatorOperationSpec object and adds it to a vector.</li>
        <li>The media negotiator returns nothing to the media component.</li>
        <li>The media component populates a sequence with different supported operations.</li>
        <li>The media component calls addSupported on the MediaNegotiatorOperationManagementImpl object proxy with the sequence and comparator unique identifier.</li>
        <li>The media negotiator instantiates a MediaNegotiatorOperationSpec object and adds it to a vector.</li>
        <li>The media negotiator returns nothing to the media component.</li>
</ol>


<h3><a name="MediaNegotiatorDesign-MediaComparatorRegistrationDiagram"></a>Media Comparator Registration Diagram</h3>

<p><span class="image-wrap" style=""><img src="/wiki/download/attachments/2129955/Media+Compare+Registration.jpg?version=3&amp;modificationDate=1278616104990" style="border: 1px solid black" /></span></p>

<p>This diagram shows a media component comparator registering to the media negotiator.</p>

<ol>
        <li>The initial step is to get a proxy to the media negotiator using service discovery.</li>
        <li>The media component comparator then calls the addCompare method with a proxy to its own media operation service and a unique identifier.</li>
        <li>The media negotiator instantiates a MediaNegotiatorComparatorImpl object and adds it to a map using the unique identifier.</li>
        <li>The media negotiator returns a proxy to the MediaNegotiatorComparatorImpl object to the media component comparator.</li>
</ol>


<h3><a name="MediaNegotiatorDesign-MediaAllocationDiagram"></a>Media Allocation Diagram</h3>

<p><span class="image-wrap" style=""><img src="/wiki/download/attachments/2129955/Media+Allocation.jpg?version=4&amp;modificationDate=1278616105052" style="border: 1px solid black" /></span></p>

<p>This diagram shows a bridging service utilizing the media negotiator for purposes of manipulating media using a media component.</p>

<ol>
        <li>The initial step is to get a proxy to the media negotiator using service discovery.</li>
        <li>The bridging service populates a sequence with media operations it wants the returning session to provide.</li>
        <li>The bridging service then calls the Allocate method with the above mentioned sequence.</li>
        <li>The MediaNegotiatorManagementImpl object begins iterating through the vector of MediaNegotiatorOperationManagementImpl objects.</li>
        <li>The media negotiator calls isSupported on the MediaNegotiatorOperationManagementImpl object.</li>
        <li>The media negotiator begins iterating through the vector of MediaNegotiatorOperationSpec objects.</li>
        <li>The media negotiator calls isSupported on the MediaNegotiatorOperationSpec object.</li>
        <li>The MediaNegotiatorOperationSpec isSupported implementation performs a basic comparison to see what requested operations are supported.</li>
        <li>If any are supported the MediaNegotiatorOperationSpec isSupported implementation finds the media component comparator using the unique identifier that was given when the MediaNegotiatorOperationSpec was instantiated.</li>
        <li>The media negotiator calls isSupported on the MediaNegotiatorComparatorManagementImpl object.</li>
        <li>The MediaNegotiatorComparatorManagementImpl isSupported implementation calls the isSupported method on the comparator proxy.</li>
        <li>The media component comparator isSupported implementation returns a result sequence with operations supported and a score for each.</li>
        <li>The result sequence is passed all the way back to the MediaNegotiatorManagementImpl object.</li>
        <li>The media negotiator sees that the requested operations are supported.</li>
        <li>The media negotiator calls getService on the MediaNegotiatorOperationManagementImpl object to get a proxy to the media component operation service.</li>
        <li>The media negotiator calls Allocate on the media component operation service proxy and passes in the sequence of supported operations.</li>
        <li>The media component operation service returns a proxy to a media operation session.</li>
        <li>The media negotiator returns the proxy to the media operation session to the bridging service.</li>
</ol>



<h3><a name="MediaNegotiatorDesign-PotentialLocationsofHooks"></a>Potential Locations of Hooks</h3>

<p>1. Sorting of possible graphs. An external component may want to apply its own logic to determine what graph should be used.<br/>
2. Adding of supported media operations. An external component may want to limit what is supported.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=TOP">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/TOP/Media+Negotiator+Design">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=2129955&revisedVersion=23&originalVersion=22">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/TOP/Media+Negotiator+Design?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>