|
|
@ -2240,11 +2240,12 @@ static int get_from_jb(void *p)
|
|
|
|
|
|
|
|
|
|
|
|
/* while we transition from the old JB to the new one, we can either make two schedule_delivery functions, or
|
|
|
|
/* while we transition from the old JB to the new one, we can either make two schedule_delivery functions, or
|
|
|
|
* make preprocessor swiss-cheese out of this one. I'm not sure which is less revolting.. */
|
|
|
|
* make preprocessor swiss-cheese out of this one. I'm not sure which is less revolting.. */
|
|
|
|
static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtrunk)
|
|
|
|
static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtrunk, unsigned int *tsout)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef NEWJB
|
|
|
|
#ifdef NEWJB
|
|
|
|
int type, len;
|
|
|
|
int type, len;
|
|
|
|
int ret;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
int needfree = 0;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
int x;
|
|
|
|
int x;
|
|
|
|
int ms;
|
|
|
|
int ms;
|
|
|
@ -2267,7 +2268,7 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
|
|
|
|
|
|
|
|
|
|
|
|
/* Attempt to recover wrapped timestamps */
|
|
|
|
/* Attempt to recover wrapped timestamps */
|
|
|
|
unwrap_timestamp(fr);
|
|
|
|
unwrap_timestamp(fr);
|
|
|
|
|
|
|
|
|
|
|
|
if (updatehistory) {
|
|
|
|
if (updatehistory) {
|
|
|
|
#ifndef NEWJB
|
|
|
|
#ifndef NEWJB
|
|
|
|
|
|
|
|
|
|
|
@ -2365,8 +2366,10 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( (!ast_test_flag(iaxs[fr->callno], IAX_USEJITTERBUF)) ) {
|
|
|
|
if ( (!ast_test_flag(iaxs[fr->callno], IAX_USEJITTERBUF)) ) {
|
|
|
|
|
|
|
|
if (tsout)
|
|
|
|
|
|
|
|
*tsout = fr->ts;
|
|
|
|
__do_deliver(fr);
|
|
|
|
__do_deliver(fr);
|
|
|
|
return 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* if the user hasn't requested we force the use of the jitterbuffer, and we're bridged to
|
|
|
|
/* if the user hasn't requested we force the use of the jitterbuffer, and we're bridged to
|
|
|
@ -2388,8 +2391,10 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
|
|
|
|
iaxs[fr->callno]->jbid = -1;
|
|
|
|
iaxs[fr->callno]->jbid = -1;
|
|
|
|
|
|
|
|
|
|
|
|
/* deliver this frame now */
|
|
|
|
/* deliver this frame now */
|
|
|
|
|
|
|
|
if (tsout)
|
|
|
|
|
|
|
|
*tsout = fr->ts;
|
|
|
|
__do_deliver(fr);
|
|
|
|
__do_deliver(fr);
|
|
|
|
return 0;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2399,7 +2404,7 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
|
|
|
|
ret = jb_put(iaxs[fr->callno]->jb, fr, type, len, fr->ts,
|
|
|
|
ret = jb_put(iaxs[fr->callno]->jb, fr, type, len, fr->ts,
|
|
|
|
calc_rxstamp(iaxs[fr->callno],fr->ts));
|
|
|
|
calc_rxstamp(iaxs[fr->callno],fr->ts));
|
|
|
|
if (ret == JB_DROP) {
|
|
|
|
if (ret == JB_DROP) {
|
|
|
|
iax2_frame_free(fr);
|
|
|
|
needfree++;
|
|
|
|
} else if (ret == JB_SCHED) {
|
|
|
|
} else if (ret == JB_SCHED) {
|
|
|
|
update_jbsched(iaxs[fr->callno]);
|
|
|
|
update_jbsched(iaxs[fr->callno]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2468,13 +2473,15 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
|
|
|
|
if ((delay > -4) || (fr->af.frametype != AST_FRAME_VOICE)) {
|
|
|
|
if ((delay > -4) || (fr->af.frametype != AST_FRAME_VOICE)) {
|
|
|
|
if (option_debug && iaxdebug)
|
|
|
|
if (option_debug && iaxdebug)
|
|
|
|
ast_log(LOG_DEBUG, "schedule_delivery: Delivering immediately (Calculated delay is %d)\n", delay);
|
|
|
|
ast_log(LOG_DEBUG, "schedule_delivery: Delivering immediately (Calculated delay is %d)\n", delay);
|
|
|
|
|
|
|
|
if (tsout)
|
|
|
|
|
|
|
|
*tsout = fr->ts;
|
|
|
|
__do_deliver(fr);
|
|
|
|
__do_deliver(fr);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (option_debug && iaxdebug)
|
|
|
|
if (option_debug && iaxdebug)
|
|
|
|
ast_log(LOG_DEBUG, "schedule_delivery: Dropping voice packet since %dms delay is too old\n", delay);
|
|
|
|
ast_log(LOG_DEBUG, "schedule_delivery: Dropping voice packet since %dms delay is too old\n", delay);
|
|
|
|
iaxs[fr->callno]->frames_dropped++;
|
|
|
|
iaxs[fr->callno]->frames_dropped++;
|
|
|
|
/* Free our iax frame */
|
|
|
|
needfree++;
|
|
|
|
iax2_frame_free(fr);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (option_debug && iaxdebug)
|
|
|
|
if (option_debug && iaxdebug)
|
|
|
@ -2482,6 +2489,13 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
|
|
|
|
fr->retrans = ast_sched_add(sched, delay, do_deliver, fr);
|
|
|
|
fr->retrans = ast_sched_add(sched, delay, do_deliver, fr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (tsout)
|
|
|
|
|
|
|
|
*tsout = fr->ts;
|
|
|
|
|
|
|
|
if (needfree) {
|
|
|
|
|
|
|
|
/* Free our iax frame */
|
|
|
|
|
|
|
|
iax2_frame_free(fr);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -6396,15 +6410,13 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
duped_fr = iaxfrdup2(&fr);
|
|
|
|
duped_fr = iaxfrdup2(&fr);
|
|
|
|
if (duped_fr) {
|
|
|
|
if (duped_fr) {
|
|
|
|
schedule_delivery(duped_fr, updatehistory, 1);
|
|
|
|
schedule_delivery(duped_fr, updatehistory, 1, &fr.ts);
|
|
|
|
fr.ts = duped_fr->ts;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
duped_fr = iaxfrdup2(&fr);
|
|
|
|
duped_fr = iaxfrdup2(&fr);
|
|
|
|
if (duped_fr) {
|
|
|
|
if (duped_fr) {
|
|
|
|
schedule_delivery(duped_fr, updatehistory, 1);
|
|
|
|
schedule_delivery(duped_fr, updatehistory, 1, &fr.ts);
|
|
|
|
fr.ts = duped_fr->ts;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (iaxs[fr.callno]->last < fr.ts) {
|
|
|
|
if (iaxs[fr.callno]->last < fr.ts) {
|
|
|
@ -7591,15 +7603,13 @@ retryowner2:
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
duped_fr = iaxfrdup2(&fr);
|
|
|
|
duped_fr = iaxfrdup2(&fr);
|
|
|
|
if (duped_fr) {
|
|
|
|
if (duped_fr) {
|
|
|
|
schedule_delivery(duped_fr, updatehistory, 0);
|
|
|
|
schedule_delivery(duped_fr, updatehistory, 0, &fr.ts);
|
|
|
|
fr.ts = duped_fr->ts;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
duped_fr = iaxfrdup2(&fr);
|
|
|
|
duped_fr = iaxfrdup2(&fr);
|
|
|
|
if (duped_fr) {
|
|
|
|
if (duped_fr) {
|
|
|
|
schedule_delivery(duped_fr, updatehistory, 0);
|
|
|
|
schedule_delivery(duped_fr, updatehistory, 0, &fr.ts);
|
|
|
|
fr.ts = duped_fr->ts;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|