[asterisk-commits] file: branch group/media_formats-reviewed r413477 - in /team/group/media_form...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 7 17:20:40 CDT 2014


Author: file
Date: Wed May  7 17:20:29 2014
New Revision: 413477

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413477
Log:
Move chan_mobile, chan_ooh323, format_mp3, app_jack, chan_console, chan_multicast_rtp, and chan_phone over.

Review: https://reviewboard.asterisk.org/r/3410/

Modified:
    team/group/media_formats-reviewed/addons/chan_mobile.c
    team/group/media_formats-reviewed/addons/chan_ooh323.c
    team/group/media_formats-reviewed/addons/chan_ooh323.h
    team/group/media_formats-reviewed/addons/format_mp3.c
    team/group/media_formats-reviewed/addons/ooh323cDriver.c
    team/group/media_formats-reviewed/addons/ooh323cDriver.h
    team/group/media_formats-reviewed/apps/app_jack.c
    team/group/media_formats-reviewed/channels/chan_console.c
    team/group/media_formats-reviewed/channels/chan_multicast_rtp.c
    team/group/media_formats-reviewed/channels/chan_phone.c
    team/group/media_formats-reviewed/include/asterisk/format_cache.h

Modified: team/group/media_formats-reviewed/addons/chan_mobile.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/addons/chan_mobile.c?view=diff&rev=413477&r1=413476&r2=413477
==============================================================================
--- team/group/media_formats-reviewed/addons/chan_mobile.c (original)
+++ team/group/media_formats-reviewed/addons/chan_mobile.c Wed May  7 17:20:29 2014
@@ -73,15 +73,15 @@
 #include "asterisk/app.h"
 #include "asterisk/manager.h"
 #include "asterisk/io.h"
+#include "asterisk/smoother.h"
+#include "asterisk/format_cache.h"
 
 #define MBL_CONFIG "chan_mobile.conf"
 #define MBL_CONFIG_OLD "mobile.conf"
 
 #define DEVICE_FRAME_SIZE 48
-#define DEVICE_FRAME_FORMAT AST_FORMAT_SLINEAR
+#define DEVICE_FRAME_FORMAT ast_format_slin
 #define CHANNEL_FRAME_SIZE 320
-
-static struct ast_format prefformat;
 
 static int discovery_interval = 60;			/* The device discovery interval, default 60 seconds. */
 static pthread_t discovery_thread = AST_PTHREADT_NULL;	/* The discovery thread */
@@ -840,7 +840,6 @@
 static struct ast_channel *mbl_new(int state, struct mbl_pvt *pvt, char *cid_num,
 		const struct ast_channel *requestor)
 {
-
 	struct ast_channel *chn;
 
 	pvt->answered = 0;
@@ -862,11 +861,11 @@
 	}
 
 	ast_channel_tech_set(chn, &mbl_tech);
-	ast_format_cap_add(ast_channel_nativeformats(chn), &prefformat);
-	ast_format_copy(ast_channel_rawreadformat(chn), &prefformat);
-	ast_format_copy(ast_channel_rawwriteformat(chn), &prefformat);
-	ast_format_copy(ast_channel_writeformat(chn), &prefformat);
-	ast_format_copy(ast_channel_readformat(chn), &prefformat);
+	ast_channel_nativeformats_set(chn, mbl_tech.capabilities);
+	ast_channel_set_rawreadformat(chn, DEVICE_FRAME_FORMAT);
+	ast_channel_set_rawwriteformat(chn, DEVICE_FRAME_FORMAT);
+	ast_channel_set_writeformat(chn, DEVICE_FRAME_FORMAT);
+	ast_channel_set_readformat(chn, DEVICE_FRAME_FORMAT);
 	ast_channel_tech_pvt_set(chn, pvt);
 
 	if (state == AST_STATE_RING)
@@ -902,7 +901,7 @@
 		return NULL;
 	}
 
-	if (!(ast_format_cap_iscompatible(cap, &prefformat))) {
+	if (!(ast_format_cap_iscompatible_format(cap, DEVICE_FRAME_FORMAT))) {
 		char tmp[256];
 		ast_log(LOG_WARNING, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), cap));
 		*cause = AST_CAUSE_FACILITY_NOT_IMPLEMENTED;
@@ -1116,7 +1115,7 @@
 
 	memset(&pvt->fr, 0x00, sizeof(struct ast_frame));
 	pvt->fr.frametype = AST_FRAME_VOICE;
-	ast_format_set(&pvt->fr.subclass.format, DEVICE_FRAME_FORMAT, 0);
+	pvt->fr.subclass.format = ast_format_copy(DEVICE_FRAME_FORMAT);
 	pvt->fr.src = "Mobile";
 	pvt->fr.offset = AST_FRIENDLY_OFFSET;
 	pvt->fr.mallocd = 0;
@@ -1131,6 +1130,7 @@
 			pvt->sco_socket = -1;
 			ast_channel_set_fd(ast, 0, -1);
 		}
+		ao2_ref(pvt->fr.subclass.format, -1);
 		goto e_return;
 	}
 
@@ -4697,7 +4697,8 @@
 	if (sdp_session)
 		sdp_close(sdp_session);
 
-	mbl_tech.capabilities = ast_format_cap_destroy(mbl_tech.capabilities);
+	ao2_ref(mbl_tech.capabilities, -1);
+	mbl_tech.capabilities = NULL;
 	return 0;
 }
 
@@ -4706,11 +4707,11 @@
 
 	int dev_id, s;
 
