[asterisk-commits] tilghman: branch group/codec_bits r111950 - in /team/group/codec_bits: apps/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 29 03:29:39 CDT 2008


Author: tilghman
Date: Sat Mar 29 03:29:35 2008
New Revision: 111950

URL: http://svn.digium.com/view/asterisk?view=rev&rev=111950
Log:
Fix most apps and codecs

Modified:
    team/group/codec_bits/apps/app_nbscat.c
    team/group/codec_bits/apps/app_parkandannounce.c
    team/group/codec_bits/apps/app_record.c
    team/group/codec_bits/apps/app_sms.c
    team/group/codec_bits/apps/app_speech_utils.c
    team/group/codec_bits/apps/app_talkdetect.c
    team/group/codec_bits/apps/app_test.c
    team/group/codec_bits/apps/app_waitforsilence.c
    team/group/codec_bits/apps/app_zapbarge.c
    team/group/codec_bits/apps/app_zapscan.c
    team/group/codec_bits/codecs/codec_a_mu.c
    team/group/codec_bits/codecs/codec_adpcm.c
    team/group/codec_bits/codecs/codec_alaw.c
    team/group/codec_bits/codecs/codec_g722.c
    team/group/codec_bits/codecs/codec_g726.c
    team/group/codec_bits/codecs/codec_gsm.c
    team/group/codec_bits/include/asterisk/speech.h
    team/group/codec_bits/include/asterisk/translate.h

Modified: team/group/codec_bits/apps/app_nbscat.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_nbscat.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_nbscat.c (original)
+++ team/group/codec_bits/apps/app_nbscat.c Sat Mar 29 03:29:35 2008
@@ -113,7 +113,7 @@
 	int fds[2];
 	int ms = -1;
 	int pid = -1;
