convert uses of LOG_DEBUG to use ast_debug()
[asterisk/asterisk.git] / channels / chan_unistim.c
index b3d5ca4..39e3e00 100644 (file)
@@ -202,6 +202,17 @@ static void dummy(char *dummy, ...)
        return;
 }
 
+/*! \brief Global jitterbuffer configuration - by default, jb is disabled */
+static struct ast_jb_conf default_jbconf =
+{
+        .flags = 0,
+       .max_size = -1,
+       .resync_threshold = -1,
+       .impl = ""
+};
+static struct ast_jb_conf global_jbconf;
+                               
+
 /* #define DUMP_PACKET 1 */
 /* #define DEBUG_TIMER ast_verbose */
 
@@ -697,7 +708,7 @@ static const struct ast_channel_tech unistim_tech = {
        .type = type,
        .description = tdesc,
        .capabilities = CAPABILITY,
-       .properties = AST_CHAN_TP_WANTSJITTER,
+       .properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
        .requester = unistim_request,
        .call = unistim_call,
        .hangup = unistim_hangup,
@@ -1546,7 +1557,7 @@ static int unalloc_sub(struct unistim_line *p, int x)
                return -1;
        }
        if (unistimdebug)
-               ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", x, p->name,
+               ast_debug(1, "Released sub %d of channel %s@%s\n", x, p->name,
                                p->parent->name);
        ast_mutex_destroy(&p->lock);
        ast_free(p->subs[x]);
@@ -2475,7 +2486,7 @@ static void HandleCallOutgoing(struct unistimsession *s)
                                         p->subs[SUB_THREEWAY]->owner, p->subs[SUB_THREEWAY]->owner->name,
                                         p->subs[SUB_THREEWAY]->subtype);
                } else
-                       ast_log(LOG_DEBUG, "Current sub [%s] already has owner\n", sub->owner->name);
+                       ast_debug(1, "Current sub [%s] already has owner\n", sub->owner->name);
        }
        return;
 }
@@ -3507,7 +3518,7 @@ static void process_request(int size, unsigned char *buf, struct unistimsession
        strcpy(tmpbuf, ast_inet_ntoa(pte->sin.sin_addr));
        strcat(tmpbuf, " Unknown request packet\n");
        if (unistimdebug)
-               ast_log(LOG_DEBUG, tmpbuf);
+               ast_debug(1, "%s", tmpbuf);
        return;
 }
 
@@ -3765,7 +3776,7 @@ static int unistim_hangup(struct ast_channel *ast)
        s = channel_to_session(ast);
        sub = ast->tech_pvt;
        if (!s) {
-               ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+               ast_debug(1, "Asked to hangup channel not connected\n");
                ast_mutex_lock(&sub->lock);
                sub->owner = NULL;
                ast->tech_pvt = NULL;
@@ -3984,7 +3995,7 @@ static struct ast_frame *unistim_rtp_read(const struct ast_channel *ast,
                /* We already hold the channel lock */
                if (f->frametype == AST_FRAME_VOICE) {
                        if (f->subclass != sub->owner->nativeformats) {
-                               ast_log(LOG_DEBUG,
+                               ast_debug(1,
                                                "Oooh, format changed from %s (%d) to %s (%d)\n",
                                                ast_getformatname(sub->owner->nativeformats),
                                                sub->owner->nativeformats, ast_getformatname(f->subclass),
@@ -4055,7 +4066,7 @@ static int unistim_fixup(struct ast_channel *oldchan, struct ast_channel *newcha
 
        ast_mutex_lock(&p->lock);
 
-       ast_log(LOG_DEBUG, "New owner for channel USTM/%s@%s-%d is %s\n", l->name,
+       ast_debug(1, "New owner for channel USTM/%s@%s-%d is %s\n", l->name,
                        l->parent->name, p->subtype, newchan->name);
 
        if (p->owner != oldchan) {
@@ -4509,6 +4520,9 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
                tmp->fds[0] = ast_rtp_fd(sub->rtp);
                tmp->fds[1] = ast_rtcp_fd(sub->rtp);
        }
+       if (sub->rtp)
+               ast_jb_configure(tmp, &global_jbconf);
+               
 /*      tmp->type = type; */
        ast_setstate(tmp, state);
        if (state == AST_STATE_RING)
@@ -5353,11 +5367,18 @@ static int reload_config(void)
                ast_log(LOG_ERROR, "Unable to load config %s\n", config);
                return -1;
        }
+       
+       /* Copy the default jb config over global_jbconf */
+       memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
 
        unistim_keepalive = 120;
        unistim_port = 0;
        v = ast_variable_browse(cfg, "general");
        while (v) {
+               /* handle jb conf */
+               if (!ast_jb_read_conf(&global_jbconf, v->name, v->value))
+                       continue;       
+       
                if (!strcasecmp(v->name, "keepalive"))
                        unistim_keepalive = atoi(v->value);
                else if (!strcasecmp(v->name, "port"))