aboutsummaryrefslogtreecommitdiffstats
path: root/rtp.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-02-25 04:10:32 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-02-25 04:10:32 +0000
commit91a49dbd77ef94e316d10913c950fbd3753581d2 (patch)
tree340405f4743954fc4f2662d43f2c3e532e541e8d /rtp.c
parentb343a418182009f512a145765c0ddde458e81cc0 (diff)
Add G.726-32kbps Codec Transcoder (Tested with Cisco ATA-186)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2239 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'rtp.c')
-rwxr-xr-xrtp.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/rtp.c b/rtp.c
index 888c83329..83bbfa8fb 100755
--- a/rtp.c
+++ b/rtp.c
@@ -468,6 +468,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
rtp->f.samples = 240 * (rtp->f.datalen / 50);
break;
case AST_FORMAT_ADPCM:
+ case AST_FORMAT_G726:
rtp->f.samples = rtp->f.datalen * 2;
break;
case AST_FORMAT_G729A:
@@ -912,7 +913,13 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
case AST_FORMAT_ALAW:
/* If we're within +/- 20ms from when where we
predict we should be, use that */
- pred = rtp->lastts + f->datalen;
+ pred = rtp->lastts + f->datalen * 2;
+ break;
+ case AST_FORMAT_ADPCM:
+ case AST_FORMAT_G726:
+ /* If we're within +/- 20ms from when where we
+ predict we should be, use that */
+ pred = rtp->lastts + f->datalen * 2;
break;
case AST_FORMAT_G729A:
pred = rtp->lastts + f->datalen * 8;
@@ -1028,6 +1035,19 @@ int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *_f)
while((f = ast_smoother_read(rtp->smoother)))
ast_rtp_raw_write(rtp, f, codec);
break;
+ case AST_FORMAT_G726:
+ if (!rtp->smoother) {
+ rtp->smoother = ast_smoother_new(80);
+ }
+ if (!rtp->smoother) {
+ ast_log(LOG_WARNING, "Unable to create smoother :(\n");
+ return -1;
+ }
+ ast_smoother_feed(rtp->smoother, _f);
+
+ while((f = ast_smoother_read(rtp->smoother)))
+ ast_rtp_raw_write(rtp, f, codec);
+ break;
case AST_FORMAT_G729A:
if (!rtp->smoother) {
rtp->smoother = ast_smoother_new(20);