-	if (!(mbl_tech.capabilities = ast_format_cap_alloc(0))) {
+	if (!(mbl_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_set(&prefformat, DEVICE_FRAME_FORMAT, 0);
-	ast_format_cap_add(mbl_tech.capabilities, &prefformat);
+
+	ast_format_cap_add(mbl_tech.capabilities, DEVICE_FRAME_FORMAT, 0);
 	/* Check if we have Bluetooth, no point loading otherwise... */
 	dev_id = hci_get_route(NULL);
 	s = hci_open_dev(dev_id);

Modified: team/group/media_formats-reviewed/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/addons/chan_ooh323.c?view=diff&rev=413477&r1=413476&r2=413477
==============================================================================
--- team/group/media_formats-reviewed/addons/chan_ooh323.c (original)
+++ team/group/media_formats-reviewed/addons/chan_ooh323.c Wed May  7 17:20:29 2014
@@ -91,8 +91,6 @@
           struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *codecs, int nat_active);
 static void ooh323_get_codec(struct ast_channel *chan, struct ast_format_cap *result);
 void setup_rtp_remote(ooCallData *call, const char *remoteIp, int remotePort);
-
-static void print_codec_to_cli(int fd, struct ast_codec_pref *pref);
 
 struct ooh323_peer *find_friend(const char *name, int port);
 
@@ -174,10 +172,9 @@
 	char callee_url[AST_MAX_EXTENSION];
  
 	int port;
-	struct ast_format readformat;   /* negotiated read format */
-	struct ast_format writeformat;  /* negotiated write format */
+	struct ast_format *readformat;   /* negotiated read format */
+	struct ast_format *writeformat;  /* negotiated write format */
 	struct ast_format_cap *cap;
-	struct ast_codec_pref prefs;
 	int dtmfmode;
 	int dtmfcodec;
 	char exten[AST_MAX_EXTENSION];	/* Requested extension */
@@ -211,7 +208,6 @@
 	char		accountcode[20];
 	int		amaflags;
 	struct ast_format_cap *cap;
-	struct ast_codec_pref prefs;
 	int		dtmfmode;
 	int		dtmfcodec;
 	int		faxdetect;
@@ -237,7 +233,6 @@
 	unsigned    outgoinglimit;
 	unsigned    outUse;
 	struct ast_format_cap *cap;
-	struct ast_codec_pref prefs;
 	char        accountcode[20];
 	int         amaflags;
 	int         dtmfmode;
@@ -305,7 +300,6 @@
 static char gCallerID[AST_MAX_EXTENSION] = "";
 static struct ooAliases *gAliasList;
 static struct ast_format_cap *gCap;
-static struct ast_codec_pref gPrefs;
 static int  gDTMFMode = H323_DTMF_RFC2833;
 static int  gDTMFCodec = 101;
 static int  gFAXdetect = FAXDETECT_CNG;
@@ -362,15 +356,17 @@
 static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state,
                                              const char *host, struct ast_format_cap *cap, const char *linkedid)
 {
+	struct ast_format_cap *caps = NULL;
 	struct ast_channel *ch = NULL;
-	struct ast_format tmpfmt;
+	struct ast_format *tmpfmt = NULL;
 	int features = 0;
 
 	if (gH323Debug) {
 		ast_verb(0, "---   ooh323_new - %s\n", host);
 	}
 
-	ast_format_clear(&tmpfmt);
+	caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+
 	/* Don't hold a h323 pvt lock while we allocate a channel */
 	ast_mutex_unlock(&i->lock);
    	ast_mutex_lock(&ooh323c_cn_lock);
@@ -382,17 +378,23 @@
    
 	ast_mutex_lock(&i->lock);
 
-	if (ch) {
+	if (ch && caps) {
 		ast_channel_tech_set(ch, &ooh323_tech);
 
 		if (cap)
 			ast_best_codec(cap, &tmpfmt);
-		if (!tmpfmt.id)
-			ast_codec_pref_index(&i->prefs, 0, &tmpfmt);
-
-		ast_format_cap_add(ast_channel_nativeformats(ch), &tmpfmt);
-		ast_format_copy(ast_channel_rawwriteformat(ch), &tmpfmt);
-		ast_format_copy(ast_channel_rawreadformat(ch), &tmpfmt);
+		if (!tmpfmt)
+			tmpfmt = ast_format_cap_get_format(i->cap, 0);
+
+		ast_format_cap_add(caps, tmpfmt, 0);
+		ast_channel_nativeformats_set(ch, caps);
+		ao2_ref(caps, -1);
+
+		ast_channel_set_rawwriteformat(ch, tmpfmt);
+		ast_channel_set_rawreadformat(ch, tmpfmt);
+		ast_set_write_format(ch, tmpfmt);
+		ast_set_read_format(ch, tmpfmt);
+		ao2_ref(tmpfmt, -1);
 
 		ast_jb_configure(ch, &global_jbconf);
 
@@ -400,8 +402,6 @@
 			ast_channel_rings_set(ch, 1);
 
 		ast_channel_adsicpe_set(ch, AST_ADSI_UNAVAILABLE);
-		ast_set_write_format(ch, &tmpfmt);
-		ast_set_read_format(ch, &tmpfmt);
 		ast_channel_tech_pvt_set(ch, i);
 		i->owner = ch;
 		ast_module_ref(myself);
@@ -481,8 +481,10 @@
 			ast_publish_channel_state(ch);
 
 		}
-	} else
+	} else {
+		ao2_cleanup(caps);
 		ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
+	}
 
 
    	if(ch)   ast_channel_unlock(ch);
@@ -508,7 +510,7 @@
 		ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
 		return NULL;
 	}
