[asterisk-commits] tilghman: branch group/codec_bits r108393 - in /team/group/codec_bits: channe...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 12 22:11:50 CDT 2008


Author: tilghman
Date: Wed Mar 12 22:11:49 2008
New Revision: 108393

URL: http://svn.digium.com/view/asterisk?view=rev&rev=108393
Log:
More changes, still far from done

Modified:
    team/group/codec_bits/channels/chan_iax2.c
    team/group/codec_bits/channels/chan_local.c
    team/group/codec_bits/channels/chan_mgcp.c
    team/group/codec_bits/channels/chan_oss.c
    team/group/codec_bits/channels/chan_phone.c
    team/group/codec_bits/channels/console_video.c
    team/group/codec_bits/channels/console_video.h
    team/group/codec_bits/include/asterisk/channel.h
    team/group/codec_bits/include/asterisk/frame.h
    team/group/codec_bits/include/asterisk/rtp.h

Modified: team/group/codec_bits/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_iax2.c?view=diff&rev=108393&r1=108392&r2=108393
==============================================================================
--- team/group/codec_bits/channels/chan_iax2.c (original)
+++ team/group/codec_bits/channels/chan_iax2.c Wed Mar 12 22:11:49 2008
@@ -186,21 +186,33 @@
 int (*iax2_regfunk)(const char *username, int onoff) = NULL;
 
 /* Ethernet, etc */
-#define IAX_CAPABILITY_FULLBANDWIDTH 	0xFFFF
+const struct ast_extended_codec IAX_CAPABILITY_FULLBANDWIDTH = { { -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1 }, -1 };
+
 /* T1, maybe ISDN */
-#define IAX_CAPABILITY_MEDBANDWIDTH 	(IAX_CAPABILITY_FULLBANDWIDTH & 	\
+const struct ast_extended_codec IAX_CAPABILITY_MEDBANDWIDTH = { { (-1 & 	\
 					 ~AST_FORMAT_SLINEAR &			\
 					 ~AST_FORMAT_ULAW &			\
 					 ~AST_FORMAT_ALAW &			\
-					 ~AST_FORMAT_G722) 
+					 ~AST_FORMAT_G722) }, };
 /* A modem */
-#define IAX_CAPABILITY_LOWBANDWIDTH	(IAX_CAPABILITY_MEDBANDWIDTH & 		\
+const struct ast_extended_codec IAX_CAPABILITY_LOWBANDWIDTH	= { { (-1 &		\
+					 ~AST_FORMAT_SLINEAR &			\
+					 ~AST_FORMAT_ULAW &			\
+					 ~AST_FORMAT_ALAW &			\
+					 ~AST_FORMAT_G722 &         \
 					 ~AST_FORMAT_G726 &			\
 					 ~AST_FORMAT_G726_AAL2 &		\
-					 ~AST_FORMAT_ADPCM)
-
-#define IAX_CAPABILITY_LOWFREE		(IAX_CAPABILITY_LOWBANDWIDTH & 		\
-					 ~AST_FORMAT_G723_1)
+					 ~AST_FORMAT_ADPCM) }, };
+
+const struct ast_extended_codec IAX_CAPABILITY_LOWFREE = { { (-1 & 		\
+					 ~AST_FORMAT_SLINEAR &			\
+					 ~AST_FORMAT_ULAW &			\
+					 ~AST_FORMAT_ALAW &			\
+					 ~AST_FORMAT_G722 &         \
+					 ~AST_FORMAT_G726 &			\
+					 ~AST_FORMAT_G726_AAL2 &		\
+					 ~AST_FORMAT_ADPCM &        \
+					 ~AST_FORMAT_G723_1) }, };
 
 
 #define DEFAULT_MAXMS		2000		/* Must be faster than 2 seconds by default */
@@ -210,7 +222,7 @@
 static	struct io_context *io;
 static	struct sched_context *sched;
 
-static int iax2_capability = IAX_CAPABILITY_FULLBANDWIDTH;
+static struct ast_extended_codec iax2_capability = { { -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1 }, -1 };
 
 static int iaxdebug = 0;
 
@@ -305,7 +317,7 @@
 	int amaflags;
 	int adsi;
 	unsigned int flags;
-	int capability;
+	struct ast_extended_codec capability;
 	int maxauthreq; /*!< Maximum allowed outstanding AUTHREQs */
 	int curauthreq; /*!< Current number of outstanding AUTHREQs */
 	struct ast_codec_pref prefs;
@@ -350,7 +362,7 @@
 
 	int expire;					/*!< Schedule entry for expiry */
 	int expiry;					/*!< How soon to expire */
-	int capability;					/*!< Capability */
+	struct ast_extended_codec capability;	/*!< Capability */
 
 	/* Qualification */
 	int callno;					/*!< Call number of POKE request */
@@ -475,15 +487,15 @@
 	/*! Socket to send/receive on for this call */
 	int sockfd;
 	/*! Last received voice format */
-	int voiceformat;
+	struct ast_extended_codec voiceformat;
 	/*! Last received video format */
-	int videoformat;
+	struct ast_extended_codec videoformat;
 	/*! Last sent voice format */
-	int svoiceformat;
+	struct ast_extended_codec svoiceformat;
 	/*! Last sent video format */
-	int svideoformat;
+	struct ast_extended_codec svideoformat;
 	/*! What we are capable of sending */
-	int capability;
+	struct ast_extended_codec capability;
 	/*! Last received timestamp */
 	unsigned int last;
 	/*! Last sent timestamp - never send the same timestamp twice in a single call */
@@ -509,11 +521,11 @@
 	/*! Negotiated format, this is only used to remember what format was
 	    chosen for an unauthenticated call so that the channel can get
 	    created later using the right format */
