<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8855">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Richard Mudgett: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bridge_softmix: Fix some REMB bugs.<br><br>This change fixes a bug where a REMB collector may be<br>freed twice, and also tweaks REMB combining such that if<br>there is no bitrate from anyone (or there are no sources)<br>we report 0 instead of using an old bitrate.<br><br>ASTERISK-27804<br><br>Change-Id: Ia9dc9c150043890ee7ff85e9cdec007f1a77fcfd<br>---<br>M bridges/bridge_softmix.c<br>1 file changed, 21 insertions(+), 13 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c<br>index f0a3fb4..ed88b7c 100644<br>--- a/bridges/bridge_softmix.c<br>+++ b/bridges/bridge_softmix.c<br>@@ -1318,6 +1318,12 @@<br>                  break;<br>                }<br>     }<br>+<br>+ /* After the report is integrated we reset this to 0 in case they stop producing<br>+      * REMB reports.<br>+      */<br>+  sc->remb.br_mantissa = 0;<br>+ sc->remb.br_exp = 0;<br> }<br> <br> static void remb_send_report(struct ast_bridge_channel *bridge_channel, struct softmix_channel *sc)<br>@@ -1328,20 +1334,18 @@<br>                 return;<br>       }<br> <br>- /* If we have a new bitrate then use it for the REMB, if not we use the previous<br>-      * one until we know otherwise. This way the bitrate doesn't drop to 0 all of a sudden.<br>+  /* We always do this calculation as even when the bitrate is zero the browser<br>+         * still prefers it to be accurate instead of lying.<br>   */<br>-  if (sc->remb_collector->bitrate) {<br>-             sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->bitrate;<br>-             sc->remb_collector->feedback.remb.br_exp = 0;<br>+  sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->bitrate;<br>+     sc->remb_collector->feedback.remb.br_exp = 0;<br> <br>-               /* The mantissa only has 18 bits available, so while it exceeds them we bump<br>-          * up the exp.<br>-                */<br>-          while (sc->remb_collector->feedback.remb.br_mantissa > 0x3ffff) {<br>-                   sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->feedback.remb.br_mantissa >> 1;<br>-                        sc->remb_collector->feedback.remb.br_exp++;<br>-            }<br>+    /* The mantissa only has 18 bits available, so while it exceeds them we bump<br>+  * up the exp.<br>+        */<br>+  while (sc->remb_collector->feedback.remb.br_mantissa > 0x3ffff) {<br>+           sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->feedback.remb.br_mantissa >> 1;<br>+                sc->remb_collector->feedback.remb.br_exp++;<br>     }<br> <br>  for (i = 0; i < AST_VECTOR_SIZE(&bridge_channel->stream_map.to_bridge); ++i) {<br>@@ -2062,6 +2066,7 @@<br>       struct ast_bridge_channel *participant;<br>       struct ast_vector_int media_types;<br>    int nths[AST_MEDIA_TYPE_END] = {0};<br>+  int idx;<br> <br>   switch (bridge->softmix.video_mode.mode) {<br>         case AST_BRIDGE_VIDEO_MODE_NONE:<br>@@ -2080,7 +2085,10 @@<br>       * When channels end up getting added back in they'll reuse their existing<br>         * collector and won't need to allocate a new one (unless they were just added).<br>   */<br>-  AST_VECTOR_RESET(&softmix_data->remb_collectors, ao2_cleanup);<br>+        for (idx = 0; idx < AST_VECTOR_SIZE(&softmix_data->remb_collectors); ++idx) {<br>+              ao2_cleanup(AST_VECTOR_GET(&softmix_data->remb_collectors, idx));<br>+             AST_VECTOR_REPLACE(&softmix_data->remb_collectors, idx, NULL);<br>+        }<br> <br>  /* First traversal: re-initialize all of the participants' stream maps */<br>         AST_LIST_TRAVERSE(&bridge->channels, participant, entry) {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8855">change 8855</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/8855"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15.4 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ia9dc9c150043890ee7ff85e9cdec007f1a77fcfd </div>
<div style="display:none"> Gerrit-Change-Number: 8855 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </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: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>