diff options
author | David Vossel <dvossel@digium.com> | 2011-02-03 16:22:10 +0000 |
---|---|---|
committer | David Vossel <dvossel@digium.com> | 2011-02-03 16:22:10 +0000 |
commit | c26c190711a1bbe3b5fff1a93facae333757c56e (patch) | |
tree | 00da0caa5a07b7b25729f089dbcafb08129fa9be /apps/app_talkdetect.c | |
parent | 652fb64a01c7a8656697d07e606620ee0ced6929 (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_talkdetect.c')
-rw-r--r-- | apps/app_talkdetect.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c index 615929e94..545261c72 100644 --- a/apps/app_talkdetect.c +++ b/apps/app_talkdetect.c @@ -87,7 +87,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data) int analysistime = -1; int continue_analysis = 1; int x; - int origrformat = 0; + struct ast_format origrformat; struct ast_dsp *dsp = NULL; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(filename); @@ -96,7 +96,8 @@ static int background_detect_exec(struct ast_channel *chan, const char *data) AST_APP_ARG(max); AST_APP_ARG(analysistime); ); - + + ast_format_clear(&origrformat); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "BackgroundDetect requires an argument (filename)\n"); return -1; @@ -126,8 +127,8 @@ static int background_detect_exec(struct ast_channel *chan, const char *data) } } - origrformat = chan->readformat; - if ((ast_set_read_format(chan, AST_FORMAT_SLINEAR))) { + ast_format_copy(&origrformat, &chan->readformat); + if ((ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR))) { ast_log(LOG_WARNING, "Unable to set read format to linear!\n"); res = -1; break; @@ -182,7 +183,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data) ast_frfree(fr); break; } - } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass.codec == AST_FORMAT_SLINEAR) && continue_analysis) { + } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass.format.id == AST_FORMAT_SLINEAR) && continue_analysis) { int totalsilence; int ms; res = ast_dsp_silence(dsp, fr, &totalsilence); @@ -228,9 +229,9 @@ static int background_detect_exec(struct ast_channel *chan, const char *data) } while (0); if (res > -1) { - if (origrformat && ast_set_read_format(chan, origrformat)) { + if (origrformat.id && ast_set_read_format(chan, &origrformat)) { ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n", - chan->name, ast_getformatname(origrformat)); + chan->name, ast_getformatname(&origrformat)); } } if (dsp) { |