-	int chosenformat;
+	struct ast_extended_codec chosenformat;
 	/*! Peer selected format */
-	int peerformat;
+	struct ast_extended_codec peerformat;
 	/*! Peer capability */
-	int peercapability;
+	struct ast_extended_codec peercapability;
 	/*! timeval that we base our transmission on */
 	struct timeval offset;
 	/*! timeval that we base our delivery on */
@@ -888,7 +900,7 @@
 static int send_command_immediate(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int);
 static int send_command_locked(unsigned short callno, char, int, unsigned int, const unsigned char *, int, int);
 static int send_command_transfer(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int);
-static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause);
+static struct ast_channel *iax2_request(const char *type, struct ast_extended_codec format, void *data, int *cause);
 static struct ast_frame *iax2_read(struct ast_channel *c);
 static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
 static struct iax2_user *build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
@@ -903,7 +915,7 @@
 static const struct ast_channel_tech iax2_tech = {
 	.type = "IAX2",
 	.description = tdesc,
-	.capabilities = IAX_CAPABILITY_FULLBANDWIDTH,
+	.capabilities = { { -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1 }, -1 },
 	.properties = AST_CHAN_TP_WANTSJITTER,
 	.requester = iax2_request,
 	.devicestate = iax2_devicestate,
@@ -2400,7 +2412,8 @@
 	char cbuf[256];
 	struct iax2_peer *peer;
 	char codec_buf[512];
-	int x = 0, codec = 0, load_realtime = 0;
+	int x = 0, load_realtime = 0;
+	struct ast_extended_codec codec;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -2438,8 +2451,8 @@
 
 		ast_cli(a->fd, "  Codec Order  : (");
 		for(x = 0; x < 32 ; x++) {
-			codec = ast_codec_pref_index(&peer->prefs,x);
-			if(!codec)
+			codec.audio[0] = ast_codec_pref_index(&peer->prefs,x);
+			if(!codec.audio[0])
 				break;
 			ast_cli(a->fd, "%s", ast_getformatname(codec));
 			if(x < 31 && ast_codec_pref_index(&peer->prefs,x+1))
@@ -2718,7 +2731,7 @@
 	now = ast_tvdiff_ms(tv, pvt->rxcore);
 	
 	if(now >= (next = jb_next(pvt->jb))) {
-		ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat, NULL));
+		ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
 		switch(ret) {
 		case JB_OK:
 			fr = frame.data;
@@ -3170,7 +3183,7 @@
 		/* But move the calling channel's native codec to the top of the preference list */
 		memcpy(&ourprefs, &prefs, sizeof(ourprefs));
 		if (c)
-			ast_codec_pref_prepend(&ourprefs, c->nativeformats, NULL, 1);
+			ast_codec_pref_prepend(&ourprefs, c->nativeformats, 1);
 		ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
 		return 0;
 	}
@@ -3687,11 +3700,14 @@
 			return AST_BRIDGE_FAILED_NOWARN;
 		}
 		if (c0->nativeformats != c1->nativeformats) {
-				char buf0[255];
-				char buf1[255];
-				ast_getformatname_multiple(buf0, sizeof(buf0) -1, c0->nativeformats);
-				ast_getformatname_multiple(buf1, sizeof(buf1) -1, c1->nativeformats);
-			ast_verb(3, "Operating with different codecs %d[%s] %d[%s] , can't native bridge...\n", c0->nativeformats, buf0, c1->nativeformats, buf1);
+			struct ast_str *str1, *str2;
+			char buf0[255];
+			char buf1[255];
+			ast_getformatname_multiple(buf0, sizeof(buf0) -1, c0->nativeformats);
+			ast_getformatname_multiple(buf1, sizeof(buf1) -1, c1->nativeformats);
+			ast_verb(3, "Operating with different codecs %s[%s] %s[%s] , can't native bridge...\n", ast_codec2bitstring(c0->nativeformats, &str1), buf0, ast_codec2bitstring(c1->nativeformats, &str2), buf1);
+			ast_free(str1);
+			ast_free(str2);
 			/* Remove from native mode */
 			lock_both(callno0, callno1);
 			if (iaxs[callno0])
@@ -3873,7 +3889,7 @@
 }
 
 /*! \brief  Create new call, interface with the PBX core */
