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

@@ -119,7 +119,7 @@ static struct ast_frame *g726_read(struct ast_filestream *s, int *whennext)
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass.codec = AST_FORMAT_G726;
ast_format_set(&s->fr.subclass.format, AST_FORMAT_G726, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
s->fr.samples = 8 * FRAME_TIME;
@@ -141,9 +141,9 @@ static int g726_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
if (f->subclass.codec != AST_FORMAT_G726) {
if (f->subclass.format.id != AST_FORMAT_G726) {
ast_log(LOG_WARNING, "Asked to write non-G726 frame (%s)!\n",
ast_getformatname(f->subclass.codec));
ast_getformatname(&f->subclass.format));
return -1;
}
if (f->datalen % frame_size[fs->rate]) {
@@ -174,11 +174,10 @@ static off_t g726_tell(struct ast_filestream *fs)
return -1;
}
static const struct ast_format f[] = {
static struct ast_format_def f[] = {
{
.name = "g726-40",
.exts = "g726-40",
.format = AST_FORMAT_G726,
.open = g726_40_open,
.rewrite = g726_40_rewrite,
.write = g726_write,
@@ -192,7 +191,6 @@ static const struct ast_format f[] = {
{
.name = "g726-32",
.exts = "g726-32",
.format = AST_FORMAT_G726,
.open = g726_32_open,
.rewrite = g726_32_rewrite,
.write = g726_write,
@@ -206,7 +204,6 @@ static const struct ast_format f[] = {
{
.name = "g726-24",
.exts = "g726-24",
.format = AST_FORMAT_G726,
.open = g726_24_open,
.rewrite = g726_24_rewrite,
.write = g726_write,
@@ -220,7 +217,6 @@ static const struct ast_format f[] = {
{
.name = "g726-16",
.exts = "g726-16",
.format = AST_FORMAT_G726,
.open = g726_16_open,
.rewrite = g726_16_rewrite,
.write = g726_write,
@@ -231,15 +227,16 @@ static const struct ast_format f[] = {
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct g726_desc),
},
{ .format = 0 } /* terminator */
{ .desc_size = 0 } /* terminator */
};
static int load_module(void)
{
int i;
for (i = 0; f[i].format ; i++) {
if (ast_format_register(&f[i])) { /* errors are fatal */
for (i = 0; f[i].desc_size ; i++) {
ast_format_set(&f[i].format, AST_FORMAT_G726, 0);
if (ast_format_def_register(&f[i])) { /* errors are fatal */
ast_log(LOG_WARNING, "Failed to register format %s.\n", f[i].name);
return AST_MODULE_LOAD_FAILURE;
}
@@ -251,8 +248,8 @@ static int unload_module(void)
{
int i;
for (i = 0; f[i].format ; i++) {
if (ast_format_unregister(f[i].name))
for (i = 0; f[i].desc_size ; i++) {
if (ast_format_def_unregister(f[i].name))
ast_log(LOG_WARNING, "Failed to unregister format %s.\n", f[i].name);
}
return(0);