[asterisk-commits] tilghman: branch group/codec_bits r112560 - in /team/group/codec_bits: format...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 2 19:23:21 CDT 2008


Author: tilghman
Date: Wed Apr  2 19:23:21 2008
New Revision: 112560

URL: http://svn.digium.com/view/asterisk?view=rev&rev=112560
Log:
Bunches more done

Modified:
    team/group/codec_bits/formats/format_pcm.c
    team/group/codec_bits/formats/format_sln.c
    team/group/codec_bits/formats/format_sln16.c
    team/group/codec_bits/formats/format_vox.c
    team/group/codec_bits/formats/format_wav.c
    team/group/codec_bits/formats/format_wav_gsm.c
    team/group/codec_bits/funcs/func_channel.c
    team/group/codec_bits/include/asterisk/abstract_jb.h
    team/group/codec_bits/include/asterisk/mod_format.h
    team/group/codec_bits/main/abstract_jb.c
    team/group/codec_bits/main/app.c
    team/group/codec_bits/main/audiohook.c
    team/group/codec_bits/main/channel.c
    team/group/codec_bits/main/dial.c
    team/group/codec_bits/main/dsp.c
    team/group/codec_bits/main/features.c
    team/group/codec_bits/main/file.c
    team/group/codec_bits/main/frame.c
    team/group/codec_bits/res/res_adsi.c
    team/group/codec_bits/res/res_agi.c
    team/group/codec_bits/res/res_clioriginate.c
    team/group/codec_bits/res/res_musiconhold.c
    team/group/codec_bits/res/res_speech.c

Modified: team/group/codec_bits/formats/format_pcm.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/formats/format_pcm.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/formats/format_pcm.c (original)
+++ team/group/codec_bits/formats/format_pcm.c Wed Apr  2 19:23:21 2008
@@ -80,7 +80,8 @@
 	/* Send a frame from the file to the appropriate channel */
 
 	s->fr.frametype = AST_FRAME_VOICE;
-	s->fr.subclass = s->fmt->format;
+	s->fr.subclass = 0;
+	s->fr.codec = s->fmt->format;
 	s->fr.mallocd = 0;
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
@@ -89,7 +90,7 @@
 		return NULL;
 	}
 	s->fr.datalen = res;
-	if (s->fmt->format == AST_FORMAT_G722)
+	if (s->fmt->format.audio[0] == AST_FORMAT_AUDIO_G722)
 		*whennext = s->fr.samples = res * 2;
 	else
 		*whennext = s->fr.samples = res;
@@ -126,7 +127,7 @@
 	}
 	if (whence == SEEK_FORCECUR && offset > max) { /* extend the file */
 		size_t left = offset - max;
-		const char *src = (fs->fmt->format == AST_FORMAT_ALAW) ? alaw_silence : ulaw_silence;
+		const char *src = (fs->fmt->format.audio[0] == AST_FORMAT_AUDIO_ALAW) ? alaw_silence : ulaw_silence;
 
 		while (left) {
 			size_t written = fwrite(src, 1, (left > BUF_SIZE) ? BUF_SIZE : left, fs->f);
@@ -163,8 +164,8 @@
 		ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
 		return -1;
 	}
-	if (f->subclass != fs->fmt->format) {
-		ast_log(LOG_WARNING, "Asked to write incompatible format frame (%d)!\n", f->subclass);
+	if (!FMT_EQ(f->codec, fs->fmt->format)) {
+		ast_log(LOG_WARNING, "Asked to write incompatible format frame (%s)!\n", ast_getformatname(f->codec));
 		return -1;
 	}
 
@@ -371,8 +372,9 @@
 {
 	off_t min, max, cur;
 	long offset = 0, bytes;
-
-	if (fs->fmt->format == AST_FORMAT_G722)
+	const struct ast_extended_codec g722 = { .audio = { AST_FORMAT_AUDIO_G722 } };
+
+	if (FMT_EQ(fs->fmt->format, g722))
 		bytes = sample_offset / 2;
 	else
 		bytes = sample_offset;
@@ -415,7 +417,7 @@
 static const struct ast_format alaw_f = {
 	.name = "alaw",
 	.exts = "alaw|al",
-	.format = AST_FORMAT_ALAW,
+	.format = { .audio = { AST_FORMAT_AUDIO_ALAW } },
 	.write = pcm_write,
 	.seek = pcm_seek,
 	.trunc = pcm_trunc,
@@ -432,7 +434,7 @@
 static const struct ast_format pcm_f = {
 	.name = "pcm",
 	.exts = "pcm|ulaw|ul|mu",
-	.format = AST_FORMAT_ULAW,
+	.format = { .audio = { AST_FORMAT_AUDIO_ULAW } },
 	.write = pcm_write,
 	.seek = pcm_seek,
 	.trunc = pcm_trunc,
@@ -444,7 +446,7 @@
 static const struct ast_format g722_f = {
 	.name = "g722",
 	.exts = "g722",
-	.format = AST_FORMAT_G722,
+	.format = { .audio = { AST_FORMAT_AUDIO_G722 } },
 	.write = pcm_write,
 	.seek = pcm_seek,
 	.trunc = pcm_trunc,
@@ -456,7 +458,7 @@
 static const struct ast_format au_f = {
 	.name = "au",
 	.exts = "au",
-	.format = AST_FORMAT_ULAW,
+	.format = { .audio = { AST_FORMAT_AUDIO_ULAW } },
 	.open = au_open,
 	.rewrite = au_rewrite,
 	.write = pcm_write,

Modified: team/group/codec_bits/formats/format_sln.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/formats/format_sln.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/formats/format_sln.c (original)
+++ team/group/codec_bits/formats/format_sln.c Wed Apr  2 19:23:21 2008
@@ -36,10 +36,12 @@
 static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext)
 {
 	int res;
+	const struct ast_extended_codec slin = { .audio = { AST_FORMAT_AUDIO_SLINEAR } };
 	/* Send a frame from the file to the appropriate channel */
 
 	s->fr.frametype = AST_FRAME_VOICE;
-	s->fr.subclass = AST_FORMAT_SLINEAR;
+	s->fr.subclass = 0;
+	s->fr.codec = slin;
 	s->fr.mallocd = 0;
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
@@ -59,13 +61,13 @@
 		ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
 		return -1;
 	}
-	if (f->subclass != AST_FORMAT_SLINEAR) {
+	if (f->codec.audio[0] != AST_FORMAT_AUDIO_SLINEAR) {
 		ast_log(LOG_WARNING, "Asked to write non-slinear frame (%d)!\n", f->subclass);
 		return -1;
 	}
 	if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) {
-			ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
-			return -1;
+		ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
+		return -1;
 	}
 	return 0;
 }
@@ -106,7 +108,7 @@
 static const struct ast_format slin_f = {
 	.name = "sln",
 	.exts = "sln|raw",
-	.format = AST_FORMAT_SLINEAR,
+	.format = { .audio = { AST_FORMAT_AUDIO_SLINEAR } },
 	.write = slinear_write,
 	.seek = slinear_seek,
 	.trunc = slinear_trunc,

Modified: team/group/codec_bits/formats/format_sln16.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/formats/format_sln16.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/formats/format_sln16.c (original)
+++ team/group/codec_bits/formats/format_sln16.c Wed Apr  2 19:23:21 2008
@@ -37,10 +37,12 @@
 static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext)
 {
 	int res;
+	const struct ast_extended_codec sln16 = { .audio = { AST_FORMAT_AUDIO_SLINEAR16 } };
 	/* Send a frame from the file to the appropriate channel */
 
 	s->fr.frametype = AST_FRAME_VOICE;
-	s->fr.subclass = AST_FORMAT_SLINEAR16;
+	s->fr.subclass = 0;
+	s->fr.codec = sln16;
 	s->fr.mallocd = 0;
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
@@ -61,8 +63,8 @@
 		ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
 		return -1;
 	}
-	if (f->subclass != AST_FORMAT_SLINEAR16) {
-		ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%d)!\n", f->subclass);
+	if (f->codec.audio[0] != AST_FORMAT_AUDIO_SLINEAR16) {
+		ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%s)!\n", ast_getformatname(f->codec));
 		return -1;
 	}
 	if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) {
@@ -113,7 +115,7 @@
 static const struct ast_format slin_f = {
 	.name = "sln16",
 	.exts = "sln16",
-	.format = AST_FORMAT_SLINEAR16,
+	.format = { .audio = { AST_FORMAT_AUDIO_SLINEAR16 } },
 	.write = slinear_write,
 	.seek = slinear_seek,
 	.trunc = slinear_trunc,

Modified: team/group/codec_bits/formats/format_vox.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/formats/format_vox.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/formats/format_vox.c (original)
+++ team/group/codec_bits/formats/format_vox.c Wed Apr  2 19:23:21 2008
@@ -38,10 +38,12 @@
 static struct ast_frame *vox_read(struct ast_filestream *s, int *whennext)
 {
 	int res;
+	const struct ast_extended_codec vox = { .audio = { AST_FORMAT_AUDIO_ADPCM } };
 
 	/* Send a frame from the file to the appropriate channel */
 	s->fr.frametype = AST_FRAME_VOICE;
-	s->fr.subclass = AST_FORMAT_ADPCM;
+	s->fr.subclass = 0;
+	s->fr.codec = vox;
 	s->fr.mallocd = 0;
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
 	if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
@@ -61,57 +63,56 @@
 		ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
 		return -1;
 	}
-	if (f->subclass != AST_FORMAT_ADPCM) {
+	if (f->codec.audio[0] != AST_FORMAT_AUDIO_ADPCM) {
 		ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%d)!\n", f->subclass);
 		return -1;
 	}
 	if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) {
-			ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
-			return -1;
+		ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
+		return -1;
 	}
 	return 0;
 }
 
 static int vox_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
 {
-     off_t offset=0,min,cur,max,distance;
-	
-     min = 0;
-     cur = ftello(fs->f);
-     fseeko(fs->f, 0, SEEK_END);
-	 max = ftello(fs->f);
-	 
-     /* have to fudge to frame here, so not fully to sample */
-     distance = sample_offset/2;
-     if(whence == SEEK_SET)
-	  offset = distance;
-     else if(whence == SEEK_CUR || whence == SEEK_FORCECUR)
-	  offset = distance + cur;
-     else if(whence == SEEK_END)
-	  offset = max - distance;
-     if (whence != SEEK_FORCECUR) {
-	  offset = (offset > max)?max:offset;
-	  offset = (offset < min)?min:offset;
-     }
-     return fseeko(fs->f, offset, SEEK_SET);
+	off_t offset=0,min,cur,max,distance;
+
+	min = 0;
+	cur = ftello(fs->f);
+	fseeko(fs->f, 0, SEEK_END);
+	max = ftello(fs->f);
+ 
+	/* have to fudge to frame here, so not fully to sample */
+	distance = sample_offset / 2;
+	if (whence == SEEK_SET) {
+		offset = distance;
+	} else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) {
+		offset = distance + cur;
+	} else if (whence == SEEK_END) {
+		offset = max - distance;
+	}
+	if (whence != SEEK_FORCECUR) {
+		offset = (offset > max) ? max : offset;
+		offset = (offset < min) ? min : offset;
+	}
+	return fseeko(fs->f, offset, SEEK_SET);
 }
 
 static int vox_trunc(struct ast_filestream *fs)
 {
-     return ftruncate(fileno(fs->f), ftello(fs->f));
+	return ftruncate(fileno(fs->f), ftello(fs->f));
 }
 
 static off_t vox_tell(struct ast_filestream *fs)
 {
-     off_t offset;
-     offset = ftello(fs->f) << 1;
-     return offset; 
+	return ftello(fs->f) << 1;
 }
 
 static const struct ast_format vox_f = {
 	.name = "vox",
 	.exts = "vox",
-	.format = AST_FORMAT_ADPCM,
+	.format = { .audio = { AST_FORMAT_AUDIO_ADPCM } },
 	.write = vox_write,
 	.seek = vox_seek,
 	.trunc = vox_trunc,

Modified: team/group/codec_bits/formats/format_wav.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/formats/format_wav.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/formats/format_wav.c (original)
+++ team/group/codec_bits/formats/format_wav.c Wed Apr  2 19:23:21 2008
@@ -345,6 +345,7 @@
 	off_t here;
 	/* Send a frame from the file to the appropriate channel */
 	struct wav_desc *fs = (struct wav_desc *)s->_private;
+	const struct ast_extended_codec wav = { .audio = { AST_FORMAT_AUDIO_SLINEAR } };
 
 	here = ftello(s->f);
 	if (fs->maxlen - here < bytes)		/* truncate if necessary */
@@ -353,7 +354,8 @@
 		bytes = 0;
 /* 	ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
 	s->fr.frametype = AST_FRAME_VOICE;
-	s->fr.subclass = AST_FORMAT_SLINEAR;
+	s->fr.subclass = 0;
+	s->fr.codec = wav;
 	s->fr.mallocd = 0;
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
 	
@@ -389,7 +391,7 @@
 		ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
 		return -1;
 	}
-	if (f->subclass != AST_FORMAT_SLINEAR) {
+	if (f->codec.audio[0] != AST_FORMAT_AUDIO_SLINEAR) {
 		ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n", f->subclass);
 		return -1;
 	}
@@ -403,7 +405,7 @@
 		return -1;
 	}
 	tmpi = f->data;
-	for (x=0; x < f->datalen/2; x++) 
+	for (x = 0; x < f->datalen / 2; x++) 
 		tmp[x] = (tmpi[x] << 8) | ((tmpi[x] & 0xff00) >> 8);
 
 	if ((res = fwrite(tmp, 1, f->datalen, fs->f)) != f->datalen ) {
@@ -431,14 +433,15 @@
 	cur = ftello(fs->f);
 	fseeko(fs->f, 0, SEEK_END);
 	max = ftello(fs->f);
-	if (whence == SEEK_SET)
+	if (whence == SEEK_SET) {
 		offset = samples + min;
-	else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
+	} else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) {
 		offset = samples + cur;
-	else if (whence == SEEK_END)
+	} else if (whence == SEEK_END) {
 		offset = max - samples;
-        if (whence != SEEK_FORCECUR) {
-		offset = (offset > max)?max:offset;
+	}
+	if (whence != SEEK_FORCECUR) {
+		offset = (offset > max) ? max : offset;
 	}
 	/* always protect the header space. */
 	offset = (offset < min)?min:offset;
@@ -463,7 +466,7 @@
 static const struct ast_format wav_f = {
 	.name = "wav",
 	.exts = "wav",
-	.format = AST_FORMAT_SLINEAR,
+	.format = { .audio = { AST_FORMAT_AUDIO_SLINEAR } },
 	.open =	wav_open,
 	.rewrite = wav_rewrite,
 	.write = wav_write,

Modified: team/group/codec_bits/formats/format_wav_gsm.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/formats/format_wav_gsm.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/formats/format_wav_gsm.c (original)
+++ team/group/codec_bits/formats/format_wav_gsm.c Wed Apr  2 19:23:21 2008
@@ -393,9 +393,11 @@
 {
 	/* Send a frame from the file to the appropriate channel */
 	struct wavg_desc *fs = (struct wavg_desc *)s->_private;
+	const struct ast_extended_codec gsm = { .audio = { AST_FORMAT_AUDIO_GSM } };
 
 	s->fr.frametype = AST_FRAME_VOICE;
-	s->fr.subclass = AST_FORMAT_GSM;
+	s->fr.subclass = 0;
+	s->fr.codec = gsm;
 	s->fr.offset = AST_FRIENDLY_OFFSET;
 	s->fr.samples = GSM_SAMPLES;
 	s->fr.mallocd = 0;
@@ -432,7 +434,7 @@
 		ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
 		return -1;
 	}
-	if (f->subclass != AST_FORMAT_GSM) {
+	if (f->codec.audio[0] != AST_FORMAT_AUDIO_GSM) {
 		ast_log(LOG_WARNING, "Asked to write non-GSM frame (%d)!\n", f->subclass);
 		return -1;
 	}
@@ -522,7 +524,7 @@
 static const struct ast_format wav49_f = {
 	.name = "wav49",
 	.exts = "WAV|wav49",
-	.format = AST_FORMAT_GSM,
+	.format = { .audio = { AST_FORMAT_AUDIO_GSM } },
 	.open =	wav_open,
 	.rewrite = wav_rewrite,
 	.write = wav_write,

Modified: team/group/codec_bits/funcs/func_channel.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/funcs/func_channel.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/funcs/func_channel.c (original)
+++ team/group/codec_bits/funcs/func_channel.c Wed Apr  2 19:23:21 2008
@@ -62,11 +62,11 @@
 	if (!strcasecmp(data, "audionativeformat"))
 		/* use the _multiple version when chan->nativeformats holds multiple formats */
 		/* ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_AUDIO_MASK); */
-		ast_copy_string(buf, ast_getformatname(chan->nativeformats & AST_FORMAT_AUDIO_MASK), len);
+		ast_copy_string(buf, ast_getformatname(FMT_AND(chan->nativeformats, AST_FMT_AUDIO_MASK)), len);
 	else if (!strcasecmp(data, "videonativeformat"))
 		/* use the _multiple version when chan->nativeformats holds multiple formats */
 		/* ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_VIDEO_MASK); */
-		ast_copy_string(buf, ast_getformatname(chan->nativeformats & AST_FORMAT_VIDEO_MASK), len);
+		ast_copy_string(buf, ast_getformatname(FMT_AND(chan->nativeformats, AST_FMT_VIDEO_MASK)), len);
 	else if (!strcasecmp(data, "audioreadformat"))
 		ast_copy_string(buf, ast_getformatname(chan->readformat), len);
 	else if (!strcasecmp(data, "audiowriteformat"))

Modified: team/group/codec_bits/include/asterisk/abstract_jb.h
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/include/asterisk/abstract_jb.h?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/include/asterisk/abstract_jb.h (original)
+++ team/group/codec_bits/include/asterisk/abstract_jb.h Wed Apr  2 19:23:21 2008
@@ -31,6 +31,7 @@
 #define _ABSTRACT_JB_H_
 
 #include <sys/time.h>
+#include "asterisk/frame.h"
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
@@ -92,7 +93,7 @@
 	/*! \brief The time the next frame should be played. */
 	long next;
 	/*! \brief Voice format of the last frame in. */
-	int last_format;
+	struct ast_extended_codec last_format;
 	/*! \brief File for frame timestamp tracing. */
 	FILE *logfile;
 	/*! \brief Jitterbuffer internal state flags. */

Modified: team/group/codec_bits/include/asterisk/mod_format.h
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/include/asterisk/mod_format.h?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/include/asterisk/mod_format.h (original)
+++ team/group/codec_bits/include/asterisk/mod_format.h Wed Apr  2 19:23:21 2008
@@ -109,7 +109,7 @@
 	/*! Transparently translate from another format -- just once */
 	struct ast_trans_pvt *trans;
 	struct ast_tranlator_pvt *tr;
-	int lastwriteformat;
+	struct ast_extended_codec lastwriteformat;
 	int lasttimeout;
 	struct ast_channel *owner;
 	FILE *f;

Modified: team/group/codec_bits/main/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/abstract_jb.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/main/abstract_jb.c (original)
+++ team/group/codec_bits/main/abstract_jb.c Wed Apr  2 19:23:21 2008
@@ -403,14 +403,15 @@
 		case JB_IMPL_DROP:
 			jb_framelog("\tJB_GET {now=%ld}: %s frame with ts=%ld and len=%ld\n",
 				now, jb_get_actions[res], f->ts, f->len);
-			jb->last_format = f->subclass;
+			jb->last_format = f->codec;
 			ast_frfree(f);
 			break;
 		case JB_IMPL_INTERP:
 			/* interpolate a frame */
 			f = &finterp;
 			f->frametype = AST_FRAME_VOICE;
-			f->subclass = jb->last_format;
+			f->subclass = 0;
+			f->codec = jb->last_format;
 			f->datalen  = 0;
 			f->samples  = interpolation_len * 8;
 			f->mallocd  = 0;
@@ -474,7 +475,7 @@
 	jb->next = jbimpl->next(jbobj);
 	
 	/* Init last format for a first time. */
-	jb->last_format = frr->subclass;
+	jb->last_format = frr->codec;
 	
 	/* Create a frame log file */
 	if (ast_test_flag(jbconf, AST_JB_LOG)) {

Modified: team/group/codec_bits/main/app.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/app.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/main/app.c (original)
+++ team/group/codec_bits/main/app.c Wed Apr  2 19:23:21 2008
@@ -300,15 +300,15 @@
 	int fd;
 	int autoclose;
 	int allowoverride;
-	int origwfmt;
+	struct ast_extended_codec origwfmt;
 };
 
 static void linear_release(struct ast_channel *chan, void *params)
 {
 	struct linear_state *ls = params;
 	
-	if (ls->origwfmt && ast_set_write_format(chan, ls->origwfmt))
-		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, ls->origwfmt);
+	if (FMT_NZ(ls->origwfmt) && ast_set_write_format(chan, ls->origwfmt))
+		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%s'\n", chan->name, ast_getformatname(ls->origwfmt));
 
 	if (ls->autoclose)
 		close(ls->fd);
@@ -322,7 +322,8 @@
 	struct linear_state *ls = data;
 	struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
+		.subclass = 0,
+		.codec = AST_FMT_SLINEAR,
 		.data = buf + AST_FRIENDLY_OFFSET / 2,
 		.offset = AST_FRIENDLY_OFFSET,
 	};
@@ -359,7 +360,7 @@
 
 	ls->origwfmt = chan->writeformat;
 
-	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
+	if (ast_set_write_format(chan, AST_FMT_SLINEAR)) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name);
 		ast_free(ls);
 		ls = params = NULL;
@@ -572,7 +573,7 @@
 	time_t start, end;
 	struct ast_dsp *sildet = NULL;   /* silence detector dsp */
 	int totalsilence = 0;
-	int rfmt = 0;
+	struct ast_extended_codec rfmt = { { 0 } };
 	struct ast_silence_generator *silgen = NULL;
 	char prependfile[80];
 
@@ -640,7 +641,7 @@
 		}
 		ast_dsp_set_threshold(sildet, silencethreshold);
 		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");
 			ast_dsp_free(sildet);
@@ -812,7 +813,7 @@
 			ast_filedelete(prependfile, sfmt[x]);
 		}
 	}
-	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);
 	}
 	if (outmsg == 2) {

Modified: team/group/codec_bits/main/audiohook.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/audiohook.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/main/audiohook.c (original)
+++ team/group/codec_bits/main/audiohook.c Wed Apr  2 19:23:21 2008
@@ -40,7 +40,7 @@
 
 struct ast_audiohook_translate {
 	struct ast_trans_pvt *trans_pvt;
-	int format;
+	struct ast_extended_codec format;
 };
 
 struct ast_audiohook_list {
@@ -148,7 +148,8 @@
 	short buf[samples];
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
+		.subclass = 0,
+		.codec = AST_FMT_SLINEAR,
 		.data = buf,
 		.datalen = sizeof(buf),
 		.samples = samples,
@@ -175,7 +176,8 @@
 	short buf1[samples], buf2[samples], *read_buf = NULL, *write_buf = NULL, *final_buf = NULL, *data1 = NULL, *data2 = NULL;
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
+		.subclass = 0,
+		.codec = AST_FMT_SLINEAR,
 		.data = NULL,
 		.datalen = sizeof(buf1),
 		.samples = samples,
@@ -267,7 +269,7 @@
  * \param format Format of frame remote side wants back
  * \return Returns frame on success, NULL on failure
  */
-struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, int format)
+struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, struct ast_extended_codec format)
 {
 	struct ast_frame *read_frame = NULL, *final_frame = NULL;
 
@@ -275,15 +277,15 @@
 		return NULL;
 
 	/* If they don't want signed linear back out, we'll have to send it through the translation path */
-	if (format != AST_FORMAT_SLINEAR) {
+	if (format.audio[0] != AST_FORMAT_AUDIO_SLINEAR) {
 		/* Rebuild translation path if different format then previously */
-		if (audiohook->format != format) {
+		if (!FMT_EQ(audiohook->format, format)) {
 			if (audiohook->trans_pvt) {
 				ast_translator_free_path(audiohook->trans_pvt);
 				audiohook->trans_pvt = NULL;
 			}
 			/* Setup new translation path for this format... if we fail we can't very well return signed linear so free the frame and return nothing */
-			if (!(audiohook->trans_pvt = ast_translator_build_path(format, AST_FORMAT_SLINEAR))) {
+			if (!(audiohook->trans_pvt = ast_translator_build_path(format, AST_FMT_SLINEAR))) {
 				ast_frfree(read_frame);
 				return NULL;
 			}
@@ -491,13 +493,13 @@
 	int samples = frame->samples;
 	
 	/* If the frame coming in is not signed linear we have to send it through the in_translate path */
-	if (frame->subclass != AST_FORMAT_SLINEAR) {
-		if (in_translate->format != frame->subclass) {
+	if (frame->codec.audio[0] != AST_FORMAT_AUDIO_SLINEAR) {
+		if (!FMT_EQ(in_translate->format, frame->codec)) {
 			if (in_translate->trans_pvt)
 				ast_translator_free_path(in_translate->trans_pvt);
-			if (!(in_translate->trans_pvt = ast_translator_build_path(AST_FORMAT_SLINEAR, frame->subclass)))
+			if (!(in_translate->trans_pvt = ast_translator_build_path(AST_FMT_SLINEAR, frame->codec)))
 				return frame;
-			in_translate->format = frame->subclass;
+			in_translate->format = frame->codec;
 		}
 		if (!(middle_frame = ast_translate(in_translate->trans_pvt, frame, 0)))
 			return frame;
@@ -570,15 +572,15 @@
 	if (middle_frame == end_frame) {
 		/* Middle frame was modified and became the end frame... let's see if we need to transcode */
 		if (end_frame->subclass != start_frame->subclass) {
-			if (out_translate->format != start_frame->subclass) {
+			if (!FMT_EQ(out_translate->format, start_frame->codec)) {
 				if (out_translate->trans_pvt)
 					ast_translator_free_path(out_translate->trans_pvt);
-				if (!(out_translate->trans_pvt = ast_translator_build_path(start_frame->subclass, AST_FORMAT_SLINEAR))) {
+				if (!(out_translate->trans_pvt = ast_translator_build_path(start_frame->codec, AST_FMT_SLINEAR))) {
 					/* We can't transcode this... drop our middle frame and return the original */
 					ast_frfree(middle_frame);
 					return start_frame;
 				}
-				out_translate->format = start_frame->subclass;
+				out_translate->format = start_frame->codec;
 			}
 			/* Transcode from our middle (signed linear) frame to new format of the frame that came in */
 			if (!(end_frame = ast_translate(out_translate->trans_pvt, middle_frame, 0))) {

Modified: team/group/codec_bits/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/channel.c?view=diff&rev=112560&r1=112559&r2=112560
==============================================================================
--- team/group/codec_bits/main/channel.c (original)
+++ team/group/codec_bits/main/channel.c Wed Apr  2 19:23:21 2008
@@ -268,6 +268,7 @@
 static char *handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct chanlist *cl = NULL;
+	struct ast_str *str = ast_str_alloca(BITSTRING_SIZE);
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -302,7 +303,7 @@
 		"  Device State: %s\n"
 		"    Indication: %s\n"
 		"     Transfer : %s\n"
-		"  Capabilities: %d\n"
+		"  Capabilities: %s\n"
 		"   Digit Begin: %s\n"
 		"     Digit End: %s\n"
 		"    Send HTML : %s\n"
@@ -312,7 +313,7 @@
 		(cl->tech->devicestate) ? "yes" : "no",
 		(cl->tech->indicate) ? "yes" : "no",
 		(cl->tech->transfer) ? "yes" : "no",
-		(cl->tech->capabilities) ? cl->tech->capabilities : -1,
+		FMT_NZ(cl->tech->capabilities) ? ast_codec2bitstring(cl->tech->capabilities, &str) : "ALL",
 		(cl->tech->send_digit_begin) ? "yes" : "no",
 		(cl->tech->send_digit_end) ? "yes" : "no",
 		(cl->tech->send_html) ? "yes" : "no",
@@ -702,56 +703,62 @@
 }
 
 /*! \brief Pick the best audio codec */
-int ast_best_codec(int fmts)
+struct ast_extended_codec ast_best_codec(struct ast_extended_codec fmts)
 {
 	/* This just our opinion, expressed in code.  We are asked to choose
 	   the best codec to use, given no information */
 	int x;
-	static const int prefs[] =
-	{
+	struct ast_extended_codec result = { { 0 } };
+	struct ast_str *str = ast_str_alloca(BITSTRING_SIZE);
+	static const struct {
+		int page;
+		int codec;
+	} prefs[] = {
 		/*! Okay, ulaw is used by all telephony equipment, so start with it */
-		AST_FORMAT_ULAW,
+		{ 0, AST_FORMAT_AUDIO_ULAW },
 		/*! Unless of course, you're a silly European, so then prefer ALAW */
-		AST_FORMAT_ALAW,
+		{ 0, AST_FORMAT_AUDIO_ALAW },
 		/*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */
-		AST_FORMAT_G722,
+		{ 0, AST_FORMAT_AUDIO_G722 },
 		/*! Okay, well, signed linear is easy to translate into other stuff */
-		AST_FORMAT_SLINEAR16,
-		AST_FORMAT_SLINEAR,
+		{ 0, AST_FORMAT_AUDIO_SLINEAR16 },
+		{ 0, AST_FORMAT_AUDIO_SLINEAR },
 		/*! G.726 is standard ADPCM, in RFC3551 packing order */
-		AST_FORMAT_G726,
+		{ 0, AST_FORMAT_AUDIO_G726 },
 		/*! G.726 is standard ADPCM, in AAL2 packing order */
-		AST_FORMAT_G726_AAL2,
+		{ 0, AST_FORMAT_AUDIO_G726_AAL2 },
 		/*! ADPCM has great sound quality and is still pretty easy to translate */
-		AST_FORMAT_ADPCM,
+		{ 0, AST_FORMAT_AUDIO_ADPCM },
 		/*! Okay, we're down to vocoders now, so pick GSM because it's small and easier to
 		    translate and sounds pretty good */
-		AST_FORMAT_GSM,
+		{ 0, AST_FORMAT_AUDIO_GSM },
 		/*! iLBC is not too bad */
-		AST_FORMAT_ILBC,
+		{ 0, AST_FORMAT_AUDIO_ILBC },
 		/*! Speex is free, but computationally more expensive than GSM */
-		AST_FORMAT_SPEEX,
+		{ 0, AST_FORMAT_AUDIO_SPEEX },
 		/*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough
 		    to use it */
-		AST_FORMAT_LPC10,
+		{ 0, AST_FORMAT_AUDIO_LPC10 },
 		/*! G.729a is faster than 723 and slightly less expensive */
-		AST_FORMAT_G729A,
+		{ 0, AST_FORMAT_AUDIO_G729A },
 		/*! Down to G.723.1 which is proprietary but at least designed for voice */
-		AST_FORMAT_G723_1,
+		{ 0, AST_FORMAT_AUDIO_G723_1 },
 	};
 
 	/* Strip out video */
-	fmts &= AST_FORMAT_AUDIO_MASK;
+	fmts = FMT_AND(fmts, AST_FMT_AUDIO_MASK);
 	
 	/* Find the first preferred codec in the format given */
 	for (x = 0; x < (sizeof(prefs) / sizeof(prefs[0]) ); x++) {
-		if (fmts & prefs[x])
-			return prefs[x];
-	}
-
-	ast_log(LOG_WARNING, "Don't know any of 0x%x formats\n", fmts);
-
-	return 0;
+		if (fmts.audio[prefs[x].page] & prefs[x].codec) {
+			result.audio[prefs[x].page] = prefs[x].codec;
+			return result;
+		}
+	}
+
+	ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_codec2bitstring(fmts, &str));
+
+	return AST_FMT_NULL_MASK;
 }
 
 static const struct ast_channel_tech null_tech = {
@@ -1724,7 +1731,7 @@
 	if (!tmp || !generate)
 		return 0;
 
-	res = generate(chan, tmp, 0, ast_format_rate(chan->writeformat & AST_FORMAT_AUDIO_MASK) / 50);
+	res = generate(chan, tmp, 0, ast_format_rate(FMT_AND(chan->writeformat, AST_FMT_AUDIO_MASK)) / 50);
 
 	chan->generatordata = tmp;
 
@@ -2266,9 +2273,9 @@
 
 		chan->generatordata = NULL;     /* reset, to let writes go through */
 
-		if (f->subclass != chan->writeformat) {
+		if (!FMT_EQ(f->codec, chan->writeformat)) {
 			float factor;
-			factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass));
+			factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->codec));
 			samples = (int) ( ((float) f->samples) * factor );
 		} else {
 			samples = f->samples;
@@ -2620,11 +2627,11 @@
 					ast_frfree(f);
 					f = &ast_null_frame;
 				}
-			} else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass & chan->nativeformats)) {
+			} else if ((f->frametype == AST_FRAME_VOICE) && FMT_NOT(FMT_AND(f->codec, chan->nativeformats))) {
 				/* This frame can't be from the current native formats -- drop it on the
 				   floor */
 				ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
-					chan->name, ast_getformatname(f->subclass), ast_getformatname(chan->nativeformats));
+					chan->name, ast_getformatname(f->codec), ast_getformatname(chan->nativeformats));
 				ast_frfree(f);
 				f = &ast_null_frame;
 			} else if ((f->frametype == AST_FRAME_VOICE)) {
@@ -2906,7 +2913,8 @@
 	/* Send an empty audio frame to get things moving */
 	if (chan->_state != AST_STATE_UP) {
 		ast_debug(1, "Prodding channel '%s'\n", chan->name);
-		a.subclass = chan->rawwriteformat;
+		a.subclass = 0;
+		a.codec = chan->rawwriteformat;
 		a.data = nothing + AST_FRIENDLY_OFFSET;
 		a.src = "ast_prod";
 		if (ast_write(chan, &a))
@@ -3014,7 +3022,7 @@
 		CHECK_BLOCKING(chan);
 		break;
 	case AST_FRAME_TEXT:
-		if (fr->subclass == AST_FORMAT_T140) {
+		if (fr->codec.text[0] == AST_FORMAT_TEXT_T140) {
 			res = (chan->tech->write_text == NULL) ? 0 :
 				chan->tech->write_text(chan, fr);
 		} else {
@@ -3048,10 +3056,11 @@
 		}
 
 		/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
-		if (fr->subclass == chan->rawwriteformat)
+		if (FMT_EQ(fr->codec, chan->rawwriteformat)) {
 			f = fr;
-		else
+		} else {
 			f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
+		}
 
 		if (!f) {
 			res = 0;
@@ -3119,27 +3128,29 @@
 	return res;
 }
 
-static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *format,
+static int set_format(struct ast_channel *chan, struct ast_extended_codec fmt, struct ast_extended_codec *rawformat, struct ast_extended_codec *format,
 		      struct ast_trans_pvt **trans, const int direction)
 {
-	int native;
+	struct ast_extended_codec native;
 	int res;
 
 	/* Make sure we only consider audio */
-	fmt &= AST_FORMAT_AUDIO_MASK;
+	fmt = FMT_AND(fmt, AST_FMT_AUDIO_MASK);
 	
 	native = chan->nativeformats;
 
-	if (!fmt || !native)	/* No audio requested */
+	if (FMT_NOT(fmt) || FMT_NOT(native)) {	/* No audio requested */
 		return 0;	/* Let's try a call without any sounds (video, text) */
-	
+	}
+
 	/* Find a translation path from the native format to one of the desired formats */
-	if (!direction)
+	if (!direction) {
 		/* reading */
 		res = ast_translator_best_choice(&fmt, &native);
-	else
+	} else {
 		/* writing */
 		res = ast_translator_best_choice(&native, &fmt);
+	}
 
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to find a codec translation path from %s to %s\n",
@@ -3150,7 +3161,7 @@
 	/* Now we have a good choice for both. */
 	ast_channel_lock(chan);
 
-	if ((*rawformat == native) && (*format == fmt) && ((*rawformat == *format) || (*trans))) {
+	if (FMT_EQ(*rawformat, native) && FMT_EQ(*format, fmt) && (FMT_EQ(*rawformat, *format) || (*trans))) {
 		/* the channel is already in these formats, so nothing to do */
 		ast_channel_unlock(chan);
 		return 0;
@@ -3163,25 +3174,26 @@
 	if (*trans)
 		ast_translator_free_path(*trans);
 	/* Build a translation path from the raw format to the desired format */
-	if (!direction)
+	if (!direction) {
 		/* reading */
 		*trans = ast_translator_build_path(*format, *rawformat);
-	else
+	} else {
 		/* writing */
 		*trans = ast_translator_build_path(*rawformat, *format);
+	}
 	ast_channel_unlock(chan);
 	ast_debug(1, "Set channel %s to %s format %s\n", chan->name,
 		direction ? "write" : "read", ast_getformatname(fmt));
 	return 0;
 }
 
-int ast_set_read_format(struct ast_channel *chan, int fmt)
+int ast_set_read_format(struct ast_channel *chan, struct ast_extended_codec fmt)
 {
 	return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat,
 			  &chan->readtrans, 0);
 }
 
-int ast_set_write_format(struct ast_channel *chan, int fmt)
+int ast_set_write_format(struct ast_channel *chan, struct ast_extended_codec fmt)
 {
 	return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat,
 			  &chan->writetrans, 1);
@@ -3210,7 +3222,7 @@
 	}
 }
 
-struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
+struct ast_channel *__ast_request_and_dial(const char *type, struct ast_extended_codec format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
 {
 	int dummy_outstate;
 	int cause = 0;
@@ -3341,21 +3353,21 @@
 	return chan;
 }
 
-struct ast_channel *ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname)
+struct ast_channel *ast_request_and_dial(const char *type, struct ast_extended_codec format, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname)
 {
 	return __ast_request_and_dial(type, format, data, timeout, outstate, cidnum, cidname, NULL);
 }
 
-struct ast_channel *ast_request(const char *type, int format, void *data, int *cause)
+struct ast_channel *ast_request(const char *type, struct ast_extended_codec format, void *data, int *cause)
 {
 	struct chanlist *chan;
 	struct ast_channel *c;
-	int capabilities;
-	int fmt;
+	struct ast_extended_codec capabilities, fmt;
 	int res;
 	int foo;
-	int videoformat = format & AST_FORMAT_VIDEO_MASK;
-	int textformat = format & AST_FORMAT_TEXT_MASK;
+	struct ast_extended_codec videoformat = FMT_AND(format, AST_FMT_VIDEO_MASK);
+	struct ast_extended_codec textformat = FMT_AND(format, AST_FMT_TEXT_MASK);
+	struct ast_str *str[2] = { ast_str_alloca(BITSTRING_SIZE), ast_str_alloca(BITSTRING_SIZE) };
 
 	if (!cause)
 		cause = &foo;
@@ -3371,14 +3383,13 @@
 			continue;
 
 		capabilities = chan->tech->capabilities;
-		fmt = format & AST_FORMAT_AUDIO_MASK;
-		if (fmt) {
+		if (FMT_NZ(fmt = FMT_AND(format, AST_FMT_AUDIO_MASK))) {
 			/* We have audio - is it possible to connect the various calls to each other? 
 				(Avoid this check for calls without audio, like text+video calls)
 			*/
 			res = ast_translator_best_choice(&fmt, &capabilities);
 			if (res < 0) {
-				ast_log(LOG_WARNING, "No translator path exists for channel type %s (native 0x%x) to 0x%x\n", type, chan->tech->capabilities, format);
+				ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type, ast_codec2bitstring(chan->tech->capabilities, &str[0]), ast_codec2bitstring(format, &str[1]));
 				*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
 				AST_RWLIST_UNLOCK(&channels);
 				return NULL;
@@ -3388,7 +3399,7 @@
 		if (!chan->tech->requester)
 			return NULL;
 		
-		if (!(c = chan->tech->requester(type, capabilities | videoformat | textformat, data, cause)))
+		if (!(c = chan->tech->requester(type, FMT_OR(capabilities, FMT_OR(videoformat, textformat)), data, cause)))
 			return NULL;
 		
 		/* no need to generate a Newchannel event here; it is done in the channel_alloc call */
@@ -3512,10 +3523,11 @@
 /*! \brief Set up translation from one channel to another */
 static int ast_channel_make_compatible_helper(struct ast_channel *from, struct ast_channel *to)
 {
-	int src;
-	int dst;
-
-	if (from->readformat == to->writeformat && from->writeformat == to->readformat) {
+	struct ast_extended_codec src;
+	struct ast_extended_codec dst;
+	struct ast_str *str[2] = { ast_str_alloca(BITSTRING_SIZE), ast_str_alloca(BITSTRING_SIZE) };
+
+	if (FMT_EQ(from->readformat, to->writeformat) && FMT_EQ(from->writeformat, to->readformat)) {
 		/* Already compatible!  Moving on ... */
 		return 0;
 	}
@@ -3525,11 +3537,12 @@
 	dst = to->nativeformats;
 
 	/* If there's no audio in this call, don't bother with trying to find a translation path */
-	if ((src & AST_FORMAT_AUDIO_MASK) == 0 || (dst & AST_FORMAT_AUDIO_MASK) == 0)
+	if (FMT_NOT(FMT_AND(src, AST_FMT_AUDIO_MASK)) || FMT_NOT(FMT_AND(dst, AST_FMT_AUDIO_MASK))) {
 		return 0;
+	}
 
 	if (ast_translator_best_choice(&dst, &src) < 0) {
-		ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", from->name, src, to->name, dst);
+		ast_log(LOG_WARNING, "No path to translate from %s(%s) to %s(%s)\n", from->name, ast_codec2bitstring(src, &str[0]), to->name, ast_codec2bitstring(dst, &str[1]));
 		return -1;
 	}
 
@@ -3537,15 +3550,15 @@
 	   transcoding is needed; if desired, force transcode path
 	   to use SLINEAR between channels, but only if there is
 	   no direct conversion available */
-	if ((src != dst) && ast_opt_transcode_via_slin &&

[... 1271 lines stripped ...]



More information about the asterisk-commits mailing list