-static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
+static struct ast_channel *ast_iax2_new(int callno, int state, struct ast_extended_codec capability)
 {
 	struct ast_channel *tmp;
 	struct chan_iax2_pvt *i;
@@ -7723,7 +7739,7 @@
 	struct iax2_peer *peer;
 	struct iax_ies ies;
 	struct iax_ie_data ied0, ied1;
-	int format;
+	struct ast_extended_codec format;
 	int fd;
 	int exists;
 	int minivid = 0;
@@ -8046,9 +8062,11 @@
 		}
 
 		if (f.frametype == AST_FRAME_VOICE) {
-			if (f.subclass != iaxs[fr->callno]->voiceformat) {
+			if (memcmp(&f.codec, &iaxs[fr->callno]->voiceformat) != 0) {
+					struct ast_str *str = NULL;
 					iaxs[fr->callno]->voiceformat = f.subclass;
-					ast_debug(1, "Ooh, voice format changed to %d\n", f.subclass);
+					ast_debug(1, "Ooh, voice format changed to %s\n", ast_codec2bitstring(f.codec, &str));
+					ast_free(str);
 					if (iaxs[fr->callno]->owner) {
 						int orignative;
 retryowner:
@@ -8838,8 +8856,10 @@
 							return 1;
 						}
 					} else {
+						struct ast_str *str = NULL;
 						ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
-						ast_verb(3, "Accepting DIAL from %s, formats = 0x%x\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat);
+						ast_verb(3, "Accepting DIAL from %s, formats = %s\n", ast_inet_ntoa(sin.sin_addr), ast_codec2bitstring(iaxs[fr->callno]->peerformat, &str));
+						ast_free(str);
 						ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
 						send_command(iaxs[fr->callno], AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, 0, NULL, 0, -1);
 						if (!(c = ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->peerformat)))
@@ -9617,7 +9637,7 @@
 	}
 }
 
-static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause)
+static struct ast_channel *iax2_request(const char *type, struct ast_extended_codec format, void *data, int *cause)
 {
 	int callno;
 	int res;
@@ -10108,9 +10128,9 @@
 			} else if (!strcasecmp(v->name, "username")) {
 				ast_string_field_set(peer, username, v->value);
 			} else if (!strcasecmp(v->name, "allow")) {
-				ast_parse_allow_disallow(&peer->prefs, &peer->capability, NULL, v->value, 1);
+				ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, 1);
 			} else if (!strcasecmp(v->name, "disallow")) {
-				ast_parse_allow_disallow(&peer->prefs, &peer->capability, NULL, v->value, 0);
+				ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, 0);
 			} else if (!strcasecmp(v->name, "callerid")) {
 				if (!ast_strlen_zero(v->value)) {
 					char name2[80];
@@ -10302,9 +10322,9 @@
 					}
 				}
 			} else if (!strcasecmp(v->name, "allow")) {
-				ast_parse_allow_disallow(&user->prefs, &user->capability, NULL, v->value, 1);
+				ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, 1);
 			} else if (!strcasecmp(v->name, "disallow")) {
-				ast_parse_allow_disallow(&user->prefs, &user->capability, NULL, v->value, 0);
+				ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, 0);
 			} else if (!strcasecmp(v->name, "trunk")) {
 				ast_set2_flag(user, ast_true(v->value), IAX_TRUNK);	
 				if (ast_test_flag(user, IAX_TRUNK) && (timingfd < 0)) {
@@ -10534,7 +10554,7 @@
 static int set_config(char *config_file, int reload)
 {
 	struct ast_config *cfg, *ucfg;
-	int capability=iax2_capability;
+	struct ast_extended_codec capability = iax2_capability;
 	struct ast_variable *v;
 	char *cat;
 	const char *utype;
@@ -10761,9 +10781,9 @@
 			} else
 				ast_log(LOG_WARNING, "bandwidth must be either low, medium, or high\n");
 		} else if (!strcasecmp(v->name, "allow")) {
-			ast_parse_allow_disallow(&prefs, &capability, NULL, v->value, 1);
+			ast_parse_allow_disallow(&prefs, &capability, v->value, 1);
 		} else if (!strcasecmp(v->name, "disallow")) {
-			ast_parse_allow_disallow(&prefs, &capability, NULL, v->value, 0);
+			ast_parse_allow_disallow(&prefs, &capability, v->value, 0);
 		} else if (!strcasecmp(v->name, "register")) {
 			iax2_register(v->value, v->lineno);
 		} else if (!strcasecmp(v->name, "iaxcompat")) {
@@ -11028,7 +11048,7 @@
 
 	ast_mutex_lock(&iaxsl[callno]);
 	ast_string_field_set(iaxs[callno], dproot, data);
-	iaxs[callno]->capability = IAX_CAPABILITY_FULLBANDWIDTH;
+	iaxs[callno]->capability.audio[0] = IAX_CAPABILITY_FULLBANDWIDTH;
 
 	iax_ie_append_short(&ied, IAX_IE_VERSION, IAX_PROTO_VERSION);
 	iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, "TBD");

Modified: team/group/codec_bits/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_local.c?view=diff&rev=108393&r1=108392&r2=108393
==============================================================================
--- team/group/codec_bits/channels/chan_local.c (original)
+++ team/group/codec_bits/channels/chan_local.c Wed Mar 12 22:11:49 2008
@@ -61,7 +61,7 @@
 	.impl = "",
 };
 
-static struct ast_channel *local_request(const char *type, int format, void *data, int *cause);
+static struct ast_channel *local_request(const char *type, struct ast_extended_codec format, void *data, int *cause);
 static int local_digit_begin(struct ast_channel *ast, char digit);
 static int local_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
 static int local_call(struct ast_channel *ast, char *dest, int timeout);
@@ -79,7 +79,7 @@
 static const struct ast_channel_tech local_tech = {
 	.type = "Local",
 	.description = tdesc,
-	.capabilities = -1,
+	.capabilities = { { -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1 }, -1 },
 	.requester = local_request,
 	.send_digit_begin = local_digit_begin,
 	.send_digit_end = local_digit_end,
@@ -102,7 +102,7 @@
 	unsigned int flags;                     /* Private flags */
 	char context[AST_MAX_CONTEXT];		/* Context to call */
 	char exten[AST_MAX_EXTENSION];		/* Extension to call */
-	int reqformat;				/* Requested format */
+	struct ast_extended_codec reqformat;				/* Requested format */
 	struct ast_jb_conf jb_conf;		/*!< jitterbuffer configuration for this local channel */
 	struct ast_channel *owner;		/* Master Channel */
 	struct ast_channel *chan;		/* Outbound channel */
@@ -574,7 +574,7 @@
 }
 
 /*! \brief Create a call structure */
