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 /main/slinfactory.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 'main/slinfactory.c')
-rw-r--r-- | main/slinfactory.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/main/slinfactory.c b/main/slinfactory.c index 4da443af5..f7363ab4b 100644 --- a/main/slinfactory.c +++ b/main/slinfactory.c @@ -36,7 +36,7 @@ void ast_slinfactory_init(struct ast_slinfactory *sf) { memset(sf, 0, sizeof(*sf)); sf->offset = sf->hold; - sf->output_format = AST_FORMAT_SLINEAR; + ast_format_set(&sf->output_format, AST_FORMAT_SLINEAR, 0); } int ast_slinfactory_init_rate(struct ast_slinfactory *sf, unsigned int sample_rate) @@ -45,10 +45,10 @@ int ast_slinfactory_init_rate(struct ast_slinfactory *sf, unsigned int sample_ra sf->offset = sf->hold; switch (sample_rate) { case 8000: - sf->output_format = AST_FORMAT_SLINEAR; + ast_format_set(&sf->output_format, AST_FORMAT_SLINEAR, 0); break; case 16000: - sf->output_format = AST_FORMAT_SLINEAR16; + ast_format_set(&sf->output_format, AST_FORMAT_SLINEAR16, 0); break; default: return -1; @@ -85,19 +85,19 @@ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f) return 0; } - if (f->subclass.codec != sf->output_format) { - if (sf->trans && f->subclass.codec != sf->format) { + if (ast_format_cmp(&f->subclass.format, &sf->output_format) == AST_FORMAT_CMP_NOT_EQUAL) { + if (sf->trans && (ast_format_cmp(&f->subclass.format, &sf->format) == AST_FORMAT_CMP_NOT_EQUAL)) { ast_translator_free_path(sf->trans); sf->trans = NULL; } if (!sf->trans) { - if (!(sf->trans = ast_translator_build_path(sf->output_format, f->subclass.codec))) { - ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", ast_getformatname(f->subclass.codec), - ast_getformatname(sf->output_format)); + if (!(sf->trans = ast_translator_build_path(&sf->output_format, &f->subclass.format))) { + ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", ast_getformatname(&f->subclass.format), + ast_getformatname(&sf->output_format)); return 0; } - sf->format = f->subclass.codec; + ast_format_copy(&sf->format, &f->subclass.format); } if (!(begin_frame = ast_translate(sf->trans, f, 0))) { |