-	if (!(pvt->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
+	if (!(pvt->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		ast_free(pvt);
 		ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
 		return NULL;
@@ -542,8 +544,7 @@
 	ast_copy_string(pvt->accountcode, gAccountcode, sizeof(pvt->accountcode));
 
 	pvt->amaflags = gAMAFLAGS;
-	ast_format_cap_copy(pvt->cap, gCap);
-	memcpy(&pvt->prefs, &gPrefs, sizeof(pvt->prefs));
+	ast_format_cap_append_by_type(pvt->cap, gCap, AST_MEDIA_TYPE_UNKNOWN);
 
 	ast_mutex_unlock(&pvt->lock); 
 	/* Add to interface list */
@@ -580,7 +581,7 @@
 		ast_verb(0, "---   ooh323_request - data %s format %s\n", data,
 										ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,cap));
 
-	if (!(ast_format_cap_has_type(cap, AST_FORMAT_TYPE_AUDIO))) {
+	if (!(ast_format_cap_has_type(cap, AST_MEDIA_TYPE_AUDIO))) {
 		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,cap));
 		return NULL;
 	}
@@ -645,8 +646,7 @@
 		if (ext)
 			ast_copy_string(p->exten, ext, sizeof(p->exten));
 
-		ast_format_cap_copy(p->cap, peer->cap);
-		memcpy(&p->prefs, &peer->prefs, sizeof(struct ast_codec_pref));
+		ast_format_cap_append_by_type(p->cap, peer->cap, AST_MEDIA_TYPE_UNKNOWN);
 		p->g729onlyA = peer->g729onlyA;
 		p->dtmfmode |= peer->dtmfmode;
 		p->dtmfcodec  = peer->dtmfcodec;
@@ -691,7 +691,7 @@
 		p->t38support = gT38Support;
 		p->rtptimeout = gRTPTimeout;
 		p->nat = gNat;
-		ast_format_cap_copy(p->cap, gCap);
+		ast_format_cap_append_by_type(p->cap, gCap, AST_MEDIA_TYPE_UNKNOWN);
 		p->rtdrinterval = gRTDRInterval;
 		p->rtdrcount = gRTDRCount;
 		p->faststart = gFastStart;
@@ -699,7 +699,6 @@
 		p->directrtp = gDirectRTP;
 		p->earlydirect = gEarlyDirect;
 
-		memcpy(&p->prefs, &gPrefs, sizeof(struct ast_codec_pref));
 		p->username = strdup(dest);
 
 		p->host = strdup(dest);
@@ -1186,16 +1185,16 @@
 			}
 
 
-			if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
-				if (!(ast_format_cap_is_empty(ast_channel_nativeformats(ast)))) {
+			if (!(ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), f->subclass.format))) {
+				if (ast_format_cap_count(ast_channel_nativeformats(ast))) {
 					ast_log(LOG_WARNING,
 							"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
-							ast_getformatname(&f->subclass.format),
+							ast_format_get_name(f->subclass.format),
 							ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
-							ast_getformatname(ast_channel_readformat(ast)),
-							ast_getformatname(ast_channel_writeformat(ast)));
-
-					ast_set_write_format(ast, &f->subclass.format);
+							ast_format_get_name(ast_channel_readformat(ast)),
+							ast_format_get_name(ast_channel_writeformat(ast)));
+
+					ast_set_write_format(ast, f->subclass.format);
 				} else {
 					/* ast_set_write_format(ast, f->subclass);
 					ast->nativeformats = f->subclass; */
@@ -1507,7 +1506,7 @@
 
 	if (gH323Debug)
 		ast_verb(0, "---   ooh323_update_writeformat %s/%d\n", 
-				ast_getformatname(fmt), txframes);
+				ast_format_get_name(fmt), txframes);
 	
 	p = find_call(call);
 	if (!p) {
@@ -1517,9 +1516,18 @@
 
 	ast_mutex_lock(&p->lock);
 
-	ast_format_copy(&(p->writeformat), fmt);
+	ao2_cleanup(p->writeformat);
+	p->writeformat = ast_format_copy(fmt);
 
 	if (p->owner) {
+		struct ast_format_cap *caps;
+
+		caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+		if (!caps) {
+			ast_log(LOG_ERROR, "Could not allocate capabilities structure\n");
+			return;
+		}
+
 		while (p->owner && ast_channel_trylock(p->owner)) {
 			ast_debug(1,"Failed to grab lock, trying again\n");
 			DEADLOCK_AVOIDANCE(&p->lock);
@@ -1527,15 +1535,19 @@
 		if (!p->owner) {
 			ast_mutex_unlock(&p->lock);
 			ast_log(LOG_ERROR, "Channel has no owner\n");
+			ao2_ref(caps, -1);
 			return;
 		}
 		if (gH323Debug)
 	  		ast_verb(0, "Writeformat before update %s/%s\n", 
-			  ast_getformatname(ast_channel_writeformat(p->owner)),
+			  ast_format_get_name(ast_channel_writeformat(p->owner)),
 			  ast_getformatname_multiple(formats, sizeof(formats), ast_channel_nativeformats(p->owner)));
+	  	/* BUGBUG: RTP - Needs to be updated if API changes */
+#if 0
 		if (txframes)
 			ast_codec_pref_setsize(&p->prefs, fmt, txframes);
 		ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs);
+#endif
 		if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) {
 			ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp),
 				 p->rtp, p->dtmfcodec, "audio", "telephone-event", 0);
@@ -1545,7 +1557,9 @@
 				 p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0);
 		}
 
-		ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
+		ast_format_cap_add(caps, fmt, 0);
+		ast_channel_nativeformats_set(p->owner, caps);
+		ao2_ref(caps, -1);
 	  	ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
 	  	ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
 		ast_channel_unlock(p->owner);
@@ -1565,7 +1579,7 @@
 
 	if (gH323Debug)
 		ast_verb(0, "---   ooh323_update_readformat %s\n", 
-				ast_getformatname(fmt));
+				ast_format_get_name(fmt));
 	
 	p = find_call(call);
 	if (!p) {
@@ -1575,9 +1589,18 @@
 
 	ast_mutex_lock(&p->lock);
 
-	ast_format_copy(&(p->readformat), fmt);
+	ao2_cleanup(p->readformat);
+	p->readformat = ast_format_copy(fmt);
 
 	if (p->owner) {
+		struct ast_format_cap *caps;
+
+		caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+		if (!caps) {
+			ast_log(LOG_ERROR, "Could not allocate capabilities structure\n");
+			return;
+		}
+
 		while (p->owner && ast_channel_trylock(p->owner)) {
 			ast_debug(1,"Failed to grab lock, trying again\n");
 			DEADLOCK_AVOIDANCE(&p->lock);
@@ -1585,13 +1608,16 @@
 		if (!p->owner) {
 			ast_mutex_unlock(&p->lock);
 			ast_log(LOG_ERROR, "Channel has no owner\n");
+			ao2_ref(caps, -1);
 			return;
 		}
 
 		if (gH323Debug)
 	  		ast_verb(0, "Readformat before update %s\n", 
-				  ast_getformatname(ast_channel_readformat(p->owner)));
-		ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
+				  ast_format_get_name(ast_channel_readformat(p->owner)));
+	  	ast_format_cap_add(caps, fmt, 0);
+	  	ast_channel_nativeformats_set(p->owner, caps);
+	  	ao2_ref(caps, -1);
 	  	ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
 		ast_channel_unlock(p->owner);
    	} else
@@ -1849,9 +1875,8 @@
 		ast_copy_string(p->context, user->context, sizeof(p->context));
 		ast_copy_string(p->accountcode, user->accountcode, sizeof(p->accountcode));
 		p->amaflags = user->amaflags;
-		ast_format_cap_copy(p->cap, user->cap);
+		ast_format_cap_append_by_type(p->cap, user->cap, AST_MEDIA_TYPE_UNKNOWN);
 		p->g729onlyA = user->g729onlyA;
-		memcpy(&p->prefs, &user->prefs, sizeof(struct ast_codec_pref));
 		p->dtmfmode |= user->dtmfmode;
 		p->dtmfcodec = user->dtmfcodec;
 		p->faxdetect = user->faxdetect;
@@ -1906,7 +1931,7 @@
 	 }
 	}
 