-static struct local_pvt *local_alloc(const char *data, int format)
+static struct local_pvt *local_alloc(const char *data, struct ast_extended_codec format)
 {
 	struct local_pvt *tmp = NULL;
 	char *c = NULL, *opts = NULL;
@@ -628,7 +628,8 @@
 static struct ast_channel *local_new(struct local_pvt *p, int state)
 {
 	struct ast_channel *tmp = NULL, *tmp2 = NULL;
-	int randnum = ast_random() & 0xffff, fmt = 0;
+	int randnum = ast_random() & 0xffff;
+	struct ast_extended_codec fmt = { { 0, }, };
 	const char *t;
 	int ama;
 
@@ -689,7 +690,7 @@
 }
 
 /*! \brief Part of PBX interface */
-static struct ast_channel *local_request(const char *type, int format, void *data, int *cause)
+static struct ast_channel *local_request(const char *type, struct ast_extended_codec format, void *data, int *cause)
 {
 	struct local_pvt *p = NULL;
 	struct ast_channel *chan = NULL;

Modified: team/group/codec_bits/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_mgcp.c?view=diff&rev=108393&r1=108392&r2=108393
==============================================================================
--- team/group/codec_bits/channels/chan_mgcp.c (original)
+++ team/group/codec_bits/channels/chan_mgcp.c Wed Mar 12 22:11:49 2008
@@ -207,7 +207,7 @@
 
 static int restart_monitor(void);
 
-static int capability = AST_FORMAT_ULAW;
+static struct ast_extended_codec capability = { { AST_FORMAT_ULAW, }, };
 static int nonCodecCapability = AST_RTP_DTMF;
 
 static char ourhost[MAXHOSTNAMELEN];
@@ -339,7 +339,7 @@
 	int iseq; /*!< Not used? */
 	int lastout; /*!< tracking this on the subchannels.  Is it needed here? */
 	int needdestroy; /*!< Not used? */
-	int capability;
+	struct ast_extended_codec capability;
 	int nonCodecCapability;
 	int onhooktime;
 	int msgstate; /*!< voicemail message state */
@@ -404,7 +404,7 @@
 static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone);
 static int transmit_modify_request(struct mgcp_subchannel *sub);
 static int transmit_notify_request_with_callerid(struct mgcp_subchannel *sub, char *tone, char *callernum, char *callername);
-static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp, int codecs);
+static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp, struct ast_extended_codec codecs);
 static int transmit_connection_del(struct mgcp_subchannel *sub);
 static int transmit_audit_endpoint(struct mgcp_endpoint *p);
 static void start_rtp(struct mgcp_subchannel *sub);
@@ -414,7 +414,7 @@
 static char *mgcp_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 static int reload_config(int reload);
 
-static struct ast_channel *mgcp_request(const char *type, int format, void *data, int *cause);
+static struct ast_channel *mgcp_request(const char *type, struct ast_extended_codec format, void *data, int *cause);
 static int mgcp_call(struct ast_channel *ast, char *dest, int timeout);
 static int mgcp_hangup(struct ast_channel *ast);
 static int mgcp_answer(struct ast_channel *ast);
