summaryrefslogtreecommitdiff
path: root/apps/app_fax.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
committerDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
commitc26c190711a1bbe3b5fff1a93facae333757c56e (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /apps/app_fax.c
parent652fb64a01c7a8656697d07e606620ee0ced6929 (diff)
Asterisk media architecture conversion - no more format bitfields
This patch is the foundation of an entire new way of looking at media in Asterisk. The code present in this patch is everything required to complete phase1 of my Media Architecture proposal. For more information about this project visit the link below. https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal The primary function of this patch is to convert all the usages of format bitfields in Asterisk to use the new format and format_cap APIs. Functionally no change in behavior should be present in this patch. Thanks to twilson and russell for all the time they spent reviewing these changes. Review: https://reviewboard.asterisk.org/r/1083/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@306010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_fax.c')
-rw-r--r--apps/app_fax.c33
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);
}