-	ooh323c_set_capability_for_call(call, &p->prefs, p->cap, p->dtmfmode, p->dtmfcodec,
+	ooh323c_set_capability_for_call(call, p->cap, p->dtmfmode, p->dtmfcodec,
 					 p->t38support, p->g729onlyA);
 /* Incoming call */
   	c = ooh323_new(p, AST_STATE_RING, p->username, 0, NULL);
@@ -2076,13 +2101,14 @@
 		}
 
 		if (gH323Debug) {
-			char prefsBuf[256];
-			ast_codec_pref_string(&p->prefs, prefsBuf, sizeof(prefsBuf));
+			char formats[FORMAT_STRING_SIZE];
+
 			ast_verb(0, " Outgoing call %s(%s) - Codec prefs - %s\n", 
-				p->username?p->username:"NULL", call->callToken, prefsBuf);
-		}
-
-      		ooh323c_set_capability_for_call(call, &p->prefs, p->cap,
+				p->username?p->username:"NULL", call->callToken,
+				ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,p->cap));
+		}
+
+      		ooh323c_set_capability_for_call(call, p->cap,
                                      p->dtmfmode, p->dtmfcodec, p->t38support, p->g729onlyA);
 
 		configure_local_rtp(p, call);
@@ -2268,7 +2294,7 @@
       if(peer->url)      free(peer->url);
       if(peer->e164)     free(peer->e164);
 
-		peer->cap = ast_format_cap_destroy(peer->cap);
+      ao2_cleanup(peer->cap);
 		free(peer);
 	}  
 
@@ -2295,8 +2321,7 @@
 		}
 		ast_mutex_init(&user->lock);
 		ast_copy_string(user->name, name, sizeof(user->name));
-		ast_format_cap_copy(user->cap, gCap);
-		memcpy(&user->prefs, &gPrefs, sizeof(user->prefs));
+		ast_format_cap_append_by_type(user->cap, gCap, AST_MEDIA_TYPE_UNKNOWN);
 		user->rtptimeout = gRTPTimeout;
 		user->nat = gNat;
 		user->dtmfmode = gDTMFMode;
@@ -2351,15 +2376,13 @@
 								sizeof(user->rtpmaskstr));
 				} else user->rtpmask = NULL;
 			} else if (!strcasecmp(v->name, "disallow")) {
-				ast_parse_allow_disallow(&user->prefs, 
-					user->cap,  v->value, 0);
+				ast_parse_allow_disallow(user->cap,  v->value, 0);
 			} else if (!strcasecmp(v->name, "allow")) {
 				const char* tcodecs = v->value;
 				if (!strcasecmp(v->value, "all")) {
 					tcodecs = "ulaw,alaw,g729,g723,gsm";
 				}
-				ast_parse_allow_disallow(&user->prefs,
-					 user->cap,  tcodecs, 1);
+				ast_parse_allow_disallow(user->cap,  tcodecs, 1);
 			} else if (!strcasecmp(v->name, "amaflags")) {
 				user->amaflags = ast_channel_string2amaflag(v->value);
          		} else if (!strcasecmp(v->name, "ip") || !strcasecmp(v->name, "host")) {
@@ -2443,8 +2466,7 @@
 		}
 		ast_mutex_init(&peer->lock);
 		ast_copy_string(peer->name, name, sizeof(peer->name));
-		ast_format_cap_copy(peer->cap, gCap);
-      		memcpy(&peer->prefs, &gPrefs, sizeof(peer->prefs));
+		ast_format_cap_append_by_type(peer->cap, gCap, AST_MEDIA_TYPE_UNKNOWN);
 		peer->rtptimeout = gRTPTimeout;
 		peer->nat = gNat;
 		ast_copy_string(peer->accountcode, gAccountcode, sizeof(peer->accountcode));
@@ -2547,15 +2569,13 @@
 								sizeof(peer->rtpmaskstr));
 				} else peer->rtpmask = NULL;
 			} else if (!strcasecmp(v->name, "disallow")) {
-				ast_parse_allow_disallow(&peer->prefs, peer->cap, 
-												 v->value, 0); 
+				ast_parse_allow_disallow(peer->cap, v->value, 0); 
 			} else if (!strcasecmp(v->name, "allow")) {
 				const char* tcodecs = v->value;
 				if (!strcasecmp(v->value, "all")) {
 					tcodecs = "ulaw,alaw,g729,g723,gsm";
 				}
-				ast_parse_allow_disallow(&peer->prefs, peer->cap, 
-												 tcodecs, 1);				 
+				ast_parse_allow_disallow(peer->cap, tcodecs, 1);				 
 			} else if (!strcasecmp(v->name,  "amaflags")) {
 				peer->amaflags = ast_channel_string2amaflag(v->value);
 			} else if (!strcasecmp(v->name, "roundtrip")) {
@@ -2736,7 +2756,6 @@
 	struct ooh323_peer *peer = NULL;
 	char *cat;
 	const char *utype;
-	struct ast_format tmpfmt;
 
 	if (gH323Debug)
 		ast_verb(0, "---   reload_config\n");
@@ -2772,8 +2791,8 @@
 	gPort = 1720;
 	gIP[0] = '\0';
 	strcpy(gCallerID, DEFAULT_H323ID);
-	ast_format_cap_set(gCap, ast_format_set(&tmpfmt, AST_FORMAT_ALAW, 0));
-	memset(&gPrefs, 0, sizeof(struct ast_codec_pref));
+	ast_format_cap_remove_bytype(gCap, AST_MEDIA_TYPE_UNKNOWN);
+	ast_format_cap_add(gCap, ast_format_ulaw, 0);
 	gDTMFMode = H323_DTMF_RFC2833;
 	gDTMFCodec = 101;
 	gFAXdetect = FAXDETECT_CNG;
@@ -2974,13 +2993,13 @@
 		} else if (!strcasecmp(v->name, "accountcode")) {
          ast_copy_string(gAccountcode, v->value, sizeof(gAccountcode));
 		} else if (!strcasecmp(v->name, "disallow")) {
-			ast_parse_allow_disallow(&gPrefs, gCap, v->value, 0);
+			ast_parse_allow_disallow(gCap, v->value, 0);
 		} else if (!strcasecmp(v->name, "allow")) {
 			const char* tcodecs = v->value;
 			if (!strcasecmp(v->value, "all")) {
 				tcodecs = "ulaw,alaw,g729,g723,gsm";
 			}
-			ast_parse_allow_disallow(&gPrefs, gCap, tcodecs, 1);
+			ast_parse_allow_disallow(gCap, tcodecs, 1);
 		} else if (!strcasecmp(v->name, "dtmfmode")) {
 			if (!strcasecmp(v->value, "inband"))
 				gDTMFMode = H323_DTMF_INBAND;
@@ -3130,9 +3149,6 @@
 					peer->h245tunneling?"yes":"no");
 		ast_cli(a->fd, "%-15s%s\n", "DirectRTP", peer->directrtp ? "yes" : "no");
 		ast_cli(a->fd, "%-15s%s\n", "EarlyDirectRTP", peer->earlydirect ? "yes" : "no");
