[svn-commits] file: branch group/media_formats-reviewed r410189 - in /team/group/media_form...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Mar 7 15:09:56 CST 2014


Author: file
Date: Fri Mar  7 15:09:53 2014
New Revision: 410189

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410189
Log:
Merge in changes to codec modules.

Modified:
    team/group/media_formats-reviewed/codecs/codec_a_mu.c
    team/group/media_formats-reviewed/codecs/codec_adpcm.c
    team/group/media_formats-reviewed/codecs/codec_alaw.c
    team/group/media_formats-reviewed/codecs/codec_dahdi.c
    team/group/media_formats-reviewed/codecs/codec_g722.c
    team/group/media_formats-reviewed/codecs/codec_g726.c
    team/group/media_formats-reviewed/codecs/codec_gsm.c
    team/group/media_formats-reviewed/codecs/codec_ilbc.c
    team/group/media_formats-reviewed/codecs/codec_lpc10.c
    team/group/media_formats-reviewed/codecs/codec_resample.c
    team/group/media_formats-reviewed/codecs/codec_speex.c
    team/group/media_formats-reviewed/codecs/codec_ulaw.c
    team/group/media_formats-reviewed/codecs/ex_g722.h
    team/group/media_formats-reviewed/codecs/ex_g726.h
    team/group/media_formats-reviewed/codecs/ex_gsm.h
    team/group/media_formats-reviewed/codecs/ex_ilbc.h
    team/group/media_formats-reviewed/codecs/ex_lpc10.h
    team/group/media_formats-reviewed/codecs/ex_speex.h
    team/group/media_formats-reviewed/codecs/ex_ulaw.h
    team/group/media_formats-reviewed/include/asterisk/format_cache.h
    team/group/media_formats-reviewed/include/asterisk/translate.h
    team/group/media_formats-reviewed/main/translate.c

