[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r302557 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 19 13:05:51 CST 2011


Author: dvossel
Date: Wed Jan 19 13:05:47 2011
New Revision: 302557

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=302557
Log:
conversion of chan_h323 to ast_format api

Modified:
    team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c
    team/dvossel/fixtheworld_phase1_step3/channels/h323/ast_h323.cxx
    team/dvossel/fixtheworld_phase1_step3/channels/h323/chan_h323.h

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c?view=diff&rev=302557&r1=302556&r2=302557
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c Wed Jan 19 13:05:47 2011
@@ -85,6 +85,8 @@
 #include "asterisk/stringfields.h"
 #include "asterisk/abstract_jb.h"
 #include "asterisk/astobj.h"
+#include "asterisk/format.h"
+#include "asterisk/format_cap.h"
 
 #ifdef __cplusplus
 }
@@ -129,7 +131,13 @@
 static char default_context[AST_MAX_CONTEXT] = "default";
 static struct sockaddr_in bindaddr;
 
-#define GLOBAL_CAPABILITY (AST_FORMAT_G723_1 | AST_FORMAT_GSM | AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_G729A | AST_FORMAT_G726_AAL2 | AST_FORMAT_H261)
+#define GLOBAL_CAPABILITY (ast_format_id_to_old_bitfield(AST_FORMAT_G723_1) | \
+	ast_format_id_to_old_bitfield(AST_FORMAT_GSM) | \
+	ast_format_id_to_old_bitfield(AST_FORMAT_ULAW) | \
+	ast_format_id_to_old_bitfield(AST_FORMAT_ALAW) | \
+	ast_format_id_to_old_bitfield(AST_FORMAT_G729A) | \
+	ast_format_id_to_old_bitfield(AST_FORMAT_G726_AAL2) | \
+	ast_format_id_to_old_bitfield(AST_FORMAT_H261)) \
 
 /** H.323 configuration values */
 static int h323_signalling_port = 1720;
@@ -173,9 +181,9 @@
 	int newcontrol;				/*!< Pending control to send */
 	int newdigit;				/*!< Pending DTMF digit to send */
 	int newduration;			/*!< Pending DTMF digit duration to send */
-	format_t pref_codec;				/*!< Preferred codec */
-	format_t peercapability;			/*!< Capabilities learned from peer */
-	format_t jointcapability;			/*!< Common capabilities for local and remote side */
+	h323_format pref_codec;				/*!< Preferred codec */
+	h323_format peercapability;			/*!< Capabilities learned from peer */
+	h323_format jointcapability;			/*!< Common capabilities for local and remote side */
 	struct ast_codec_pref peer_prefs;	/*!< Preferenced list of codecs which remote side supports */
 	int dtmf_pt[2];				/*!< Payload code used for RFC2833/CISCO messages */
 	int curDTMF;				/*!< DTMF tone being generated to Asterisk side */
@@ -231,7 +239,7 @@
 static void delete_aliases(void);
 static void prune_peers(void);
 
-static struct ast_channel *oh323_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *oh323_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause);
 static int oh323_digit_begin(struct ast_channel *c, char digit);
 static int oh323_digit_end(struct ast_channel *c, char digit, unsigned int duration);
 static int oh323_call(struct ast_channel *c, char *dest, int timeout);
@@ -242,10 +250,9 @@
 static int oh323_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen);
 static int oh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 