-		ast_cli(a->fd, "%-15.15s%s", "Format Prefs: ", "(");
-		print_codec_to_cli(a->fd, &peer->prefs);
-		ast_cli(a->fd, ")\n");
 		ast_cli(a->fd, "%-15.15s", "DTMF Mode: ");
 		if (peer->dtmfmode & H323_DTMF_CISCO) {
 			ast_cli(a->fd, "%s\n", "cisco");
@@ -3233,24 +3249,6 @@
 	return CLI_SUCCESS;
 }
 
-/*! \brief Print codec list from preference to CLI/manager */
-static void print_codec_to_cli(int fd, struct ast_codec_pref *pref)
-{
-	int x;
-	struct ast_format tmpfmt;
-	for (x = 0; x < 32; x++) {
-		ast_codec_pref_index(pref, x, &tmpfmt);
-		if (!tmpfmt.id)
-			break;
-		ast_cli(fd, "%s", ast_getformatname(&tmpfmt));
-		ast_cli(fd, ":%d", pref->framing[x]);
-		if (x < 31 && ast_codec_pref_index(pref, x + 1, &tmpfmt))
-			ast_cli(fd, ",");
-	}
-	if (!x)
-		ast_cli(fd, "none");
-}
-
 static char *handle_cli_ooh323_show_user(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ooh323_user *prev = NULL, *user = NULL;
@@ -3289,9 +3287,6 @@
 					user->h245tunneling?"yes":"no");
 		ast_cli(a->fd, "%-15s%s\n", "DirectRTP", user->directrtp ? "yes" : "no");
 		ast_cli(a->fd, "%-15s%s\n", "EarlyDirectRTP", user->earlydirect ? "yes" : "no");
