]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fixed problem with jitterbuf, whereas it would not complain about, and
authorJim Dixon <telesistant@hotmail.com>
Mon, 29 Jan 2007 04:18:36 +0000 (04:18 +0000)
committerJim Dixon <telesistant@hotmail.com>
Mon, 29 Jan 2007 04:18:36 +0000 (04:18 +0000)
would allow itself to be overfilled (per the max_jitterbuf parameter). Now
it rejects any data over and above that size, and complains about it.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@52494 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/jitterbuf.h
main/jitterbuf.c

index 3213534d023feb5f486878db4d92614ba9eb3533..5694f7b6c3b4627048519efc7a88ff3435f66c03 100644 (file)
@@ -103,6 +103,7 @@ typedef struct jitterbuf {
        long hist_maxbuf[JB_HISTORY_MAXBUF_SZ]; /* a sorted buffer of the max delays (highest first) */
        long hist_minbuf[JB_HISTORY_MAXBUF_SZ]; /* a sorted buffer of the min delays (lowest first) */
        int  hist_maxbuf_valid;                 /* are the "maxbuf"/minbuf valid? */
+       int  dropem;                            /* flag to indicate dropping frames (overload) */
 
 
        jb_frame *frames;               /* queued frames */
index 05e29a4a473e6a6df546f8cfacfbb8d9660b9b64..f87e273b6726df4cd3f4588909d22227443c624c 100644 (file)
@@ -512,17 +512,30 @@ static void jb_dbgqueue(jitterbuf *jb)
 
 enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now) 
 {
+       long numts;
+
        jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now);
 
        jb->info.frames_in++;
 
+        if (jb->frames && jb->dropem) return(JB_DROP);
+        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))
                        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_NOTICE,"Attempting to exceed Jitterbuf max %ld timeslots\n",jb->info.conf.max_jitterbuf);
+                jb->dropem = 1;
+                return JB_DROP;
+        }
        /* if put into head of queue, caller needs to reschedule */
        if (queue_put(jb,data,type,ms,ts)) {
                return JB_SCHED;