<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://reviewboard.asterisk.org/r/1894/">https://reviewboard.asterisk.org/r/1894/</a>
     </td>
    </tr>
   </table>
   <br />


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers.</div>
<div>By rmudgett.</div>





<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The masquerade torture test (ASTERISK-19807) is a long chain of local channels to be optimized out of a call when answered.
This patch fixes local channel so it can successfully optimize itself out when there are chains of channels.

The principle problem was check_bridge() failed to check the ast_channel_masquerade() return value to see if the masquerade was actually setup.  In long chains of local channels, the masquerade occasionally fails to get setup because there is another masquerade already setup on an adjacent local channel in the chain.

* Checks the return value of ast_channel_masquerade().

* Made sure that the outgoing local channel (the ;2 channel) also does not have any frames in its queue before the masquerade.

* The outgoing channel will flush one voice or video frame per optimization attempt.

* Do the masquerade immediately to ensure that the outgoing channel queue does not get any new frames added and thus unconditionally flushed.

* Blocks indication -1 (Stop tones event) when the local channel is going to optimize itself out.  When the call is answered, a chain of local channels pass down a -1 indication for each bridge.  This blizzard of -1 events really slows down the optimization process.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Chains of 100 local channels now are able to optimize themselves out.</pre>
  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/branches/1.8/channels/chan_local.c <span style="color: grey">(364846)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/1894/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>




  </div>
 </body>
</html>