-		ast_cli(a->fd, "%-15.15s%s", "Format Prefs: ", "(");
-		print_codec_to_cli(a->fd, &user->prefs);
-		ast_cli(a->fd, ")\n");
 		ast_cli(a->fd, "%-15.15s", "DTMF Mode: ");
 		if (user->dtmfmode & H323_DTMF_CISCO) {
 			ast_cli(a->fd, "%s\n", "cisco");
@@ -3717,7 +3712,6 @@
 {
 	struct ooAliases * pNewAlias = NULL;
 	struct ooh323_peer *peer = NULL;
-	struct ast_format tmpfmt;
 	OOH225MsgCallbacks h225Callbacks = {0, 0, 0, 0};
 
 	OOH323CALLBACKS h323Callbacks = {
@@ -3733,14 +3727,16 @@
 		.onModeChanged = onModeChanged,
 		.onMediaChanged = (cb_OnMediaChanged) setup_rtp_remote,
 	};
-	if (!(gCap = ast_format_cap_alloc(0))) {
+	if (!(gCap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return 1; 
 	}
-	if (!(ooh323_tech.capabilities = ast_format_cap_alloc(0))) {
+	if (!(ooh323_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
+		ao2_ref(gCap, -1);
+		gCap = NULL;
 		return 1;
 	}
-	ast_format_cap_add(gCap, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
-	ast_format_cap_add_all(ooh323_tech.capabilities);
+	ast_format_cap_add(gCap, ast_format_ulaw, 0);
+	ast_format_cap_add_all_by_type(ooh323_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
 
 	myself = ast_module_info->self;
 
@@ -3767,6 +3763,10 @@
 		/* Make sure we can register our OOH323 channel type */
 		if (ast_channel_register(&ooh323_tech)) {
 			ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+			ao2_ref(gCap, -1);
+			gCap = NULL;
+			ao2_ref(ooh323_tech.capabilities, -1);
+			ooh323_tech.capabilities = NULL;
 			return 0;
 		}
 		ast_rtp_glue_register(&ooh323_rtp);
@@ -3776,6 +3776,10 @@
 		if (OO_OK != ooH323EpInitialize(OO_CALLMODE_AUDIOCALL, gLogFile)) {
          ast_log(LOG_ERROR, "Failed to initialize OOH323 endpoint-"
                             "OOH323 Disabled\n");
+			ao2_ref(gCap, -1);
+			gCap = NULL;
+			ao2_ref(ooh323_tech.capabilities, -1);
+			ooh323_tech.capabilities = NULL;
 			return 1;
 		}
 
@@ -3856,8 +3860,12 @@
 		ooH323EpSetH323Callbacks(h323Callbacks);
 
 		/* Add endpoint capabilities */
-		if (ooh323c_set_capability(&gPrefs, gCap, gDTMFMode, gDTMFCodec) < 0) {
+		if (ooh323c_set_capability(gCap, gDTMFMode, gDTMFCodec) < 0) {
 			ast_log(LOG_ERROR, "Capabilities failure for OOH323. OOH323 Disabled.\n");
+			ao2_ref(gCap, -1);
+			gCap = NULL;
+			ao2_ref(ooh323_tech.capabilities, -1);
+			ooh323_tech.capabilities = NULL;
 			return 1;
 		}
   
@@ -3867,6 +3875,10 @@
                             "OOH323 DISABLED\n");
 		
 			ooH323EpDestroy();
+			ao2_ref(gCap, -1);
+			gCap = NULL;
+			ao2_ref(ooh323_tech.capabilities, -1);
+			ooh323_tech.capabilities = NULL;
 			return 1;
 		}
 
@@ -3874,6 +3886,10 @@
 			ast_log(LOG_ERROR, "Failed to start OOH323 stack thread. "
                             "OOH323 DISABLED\n");
 			ooH323EpDestroy();
+			ao2_ref(gCap, -1);
+			gCap = NULL;
+			ao2_ref(ooh323_tech.capabilities, -1);
+			ooh323_tech.capabilities = NULL;
 			return 1;
 		}
 		/* And start the monitor for the first time */
@@ -4103,7 +4119,9 @@
 
 		ast_mutex_unlock(&cur->lock);
 		ast_mutex_destroy(&cur->lock);
-		cur->cap = ast_format_cap_destroy(cur->cap);
+		ao2_cleanup(cur->writeformat);
+		ao2_cleanup(cur->readformat);
+		ao2_cleanup(cur->cap);
 		ast_free(cur);
 	}
 
@@ -4168,7 +4186,7 @@
 	  			free(prev->rtpmask);
       			}
       		}
-		prev->cap = ast_format_cap_destroy(prev->cap);
+      	ao2_cleanup(prev->cap);
 		free(prev);
 		if (cur == userl.users) {
 			break;
@@ -4296,8 +4314,10 @@
 		ast_verb(0, "+++ ooh323  unload_module \n");
 	}
 
-	gCap = ast_format_cap_destroy(gCap);
-	ooh323_tech.capabilities = ast_format_cap_destroy(ooh323_tech.capabilities);
+	ao2_ref(gCap, -1);
+	gCap = NULL;
+	ao2_ref(ooh323_tech.capabilities, -1);
+	ooh323_tech.capabilities = NULL;
 	return 0;
 }
 
@@ -4309,8 +4329,11 @@
 	}
 
 	if (p) {
-		ast_format_cap_append(result,  ast_format_cap_is_empty(ast_channel_nativeformats(chan)) ?
-				(ast_format_cap_is_empty(p->cap) ? NULL : p->cap) : ast_channel_nativeformats(chan));
+		if (ast_format_cap_count(ast_channel_nativeformats(chan))) {
+			ast_format_cap_append_by_type(result, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_UNKNOWN);
+		} else if (ast_format_cap_count(p->cap)) {
+			ast_format_cap_append_by_type(result, p->cap, AST_MEDIA_TYPE_UNKNOWN);
+		}
 	}
 
 	if (gH323Debug) {
@@ -4384,56 +4407,28 @@
 	return res;
 }
 
-
-int ooh323_update_capPrefsOrderForCall
-	(ooCallData *call, struct ast_codec_pref *prefs)
-{
-	int i = 0;
-	struct ast_format tmpfmt;
-
-	ast_codec_pref_index(prefs, i, &tmpfmt);
-
-	ooResetCapPrefs(call);
-	while (tmpfmt.id) {
-		ooAppendCapToCapPrefs(call, ooh323_convertAsteriskCapToH323Cap(&tmpfmt));
-		ast_codec_pref_index(prefs, ++i, &tmpfmt);
-	}
-
-	return 0;
-}
-
-
 int ooh323_convertAsteriskCapToH323Cap(struct ast_format *format)
 {
-	switch (format->id) {
-	case AST_FORMAT_ULAW:
+	if (ast_format_cmp(format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
 		return OO_G711ULAW64K;
-	case AST_FORMAT_ALAW:
+	} else if (ast_format_cmp(format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
 		return OO_G711ALAW64K;
-	case AST_FORMAT_GSM:
+	} else if (ast_format_cmp(format, ast_format_gsm) == AST_FORMAT_CMP_EQUAL) {
 		return OO_GSMFULLRATE;
-
-#ifdef AST_FORMAT_AMRNB
-	case AST_FORMAT_AMRNB:
-		return OO_AMRNB;
-#endif
-#ifdef AST_FORMAT_SPEEX
-	case AST_FORMAT_SPEEX:
+	} else if (ast_format_cmp(format, ast_format_speex) == AST_FORMAT_CMP_EQUAL) {
 		return OO_SPEEX;
-#endif
-
-	case AST_FORMAT_G729A:
+	} else if (ast_format_cmp(format, ast_format_g729) == AST_FORMAT_CMP_EQUAL) {
 		return OO_G729A;
-	case AST_FORMAT_G726:
+	} else if (ast_format_cmp(format, ast_format_g726) == AST_FORMAT_CMP_EQUAL) {
 		return OO_G726;
-	case AST_FORMAT_G726_AAL2:
+	} else if (ast_format_cmp(format, ast_format_g726_aal2) == AST_FORMAT_CMP_EQUAL) {
 		return OO_G726AAL2;
-	case AST_FORMAT_G723_1:
+	} else if (ast_format_cmp(format, ast_format_g723) == AST_FORMAT_CMP_EQUAL) {
 		return OO_G7231;
-	case AST_FORMAT_H263:
+	} else if (ast_format_cmp(format, ast_format_h263) == AST_FORMAT_CMP_EQUAL) {
 		return OO_H263VIDEO;
-	default:
-		ast_log(LOG_NOTICE, "Don't know how to deal with mode %s\n", ast_getformatname(format));
+	} else {
+		ast_log(LOG_NOTICE, "Don't know how to deal with mode %s\n", ast_format_get_name(format));
 		return -1;
 	}
 }
@@ -4512,9 +4507,6 @@
 	struct ast_sockaddr tmp;
 	ooMediaInfo mediaInfo;
 	int x;
-	struct ast_format tmpfmt;
-
-	ast_format_clear(&tmpfmt);
 
 	if (gH323Debug)
 		ast_verb(0, "---   configure_local_rtp\n");
@@ -4560,7 +4552,10 @@
 	ast_channel_unlock(p->owner);
 
 	if (p->rtp) {
+	  	/* BUGBUG: RTP - Needs to be updated if API changes */
+#if 0
 		ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs);
+#endif
 		if (p->nat) {
 			ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_NAT, 1);
 		}
@@ -4597,9 +4592,11 @@
 	ast_copy_string(mediaInfo.lMediaIP, lhost, sizeof(mediaInfo.lMediaIP));
 	mediaInfo.lMediaPort = lport;
 	mediaInfo.lMediaCntrlPort = mediaInfo.lMediaPort + 1;
-	for (x = 0; ast_codec_pref_index(&p->prefs, x, &tmpfmt); x++) {
+	for (x = 0; x < ast_format_cap_count(p->cap); x++) {
+		struct ast_format *format = ast_format_cap_get_format(p->cap, x);
+
 		strcpy(mediaInfo.dir, "transmit");
-		mediaInfo.cap = ooh323_convertAsteriskCapToH323Cap(&tmpfmt);
+		mediaInfo.cap = ooh323_convertAsteriskCapToH323Cap(format);
 		ooAddMediaInfo(call, mediaInfo);
 		strcpy(mediaInfo.dir, "receive");
 		ooAddMediaInfo(call, mediaInfo);
@@ -4616,6 +4613,8 @@
 			strcpy(mediaInfo.dir, "receive");
 			ooAddMediaInfo(call, mediaInfo);
 		}
+
+		ao2_ref(format, -1);
 	}
 
 	if (p->udptl) {
@@ -4699,7 +4698,7 @@
 	ast_sockaddr_set_port(&tmp, remotePort);
 	ast_rtp_instance_set_remote_address(p->rtp, &tmp);
 
-	if (p->writeformat.id == AST_FORMAT_G726_AAL2) {
+	if (ast_format_cmp(p->writeformat, ast_format_g726_aal2) == AST_FORMAT_CMP_EQUAL) {
                 ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, 2,
 							"audio", "G726-32", AST_RTP_OPT_G726_NONSTANDARD);
 	}
@@ -4916,15 +4915,24 @@
 
 	if (f && p->owner && !p->faxmode && (f->frametype == AST_FRAME_VOICE)) {
 		/* We already hold the channel lock */
-		if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(p->owner), &f->subclass.format))) {
-			ast_debug(1, "Oooh, voice format changed to %s\n", ast_getformatname(&f->subclass.format));
-			ast_format_cap_set(ast_channel_nativeformats(p->owner), &f->subclass.format);
+		if (!(ast_format_cap_iscompatible_format(ast_channel_nativeformats(p->owner), f->subclass.format))) {
+			struct ast_format_cap *caps;
+
+			ast_debug(1, "Oooh, voice format changed to %s\n", ast_format_get_name(f->subclass.format));
+
+			caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+			if (caps) {
+				ast_format_cap_add(caps, f->subclass.format, 0);
+				ast_channel_nativeformats_set(p->owner, caps);
+				ao2_ref(caps, -1);
+			}
 			ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
 			ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
 		}
 		if (((p->dtmfmode & H323_DTMF_INBAND) || (p->faxdetect & FAXDETECT_CNG)) && p->vad &&
-		    (f->subclass.format.id == AST_FORMAT_SLINEAR || f->subclass.format.id == AST_FORMAT_ALAW ||
-		     f->subclass.format.id == AST_FORMAT_ULAW)) {
+			((ast_format_cmp(f->subclass.format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) ||
+			(ast_format_cmp(f->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) ||
+			(ast_format_cmp(f->subclass.format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL))) {
 			dfr = ast_frdup(f);
 			dfr = ast_dsp_process(p->owner, p->vad, dfr);
 		}

Modified: team/group/media_formats-reviewed/addons/chan_ooh323.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/addons/chan_ooh323.h?view=diff&rev=413477&r1=413476&r2=413477
==============================================================================
--- team/group/media_formats-reviewed/addons/chan_ooh323.h (original)
+++ team/group/media_formats-reviewed/addons/chan_ooh323.h Wed May  7 17:20:29 2014
@@ -65,6 +65,7 @@
 #include "asterisk/format_cap.h"
 #include "asterisk/udptl.h"
 #include "asterisk/stasis_channels.h"
+#include "asterisk/format_cache.h"
 
 #include "ootypes.h"
 #include "ooUtils.h"
@@ -104,9 +105,6 @@
 void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txframes);
 void ooh323_set_read_format(ooCallData *call, struct ast_format *fmt);
 
-int ooh323_update_capPrefsOrderForCall
-   (ooCallData *call, struct ast_codec_pref *prefs);
-
 int ooh323_convertAsteriskCapToH323Cap(struct ast_format *format);
 
 int ooh323_convert_hangupcause_asteriskToH323(int cause);

Modified: team/group/media_formats-reviewed/addons/format_mp3.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/addons/format_mp3.c?view=diff&rev=413477&r1=413476&r2=413477
==============================================================================
--- team/group/media_formats-reviewed/addons/format_mp3.c (original)
+++ team/group/media_formats-reviewed/addons/format_mp3.c Wed May  7 17:20:29 2014
@@ -42,6 +42,7 @@
 #include "asterisk/module.h"
 #include "asterisk/mod_format.h"
 #include "asterisk/logger.h"
+#include "asterisk/format_cache.h"
 
 #define MP3_BUFLEN 320
 #define MP3_SCACHE 16384
@@ -229,10 +230,7 @@
 
 	p->offset += p->buflen;
 	delay = p->buflen / 2;
-	s->fr.frametype = AST_FRAME_VOICE;
-	ast_format_set(&s->fr.subclass.format, AST_FORMAT_SLINEAR, 0);
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, p->buflen);
-	s->fr.mallocd = 0;
 	s->fr.samples = delay;
 	*whennext = delay;
 	return &s->fr;
@@ -318,7 +316,7 @@
 
 static int load_module(void)
 {
-	ast_format_set(&mp3_f.format, AST_FORMAT_SLINEAR, 0);
+	mp3_f.format = ast_format_slin;
 	InitMP3Constants();
 	return ast_format_def_register(&mp3_f);
 }

Modified: team/group/media_formats-reviewed/addons/ooh323cDriver.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/addons/ooh323cDriver.c?view=diff&rev=413477&r1=413476&r2=413477
==============================================================================
--- team/group/media_formats-reviewed/addons/ooh323cDriver.c (original)
+++ team/group/media_formats-reviewed/addons/ooh323cDriver.c Wed May  7 17:20:29 2014
@@ -225,17 +225,17 @@
 }
 
 int ooh323c_set_capability
-   (struct ast_codec_pref *prefs, struct ast_format_cap *cap, int dtmf, int dtmfcodec)
+   (struct ast_format_cap *cap, int dtmf, int dtmfcodec)
 {
    int ret = 0, x;
-   struct ast_format tmpfmt;
    if (gH323Debug) {
      ast_verb(0, "\tAdding capabilities to H323 endpoint\n");
    }
 
-   for(x=0; ast_codec_pref_index(prefs, x, &tmpfmt); x++)
+   for(x=0; x<ast_format_cap_count(cap); x++)
    {
-      if(tmpfmt.id == AST_FORMAT_ULAW)
+    struct ast_format *format = ast_format_cap_get_format(cap, x);
+      if(ast_format_cmp(format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
             ast_verb(0, "\tAdding g711 ulaw capability to H323 endpoint\n");
@@ -246,7 +246,7 @@
                                      &ooh323c_stop_receive_channel, 
                                      &ooh323c_stop_transmit_channel);
       }
-      if(tmpfmt.id == AST_FORMAT_ALAW)
+      if(ast_format_cmp(format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
             ast_verb(0, "\tAdding g711 alaw capability to H323 endpoint\n");
@@ -258,7 +258,7 @@
                                      &ooh323c_stop_transmit_channel);
       }
 
-      if(tmpfmt.id == AST_FORMAT_G729A)
+      if(ast_format_cmp(format, ast_format_g729) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
 	    ast_verb(0, "\tAdding g729A capability to H323 endpoint\n");
@@ -287,7 +287,7 @@
                                      &ooh323c_stop_transmit_channel);
       }
 
-      if(tmpfmt.id == AST_FORMAT_G723_1)
+      if(ast_format_cmp(format, ast_format_g723) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
             ast_verb(0, "\tAdding g7231 capability to H323 endpoint\n");
@@ -300,7 +300,7 @@
 
       }
 
-      if(tmpfmt.id == AST_FORMAT_G726)
+      if(ast_format_cmp(format, ast_format_g726) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
             ast_verb(0, "\tAdding g726 capability to H323 endpoint\n");
@@ -313,7 +313,7 @@
 
       }
 
-      if(tmpfmt.id == AST_FORMAT_G726_AAL2)
+      if(ast_format_cmp(format, ast_format_g726_aal2) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
             ast_verb(0, "\tAdding g726aal2 capability to H323 endpoint\n");
@@ -326,7 +326,7 @@
 
       }
 
-      if(tmpfmt.id == AST_FORMAT_H263)
+      if(ast_format_cmp(format, ast_format_h263) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
             ast_verb(0, "\tAdding h263 capability to H323 endpoint\n");
@@ -339,7 +339,7 @@
 
       }
 
-      if(tmpfmt.id == AST_FORMAT_GSM)
+      if(ast_format_cmp(format, ast_format_gsm) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
             ast_verb(0, "\tAdding gsm capability to H323 endpoint\n");
@@ -351,24 +351,8 @@
                                      &ooh323c_stop_transmit_channel);
 
       }
-      
-#ifdef AST_FORMAT_AMRNB
-      if(tmpfmt.id == AST_FORMAT_AMRNB)
-      {
-         if (gH323Debug) {
-            ast_verb(0, "\tAdding amr nb capability to H323 endpoint\n");
-	 }
-         ret = ooH323EpAddAMRNBCapability(OO_AMRNB, 4, 4, FALSE, 
-                                     OORXANDTX, &ooh323c_start_receive_channel,
-                                     &ooh323c_start_transmit_channel,
-                                     &ooh323c_stop_receive_channel, 
-                                     &ooh323c_stop_transmit_channel);
-
-      }
-#endif
-
-#ifdef AST_FORMAT_SPEEX
-      if(tmpfmt.id == AST_FORMAT_SPEEX)
+
+      if(ast_format_cmp(format, ast_format_speex) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
             ast_verb(0, "\tAdding speex capability to H323 endpoint\n");
@@ -380,8 +364,8 @@
                                      &ooh323c_stop_transmit_channel);
 
       }
-#endif
-      
+
+    ao2_ref(format, -1);      
    }
    
    if(dtmf & H323_DTMF_CISCO)
@@ -397,11 +381,10 @@
 }
 
 int ooh323c_set_capability_for_call
