[asterisk-commits] file: branch file/bridging r79620 - /team/file/bridging/bridges/bridge_zaptel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Aug 15 15:17:04 CDT 2007
Author: file
Date: Wed Aug 15 15:17:03 2007
New Revision: 79620
URL: http://svn.digium.com/view/asterisk?view=rev&rev=79620
Log:
Add support for accepting ulaw/alaw audio for mixing.
Modified:
team/file/bridging/bridges/bridge_zaptel.c
Modified: team/file/bridging/bridges/bridge_zaptel.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/bridges/bridge_zaptel.c?view=diff&rev=79620&r1=79619&r2=79620
==============================================================================
--- team/file/bridging/bridges/bridge_zaptel.c (original)
+++ team/file/bridging/bridges/bridge_zaptel.c Wed Aug 15 15:17:03 2007
@@ -124,7 +124,7 @@
struct zaptel_mixer *zm = bridge->bridge_pvt;
int fd = -1;
struct zt_confinfo ztc = { 0, };
- int flags = 0, x = 1;
+ int flags = 0, x = 0;
ZT_BUFFERINFO bi;
/* Attempt to open the pseudo channel */
@@ -150,10 +150,22 @@
return -1;
}
+ /* If the bridge negotiated the channel to signed linear set the zaptel channel to it, otherwise we are in a *law format */
+ x = (bridge_channel->chan->readformat == AST_FORMAT_SLINEAR ? 1 : 0);
+
/* Set linear mode */
if (ioctl(fd, ZT_SETLINEAR, &x)) {
close(fd);
return -1;
+ }
+
+ /* If we didn't end up being in signed linear we need to set which *law format we are in */
+ if (!x) {
+ x = (bridge_channel->chan->readformat == AST_FORMAT_ULAW ? ZT_LAW_MULAW : ZT_LAW_ALAW);
+ if (ioctl(fd, ZT_SETLAW, &x)) {
+ close(fd);
+ return -1;
+ }
}
/* Add us to the conference */
@@ -204,10 +216,10 @@
if ((res = read(fd, buf, CONF_SIZE)) > 0) {
struct ast_frame out_frame = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass = bridge_channel->chan->readformat,
.data = buf,
.datalen = res,
- .samples = res/2,
+ .samples = (bridge_channel->chan->readformat == AST_FORMAT_SLINEAR ? res/2 : res),
.offset = AST_FRIENDLY_OFFSET,
};
ast_write(bridge_channel->chan, ast_frdup(&out_frame));
@@ -220,7 +232,7 @@
.name = "zaptel_bridge",
.capabilities = AST_BRIDGE_CAPABILITY_MULTIMIX | AST_BRIDGE_CAPABILITY_MULTITHREADED,
.preference = AST_BRIDGE_PREFERENCE_HIGH,
- .formats = AST_FORMAT_SLINEAR,
+ .formats = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW,
.create = zaptel_bridge_create,
.destroy = zaptel_bridge_destroy,
.join = zaptel_bridge_join,
More information about the asterisk-commits
mailing list