mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-20 20:44:20 +00:00
Fix segfault when building peer based on IP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6846 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2129,7 +2129,8 @@ static void update_jbsched(struct chan_iax2_pvt *pvt) {
|
|||||||
pvt->jbid = ast_sched_add(sched, when, get_from_jb, (void *)pvt);
|
pvt->jbid = ast_sched_add(sched, when, get_from_jb, (void *)pvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_from_jb(void *p) {
|
static int get_from_jb(void *p)
|
||||||
|
{
|
||||||
/* make sure pvt is valid! */
|
/* make sure pvt is valid! */
|
||||||
struct chan_iax2_pvt *pvt = p;
|
struct chan_iax2_pvt *pvt = p;
|
||||||
struct iax_frame *fr;
|
struct iax_frame *fr;
|
||||||
@@ -2152,49 +2153,49 @@ static int get_from_jb(void *p) {
|
|||||||
now = ast_tvdiff_ms(tv, pvt->rxcore);
|
now = ast_tvdiff_ms(tv, pvt->rxcore);
|
||||||
|
|
||||||
if(now >= (next = jb_next(pvt->jb))) {
|
if(now >= (next = jb_next(pvt->jb))) {
|
||||||
ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
|
ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
|
||||||
switch(ret) {
|
switch(ret) {
|
||||||
case JB_OK:
|
case JB_OK:
|
||||||
/*if(frame.type == JB_TYPE_VOICE && next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
|
/*if(frame.type == JB_TYPE_VOICE && next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
|
||||||
fr = frame.data;
|
fr = frame.data;
|
||||||
__do_deliver(fr);
|
__do_deliver(fr);
|
||||||
break;
|
break;
|
||||||
case JB_INTERP:
|
case JB_INTERP:
|
||||||
{
|
{
|
||||||
struct ast_frame af;
|
struct ast_frame af;
|
||||||
|
|
||||||
/*if(next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
|
/*if(next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
|
||||||
|
|
||||||
/* create an interpolation frame */
|
/* create an interpolation frame */
|
||||||
/*fprintf(stderr, "Making Interpolation frame\n"); */
|
/*fprintf(stderr, "Making Interpolation frame\n"); */
|
||||||
af.frametype = AST_FRAME_VOICE;
|
af.frametype = AST_FRAME_VOICE;
|
||||||
af.subclass = pvt->voiceformat;
|
af.subclass = pvt->voiceformat;
|
||||||
af.datalen = 0;
|
af.datalen = 0;
|
||||||
af.samples = frame.ms * 8;
|
af.samples = frame.ms * 8;
|
||||||
af.mallocd = 0;
|
af.mallocd = 0;
|
||||||
af.src = "IAX2 JB interpolation";
|
af.src = "IAX2 JB interpolation";
|
||||||
af.data = NULL;
|
af.data = NULL;
|
||||||
af.delivery = ast_tvadd(pvt->rxcore, ast_samp2tv(next, 1000));
|
af.delivery = ast_tvadd(pvt->rxcore, ast_samp2tv(next, 1000));
|
||||||
af.offset=AST_FRIENDLY_OFFSET;
|
af.offset=AST_FRIENDLY_OFFSET;
|
||||||
|
|
||||||
/* queue the frame: For consistency, we would call __do_deliver here, but __do_deliver wants an iax_frame,
|
/* queue the frame: For consistency, we would call __do_deliver here, but __do_deliver wants an iax_frame,
|
||||||
* which we'd need to malloc, and then it would free it. That seems like a drag */
|
* which we'd need to malloc, and then it would free it. That seems like a drag */
|
||||||
if (iaxs[pvt->callno] && !ast_test_flag(iaxs[pvt->callno], IAX_ALREADYGONE))
|
if (iaxs[pvt->callno] && !ast_test_flag(iaxs[pvt->callno], IAX_ALREADYGONE))
|
||||||
iax2_queue_frame(pvt->callno, &af);
|
iax2_queue_frame(pvt->callno, &af);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JB_DROP:
|
case JB_DROP:
|
||||||
/*if(next != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not next %ld!\n", jb_next(pvt->jb), next); */
|
/*if(next != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not next %ld!\n", jb_next(pvt->jb), next); */
|
||||||
iax2_frame_free(frame.data);
|
iax2_frame_free(frame.data);
|
||||||
break;
|
break;
|
||||||
case JB_NOFRAME:
|
case JB_NOFRAME:
|
||||||
case JB_EMPTY:
|
case JB_EMPTY:
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* shouldn't happen */
|
/* shouldn't happen */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_jbsched(pvt);
|
update_jbsched(pvt);
|
||||||
ast_mutex_unlock(&iaxsl[pvt->callno]);
|
ast_mutex_unlock(&iaxsl[pvt->callno]);
|
||||||
@@ -2533,6 +2534,15 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
|
|||||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
|
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
|
||||||
sprintf(porta, "%d", ntohs(sin->sin_port));
|
sprintf(porta, "%d", ntohs(sin->sin_port));
|
||||||
var = ast_load_realtime("iaxpeers", "ipaddr", iabuf, "port", porta, NULL);
|
var = ast_load_realtime("iaxpeers", "ipaddr", iabuf, "port", porta, NULL);
|
||||||
|
if (var) {
|
||||||
|
/* We'll need the peer name in order to build the structure! */
|
||||||
|
tmp = var;
|
||||||
|
while(tmp) {
|
||||||
|
if (!strcasecmp(tmp->name, "name"))
|
||||||
|
peername = tmp->value;
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!var)
|
if (!var)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user