[asterisk-commits] branch group/rtpjitterbuffer r26980 -
/team/group/rtpjitterbuffer/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu May 11 09:51:00 MST 2006
Author: russell
Date: Thu May 11 11:51:00 2006
New Revision: 26980
URL: http://svn.digium.com/view/asterisk?rev=26980&view=rev
Log:
just formatting
Modified:
team/group/rtpjitterbuffer/abstract_jb.c
team/group/rtpjitterbuffer/channel.c
Modified: team/group/rtpjitterbuffer/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/team/group/rtpjitterbuffer/abstract_jb.c?rev=26980&r1=26979&r2=26980&view=diff
==============================================================================
--- team/group/rtpjitterbuffer/abstract_jb.c (original)
+++ team/group/rtpjitterbuffer/abstract_jb.c Thu May 11 11:51:00 2006
@@ -157,7 +157,7 @@
/*! \brief Macros for JB logs */
/*#define jb_verbose(...) ast_verbose(VERBOSE_PREFIX_3 " ***[JB LOG]*** " __VA_ARGS__)*/
-#define jb_verbose(...) if(1){\
+#define jb_verbose(...) if (1){\
char tmp[192];\
char msg[128];\
snprintf(msg, sizeof(msg), VERBOSE_PREFIX_3 "***[JB LOG]*** " __VA_ARGS__);\
@@ -165,7 +165,7 @@
/*! \brief Macros for the frame log files */
#define jb_framelog(...) \
-if(jb->logfile) \
+if (jb->logfile) \
{ \
fprintf(jb->logfile, __VA_ARGS__); \
fflush(jb->logfile); \
@@ -191,12 +191,12 @@
jb->impl = &avail_impl[default_impl];
- if(*jbconf->impl == '\0')
+ if (*jbconf->impl == '\0')
return;
for(i=0; i<avail_impl_count; i++) {
test_impl = &avail_impl[i];
- if(strcmp(jbconf->impl, test_impl->name) == 0) {
+ if (strcmp(jbconf->impl, test_impl->name) == 0) {
jb->impl = test_impl;
return;
}
@@ -222,11 +222,12 @@
int c1_force_jb = ast_test_flag(conf1, AST_JB_FORCED);
int c1_jb_timebase_initialized = ast_test_flag(jb1, JB_TIMEBASE_INITIALIZED);
int c1_jb_created = ast_test_flag(jb1, JB_CREATED);
-
- if(((!c0_wants_jitter && c1_creates_jitter) || c0_force_jb) && c0_jb_enabled) {
+
+ /* Determine whether audio going to c0 needs a jitter buffer */
+ if (((!c0_wants_jitter && c1_creates_jitter) || c0_force_jb) && c0_jb_enabled) {
ast_set_flag(jb0, JB_USE);
- if(!c0_jb_timebase_initialized) {
- if(c1_jb_timebase_initialized) {
+ if (!c0_jb_timebase_initialized) {
+ if (c1_jb_timebase_initialized) {
memcpy(&jb0->timebase, &jb1->timebase, sizeof(struct timeval));
} else {
gettimeofday(&jb0->timebase, NULL);
@@ -234,15 +235,16 @@
ast_set_flag(jb0, JB_TIMEBASE_INITIALIZED);
}
- if(!c0_jb_created) {
+ if (!c0_jb_created) {
jb_choose_impl(c0);
}
}
- if(((!c1_wants_jitter && c0_creates_jitter) || c1_force_jb) && c1_jb_enabled) {
+ /* Determine whether audio going to c1 needs a jitter buffer */
+ if (((!c1_wants_jitter && c0_creates_jitter) || c1_force_jb) && c1_jb_enabled) {
ast_set_flag(jb1, JB_USE);
- if(!c1_jb_timebase_initialized) {
- if(c0_jb_timebase_initialized) {
+ if (!c1_jb_timebase_initialized) {
+ if (c0_jb_timebase_initialized) {
memcpy(&jb1->timebase, &jb0->timebase, sizeof(struct timeval));
} else {
gettimeofday(&jb1->timebase, NULL);
@@ -250,12 +252,11 @@
ast_set_flag(jb1, JB_TIMEBASE_INITIALIZED);
}
- if(!c1_jb_created) {
+ if (!c1_jb_created) {
jb_choose_impl(c1);
}
}
}
-
int ast_jb_get_when_to_wakeup(struct ast_channel *c0, struct ast_channel *c1, int time_left)
{
@@ -268,13 +269,13 @@
int wait, wait0, wait1;
struct timeval tv_now;
- if(time_left == 0) {
+ if (time_left == 0) {
/* No time left - the bridge will be retried */
/* TODO: Test disable this */
/*return 0;*/
}
- if(time_left < 0) {
+ if (time_left < 0) {
time_left = INT_MAX;
}
@@ -286,9 +287,9 @@
wait = wait0 < wait1 ? wait0 : wait1;
wait = wait < time_left ? wait : time_left;
- if(wait == INT_MAX) {
+ if (wait == INT_MAX) {
wait = -1;
- } else if(wait < 1) {
+ } else if (wait < 1) {
/* don't let wait=0, because this can cause the pbx thread to loop without any sleeping at all */
wait = 1;
}
@@ -305,12 +306,12 @@
struct ast_frame *frr;
long now = 0;
- if(!ast_test_flag(jb, JB_USE)) {
+ if (!ast_test_flag(jb, JB_USE)) {
return -1;
}
- if(f->frametype != AST_FRAME_VOICE) {
- if(f->frametype == AST_FRAME_DTMF && ast_test_flag(jb, JB_CREATED)) {
+ if (f->frametype != AST_FRAME_VOICE) {
+ if (f->frametype == AST_FRAME_DTMF && ast_test_flag(jb, JB_CREATED)) {
jb_framelog("JB_PUT {now=%ld}: Received DTMF frame. Force resynching jb...\n", now);
jbimpl->force_resync(jbobj);
}
@@ -319,24 +320,24 @@
}
/* We consider an enabled jitterbuffer should receive frames with valid timing info. */
- if(!f->has_timing_info || f->len < 2 || f->ts < 0) {
+ if (!f->has_timing_info || f->len < 2 || f->ts < 0) {
ast_log(LOG_WARNING, "Recieved frame with invalid timing info: "
"has_timing_info=%d, len=%ld, ts=%ld\n", f->has_timing_info, f->len, f->ts);
return -1;
}
- if(f->mallocd & AST_MALLOCD_HDR) {
+ if (f->mallocd & AST_MALLOCD_HDR) {
frr = ast_frdup(f);
} else {
frr = ast_frisolate(f);
}
- if(frr == NULL) {
+ if (frr == NULL) {
ast_log(LOG_ERROR, "Failed to isolate frame for the jitterbuffer on channel '%s'\n", chan->name);
return -1;
}
- if(!ast_test_flag(jb, JB_CREATED)) {
- if(create_jb(chan, frr)) {
+ if (!ast_test_flag(jb, JB_CREATED)) {
+ if (create_jb(chan, frr)) {
ast_frfree(frr);
/* Disable the jitterbuffer */
ast_clear_flag(jb, JB_USE);
@@ -347,7 +348,7 @@
return 0;
} else {
now = get_now(jb, NULL);
- if(jbimpl->put(jbobj, frr, now) != JB_IMPL_OK) {
+ if (jbimpl->put(jbobj, frr, now) != JB_IMPL_OK) {
jb_framelog("JB_PUT {now=%ld}: Dropped frame with ts=%ld and len=%ld\n", now, frr->ts, frr->len);
ast_frfree(frr);
/*return -1;*/
@@ -374,11 +375,11 @@
int c1_use_jb = ast_test_flag(jb1, JB_USE);
int c1_jb_is_created = ast_test_flag(jb1, JB_CREATED);
- if(c0_use_jb && c0_jb_is_created) {
+ if (c0_use_jb && c0_jb_is_created) {
jb_get_and_deliver(c0);
}
- if(c1_use_jb && c1_jb_is_created) {
+ if (c1_use_jb && c1_jb_is_created) {
jb_get_and_deliver(c1);
}
}
@@ -395,7 +396,7 @@
now = get_now(jb, NULL);
jb->next = jbimpl->next(jbobj);
- if(now < jb->next) {
+ if (now < jb->next) {
jb_framelog("\tJB_GET {now=%ld}: now < next=%ld\n", now, jb->next);
return;
}
@@ -461,7 +462,7 @@
int res;
jbobj = jb->jbobj = jbimpl->create(jbconf, jbconf->resync_threshold);
- if(jbobj == NULL) {
+ if (jbobj == NULL) {
ast_log(LOG_WARNING, "Failed to create jitterbuffer on channel '%s'\n", chan->name);
return -1;
}
@@ -471,7 +472,7 @@
/* The result of putting the first frame should not differ from OK. However, its possible
some implementations (i.e. stevek's when resynch_threshold is specified) to drop it. */
- if(res != JB_IMPL_OK) {
+ if (res != JB_IMPL_OK) {
ast_log(LOG_WARNING, "Failed to put first frame in the jitterbuffer on channel '%s'\n", chan->name);
/*
jbimpl->destroy(jbobj);
@@ -486,31 +487,31 @@
jb->last_format = frr->subclass;
/* Create a frame log file */
- if(ast_test_flag(jbconf, AST_JB_LOG)) {
+ if (ast_test_flag(jbconf, AST_JB_LOG)) {
snprintf(name2, sizeof(name2), "%s", chan->name);
tmp = strchr(name2, '/');
- if(tmp != NULL) {
+ if (tmp != NULL) {
*tmp = '#';
}
bridged = ast_bridged_channel(chan);
- if(bridged == NULL) {
+ if (bridged == NULL) {
/* We should always have bridged chan if a jitterbuffer is in use */
CRASH;
}
snprintf(name1, sizeof(name1), "%s", bridged->name);
tmp = strchr(name1, '/');
- if(tmp != NULL) {
+ if (tmp != NULL) {
*tmp = '#';
}
snprintf(logfile_pathname, sizeof(logfile_pathname),
"/tmp/ast_%s_jb_%s--%s.log", jbimpl->name, name1, name2);
jb->logfile = fopen(logfile_pathname, "w+b");
- if(jb->logfile == NULL) {
+ if (jb->logfile == NULL) {
ast_log(LOG_WARNING, "Failed to create frame log file with pathname '%s'\n", logfile_pathname);
}
- if(res == JB_IMPL_OK) {
+ if (res == JB_IMPL_OK) {
jb_framelog("JB_PUT_FIRST {now=%ld}: Queued frame with ts=%ld and len=%ld\n",
now, frr->ts, frr->len);
} else {
@@ -522,7 +523,7 @@
jb_verbose("%s jitterbuffer created on channel %s", jbimpl->name, chan->name);
/* Free the frame if it has not been queued in the jb */
- if(res != JB_IMPL_OK) {
+ if (res != JB_IMPL_OK) {
ast_frfree(frr);
}
@@ -537,12 +538,12 @@
void *jbobj = jb->jbobj;
struct ast_frame *f;
- if(jb->logfile != NULL) {
+ if (jb->logfile != NULL) {
fclose(jb->logfile);
jb->logfile = NULL;
}
- if(ast_test_flag(jb, JB_CREATED)) {
+ if (ast_test_flag(jb, JB_CREATED)) {
/* Remove and free all frames still queued in jb */
while(jbimpl->remove(jbobj, &f) == JB_IMPL_OK) {
ast_frfree(f);
@@ -562,7 +563,7 @@
{
struct timeval now;
- if(tv == NULL) {
+ if (tv == NULL) {
tv = &now;
gettimeofday(tv, NULL);
}
@@ -581,39 +582,39 @@
char *name;
int tmp;
- if(memcmp(AST_JB_CONF_PREFIX, varname, prefixlen) != 0) {
+ if (memcmp(AST_JB_CONF_PREFIX, varname, prefixlen) != 0) {
return -1;
}
name = varname + prefixlen;
- if(strcmp(name, AST_JB_CONF_ENABLE) == 0) {
- if(ast_true(value)) {
+ if (strcmp(name, AST_JB_CONF_ENABLE) == 0) {
+ if (ast_true(value)) {
conf->flags |= AST_JB_ENABLED;
}
}
- else if(strcmp(name, AST_JB_CONF_FORCE) == 0) {
- if(ast_true(value)) {
+ else if (strcmp(name, AST_JB_CONF_FORCE) == 0) {
+ if (ast_true(value)) {
conf->flags |= AST_JB_FORCED;
}
}
- else if(strcmp(name, AST_JB_CONF_MAX_SIZE) == 0) {
- if((tmp = atoi(value)) > 0) {
+ else if (strcmp(name, AST_JB_CONF_MAX_SIZE) == 0) {
+ if ((tmp = atoi(value)) > 0) {
conf->max_size = tmp;
}
}
- else if(strcmp(name, AST_JB_CONF_RESYNCH_THRESHOLD) == 0) {
- if((tmp = atoi(value)) > 0) {
+ else if (strcmp(name, AST_JB_CONF_RESYNCH_THRESHOLD) == 0) {
+ if ((tmp = atoi(value)) > 0) {
conf->resync_threshold = tmp;
}
}
- else if(strcmp(name, AST_JB_CONF_IMPL) == 0) {
- if(*value) {
+ else if (strcmp(name, AST_JB_CONF_IMPL) == 0) {
+ if (*value) {
snprintf(conf->impl, sizeof(conf->impl), "%s", value);
}
}
- else if(strcmp(name, AST_JB_CONF_LOG) == 0) {
- if(ast_true(value)) {
+ else if (strcmp(name, AST_JB_CONF_LOG) == 0) {
+ if (ast_true(value)) {
conf->flags |= AST_JB_LOG;
}
} else {
@@ -738,7 +739,7 @@
jitterbuf *stevekjb;
stevekjb = jb_new();
- if(stevekjb != NULL) {
+ if (stevekjb != NULL) {
jbconf.max_jitterbuf = general_config->max_size;
jbconf.resync_threshold = general_config->resync_threshold;
jbconf.max_contig_interp = 10;
Modified: team/group/rtpjitterbuffer/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/rtpjitterbuffer/channel.c?rev=26980&r1=26979&r2=26980&view=diff
==============================================================================
--- team/group/rtpjitterbuffer/channel.c (original)
+++ team/group/rtpjitterbuffer/channel.c Thu May 11 11:51:00 2006
@@ -3405,7 +3405,7 @@
#endif
#ifdef AST_JB
/* Write immediately frames, not passed through jb */
- if(!frame_put_in_jb)
+ if (!frame_put_in_jb)
ast_write((who == c0) ? c1 : c0, f);
/* Check if we have to deliver now */
More information about the asterisk-commits
mailing list