Modified: team/group/media_formats-reviewed/codecs/codec_a_mu.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_a_mu.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_a_mu.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_a_mu.c Fri Mar  7 15:09:53 2014
@@ -80,6 +80,17 @@
 
 static struct ast_translator alawtoulaw = {
 	.name = "alawtoulaw",
+	.src_codec = {
+		.name = "alaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "ulaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "ulaw",
 	.framein = alawtoulaw_framein,
 	.sample = alaw_sample,
 	.buffer_samples = BUFFER_SAMPLES,
@@ -88,6 +99,17 @@
 
 static struct ast_translator ulawtoalaw = {
 	.name = "ulawtoalaw",
+	.src_codec = {
+		.name = "ulaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "alaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "alaw",
 	.framein = ulawtoalaw_framein,
 	.sample = ulaw_sample,
 	.buffer_samples = BUFFER_SAMPLES,
@@ -111,23 +133,19 @@
 	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));
 	}
+
 	res = ast_register_translator(&alawtoulaw);
-	if (!res)
-		res = ast_register_translator(&ulawtoalaw);
-	else
-		ast_unregister_translator(&alawtoulaw);
-	if (res)
+	res |= ast_register_translator(&ulawtoalaw);
+
+	if (res) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
+	}
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: team/group/media_formats-reviewed/codecs/codec_adpcm.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_adpcm.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_adpcm.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_adpcm.c Fri Mar  7 15:09:53 2014
@@ -290,6 +290,17 @@
 
 static struct ast_translator adpcmtolin = {
 	.name = "adpcmtolin",
+	.src_codec = {
+		.name = "adpcm",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.framein = adpcmtolin_framein,
 	.sample = adpcm_sample,
 	.desc_size = sizeof(struct adpcm_decoder_pvt),
@@ -299,6 +310,17 @@
 
 static struct ast_translator lintoadpcm = {
 	.name = "lintoadpcm",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "adpcm",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "adpcm",
 	.framein = lintoadpcm_framein,
 	.frameout = lintoadpcm_frameout,
 	.sample = slin8_sample,
@@ -307,12 +329,6 @@
 	.buf_size = BUFFER_SAMPLES/ 2,	/* 2 samples per byte */
 };
 
-/*! \brief standard module glue */
-static int reload(void)
-{
-	return AST_MODULE_LOAD_SUCCESS;
-}
-
 static int unload_module(void)
 {
 	int res;
@@ -320,23 +336,12 @@
 	res = ast_unregister_translator(&lintoadpcm);
 	res |= ast_unregister_translator(&adpcmtolin);
 
-	ao2_cleanup(adpcmtolin.src_codec);
-	ao2_cleanup(adpcmtolin.dst_codec);
-	ao2_cleanup(lintoadpcm.src_codec);
-	ao2_cleanup(lintoadpcm.dst_codec);
-
 	return res;
 }
 
 static int load_module(void)
 {
 	int res = 0;
-
-	adpcmtolin.src_codec = ast_codec_get("adpcm", AST_MEDIA_TYPE_AUDIO, 8000);
-	adpcmtolin.dst_codec = ast_codec_get("slin", AST_MEDIA_TYPE_AUDIO, 8000);
-
-	lintoadpcm.src_codec = ast_codec_get("slin", AST_MEDIA_TYPE_AUDIO, 8000);
-	lintoadpcm.dst_codec = ast_codec_get("adpcm", AST_MEDIA_TYPE_AUDIO, 8000);
 
 	res = ast_register_translator(&adpcmtolin);
 	res |= ast_register_translator(&lintoadpcm);
@@ -352,5 +357,4 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Adaptive Differential PCM Coder/Decoder",
 		.load = load_module,
 		.unload = unload_module,
-		.reload = reload,
 	       );

Modified: team/group/media_formats-reviewed/codecs/codec_alaw.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_alaw.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_alaw.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_alaw.c Fri Mar  7 15:09:53 2014
@@ -77,6 +77,17 @@
 
 static struct ast_translator alawtolin = {
 	.name = "alawtolin",
+	.src_codec = {
+		.name = "alaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.framein = alawtolin_framein,
 	.sample = alaw_sample,
 	.buffer_samples = BUFFER_SAMPLES,
@@ -84,19 +95,23 @@
 };
 
 static struct ast_translator lintoalaw = {
-	"lintoalaw",
+	.name = "lintoalaw",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "alaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "alaw",
 	.framein = lintoalaw_framein,
 	.sample = slin8_sample,
 	.buffer_samples = BUFFER_SAMPLES,
 	.buf_size = BUFFER_SAMPLES,
 };
-
-/*! \brief standard module stuff */
-
-static int reload(void)
-{
-	return AST_MODULE_LOAD_SUCCESS;
-}
 
 static int unload_module(void)
 {
@@ -112,24 +127,18 @@
 {
 	int res;
 
-	ast_format_set(&lintoalaw.src_format, AST_FORMAT_SLINEAR, 0);
-	ast_format_set(&lintoalaw.dst_format, AST_FORMAT_ALAW, 0);
+	res = ast_register_translator(&alawtolin);
+	res |= ast_register_translator(&lintoalaw);
 
-	ast_format_set(&alawtolin.src_format, AST_FORMAT_ALAW, 0);
-	ast_format_set(&alawtolin.dst_format, AST_FORMAT_SLINEAR, 0);
+	if (res) {
+		unload_module();
+		return AST_MODULE_LOAD_FAILURE;
+	}
 
-	res = ast_register_translator(&alawtolin);
-	if (!res)
-		res = ast_register_translator(&lintoalaw);
-	else
-		ast_unregister_translator(&alawtolin);
-	if (res)
-		return AST_MODULE_LOAD_FAILURE;
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "A-law Coder/Decoder",
 		.load = load_module,
 		.unload = unload_module,
-		.reload = reload,
 	       );

Modified: team/group/media_formats-reviewed/codecs/codec_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_dahdi.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_dahdi.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_dahdi.c Fri Mar  7 15:09:53 2014
@@ -78,6 +78,64 @@
 	int decoders;
 } channels;
 
+static struct ast_codec codecs[] = {
+	[DAHDI_FORMAT_G723_1] = {
+		.name = "g723",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_GSM] = {
+		.name = "gsm",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_ULAW] = {
+		.name = "ulaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_ALAW] = {
+		.name = "alaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_G726] = {
+		.name = "g726",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_ADPCM] = {
+		.name = "adpcm",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_SLINEAR] = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_LPC10] = {
+		.name = "lpc10",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_G729A] = {
+		.name = "g729",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_SPEEX] = {
+		.name = "speex",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	[DAHDI_FORMAT_ILBC] = {
+		.name = "ilbc",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+};
+
 static char *handle_cli_transcoder_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 
 static struct ast_cli_entry cli[] = {
@@ -190,7 +248,7 @@
 {
 	struct codec_dahdi_pvt *dahdip = pvt->pvt;
 
-	if (!f->subclass.format.id) {
+	if (!f->subclass.format) {
 		/* We're just faking a return for calculation purposes. */
 		dahdip->fake = 2;
 		pvt->samples = f->samples;
@@ -247,7 +305,8 @@
 	if (2 == dahdip->fake) {
 		dahdip->fake = 1;
 		pvt->f.frametype = AST_FRAME_VOICE;
-		ast_format_clear(&pvt->f.subclass.format);
+		ao2_cleanup(pvt->f.subclass.format);
+		pvt->f.subclass.format = NULL;
 		pvt->f.samples = dahdip->required_samples;
 		pvt->f.data.ptr = NULL;
 		pvt->f.offset = 0;
@@ -277,13 +336,7 @@
 		}
 	} else {
 		pvt->f.datalen = res;
-		pvt->f.frametype = AST_FRAME_VOICE;
-		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;
-		pvt->f.data.ptr = pvt->outbuf.c;
-		pvt->f.samples = ast_codec_get_samples(&pvt->f);
+		pvt->f.samples = ast_codec_samples_count(&pvt->f);
 
 		dahdip->samples_written_to_hardware =
 		  (dahdip->samples_written_to_hardware >= pvt->f.samples) ?
@@ -302,7 +355,7 @@
 {
 	struct codec_dahdi_pvt *dahdip = pvt->pvt;
 
-	if (!f->subclass.format.id) {
+	if (!f->subclass.format) {
 		/* We're just faking a return for calculation purposes. */
 		dahdip->fake = 2;
 		pvt->samples = f->samples;
@@ -329,7 +382,8 @@
 	if (2 == dahdip->fake) {
 		dahdip->fake = 1;
 		pvt->f.frametype = AST_FRAME_VOICE;
-		ast_format_clear(&pvt->f.subclass.format);
+		ao2_cleanup(pvt->f.subclass.format);
+		pvt->f.subclass.format = NULL;
 		pvt->f.samples = dahdip->required_samples;
 		pvt->f.data.ptr = NULL;
 		pvt->f.offset = 0;
@@ -370,12 +424,6 @@
 			pvt->f.datalen = res;
 		}
 		pvt->datalen = 0;
-		pvt->f.frametype = AST_FRAME_VOICE;
-		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;
-		pvt->f.data.ptr = pvt->outbuf.c;
 		pvt->f.samples = res;
 		pvt->samples = 0;
 		dahdip->samples_written_to_hardware =
@@ -394,9 +442,9 @@
 {
 	struct codec_dahdi_pvt *dahdip = pvt->pvt;
 
-	switch (ast_format_id_from_old_bitfield(dahdip->fmts.dstfmt)) {
-	case AST_FORMAT_G729A:
-	case AST_FORMAT_G723_1:
+	switch (dahdip->fmts.dstfmt) {
+	case DAHDI_FORMAT_G729A:
+	case DAHDI_FORMAT_G723_1:
 		ast_atomic_fetchadd_int(&channels.encoders, -1);
 		break;
 	default:
@@ -407,7 +455,38 @@
 	close(dahdip->fd);
 }
 
-static int dahdi_translate(struct ast_trans_pvt *pvt, struct ast_format *dst_format, struct ast_format *src_format)
+static struct ast_format *dahdi_format_to_cached(int format)
+{
+	switch (format) {
+	case DAHDI_FORMAT_G723_1:
+		return ast_format_g723;
+	case DAHDI_FORMAT_GSM:
+		return ast_format_gsm;
+	case DAHDI_FORMAT_ULAW:
+		return ast_format_ulaw;
+	case DAHDI_FORMAT_ALAW:
+		return ast_format_alaw;
+	case DAHDI_FORMAT_G726:
+		return ast_format_g726;
+	case DAHDI_FORMAT_ADPCM:
+		return ast_format_adpcm;
+	case DAHDI_FORMAT_SLINEAR:
+		return ast_format_slin;
+	case DAHDI_FORMAT_LPC10:
+		return ast_format_lpc10;
+	case DAHDI_FORMAT_G729A:
+		return ast_format_g729;
+	case DAHDI_FORMAT_SPEEX:
+		return ast_format_speex;
+	case DAHDI_FORMAT_ILBC:
+		return ast_format_ilbc;
+	}
+
+	/* This will never be reached */
+	return NULL;
+}
+
+static int dahdi_translate(struct ast_trans_pvt *pvt, struct ast_codec *dst_codec, struct ast_codec *src_codec)
 {
 	/* Request translation through zap if possible */
 	int fd;
@@ -421,10 +500,17 @@
 		return -1;
 	}
 
-	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 %s to %s.\n", ast_getformatname(src_format), ast_getformatname(dst_format));
+	dahdip->fmts.srcfmt = src_codec->original_id;
+	dahdip->fmts.dstfmt = dst_codec->original_id;
+
+	pvt->f.frametype = AST_FRAME_VOICE;
+	pvt->f.subclass.format = ast_format_copy(dahdi_format_to_cached(dst_codec->original_id));
+	pvt->f.mallocd = 0;
+	pvt->f.offset = AST_FRIENDLY_OFFSET;
+	pvt->f.src = pvt->t->name;
+	pvt->f.data.ptr = pvt->outbuf.c;
+
+	ast_debug(1, "Opening transcoder channel from %s to %s.\n", src_codec->name, dst_codec->name);
 
 retry:
 	if (ioctl(fd, DAHDI_TC_ALLOCATE, &dahdip->fmts)) {
@@ -437,14 +523,14 @@
 			 * support for ULAW instead of signed linear and then
 			 * we'll just convert from ulaw to signed linear in
 			 * software. */
-			if (AST_FORMAT_SLINEAR == ast_format_id_from_old_bitfield(dahdip->fmts.srcfmt)) {
+			if (dahdip->fmts.srcfmt == DAHDI_FORMAT_SLINEAR) {
 				ast_debug(1, "Using soft_slin support on source\n");
 				dahdip->softslin = 1;
-				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)) {
+				dahdip->fmts.srcfmt = DAHDI_FORMAT_ULAW;
+			} else if (dahdip->fmts.dstfmt == DAHDI_FORMAT_SLINEAR) {
 				ast_debug(1, "Using soft_slin support on destination\n");
 				dahdip->softslin = 1;
-				dahdip->fmts.dstfmt = ast_format_id_to_old_bitfield(AST_FORMAT_ULAW);
+				dahdip->fmts.dstfmt = DAHDI_FORMAT_ULAW;
 			}
 			tried_once = 1;
 			goto retry;
@@ -463,13 +549,13 @@
 
 	dahdip->fd = fd;
 
-	dahdip->required_samples = ((dahdip->fmts.dstfmt|dahdip->fmts.srcfmt) & (ast_format_id_to_old_bitfield(AST_FORMAT_G723_1))) ? G723_SAMPLES : G729_SAMPLES;
-
-	switch (ast_format_id_from_old_bitfield(dahdip->fmts.dstfmt)) {
-	case AST_FORMAT_G729A:
+	dahdip->required_samples = ((dahdip->fmts.dstfmt|dahdip->fmts.srcfmt) & (DAHDI_FORMAT_G723_1)) ? G723_SAMPLES : G729_SAMPLES;
+
+	switch (dahdip->fmts.dstfmt) {
+	case DAHDI_FORMAT_G729A:
 		ast_atomic_fetchadd_int(&channels.encoders, +1);
 		break;
-	case AST_FORMAT_G723_1:
+	case DAHDI_FORMAT_G723_1:
 		ast_atomic_fetchadd_int(&channels.encoders, +1);
 		break;
 	default:
@@ -483,8 +569,8 @@
 static int dahdi_new(struct ast_trans_pvt *pvt)
 {
 	return dahdi_translate(pvt,
-		&pvt->t->dst_format,
-		&pvt->t->src_format);
+		pvt->t->core_dst_codec,
+		pvt->t->core_src_codec);
 }
 
 static struct ast_frame *fakesrc_sample(void)
@@ -501,9 +587,9 @@
 
 static int is_encoder(struct translator *zt)
 {
-	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)) {
+	if ((zt->t.core_src_codec->original_id == DAHDI_FORMAT_ULAW) ||
+		(zt->t.core_src_codec->original_id == DAHDI_FORMAT_ALAW) ||
+		(zt->t.core_src_codec->original_id == DAHDI_FORMAT_SLINEAR)) {
 		return 1;
 	} else {
 		return 0;
@@ -514,20 +600,15 @@
 {
 	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(&src_format), ast_getformatname(&dst_format));
-	ast_format_copy(&zt->t.src_format, &src_format);
-	ast_format_copy(&zt->t.dst_format, &dst_format);
+		 codecs[src].name, codecs[dst].name);
+	memcpy(&zt->t.src_codec, &codecs[src], sizeof(struct ast_codec));
+	memcpy(&zt->t.dst_codec, &codecs[dst], sizeof(struct ast_codec));
 	zt->t.buf_size = BUFFER_SIZE;
 	if (is_encoder(zt)) {
 		zt->t.framein = dahdi_encoder_framein;
@@ -563,10 +644,10 @@
 
 	AST_LIST_LOCK(&translators);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, cur, entry) {
-		if (cur->t.src_format.id != ast_format_id_from_old_bitfield((1 << src)))
+		if (cur->t.core_src_codec->original_id != src)
 			continue;
 
-		if (cur->t.dst_format.id != ast_format_id_from_old_bitfield((1 << dst)))
+		if (cur->t.core_dst_codec->original_id != dst)
 			continue;
 
 		AST_LIST_REMOVE_CURRENT(entry);

Modified: team/group/media_formats-reviewed/codecs/codec_g722.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_g722.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_g722.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_g722.c Fri Mar  7 15:09:53 2014
@@ -138,6 +138,17 @@
 
 static struct ast_translator g722tolin = {
 	.name = "g722tolin",
+	.src_codec = {
+		.name = "g722",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.newpvt = g722tolin_new,	/* same for both directions */
 	.framein = g722tolin_framein,
 	.sample = g722_sample,
@@ -148,6 +159,17 @@
 
 static struct ast_translator lintog722 = {
 	.name = "lintog722",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "g722",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	.format = "g722",
 	.newpvt = lintog722_new,	/* same for both directions */
 	.framein = lintog722_framein,
 	.sample = slin8_sample,
@@ -158,6 +180,17 @@
 
 static struct ast_translator g722tolin16 = {
 	.name = "g722tolin16",
+	.src_codec = {
+		.name = "g722",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	.format = "slin16",
 	.newpvt = g722tolin16_new,	/* same for both directions */
 	.framein = g722tolin_framein,
 	.sample = g722_sample,
@@ -168,6 +201,17 @@
 
 static struct ast_translator lin16tog722 = {
 	.name = "lin16tog722",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	.dst_codec = {
+		.name = "g722",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	.format = "g722",
 	.newpvt = lin16tog722_new,	/* same for both directions */
 	.framein = lintog722_framein,
 	.sample = slin16_sample,
@@ -176,11 +220,6 @@
 	.buf_size = BUFFER_SAMPLES,
 };
 
-static int reload(void)
-{
-	return AST_MODULE_LOAD_SUCCESS;
-}
-
 static int unload_module(void)
 {
 	int res = 0;
@@ -197,18 +236,6 @@
 {
 	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);
@@ -225,5 +252,4 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ITU G.722-64kbps G722 Transcoder",
 		.load = load_module,
 		.unload = unload_module,
-		.reload = reload,
 	       );

Modified: team/group/media_formats-reviewed/codecs/codec_g726.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_g726.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_g726.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_g726.c Fri Mar  7 15:09:53 2014
@@ -785,6 +785,17 @@
 
 static struct ast_translator g726tolin = {
 	.name = "g726tolin",
+	.src_codec = {
+		.name = "g726",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.newpvt = lintog726_new,	/* same for both directions */
 	.framein = g726tolin_framein,
 	.sample = g726_sample,
@@ -795,6 +806,17 @@
 
 static struct ast_translator lintog726 = {
 	.name = "lintog726",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "g726",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "g726",
 	.newpvt = lintog726_new,	/* same for both directions */
 	.framein = lintog726_framein,
 	.sample = slin8_sample,
@@ -805,6 +827,17 @@
 
 static struct ast_translator g726aal2tolin = {
 	.name = "g726aal2tolin",
+	.src_codec = {
+		.name = "g726aal2",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.newpvt = lintog726_new,	/* same for both directions */
 	.framein = g726aal2tolin_framein,
 	.sample = g726_sample,
@@ -815,6 +848,17 @@
 
 static struct ast_translator lintog726aal2 = {
 	.name = "lintog726aal2",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "g726aal2",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "g726aal2",
 	.newpvt = lintog726_new,	/* same for both directions */
 	.framein = lintog726aal2_framein,
 	.sample = slin8_sample,
@@ -823,11 +867,6 @@
 	.buf_size = BUFFER_SAMPLES / 2,
 };
 
-static int reload(void)
-{
-	return AST_MODULE_LOAD_SUCCESS;
-}
-
 static int unload_module(void)
 {
 	int res = 0;
@@ -844,18 +883,6 @@
 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);
@@ -874,5 +901,4 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ITU G.726-32kbps G726 Transcoder",
 		.load = load_module,
 		.unload = unload_module,
-		.reload = reload,
 	       );

Modified: team/group/media_formats-reviewed/codecs/codec_gsm.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_gsm.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_gsm.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_gsm.c Fri Mar  7 15:09:53 2014
@@ -168,7 +168,18 @@
 }
 
 static struct ast_translator gsmtolin = {
-	.name = "gsmtolin", 
+	.name = "gsmtolin",
+	.src_codec = {
+		.name = "gsm",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.newpvt = gsm_new,
 	.framein = gsmtolin_framein,
 	.destroy = gsm_destroy_stuff,
@@ -179,7 +190,18 @@
 };
 
 static struct ast_translator lintogsm = {
-	.name = "lintogsm", 
+	.name = "lintogsm",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "gsm",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "gsm",
 	.newpvt = gsm_new,
 	.framein = lintogsm_framein,
 	.frameout = lintogsm_frameout,
@@ -189,19 +211,12 @@
 	.buf_size = (BUFFER_SAMPLES * GSM_FRAME_LEN + GSM_SAMPLES - 1)/GSM_SAMPLES,
 };
 
-/*! \brief standard module glue */
-static int reload(void)
-{
-	return AST_MODULE_LOAD_SUCCESS;
-}
-
 static int unload_module(void)
 {
 	int res;
 
 	res = ast_unregister_translator(&lintogsm);
-	if (!res)
-		res = ast_unregister_translator(&gsmtolin);
+	res |= ast_unregister_translator(&gsmtolin);
 
 	return res;
 }
@@ -210,24 +225,18 @@
 {
 	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);
-	else
-		ast_unregister_translator(&gsmtolin);
-	if (res) 
+	res |= ast_register_translator(&lintogsm);
+
+	if (res) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
+	}
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "GSM Coder/Decoder",
 		.load = load_module,
 		.unload = unload_module,
-		.reload = reload,
 	       );

Modified: team/group/media_formats-reviewed/codecs/codec_ilbc.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_ilbc.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_ilbc.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_ilbc.c Fri Mar  7 15:09:53 2014
@@ -178,7 +178,18 @@
 }
 
 static struct ast_translator ilbctolin = {
-	.name = "ilbctolin", 
+	.name = "ilbctolin",
+	.src_codec = {
+		.name = "ilbc",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.newpvt = ilbctolin_new,
 	.framein = ilbctolin_framein,
 	.sample = ilbc_sample,
@@ -188,7 +199,18 @@
 };
 
 static struct ast_translator lintoilbc = {
-	.name = "lintoilbc", 
+	.name = "lintoilbc",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "ilbc",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "ilbc",
 	.newpvt = lintoilbc_new,
 	.framein = lintoilbc_framein,
 	.frameout = lintoilbc_frameout,
@@ -211,20 +233,14 @@
 {
 	int res;
 
-	ast_format_set(&ilbctolin.src_format, AST_FORMAT_ILBC, 0);
-	ast_format_set(&ilbctolin.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);
-	else
-		ast_unregister_translator(&ilbctolin);
-	if (res)
+	res |= ast_register_translator(&lintoilbc);
+
+	if (res) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
+	}
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: team/group/media_formats-reviewed/codecs/codec_lpc10.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_lpc10.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_lpc10.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_lpc10.c Fri Mar  7 15:09:53 2014
@@ -196,7 +196,18 @@
 }
 
 static struct ast_translator lpc10tolin = {
-	.name = "lpc10tolin", 
+	.name = "lpc10tolin",
+	.src_codec = {
+		.name = "lpc10",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.newpvt = lpc10_dec_new,
 	.framein = lpc10tolin_framein,
 	.destroy = lpc10_destroy,
@@ -207,7 +218,18 @@
 };
 
 static struct ast_translator lintolpc10 = {
-	.name = "lintolpc10", 
+	.name = "lintolpc10",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "lpc10",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "lpc10",
 	.newpvt = lpc10_enc_new,
 	.framein = lintolpc10_framein,
 	.frameout = lintolpc10_frameout,
@@ -218,12 +240,6 @@
 	.buf_size = LPC10_BYTES_IN_COMPRESSED_FRAME * (1 + BUFFER_SAMPLES / LPC10_SAMPLES_PER_FRAME),
 };
 
-static int reload(void)
-{
-	return AST_MODULE_LOAD_SUCCESS;
-}
-
-
 static int unload_module(void)
 {
 	int res;
@@ -238,24 +254,18 @@
 {
 	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);
-	else
-		ast_unregister_translator(&lpc10tolin);
-	if (res)
+	res |= ast_register_translator(&lintolpc10);
+
+	if (res) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
+	}
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "LPC10 2.4kbps Coder/Decoder",
 		.load = load_module,
 		.unload = unload_module,
-		.reload = reload,
 	       );

Modified: team/group/media_formats-reviewed/codecs/codec_resample.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_resample.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_resample.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_resample.c Fri Mar  7 15:09:53 2014
@@ -42,25 +42,63 @@
 
 static struct ast_translator *translators;
 static int trans_size;
-static int id_list[] = {
-	AST_FORMAT_SLINEAR,
-	AST_FORMAT_SLINEAR12,
-	AST_FORMAT_SLINEAR16,
-	AST_FORMAT_SLINEAR24,
-	AST_FORMAT_SLINEAR32,
-	AST_FORMAT_SLINEAR44,
-	AST_FORMAT_SLINEAR48,
-	AST_FORMAT_SLINEAR96,
-	AST_FORMAT_SLINEAR192,
+static struct ast_codec codec_list[] = {
+	{
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	{
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 12000,
+	},
+	{
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	{
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 24000,
+	},
+	{
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 32000,
+	},
+	{
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 44000,
+	},
+	{
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 48000,
+	},
+	{
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 96000,
+	},
+	{
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 192000,
+	},
 };
 
 static int resamp_new(struct ast_trans_pvt *pvt)
 {
 	int err;
 
-	if (!(pvt->pvt = speex_resampler_init(1, ast_format_rate(&pvt->t->src_format), ast_format_rate(&pvt->t->dst_format), 5, &err))) {
+	if (!(pvt->pvt = speex_resampler_init(1, pvt->t->src_codec.sample_rate, pvt->t->dst_codec.sample_rate, 5, &err))) {
 		return -1;
 	}
+
+	pvt->f.subclass.format = ast_format_cache_get_slin_by_rate(pvt->t->dst_codec.sample_rate);
 
 	return 0;
 }
@@ -113,13 +151,13 @@
 	int res = 0;
 	int x, y, idx = 0;
 
-	trans_size = ARRAY_LEN(id_list) * (ARRAY_LEN(id_list) - 1);
+	trans_size = ARRAY_LEN(codec_list) * (ARRAY_LEN(codec_list) - 1);
 	if (!(translators = ast_calloc(1, sizeof(struct ast_translator) * trans_size))) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
-	for (x = 0; x < ARRAY_LEN(id_list); x++) {
-		for (y = 0; y < ARRAY_LEN(id_list); y++) {
+	for (x = 0; x < ARRAY_LEN(codec_list); x++) {
+		for (y = 0; y < ARRAY_LEN(codec_list); y++) {
 			if (x == y) {
 				continue;
 			}
@@ -129,10 +167,10 @@
 			translators[idx].desc_size = 0;
 			translators[idx].buffer_samples = (OUTBUF_SIZE / sizeof(int16_t));
 			translators[idx].buf_size = OUTBUF_SIZE;
-			ast_format_set(&translators[idx].src_format, id_list[x], 0);
-			ast_format_set(&translators[idx].dst_format, id_list[y], 0);
+			memcpy(&translators[idx].src_codec, &codec_list[x], sizeof(struct ast_codec));
+			memcpy(&translators[idx].dst_codec, &codec_list[y], sizeof(struct ast_codec));
 			snprintf(translators[idx].name, sizeof(translators[idx].name), "slin %dkhz -> %dkhz",
-				ast_format_rate(&translators[idx].src_format), ast_format_rate(&translators[idx].dst_format));
+				translators[idx].src_codec.sample_rate, translators[idx].dst_codec.sample_rate);
 			res |= ast_register_translator(&translators[idx]);
 			idx++;
 		}

Modified: team/group/media_formats-reviewed/codecs/codec_speex.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_speex.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_speex.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_speex.c Fri Mar  7 15:09:53 2014
@@ -341,7 +341,18 @@
 }
 
 static struct ast_translator speextolin = {
-	.name = "speextolin", 
+	.name = "speextolin",
+	.src_codec = {
+		.name = "speex",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.newpvt = speextolin_new,
 	.framein = speextolin_framein,
 	.destroy = speextolin_destroy,
@@ -354,6 +365,17 @@
 
 static struct ast_translator lintospeex = {
 	.name = "lintospeex", 
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "speex",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "speex",
 	.newpvt = lintospeex_new,
 	.framein = lintospeex_framein,
 	.frameout = lintospeex_frameout,
@@ -365,7 +387,18 @@
 };
 
 static struct ast_translator speexwbtolin16 = {
-	.name = "speexwbtolin16", 
+	.name = "speexwbtolin16",
+	.src_codec = {
+		.name = "speex",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	}, 
+	.format = "slin16",
 	.newpvt = speexwbtolin16_new,
 	.framein = speextolin_framein,
 	.destroy = speextolin_destroy,
@@ -377,7 +410,18 @@
 };
 
 static struct ast_translator lin16tospeexwb = {
-	.name = "lin16tospeexwb", 
+	.name = "lin16tospeexwb",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	.dst_codec = {
+		.name = "speex",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 16000,
+	},
+	.format = "speex16",
 	.newpvt = lin16tospeexwb_new,
 	.framein = lintospeex_framein,
 	.frameout = lintospeex_frameout,
@@ -389,7 +433,18 @@
 };
 
 static struct ast_translator speexuwbtolin32 = {
-	.name = "speexuwbtolin32", 
+	.name = "speexuwbtolin32",
+	.src_codec = {
+		.name = "speex",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 32000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 32000,
+	},
+	.format = "slin32",
 	.newpvt = speexuwbtolin32_new,
 	.framein = speextolin_framein,
 	.destroy = speextolin_destroy,
@@ -400,7 +455,18 @@
 };
 
 static struct ast_translator lin32tospeexuwb = {
-	.name = "lin32tospeexuwb", 
+	.name = "lin32tospeexuwb",
+	.src_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 32000,
+	},
+	.dst_codec = {
+		.name = "speex",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 32000,
+	},
+	.format = "speex32",
 	.newpvt = lin32tospeexuwb_new,
 	.framein = lintospeex_framein,
 	.frameout = lintospeex_frameout,
@@ -534,25 +600,6 @@
 	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);
-
-	ast_format_set(&speexuwbtolin32.src_format, AST_FORMAT_SPEEX32, 0);
-	ast_format_set(&speexuwbtolin32.dst_format, AST_FORMAT_SLINEAR32, 0);
-
-	ast_format_set(&lin32tospeexuwb.src_format, AST_FORMAT_SLINEAR32, 0);
-	ast_format_set(&lin32tospeexuwb.dst_format, AST_FORMAT_SPEEX32, 0);
-
 	res |= ast_register_translator(&speextolin);
 	res |= ast_register_translator(&lintospeex);
 	res |= ast_register_translator(&speexwbtolin16);
@@ -560,6 +607,10 @@
 	res |= ast_register_translator(&speexuwbtolin32);
 	res |= ast_register_translator(&lin32tospeexuwb);
 
+	if (res) {
+		unload_module();
+		return res;
+	}
 
 	return res;
 }

Modified: team/group/media_formats-reviewed/codecs/codec_ulaw.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/codecs/codec_ulaw.c?view=diff&rev=410189&r1=410188&r2=410189
==============================================================================
--- team/group/media_formats-reviewed/codecs/codec_ulaw.c (original)
+++ team/group/media_formats-reviewed/codecs/codec_ulaw.c Fri Mar  7 15:09:53 2014
@@ -82,6 +82,17 @@
 
 static struct ast_translator ulawtolin = {
 	.name = "ulawtolin",
+	.src_codec = {
+		.name = "ulaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.framein = ulawtolin_framein,
 	.sample = ulaw_sample,
 	.buffer_samples = BUFFER_SAMPLES,
@@ -90,6 +101,17 @@
 
 static struct ast_translator testlawtolin = {
 	.name = "testlawtolin",
+	.src_codec = {
+		.name = "testlaw",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.dst_codec = {
+		.name = "slin",
+		.type = AST_MEDIA_TYPE_AUDIO,
+		.sample_rate = 8000,
+	},
+	.format = "slin",
 	.framein = ulawtolin_framein,
 	.sample = ulaw_sample,
 	.buffer_samples = BUFFER_SAMPLES,
@@ -102,6 +124,17 @@
 

[... 288 lines stripped ...]



More information about the svn-commits mailing list