-   (ooCallData *call, struct ast_codec_pref *prefs, struct ast_format_cap *cap, int dtmf, int dtmfcodec,
+   (ooCallData *call, struct ast_format_cap *cap, int dtmf, int dtmfcodec,
 		 int t38support, int g729onlyA)
 {
    int ret = 0, x, txframes;
-   struct ast_format tmpfmt;
    if (gH323Debug) {
      ast_verb(0, "\tAdding capabilities to call(%s, %s)\n", call->callType, 
                                                             call->callToken);
@@ -423,15 +406,16 @@
 					&ooh323c_stop_transmit_datachannel,
 					0);
 
-   for(x=0; ast_codec_pref_index(prefs, x, &tmpfmt); x++)
+   for(x=0; x<ast_format_cap_count(cap); x++)
    {
-      if(tmpfmt.id == AST_FORMAT_ULAW)
+    struct ast_format *format = ast_format_cap_get_format(cap, x);
+      if(ast_format_cmp(format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL)
       {
          if (gH323Debug) {
             ast_verb(0, "\tAdding g711 ulaw capability to call(%s, %s)\n", 
                                               call->callType, call->callToken);
 	 }
-	 txframes = prefs->framing[x];
+	 txframes = ast_format_cap_get_framing(cap, format);
          ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes, 
                                       txframes, OORXANDTX, 
                                       &ooh323c_start_receive_channel,
@@ -439,13 +423,13 @@
                                       &ooh323c_stop_receive_channel, 

[... 518 lines stripped ...]



More information about the asterisk-commits mailing list