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_mp3.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_mp3.c')
-rw-r--r-- | apps/app_mp3.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/apps/app_mp3.c b/apps/app_mp3.c index f8e42a12c..f8c5a0578 100644 --- a/apps/app_mp3.c +++ b/apps/app_mp3.c @@ -137,7 +137,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data) int fds[2]; int ms = -1; int pid = -1; - int owriteformat; + struct ast_format owriteformat; int timeout = 2000; struct timeval next; struct ast_frame *f; @@ -149,6 +149,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data) .f = { 0, }, }; + ast_format_clear(&owriteformat); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "MP3 Playback requires an argument (filename)\n"); return -1; @@ -161,8 +162,8 @@ static int mp3_exec(struct ast_channel *chan, const char *data) ast_stopstream(chan); - owriteformat = chan->writeformat; - res = ast_set_write_format(chan, AST_FORMAT_SLINEAR); + ast_format_copy(&owriteformat, &chan->writeformat); + res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set write format to signed linear\n"); return -1; @@ -185,7 +186,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data) res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata), timeout); if (res > 0) { myf.f.frametype = AST_FRAME_VOICE; - myf.f.subclass.codec = AST_FORMAT_SLINEAR; + ast_format_set(&myf.f.subclass.format, AST_FORMAT_SLINEAR, 0); myf.f.datalen = res; myf.f.samples = res / 2; myf.f.mallocd = 0; @@ -234,8 +235,8 @@ static int mp3_exec(struct ast_channel *chan, const char *data) if (pid > -1) kill(pid, SIGKILL); - if (!res && owriteformat) - ast_set_write_format(chan, owriteformat); + if (!res && owriteformat.id) + ast_set_write_format(chan, &owriteformat); return res; } |