diff options
Diffstat (limited to 'codecs')
-rw-r--r-- | codecs/codec_a_mu.c | 10 | ||||
-rw-r--r-- | codecs/codec_adpcm.c | 10 | ||||
-rw-r--r-- | codecs/codec_alaw.c | 10 | ||||
-rw-r--r-- | codecs/codec_dahdi.c | 55 | ||||
-rw-r--r-- | codecs/codec_g722.c | 20 | ||||
-rw-r--r-- | codecs/codec_g726.c | 20 | ||||
-rw-r--r-- | codecs/codec_gsm.c | 10 | ||||
-rw-r--r-- | codecs/codec_ilbc.c | 11 | ||||
-rw-r--r-- | codecs/codec_lpc10.c | 10 | ||||
-rw-r--r-- | codecs/codec_resample.c | 10 | ||||
-rw-r--r-- | codecs/codec_speex.c | 21 | ||||
-rw-r--r-- | codecs/codec_ulaw.c | 20 | ||||
-rw-r--r-- | codecs/ex_adpcm.h | 2 | ||||
-rw-r--r-- | codecs/ex_alaw.h | 3 | ||||
-rw-r--r-- | codecs/ex_g722.h | 3 | ||||
-rw-r--r-- | codecs/ex_g726.h | 3 | ||||
-rw-r--r-- | codecs/ex_gsm.h | 2 | ||||
-rw-r--r-- | codecs/ex_lpc10.h | 3 | ||||
-rw-r--r-- | codecs/ex_speex.h | 5 | ||||
-rw-r--r-- | codecs/ex_ulaw.h | 2 |
20 files changed, 137 insertions, 93 deletions
diff --git a/codecs/codec_a_mu.c b/codecs/codec_a_mu.c index 9b2e40850..a7d86e2c4 100644 --- a/codecs/codec_a_mu.c +++ b/codecs/codec_a_mu.c @@ -76,8 +76,6 @@ static int ulawtoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) static struct ast_translator alawtoulaw = { .name = "alawtoulaw", - .srcfmt = AST_FORMAT_ALAW, - .dstfmt = AST_FORMAT_ULAW, .framein = alawtoulaw_framein, .sample = alaw_sample, .buffer_samples = BUFFER_SAMPLES, @@ -86,8 +84,6 @@ static struct ast_translator alawtoulaw = { static struct ast_translator ulawtoalaw = { .name = "ulawtoalaw", - .srcfmt = AST_FORMAT_ULAW, - .dstfmt = AST_FORMAT_ALAW, .framein = ulawtoalaw_framein, .sample = ulaw_sample, .buffer_samples = BUFFER_SAMPLES, @@ -111,6 +107,12 @@ static int load_module(void) int res; int x; + ast_format_set(&alawtoulaw.src_format, AST_FORMAT_ALAW, 0); + ast_format_set(&alawtoulaw.dst_format, AST_FORMAT_ULAW, 0); + + ast_format_set(&ulawtoalaw.src_format, AST_FORMAT_ULAW, 0); + ast_format_set(&ulawtoalaw.dst_format, AST_FORMAT_ALAW, 0); + for (x=0;x<256;x++) { mu2a[x] = AST_LIN2A(AST_MULAW(x)); a2mu[x] = AST_LIN2MU(AST_ALAW(x)); diff --git a/codecs/codec_adpcm.c b/codecs/codec_adpcm.c index a1b0680a5..63745c170 100644 --- a/codecs/codec_adpcm.c +++ b/codecs/codec_adpcm.c @@ -286,8 +286,6 @@ static struct ast_frame *lintoadpcm_frameout(struct ast_trans_pvt *pvt) static struct ast_translator adpcmtolin = { .name = "adpcmtolin", - .srcfmt = AST_FORMAT_ADPCM, - .dstfmt = AST_FORMAT_SLINEAR, .framein = adpcmtolin_framein, .sample = adpcm_sample, .desc_size = sizeof(struct adpcm_decoder_pvt), @@ -297,8 +295,6 @@ static struct ast_translator adpcmtolin = { static struct ast_translator lintoadpcm = { .name = "lintoadpcm", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_ADPCM, .framein = lintoadpcm_framein, .frameout = lintoadpcm_frameout, .sample = slin8_sample, @@ -327,6 +323,12 @@ static int load_module(void) { int res; + ast_format_set(&adpcmtolin.src_format, AST_FORMAT_ADPCM, 0); + ast_format_set(&adpcmtolin.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&lintoadpcm.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintoadpcm.dst_format, AST_FORMAT_ADPCM, 0); + res = ast_register_translator(&adpcmtolin); if (!res) res = ast_register_translator(&lintoadpcm); diff --git a/codecs/codec_alaw.c b/codecs/codec_alaw.c index bb749d003..3d2fc92ae 100644 --- a/codecs/codec_alaw.c +++ b/codecs/codec_alaw.c @@ -73,8 +73,6 @@ static int lintoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) static struct ast_translator alawtolin = { .name = "alawtolin", - .srcfmt = AST_FORMAT_ALAW, - .dstfmt = AST_FORMAT_SLINEAR, .framein = alawtolin_framein, .sample = alaw_sample, .buffer_samples = BUFFER_SAMPLES, @@ -83,8 +81,6 @@ static struct ast_translator alawtolin = { static struct ast_translator lintoalaw = { "lintoalaw", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_ALAW, .framein = lintoalaw_framein, .sample = slin8_sample, .buffer_samples = BUFFER_SAMPLES, @@ -112,6 +108,12 @@ static int load_module(void) { int res; + ast_format_set(&lintoalaw.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintoalaw.dst_format, AST_FORMAT_ALAW, 0); + + ast_format_set(&alawtolin.src_format, AST_FORMAT_ALAW, 0); + ast_format_set(&alawtolin.dst_format, AST_FORMAT_SLINEAR, 0); + res = ast_register_translator(&alawtolin); if (!res) res = ast_register_translator(&lintoalaw); diff --git a/codecs/codec_dahdi.c b/codecs/codec_dahdi.c index 64b73cdc1..960a594f7 100644 --- a/codecs/codec_dahdi.c +++ b/codecs/codec_dahdi.c @@ -179,7 +179,7 @@ static int dahdi_encoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct codec_dahdi_pvt *dahdip = pvt->pvt; - if (!f->subclass.codec) { + if (!f->subclass.format.id) { /* We're just faking a return for calculation purposes. */ dahdip->fake = 2; pvt->samples = f->samples; @@ -227,7 +227,7 @@ static struct ast_frame *dahdi_encoder_frameout(struct ast_trans_pvt *pvt) if (2 == dahdip->fake) { dahdip->fake = 1; pvt->f.frametype = AST_FRAME_VOICE; - pvt->f.subclass.codec = 0; + ast_format_clear(&pvt->f.subclass.format); pvt->f.samples = dahdip->required_samples; pvt->f.data.ptr = NULL; pvt->f.offset = 0; @@ -255,7 +255,7 @@ static struct ast_frame *dahdi_encoder_frameout(struct ast_trans_pvt *pvt) pvt->f.datalen = res; pvt->f.samples = dahdip->required_samples; pvt->f.frametype = AST_FRAME_VOICE; - pvt->f.subclass.codec = 1 << (pvt->t->dstfmt); + ast_format_copy(&pvt->f.subclass.format, &pvt->t->dst_format); pvt->f.mallocd = 0; pvt->f.offset = AST_FRIENDLY_OFFSET; pvt->f.src = pvt->t->name; @@ -274,7 +274,7 @@ static int dahdi_decoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct codec_dahdi_pvt *dahdip = pvt->pvt; - if (!f->subclass.codec) { + if (!f->subclass.format.id) { /* We're just faking a return for calculation purposes. */ dahdip->fake = 2; pvt->samples = f->samples; @@ -300,7 +300,7 @@ static struct ast_frame *dahdi_decoder_frameout(struct ast_trans_pvt *pvt) if (2 == dahdip->fake) { dahdip->fake = 1; pvt->f.frametype = AST_FRAME_VOICE; - pvt->f.subclass.codec = 0; + ast_format_clear(&pvt->f.subclass.format); pvt->f.samples = dahdip->required_samples; pvt->f.data.ptr = NULL; pvt->f.offset = 0; @@ -338,7 +338,7 @@ static struct ast_frame *dahdi_decoder_frameout(struct ast_trans_pvt *pvt) } pvt->datalen = 0; pvt->f.frametype = AST_FRAME_VOICE; - pvt->f.subclass.codec = 1 << (pvt->t->dstfmt); + ast_format_copy(&pvt->f.subclass.format, &pvt->t->dst_format); pvt->f.mallocd = 0; pvt->f.offset = AST_FRIENDLY_OFFSET; pvt->f.src = pvt->t->name; @@ -371,7 +371,7 @@ static void dahdi_destroy(struct ast_trans_pvt *pvt) close(dahdip->fd); } -static int dahdi_translate(struct ast_trans_pvt *pvt, int dest, int source) +static int dahdi_translate(struct ast_trans_pvt *pvt, struct ast_format *dst_format, struct ast_format *src_format) { /* Request translation through zap if possible */ int fd; @@ -385,10 +385,10 @@ static int dahdi_translate(struct ast_trans_pvt *pvt, int dest, int source) return -1; } - dahdip->fmts.srcfmt = (1 << source); - dahdip->fmts.dstfmt = (1 << dest); + dahdip->fmts.srcfmt = ast_format_to_old_bitfield(src_format); + dahdip->fmts.dstfmt = ast_format_to_old_bitfield(dst_format); - ast_debug(1, "Opening transcoder channel from %d to %d.\n", source, dest); + ast_debug(1, "Opening transcoder channel from %s to %s.\n", ast_getformatname(src_format), ast_getformatname(dst_format)); retry: if (ioctl(fd, DAHDI_TC_ALLOCATE, &dahdip->fmts)) { @@ -401,14 +401,14 @@ retry: * support for ULAW instead of signed linear and then * we'll just convert from ulaw to signed linear in * software. */ - if (AST_FORMAT_SLINEAR == dahdip->fmts.srcfmt) { + if (AST_FORMAT_SLINEAR == ast_format_id_from_old_bitfield(dahdip->fmts.srcfmt)) { ast_debug(1, "Using soft_slin support on source\n"); dahdip->softslin = 1; - dahdip->fmts.srcfmt = AST_FORMAT_ULAW; - } else if (AST_FORMAT_SLINEAR == dahdip->fmts.dstfmt) { + dahdip->fmts.srcfmt = ast_format_id_to_old_bitfield(AST_FORMAT_ULAW); + } else if (AST_FORMAT_SLINEAR == ast_format_id_from_old_bitfield(dahdip->fmts.dstfmt)) { ast_debug(1, "Using soft_slin support on destination\n"); dahdip->softslin = 1; - dahdip->fmts.dstfmt = AST_FORMAT_ULAW; + dahdip->fmts.dstfmt = ast_format_id_to_old_bitfield(AST_FORMAT_ULAW); } tried_once = 1; goto retry; @@ -427,9 +427,9 @@ retry: dahdip->fd = fd; - dahdip->required_samples = ((dahdip->fmts.dstfmt|dahdip->fmts.srcfmt)&AST_FORMAT_G723_1) ? G723_SAMPLES : G729_SAMPLES; + dahdip->required_samples = ((dahdip->fmts.dstfmt|dahdip->fmts.srcfmt) & (ast_format_id_to_old_bitfield(AST_FORMAT_G723_1))) ? G723_SAMPLES : G729_SAMPLES; - switch (dahdip->fmts.dstfmt) { + switch (ast_format_id_from_old_bitfield(dahdip->fmts.dstfmt)) { case AST_FORMAT_G729A: ast_atomic_fetchadd_int(&channels.encoders, +1); break; @@ -446,7 +446,9 @@ retry: static int dahdi_new(struct ast_trans_pvt *pvt) { - return dahdi_translate(pvt, pvt->t->dstfmt, pvt->t->srcfmt); + return dahdi_translate(pvt, + &pvt->t->dst_format, + &pvt->t->src_format); } static struct ast_frame *fakesrc_sample(void) @@ -463,7 +465,9 @@ static struct ast_frame *fakesrc_sample(void) static int is_encoder(struct translator *zt) { - if (zt->t.srcfmt&(AST_FORMAT_ULAW|AST_FORMAT_ALAW|AST_FORMAT_SLINEAR)) { + if ((zt->t.src_format.id == AST_FORMAT_ULAW) || + (zt->t.src_format.id == AST_FORMAT_ALAW) || + (zt->t.src_format.id == AST_FORMAT_SLINEAR)) { return 1; } else { return 0; @@ -474,15 +478,20 @@ static int register_translator(int dst, int src) { struct translator *zt; int res; + struct ast_format dst_format; + struct ast_format src_format; + + ast_format_from_old_bitfield(&dst_format, (1 << dst)); + ast_format_from_old_bitfield(&src_format, (1 << src)); if (!(zt = ast_calloc(1, sizeof(*zt)))) { return -1; } snprintf((char *) (zt->t.name), sizeof(zt->t.name), "zap%sto%s", - ast_getformatname((1 << src)), ast_getformatname((1 << dst))); - zt->t.srcfmt = (1 << src); - zt->t.dstfmt = (1 << dst); + ast_getformatname(&src_format), ast_getformatname(&dst_format)); + ast_format_copy(&zt->t.src_format, &src_format); + ast_format_copy(&zt->t.dst_format, &dst_format); zt->t.buf_size = BUFFER_SIZE; if (is_encoder(zt)) { zt->t.framein = dahdi_encoder_framein; @@ -518,10 +527,10 @@ static void drop_translator(int dst, int src) AST_LIST_LOCK(&translators); AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, cur, entry) { - if (cur->t.srcfmt != src) + if (cur->t.src_format.id != ast_format_id_from_old_bitfield((1 << src))) continue; - if (cur->t.dstfmt != dst) + if (cur->t.dst_format.id != ast_format_id_from_old_bitfield((1 << dst))) continue; AST_LIST_REMOVE_CURRENT(entry); diff --git a/codecs/codec_g722.c b/codecs/codec_g722.c index 22196da01..9c3a01846 100644 --- a/codecs/codec_g722.c +++ b/codecs/codec_g722.c @@ -134,8 +134,6 @@ static int lintog722_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) static struct ast_translator g722tolin = { .name = "g722tolin", - .srcfmt = AST_FORMAT_G722, - .dstfmt = AST_FORMAT_SLINEAR, .newpvt = g722tolin_new, /* same for both directions */ .framein = g722tolin_framein, .sample = g722_sample, @@ -146,8 +144,6 @@ static struct ast_translator g722tolin = { static struct ast_translator lintog722 = { .name = "lintog722", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_G722, .newpvt = lintog722_new, /* same for both directions */ .framein = lintog722_framein, .sample = slin8_sample, @@ -158,8 +154,6 @@ static struct ast_translator lintog722 = { static struct ast_translator g722tolin16 = { .name = "g722tolin16", - .srcfmt = AST_FORMAT_G722, - .dstfmt = AST_FORMAT_SLINEAR16, .newpvt = g722tolin16_new, /* same for both directions */ .framein = g722tolin_framein, .sample = g722_sample, @@ -170,8 +164,6 @@ static struct ast_translator g722tolin16 = { static struct ast_translator lin16tog722 = { .name = "lin16tog722", - .srcfmt = AST_FORMAT_SLINEAR16, - .dstfmt = AST_FORMAT_G722, .newpvt = lin16tog722_new, /* same for both directions */ .framein = lintog722_framein, .sample = slin16_sample, @@ -201,6 +193,18 @@ static int load_module(void) { int res = 0; + ast_format_set(&g722tolin.src_format, AST_FORMAT_G722, 0); + ast_format_set(&g722tolin.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&lintog722.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintog722.dst_format, AST_FORMAT_G722, 0); + + ast_format_set(&g722tolin16.src_format, AST_FORMAT_G722, 0); + ast_format_set(&g722tolin16.dst_format, AST_FORMAT_SLINEAR16, 0); + + ast_format_set(&lin16tog722.src_format, AST_FORMAT_SLINEAR16, 0); + ast_format_set(&lin16tog722.dst_format, AST_FORMAT_G722, 0); + res |= ast_register_translator(&g722tolin); res |= ast_register_translator(&lintog722); res |= ast_register_translator(&g722tolin16); diff --git a/codecs/codec_g726.c b/codecs/codec_g726.c index cc9b1cb31..f8a57f740 100644 --- a/codecs/codec_g726.c +++ b/codecs/codec_g726.c @@ -771,8 +771,6 @@ static int lintog726_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) static struct ast_translator g726tolin = { .name = "g726tolin", - .srcfmt = AST_FORMAT_G726, - .dstfmt = AST_FORMAT_SLINEAR, .newpvt = lintog726_new, /* same for both directions */ .framein = g726tolin_framein, .sample = g726_sample, @@ -783,8 +781,6 @@ static struct ast_translator g726tolin = { static struct ast_translator lintog726 = { .name = "lintog726", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_G726, .newpvt = lintog726_new, /* same for both directions */ .framein = lintog726_framein, .sample = slin8_sample, @@ -795,8 +791,6 @@ static struct ast_translator lintog726 = { static struct ast_translator g726aal2tolin = { .name = "g726aal2tolin", - .srcfmt = AST_FORMAT_G726_AAL2, - .dstfmt = AST_FORMAT_SLINEAR, .newpvt = lintog726_new, /* same for both directions */ .framein = g726aal2tolin_framein, .sample = g726_sample, @@ -807,8 +801,6 @@ static struct ast_translator g726aal2tolin = { static struct ast_translator lintog726aal2 = { .name = "lintog726aal2", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_G726_AAL2, .newpvt = lintog726_new, /* same for both directions */ .framein = lintog726aal2_framein, .sample = slin8_sample, @@ -839,6 +831,18 @@ static int load_module(void) { int res = 0; + ast_format_set(&g726tolin.src_format, AST_FORMAT_G726, 0); + ast_format_set(&g726tolin.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&lintog726.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintog726.dst_format, AST_FORMAT_G726, 0); + + ast_format_set(&g726aal2tolin.src_format, AST_FORMAT_G726_AAL2, 0); + ast_format_set(&g726aal2tolin.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&lintog726aal2.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintog726aal2.dst_format, AST_FORMAT_G726_AAL2, 0); + res |= ast_register_translator(&g726tolin); res |= ast_register_translator(&lintog726); diff --git a/codecs/codec_gsm.c b/codecs/codec_gsm.c index ab2815445..46c1c84fb 100644 --- a/codecs/codec_gsm.c +++ b/codecs/codec_gsm.c @@ -168,8 +168,6 @@ static void gsm_destroy_stuff(struct ast_trans_pvt *pvt) static struct ast_translator gsmtolin = { .name = "gsmtolin", - .srcfmt = AST_FORMAT_GSM, - .dstfmt = AST_FORMAT_SLINEAR, .newpvt = gsm_new, .framein = gsmtolin_framein, .destroy = gsm_destroy_stuff, @@ -181,8 +179,6 @@ static struct ast_translator gsmtolin = { static struct ast_translator lintogsm = { .name = "lintogsm", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_GSM, .newpvt = gsm_new, .framein = lintogsm_framein, .frameout = lintogsm_frameout, @@ -213,6 +209,12 @@ static int load_module(void) { int res; + ast_format_set(&gsmtolin.src_format, AST_FORMAT_GSM, 0); + ast_format_set(&gsmtolin.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&lintogsm.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintogsm.dst_format, AST_FORMAT_GSM, 0); + res = ast_register_translator(&gsmtolin); if (!res) res=ast_register_translator(&lintogsm); diff --git a/codecs/codec_ilbc.c b/codecs/codec_ilbc.c index 3227dc80e..bbd0019de 100644 --- a/codecs/codec_ilbc.c +++ b/codecs/codec_ilbc.c @@ -166,8 +166,6 @@ static struct ast_frame *lintoilbc_frameout(struct ast_trans_pvt *pvt) static struct ast_translator ilbctolin = { .name = "ilbctolin", - .srcfmt = AST_FORMAT_ILBC, - .dstfmt = AST_FORMAT_SLINEAR, .newpvt = ilbctolin_new, .framein = ilbctolin_framein, .sample = ilbc_sample, @@ -178,8 +176,6 @@ static struct ast_translator ilbctolin = { static struct ast_translator lintoilbc = { .name = "lintoilbc", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_ILBC, .newpvt = lintoilbc_new, .framein = lintoilbc_framein, .frameout = lintoilbc_frameout, @@ -202,6 +198,13 @@ static int load_module(void) { int res; + ast_format_set(&ilibctolin.src_format, AST_FORMAT_ILBC, 0); + ast_format_set(&ilibctolin.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&lintoilbc.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintoilbc.dst_format, AST_FORMAT_ILBC, 0); + + res = ast_register_translator(&ilbctolin); if (!res) res=ast_register_translator(&lintoilbc); diff --git a/codecs/codec_lpc10.c b/codecs/codec_lpc10.c index d61729c95..7d1739203 100644 --- a/codecs/codec_lpc10.c +++ b/codecs/codec_lpc10.c @@ -193,8 +193,6 @@ static void lpc10_destroy(struct ast_trans_pvt *arg) static struct ast_translator lpc10tolin = { .name = "lpc10tolin", - .srcfmt = AST_FORMAT_LPC10, - .dstfmt = AST_FORMAT_SLINEAR, .newpvt = lpc10_dec_new, .framein = lpc10tolin_framein, .destroy = lpc10_destroy, @@ -206,8 +204,6 @@ static struct ast_translator lpc10tolin = { static struct ast_translator lintolpc10 = { .name = "lintolpc10", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_LPC10, .newpvt = lpc10_enc_new, .framein = lintolpc10_framein, .frameout = lintolpc10_frameout, @@ -238,6 +234,12 @@ static int load_module(void) { int res; + ast_format_set(&lpc10tolin.src_format, AST_FORMAT_LPC10, 0); + ast_format_set(&lpc10tolin.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&lintolpc10.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintolpc10.dst_format, AST_FORMAT_LPC10, 0); + res = ast_register_translator(&lpc10tolin); if (!res) res = ast_register_translator(&lintolpc10); diff --git a/codecs/codec_resample.c b/codecs/codec_resample.c index 834fb46ba..80823bb7c 100644 --- a/codecs/codec_resample.c +++ b/codecs/codec_resample.c @@ -170,8 +170,6 @@ static int slin8_to_slin16_framein(struct ast_trans_pvt *pvt, struct ast_frame * static struct ast_translator slin16_to_slin8 = { .name = "slin16_to_slin8", - .srcfmt = AST_FORMAT_SLINEAR16, - .dstfmt = AST_FORMAT_SLINEAR, .newpvt = slin16_to_slin8_new, .destroy = slin16_to_slin8_destroy, .framein = slin16_to_slin8_framein, @@ -183,8 +181,6 @@ static struct ast_translator slin16_to_slin8 = { static struct ast_translator slin8_to_slin16 = { .name = "slin8_to_slin16", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_SLINEAR16, .newpvt = slin8_to_slin16_new, .destroy = slin8_to_slin16_destroy, .framein = slin8_to_slin16_framein, @@ -208,6 +204,12 @@ static int load_module(void) { int res = 0; + ast_format_set(&slin16_to_slin8.src_format, AST_FORMAT_SLINEAR16, 0); + ast_format_set(&slin16_to_slin8.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&slin8_to_slin16.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&slin8_to_slin16.dst_format, AST_FORMAT_SLINEAR16, 0); + res |= ast_register_translator(&slin16_to_slin8); res |= ast_register_translator(&slin8_to_slin16); diff --git a/codecs/codec_speex.c b/codecs/codec_speex.c index 2bfdec228..aaaa1bea2 100644 --- a/codecs/codec_speex.c +++ b/codecs/codec_speex.c @@ -330,8 +330,6 @@ static void lintospeex_destroy(struct ast_trans_pvt *arg) static struct ast_translator speextolin = { .name = "speextolin", - .srcfmt = AST_FORMAT_SPEEX, - .dstfmt = AST_FORMAT_SLINEAR, .newpvt = speextolin_new, .framein = speextolin_framein, .destroy = speextolin_destroy, @@ -344,8 +342,6 @@ static struct ast_translator speextolin = { static struct ast_translator lintospeex = { .name = "lintospeex", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_SPEEX, .newpvt = lintospeex_new, .framein = lintospeex_framein, .frameout = lintospeex_frameout, @@ -358,8 +354,6 @@ static struct ast_translator lintospeex = { static struct ast_translator speexwbtolin16 = { .name = "speexwbtolin16", - .srcfmt = AST_FORMAT_SPEEX16, - .dstfmt = AST_FORMAT_SLINEAR16, .newpvt = speexwbtolin16_new, .framein = speextolin_framein, .destroy = speextolin_destroy, @@ -372,8 +366,6 @@ static struct ast_translator speexwbtolin16 = { static struct ast_translator lin16tospeexwb = { .name = "lin16tospeexwb", - .srcfmt = AST_FORMAT_SLINEAR16, - .dstfmt = AST_FORMAT_SPEEX16, .newpvt = lin16tospeexwb_new, .framein = lintospeex_framein, .frameout = lintospeex_frameout, @@ -505,6 +497,19 @@ static int load_module(void) if (parse_config(0)) return AST_MODULE_LOAD_DECLINE; + + ast_format_set(&speextolin.src_format, AST_FORMAT_SPEEX, 0); + ast_format_set(&speextolin.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&lintospeex.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintospeex.dst_format, AST_FORMAT_SPEEX, 0); + + ast_format_set(&speexwbtolin16.src_format, AST_FORMAT_SPEEX16, 0); + ast_format_set(&speexwbtolin16.dst_format, AST_FORMAT_SLINEAR16, 0); + + ast_format_set(&lin16tospeexwb.src_format, AST_FORMAT_SLINEAR16, 0); + ast_format_set(&lin16tospeexwb.dst_format, AST_FORMAT_SPEEX16, 0); + res |= ast_register_translator(&speextolin); res |= ast_register_translator(&lintospeex); res |= ast_register_translator(&speexwbtolin16); diff --git a/codecs/codec_ulaw.c b/codecs/codec_ulaw.c index 07f5da39d..b5211a585 100644 --- a/codecs/codec_ulaw.c +++ b/codecs/codec_ulaw.c @@ -78,8 +78,6 @@ static int lintoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) static struct ast_translator ulawtolin = { .name = "ulawtolin", - .srcfmt = AST_FORMAT_ULAW, - .dstfmt = AST_FORMAT_SLINEAR, .framein = ulawtolin_framein, .sample = ulaw_sample, .buffer_samples = BUFFER_SAMPLES, @@ -88,8 +86,6 @@ static struct ast_translator ulawtolin = { static struct ast_translator testlawtolin = { .name = "testlawtolin", - .srcfmt = AST_FORMAT_TESTLAW, - .dstfmt = AST_FORMAT_SLINEAR, .framein = ulawtolin_framein, .sample = ulaw_sample, .buffer_samples = BUFFER_SAMPLES, @@ -102,8 +98,6 @@ static struct ast_translator testlawtolin = { static struct ast_translator lintoulaw = { .name = "lintoulaw", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_ULAW, .framein = lintoulaw_framein, .sample = slin8_sample, .buf_size = BUFFER_SAMPLES, @@ -112,8 +106,6 @@ static struct ast_translator lintoulaw = { static struct ast_translator lintotestlaw = { .name = "lintotestlaw", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_TESTLAW, .framein = lintoulaw_framein, .sample = slin8_sample, .buf_size = BUFFER_SAMPLES, @@ -141,6 +133,18 @@ static int load_module(void) { int res; + ast_format_set(&lintoulaw.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintoulaw.dst_format, AST_FORMAT_ULAW, 0); + + ast_format_set(&lintotestlaw.src_format, AST_FORMAT_SLINEAR, 0); + ast_format_set(&lintotestlaw.dst_format, AST_FORMAT_TESTLAW, 0); + + ast_format_set(&ulawtolin.src_format, AST_FORMAT_ULAW, 0); + ast_format_set(&ulawtolin.dst_format, AST_FORMAT_SLINEAR, 0); + + ast_format_set(&testlawtolin.src_format, AST_FORMAT_TESTLAW, 0); + ast_format_set(&testlawtolin.dst_format, AST_FORMAT_SLINEAR, 0); + res = ast_register_translator(&ulawtolin); if (!res) { res = ast_register_translator(&lintoulaw); diff --git a/codecs/ex_adpcm.h b/codecs/ex_adpcm.h index 8a1a5eea9..96b7c51f8 100644 --- a/codecs/ex_adpcm.h +++ b/codecs/ex_adpcm.h @@ -19,7 +19,6 @@ static struct ast_frame *adpcm_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_ADPCM, .datalen = sizeof(ex_adpcm), .samples = ARRAY_LEN(ex_adpcm) * 2, .mallocd = 0, @@ -27,6 +26,7 @@ static struct ast_frame *adpcm_sample(void) .src = __PRETTY_FUNCTION__, .data.ptr = ex_adpcm, }; + ast_format_set(&f.subclass.format, AST_FORMAT_ADPCM, 0); return &f; } diff --git a/codecs/ex_alaw.h b/codecs/ex_alaw.h index 5a03111fa..bbf8ad982 100644 --- a/codecs/ex_alaw.h +++ b/codecs/ex_alaw.h @@ -24,7 +24,6 @@ static struct ast_frame *alaw_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_ALAW, .datalen = sizeof(ex_alaw), .samples = ARRAY_LEN(ex_alaw), .mallocd = 0, @@ -32,6 +31,6 @@ static struct ast_frame *alaw_sample(void) .src = __PRETTY_FUNCTION__, .data.ptr = ex_alaw, }; - + ast_format_set(&f.subclass.format, AST_FORMAT_ALAW, 0); return &f; } diff --git a/codecs/ex_g722.h b/codecs/ex_g722.h index 61146909e..0e9f22686 100644 --- a/codecs/ex_g722.h +++ b/codecs/ex_g722.h @@ -34,7 +34,6 @@ static struct ast_frame *g722_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_G722, .datalen = sizeof(ex_g722), .samples = ARRAY_LEN(ex_g722), .mallocd = 0, @@ -43,5 +42,7 @@ static struct ast_frame *g722_sample(void) .data.ptr = ex_g722, }; + ast_format_set(&f.subclass.format, AST_FORMAT_G722, 0); + return &f; } diff --git a/codecs/ex_g726.h b/codecs/ex_g726.h index 622418a27..d5438c91a 100644 --- a/codecs/ex_g726.h +++ b/codecs/ex_g726.h @@ -19,7 +19,6 @@ static struct ast_frame *g726_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_G726, .datalen = sizeof(ex_g726), .samples = ARRAY_LEN(ex_g726) * 2, /* 2 samples per byte */ .mallocd = 0, @@ -28,5 +27,7 @@ static struct ast_frame *g726_sample(void) .data.ptr = ex_g726, }; + ast_format_set(&f.subclass.format, AST_FORMAT_G726, 0); + return &f; } diff --git a/codecs/ex_gsm.h b/codecs/ex_gsm.h index 0e4cffab0..8f8b4f9fe 100644 --- a/codecs/ex_gsm.h +++ b/codecs/ex_gsm.h @@ -18,7 +18,6 @@ static struct ast_frame *gsm_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_GSM, .datalen = sizeof(ex_gsm), /* All frames are 20 ms long */ .samples = GSM_SAMPLES, @@ -28,5 +27,6 @@ static struct ast_frame *gsm_sample(void) .data.ptr = ex_gsm, }; + ast_format_set(&f.subclass.format, AST_FORMAT_GSM, 0); return &f; } diff --git a/codecs/ex_lpc10.h b/codecs/ex_lpc10.h index 9c2ded88b..a36e06add 100644 --- a/codecs/ex_lpc10.h +++ b/codecs/ex_lpc10.h @@ -15,7 +15,6 @@ static struct ast_frame *lpc10_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_LPC10, .datalen = sizeof(ex_lpc10), /* All frames are 22 ms long (maybe a little more -- why did he choose LPC10_SAMPLES_PER_FRAME sample frames anyway?? */ @@ -26,5 +25,7 @@ static struct ast_frame *lpc10_sample(void) .data.ptr = ex_lpc10, }; + ast_format_set(&f.subclass.format, AST_FORMAT_LPC10, 0); + return &f; } diff --git a/codecs/ex_speex.h b/codecs/ex_speex.h index 60ccf092e..e9411e5d7 100644 --- a/codecs/ex_speex.h +++ b/codecs/ex_speex.h @@ -18,7 +18,6 @@ static struct ast_frame *speex_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_SPEEX, .datalen = sizeof(ex_speex), /* All frames are 20 ms long */ .samples = SPEEX_SAMPLES, @@ -28,6 +27,8 @@ static struct ast_frame *speex_sample(void) .data.ptr = ex_speex, }; + ast_format_set(&f.subclass.format, AST_FORMAT_SPEEX, 0); + return &f; } @@ -49,7 +50,6 @@ static struct ast_frame *speex16_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_SPEEX16, .datalen = sizeof(ex_speex16), /* All frames are 20 ms long */ .samples = SPEEX_SAMPLES, @@ -58,6 +58,7 @@ static struct ast_frame *speex16_sample(void) .src = __PRETTY_FUNCTION__, .data.ptr = ex_speex16, }; + ast_format_set(&f.subclass.format, AST_FORMAT_SPEEX16, 0); return &f; } diff --git a/codecs/ex_ulaw.h b/codecs/ex_ulaw.h index b3970f5f8..2ab9222fb 100644 --- a/codecs/ex_ulaw.h +++ b/codecs/ex_ulaw.h @@ -24,7 +24,6 @@ static struct ast_frame *ulaw_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_ULAW, .datalen = sizeof(ex_ulaw), .samples = ARRAY_LEN(ex_ulaw), .mallocd = 0, @@ -33,5 +32,6 @@ static struct ast_frame *ulaw_sample(void) .data.ptr = ex_ulaw, }; + ast_format_set(&f.subclass.format, AST_FORMAT_ULAW, 0); return &f; } |