aboutsummaryrefslogtreecommitdiffstats
path: root/formats
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2011-02-03 16:22:10 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2011-02-03 16:22:10 +0000
commit4aca3187a3db25ff4d2208f116f618b363dec7d5 (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /formats
parent8170aae0a0882a93ca1ef80736cb95c2d6126865 (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: http://svn.digium.com/svn/asterisk/trunk@306010 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'formats')
-rw-r--r--formats/format_g719.c15
-rw-r--r--formats/format_g723.c13
-rw-r--r--formats/format_g726.c23
-rw-r--r--formats/format_g729.c14
-rw-r--r--formats/format_gsm.c14
-rw-r--r--formats/format_h263.c28
-rw-r--r--formats/format_h264.c22
-rw-r--r--formats/format_ilbc.c14
-rw-r--r--formats/format_jpeg.c6
-rw-r--r--formats/format_ogg_vorbis.c14
-rw-r--r--formats/format_pcm.c44
-rw-r--r--formats/format_siren14.c14
-rw-r--r--formats/format_siren7.c14
-rw-r--r--formats/format_sln.c14
-rw-r--r--formats/format_sln16.c14
-rw-r--r--formats/format_vox.c14
-rw-r--r--formats/format_wav.c28
-rw-r--r--formats/format_wav_gsm.c14
18 files changed, 158 insertions, 161 deletions
diff --git a/formats/format_g719.c b/formats/format_g719.c
index c5fc8efaa..b679122f8 100644
--- a/formats/format_g719.c
+++ b/formats/format_g719.c
@@ -41,7 +41,7 @@ static struct ast_frame *g719read(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_G719;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_G719, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -61,8 +61,8 @@ static int g719write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != AST_FORMAT_G719) {
- ast_log(LOG_WARNING, "Asked to write non-G.719 frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_G719) {
+ ast_log(LOG_WARNING, "Asked to write non-G.719 frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
@@ -110,10 +110,9 @@ static off_t g719tell(struct ast_filestream *fs)
return BYTES_TO_SAMPLES(ftello(fs->f));
}
-static const struct ast_format g719_f = {
+static struct ast_format_def g719_f = {
.name = "g719",
.exts = "g719",
- .format = AST_FORMAT_G719,
.write = g719write,
.seek = g719seek,
.trunc = g719trunc,
@@ -124,15 +123,15 @@ static const struct ast_format g719_f = {
static int load_module(void)
{
- if (ast_format_register(&g719_f))
+ ast_format_set(&g719_f.format, AST_FORMAT_G719, 0);
+ if (ast_format_def_register(&g719_f))
return AST_MODULE_LOAD_DECLINE;
-
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(g719_f.name);
+ return ast_format_def_unregister(g719_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ITU G.719",
diff --git a/formats/format_g723.c b/formats/format_g723.c
index 109811609..6dab66a86 100644
--- a/formats/format_g723.c
+++ b/formats/format_g723.c
@@ -61,7 +61,7 @@ static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext)
}
/* Read the data into the buffer */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass.codec = AST_FORMAT_G723_1;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_G723_1, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != size) {
@@ -82,7 +82,7 @@ static int g723_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_G723_1) {
+ if (f->subclass.format.id != AST_FORMAT_G723_1) {
ast_log(LOG_WARNING, "Asked to write non-g723 frame!\n");
return -1;
}
@@ -125,10 +125,9 @@ static off_t g723_tell(struct ast_filestream *fs)
return -1;
}
-static const struct ast_format g723_1_f = {
+static struct ast_format_def g723_1_f = {
.name = "g723sf",
.exts = "g723|g723sf",
- .format = AST_FORMAT_G723_1,
.write = g723_write,
.seek = g723_seek,
.trunc = g723_trunc,
@@ -139,14 +138,16 @@ static const struct ast_format g723_1_f = {
static int load_module(void)
{
- if (ast_format_register(&g723_1_f))
+ ast_format_set(&g723_1_f.format, AST_FORMAT_G723_1, 0);
+
+ if (ast_format_def_register(&g723_1_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(g723_1_f.name);
+ return ast_format_def_unregister(g723_1_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "G.723.1 Simple Timestamp File Format",
diff --git a/formats/format_g726.c b/formats/format_g726.c
index 3c5697f5d..73a57c8ee 100644
--- a/formats/format_g726.c
+++ b/formats/format_g726.c
@@ -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);
diff --git a/formats/format_g729.c b/formats/format_g729.c
index ad7d7fee7..22b3c3282 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -46,7 +46,7 @@ static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext)
int res;
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass.codec = AST_FORMAT_G729A;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_G729A, 0);
s->fr.mallocd = 0;
s->fr.samples = G729A_SAMPLES;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
@@ -66,8 +66,8 @@ static int g729_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != AST_FORMAT_G729A) {
- ast_log(LOG_WARNING, "Asked to write non-G729 frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_G729A) {
+ ast_log(LOG_WARNING, "Asked to write non-G729 frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
if (f->datalen % 10) {
@@ -121,10 +121,9 @@ static off_t g729_tell(struct ast_filestream *fs)
return (offset/BUF_SIZE)*G729A_SAMPLES;
}
-static const struct ast_format g729_f = {
+static struct ast_format_def g729_f = {
.name = "g729",
.exts = "g729",
- .format = AST_FORMAT_G729A,
.write = g729_write,
.seek = g729_seek,
.trunc = g729_trunc,
@@ -135,14 +134,15 @@ static const struct ast_format g729_f = {
static int load_module(void)
{
- if (ast_format_register(&g729_f))
+ ast_format_set(&g729_f.format, AST_FORMAT_G729A, 0);
+ if (ast_format_def_register(&g729_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(g729_f.name);
+ return ast_format_def_unregister(g729_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw G.729 data",
diff --git a/formats/format_gsm.c b/formats/format_gsm.c
index 2b0b3413e..26257c39f 100644
--- a/formats/format_gsm.c
+++ b/formats/format_gsm.c
@@ -53,7 +53,7 @@ static struct ast_frame *gsm_read(struct ast_filestream *s, int *whennext)
int res;
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass.codec = AST_FORMAT_GSM;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_GSM, 0);
AST_FRAME_SET_BUFFER(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE)
s->fr.mallocd = 0;
if ((res = fread(s->fr.data.ptr, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) {
@@ -74,8 +74,8 @@ static int gsm_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != AST_FORMAT_GSM) {
- ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_GSM) {
+ ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
if (!(f->datalen % 65)) {
@@ -145,10 +145,9 @@ static off_t gsm_tell(struct ast_filestream *fs)
return (offset/GSM_FRAME_SIZE)*GSM_SAMPLES;
}
-static const struct ast_format gsm_f = {
+static struct ast_format_def gsm_f = {
.name = "gsm",
.exts = "gsm",
- .format = AST_FORMAT_GSM,
.write = gsm_write,
.seek = gsm_seek,
.trunc = gsm_trunc,
@@ -159,14 +158,15 @@ static const struct ast_format gsm_f = {
static int load_module(void)
{
- if (ast_format_register(&gsm_f))
+ ast_format_set(&gsm_f.format, AST_FORMAT_GSM, 0);
+ if (ast_format_def_register(&gsm_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(gsm_f.name);
+ return ast_format_def_unregister(gsm_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw GSM data",
diff --git a/formats/format_h263.c b/formats/format_h263.c
index 12c9d0170..76555a67c 100644
--- a/formats/format_h263.c
+++ b/formats/format_h263.c
@@ -64,7 +64,7 @@ static int h263_open(struct ast_filestream *s)
static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
{
int res;
- format_t mark;
+ uint32_t mark;
unsigned short len;
unsigned int ts;
struct h263_desc *fs = (struct h263_desc *)s->_private;
@@ -80,7 +80,7 @@ static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
return NULL;
}
s->fr.frametype = AST_FRAME_VIDEO;
- s->fr.subclass.codec = AST_FORMAT_H263;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_H263, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -90,7 +90,9 @@ static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
}
s->fr.samples = fs->lastts; /* XXX what ? */
s->fr.datalen = len;
- s->fr.subclass.codec |= mark;
+ if (mark) {
+ ast_format_set_video_mark(&s->fr.subclass.format);
+ }
s->fr.delivery.tv_sec = 0;
s->fr.delivery.tv_usec = 0;
if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
@@ -106,18 +108,14 @@ static int h263_write(struct ast_filestream *fs, struct ast_frame *f)
int res;
unsigned int ts;
unsigned short len;
- format_t subclass;
- format_t mark=0;
+ uint32_t mark = 0;
if (f->frametype != AST_FRAME_VIDEO) {
ast_log(LOG_WARNING, "Asked to write non-video frame!\n");
return -1;
}
- subclass = f->subclass.codec;
- if (subclass & 0x1)
- mark=0x8000;
- subclass &= ~0x1;
- if (subclass != AST_FORMAT_H263) {
- ast_log(LOG_WARNING, "Asked to write non-h263 frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ mark = ast_format_get_video_mark(&f->subclass.format) ? 0x8000 : 0;
+ if (f->subclass.format.id != AST_FORMAT_H263) {
+ ast_log(LOG_WARNING, "Asked to write non-h263 frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
ts = htonl(f->samples);
@@ -157,10 +155,9 @@ static off_t h263_tell(struct ast_filestream *fs)
return offset; /* XXX totally bogus, needs fixing */
}
-static const struct ast_format h263_f = {
+static struct ast_format_def h263_f = {
.name = "h263",
.exts = "h263",
- .format = AST_FORMAT_H263,
.open = h263_open,
.write = h263_write,
.seek = h263_seek,
@@ -173,14 +170,15 @@ static const struct ast_format h263_f = {
static int load_module(void)
{
- if (ast_format_register(&h263_f))
+ ast_format_set(&h263_f.format, AST_FORMAT_H263, 0);
+ if (ast_format_def_register(&h263_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(h263_f.name);
+ return ast_format_def_unregister(h263_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw H.263 data",
diff --git a/formats/format_h264.c b/formats/format_h264.c
index f8fe75c42..ea82454f3 100644
--- a/formats/format_h264.c
+++ b/formats/format_h264.c
@@ -56,7 +56,7 @@ static int h264_open(struct ast_filestream *s)
static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
{
int res;
- int mark=0;
+ int mark = 0;
unsigned short len;
unsigned int ts;
struct h264_desc *fs = (struct h264_desc *)s->_private;
@@ -72,7 +72,7 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
len = BUF_SIZE; /* XXX truncate */
}
s->fr.frametype = AST_FRAME_VIDEO;
- s->fr.subclass.codec = AST_FORMAT_H264;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_H264, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -82,7 +82,9 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
}
s->fr.samples = fs->lastts;
s->fr.datalen = len;
- s->fr.subclass.codec |= mark;
+ if (mark) {
+ ast_format_set_video_mark(&s->fr.subclass.format);
+ }
s->fr.delivery.tv_sec = 0;
s->fr.delivery.tv_usec = 0;
if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
@@ -104,9 +106,9 @@ static int h264_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-video frame!\n");
return -1;
}
- mark = (f->subclass.codec & 0x1) ? 0x8000 : 0;
- if ((f->subclass.codec & ~0x1) != AST_FORMAT_H264) {
- ast_log(LOG_WARNING, "Asked to write non-h264 frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ mark = ast_format_get_video_mark(&f->subclass.format) ? 0x8000 : 0;
+ if (f->subclass.format.id != AST_FORMAT_H264) {
+ ast_log(LOG_WARNING, "Asked to write non-h264 frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
ts = htonl(f->samples);
@@ -146,10 +148,9 @@ static off_t h264_tell(struct ast_filestream *fs)
return offset; /* XXX totally bogus, needs fixing */
}
-static const struct ast_format h264_f = {
+static struct ast_format_def h264_f = {
.name = "h264",
.exts = "h264",
- .format = AST_FORMAT_H264,
.open = h264_open,
.write = h264_write,
.seek = h264_seek,
@@ -162,14 +163,15 @@ static const struct ast_format h264_f = {
static int load_module(void)
{
- if (ast_format_register(&h264_f))
+ ast_format_set(&h264_f.format, AST_FORMAT_H264, 0);
+ if (ast_format_def_register(&h264_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(h264_f.name);
+ return ast_format_def_unregister(h264_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw H.264 data",
diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c
index 40bda2639..a60b585d7 100644
--- a/formats/format_ilbc.c
+++ b/formats/format_ilbc.c
@@ -45,7 +45,7 @@ static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext)
int res;
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass.codec = AST_FORMAT_ILBC;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_ILBC, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -64,8 +64,8 @@ static int ilbc_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != AST_FORMAT_ILBC) {
- ast_log(LOG_WARNING, "Asked to write non-iLBC frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_ILBC) {
+ ast_log(LOG_WARNING, "Asked to write non-iLBC frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
if (f->datalen % 50) {
@@ -119,10 +119,9 @@ static off_t ilbc_tell(struct ast_filestream *fs)
return (offset/ILBC_BUF_SIZE)*ILBC_SAMPLES;
}
-static const struct ast_format ilbc_f = {
+static struct ast_format_def ilbc_f = {
.name = "iLBC",
.exts = "ilbc",
- .format = AST_FORMAT_ILBC,
.write = ilbc_write,
.seek = ilbc_seek,
.trunc = ilbc_trunc,
@@ -133,14 +132,15 @@ static const struct ast_format ilbc_f = {
static int load_module(void)
{
- if (ast_format_register(&ilbc_f))
+ ast_format_set(&ilbc_f.format, AST_FORMAT_ILBC, 0);
+ if (ast_format_def_register(&ilbc_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(ilbc_f.name);
+ return ast_format_def_unregister(ilbc_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw iLBC data",
diff --git a/formats/format_jpeg.c b/formats/format_jpeg.c
index 9b1fb9965..99de8dac1 100644
--- a/formats/format_jpeg.c
+++ b/formats/format_jpeg.c
@@ -48,7 +48,7 @@ static struct ast_frame *jpeg_read_image(int fd, int len)
}
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_IMAGE;
- fr.subclass.codec = AST_FORMAT_JPEG;
+ ast_format_set(&fr.subclass.format, AST_FORMAT_JPEG, 0);
fr.data.ptr = buf;
fr.src = "JPEG Read";
fr.datalen = len;
@@ -74,7 +74,7 @@ static int jpeg_write_image(int fd, struct ast_frame *fr)
ast_log(LOG_WARNING, "Not an image\n");
return -1;
}
- if (fr->subclass.codec != AST_FORMAT_JPEG) {
+ if (fr->subclass.format.id != AST_FORMAT_JPEG) {
ast_log(LOG_WARNING, "Not a jpeg image\n");
return -1;
}
@@ -92,7 +92,6 @@ static struct ast_imager jpeg_format = {
.name = "jpg",
.desc = "JPEG (Joint Picture Experts Group)",
.exts = "jpg|jpeg",
- .format = AST_FORMAT_JPEG,
.read_image = jpeg_read_image,
.identify = jpeg_identify,
.write_image = jpeg_write_image,
@@ -100,6 +99,7 @@ static struct ast_imager jpeg_format = {
static int load_module(void)
{
+ ast_format_set(&jpeg_format.format, AST_FORMAT_JPEG, 0);
if (ast_image_register(&jpeg_format))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c
index d2a087360..949a13f78 100644
--- a/formats/format_ogg_vorbis.c
+++ b/formats/format_ogg_vorbis.c
@@ -291,9 +291,9 @@ static int ogg_vorbis_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != AST_FORMAT_SLINEAR) {
+ if (f->subclass.format.id != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%s)!\n",
- ast_getformatname(f->subclass.codec));
+ ast_getformatname(&f->subclass.format));
return -1;
}
if (!f->datalen)
@@ -438,7 +438,7 @@ static struct ast_frame *ogg_vorbis_read(struct ast_filestream *fs,
short *buf; /* SLIN data buffer */
fs->fr.frametype = AST_FRAME_VOICE;
- fs->fr.subclass.codec = AST_FORMAT_SLINEAR;
+ ast_format_set(&fs->fr.subclass.format, AST_FORMAT_SLINEAR, 0);
fs->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
buf = (short *)(fs->fr.data.ptr); /* SLIN data buffer */
@@ -528,10 +528,9 @@ static off_t ogg_vorbis_tell(struct ast_filestream *s)
return -1;
}
-static const struct ast_format vorbis_f = {
+static struct ast_format_def vorbis_f = {
.name = "ogg_vorbis",
.exts = "ogg",
- .format = AST_FORMAT_SLINEAR,
.open = ogg_vorbis_open,
.rewrite = ogg_vorbis_rewrite,
.write = ogg_vorbis_write,
@@ -546,14 +545,15 @@ static const struct ast_format vorbis_f = {
static int load_module(void)
{
- if (ast_format_register(&vorbis_f))
+ ast_format_set(&vorbis_f.format, AST_FORMAT_SLINEAR, 0);
+ if (ast_format_def_register(&vorbis_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(vorbis_f.name);
+ return ast_format_def_unregister(vorbis_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "OGG/Vorbis audio",
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index 76eb9c6af..ec628c5b3 100644
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -80,7 +80,7 @@ static struct ast_frame *pcm_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 = s->fmt->format;
+ ast_format_copy(&s->fr.subclass.format, &s->fmt->format);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
@@ -89,7 +89,7 @@ static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext)
return NULL;
}
s->fr.datalen = res;
- if (s->fmt->format == AST_FORMAT_G722)
+ if (s->fmt->format.id == AST_FORMAT_G722)
*whennext = s->fr.samples = res * 2;
else
*whennext = s->fr.samples = res;
@@ -126,7 +126,7 @@ static int pcm_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
}
if (whence == SEEK_FORCECUR && offset > max) { /* extend the file */
size_t left = offset - max;
- const char *src = (fs->fmt->format == AST_FORMAT_ALAW) ? alaw_silence : ulaw_silence;
+ const char *src = (fs->fmt->format.id == AST_FORMAT_ALAW) ? alaw_silence : ulaw_silence;
while (left) {
size_t written = fwrite(src, 1, (left > BUF_SIZE) ? BUF_SIZE : left, fs->f);
@@ -163,8 +163,8 @@ static int pcm_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != fs->fmt->format) {
- ast_log(LOG_WARNING, "Asked to write incompatible format frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (ast_format_cmp(&f->subclass.format, &fs->fmt->format) == AST_FORMAT_CMP_NOT_EQUAL) {
+ ast_log(LOG_WARNING, "Asked to write incompatible format frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
@@ -373,7 +373,7 @@ static int au_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
off_t min, max, cur;
long offset = 0, bytes;
- if (fs->fmt->format == AST_FORMAT_G722)
+ if (fs->fmt->format.id == AST_FORMAT_G722)
bytes = sample_offset / 2;
else
bytes = sample_offset;
@@ -413,10 +413,9 @@ static off_t au_tell(struct ast_filestream *fs)
return offset - AU_HEADER_SIZE;
}
-static const struct ast_format alaw_f = {
+static struct ast_format_def alaw_f = {
.name = "alaw",
.exts = "alaw|al|alw",
- .format = AST_FORMAT_ALAW,
.write = pcm_write,
.seek = pcm_seek,
.trunc = pcm_trunc,
@@ -430,10 +429,9 @@ static const struct ast_format alaw_f = {
#endif
};
-static const struct ast_format pcm_f = {
+static struct ast_format_def pcm_f = {
.name = "pcm",
.exts = "pcm|ulaw|ul|mu|ulw",
- .format = AST_FORMAT_ULAW,
.write = pcm_write,
.seek = pcm_seek,
.trunc = pcm_trunc,
@@ -442,10 +440,9 @@ static const struct ast_format pcm_f = {
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
};
-static const struct ast_format g722_f = {
+static struct ast_format_def g722_f = {
.name = "g722",
.exts = "g722",
- .format = AST_FORMAT_G722,
.write = pcm_write,
.seek = pcm_seek,
.trunc = pcm_trunc,
@@ -454,10 +451,9 @@ static const struct ast_format g722_f = {
.buf_size = (BUF_SIZE * 2) + AST_FRIENDLY_OFFSET,
};
-static const struct ast_format au_f = {
+static struct ast_format_def au_f = {
.name = "au",
.exts = "au",
- .format = AST_FORMAT_ULAW,
.open = au_open,
.rewrite = au_rewrite,
.write = pcm_write,
@@ -478,20 +474,24 @@ static int load_module(void)
for (i = 0; i < ARRAY_LEN(alaw_silence); i++)
alaw_silence[i] = AST_LIN2A(0);
- if ( ast_format_register(&pcm_f)
- || ast_format_register(&alaw_f)
- || ast_format_register(&au_f)
- || ast_format_register(&g722_f) )
+ ast_format_set(&pcm_f.format, AST_FORMAT_ULAW, 0);
+ ast_format_set(&alaw_f.format, AST_FORMAT_ALAW, 0);
+ ast_format_set(&au_f.format, AST_FORMAT_ULAW, 0);
+ ast_format_set(&g722_f.format, AST_FORMAT_G722, 0);
+ if ( ast_format_def_register(&pcm_f)
+ || ast_format_def_register(&alaw_f)
+ || ast_format_def_register(&au_f)
+ || ast_format_def_register(&g722_f) )
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(pcm_f.name)
- || ast_format_unregister(alaw_f.name)
- || ast_format_unregister(au_f.name)
- || ast_format_unregister(g722_f.name);
+ return ast_format_def_unregister(pcm_f.name)
+ || ast_format_def_unregister(alaw_f.name)
+ || ast_format_def_unregister(au_f.name)
+ || ast_format_def_unregister(g722_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw/Sun uLaw/ALaw 8KHz (PCM,PCMA,AU), G.722 16Khz",
diff --git a/formats/format_siren14.c b/formats/format_siren14.c
index 0b8526bde..53c9ea922 100644
--- a/formats/format_siren14.c
+++ b/formats/format_siren14.c
@@ -41,7 +41,7 @@ static struct ast_frame *siren14read(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_SIREN14;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_SIREN14, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -61,8 +61,8 @@ static int siren14write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != AST_FORMAT_SIREN14) {
- ast_log(LOG_WARNING, "Asked to write non-Siren14 frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_SIREN14) {
+ ast_log(LOG_WARNING, "Asked to write non-Siren14 frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
@@ -110,10 +110,9 @@ static off_t siren14tell(struct ast_filestream *fs)
return BYTES_TO_SAMPLES(ftello(fs->f));
}
-static const struct ast_format siren14_f = {
+static struct ast_format_def siren14_f = {
.name = "siren14",
.exts = "siren14",
- .format = AST_FORMAT_SIREN14,
.write = siren14write,
.seek = siren14seek,
.trunc = siren14trunc,
@@ -124,7 +123,8 @@ static const struct ast_format siren14_f = {
static int load_module(void)
{
- if (ast_format_register(&siren14_f))
+ ast_format_set(&siren14_f.format, AST_FORMAT_SIREN14, 0);
+ if (ast_format_def_register(&siren14_f))
return AST_MODULE_LOAD_DECLINE;
return AST_MODULE_LOAD_SUCCESS;
@@ -132,7 +132,7 @@ static int load_module(void)
static int unload_module(void)
{
- return ast_format_unregister(siren14_f.name);
+ return ast_format_def_unregister(siren14_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ITU G.722.1 Annex C (Siren14, licensed from Polycom)",
diff --git a/formats/format_siren7.c b/formats/format_siren7.c
index 5c7919307..16eca5df5 100644
--- a/formats/format_siren7.c
+++ b/formats/format_siren7.c
@@ -41,7 +41,7 @@ static struct ast_frame *siren7read(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_SIREN7;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_SIREN7, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -61,8 +61,8 @@ static int siren7write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != AST_FORMAT_SIREN7) {
- ast_log(LOG_WARNING, "Asked to write non-Siren7 frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_SIREN7) {
+ ast_log(LOG_WARNING, "Asked to write non-Siren7 frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
@@ -110,10 +110,9 @@ static off_t siren7tell(struct ast_filestream *fs)
return BYTES_TO_SAMPLES(ftello(fs->f));
}
-static const struct ast_format siren7_f = {
+static struct ast_format_def siren7_f = {
.name = "siren7",
.exts = "siren7",
- .format = AST_FORMAT_SIREN7,
.write = siren7write,
.seek = siren7seek,
.trunc = siren7trunc,
@@ -124,7 +123,8 @@ static const struct ast_format siren7_f = {
static int load_module(void)
{
- if (ast_format_register(&siren7_f))
+ ast_format_set(&siren7_f.format, AST_FORMAT_SIREN7, 0);
+ if (ast_format_def_register(&siren7_f))
return AST_MODULE_LOAD_DECLINE;
return AST_MODULE_LOAD_SUCCESS;
@@ -132,7 +132,7 @@ static int load_module(void)
static int unload_module(void)
{
- return ast_format_unregister(siren7_f.name);
+ return ast_format_def_unregister(siren7_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ITU G.722.1 (Siren7, licensed from Polycom)",
diff --git a/formats/format_sln.c b/formats/format_sln.c
index 578e64c7b..0cb27949d 100644
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -39,7 +39,7 @@ static struct ast_frame *slinear_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_SLINEAR;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_SLINEAR, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
@@ -59,8 +59,8 @@ static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != AST_FORMAT_SLINEAR) {
- ast_log(LOG_WARNING, "Asked to write non-slinear frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_SLINEAR) {
+ ast_log(LOG_WARNING, "Asked to write non-slinear frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
@@ -103,10 +103,9 @@ static off_t slinear_tell(struct ast_filestream *fs)
return ftello(fs->f) / 2;
}
-static const struct ast_format slin_f = {
+static struct ast_format_def slin_f = {
.name = "sln",
.exts = "sln|raw",
- .format = AST_FORMAT_SLINEAR,
.write = slinear_write,
.seek = slinear_seek,
.trunc = slinear_trunc,
@@ -117,14 +116,15 @@ static const struct ast_format slin_f = {
static int load_module(void)
{
- if (ast_format_register(&slin_f))
+ ast_format_set(&slin_f.format, AST_FORMAT_SLINEAR, 0);
+ if (ast_format_def_register(&slin_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(slin_f.name);
+ return ast_format_def_unregister(slin_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw Signed Linear Audio support (SLN)",
diff --git a/formats/format_sln16.c b/formats/format_sln16.c
index 1e3249412..cac019615 100644
--- a/formats/format_sln16.c
+++ b/formats/format_sln16.c
@@ -40,7 +40,7 @@ static struct ast_frame *slinear_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_SLINEAR16;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_SLINEAR16, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
@@ -61,8 +61,8 @@ static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass.codec != AST_FORMAT_SLINEAR16) {
- ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_SLINEAR16) {
+ ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
@@ -110,10 +110,9 @@ static off_t slinear_tell(struct ast_filestream *fs)
return ftello(fs->f) / 2;
}
-static const struct ast_format slin_f = {
+static struct ast_format_def slin_f = {
.name = "sln16",
.exts = "sln16",
- .format = AST_FORMAT_SLINEAR16,
.write = slinear_write,
.seek = slinear_seek,
.trunc = slinear_trunc,
@@ -124,7 +123,8 @@ static const struct ast_format slin_f = {
static int load_module(void)
{
- if (ast_format_register(&slin_f))
+ ast_format_set(&slin_f.format, AST_FORMAT_SLINEAR16, 0);
+ if (ast_format_def_register(&slin_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
@@ -132,7 +132,7 @@ static int load_module(void)
static int unload_module(void)
{
- return ast_format_unregister(slin_f.name);
+ return ast_format_def_unregister(slin_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw Signed Linear 16KHz Audio support (SLN16)",
diff --git a/formats/format_vox.c b/formats/format_vox.c
index c13dd7ac5..05ecdeeaf 100644
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -41,7 +41,7 @@ static struct ast_frame *vox_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_ADPCM;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_ADPCM, 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
@@ -61,8 +61,8 @@ static int vox_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_ADPCM) {
- ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_ADPCM) {
+ ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) {
@@ -108,10 +108,9 @@ static off_t vox_tell(struct ast_filestream *fs)
return offset;
}
-static const struct ast_format vox_f = {
+static struct ast_format_def vox_f = {
.name = "vox",
.exts = "vox",
- .format = AST_FORMAT_ADPCM,
.write = vox_write,
.seek = vox_seek,
.trunc = vox_trunc,
@@ -122,14 +121,15 @@ static const struct ast_format vox_f = {
static int load_module(void)
{
- if (ast_format_register(&vox_f))
+ ast_format_set(&vox_f.format, AST_FORMAT_ADPCM, 0);
+ if (ast_format_def_register(&vox_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(vox_f.name);
+ return ast_format_def_unregister(vox_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Dialogic VOX (ADPCM) File Format",
diff --git a/formats/format_wav.c b/formats/format_wav.c
index 91a309ef4..74c14f21c 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -319,7 +319,7 @@ static int wav_open(struct ast_filestream *s)
if we did, it would go here. We also might want to check
and be sure it's a valid file. */
struct wav_desc *tmp = (struct wav_desc *)s->_private;
- if ((tmp->maxlen = check_header(s->f, (s->fmt->format == AST_FORMAT_SLINEAR16 ? 16000 : 8000))) < 0)
+ if ((tmp->maxlen = check_header(s->f, (s->fmt->format.id == AST_FORMAT_SLINEAR16 ? 16000 : 8000))) < 0)
return -1;
return 0;
}
@@ -331,7 +331,7 @@ static int wav_rewrite(struct ast_filestream *s, const char *comment)
and be sure it's a valid file. */
struct wav_desc *tmp = (struct wav_desc *)s->_private;
- tmp->hz = (s->fmt->format == AST_FORMAT_SLINEAR16 ? 16000 : 8000);
+ tmp->hz = (s->fmt->format.id == AST_FORMAT_SLINEAR16 ? 16000 : 8000);
if (write_header(s->f,tmp->hz))
return -1;
return 0;
@@ -376,7 +376,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
bytes = 0;
/* ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass.codec = (fs->hz == 16000 ? AST_FORMAT_SLINEAR16 : AST_FORMAT_SLINEAR);
+ ast_format_set(&s->fr.subclass.format, (fs->hz == 16000 ? AST_FORMAT_SLINEAR16 : AST_FORMAT_SLINEAR), 0);
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
@@ -412,11 +412,11 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if ((f->subclass.codec != AST_FORMAT_SLINEAR) && (f->subclass.codec != AST_FORMAT_SLINEAR16)) {
- ast_log(LOG_WARNING, "Asked to write non-SLINEAR%s frame (%s)!\n", s->hz == 16000 ? "16" : "", ast_getformatname(f->subclass.codec));
+ if ((f->subclass.format.id != AST_FORMAT_SLINEAR) && (f->subclass.format.id != AST_FORMAT_SLINEAR16)) {
+ ast_log(LOG_WARNING, "Asked to write non-SLINEAR%s frame (%s)!\n", s->hz == 16000 ? "16" : "", ast_getformatname(&f->subclass.format));
return -1;
}
- if (f->subclass.codec != fs->fmt->format) {
+ if (ast_format_cmp(&f->subclass.format, &fs->fmt->format) == AST_FORMAT_CMP_NOT_EQUAL) {
ast_log(LOG_WARNING, "Can't change SLINEAR frequency during write\n");
return -1;
}
@@ -486,10 +486,9 @@ static off_t wav_tell(struct ast_filestream *fs)
return (offset - 44)/2;
}
-static const struct ast_format wav16_f = {
+static struct ast_format_def wav16_f = {
.name = "wav16",
.exts = "wav16",
- .format = AST_FORMAT_SLINEAR16,
.open = wav_open,
.rewrite = wav_rewrite,
.write = wav_write,
@@ -502,10 +501,9 @@ static const struct ast_format wav16_f = {
.desc_size = sizeof(struct wav_desc),
};
-static const struct ast_format wav_f = {
+static struct ast_format_def wav_f = {
.name = "wav",
.exts = "wav",
- .format = AST_FORMAT_SLINEAR,
.open = wav_open,
.rewrite = wav_rewrite,
.write = wav_write,
@@ -520,16 +518,18 @@ static const struct ast_format wav_f = {
static int load_module(void)
{
- if (ast_format_register(&wav_f)
- || ast_format_register(&wav16_f))
+ ast_format_set(&wav_f.format, AST_FORMAT_SLINEAR, 0);
+ ast_format_set(&wav16_f.format, AST_FORMAT_SLINEAR16, 0);
+ if (ast_format_def_register(&wav_f)
+ || ast_format_def_register(&wav16_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(wav_f.name)
- || ast_format_unregister(wav16_f.name);
+ return ast_format_def_unregister(wav_f.name)
+ || ast_format_def_unregister(wav16_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Microsoft WAV/WAV16 format (8kHz/16kHz Signed Linear)",
diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c
index f864f2814..ae1f11ed8 100644
--- a/formats/format_wav_gsm.c
+++ b/formats/format_wav_gsm.c
@@ -395,7 +395,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
struct wavg_desc *fs = (struct wavg_desc *)s->_private;
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass.codec = AST_FORMAT_GSM;
+ ast_format_set(&s->fr.subclass.format, AST_FORMAT_GSM, 0);
s->fr.offset = AST_FRIENDLY_OFFSET;
s->fr.samples = GSM_SAMPLES;
s->fr.mallocd = 0;
@@ -432,8 +432,8 @@ static int wav_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_GSM) {
- ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(f->subclass.codec));
+ if (f->subclass.format.id != AST_FORMAT_GSM) {
+ ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(&f->subclass.format));
return -1;
}
/* XXX this might fail... if the input is a multiple of MSGSM_FRAME_SIZE
@@ -521,10 +521,9 @@ static off_t wav_tell(struct ast_filestream *fs)
return (offset - MSGSM_DATA_OFFSET)/MSGSM_FRAME_SIZE*MSGSM_SAMPLES;
}
-static const struct ast_format wav49_f = {
+static struct ast_format_def wav49_f = {
.name = "wav49",
.exts = "WAV|wav49",
- .format = AST_FORMAT_GSM,
.open = wav_open,
.rewrite = wav_rewrite,
.write = wav_write,
@@ -538,14 +537,15 @@ static const struct ast_format wav49_f = {
static int load_module(void)
{
- if (ast_format_register(&wav49_f))
+ ast_format_set(&wav49_f.format, AST_FORMAT_GSM, 0);
+ if (ast_format_def_register(&wav49_f))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- return ast_format_unregister(wav49_f.name);
+ return ast_format_def_unregister(wav49_f.name);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Microsoft WAV format (Proprietary GSM)",