<h1>Project "FreeSWITCH Source" received a push.</h1>

<h2>branch: master updated</h2>
<pre>
       via: a126cc7f16479578d76cf6395ff92697d021274c (commit)
      from: 4ef6280a05cea21e52a4be29fb31d33aa50a19a7 (commit)


</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
add param to jb to try to recapture latency (disabled by default)

<span style="color: #000080; font-weight: bold">diff --git a/libs/stfu/stfu.c b/libs/stfu/stfu.c</span>
<span style="color: #000080; font-weight: bold">index d2c443a..f00dfaf 100644</span>
<span style="color: #A00000">--- a/libs/stfu/stfu.c</span>
<span style="color: #00A000">+++ b/libs/stfu/stfu.c</span>
<span style="color: #800080; font-weight: bold">@@ -102,7 +102,10 @@ struct stfu_instance {</span>
 
     int32_t ts_offset;
     int32_t ts_drift;
<span style="color: #A00000">-    </span>
<span style="color: #00A000">+    int32_t max_drift;</span>
<span style="color: #00A000">+    uint32_t drift_dropped_packets;</span>
<span style="color: #00A000">+    uint32_t drift_max_dropped;</span>
<span style="color: #00A000">+</span>
     int32_t ts_diff;
     int32_t last_ts_diff;
     int32_t same_ts;
<span style="color: #800080; font-weight: bold">@@ -258,7 +261,7 @@ stfu_status_t stfu_n_resize(stfu_instance_t *i, uint32_t qlen)</span>
     return s;
 }
 
<span style="color: #A00000">-stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second)</span>
<span style="color: #00A000">+stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift_ms)</span>
 {
         struct stfu_instance *i;
 
<span style="color: #800080; font-weight: bold">@@ -277,6 +280,12 @@ stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_</span>
         stfu_n_init_aqueue(&amp;i-&gt;b_queue, qlen);
         stfu_n_init_aqueue(&amp;i-&gt;c_queue, qlen);
 
<span style="color: #00A000">+    i-&gt;max_drift = (int32_t)(max_drift_ms * (samples_per_second / 1000) * -1);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+    if (max_drift_ms &amp;&amp; samples_per_packet) {</span>
<span style="color: #00A000">+        i-&gt;drift_max_dropped = (samples_per_second * 2) / samples_per_packet;</span>
<span style="color: #00A000">+    }</span>
<span style="color: #00A000">+</span>
         i-&gt;in_queue = &amp;i-&gt;a_queue;
         i-&gt;out_queue = &amp;i-&gt;b_queue;
         i-&gt;old_queue = &amp;i-&gt;c_queue;
<span style="color: #800080; font-weight: bold">@@ -396,6 +405,9 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void</span>
         if (i-&gt;last_ts_diff == i-&gt;ts_diff) {
             if (++i-&gt;same_ts == 5) {
                 i-&gt;samples_per_packet = i-&gt;ts_diff;
<span style="color: #00A000">+                if (i-&gt;max_drift &amp;&amp; i-&gt;samples_per_packet) {</span>
<span style="color: #00A000">+                    i-&gt;drift_max_dropped = (i-&gt;samples_per_second * 2) / i-&gt;samples_per_packet;</span>
<span style="color: #00A000">+                }</span>
             }
         } else {
             i-&gt;same_ts = 0;
<span style="color: #800080; font-weight: bold">@@ -409,11 +421,24 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void</span>
         }
     }
  