-	int owriteformat;
+	struct ast_extended_codec owriteformat;
 	struct timeval next;
 	struct ast_frame *f;
 	struct myframe {
@@ -150,7 +150,8 @@
 				res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata));
 				if (res > 0) {
 					myf.f.frametype = AST_FRAME_VOICE;
-					myf.f.subclass = AST_FORMAT_SLINEAR;
+					myf.f.subclass = 0;
+					myf.f.codec = AST_FMT_SLINEAR;
 					myf.f.datalen = res;
 					myf.f.samples = res / 2;
 					myf.f.mallocd = 0;
@@ -199,7 +200,7 @@
 	
 	if (pid > -1)
 		kill(pid, SIGKILL);
-	if (!res && owriteformat)
+	if (!res && FMT_NZ(owriteformat))
 		ast_set_write_format(chan, owriteformat);
 
 	return res;

Modified: team/group/codec_bits/apps/app_parkandannounce.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_parkandannounce.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_parkandannounce.c (original)
+++ team/group/codec_bits/apps/app_parkandannounce.c Sat Mar 29 03:29:35 2008
@@ -122,7 +122,7 @@
 	snprintf(buf, sizeof(buf), "%d", lot);
 	oh.parent_channel = chan;
 	oh.vars = ast_variable_new("_PARKEDAT", buf, "");
-	dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, args.dial, 30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh);
+	dchan = __ast_request_and_dial(dialtech, AST_FMT_SLINEAR, args.dial, 30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh);
 
 	if (dchan) {
 		if (dchan->_state == AST_STATE_UP) {

Modified: team/group/codec_bits/apps/app_record.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_record.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_record.c (original)
+++ team/group/codec_bits/apps/app_record.c Sat Mar 29 03:29:35 2008
@@ -104,7 +104,7 @@
 	int maxduration = 0;		/* max duration of recording in milliseconds */
 	int gottimeout = 0;		/* did we timeout for maxduration exceeded? */
 	int terminator = '#';
-	int rfmt = 0;
+	struct ast_extended_codec rfmt = AST_FMT_NULL_MASK;
 	int ioflags;
 	int waitres;
 	struct ast_silence_generator *silgen = NULL;
@@ -233,7 +233,7 @@
 
 	if (silence > 0) {
 		rfmt = chan->readformat;
-		res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+		res = ast_set_read_format(chan, AST_FMT_SLINEAR);
 		if (res < 0) {
 			ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
 			return -1;
@@ -341,7 +341,7 @@
 		ast_channel_stop_silence_generator(chan, silgen);
 
 out:
-	if ((silence > 0) && rfmt) {
+	if ((silence > 0) && FMT_NZ(rfmt)) {
 		res = ast_set_read_format(chan, rfmt);
 		if (res)
 			ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);

Modified: team/group/codec_bits/apps/app_sms.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_sms.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_sms.c (original)
+++ team/group/codec_bits/apps/app_sms.c Sat Mar 29 03:29:35 2008
@@ -114,11 +114,11 @@
 static unsigned char wavea[80];
 typedef unsigned char output_t;
 static const output_t *wave_out = wavea;	/* outgoing samples */
-#define __OUT_FMT AST_FORMAT_ALAW;
+#define __OUT_FMT AST_FMT_ALAW;
 #else
 typedef signed short output_t;
 static const output_t *wave_out = wave;		/* outgoing samples */
-#define __OUT_FMT AST_FORMAT_SLINEAR
+#define __OUT_FMT AST_FMT_SLINEAR
 #endif
 
 #define OSYNC_BITS	80	/* initial sync bits */
@@ -1495,7 +1495,8 @@
 	buf = alloca(len);
 
 	f.frametype = AST_FRAME_VOICE;
-	f.subclass = __OUT_FMT;
+	f.subclass = 0;
+	f.codec = __OUT_FMT;
 	f.datalen = samples * sizeof(*buf);
 	f.offset = AST_FRIENDLY_OFFSET;
 	f.mallocd = 0;
@@ -1874,7 +1875,7 @@
 
 	res = ast_set_write_format(chan, __OUT_FMT);
 	if (res >= 0)
-		res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+		res = ast_set_read_format(chan, AST_FMT_SLINEAR);
 	if (res < 0) {
 		ast_log(LOG_ERROR, "Unable to set to linear mode, giving up\n");
 		goto done;

Modified: team/group/codec_bits/apps/app_speech_utils.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_speech_utils.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_speech_utils.c (original)
+++ team/group/codec_bits/apps/app_speech_utils.c Sat Mar 29 03:29:35 2008
@@ -504,7 +504,7 @@
 	int res = 0, done = 0, started = 0, quieted = 0, max_dtmf_len = 0;
 	struct ast_speech *speech = find_speech(chan);
 	struct ast_frame *f = NULL;
-	int oldreadformat = AST_FORMAT_SLINEAR;
+	struct ast_extended_codec oldreadformat = AST_FMT_SLINEAR;
 	char dtmf[AST_MAX_EXTENSION] = "";
 	time_t start, current;
 	struct ast_datastore *datastore = NULL;

Modified: team/group/codec_bits/apps/app_talkdetect.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_talkdetect.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_talkdetect.c (original)
+++ team/group/codec_bits/apps/app_talkdetect.c Sat Mar 29 03:29:35 2008
@@ -66,7 +66,7 @@
 	int min = 100;
 	int max = -1;
 	int x;
-	int origrformat=0;
+	struct ast_extended_codec origrformat = AST_FMT_NULL_MASK;
 	struct ast_dsp *dsp = NULL;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(filename);
@@ -98,7 +98,7 @@
 		}
 
 		origrformat = chan->readformat;
-		if ((ast_set_read_format(chan, AST_FORMAT_SLINEAR))) {
+		if ((ast_set_read_format(chan, AST_FMT_SLINEAR))) {
 			ast_log(LOG_WARNING, "Unable to set read format to linear!\n");
 			res = -1;
 			break;
@@ -142,7 +142,7 @@
 						ast_frfree(fr);
 						break;
 					}
-				} else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass == AST_FORMAT_SLINEAR)) {
+				} else if ((fr->frametype == AST_FRAME_VOICE) && FMT_EQ(fr->codec, AST_FMT_SLINEAR)) {
 					int totalsilence;
 					int ms;
 					res = ast_dsp_silence(dsp, fr, &totalsilence);
@@ -188,7 +188,7 @@
 	} while (0);
 
 	if (res > -1) {
-		if (origrformat && ast_set_read_format(chan, origrformat)) {
+		if (FMT_NZ(origrformat) && ast_set_read_format(chan, origrformat)) {
 			ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n", 
 				chan->name, ast_getformatname(origrformat));
 		}

Modified: team/group/codec_bits/apps/app_test.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_test.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_test.c (original)
+++ team/group/codec_bits/apps/app_test.c Sat Mar 29 03:29:35 2008
@@ -64,9 +64,9 @@
 	short *foo;
 	struct timeval start;
 	struct ast_frame *f;
-	int rformat;
-	rformat = chan->readformat;
-	if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
+	struct ast_extended_codec rformat = chan->readformat;
+
+	if (ast_set_read_format(chan, AST_FMT_SLINEAR)) {
 		ast_log(LOG_NOTICE, "Unable to set to linear mode!\n");
 		return -1;
 	}
@@ -83,7 +83,7 @@
 			res = -1;
 			break;
 		}
-		if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
+		if ((f->frametype == AST_FRAME_VOICE) && FMT_EQ(f->codec, AST_FMT_SLINEAR)) {
 			foo = (short *)f->data;
 			for (x=0;x<f->samples;x++) {
 				noise += abs(foo[x]);
@@ -93,7 +93,7 @@
 		ast_frfree(f);
 	}
 
-	if (rformat) {
+	if (FMT_NZ(rformat)) {
 		if (ast_set_read_format(chan, rformat)) {
 			ast_log(LOG_NOTICE, "Unable to restore original format!\n");
 			return -1;

Modified: team/group/codec_bits/apps/app_waitforsilence.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_waitforsilence.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_waitforsilence.c (original)
+++ team/group/codec_bits/apps/app_waitforsilence.c Sat Mar 29 03:29:35 2008
@@ -83,7 +83,7 @@
 static int do_waiting(struct ast_channel *chan, int timereqd, time_t waitstart, int timeout, int wait_for_silence) {
 	struct ast_frame *f;
 	int dsptime = 0;
-	int rfmt = 0;
+	struct ast_extended_codec rfmt = AST_FMT_NULL_MASK;
 	int res = 0;
 	struct ast_dsp *sildet;	 /* silence detector dsp */
  	time_t now;
@@ -93,7 +93,7 @@
 				wait_for_silence ? ast_dsp_silence : ast_dsp_noise;
 
 	rfmt = chan->readformat; /* Set to linear mode */
-	res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+	res = ast_set_read_format(chan, AST_FMT_SLINEAR);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set channel to linear mode, giving up\n");
 		return -1;
@@ -160,7 +160,7 @@
 	}
 
 
-	if (rfmt && ast_set_read_format(chan, rfmt)) {
+	if (FMT_NZ(rfmt) && ast_set_read_format(chan, rfmt)) {
 		ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
 	}
 	ast_dsp_free(sildet);

Modified: team/group/codec_bits/apps/app_zapbarge.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_zapbarge.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_zapbarge.c (original)
+++ team/group/codec_bits/apps/app_zapbarge.c Sat Mar 29 03:29:35 2008
@@ -104,13 +104,13 @@
 	char *buf = __buf + AST_FRIENDLY_OFFSET;
 
 	/* Set it into U-law mode (write) */
-	if (ast_set_write_format(chan, AST_FORMAT_ULAW) < 0) {
+	if (ast_set_write_format(chan, AST_FMT_ULAW) < 0) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to write ulaw mode\n", chan->name);
 		goto outrun;
 	}
 
 	/* Set it into U-law mode (read) */
-	if (ast_set_read_format(chan, AST_FORMAT_ULAW) < 0) {
+	if (ast_set_read_format(chan, AST_FMT_ULAW) < 0) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to read ulaw mode\n", chan->name);
 		goto outrun;
 	}
@@ -205,7 +205,7 @@
 				break;
 			} else if (fd != chan->fds[0]) {
 				if (f->frametype == AST_FRAME_VOICE) {
-					if (f->subclass == AST_FORMAT_ULAW) {
+					if (FMT_EQ(f->codec, AST_FMT_ULAW)) {
 						/* Carefully write */
 						careful_write(fd, f->data, f->datalen);
 					} else
@@ -218,7 +218,8 @@
 			if (res > 0) {
 				memset(&fr, 0, sizeof(fr));
 				fr.frametype = AST_FRAME_VOICE;
-				fr.subclass = AST_FORMAT_ULAW;
+				fr.subclass = 0;
+				fr.codec = AST_FMT_ULAW;
 				fr.datalen = res;
 				fr.samples = res;
 				fr.data = buf;

Modified: team/group/codec_bits/apps/app_zapscan.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/apps/app_zapscan.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/apps/app_zapscan.c (original)
+++ team/group/codec_bits/apps/app_zapscan.c Sat Mar 29 03:29:35 2008
@@ -111,13 +111,13 @@
 	char *buf = __buf + AST_FRIENDLY_OFFSET;
 	
 	/* Set it into U-law mode (write) */
-	if (ast_set_write_format(chan, AST_FORMAT_ULAW) < 0) {
+	if (ast_set_write_format(chan, AST_FMT_ULAW) < 0) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to write ulaw mode\n", chan->name);
 		goto outrun;
 	}
 	
 	/* Set it into U-law mode (read) */
-	if (ast_set_read_format(chan, AST_FORMAT_ULAW) < 0) {
+	if (ast_set_read_format(chan, AST_FMT_ULAW) < 0) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to read ulaw mode\n", chan->name);
 		goto outrun;
 	}
@@ -230,9 +230,9 @@
 				
 				if (fd != chan->fds[0]) {
 					if (f->frametype == AST_FRAME_VOICE) {
-						if (f->subclass == AST_FORMAT_ULAW) {
+						if (FMT_EQ(f->codec, AST_FMT_ULAW)) {
 							/* Carefully write */
-                                                careful_write(fd, f->data, f->datalen);
+							careful_write(fd, f->data, f->datalen);
 						} else
 							ast_log(LOG_WARNING, "Huh?  Got a non-ulaw (%d) frame in the conference\n", f->subclass);
 					}
@@ -243,7 +243,8 @@
 				if (res > 0) {
 					memset(&fr, 0, sizeof(fr));
 					fr.frametype = AST_FRAME_VOICE;
-					fr.subclass = AST_FORMAT_ULAW;
+					fr.subclass = 0;
+					fr.codec = AST_FMT_ULAW;
 					fr.datalen = res;
 					fr.samples = res;
 					fr.data = buf;

Modified: team/group/codec_bits/codecs/codec_a_mu.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/codecs/codec_a_mu.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/codecs/codec_a_mu.c (original)
+++ team/group/codec_bits/codecs/codec_a_mu.c Sat Mar 29 03:29:35 2008
@@ -81,7 +81,8 @@
 {
 	static struct ast_frame f;
 	f.frametype = AST_FRAME_VOICE;
-	f.subclass = AST_FORMAT_ALAW;
+	f.subclass = 0;
+	f.codec = AST_FMT_ALAW;
 	f.datalen = sizeof(ulaw_slin_ex);
 	f.samples = sizeof(ulaw_slin_ex);
 	f.mallocd = 0;
@@ -95,7 +96,8 @@
 {
 	static struct ast_frame f;
 	f.frametype = AST_FRAME_VOICE;
-	f.subclass = AST_FORMAT_ULAW;
+	f.subclass = 0;
+	f.codec = AST_FMT_ULAW;
 	f.datalen = sizeof(ulaw_slin_ex);
 	f.samples = sizeof(ulaw_slin_ex);
 	f.mallocd = 0;
@@ -107,8 +109,8 @@
 
 static struct ast_translator alawtoulaw = {
 	.name = "alawtoulaw",
-	.srcfmt = AST_FORMAT_ALAW,
-	.dstfmt = AST_FORMAT_ULAW,
+	.srcfmt = { { AST_FORMAT_AUDIO_ALAW } },
+	.dstfmt = { { AST_FORMAT_AUDIO_ULAW } },
 	.framein = alawtoulaw_framein,
 	.sample = alawtoulaw_sample,
 	.buffer_samples = BUFFER_SAMPLES,
@@ -117,8 +119,8 @@
 
 static struct ast_translator ulawtoalaw = {
 	.name = "ulawtoalaw",
-	.srcfmt = AST_FORMAT_ULAW,
-	.dstfmt = AST_FORMAT_ALAW,
+	.srcfmt = { { AST_FORMAT_AUDIO_ULAW } },
+	.dstfmt = { { AST_FORMAT_AUDIO_ALAW } },
 	.framein = ulawtoalaw_framein,
 	.sample = ulawtoalaw_sample,
 	.buffer_samples = BUFFER_SAMPLES,

Modified: team/group/codec_bits/codecs/codec_adpcm.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/codecs/codec_adpcm.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/codecs/codec_adpcm.c (original)
+++ team/group/codec_bits/codecs/codec_adpcm.c Sat Mar 29 03:29:35 2008
@@ -290,7 +290,9 @@
 {
 	static struct ast_frame f;
 	f.frametype = AST_FRAME_VOICE;
-	f.subclass = AST_FORMAT_ADPCM;
+	f.subclass = 0;
+	f.codec = AST_FMT_NULL_MASK;
+	f.codec.audio[0] |= AST_FORMAT_AUDIO_ADPCM;
 	f.datalen = sizeof(adpcm_slin_ex);
 	f.samples = sizeof(adpcm_slin_ex) * 2;
 	f.mallocd = 0;
@@ -305,7 +307,8 @@
 {
 	static struct ast_frame f;
 	f.frametype = AST_FRAME_VOICE;
-	f.subclass = AST_FORMAT_SLINEAR;
+	f.subclass = 0;
+	f.codec = AST_FMT_SLINEAR;
 	f.datalen = sizeof(slin_adpcm_ex);
 	/* Assume 8000 Hz */
 	f.samples = sizeof(slin_adpcm_ex) / 2;
@@ -318,8 +321,8 @@
 
 static struct ast_translator adpcmtolin = {
 	.name = "adpcmtolin",
-	.srcfmt = AST_FORMAT_ADPCM,
-	.dstfmt = AST_FORMAT_SLINEAR,
+	.srcfmt = { { AST_FORMAT_AUDIO_ADPCM } },
+	.dstfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
 	.framein = adpcmtolin_framein,
 	.sample = adpcmtolin_sample,
 	.desc_size = sizeof(struct adpcm_decoder_pvt),
@@ -330,8 +333,8 @@
 
 static struct ast_translator lintoadpcm = {
 	.name = "lintoadpcm",
-	.srcfmt = AST_FORMAT_SLINEAR,
-	.dstfmt = AST_FORMAT_ADPCM,
+	.srcfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
+	.dstfmt = { { AST_FORMAT_AUDIO_ADPCM } },
 	.framein = lintoadpcm_framein,
 	.frameout = lintoadpcm_frameout,
 	.sample = lintoadpcm_sample,

Modified: team/group/codec_bits/codecs/codec_alaw.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/codecs/codec_alaw.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/codecs/codec_alaw.c (original)
+++ team/group/codec_bits/codecs/codec_alaw.c Sat Mar 29 03:29:35 2008
@@ -77,7 +77,8 @@
 {
 	static struct ast_frame f;
 	f.frametype = AST_FRAME_VOICE;
-	f.subclass = AST_FORMAT_ALAW;
+	f.subclass = 0;
+	f.codec = AST_FMT_ALAW;
 	f.datalen = sizeof(ulaw_slin_ex);
 	f.samples = sizeof(ulaw_slin_ex);
 	f.mallocd = 0;
@@ -92,7 +93,8 @@
 {
 	static struct ast_frame f;
 	f.frametype = AST_FRAME_VOICE;
-	f.subclass = AST_FORMAT_SLINEAR;
+	f.subclass = 0;
+	f.codec = AST_FMT_SLINEAR;
 	f.datalen = sizeof(slin_ulaw_ex);
 	f.samples = sizeof(slin_ulaw_ex) / 2;
 	f.mallocd = 0;
@@ -104,8 +106,8 @@
 
 static struct ast_translator alawtolin = {
 	.name = "alawtolin",
-	.srcfmt = AST_FORMAT_ALAW,
-	.dstfmt = AST_FORMAT_SLINEAR,
+	.srcfmt = { { AST_FORMAT_AUDIO_ALAW } },
+	.dstfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
 	.framein = alawtolin_framein,
 	.sample = alawtolin_sample,
 	.buffer_samples = BUFFER_SAMPLES,
@@ -115,8 +117,8 @@
 
 static struct ast_translator lintoalaw = {
 	"lintoalaw",
-	.srcfmt = AST_FORMAT_SLINEAR,
-	.dstfmt = AST_FORMAT_ALAW,
+	.srcfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
+	.dstfmt = { { AST_FORMAT_AUDIO_ALAW } },
 	.framein = lintoalaw_framein,
 	.sample = lintoalaw_sample,
 	.buffer_samples = BUFFER_SAMPLES,

Modified: team/group/codec_bits/codecs/codec_g722.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/codecs/codec_g722.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/codecs/codec_g722.c (original)
+++ team/group/codec_bits/codecs/codec_g722.c Sat Mar 29 03:29:35 2008
@@ -136,7 +136,8 @@
 {
 	static struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_G722,
+		.subclass = 0,
+		.codec = { { AST_FORMAT_AUDIO_G722 } },
 		.datalen = sizeof(g722_slin_ex),
 		.samples = sizeof(g722_slin_ex) * 2,
 		.src = __PRETTY_FUNCTION__,
@@ -150,7 +151,8 @@
 {
 	static struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_G722,
+		.subclass = 0,
+		.codec = { { AST_FORMAT_AUDIO_G722 } },
 		.datalen = sizeof(g722_slin_ex),
 		.samples = sizeof(g722_slin_ex) * 2,
 		.src = __PRETTY_FUNCTION__,
@@ -164,7 +166,8 @@
 {
 	static struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
+		.subclass = 0,
+		.codec = { { AST_FORMAT_AUDIO_SLINEAR } },
 		.datalen = sizeof(slin_g722_ex),
 		.samples = sizeof(slin_g722_ex) / sizeof(slin_g722_ex[0]),
 		.src = __PRETTY_FUNCTION__,
@@ -178,7 +181,8 @@
 {
 	static struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR16,
+		.subclass = 0,
+		.codec = { { AST_FORMAT_AUDIO_SLINEAR16 } },
 		.datalen = sizeof(slin_g722_ex),
 		.samples = sizeof(slin_g722_ex) / sizeof(slin_g722_ex[0]),
 		.src = __PRETTY_FUNCTION__,
@@ -190,8 +194,8 @@
 
 static struct ast_translator g722tolin = {
 	.name = "g722tolin",
-	.srcfmt = AST_FORMAT_G722,
-	.dstfmt = AST_FORMAT_SLINEAR,
+	.srcfmt = { { AST_FORMAT_AUDIO_G722 } },
+	.dstfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
 	.newpvt = g722tolin_new,	/* same for both directions */
 	.framein = g722tolin_framein,
 	.sample = g722tolin_sample,
@@ -203,8 +207,8 @@
 
 static struct ast_translator lintog722 = {
 	.name = "lintog722",
-	.srcfmt = AST_FORMAT_SLINEAR,
-	.dstfmt = AST_FORMAT_G722,
+	.srcfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
+	.dstfmt = { { AST_FORMAT_AUDIO_G722 } },
 	.newpvt = lintog722_new,	/* same for both directions */
 	.framein = lintog722_framein,
 	.sample = lintog722_sample,
@@ -215,8 +219,8 @@
 
 static struct ast_translator g722tolin16 = {
 	.name = "g722tolin16",
-	.srcfmt = AST_FORMAT_G722,
-	.dstfmt = AST_FORMAT_SLINEAR16,
+	.srcfmt = { { AST_FORMAT_AUDIO_G722 } },
+	.dstfmt = { { AST_FORMAT_AUDIO_SLINEAR16 } },
 	.newpvt = g722tolin16_new,	/* same for both directions */
 	.framein = g722tolin_framein,
 	.sample = g722tolin16_sample,
@@ -228,8 +232,8 @@
 
 static struct ast_translator lin16tog722 = {
 	.name = "lin16tog722",
-	.srcfmt = AST_FORMAT_SLINEAR16,
-	.dstfmt = AST_FORMAT_G722,
+	.srcfmt = { { AST_FORMAT_AUDIO_SLINEAR16 } },
+	.dstfmt = { { AST_FORMAT_AUDIO_G722 } },
 	.newpvt = lin16tog722_new,	/* same for both directions */
 	.framein = lintog722_framein,
 	.sample = lin16tog722_sample,

Modified: team/group/codec_bits/codecs/codec_g726.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/codecs/codec_g726.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/codecs/codec_g726.c (original)
+++ team/group/codec_bits/codecs/codec_g726.c Sat Mar 29 03:29:35 2008
@@ -790,7 +790,8 @@
 {
 	static struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_G726,
+		.subclass = 0,
+		.codec = { { AST_FORMAT_AUDIO_G726 } },
 		.datalen = sizeof(g726_slin_ex),
 		.samples = sizeof(g726_slin_ex) * 2,	/* 2 samples per byte */
 		.src = __PRETTY_FUNCTION__,
@@ -804,7 +805,8 @@
 {
 	static struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
+		.subclass = 0,
+		.codec = { { AST_FORMAT_AUDIO_SLINEAR } },
 		.datalen = sizeof(slin_g726_ex),
 		.samples = sizeof(slin_g726_ex) / 2,	/* 1 sample per 2 bytes */
 		.src = __PRETTY_FUNCTION__,
@@ -816,8 +818,8 @@
 
 static struct ast_translator g726tolin = {
 	.name = "g726tolin",
-	.srcfmt = AST_FORMAT_G726,
-	.dstfmt = AST_FORMAT_SLINEAR,
+	.srcfmt = { { AST_FORMAT_AUDIO_G726 } },
+	.dstfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
 	.newpvt = lintog726_new,	/* same for both directions */
 	.framein = g726tolin_framein,
 	.sample = g726tolin_sample,
@@ -829,8 +831,8 @@
 
 static struct ast_translator lintog726 = {
 	.name = "lintog726",
-	.srcfmt = AST_FORMAT_SLINEAR,
-	.dstfmt = AST_FORMAT_G726,
+	.srcfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
+	.dstfmt = { { AST_FORMAT_AUDIO_G726 } },
 	.newpvt = lintog726_new,	/* same for both directions */
 	.framein = lintog726_framein,
 	.sample = lintog726_sample,
@@ -841,8 +843,8 @@
 
 static struct ast_translator g726aal2tolin = {
 	.name = "g726aal2tolin",
-	.srcfmt = AST_FORMAT_G726_AAL2,
-	.dstfmt = AST_FORMAT_SLINEAR,
+	.srcfmt = { { AST_FORMAT_AUDIO_G726_AAL2 } },
+	.dstfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
 	.newpvt = lintog726_new,	/* same for both directions */
 	.framein = g726aal2tolin_framein,
 	.sample = g726tolin_sample,
@@ -854,8 +856,8 @@
 
 static struct ast_translator lintog726aal2 = {
 	.name = "lintog726aal2",
-	.srcfmt = AST_FORMAT_SLINEAR,
-	.dstfmt = AST_FORMAT_G726_AAL2,
+	.srcfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
+	.dstfmt = { { AST_FORMAT_AUDIO_G726_AAL2 } },
 	.newpvt = lintog726_new,	/* same for both directions */
 	.framein = lintog726aal2_framein,
 	.sample = lintog726_sample,
@@ -866,8 +868,8 @@
 
 static struct ast_translator g726tog726aal2 = {
 	.name = "g726tog726aal2",
-	.srcfmt = AST_FORMAT_G726,
-	.dstfmt = AST_FORMAT_G726_AAL2,
+	.srcfmt = { { AST_FORMAT_AUDIO_G726 } },
+	.dstfmt = { { AST_FORMAT_AUDIO_G726_AAL2 } },
 	.framein = g726tog726aal2_framein,	/* same for both directions */
 	.sample = lintog726_sample,
 	.buffer_samples = BUFFER_SAMPLES,
@@ -876,8 +878,8 @@
 
 static struct ast_translator g726aal2tog726 = {
 	.name = "g726aal2tog726",
-	.srcfmt = AST_FORMAT_G726_AAL2,
-	.dstfmt = AST_FORMAT_G726,
+	.srcfmt = { { AST_FORMAT_AUDIO_G726_AAL2 } },
+	.dstfmt = { { AST_FORMAT_AUDIO_G726 } },
 	.framein = g726tog726aal2_framein,	/* same for both directions */
 	.sample = lintog726_sample,
 	.buffer_samples = BUFFER_SAMPLES,

Modified: team/group/codec_bits/codecs/codec_gsm.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/codecs/codec_gsm.c?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/codecs/codec_gsm.c (original)
+++ team/group/codec_bits/codecs/codec_gsm.c Sat Mar 29 03:29:35 2008
@@ -72,7 +72,8 @@
 {
 	static struct ast_frame f;
 	f.frametype = AST_FRAME_VOICE;
-	f.subclass = AST_FORMAT_SLINEAR;
+	f.subclass = 0;
+	f.codec = AST_FMT_SLINEAR;
 	f.datalen = sizeof(slin_gsm_ex);
 	/* Assume 8000 Hz */
 	f.samples = sizeof(slin_gsm_ex)/2;
@@ -85,9 +86,9 @@
 
 static struct ast_frame *gsmtolin_sample(void)
 {
-	static struct ast_frame f;
+	static struct ast_frame f = { .codec = { { AST_FORMAT_AUDIO_GSM } } };
 	f.frametype = AST_FRAME_VOICE;
-	f.subclass = AST_FORMAT_GSM;
+	f.subclass = 0;
 	f.datalen = sizeof(gsm_slin_ex);
 	/* All frames are 20 ms long */
 	f.samples = GSM_SAMPLES;
@@ -198,8 +199,8 @@
 
 static struct ast_translator gsmtolin = {
 	.name = "gsmtolin", 
-	.srcfmt = AST_FORMAT_GSM,
-	.dstfmt = AST_FORMAT_SLINEAR,
+	.srcfmt = { { AST_FORMAT_AUDIO_GSM } },
+	.dstfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
 	.newpvt = gsm_new,
 	.framein = gsmtolin_framein,
 	.destroy = gsm_destroy_stuff,
@@ -212,8 +213,8 @@
 
 static struct ast_translator lintogsm = {
 	.name = "lintogsm", 
-	.srcfmt = AST_FORMAT_SLINEAR,
-	.dstfmt = AST_FORMAT_GSM,
+	.srcfmt = { { AST_FORMAT_AUDIO_SLINEAR } },
+	.dstfmt = { { AST_FORMAT_AUDIO_GSM } },
 	.newpvt = gsm_new,
 	.framein = lintogsm_framein,
 	.frameout = lintogsm_frameout,

Modified: team/group/codec_bits/include/asterisk/speech.h
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/include/asterisk/speech.h?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/include/asterisk/speech.h (original)
+++ team/group/codec_bits/include/asterisk/speech.h Sat Mar 29 03:29:35 2008
@@ -58,7 +58,7 @@
 	/*! Current state of structure */
 	int state;
 	/*! Expected write format */
-	int format;
+	struct ast_extended_codec format;
 	/*! Data for speech engine */
 	void *data;
 	/*! Cached results */
@@ -74,7 +74,7 @@
 	/*! Name of speech engine */
 	char *name;
 	/*! Set up the speech structure within the engine */
-	int (*create)(struct ast_speech *speech, int format);
+	int (*create)(struct ast_speech *speech, struct ast_extended_codec format);
 	/*! Destroy any data set on the speech structure by the engine */
 	int (*destroy)(struct ast_speech *speech);
 	/*! Load a local grammar on the speech structure */
@@ -98,7 +98,7 @@
 	/*! Try to get results */
 	struct ast_speech_result *(*get)(struct ast_speech *speech);
 	/*! Accepted formats by the engine */
-	int formats;
+	struct ast_extended_codec formats;
 	AST_LIST_ENTRY(ast_speech_engine) list;
 };
 
@@ -131,7 +131,7 @@
 /*! \brief Indicate to the speech engine that audio is now going to start being written */
 void ast_speech_start(struct ast_speech *speech);
 /*! \brief Create a new speech structure */
-struct ast_speech *ast_speech_new(char *engine_name, int formats);
+struct ast_speech *ast_speech_new(char *engine_name, struct ast_extended_codec formats);
 /*! \brief Destroy a speech structure */
 int ast_speech_destroy(struct ast_speech *speech);
 /*! \brief Write audio to the speech engine */

Modified: team/group/codec_bits/include/asterisk/translate.h
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/include/asterisk/translate.h?view=diff&rev=111950&r1=111949&r2=111950
==============================================================================
--- team/group/codec_bits/include/asterisk/translate.h (original)
+++ team/group/codec_bits/include/asterisk/translate.h Sat Mar 29 03:29:35 2008
@@ -70,9 +70,9 @@
  */
 struct ast_translator {
 	const char name[80];		/*!< Name of translator */
-	int srcfmt;			/*!< Source format (note: bit position,
+	struct ast_extended_codec srcfmt;	/*!< Source format (note: bit position,
 					  converted to index during registration) */
-	int dstfmt;			/*!< Destination format (note: bit position,
+	struct ast_extended_codec dstfmt;	/*!< Destination format (note: bit position,
 					  converted to index during registration) */
 
 	int (*newpvt)(struct ast_trans_pvt *); /*!< initialize private data 
@@ -210,7 +210,7 @@
  * \param source source format
  * \return ast_trans_pvt on success, NULL on failure
  * */
-struct ast_trans_pvt *ast_translator_build_path(int dest, int source);
+struct ast_trans_pvt *ast_translator_build_path(struct ast_extended_codec dest, struct ast_extended_codec source);
 
 /*!
  * \brief Frees a translator path
@@ -236,7 +236,7 @@
  * \param src source format
  * \return the number of translation steps required, or -1 if no path is available
  */
-unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src);
+unsigned int ast_translate_path_steps(struct ast_extended_codec dest, struct ast_extended_codec src);
 
 /*!
  * \brief Mask off unavailable formats from a format bitmask




More information about the asterisk-commits mailing list