Skip to content
Snippets Groups Projects
Commit 04426fab authored by Joshua Colp's avatar Joshua Colp
Browse files

Add support for G729 passthrough with Sigma Designs boards. (issue #8829 reported by ywalther)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51144 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 3d91c0a0
No related branches found
No related tags found
No related merge requests found
...@@ -61,6 +61,7 @@ Changes since Asterisk 1.4-beta was branched: ...@@ -61,6 +61,7 @@ Changes since Asterisk 1.4-beta was branched:
* Added the jittertargetextra configuration option. * Added the jittertargetextra configuration option.
* Added the URI redirect option for the built-in HTTP server * Added the URI redirect option for the built-in HTTP server
* Added the trunkmaxsize configuration option to chan_iax2. * Added the trunkmaxsize configuration option to chan_iax2.
* Added G729 passthrough support to chan_phone for Sigma Designs boards.
SIP changes SIP changes
----------- -----------
......
...@@ -98,7 +98,7 @@ static int echocancel = AEC_OFF; ...@@ -98,7 +98,7 @@ static int echocancel = AEC_OFF;
static int silencesupression = 0; static int silencesupression = 0;
static int prefformat = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW; static int prefformat = AST_FORMAT_G729A | AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW;
/* Protect the interface list (of phone_pvt's) */ /* Protect the interface list (of phone_pvt's) */
AST_MUTEX_DEFINE_STATIC(iflock); AST_MUTEX_DEFINE_STATIC(iflock);
...@@ -170,7 +170,7 @@ static int phone_indicate(struct ast_channel *chan, int condition, const void *d ...@@ -170,7 +170,7 @@ static int phone_indicate(struct ast_channel *chan, int condition, const void *d
static const struct ast_channel_tech phone_tech = { static const struct ast_channel_tech phone_tech = {
.type = "Phone", .type = "Phone",
.description = tdesc, .description = tdesc,
.capabilities = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, .capabilities = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_G729A,
.requester = phone_request, .requester = phone_request,
.send_digit_begin = phone_digit_begin, .send_digit_begin = phone_digit_begin,
.send_digit_end = phone_digit_end, .send_digit_end = phone_digit_end,
...@@ -399,8 +399,17 @@ static int phone_setup(struct ast_channel *ast) ...@@ -399,8 +399,17 @@ static int phone_setup(struct ast_channel *ast)
p = ast->tech_pvt; p = ast->tech_pvt;
ioctl(p->fd, PHONE_CPT_STOP); ioctl(p->fd, PHONE_CPT_STOP);
/* Nothing to answering really, just start recording */ /* Nothing to answering really, just start recording */
if (ast->rawreadformat == AST_FORMAT_G723_1) { if (ast->rawreadformat == AST_FORMAT_G729A) {
/* Prefer g723 */ /* Prefer g729 */
ioctl(p->fd, PHONE_REC_STOP);
if (p->lastinput != AST_FORMAT_G729A) {
p->lastinput = AST_FORMAT_G729A;
if (ioctl(p->fd, PHONE_REC_CODEC, G729)) {
ast_log(LOG_WARNING, "Failed to set codec to g729\n");
return -1;
}
}
} else if (ast->rawreadformat == AST_FORMAT_G723_1) {
ioctl(p->fd, PHONE_REC_STOP); ioctl(p->fd, PHONE_REC_STOP);
if (p->lastinput != AST_FORMAT_G723_1) { if (p->lastinput != AST_FORMAT_G723_1) {
p->lastinput = AST_FORMAT_G723_1; p->lastinput = AST_FORMAT_G723_1;
...@@ -667,7 +676,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame) ...@@ -667,7 +676,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
return 0; return 0;
} }
if (!(frame->subclass & if (!(frame->subclass &
(AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW)) && (AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_G729A)) &&
p->mode != MODE_FXS) { p->mode != MODE_FXS) {
ast_log(LOG_WARNING, "Cannot handle frames in %d format\n", frame->subclass); ast_log(LOG_WARNING, "Cannot handle frames in %d format\n", frame->subclass);
return -1; return -1;
...@@ -684,7 +693,30 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame) ...@@ -684,7 +693,30 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
return 0; return 0;
} }
#endif #endif
if (frame->subclass == AST_FORMAT_G723_1) { if (frame->subclass == AST_FORMAT_G729A) {
if (p->lastformat != AST_FORMAT_G729A) {
ioctl(p->fd, PHONE_PLAY_STOP);
ioctl(p->fd, PHONE_REC_STOP);
if (ioctl(p->fd, PHONE_PLAY_CODEC, G729)) {
ast_log(LOG_WARNING, "Unable to set G729 mode\n");
return -1;
}
if (ioctl(p->fd, PHONE_REC_CODEC, G729)) {
ast_log(LOG_WARNING, "Unable to set G729 mode\n");
return -1;
}
p->lastformat = AST_FORMAT_G729A;
p->lastinput = AST_FORMAT_G729A;
/* Reset output buffer */
p->obuflen = 0;
codecset = 1;
}
if (frame->datalen > 80) {
ast_log(LOG_WARNING, "Frame size too large for G.729 (%d bytes)\n", frame->datalen);
return -1;
}
maxfr = 80;
} else if (frame->subclass == AST_FORMAT_G723_1) {
if (p->lastformat != AST_FORMAT_G723_1) { if (p->lastformat != AST_FORMAT_G723_1) {
ioctl(p->fd, PHONE_PLAY_STOP); ioctl(p->fd, PHONE_PLAY_STOP);
ioctl(p->fd, PHONE_REC_STOP); ioctl(p->fd, PHONE_REC_STOP);
...@@ -1214,7 +1246,7 @@ static struct ast_channel *phone_request(const char *type, int format, void *dat ...@@ -1214,7 +1246,7 @@ static struct ast_channel *phone_request(const char *type, int format, void *dat
p = iflist; p = iflist;
while(p) { while(p) {
if (p->mode == MODE_FXS || if (p->mode == MODE_FXS ||
format & (AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW)) { format & (AST_FORMAT_G729A | AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW)) {
size_t length = strlen(p->dev + 5); size_t length = strlen(p->dev + 5);
if (strncmp(name, p->dev + 5, length) == 0 && if (strncmp(name, p->dev + 5, length) == 0 &&
!isalnum(name[length])) { !isalnum(name[length])) {
...@@ -1231,7 +1263,7 @@ static struct ast_channel *phone_request(const char *type, int format, void *dat ...@@ -1231,7 +1263,7 @@ static struct ast_channel *phone_request(const char *type, int format, void *dat
restart_monitor(); restart_monitor();
if (tmp == NULL) { if (tmp == NULL) {
oldformat = format; oldformat = format;
format &= (AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW); format &= (AST_FORMAT_G729A | AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW);
if (!format) { if (!format) {
ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat); ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat);
return NULL; return NULL;
...@@ -1382,7 +1414,9 @@ static int load_module(void) ...@@ -1382,7 +1414,9 @@ static int load_module(void)
} else if (!strcasecmp(v->name, "context")) { } else if (!strcasecmp(v->name, "context")) {
ast_copy_string(context, v->value, sizeof(context)); ast_copy_string(context, v->value, sizeof(context));
} else if (!strcasecmp(v->name, "format")) { } else if (!strcasecmp(v->name, "format")) {
if (!strcasecmp(v->value, "g723.1")) { if (!strcasecmp(v->value, "g729")) {
prefformat = AST_FORMAT_G729A;
} else if (!strcasecmp(v->value, "g723.1")) {
prefformat = AST_FORMAT_G723_1; prefformat = AST_FORMAT_G723_1;
} else if (!strcasecmp(v->value, "slinear")) { } else if (!strcasecmp(v->value, "slinear")) {
if (mode == MODE_FXS) if (mode == MODE_FXS)
......
...@@ -18,12 +18,14 @@ mode=immediate ...@@ -18,12 +18,14 @@ mode=immediate
;mode=fxo ;mode=fxo
;mode=sig ;mode=sig
; ;
; You can decide which format to use by default, "g723.1" or "slinear". ; You can decide which format to use by default, "g723.1", "g729", or "slinear".
; Note that g729 is only supported for Sigma Designs boards.
; XXX Be careful, sometimes the card causes kernel panics when running ; XXX Be careful, sometimes the card causes kernel panics when running
; in signed linear mode for some reason... XXX ; in signed linear mode for some reason... XXX
; ;
format=slinear format=slinear
;format=g723.1 ;format=g723.1
;format=g729
; ;
; And set the echo cancellation to "off", "low", "medium", and "high". ; And set the echo cancellation to "off", "low", "medium", and "high".
; This is not supported on all phones. ; This is not supported on all phones.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment