[asterisk-commits] tilghman: branch group/codec_bits r112818 - in /team/group/codec_bits: includ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 4 13:35:29 CDT 2008


Author: tilghman
Date: Fri Apr  4 13:35:28 2008
New Revision: 112818

URL: http://svn.digium.com/view/asterisk?view=rev&rev=112818
Log:
Bunch more core changes

Modified:
    team/group/codec_bits/include/asterisk/image.h
    team/group/codec_bits/main/frame.c
    team/group/codec_bits/main/image.c
    team/group/codec_bits/main/indications.c
    team/group/codec_bits/main/manager.c
    team/group/codec_bits/main/pbx.c
    team/group/codec_bits/main/rtp.c

Modified: team/group/codec_bits/include/asterisk/image.h
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/include/asterisk/image.h?view=diff&rev=112818&r1=112817&r2=112818
==============================================================================
--- team/group/codec_bits/include/asterisk/image.h (original)
+++ team/group/codec_bits/include/asterisk/image.h Fri Apr  4 13:35:28 2008
@@ -64,7 +64,7 @@
  * \retval an ast_frame on success
  * \retval NULL on failure
  */
-struct ast_frame *ast_read_image(char *filename, const char *preflang, int format);
+struct ast_frame *ast_read_image(char *filename, const char *preflang, struct ast_extended_codec format);
 
 /*! 
  * \brief Register image format

Modified: team/group/codec_bits/main/frame.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/frame.c?view=diff&rev=112818&r1=112817&r2=112818
==============================================================================
--- team/group/codec_bits/main/frame.c (original)
+++ team/group/codec_bits/main/frame.c Fri Apr  4 13:35:28 2008
@@ -37,6 +37,7 @@
 #include "asterisk/threadstorage.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/translate.h"
+#include "asterisk/app.h"
 
 #ifdef TRACE_FRAMES
 static int headers;
@@ -106,28 +107,50 @@
 
 /*! \brief Definition of supported media formats (codecs) */
 static struct ast_format_list AST_FORMAT_LIST[] = {
-	{ AST_FORMAT_AUDIO_G723_1 , "g723", 8000, "G.723.1", 20, 30, 300, 30, 30 },                                  /*!< G723.1 */
-	{ AST_FORMAT_AUDIO_GSM, "gsm", 8000, "GSM", 33, 20, 300, 20, 20 },                                           /*!< codec_gsm.c */
-	{ AST_FORMAT_AUDIO_ULAW, "ulaw", 8000, "G.711 u-law", 80, 10, 150, 10, 20 },                                 /*!< codec_ulaw.c */
-	{ AST_FORMAT_AUDIO_ALAW, "alaw", 8000, "G.711 A-law", 80, 10, 150, 10, 20 },                                 /*!< codec_alaw.c */
-	{ AST_FORMAT_AUDIO_G726, "g726", 8000, "G.726 RFC3551", 40, 10, 300, 10, 20 },                               /*!< codec_g726.c */
-	{ AST_FORMAT_AUDIO_ADPCM, "adpcm" , 8000, "ADPCM", 40, 10, 300, 10, 20 },                                    /*!< codec_adpcm.c */
-	{ AST_FORMAT_AUDIO_SLINEAR, "slin", 8000, "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE }, /*!< Signed linear */
-	{ AST_FORMAT_AUDIO_LPC10, "lpc10", 8000, "LPC10", 7, 20, 20, 20, 20 },                                       /*!< codec_lpc10.c */ 
-	{ AST_FORMAT_AUDIO_G729A, "g729", 8000, "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729 },             /*!< Binary commercial distribution */
-	{ AST_FORMAT_AUDIO_SPEEX, "speex", 8000, "SpeeX", 10, 10, 60, 10, 20 },                                      /*!< codec_speex.c */
-	{ AST_FORMAT_AUDIO_ILBC, "ilbc", 8000, "iLBC", 50, 30, 30, 30, 30 },                                         /*!< codec_ilbc.c */ /* inc=30ms - workaround */
-	{ AST_FORMAT_AUDIO_G726_AAL2, "g726aal2", 8000, "G.726 AAL2", 40, 10, 300, 10, 20 },                         /*!< codec_g726.c */
-	{ AST_FORMAT_AUDIO_G722, "g722", 16000, "G722", 80, 10, 150, 10, 20 },                                       /*!< codec_g722.c */
-	{ AST_FORMAT_AUDIO_SLINEAR16, "slin16", 16000, "16 bit Signed Linear PCM (16kHz)", 320, 10, 70, 10, 20 },    /*!< Signed linear (16kHz) */
-	{ AST_FORMAT_IMAGE_JPEG, "jpeg", 0, "JPEG image"},                                                           /*!< See format_jpeg.c */
-	{ AST_FORMAT_IMAGE_PNG, "png", 0, "PNG image"},                                                              /*!< PNG Image format */
-	{ AST_FORMAT_VIDEO_H261, "h261", 0, "H.261 Video" },                                                         /*!< H.261 Video Passthrough */
-	{ AST_FORMAT_VIDEO_H263, "h263", 0, "H.263 Video" },                                                         /*!< H.263 Passthrough support, see format_h263.c */
-	{ AST_FORMAT_VIDEO_H263_PLUS, "h263p", 0, "H.263+ Video" },                                                  /*!< H.263plus passthrough support See format_h263.c */
-	{ AST_FORMAT_VIDEO_H264, "h264", 0, "H.264 Video" },                                                         /*!< Passthrough support, see format_h263.c */
-	{ AST_FORMAT_VIDEO_MP4_VIDEO, "mpeg4", 0, "MPEG4 Video" },                                                   /*!< Passthrough support for MPEG4 */
-	{ AST_FORMAT_TEXT_T140, "t140", 0, "Passthrough T.140 Realtime Text" },                                      /*!< Passthrough support for T.140 Realtime Text */
+	/*! G723.1 */
+	{ { .audio = { AST_FORMAT_AUDIO_G723_1 } }, "g723", 8000, "G.723.1", 20, 30, 300, 30, 30 },
+	/*! codec_gsm.c */
+	{ { .audio = { AST_FORMAT_AUDIO_GSM } }, "gsm", 8000, "GSM", 33, 20, 300, 20, 20 },
+	/*! codec_ulaw.c */
+	{ { .audio = { AST_FORMAT_AUDIO_ULAW } }, "ulaw", 8000, "G.711 u-law", 80, 10, 150, 10, 20 },
+	/*! codec_alaw.c */
+	{ { .audio = { AST_FORMAT_AUDIO_ALAW } }, "alaw", 8000, "G.711 A-law", 80, 10, 150, 10, 20 },
+	/*! codec_g726.c */
+	{ { .audio = { AST_FORMAT_AUDIO_G726 } }, "g726", 8000, "G.726 RFC3551", 40, 10, 300, 10, 20 },
+	/*! codec_adpcm.c */
+	{ { .audio = { AST_FORMAT_AUDIO_ADPCM } }, "adpcm" , 8000, "ADPCM", 40, 10, 300, 10, 20 },
+	/*! Signed linear */
+	{ { .audio = { AST_FORMAT_AUDIO_SLINEAR } }, "slin", 8000, "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE },
+	/*! codec_lpc10.c */ 
+	{ { .audio = { AST_FORMAT_AUDIO_LPC10 } }, "lpc10", 8000, "LPC10", 7, 20, 20, 20, 20 },
+	/*! Binary commercial distribution */
+	{ { .audio = { AST_FORMAT_AUDIO_G729A } }, "g729", 8000, "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729 },
+	/*! codec_speex.c */
+	{ { .audio = { AST_FORMAT_AUDIO_SPEEX } }, "speex", 8000, "SpeeX", 10, 10, 60, 10, 20 },
+	/*! codec_ilbc.c */ /* inc=30ms - workaround */
+	{ { .audio = { AST_FORMAT_AUDIO_ILBC } }, "ilbc", 8000, "iLBC", 50, 30, 30, 30, 30 },
+	/*! codec_g726.c */
+	{ { .audio = { AST_FORMAT_AUDIO_G726_AAL2 } }, "g726aal2", 8000, "G.726 AAL2", 40, 10, 300, 10, 20 },
+	/*! codec_g722.c */
+	{ { .audio = { AST_FORMAT_AUDIO_G722 } }, "g722", 16000, "G722", 80, 10, 150, 10, 20 },
+	/*! Signed linear (16kHz) */
+	{ { .audio = { AST_FORMAT_AUDIO_SLINEAR16 } }, "slin16", 16000, "16 bit Signed Linear PCM (16kHz)", 320, 10, 70, 10, 20 },
+	/*! See format_jpeg.c */
+	{ { .image = { AST_FORMAT_IMAGE_JPEG } }, "jpeg", 0, "JPEG image"},
+	/*! PNG Image format */
+	{ { .image = { AST_FORMAT_IMAGE_PNG } }, "png", 0, "PNG image"},
+	/*! H.261 Video Passthrough */
+	{ { .video = { AST_FORMAT_VIDEO_H261 } }, "h261", 0, "H.261 Video" },
+	/*! H.263 Passthrough support, see format_h263.c */
+	{ { .video = { AST_FORMAT_VIDEO_H263 } }, "h263", 0, "H.263 Video" },
+	/*! H.263plus passthrough support See format_h263.c */
+	{ { .video = { AST_FORMAT_VIDEO_H263_PLUS } }, "h263p", 0, "H.263+ Video" },
+	/*! Passthrough support, see format_h263.c */
+	{ { .video = { AST_FORMAT_VIDEO_H264 } }, "h264", 0, "H.264 Video" },
+	/*! Passthrough support for MPEG4 */
+	{ { .video = { AST_FORMAT_VIDEO_MP4_VIDEO } }, "mpeg4", 0, "MPEG4 Video" },
+	/*! Passthrough support for T.140 Realtime Text */
+	{ { .text = { AST_FORMAT_TEXT_T140 } }, "t140", 0, "Passthrough T.140 Realtime Text" },
 };
 
 struct ast_frame ast_null_frame = { AST_FRAME_NULL, };
@@ -169,11 +192,11 @@
 		ast_log(LOG_WARNING, "Huh?  Can't smooth a non-voice frame!\n");
 		return -1;
 	}
-	if (!s->format) {
-		s->format = f->subclass;
+	if (FMT_NOT(s->format)) {
+		s->format = f->codec;
 		s->samplesperbyte = (float)f->samples / (float)f->datalen;
-	} else if (s->format != f->subclass) {
-		ast_log(LOG_WARNING, "Smoother was working on %d format frames, now trying to feed %d?\n", s->format, f->subclass);
+	} else if (!FMT_EQ(s->format, f->codec)) {
+		ast_log(LOG_WARNING, "Smoother was working on %s format frames, now trying to feed %s?\n", ast_getformatname(s->format), ast_getformatname(f->codec));
 		return -1;
 	}
 	if (s->len + f->datalen > SMOOTHER_SIZE) {
@@ -235,7 +258,8 @@
 		len = s->len;
 	/* Make frame */
 	s->f.frametype = AST_FRAME_VOICE;
-	s->f.subclass = s->format;
+	s->f.subclass = 0;
+	s->f.codec = s->format;
 	s->f.data = s->framedata + AST_FRIENDLY_OFFSET;
 	s->f.offset = AST_FRIENDLY_OFFSET;
 	s->f.datalen = len;
@@ -529,19 +553,19 @@
 	int x;
 	unsigned len;
 	char *start, *end = buf;
+	struct ast_str *str = ast_str_alloca(BITSTRING_SIZE);
 
 	if (!size) {
 		return buf;
 	}
-	snprintf(end, size, "0x%x (", format);
+	snprintf(end, size, "%s (", ast_codec2bitstring(format, &str));
 	len = strlen(end);
 	end += len;
 	size -= len;
 	start = end;
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
-		if (AST_FORMAT_LIST[x].bits & format) {
-			snprintf(end, size,"%s|",AST_FORMAT_LIST[x].name);
-			len = strlen(end);
+		if (FMT_NZ(FMT_AND(AST_FORMAT_LIST[x].bits, format))) {
+			len = snprintf(end, size, "%s|", AST_FORMAT_LIST[x].name);
 			end += len;
 			size -= len;
 		}
@@ -573,30 +597,32 @@
 	return in;
 }
 
-int ast_getformatbyname(const char *name)
-{
-	int x, all, format = 0;
+struct ast_extended_codec ast_getformatbyname(const char *name)
+{
+	int x, all;
+	struct ast_extended_codec format = { { 0 } };
 
 	all = strcasecmp(name, "all") ? 0 : 1;
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
 		if (all || 
-			  !strcasecmp(AST_FORMAT_LIST[x].name,name) ||
-			  !strcasecmp(AST_FORMAT_LIST[x].name,ast_expand_codec_alias(name))) {
-			format |= AST_FORMAT_LIST[x].bits;
-			if (!all)
+			  !strcasecmp(AST_FORMAT_LIST[x].name, name) ||
+			  !strcasecmp(AST_FORMAT_LIST[x].name, ast_expand_codec_alias(name))) {
+			format = FMT_OR(format, AST_FORMAT_LIST[x].bits);
+			if (!all) {
 				break;
+			}
 		}
 	}
 
 	return format;
 }
 
-char *ast_codec2str(int codec)
+const char *ast_codec2str(struct ast_extended_codec codec)
 {
 	int x;
 	char *ret = "unknown";
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
-		if (AST_FORMAT_LIST[x].bits == codec) {
+		if (FMT_EQ(AST_FORMAT_LIST[x].bits, codec)) {
 			ret = AST_FORMAT_LIST[x].desc;
 			break;
 		}
@@ -606,14 +632,15 @@
 
 static char *show_codecs(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	int i, found=0;
-	char hex[25];
+	int page, bits, found = 0;
+	struct ast_extended_codec codec = { { 0 } };
+	struct ast_str *str = ast_str_alloca(BITSTRING_SIZE);
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "core show codecs [audio|video|image]";
+		e->command = "core show codecs [audio|video|image|text]";
 		e->usage = 
-			"Usage: core show codecs [audio|video|image]\n"
+			"Usage: core show codecs [audio|video|image|text]\n"
 			"       Displays codec mapping\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -627,29 +654,61 @@
 		ast_cli(a->fd, "Disclaimer: this command is for informational purposes only.\n"
 				"\tIt does not indicate anything about your configuration.\n");
 
-	ast_cli(a->fd, "%11s %9s %10s   TYPE   %8s   %s\n","INT","BINARY","HEX","NAME","DESC");
+	ast_cli(a->fd, "TYPE   %*s  %8s (%s)\n", BITSTRING_SIZE, "BITSTRING", "NAME", "DESC");
 	ast_cli(a->fd, "--------------------------------------------------------------------------------\n");
-	if ((a->argc == 3) || (!strcasecmp(a->argv[3],"audio"))) {
+	if ((a->argc == 3) || (!strcasecmp(a->argv[3], "audio"))) {
 		found = 1;
-		for (i=0;i<13;i++) {
-			snprintf(hex,25,"(0x%x)",1<<i);
-			ast_cli(a->fd, "%11u (1 << %2d) %10s  audio   %8s   (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
-		}
-	}
-
-	if ((a->argc == 3) || (!strcasecmp(a->argv[3],"image"))) {
+		for (page = 0; page < sizeof(codec.audio) / sizeof(codec.audio[0]); page++) {
+			for (bits = 0; bits < sizeof(codec.audio[0]) * 8; bits++) {
+				codec.audio[page] = 1 << bits;
+				/* Skip undefined bits */
+				if (strcmp(ast_codec2str(codec), "unknown") != 0) {
+					ast_cli(a->fd, "audio  %*s  %s  (%s)\n", BITSTRING_SIZE, ast_codec2bitstring(codec, &str), ast_getformatname(codec), ast_codec2str(codec));
+				}
+			}
+			codec.audio[page] = 0;
+		}
+	}
+
+	if ((a->argc == 3) || (!strcasecmp(a->argv[3], "image"))) {
 		found = 1;
-		for (i=16;i<18;i++) {
-			snprintf(hex,25,"(0x%x)",1<<i);
-			ast_cli(a->fd, "%11u (1 << %2d) %10s  image   %8s   (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
-		}
-	}
-
-	if ((a->argc == 3) || (!strcasecmp(a->argv[3],"video"))) {
+		for (page = 0; page < sizeof(codec.image) / sizeof(codec.image[0]); page++) {
+			for (bits = 0; bits < sizeof(codec.image[0]) * 8; bits++) {
+				codec.image[page] = 1 << bits;
+				/* Skip undefined bits */
+				if (strcmp(ast_codec2str(codec), "unknown") != 0) {
+					ast_cli(a->fd, "image  %*s  %s  (%s)\n", BITSTRING_SIZE, ast_codec2bitstring(codec, &str), ast_getformatname(codec), ast_codec2str(codec));
+				}
+			}
+			codec.image[page] = 0;
+		}
+	}
+
+	if ((a->argc == 3) || (!strcasecmp(a->argv[3], "video"))) {
 		found = 1;
-		for (i=18;i<22;i++) {
-			snprintf(hex,25,"(0x%x)",1<<i);
-			ast_cli(a->fd, "%11u (1 << %2d) %10s  video   %8s   (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+		for (page = 0; page < sizeof(codec.video) / sizeof(codec.video[0]); page++) {
+			for (bits = 0; bits < sizeof(codec.video[0]) * 8; bits++) {
+				codec.video[page] = 1 << bits;
+				/* Skip undefined bits */
+				if (strcmp(ast_codec2str(codec), "unknown") != 0) {
+					ast_cli(a->fd, "video  %*s  %s  (%s)\n", BITSTRING_SIZE, ast_codec2bitstring(codec, &str), ast_getformatname(codec), ast_codec2str(codec));
+				}
+			}
+			codec.video[page] = 0;
+		}
+	}
+
+	if ((a->argc == 3) || (!strcasecmp(a->argv[3], "text"))) {
+		found = 1;
+		for (page = 0; page < sizeof(codec.text) / sizeof(codec.text[0]); page++) {
+			for (bits = 0; bits < sizeof(codec.text[0]) * 8; bits++) {
+				codec.text[page] = 1 << bits;
+				/* Skip undefined bits */
+				if (strcmp(ast_codec2str(codec), "unknown") != 0) {
+					ast_cli(a->fd, "text  %*s  %s  (%s)\n", BITSTRING_SIZE, ast_codec2bitstring(codec, &str), ast_getformatname(codec), ast_codec2str(codec));
+				}
+			}
+			codec.text[page] = 0;
 		}
 	}
 
@@ -659,35 +718,120 @@
 		return CLI_SUCCESS;
 }
 
+const char *ast_codec2bitstring(struct ast_extended_codec codec, struct ast_str **str)
+{
+	int page;
+
+	ast_str_set(str, 0, "A:");
+	for (page = 0; page < sizeof(codec.audio) / sizeof(codec.audio[0]); page++) {
+		char hex[4];
+		snprintf(hex, sizeof(hex), "%s%0x", page > 0 ? "-" : "", codec.audio[page]);
+		ast_str_append(str, 0, "%s", hex);
+	}
+
+	ast_str_append(str, 0, ";V:");
+	for (page = 0; page < sizeof(codec.video) / sizeof(codec.video[0]); page++) {
+		char hex[4];
+		snprintf(hex, sizeof(hex), "%s%0x", page > 0 ? "-" : "", codec.video[page]);
+		ast_str_append(str, 0, "%s", hex);
+	}
+
+	ast_str_append(str, 0, ";I:");
+	for (page = 0; page < sizeof(codec.image) / sizeof(codec.image[0]); page++) {
+		char hex[4];
+		snprintf(hex, sizeof(hex), "%s%0x", page > 0 ? "-" : "", codec.image[page]);
+		ast_str_append(str, 0, "%s", hex);
+	}
+
+	ast_str_append(str, 0, ";T:");
+	for (page = 0; page < sizeof(codec.text) / sizeof(codec.text[0]); page++) {
+		char hex[4];
+		snprintf(hex, sizeof(hex), "%s%0x", page > 0 ? "-" : "", codec.text[page]);
+		ast_str_append(str, 0, "%s", hex);
+	}
+
+	return ( (*str)->str );
+}
+
 static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	int codec, i, found=0;
+	int page, bits, i;
+	union {
+		struct ast_extended_codec codec;
+		int bitfield[64];
+	} u = { { { 0, } } }, my = { { { 0 } } };
+	char *data;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(bits)[4];
+	);
+	struct ast_str *str = ast_str_alloca(BITSTRING_SIZE);
 
 	switch (cmd) {
 	case CLI_INIT:
 		e->command = "core show codec";
 		e->usage = 
-			"Usage: core show codec <number>\n"
+			"Usage: core show codec <bitstring>\n"
 			"       Displays codec mapping\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
 	}
 
-	if (a->argc != 4)
+	if (a->argc != 4) {
 		return CLI_SHOWUSAGE;
-
-	if (sscanf(a->argv[3],"%d",&codec) != 1)
+	}
+
+	data = ast_strdupa(a->argv[3]);
+	AST_NONSTANDARD_APP_ARGS(args, data, ';');
+
+	for (i = 0; i < args.argc; i++) {
+		int *start;
+		int max;
+		int j;
+
+		if (strncasecmp(args.bits[i], "A:", 2) == 0) {
+			start = my.codec.audio;
+			max = sizeof(my.codec.audio) / sizeof(my.codec.audio[0]);
+		} else if (strncasecmp(args.bits[i], "V:", 2) == 0) {
+			start = my.codec.video;
+			max = sizeof(my.codec.video) / sizeof(my.codec.video[0]);
+		} else if (strncasecmp(args.bits[i], "I:", 2) == 0) {
+			start = my.codec.image;
+			max = sizeof(my.codec.image) / sizeof(my.codec.image[0]);
+		} else if (strncasecmp(args.bits[i], "T:", 2) == 0) {
+			start = my.codec.text;
+			max = sizeof(my.codec.text) / sizeof(my.codec.text[0]);
+		} else {
+			return CLI_SHOWUSAGE;
+		}
+
+		/* Skip preamble */
+		args.bits[i] += 2;
+
+		for (j = 0; j < max; j++) {
+			char spacer = 0;
+			if (sscanf(args.bits[i], "%x%c", start + j, &spacer) < 1) {
+				break;
+			}
+
+			/* Parsed spacer char? */
+			args.bits[i] += spacer ? 3 : 2;
+		}
+	}
+
+	if (FMT_NOT(my.codec)) {
 		return CLI_SHOWUSAGE;
-
-	for (i = 0; i < 32; i++)
-		if (codec & (1 << i)) {
-			found = 1;
-			ast_cli(a->fd, "%11u (1 << %2d)  %s\n",1 << i,i,ast_codec2str(1<<i));
-		}
-
-	if (!found)
-		ast_cli(a->fd, "Codec %d not found\n", codec);
+	}
+
+	for (page = 0; page < sizeof(u.codec) / sizeof(int); page++) {
+		for (bits = 0; bits < sizeof(int) * 8; bits++) {
+			u.bitfield[page] = 1 << bits;
+			if (FMT_NZ(FMT_AND(u.codec, my.codec))) {
+				ast_cli(a->fd, "%s  %s\n", ast_codec2bitstring(u.codec, &str), ast_codec2str(u.codec));
+			}
+		}
+		u.bitfield[page] = 0;
+	}
 
 	return CLI_SUCCESS;
 }
@@ -822,7 +966,7 @@
 		break;
 	case AST_FRAME_IMAGE:
 		strcpy(ftype, "Image");
-		snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass));
+		snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->codec));
 		break;
 	case AST_FRAME_HTML:
 		strcpy(ftype, "HTML");
@@ -969,7 +1113,8 @@
 
 int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size) 
 {
-	int x, codec; 
+	int x;
+	struct ast_extended_codec codec; 
 	size_t total_len, slen;
 	char *formatname;
 	
@@ -980,7 +1125,7 @@
 	for(x = 0; x < 32 ; x++) {
 		if (total_len <= 0)
 			break;
-		if (!(codec = ast_codec_pref_index(pref,x)))
+		if (FMT_NOT(codec = ast_codec_pref_index(pref, x)))
 			break;
 		if ((formatname = ast_getformatname(codec))) {
 			slen = strlen(formatname);
@@ -989,7 +1134,7 @@
 			strncat(buf, formatname, total_len - 1); /* safe */
 			total_len -= slen;
 		}
-		if (total_len && x < 31 && ast_codec_pref_index(pref , x + 1)) {
+		if (total_len && x < 31 && FMT_NZ(ast_codec_pref_index(pref , x + 1))) {
 			strncat(buf, "|", total_len - 1); /* safe */
 			total_len--;
 		}
@@ -1002,16 +1147,15 @@
 	return size - total_len;
 }
 
-int ast_codec_pref_index(struct ast_codec_pref *pref, int index) 
+struct ast_extended_codec ast_codec_pref_index(struct ast_codec_pref *pref, int index) 
 {
 	int slot = 0;
 
-	
 	if ((index >= 0) && (index < sizeof(pref->order))) {
 		slot = pref->order[index];
 	}
 
-	return slot ? AST_FORMAT_LIST[slot-1].bits : 0;
+	return slot ? AST_FORMAT_LIST[slot-1].bits : AST_FMT_NULL_MASK;
 }
 
 /*! \brief Remove codec from pref list */
@@ -1033,7 +1177,7 @@
 		size = oldorder.framing[x];
 		if (! slot)
 			break;
-		if (AST_FORMAT_LIST[slot-1].bits != format) {
+		if (!FMT_EQ(AST_FORMAT_LIST[slot-1].bits, format)) {
 			pref->order[y] = slot;
 			pref->framing[y++] = size;
 		}
@@ -1042,14 +1186,14 @@
 }
 
 /*! \brief Append codec to list */
-int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
+int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_extended_codec format)
 {
 	int x, newindex = 0;
 
 	ast_codec_pref_remove(pref, format);
 
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
-		if (AST_FORMAT_LIST[x].bits == format) {
+		if (FMT_EQ(AST_FORMAT_LIST[x].bits, format)) {
 			newindex = x + 1;
 			break;
 		}
@@ -1068,13 +1212,13 @@
 }
 
 /*! \brief Prepend codec to list */
-void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if_existing)
+void ast_codec_pref_prepend(struct ast_codec_pref *pref, struct ast_extended_codec format, int only_if_existing)
 {
 	int x, newindex = 0;
 
 	/* First step is to get the codecs "index number" */
 	for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
-		if (AST_FORMAT_LIST[x].bits == format) {
+		if (FMT_EQ(AST_FORMAT_LIST[x].bits, format)) {
 			newindex = x + 1;
 			break;
 		}
@@ -1105,12 +1249,12 @@
 }
 
 /*! \brief Set packet size for codec */
-int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems)
+int ast_codec_pref_setsize(struct ast_codec_pref *pref, struct ast_extended_codec format, int framems)
 {
 	int x, index = -1;
 
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
-		if (AST_FORMAT_LIST[x].bits == format) {
+		if (FMT_EQ(AST_FORMAT_LIST[x].bits, format)) {
 			index = x;
 			break;
 		}
@@ -1147,10 +1291,10 @@
 struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, struct ast_extended_codec format)
 {
 	int x, index = -1, framems = 0;
-	struct ast_format_list fmt = { 0, };
+	struct ast_format_list fmt = { { { 0, } } };
 
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
-		if (AST_FORMAT_LIST[x].bits == format) {
+		if (FMT_EQ(AST_FORMAT_LIST[x].bits, format)) {
 			fmt = AST_FORMAT_LIST[x];
 			index = x;
 			break;
@@ -1183,33 +1327,35 @@
 }
 
 /*! \brief Pick a codec */
-int ast_codec_choose(struct ast_codec_pref *pref, struct ast_extended_codec formats, int find_best)
-{
-	int x, ret = 0, slot;
+struct ast_extended_codec ast_codec_choose(struct ast_codec_pref *pref, struct ast_extended_codec formats, int find_best)
+{
+	int x, slot;
+	struct ast_extended_codec ret = { { 0 } };
 
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
 		slot = pref->order[x];
 
 		if (!slot)
 			break;
-		if (formats & AST_FORMAT_LIST[slot-1].bits) {
+		if (FMT_NZ(FMT_AND(formats, AST_FORMAT_LIST[slot-1].bits))) {
 			ret = AST_FORMAT_LIST[slot-1].bits;
 			break;
 		}
 	}
-	if (ret & AST_FORMAT_AUDIO_MASK)
+	if (FMT_NZ(FMT_AND(ret, AST_FMT_AUDIO_MASK))) {
 		return ret;
+	}
 
 	ast_debug(4, "Could not find preferred codec - %s\n", find_best ? "Going for the best codec" : "Returning zero codec");
 
-   	return find_best ? ast_best_codec(formats) : 0;
+   	return find_best ? ast_best_codec(formats) : AST_FMT_NULL_MASK;
 }
 
 int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_extended_codec *mask, const char *list, int allowing) 
 {
 	int errors = 0;
 	char *parse = NULL, *this = NULL, *psize = NULL;
-	struct ast_extended_codec format = 0
+	struct ast_extended_codec format = { { 0 } };
 	int framems = 0;
 
 	parse = ast_strdupa(list);

Modified: team/group/codec_bits/main/image.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/image.c?view=diff&rev=112818&r1=112817&r2=112818
==============================================================================
--- team/group/codec_bits/main/image.c (original)
+++ team/group/codec_bits/main/image.c Fri Apr  4 13:35:28 2008
@@ -96,7 +96,7 @@
 	}
 }
 
-struct ast_frame *ast_read_image(char *filename, const char *preflang, int format)
+struct ast_frame *ast_read_image(char *filename, const char *preflang, struct ast_extended_codec format)
 {
 	struct ast_imager *i;
 	char buf[256];
@@ -109,7 +109,7 @@
 	
 	AST_RWLIST_RDLOCK(&imagers);
 	AST_RWLIST_TRAVERSE(&imagers, i, list) {
-		if (i->format & format) {
+		if (FMT_NZ(FMT_AND(i->format, format))) {
 			char *stringp=NULL;
 			ast_copy_string(tmp, i->exts, sizeof(tmp));
 			stringp = tmp;
@@ -157,7 +157,7 @@
 	struct ast_frame *f;
 	int res = -1;
 	if (chan->tech->send_image) {
-		f = ast_read_image(filename, chan->language, -1);
+		f = ast_read_image(filename, chan->language, AST_FMT_IMAGE_MASK);
 		if (f) {
 			res = chan->tech->send_image(chan, f);
 			ast_frfree(f);

Modified: team/group/codec_bits/main/indications.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/indications.c?view=diff&rev=112818&r1=112817&r2=112818
==============================================================================
--- team/group/codec_bits/main/indications.c (original)
+++ team/group/codec_bits/main/indications.c Fri Apr  4 13:35:28 2008
@@ -90,7 +90,7 @@
 	int npos;
 	int oldnpos;
 	int pos;
-	int origwfmt;
+	struct ast_extended_codec origwfmt;
 	struct ast_frame f;
 	unsigned char offset[AST_FRIENDLY_OFFSET];
 	short data[4000];
@@ -118,7 +118,7 @@
 
 	ps->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 signed linear format (write)\n", chan->name);
 		playtones_release(NULL, ps);
 		ps = NULL;
@@ -184,7 +184,8 @@
 	}
 	
 	ps->f.frametype = AST_FRAME_VOICE;
-	ps->f.subclass = AST_FORMAT_SLINEAR;
+	ps->f.subclass = 0;
+	ps->f.codec = AST_FMT_SLINEAR;
 	ps->f.datalen = len;
 	ps->f.samples = samples;
 	ps->f.offset = AST_FRIENDLY_OFFSET;

Modified: team/group/codec_bits/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/manager.c?view=diff&rev=112818&r1=112817&r2=112818
==============================================================================
--- team/group/codec_bits/main/manager.c (original)
+++ team/group/codec_bits/main/manager.c Fri Apr  4 13:35:28 2008
@@ -2089,12 +2089,12 @@
 	char requested_channel[AST_CHANNEL_NAME];
 
 	if (!ast_strlen_zero(in->app)) {
-		res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1,
+		res = ast_pbx_outgoing_app(in->tech, AST_FMT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1,
 			S_OR(in->cid_num, NULL),
 			S_OR(in->cid_name, NULL),
 			in->vars, in->account, &chan);
 	} else {
-		res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
+		res = ast_pbx_outgoing_exten(in->tech, AST_FMT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
 			S_OR(in->cid_num, NULL),
 			S_OR(in->cid_name, NULL),
 			in->vars, in->account, &chan);
@@ -2242,10 +2242,10 @@
 			astman_send_error(s, m, "Originate with certain 'Application' arguments requires the additional System privilege, which you do not have.");
 			return 0;
 		}
-		res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
+		res = ast_pbx_outgoing_app(tech, AST_FMT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
 	} else {
 		if (exten && context && pi)
-			res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
+			res = ast_pbx_outgoing_exten(tech, AST_FMT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
 		else {
 			astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
 			return 0;

Modified: team/group/codec_bits/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/pbx.c?view=diff&rev=112818&r1=112817&r2=112818
==============================================================================
--- team/group/codec_bits/main/pbx.c (original)
+++ team/group/codec_bits/main/pbx.c Fri Apr  4 13:35:28 2008
@@ -6801,7 +6801,7 @@
 	return 0;  /* success */
 }
 
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
+int ast_pbx_outgoing_exten(const char *type, struct ast_extended_codec format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
 {
 	struct ast_channel *chan;
 	struct async_stat *as;
@@ -6967,7 +6967,7 @@
 	return NULL;
 }
 
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
+int ast_pbx_outgoing_app(const char *type, struct ast_extended_codec format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
 {
 	struct ast_channel *chan;
 	struct app_tmp *tmp;

Modified: team/group/codec_bits/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/rtp.c?view=diff&rev=112818&r1=112817&r2=112818
==============================================================================
--- team/group/codec_bits/main/rtp.c (original)
+++ team/group/codec_bits/main/rtp.c Fri Apr  4 13:35:28 2008
@@ -1589,7 +1589,7 @@
 		return f ? f : &ast_null_frame;
 	}
 	rtp->lastrxformat = rtp->f.subclass = rtpPT.code;
-	rtp->f.frametype = (rtp->f.subclass & AST_FORMAT_AUDIO_MASK) ? AST_FRAME_VOICE : (rtp->f.subclass & AST_FORMAT_VIDEO_MASK) ? AST_FRAME_VIDEO : AST_FRAME_TEXT;
+	rtp->f.frametype = FMT_NZ(FMT_AND(rtp->f.codec, AST_FMT_AUDIO_MASK)) ? AST_FRAME_VOICE : FMT_NZ(FMT_AND(rtp->f.codec, AST_FMT_VIDEO_MASK)) ? AST_FRAME_VIDEO : AST_FRAME_TEXT;
 
 	if (!rtp->lastrxts)
 		rtp->lastrxts = timestamp;




More information about the asterisk-commits mailing list