@@ -430,7 +430,7 @@
 static const struct ast_channel_tech mgcp_tech = {
 	.type = "MGCP",
 	.description = tdesc,
-	.capabilities = AST_FORMAT_ULAW,
+	.capabilities = { { AST_FORMAT_ULAW, }, },
 	.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
 	.requester = mgcp_request,
 	.devicestate = mgcp_devicestate,
@@ -1237,9 +1237,11 @@
 	if (sub->owner) {
 		/* We already hold the channel lock */
 		if (f->frametype == AST_FRAME_VOICE) {
-			if (f->subclass != sub->owner->nativeformats) {
-				ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
-				sub->owner->nativeformats = f->subclass;
+			if (memcmp(&f->codec, &sub->owner->nativeformats, sizeof(f->codec)) != 0) {
+				struct ast_str *str = NULL;
+				ast_debug(1, "Oooh, format changed to %s\n", ast_codec2bitstring(f->codec, &str));
+				ast_free(str);
+				sub->owner->nativeformats = f->codec;
 				ast_set_read_format(sub->owner, sub->owner->readformat);
 				ast_set_write_format(sub->owner, sub->owner->writeformat);
 			}
@@ -1270,6 +1272,7 @@
 {
 	struct mgcp_subchannel *sub = ast->tech_pvt;
 	int res = 0;
+	struct ast_str *str[4] = { NULL, };
 	if (frame->frametype != AST_FRAME_VOICE) {
 		if (frame->frametype == AST_FRAME_IMAGE)
 			return 0;
@@ -1278,9 +1281,13 @@
 			return 0;
 		}
 	} else {
-		if (!(frame->subclass & ast->nativeformats)) {
-			ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
-				frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat);
+		if (ast_extended_codec_not(ast_extended_codec_and(frame->codec, ast->nativeformats))) {
+			ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
+				ast_codec2bitstring(frame->codec, &str[0]), ast_codec2bitstring(ast->nativeformats, &str[1]), ast_codec2bitstring(ast->readformat, &str[2]), ast_codec2bitstring(ast->writeformat, &str[3]));
+			ast_free(str[0]);
+			ast_free(str[1]);
+			ast_free(str[2]);
+			ast_free(str[3]);
 			return -1;
 		}
 	}
@@ -1497,13 +1504,13 @@
 {
 	struct ast_channel *tmp;
 	struct mgcp_endpoint *i = sub->parent;
-	int fmt;
+	struct ast_extended_codec fmt;
 
 	tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id);
 	if (tmp) {
 		tmp->tech = &mgcp_tech;
 		tmp->nativeformats = i->capability;
-		if (!tmp->nativeformats)
+		if (ast_extended_codec_not(tmp->nativeformats))
 			tmp->nativeformats = capability;
 		fmt = ast_best_codec(tmp->nativeformats);
 		ast_string_field_build(tmp, name, "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id);
@@ -1869,7 +1876,8 @@
 	char host[258];
 	int len;
 	int portno;
-	int peercapability, peerNonCodecCapability;
+	struct ast_extended_codec peercapability;
+	int peerNonCodecCapability;
 	struct sockaddr_in sin;
 	char *codecs;
 	struct ast_hostent ahp; struct hostent *hp;
@@ -1933,14 +1941,18 @@
 
 	/* Now gather all of the codecs that were asked for: */
 	ast_rtp_get_current_formats(sub->rtp, &peercapability, &peerNonCodecCapability);
-	p->capability = capability & peercapability;
+	p->capability = ast_extended_codec_and(capability, peercapability);
 	if (mgcpdebug) {
-		ast_verbose("Capabilities: us - %d, them - %d, combined - %d\n",
-			capability, peercapability, p->capability);
+		struct ast_str *str[3];
+		ast_verbose("Capabilities: us - %s, them - %s, combined - %s\n",
+			ast_codec2bitstring(capability, &str[0]), ast_codec2bitstring(peercapability, &str[1]), ast_codec2bitstring(p->capability, &str[2]));
+		ast_free(str[0]);
+		ast_free(str[1]);
+		ast_free(str[2]);
 		ast_verbose("Non-codec capabilities: us - %d, them - %d, combined - %d\n",
 			nonCodecCapability, peerNonCodecCapability, p->nonCodecCapability);
 	}
-	if (!p->capability) {
+	if (ast_extended_codec_not(p->capability)) {
 		ast_log(LOG_WARNING, "No compatible codecs!\n");
 		return -1;
 	}
@@ -2083,7 +2095,7 @@
 	char t[256];
 	char m[256] = "";
 	char a[1024] = "";
-	int x;
+	int x, y;
 	struct sockaddr_in dest;
 	struct mgcp_endpoint *p = sub->parent;
 	/* XXX We break with the "recommendation" and send our IP, in order that our
@@ -2116,17 +2128,22 @@
 	snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(dest.sin_addr));
 	ast_copy_string(t, "t=0 0\r\n", sizeof(t));
 	snprintf(m, sizeof(m), "m=audio %d RTP/AVP", ntohs(dest.sin_port));
-	for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
-		if (p->capability & x) {
-			if (mgcpdebug) {
-				ast_verbose("Answering with capability %d\n", x);
-			}
-			codec = ast_rtp_lookup_code(sub->rtp, 1, x);
-			if (codec > -1) {
-				snprintf(costr, sizeof(costr), " %d", codec);
-				strncat(m, costr, sizeof(m) - strlen(m) - 1);
-				snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype(1, x, 0));
-				strncat(a, costr, sizeof(a) - strlen(a) - 1);
+	for (x = 0; x <= 7; x++) {
+		for (y = 0; y < 32; y++) {
+			struct ast_extended_codec audiocodec = { { 0, }, };
+			audiocodec.audio[x] = (1 << y);
+
+			if (!ast_extended_codec_not(ast_extended_codec_and(p->capability, audiocodec))) {
+				if (mgcpdebug) {
+					ast_verbose("Answering with capability %d\n", x);
+				}
+				codec = ast_rtp_lookup_codec(sub->rtp, 1, audiocodec);
+				if (codec > -1) {
+					snprintf(costr, sizeof(costr), " %d", codec);
+					strncat(m, costr, sizeof(m) - strlen(m) - 1);
+					snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_codec_mime_subtype(audiocodec, 0));
+					strncat(a, costr, sizeof(a) - strlen(a) - 1);
+				}
 			}
 		}
 	}
@@ -2139,7 +2156,7 @@
 			if (codec > -1) {
 				snprintf(costr, sizeof(costr), " %d", codec);
 				strncat(m, costr, sizeof(m) - strlen(m) - 1);
-				snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype(0, x, 0));
+				snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_noncodec_mime_subtype(x, 0));
 				strncat(a, costr, sizeof(a) - strlen(a) - 1);
 				if (x == AST_RTP_DTMF) {
 					/* Indicate we support DTMF...  Not sure about 16,
@@ -2163,17 +2180,17 @@
 	return 0;
 }
 
-static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp, int codecs)
+static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp, struct ast_extended_codec codecs)
 {
 	struct mgcp_request resp;
 	char local[256];
 	char tmp[80];
-	int x;
-	int capability;
+	int x, y;
+	struct ast_extended_codec capability;
 	struct mgcp_endpoint *p = sub->parent;
 
 	capability = p->capability;
-	if (codecs)
+	if (!ast_extended_codec_not(codecs))
 		capability = codecs;
 	if (ast_strlen_zero(sub->cxident) && rtp) {
 		/* We don't have a CXident yet, store the destination and
@@ -2182,10 +2199,14 @@
 		return 0;
 	}
 	ast_copy_string(local, "p:20", sizeof(local));
-	for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
-		if (p->capability & x) {
-			snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x, 0));
-			strncat(local, tmp, sizeof(local) - strlen(local) - 1);
+	for (x = 0; x < 8; x++) {
+		for (y = 0; y <= 32; y++) {
+			struct ast_extended_codec audiocodec = { { 0, }, };
+			audiocodec.audio[x] = (1 << y);
+			if (!ast_extended_codec_not(ast_extended_codec_and(p->capability, audiocodec))) {
+				snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_codec_mime_subtype(audiocodec, 0));
+				strncat(local, tmp, sizeof(local) - strlen(local) - 1);
+			}
 		}
 	}
 	reqprep(&resp, p, "MDCX");
@@ -2208,14 +2229,18 @@
 	struct mgcp_request resp;
 	char local[256];
 	char tmp[80];
-	int x;
+	int x, y;
 	struct mgcp_endpoint *p = sub->parent;
 
 	ast_copy_string(local, "p:20", sizeof(local));
-	for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
-		if (p->capability & x) {
-			snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x, 0));
-			strncat(local, tmp, sizeof(local) - strlen(local) - 1);
+	for (x = 0; x < 8; x++) {
+		for (y = 0; y <= 32; y++) {
+			struct ast_extended_codec audiocodec = { { 0, }, };
+			audiocodec.audio[x] = (1 << y);
+			if (!ast_extended_codec_not(ast_extended_codec_and(p->capability, audiocodec))) {
+				snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_codec_mime_subtype(audiocodec, 0));
+				strncat(local, tmp, sizeof(local) - strlen(local) - 1);
+			}
 		}
 	}
 	if (mgcpdebug) {
@@ -2486,6 +2511,7 @@
 	char *c;
 	struct mgcp_request *req;
 	struct mgcp_gateway *gw = p->parent;
+	struct ast_extended_codec zero = { { 0, }, };
 
 	if (result < 200) {
 		/* provisional response */
@@ -2556,7 +2582,7 @@
 						}
 						ast_copy_string(sub->cxident, c, sizeof(sub->cxident));
 						if (sub->tmpdest.sin_addr.s_addr) {
-							transmit_modify_with_sdp(sub, NULL, 0);
+							transmit_modify_with_sdp(sub, NULL, zero);
 						}
 					} else {
 						/* XXX delete this one
@@ -3524,18 +3550,20 @@
 	return 0;
 }
 
-static struct ast_channel *mgcp_request(const char *type, int format, void *data, int *cause)
-{
-	int oldformat;
+static struct ast_channel *mgcp_request(const char *type, struct ast_extended_codec format, void *data, int *cause)
+{
+	struct ast_extended_codec oldformat;
 	struct mgcp_subchannel *sub;
 	struct ast_channel *tmpc = NULL;
 	char tmp[256];
 	char *dest = data;
+	struct ast_str *str = NULL;
 
 	oldformat = format;
-	format &= capability;
-	if (!format) {
-		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format);
+	format = ast_extended_codec_and(capability, format);
+	if (ast_extended_codec_not(format)) {
+		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_codec2bitstring(oldformat, &str));
+		ast_free(str);
 		return NULL;
 	}
 	ast_copy_string(tmp, dest, sizeof(tmp));
@@ -3977,7 +4005,7 @@
 		return AST_RTP_TRY_PARTIAL;
 }
 
-static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
+static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, struct ast_extended_codec codecs, int nat_active)
 {
 	/* XXX Is there such thing as video support with MGCP? XXX */
 	struct mgcp_subchannel *sub;
@@ -4103,7 +4131,7 @@
 	char *cat;
 	struct ast_hostent ahp;
 	struct hostent *hp;
-	int format;
+	struct ast_extended_codec format;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 	
 	if (gethostname(ourhost, sizeof(ourhost)-1)) {
@@ -4142,16 +4170,16 @@
 			}
 		} else if (!strcasecmp(v->name, "allow")) {
 			format = ast_getformatbyname(v->value);
-			if (format < 1) 
+			if (ast_extended_codec_not(format)) 
 				ast_log(LOG_WARNING, "Cannot allow unknown format '%s'\n", v->value);
 			else
-				capability |= format;
+				capability = ast_extended_codec_or(capability, format);
 		} else if (!strcasecmp(v->name, "disallow")) {
 			format = ast_getformatbyname(v->value);
-			if (format < 1) 
+			if (ast_extended_codec_not(format)) 
 				ast_log(LOG_WARNING, "Cannot disallow unknown format '%s'\n", v->value);
 			else
-				capability &= ~format;
+				capability = ast_extended_codec_and(ast_extended_codec_compl(format), capability);
 		} else if (!strcasecmp(v->name, "tos")) {
 			if (ast_str2tos(v->value, &tos))
 			    ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);

Modified: team/group/codec_bits/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_oss.c?view=diff&rev=108393&r1=108392&r2=108393
==============================================================================
--- team/group/codec_bits/channels/chan_oss.c (original)
+++ team/group/codec_bits/channels/chan_oss.c Wed Mar 12 22:11:49 2008
@@ -332,8 +332,7 @@
 
 static int setformat(struct chan_oss_pvt *o, int mode);
 
-static struct ast_channel *oss_request(const char *type, int format, void *data
-, int *cause);
+static struct ast_channel *oss_request(const char *type, const struct ast_extended_codec format, void *data, int *cause);
 static int oss_digit_begin(struct ast_channel *c, char digit);
 static int oss_digit_end(struct ast_channel *c, char digit, unsigned int duration);
 static int oss_text(struct ast_channel *c, const char *text);
@@ -350,7 +349,7 @@
 static struct ast_channel_tech oss_tech = {
 	.type = "Console",
 	.description = tdesc,
-	.capabilities = AST_FORMAT_SLINEAR, /* overwritten later */
+	.capabilities = { { AST_FORMAT_SLINEAR, }, }, /* overwritten later */
 	.requester = oss_request,
 	.send_digit_begin = oss_digit_begin,
 	.send_digit_end = oss_digit_end,
@@ -788,6 +787,7 @@
 static struct ast_channel *oss_new(struct chan_oss_pvt *o, char *ext, char *ctx, int state)
 {
 	struct ast_channel *c;
+	const struct ast_extended_codec slin = { { AST_FORMAT_SLINEAR, }, };
 
 	c = ast_channel_alloc(1, state, o->cid_num, o->cid_name, "", ext, ctx, 0, "OSS/%s", o->device + 5);
 	if (c == NULL)
@@ -796,13 +796,14 @@
 	if (o->sounddev < 0)
 		setformat(o, O_RDWR);
 	ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
-	c->nativeformats = AST_FORMAT_SLINEAR;
+	c->nativeformats = slin;
 	/* if the console makes the call, add video to the offer */
-	if (state == AST_STATE_RINGING)
-		c->nativeformats |= console_video_formats;
-
-	c->readformat = AST_FORMAT_SLINEAR;
-	c->writeformat = AST_FORMAT_SLINEAR;
+	if (state == AST_STATE_RINGING) {
+		c->nativeformats = ast_extended_codec_or(c->nativeformats, console_video_formats);
+	}
+
+	c->readformat = slin;
+	c->writeformat = slin;
 	c->tech_pvt = o;
 
 	if (!ast_strlen_zero(o->language))
@@ -829,7 +830,7 @@
 	return c;
 }
 
-static struct ast_channel *oss_request(const char *type, int format, void *data, int *cause)
+static struct ast_channel *oss_request(const char *type, const struct ast_extended_codec format, void *data, int *cause)
 {
 	struct ast_channel *c;
 	struct chan_oss_pvt *o;
@@ -838,6 +839,7 @@
 		AST_APP_ARG(flags);
 	);
 	char *parse = ast_strdupa(data);
+	const struct ast_extended_codec slin = { { AST_FORMAT_SLINEAR, }, };
 
 	AST_NONSTANDARD_APP_ARGS(args, parse, '/');
 	o = find_desc(args.name);
@@ -848,8 +850,10 @@
 		/* XXX we could default to 'dsp' perhaps ? */
 		return NULL;
 	}
-	if ((format & AST_FORMAT_SLINEAR) == 0) {
-		ast_log(LOG_NOTICE, "Format 0x%x unsupported\n", format);
+	if (ast_extended_codec_not(ast_extended_codec_and(format, slin))) {
+		struct ast_str *str = NULL;
+		ast_log(LOG_NOTICE, "Format %s unsupported\n", ast_codec2bitstring(format, &str));
+		ast_free(str);
 		return NULL;
 	}
 	if (o->owner) {
@@ -1437,7 +1441,7 @@
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
-	oss_tech.capabilities |= console_video_formats;
+	oss_tech.capabilities = ast_extended_codec_or(oss_tech.capabilities, console_video_formats);
 
 	if (ast_channel_register(&oss_tech)) {
 		ast_log(LOG_ERROR, "Unable to register channel type 'OSS'\n");

Modified: team/group/codec_bits/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_phone.c?view=diff&rev=108393&r1=108392&r2=108393
==============================================================================
--- team/group/codec_bits/channels/chan_phone.c (original)
+++ team/group/codec_bits/channels/chan_phone.c Wed Mar 12 22:11:49 2008
@@ -84,6 +84,8 @@
 static const char tdesc[] = "Standard Linux Telephony API Driver";
 static const char config[] = "phone.conf";
 
+const struct ast_extended_codec all_codecs = { { -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1 }, -1 };
+
 /* Default context for dialtone mode */
 static char context[AST_MAX_EXTENSION] = "default";
 
@@ -94,7 +96,7 @@
 
 static int silencesupression = 0;
 
-static int prefformat = AST_FORMAT_G729A | AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW;
+static struct ast_extended_codec prefformat = { { AST_FORMAT_G729A | AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW }, };
 
 /* Protect the interface list (of phone_pvt's) */
 AST_MUTEX_DEFINE_STATIC(iflock);
@@ -125,8 +127,8 @@
 	int fd;							/* Raw file descriptor for this device */
 	struct ast_channel *owner;		/* Channel we belong to, possibly NULL */
 	int mode;						/* Is this in the  */
-	int lastformat;					/* Last output format */
-	int lastinput;					/* Last input format */
+	struct ast_extended_codec lastformat;	/* Last output format */
+	struct ast_extended_codec lastinput;	/* Last input format */
 	int ministate;					/* Miniature state, for dialtone mode */
 	char dev[256];					/* Device name */
 	struct phone_pvt *next;			/* Next channel in list */
@@ -150,7 +152,7 @@
 static char cid_num[AST_MAX_EXTENSION];
 static char cid_name[AST_MAX_EXTENSION];
 
-static struct ast_channel *phone_request(const char *type, int format, void *data, int *cause);
+static struct ast_channel *phone_request(const char *type, const struct ast_extended_codec format, void *data, int *cause);
 static int phone_digit_begin(struct ast_channel *ast, char digit);
 static int phone_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
 static int phone_call(struct ast_channel *ast, char *dest, int timeout);
@@ -166,7 +168,7 @@
 static const struct ast_channel_tech phone_tech = {
 	.type = "Phone",
 	.description = tdesc,
-	.capabilities = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_G729A,
+	.capabilities = { { AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_G729A }, },
 	.requester = phone_request,
 	.send_digit_begin = phone_digit_begin,
 	.send_digit_end = phone_digit_end,
@@ -210,7 +212,7 @@
 		ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
 		usleep(320000);
 		ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_OFF_HOOK);
-			p->lastformat = -1;
+			p->lastformat = all_codecs;
 			res = 0;
 			break;
 	case AST_CONTROL_HOLD:
@@ -272,7 +274,7 @@
 		ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
 		usleep(320000);
 		ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_OFF_HOOK);
-		p->lastformat = -1;
+		p->lastformat = all_codecs;
 		return 0;
 	default:
 		ast_log(LOG_WARNING, "Unknown digit '%c'\n", digit);
@@ -280,7 +282,7 @@
 	}
 	ast_debug(1, "Dialed %d\n", outdigit);
 	ioctl(p->fd, PHONE_PLAY_TONE, outdigit);
-	p->lastformat = -1;
+	p->lastformat = all_codecs;
 	return 0;
 }
 
@@ -370,8 +372,8 @@
 		ioctl(p->fd, PHONE_BUSY);
 		p->cpt = 1;
 	}
-	p->lastformat = -1;
-	p->lastinput = -1;
+	p->lastformat = all_codecs;
+	p->lastinput = all_codecs;
 	p->ministate = 0;
 	p->obuflen = 0;
 	p->dialtone = 0;
@@ -391,38 +393,38 @@
 	p = ast->tech_pvt;
 	ioctl(p->fd, PHONE_CPT_STOP);
 	/* Nothing to answering really, just start recording */
-	if (ast->rawreadformat == AST_FORMAT_G729A) {
+	if (ast->rawreadformat.audio[0] == AST_FORMAT_G729A) {
 		/* Prefer g729 */
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (p->lastinput != AST_FORMAT_G729A) {
-			p->lastinput = AST_FORMAT_G729A;
+		if (p->lastinput.audio[0] != AST_FORMAT_G729A) {
+			p->lastinput.audio[0] = AST_FORMAT_G729A;
 			if (ioctl(p->fd, PHONE_REC_CODEC, G729)) {
 				ast_log(LOG_WARNING, "Failed to set codec to g729\n");
 				return -1;
 			}
 		}
-        } else if (ast->rawreadformat == AST_FORMAT_G723_1) {
+	} else if (ast->rawreadformat.audio[0] == AST_FORMAT_G723_1) {
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (p->lastinput != AST_FORMAT_G723_1) {
-			p->lastinput = AST_FORMAT_G723_1;
+		if (p->lastinput.audio[0] != AST_FORMAT_G723_1) {
+			p->lastinput.audio[0] = AST_FORMAT_G723_1;
 			if (ioctl(p->fd, PHONE_REC_CODEC, G723_63)) {
 				ast_log(LOG_WARNING, "Failed to set codec to g723.1\n");
 				return -1;
 			}
 		}
-	} else if (ast->rawreadformat == AST_FORMAT_SLINEAR) {
+	} else if (ast->rawreadformat.audio[0] == AST_FORMAT_SLINEAR) {
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (p->lastinput != AST_FORMAT_SLINEAR) {
-			p->lastinput = AST_FORMAT_SLINEAR;
+		if (p->lastinput.audio[0] != AST_FORMAT_SLINEAR) {
+			p->lastinput.audio[0] = AST_FORMAT_SLINEAR;
 			if (ioctl(p->fd, PHONE_REC_CODEC, LINEAR16)) {
 				ast_log(LOG_WARNING, "Failed to set codec to signed linear 16\n");
 				return -1;
 			}
 		}
-	} else if (ast->rawreadformat == AST_FORMAT_ULAW) {
+	} else if (ast->rawreadformat.audio[0] == AST_FORMAT_ULAW) {
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (p->lastinput != AST_FORMAT_ULAW) {
-			p->lastinput = AST_FORMAT_ULAW;
+		if (p->lastinput.audio[0] != AST_FORMAT_ULAW) {
+			p->lastinput.audio[0] = AST_FORMAT_ULAW;
 			if (ioctl(p->fd, PHONE_REC_CODEC, ULAW)) {
 				ast_log(LOG_WARNING, "Failed to set codec to uLaw\n");
 				return -1;
@@ -430,11 +432,13 @@
 		}
 	} else if (p->mode == MODE_FXS) {
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (p->lastinput != ast->rawreadformat) {
+		if (memcmp(&p->lastinput, &ast->rawreadformat, sizeof(ast->rawreadformat)) != 0) {
 			p->lastinput = ast->rawreadformat;
-			if (ioctl(p->fd, PHONE_REC_CODEC, ast->rawreadformat)) {
-				ast_log(LOG_WARNING, "Failed to set codec to %d\n", 
-					ast->rawreadformat);
+			if (ioctl(p->fd, PHONE_REC_CODEC, ast->rawreadformat.audio[0])) {
+				struct ast_str *str = NULL;
+				ast_log(LOG_WARNING, "Failed to set codec to %s\n", 
+					ast_codec2bitstring(ast->rawreadformat, &str));
+				ast_free(str);
 				return -1;
 			}
 		}
@@ -590,14 +594,14 @@
 	}
 	p->fr.samples = 240;
 	p->fr.datalen = res;
-	p->fr.frametype = p->lastinput <= AST_FORMAT_AUDIO_MASK ?
+	p->fr.frametype = ast_extended_codec_isaudio(p->lastinput) ?
                           AST_FRAME_VOICE : 
-			  p->lastinput <= AST_FORMAT_PNG ? AST_FRAME_IMAGE 
+			  ast_extended_codec_isimage(p->lastinput) ? AST_FRAME_IMAGE 
 			  : AST_FRAME_VIDEO;
-	p->fr.subclass = p->lastinput;
+	p->fr.codec = p->lastinput;
 	p->fr.offset = AST_FRIENDLY_OFFSET;
 	/* Byteswap from little-endian to native-endian */
-	if (p->fr.subclass == AST_FORMAT_SLINEAR)
+	if (p->fr.codec.audio[0] == AST_FORMAT_SLINEAR)
 		ast_frame_byteswap_le(&p->fr);
 	return &p->fr;
 }
@@ -677,8 +681,8 @@
 		return 0;
 	}
 #endif	
-	if (frame->subclass == AST_FORMAT_G729A) {
-		if (p->lastformat != AST_FORMAT_G729A) {
+	if (frame->codec.audio[0] == AST_FORMAT_G729A) {
+		if (p->lastformat.audio[0] != AST_FORMAT_G729A) {
 			ioctl(p->fd, PHONE_PLAY_STOP);
 			ioctl(p->fd, PHONE_REC_STOP);

[... 346 lines stripped ...]



More information about the asterisk-commits mailing list