<span style="color: #A00000">-    if (timer_ts &amp;&amp; ts &amp;&amp; !i-&gt;ts_offset) {</span>
<span style="color: #A00000">-        i-&gt;ts_offset = timer_ts - ts;</span>
<span style="color: #A00000">-    }</span>
<span style="color: #00A000">+    if (timer_ts) {</span>
<span style="color: #00A000">+        if (ts &amp;&amp; !i-&gt;ts_offset) {</span>
<span style="color: #00A000">+            i-&gt;ts_offset = timer_ts - ts;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        i-&gt;ts_drift = ts + (i-&gt;ts_offset - timer_ts);</span>
 
<span style="color: #A00000">-    i-&gt;ts_drift = ts + (i-&gt;ts_offset - timer_ts);</span>
<span style="color: #00A000">+        if (i-&gt;max_drift) {</span>
<span style="color: #00A000">+            if (i-&gt;ts_drift &lt; i-&gt;max_drift) {</span>
<span style="color: #00A000">+                if (++i-&gt;drift_dropped_packets &lt; i-&gt;drift_max_dropped) {</span>
<span style="color: #00A000">+                    stfu_log(STFU_LOG_EMERG, &quot;%s TOO LATE !!! %u \n\n\n&quot;, i-&gt;name, ts);</span>
<span style="color: #00A000">+                    return STFU_ITS_TOO_LATE;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+            } else {</span>
<span style="color: #00A000">+                i-&gt;drift_dropped_packets = 0;</span>
<span style="color: #00A000">+            }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+    }</span>
 
     if (i-&gt;sync_in) {
         good_ts = 1;
<span style="color: #800080; font-weight: bold">@@ -493,12 +518,12 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void</span>
     
 
     if (stfu_log != null_logger &amp;&amp; i-&gt;debug) {
<span style="color: #A00000">-        stfu_log(STFU_LOG_EMERG, &quot;I: %s %u i=%u/%u - g:%u/%u c:%u/%u b:%u - %u:%u - %u %d %u %u %d %d %d\n&quot;, i-&gt;name,</span>
<span style="color: #00A000">+        stfu_log(STFU_LOG_EMERG, &quot;I: %s %u i=%u/%u - g:%u/%u c:%u/%u b:%u - %u:%u - %u %d %u %u %d %d %d/%d\n&quot;, i-&gt;name,</span>
                  i-&gt;qlen, i-&gt;period_packet_in_count, i-&gt;period_time, i-&gt;consecutive_good_count, 
                  i-&gt;decrement_time, i-&gt;period_clean_count, i-&gt;decrement_time, i-&gt;consecutive_bad_count,
                  ts, ts / i-&gt;samples_per_packet, 
                  i-&gt;period_missing_count, i-&gt;period_need_range_avg,
<span style="color: #A00000">-                 i-&gt;last_wr_ts, ts, i-&gt;diff, i-&gt;diff_total / least1(i-&gt;period_packet_in_count), i-&gt;ts_drift);</span>
<span style="color: #00A000">+                 i-&gt;last_wr_ts, ts, i-&gt;diff, i-&gt;diff_total / least1(i-&gt;period_packet_in_count), i-&gt;ts_drift, i-&gt;max_drift);</span>
     }
 
         if (last || i-&gt;in_queue-&gt;array_len == i-&gt;in_queue-&gt;array_size) {
<span style="color: #800080; font-weight: bold">@@ -597,7 +622,7 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i)</span>
     
     if (!i-&gt;ready) {
         if (stfu_log != null_logger &amp;&amp; i-&gt;debug) {
<span style="color: #A00000">-            stfu_log(STFU_LOG_EMERG, &quot;%s XXXSKIP\n&quot;, i-&gt;name);</span>
<span style="color: #00A000">+            stfu_log(STFU_LOG_EMERG, &quot;%s JITTERBUFFER NOT READY: IGNORING FRAME\n&quot;, i-&gt;name);</span>
         }
         return NULL;
     }
<span style="color: #800080; font-weight: bold">@@ -612,7 +637,7 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i)</span>
             }
             if (i-&gt;cur_ts == 0) {
                 if (stfu_log != null_logger &amp;&amp; i-&gt;debug) {
<span style="color: #A00000">-                    stfu_log(STFU_LOG_EMERG, &quot;%s XXXPUNT\n&quot;, i-&gt;name);</span>
<span style="color: #00A000">+                    stfu_log(STFU_LOG_EMERG, &quot;%s JITTERBUFFER ERROR: PUNTING\n&quot;, i-&gt;name);</span>
                     return NULL;
                 }
             }
<span style="color: #000080; font-weight: bold">diff --git a/libs/stfu/stfu.h b/libs/stfu/stfu.h</span>
<span style="color: #000080; font-weight: bold">index b92bb3f..d8fbf44 100644</span>
<span style="color: #A00000">--- a/libs/stfu/stfu.h</span>
<span style="color: #00A000">+++ b/libs/stfu/stfu.h</span>
<span style="color: #800080; font-weight: bold">@@ -179,7 +179,7 @@ typedef void (*stfu_n_call_me_t)(stfu_instance_t *i, void *);</span>
 
 void stfu_n_report(stfu_instance_t *i, stfu_report_t *r);
 void stfu_n_destroy(stfu_instance_t **i);
<span style="color: #A00000">-stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second);</span>
<span style="color: #00A000">+stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift_ms);</span>
 stfu_status_t stfu_n_resize(stfu_instance_t *i, uint32_t qlen);
 stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void *data, size_t datalen, uint32_t timer_ts, int last);
 stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i);
</pre></div>
========================================================================<pre>

Summary of changes:
 libs/stfu/stfu.c |   45 +++++++++++++++++++++++++++++++++++----------
 libs/stfu/stfu.h |    2 +-
 2 files changed, 36 insertions(+), 11 deletions(-)
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH Source</p>