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
This commit is contained in:
David Vossel
2011-02-03 16:22:10 +00:00
parent 652fb64a01
commit c26c190711
168 changed files with 8120 additions and 3764 deletions

View File

@@ -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))) {