diff options
Diffstat (limited to 'apps/app_fax.c')
-rw-r--r-- | apps/app_fax.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/apps/app_fax.c b/apps/app_fax.c index 54d22db16..ce8541910 100644 --- a/apps/app_fax.c +++ b/apps/app_fax.c @@ -329,9 +329,9 @@ static int fax_generator_generate(struct ast_channel *chan, void *data, int len, struct ast_frame outf = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_SLINEAR, .src = __FUNCTION__, }; + ast_format_set(&outf.subclass.format, AST_FORMAT_SLINEAR, 0); if (samples > MAX_SAMPLES) { ast_log(LOG_WARNING, "Only generating %d samples, where %d requested\n", MAX_SAMPLES, samples); @@ -362,8 +362,8 @@ static struct ast_generator generator = { static int transmit_audio(fax_session *s) { int res = -1; - int original_read_fmt = AST_FORMAT_SLINEAR; - int original_write_fmt = AST_FORMAT_SLINEAR; + struct ast_format original_read_fmt; + struct ast_format original_write_fmt; fax_state_t fax; t30_state_t *t30state; struct ast_frame *inf = NULL; @@ -383,6 +383,9 @@ static int transmit_audio(fax_session *s) */ }; + ast_format_clear(&original_read_fmt); + ast_format_clear(&original_write_fmt); + /* if in called party mode, try to use T.38 */ if (s->caller_mode == FALSE) { /* check if we are already in T.38 mode (unlikely), or if we can request @@ -455,18 +458,18 @@ static int transmit_audio(fax_session *s) t30state = &fax.t30_state; #endif - original_read_fmt = s->chan->readformat; - if (original_read_fmt != AST_FORMAT_SLINEAR) { - res = ast_set_read_format(s->chan, AST_FORMAT_SLINEAR); + ast_format_copy(&original_read_fmt, &s->chan->readformat); + if (original_read_fmt.id != AST_FORMAT_SLINEAR) { + res = ast_set_read_format_by_id(s->chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set to linear read mode, giving up\n"); goto done; } } - original_write_fmt = s->chan->writeformat; - if (original_write_fmt != AST_FORMAT_SLINEAR) { - res = ast_set_write_format(s->chan, AST_FORMAT_SLINEAR); + ast_format_copy(&original_write_fmt, &s->chan->writeformat); + if (original_write_fmt.id != AST_FORMAT_SLINEAR) { + res = ast_set_write_format_by_id(s->chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set to linear write mode, giving up\n"); goto done; @@ -523,12 +526,12 @@ static int transmit_audio(fax_session *s) break; } - ast_debug(10, "frame %d/%llu, len=%d\n", inf->frametype, (unsigned long long) inf->subclass.codec, inf->datalen); + ast_debug(10, "frame %d/%u, len=%d\n", inf->frametype, (unsigned int) inf->subclass.format.id, inf->datalen); /* Check the frame type. Format also must be checked because there is a chance that a frame in old format was already queued before we set channel format to slinear so it will still be received by ast_read */ - if (inf->frametype == AST_FRAME_VOICE && inf->subclass.codec == AST_FORMAT_SLINEAR) { + if (inf->frametype == AST_FRAME_VOICE && inf->subclass.format.id == AST_FORMAT_SLINEAR) { if (fax_rx(&fax, inf->data.ptr, inf->samples) < 0) { /* I know fax_rx never returns errors. The check here is for good style only */ ast_log(LOG_WARNING, "fax_rx returned error\n"); @@ -582,13 +585,13 @@ static int transmit_audio(fax_session *s) fax_release(&fax); done: - if (original_write_fmt != AST_FORMAT_SLINEAR) { - if (ast_set_write_format(s->chan, original_write_fmt) < 0) + if (original_write_fmt.id != AST_FORMAT_SLINEAR) { + if (ast_set_write_format(s->chan, &original_write_fmt) < 0) ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", s->chan->name); } - if (original_read_fmt != AST_FORMAT_SLINEAR) { - if (ast_set_read_format(s->chan, original_read_fmt) < 0) + if (original_read_fmt.id != AST_FORMAT_SLINEAR) { + if (ast_set_read_format(s->chan, &original_read_fmt) < 0) ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", s->chan->name); } |