aboutsummaryrefslogtreecommitdiffstats
path: root/main/jitterbuf.c
diff options
context:
space:
mode:
authormnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-10 17:52:42 +0000
committermnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-10 17:52:42 +0000
commit87baafa18b327efd5fe1647059110e13207d3fd0 (patch)
tree6b243581e20a47912e0afb9912454c8a9fc13719 /main/jitterbuf.c
parentaa82d132a4a22e1526a48bb0c83596f18662bef6 (diff)
Improve behavior of jitterbuffer when maxjitterbuffer is set.
This change improves the way the jitterbuffer handles maxjitterbuffer and dramatically reduces the number of frames dropped when maxjitterbuffer is exceeded. In the previous jitterbuffer, when maxjitterbuffer was exceeded, all new frames were dropped until the jitterbuffer is empty. This change modifies the code to only drop frames until maxjitterbuffer is no longer exceeded. Also, previously when maxjitterbuffer was exceeded, dropped frames were not tracked causing stats for dropped frames to be incorrect, this change also addresses that problem. (closes issue #14044) Patches: bug14044-1.diff uploaded by mnicholson (license 96) Tested by: mnicholson Review: http://reviewboard.digium.com/r/144/ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@174583 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/jitterbuf.c')
-rw-r--r--main/jitterbuf.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/main/jitterbuf.c b/main/jitterbuf.c
index 849cffab5..6a4172e07 100644
--- a/main/jitterbuf.c
+++ b/main/jitterbuf.c
@@ -516,27 +516,33 @@ enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type t
jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now);
- jb->info.frames_in++;
+ numts = 0;
+ if (jb->frames)
+ numts = jb->frames->prev->ts - jb->frames->ts;
- if (jb->frames && jb->dropem)
+ if (numts >= jb->info.conf.max_jitterbuf) {
+ if (!jb->dropem) {
+ ast_log(LOG_DEBUG, "Attempting to exceed Jitterbuf max %ld timeslots\n",
+ jb->info.conf.max_jitterbuf);
+ jb->dropem = 1;
+ }
+ jb->info.frames_dropped++;
return JB_DROP;
- jb->dropem = 0;
+ } else {
+ jb->dropem = 0;
+ }
if (type == JB_TYPE_VOICE) {
/* presently, I'm only adding VOICE frames to history and drift calculations; mostly because with the
* IAX integrations, I'm sending retransmitted control frames with their awkward timestamps through */
- if (history_put(jb,ts,now,ms))
+ if (history_put(jb,ts,now,ms)) {
+ jb->info.frames_dropped++;
return JB_DROP;
+ }
}
- numts = 0;
- if (jb->frames)
- numts = jb->frames->prev->ts - jb->frames->ts;
- if (numts >= jb->info.conf.max_jitterbuf) {
- ast_log(LOG_DEBUG, "Attempting to exceed Jitterbuf max %ld timeslots\n",
- jb->info.conf.max_jitterbuf);
- jb->dropem = 1;
- return JB_DROP;
- }
+
+ jb->info.frames_in++;
+
/* if put into head of queue, caller needs to reschedule */
if (queue_put(jb,data,type,ms,ts)) {
return JB_SCHED;