-static const struct ast_channel_tech oh323_tech = {
+static struct ast_channel_tech oh323_tech = {
 	.type = "H323",
 	.description = tdesc,
-	.capabilities = AST_FORMAT_AUDIO_MASK,
 	.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
 	.requester = oh323_request,
 	.send_digit_begin = oh323_digit_begin,
@@ -331,12 +338,13 @@
 /*! \brief Channel and private structures should be already locked */
 static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
 {
-	if (c->nativeformats != pvt->nativeformats) {
+	h323_format chan_nativeformats_bits = ast_format_cap_to_old_bitfield(c->nativeformats);
+	if (chan_nativeformats_bits != pvt->nativeformats) {
 		if (h323debug)
 			ast_debug(1, "Preparing %s for new native format\n", c->name);
-		c->nativeformats = pvt->nativeformats;
-		ast_set_read_format(c, c->readformat);
-		ast_set_write_format(c, c->writeformat);
+		ast_format_cap_from_old_bitfield(c->nativeformats, pvt->nativeformats);
+		ast_set_read_format(c, &c->readformat);
+		ast_set_write_format(c, &c->writeformat);
 	}
 	if (pvt->needhangup) {
 		if (h323debug)
@@ -764,18 +772,21 @@
 	if (pvt->owner) {
 		/* We already hold the channel lock */
 		if (f->frametype == AST_FRAME_VOICE) {
-			if (f->subclass.codec != pvt->owner->nativeformats) {
+			if (!ast_format_cap_iscompatible(pvt->owner->nativeformats, &f->subclass.format)) {
 				/* Try to avoid deadlock */
 				if (ast_channel_trylock(pvt->owner)) {
 					ast_log(LOG_NOTICE, "Format changed but channel is locked. Ignoring frame...\n");
 					return &ast_null_frame;
 				}
 				if (h323debug)
-					ast_debug(1, "Oooh, format changed to '%s'\n", ast_getformatname(f->subclass.codec));
-				pvt->owner->nativeformats = f->subclass.codec;
-				pvt->nativeformats = f->subclass.codec;
-				ast_set_read_format(pvt->owner, pvt->owner->readformat);
-				ast_set_write_format(pvt->owner, pvt->owner->writeformat);
+					ast_debug(1, "Oooh, format changed to '%s'\n", ast_getformatname(&f->subclass.format));
+				ast_format_cap_remove_all(pvt->owner->nativeformats);
+				ast_format_cap_add(pvt->owner->nativeformats, &f->subclass.format);
+
+				pvt->nativeformats = ast_format_to_old_bitfield(&f->subclass.format);
+
+				ast_set_read_format(pvt->owner, &pvt->owner->readformat);
+				ast_set_write_format(pvt->owner, &pvt->owner->writeformat);
 				ast_channel_unlock(pvt->owner);
 			}
 			/* Do in-band DTMF detection */
@@ -788,7 +799,7 @@
 					else
 						ast_log(LOG_NOTICE, "Unable to process inband DTMF while channel is locked\n");
 				} else if (pvt->nativeformats && !pvt->noInbandDtmf) {
-					ast_log(LOG_NOTICE, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(f->subclass.codec));
+					ast_log(LOG_NOTICE, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(&f->subclass.format));
 					pvt->noInbandDtmf = 1;
 				}
 				if (f &&(f->frametype == AST_FRAME_DTMF)) {
@@ -838,10 +849,10 @@
 			return 0;
 		}
 	} else {
-		if (!(frame->subclass.codec & c->nativeformats)) {
+		if (!(ast_format_cap_iscompatible(c->nativeformats, &frame->subclass.format))) {
 			char tmp[256];
 			ast_log(LOG_WARNING, "Asked to transmit frame type '%s', while native formats is '%s' (read/write = %s/%s)\n",
-				ast_getformatname(frame->subclass.codec), ast_getformatname_multiple(tmp, sizeof(tmp), c->nativeformats), ast_getformatname(c->readformat), ast_getformatname(c->writeformat));
+				ast_getformatname(&frame->subclass.format), ast_getformatname_multiple(tmp, sizeof(tmp), c->nativeformats), ast_getformatname(&c->readformat), ast_getformatname(&c->writeformat));
 			return 0;
 		}
 	}
@@ -1011,7 +1022,8 @@
 {
 	struct ast_channel *ch;
 	char *cid_num, *cid_name;
-	int fmt;
+	h323_format fmt;
+	struct ast_format tmpfmt;
 
 	if (!ast_strlen_zero(pvt->options.cid_num))
 		cid_num = pvt->options.cid_num;
@@ -1033,13 +1045,19 @@
 		ch->tech = &oh323_tech;
 		if (!(fmt = pvt->jointcapability) && !(fmt = pvt->options.capability))
 			fmt = global_options.capability;
-		ch->nativeformats = ast_codec_choose(&pvt->options.prefs, fmt, 1)/* | (pvt->jointcapability & AST_FORMAT_VIDEO_MASK)*/;
-		pvt->nativeformats = ch->nativeformats;
-		fmt = ast_best_codec(ch->nativeformats);
-		ch->writeformat = fmt;
-		ch->rawwriteformat = fmt;
-		ch->readformat = fmt;
-		ch->rawreadformat = fmt;
+
+		ast_format_cap_from_old_bitfield(ch->nativeformats, fmt);
+		ast_codec_choose(&pvt->options.prefs, ch->nativeformats, 1, &tmpfmt)/* | (pvt->jointcapability & AST_FORMAT_VIDEO_MASK)*/;
+
+		ast_format_cap_remove_all(ch->nativeformats);
+		ast_format_cap_add(ch->nativeformats, &tmpfmt);
+
+		pvt->nativeformats = ast_format_cap_to_old_bitfield(ch->nativeformats);
+		ast_best_codec(ch->nativeformats, &tmpfmt);
+		ast_format_copy(&ch->writeformat, &tmpfmt);
+		ast_format_copy(&ch->rawwriteformat, &tmpfmt);
+		ast_format_copy(&ch->readformat, &tmpfmt);
+		ast_format_copy(&ch->rawreadformat, &tmpfmt);
 		if (!pvt->rtp)
 			__oh323_rtp_create(pvt);
 #if 0
@@ -1264,17 +1282,33 @@
 	return a;
 }
 
+static int h323_parse_allow_disallow(struct ast_codec_pref *pref, h323_format *formats, const char *list, int allowing)
+{
+	int res;
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+	if (!cap) {
+		return 1;
+	}
+
+	ast_format_cap_from_old_bitfield(cap, *formats);
+	res = ast_parse_allow_disallow(pref, cap, list, allowing);
+	*formats = ast_format_cap_to_old_bitfield(cap);
+	cap = ast_format_cap_destroy(cap);
+	return res;
+
+}
+
 static int update_common_options(struct ast_variable *v, struct call_options *options)
 {
 	int tmp = 0;
 	char *val, *opt;
 
 	if (!strcasecmp(v->name, "allow")) {
-		ast_parse_allow_disallow(&options->prefs, &options->capability, v->value, 1);
+		h323_parse_allow_disallow(&options->prefs, &options->capability, v->value, 1);
 	} else if (!strcasecmp(v->name, "autoframing")) {
 		options->autoframing = ast_true(v->value);
 	} else if (!strcasecmp(v->name, "disallow")) {
-		ast_parse_allow_disallow(&options->prefs, &options->capability, v->value, 0);
+		h323_parse_allow_disallow(&options->prefs, &options->capability, v->value, 0);
 	} else if (!strcasecmp(v->name, "dtmfmode")) {
 		val = ast_strdupa(v->value);
 		if ((opt = strchr(val, ':')) != (char *)NULL) {
@@ -1745,9 +1779,8 @@
 		return 0;
 	}
 }
-static struct ast_channel *oh323_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
-{
-	format_t oldformat;
+static struct ast_channel *oh323_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause)
+{
 	struct oh323_pvt *pvt;
 	struct ast_channel *tmpc = NULL;
 	char *dest = (char *)data;
@@ -1756,17 +1789,15 @@
 	char tmp[256], tmp1[256];
 
 	if (h323debug)
-		ast_debug(1, "type=%s, format=%s, data=%s.\n", type, ast_getformatname_multiple(tmp, sizeof(tmp), format), (char *)data);
+		ast_debug(1, "type=%s, format=%s, data=%s.\n", type, ast_getformatname_multiple(tmp, sizeof(tmp), cap), (char *)data);
 
 	pvt = oh323_alloc(0);
 	if (!pvt) {
 		ast_log(LOG_WARNING, "Unable to build pvt data for '%s'\n", (char *)data);
 		return NULL;
 	}
-	oldformat = format;
-	format &= AST_FORMAT_AUDIO_MASK;
-	if (!format) {
-		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), format));
+	if (!(ast_format_cap_has_type(cap, AST_FORMAT_TYPE_AUDIO))) {
+		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), cap));
 		oh323_destroy(pvt);
 		if (cause)
 			*cause = AST_CAUSE_INCOMPATIBLE_DESTINATION;
@@ -2020,11 +2051,11 @@
 	nativeformats_changed = 0;
 	if (pt != 128 && pvt->rtp) {	/* Payload type is invalid, so try to use previously decided */
 		struct ast_rtp_payload_type rtptype = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(pvt->rtp), pt);
-		if (h323debug)
-			ast_debug(1, "Native format is set to %llu from %d by RTP payload type %d\n", (unsigned long long) rtptype.code, pvt->nativeformats, pt);
-		if (pvt->nativeformats != rtptype.code) {
-			pvt->nativeformats = rtptype.code;
-			nativeformats_changed = 1;
+		if (rtptype.asterisk_format) {
+			if (pvt->nativeformats != ast_format_to_old_bitfield(&rtptype.format)) {
+				pvt->nativeformats = ast_format_to_old_bitfield(&rtptype.format);
+				nativeformats_changed = 1;
+			}
 		}
 	} else if (h323debug)
 		ast_log(LOG_NOTICE, "Payload type is unknown, formats isn't changed\n");
@@ -2032,15 +2063,18 @@
 	/* Don't try to lock the channel if nothing changed */
 	if (nativeformats_changed || pvt->options.progress_audio || (rtp_change != NEED_NONE)) {
 		if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
+			struct ast_format_cap *pvt_native = ast_format_cap_alloc_nolock();
+			ast_format_cap_from_old_bitfield(pvt_native, pvt->nativeformats);
+
 			/* Re-build translation path only if native format(s) has been changed */
-			if (pvt->owner->nativeformats != pvt->nativeformats) {
+			if (!(ast_format_cap_identical(pvt->owner->nativeformats, pvt_native))) {
 				if (h323debug) {
 					char tmp[256], tmp2[256];
-					ast_debug(1, "Native format changed to '%s' from '%s', read format is %s, write format is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), pvt->nativeformats), ast_getformatname_multiple(tmp2, sizeof(tmp2), pvt->owner->nativeformats), ast_getformatname(pvt->owner->readformat), ast_getformatname(pvt->owner->writeformat));
+					ast_debug(1, "Native format changed to '%s' from '%s', read format is %s, write format is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), pvt_native), ast_getformatname_multiple(tmp2, sizeof(tmp2), pvt->owner->nativeformats), ast_getformatname(&pvt->owner->readformat), ast_getformatname(&pvt->owner->writeformat));
 				}
-				pvt->owner->nativeformats = pvt->nativeformats;
-				ast_set_read_format(pvt->owner, pvt->owner->readformat);
-				ast_set_write_format(pvt->owner, pvt->owner->writeformat);
+				ast_format_cap_copy2(pvt->owner->nativeformats, pvt_native);
+				ast_set_read_format(pvt->owner, &pvt->owner->readformat);
+				ast_set_write_format(pvt->owner, &pvt->owner->writeformat);
 			}
 			if (pvt->options.progress_audio)
 				ast_queue_control(pvt->owner, AST_CONTROL_PROGRESS);
@@ -2055,6 +2089,7 @@
 				break;
 			}
 			ast_channel_unlock(pvt->owner);
+			pvt_native = ast_format_cap_destroy(pvt_native);
 		}
 		else {
 			if (pvt->options.progress_audio)
@@ -2491,7 +2526,7 @@
 			for (i = 0; i < 32; ++i) {
 				if (!prefs->order[i])
 					break;
-				ast_debug(1, "prefs[%d]=%s:%d\n", i, (prefs->order[i] ? ast_getformatname(1 << (prefs->order[i]-1)) : "<none>"), prefs->framing[i]);
+				ast_debug(1, "prefs[%d]=%s:%d\n", i, (prefs->order[i] ? ast_getformatname(&prefs->formats[i]) : "<none>"), prefs->framing[i]);
 			}
 		}
 		if (pvt->rtp) {
@@ -2531,7 +2566,7 @@
 		for (i = 0; i < 32; i++) {
 			if (!prefs.order[i])
 				break;
-			ast_debug(1, "local prefs[%d]=%s:%d\n", i, (prefs.order[i] ? ast_getformatname(1 << (prefs.order[i]-1)) : "<none>"), prefs.framing[i]);
+			ast_debug(1, "local prefs[%d]=%s:%d\n", i, (prefs.order[i] ? ast_getformatname(&prefs.formats[i]) : "<none>"), prefs.framing[i]);
 		}
 		ast_debug(1, "Capabilities for connection %s is set\n", token);
 	}
@@ -3191,9 +3226,9 @@
 	return res;
 }
 
-static char *convertcap(format_t cap)
-{
-	switch (cap) {
+static char *convertcap(struct ast_format *format)
+{
+	switch (format->id) {
 	case AST_FORMAT_G723_1:
 		return "G.723";
 	case AST_FORMAT_GSM:
@@ -3213,12 +3248,12 @@
 	case AST_FORMAT_ILBC:
 		return "ILBC";
 	default:
-		ast_log(LOG_NOTICE, "Don't know how to deal with mode %" PRId64 "\n", cap);
+		ast_log(LOG_NOTICE, "Don't know how to deal with mode %s\n", ast_getformatname(format));
 		return NULL;
 	}
 }
 
-static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active)
+static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *codecs, int nat_active)
 {
 	/* XXX Deal with Video */
 	struct oh323_pvt *pvt;
@@ -3230,7 +3265,7 @@
 		return 0;
 	}
 
-	mode = convertcap(chan->writeformat);
+	mode = convertcap(&chan->writeformat);
 	pvt = (struct oh323_pvt *) chan->tech_pvt;
 	if (!pvt) {
 		ast_log(LOG_ERROR, "No Private Structure, this is bad\n");
@@ -3259,6 +3294,11 @@
 static enum ast_module_load_result load_module(void)
 {
 	int res;
+
+	if (!(oh323_tech.capabilities = ast_format_cap_alloc())) {
+		return AST_MODULE_LOAD_FAILURE;
+	}
+	ast_format_cap_add_all_by_type(oh323_tech.capabilities, AST_FORMAT_TYPE_AUDIO);
 
 	h323debug = 0;
 	sched = ast_sched_context_create();
@@ -3430,6 +3470,7 @@
 	ASTOBJ_CONTAINER_DESTROYALL(&aliasl, oh323_destroy_alias);
 	ASTOBJ_CONTAINER_DESTROY(&aliasl);
 
+	oh323_tech.capabilities = ast_format_cap_destroy(oh323_tech.capabilities);
 	return 0;
 }
 

Modified: team/dvossel/fixtheworld_phase1_step3/channels/h323/ast_h323.cxx
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/h323/ast_h323.cxx?view=diff&rev=302557&r1=302556&r2=302557
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/h323/ast_h323.cxx (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/h323/ast_h323.cxx Wed Jan 19 13:05:47 2011
@@ -1770,20 +1770,21 @@
 				if ((subType == codecs[x].h245_cap) && (!codecs[x].formatName || (!strcmp(codecs[x].formatName, (const char *)remoteCapabilities[i].GetFormatName())))) {
 					int ast_codec = codecs[x].asterisk_codec;
 					int ms = 0;
-					if (!(peer_capabilities & ast_codec)) {
+					struct ast_format tmpfmt;
+					if (!(peer_capabilities & ast_format_id_to_old_bitfield((enum ast_format_id) ast_codec))) {
 						struct ast_format_list format;
-						ast_codec_pref_append(&prefs, ast_codec);
-						format = ast_codec_pref_getsize(&prefs, ast_codec);
+						ast_codec_pref_append(&prefs, ast_format_set(&tmpfmt, (enum ast_format_id) ast_codec, 0));
+						format = ast_codec_pref_getsize(&prefs, &tmpfmt);
 						if ((ast_codec == AST_FORMAT_ALAW) || (ast_codec == AST_FORMAT_ULAW)) {
 							ms = remoteCapabilities[i].GetTxFramesInPacket();
 						} else
 							ms = remoteCapabilities[i].GetTxFramesInPacket() * format.inc_ms;
-						ast_codec_pref_setsize(&prefs, ast_codec, ms);
+						ast_codec_pref_setsize(&prefs, &tmpfmt, ms);
 					}
 					if (h323debug) {
 						cout << "Found peer capability " << remoteCapabilities[i] << ", Asterisk code is " << ast_codec << ", frame size (in ms) is " << ms << endl;
 					}
-					peer_capabilities |= ast_codec;
+					peer_capabilities |= ast_format_id_to_old_bitfield((enum ast_format_id) ast_codec);
 				}
 			}
 			break;
@@ -1846,12 +1847,7 @@
 			break;
 		}
 	}
-	if (h323debug) {
-		char caps_str[1024], caps2_str[1024];
-		ast_codec_pref_string(&prefs, caps2_str, sizeof(caps2_str));
-		cout << "Peer capabilities = " << ast_getformatname_multiple(caps_str, sizeof(caps_str), peer_capabilities)
-				<< ", ordered list is " << caps2_str << endl;
-	}
+
 #if 0
 	redir_capabilities &= peer_capabilities;
 #endif
@@ -1897,38 +1893,37 @@
 	int alreadysent = 0;
 	int codec;
 	int x, y;
-	char caps_str[1024];
 	struct ast_codec_pref *prefs = (struct ast_codec_pref *)_prefs;
 	struct ast_format_list format;
 	int frames_per_packet;
+	struct ast_format tmpfmt;
 	H323Capability *cap;
 
 	localCapabilities.RemoveAll();
 
-	if (h323debug) {
-		cout << "Setting capabilities to " << ast_getformatname_multiple(caps_str, sizeof(caps_str), caps) << endl;
-		ast_codec_pref_string(prefs, caps_str, sizeof(caps_str));
-		cout << "Capabilities in preference order is " << caps_str << endl;
-	}
 	/* Add audio codecs in preference order first, then
 	   audio codecs without preference as allowed by mask */
 	for (y = 0, x = -1; x < 32 + 32; ++x) {
+		ast_format_clear(&tmpfmt);
 		if (x < 0)
 			codec = pref_codec;
-		else if (y || (!(codec = ast_codec_pref_index(prefs, x)))) {
+		else if (y || (!(ast_codec_pref_index(prefs, x, &tmpfmt)))) {
 			if (!y)
 				y = 1;
 			else
 				y <<= 1;
 			codec = y;
 		}
-		if (!(caps & codec) || (alreadysent & codec) || !(codec & AST_FORMAT_AUDIO_MASK))
+		if (tmpfmt.id) {
+			codec = ast_format_to_old_bitfield(&tmpfmt);
+		}
+		if (!(caps & codec) || (alreadysent & codec) || (AST_FORMAT_GET_TYPE(ast_format_id_from_old_bitfield(codec)) != AST_FORMAT_TYPE_AUDIO))
 			continue;
 		alreadysent |= codec;
 		/* format.cur_ms will be set to default if packetization is not explicitly set */
-		format = ast_codec_pref_getsize(prefs, codec);
+		format = ast_codec_pref_getsize(prefs, ast_format_from_old_bitfield(&tmpfmt, codec));
 		frames_per_packet = (format.inc_ms ? format.cur_ms / format.inc_ms : format.cur_ms);
-		switch(codec) {
+		switch(ast_format_id_from_old_bitfield(codec)) {
 #if 0
 		case AST_FORMAT_SPEEX:
 			/* Not real sure if Asterisk acutally supports all

Modified: team/dvossel/fixtheworld_phase1_step3/channels/h323/chan_h323.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/h323/chan_h323.h?view=diff&rev=302557&r1=302556&r2=302557
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/h323/chan_h323.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/h323/chan_h323.h Wed Jan 19 13:05:47 2011
@@ -30,7 +30,7 @@
 #define CHAN_H323_H
 
 #include <arpa/inet.h>
-#include "asterisk/frame_defs.h"
+#include "asterisk/format.h"
 
 /*
  * Enable support for sending/reception of tunnelled Q.SIG messages and
@@ -46,6 +46,8 @@
 #define H323_HOLD_NOTIFY	(1 << 0)
 #define H323_HOLD_Q931ONLY	(1 << 1)
 #define H323_HOLD_H450		(1 << 2)
+
+typedef int64_t h323_format;
 
 /** call_option struct holds various bits
  *         of information for each call */
@@ -65,7 +67,7 @@
 	int				progress_audio;
 	int				dtmfcodec[2];
 	int				dtmfmode;
-	format_t        capability;
+	h323_format     capability;
 	int				bridge;
 	int				nat;
 	int				tunnelOptions;




More information about the asterisk-commits mailing list