diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-07-09 15:37:05 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-07-09 15:37:05 +0000 |
commit | 97e083be4bc51f35a7f6bb34ce9e0df08011d515 (patch) | |
tree | a831e07e6c1f87c29a10f8e2aa6e49049716c621 /channels/chan_iax2.c | |
parent | 56bb1be892c00d64dfcc8b41565dcfc06bb0a3df (diff) |
Merged revisions 205479 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r205479 | dvossel | 2009-07-08 18:19:09 -0500 (Wed, 08 Jul 2009) | 16 lines
Merged revisions 205471 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r205471 | dvossel | 2009-07-08 18:15:54 -0500 (Wed, 08 Jul 2009) | 10 lines
Fixes 8khz assumptions
Many calculations assume 8khz is the codec rate. This
is not always the case. This patch only addresses chan_iax.c
and res_rtp_asterisk.c, but I am sure there are other areas
that make this assumption as well.
Review: https://reviewboard.asterisk.org/r/306/
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@205595 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r-- | channels/chan_iax2.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 82b2e6122..81dddcd5a 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -3181,7 +3181,7 @@ static void __get_from_jb(const void *p) /* create an interpolation frame */ af.frametype = AST_FRAME_VOICE; af.subclass = pvt->voiceformat; - af.samples = frame.ms * 8; + af.samples = frame.ms * (ast_format_rate(pvt->voiceformat) / 1000); af.src = "IAX2 JB interpolation"; af.delivery = ast_tvadd(pvt->rxcore, ast_samp2tv(next, 1000)); af.offset = AST_FRIENDLY_OFFSET; @@ -3253,7 +3253,7 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr if(fr->af.frametype == AST_FRAME_VOICE) { type = JB_TYPE_VOICE; - len = ast_codec_get_samples(&fr->af) / 8; + len = ast_codec_get_samples(&fr->af) / (ast_format_rate(fr->af.subclass) / 1000); } else if(fr->af.frametype == AST_FRAME_CNG) { type = JB_TYPE_SILENCE; } @@ -4601,6 +4601,7 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str int voice = 0; int genuine = 0; int adjust; + int rate = ast_format_rate(f->subclass) / 1000; struct timeval *delivery = NULL; @@ -4668,7 +4669,7 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str p->offset = ast_tvadd(p->offset, ast_samp2tv(adjust, 10000)); if (!p->nextpred) { - p->nextpred = ms; /*f->samples / 8;*/ + p->nextpred = ms; /*f->samples / rate;*/ if (p->nextpred <= p->lastsent) p->nextpred = p->lastsent + 3; } @@ -4687,11 +4688,11 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str ast_debug(1, "predicted timestamp skew (%u) > max (%u), using real ts instead.\n", abs(ms - p->nextpred), MAX_TIMESTAMP_SKEW); - if (f->samples >= 8) /* check to make sure we dont core dump */ + if (f->samples >= rate) /* check to make sure we dont core dump */ { - int diff = ms % (f->samples / 8); + int diff = ms % (f->samples / rate); if (diff) - ms += f->samples/8 - diff; + ms += f->samples/rate - diff; } p->nextpred = ms; @@ -4723,7 +4724,7 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str } p->lastsent = ms; if (voice) - p->nextpred = p->nextpred + f->samples / 8; + p->nextpred = p->nextpred + f->samples / rate; return ms; } |