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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}