[svn-commits] file: branch group/media_formats-reviewed r411573 - in /team/group/media_form...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Mar 30 07:12:07 CDT 2014


Author: file
Date: Sun Mar 30 07:11:54 2014
New Revision: 411573

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411573
Log:
Move chan_nbs, chan_phone, and chan_vpb over.

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

Modified:
    team/group/media_formats-reviewed/channels/chan_nbs.c
    team/group/media_formats-reviewed/channels/chan_phone.c
    team/group/media_formats-reviewed/channels/chan_vpb.cc
    team/group/media_formats-reviewed/include/asterisk/channel.h
    team/group/media_formats-reviewed/include/asterisk/format.h
    team/group/media_formats-reviewed/main/format.c

Modified: team/group/media_formats-reviewed/channels/chan_nbs.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/channels/chan_nbs.c?view=diff&rev=411573&r1=411572&r2=411573
==============================================================================
--- team/group/media_formats-reviewed/channels/chan_nbs.c (original)
+++ team/group/media_formats-reviewed/channels/chan_nbs.c Sun Mar 30 07:11:54 2014
@@ -47,11 +47,9 @@
 #include "asterisk/module.h"
 #include "asterisk/pbx.h"
 #include "asterisk/utils.h"
+#include "asterisk/format_cache.h"
 
 static const char tdesc[] = "Network Broadcast Sound Driver";
-
-/* Only linear is allowed */
-static struct ast_format prefformat;
 
 static char context[AST_MAX_EXTENSION] = "default";
 static const char type[] = "NBS";
@@ -63,7 +61,6 @@
 	struct ast_channel *owner;		/* Channel we belong to, possibly NULL */
 	char app[16];					/* Our app */
 	char stream[80];				/* Our stream */
-	struct ast_frame fr;			/* "null" frame */
 	struct ast_module_user *u;		/*! for holding a reference to this module */
 };
 
@@ -178,37 +175,14 @@
 
 static struct ast_frame  *nbs_xread(struct ast_channel *ast)
 {
+	ast_debug(1, "Returning null frame on %s\n", ast_channel_name(ast));
+
+	return &ast_null_frame;
+}
+
+static int nbs_xwrite(struct ast_channel *ast, struct ast_frame *frame)
+{
 	struct nbs_pvt *p = ast_channel_tech_pvt(ast);
-	
-
-	/* Some nice norms */
-	p->fr.datalen = 0;
-	p->fr.samples = 0;
-	p->fr.data.ptr =  NULL;
-	p->fr.src = type;
-	p->fr.offset = 0;
-	p->fr.mallocd=0;
-	p->fr.delivery.tv_sec = 0;
-	p->fr.delivery.tv_usec = 0;
-
-	ast_debug(1, "Returning null frame on %s\n", ast_channel_name(ast));
-
-	return &p->fr;
-}
-
-static int nbs_xwrite(struct ast_channel *ast, struct ast_frame *frame)
-{
-	struct nbs_pvt *p = ast_channel_tech_pvt(ast);
-	/* Write a frame of (presumably voice) data */
-	if (frame->frametype != AST_FRAME_VOICE) {
-		if (frame->frametype != AST_FRAME_IMAGE)
-			ast_log(LOG_WARNING, "Don't know what to do with  frame type '%d'\n", frame->frametype);
-		return 0;
-	}
-	if (frame->subclass.format.id != (AST_FORMAT_SLINEAR)) {
-		ast_log(LOG_WARNING, "Cannot handle frames in %s format\n", ast_getformatname(&frame->subclass.format));
-		return 0;
-	}
 	if (ast_channel_state(ast) != AST_STATE_UP) {
 		/* Don't try tos end audio on-hook */
 		return 0;
@@ -226,11 +200,11 @@
 		ast_channel_tech_set(tmp, &nbs_tech);
 		ast_channel_set_fd(tmp, 0, nbs_fd(i->nbs));
 
-		ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
-		ast_format_copy(ast_channel_rawreadformat(tmp), &prefformat);
-		ast_format_copy(ast_channel_rawwriteformat(tmp), &prefformat);
-		ast_format_copy(ast_channel_writeformat(tmp), &prefformat);
-		ast_format_copy(ast_channel_readformat(tmp), &prefformat);
+		ast_channel_nativeformats_set(tmp, nbs_tech.capabilities);
+		ast_channel_set_rawreadformat(tmp, ast_format_slin);
+		ast_channel_set_rawwriteformat(tmp, ast_format_slin);
+		ast_channel_set_writeformat(tmp, ast_format_slin);
+		ast_channel_set_readformat(tmp, ast_format_slin);
 		if (state == AST_STATE_RING)
 			ast_channel_rings_set(tmp, 1);
 		ast_channel_tech_pvt_set(tmp, i);
@@ -257,7 +231,7 @@
 	struct nbs_pvt *p;
 	struct ast_channel *tmp = NULL;
 
-	if (!(ast_format_cap_iscompatible(cap, &prefformat))) {
+	if (!(ast_format_cap_iscompatible_format(cap, ast_format_slin))) {
 		char tmp[256];
 		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), cap));
 		return NULL;
@@ -275,17 +249,17 @@
 {
 	/* First, take us out of the channel loop */
 	ast_channel_unregister(&nbs_tech);
-	nbs_tech.capabilities = ast_format_cap_destroy(nbs_tech.capabilities);
+	ao2_ref(nbs_tech.capabilities, -1);
+	nbs_tech.capabilities = NULL;
 	return 0;
 }
 
 static int load_module(void)
 {
-	ast_format_set(&prefformat, AST_FORMAT_SLINEAR, 0);
-	if (!(nbs_tech.capabilities = ast_format_cap_alloc(0))) {
+	if (!(nbs_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	ast_format_cap_add(nbs_tech.capabilities, &prefformat);
+	ast_format_cap_add(nbs_tech.capabilities, ast_format_slin, 0);
 	/* Make sure we can register our channel type */
 	if (ast_channel_register(&nbs_tech)) {
 		ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);

Modified: team/group/media_formats-reviewed/channels/chan_phone.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/channels/chan_phone.c?view=diff&rev=411573&r1=411572&r2=411573
==============================================================================
--- team/group/media_formats-reviewed/channels/chan_phone.c (original)
+++ team/group/media_formats-reviewed/channels/chan_phone.c Sun Mar 30 07:11:54 2014
@@ -67,6 +67,7 @@
 #include "asterisk/causes.h"
 #include "asterisk/stringfields.h"
 #include "asterisk/musiconhold.h"
+#include "asterisk/format_cache.h"
 
 #include "chan_phone.h"
 
@@ -134,8 +135,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  */
-	struct ast_format lastformat;            /* Last output format */
-	struct ast_format lastinput;             /* Last input format */
+	struct ast_format *lastformat;            /* Last output format */
+	struct ast_format *lastinput;             /* Last input format */
 	int ministate;					/* Miniature state, for dialtone mode */
 	char dev[256];					/* Device name */
 	struct phone_pvt *next;			/* Next channel in list */
@@ -218,7 +219,8 @@
 		ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
 		usleep(320000);
 		ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_OFF_HOOK);
-		ast_format_clear(&p->lastformat);
+		ao2_cleanup(p->lastformat);
+		p->lastformat = NULL;
 		res = 0;
 		break;
 	case AST_CONTROL_HOLD:
@@ -282,7 +284,8 @@
 		ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
 		usleep(320000);
 		ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_OFF_HOOK);
-		ast_format_clear(&p->lastformat);
+		ao2_cleanup(p->lastformat);
+		p->lastformat = NULL;
 		return 0;
 	default:
 		ast_log(LOG_WARNING, "Unknown digit '%c'\n", digit);
@@ -290,7 +293,8 @@
 	}
 	ast_debug(1, "Dialed %d\n", outdigit);
 	ioctl(p->fd, PHONE_PLAY_TONE, outdigit);
-	ast_format_clear(&p->lastformat);
+	ao2_cleanup(p->lastformat);
+	p->lastformat = NULL;
 	return 0;
 }
 
@@ -381,8 +385,10 @@
 		ioctl(p->fd, PHONE_BUSY);
 		p->cpt = 1;
 	}
-	ast_format_clear(&p->lastformat);
-	ast_format_clear(&p->lastinput);
+	ao2_cleanup(p->lastformat);
+	p->lastformat = NULL;
+	ao2_cleanup(p->lastinput);
+	p->lastinput = NULL;
 	p->ministate = 0;
 	p->obuflen = 0;
 	p->dialtone = 0;
@@ -402,38 +408,42 @@
 	p = ast_channel_tech_pvt(ast);
 	ioctl(p->fd, PHONE_CPT_STOP);
 	/* Nothing to answering really, just start recording */
-	if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_G729A) {
+	if (ast_format_cmp(ast_channel_rawreadformat(ast), ast_format_g729) == AST_FORMAT_CMP_EQUAL) {
 		/* Prefer g729 */
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (p->lastinput.id != AST_FORMAT_G729A) {
-			ast_format_set(&p->lastinput, AST_FORMAT_G729A, 0);
+		if (!p->lastinput || (ast_format_cmp(p->lastinput, ast_format_g729) != AST_FORMAT_CMP_EQUAL)) {
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(ast_format_g729);
 			if (ioctl(p->fd, PHONE_REC_CODEC, G729)) {
 				ast_log(LOG_WARNING, "Failed to set codec to g729\n");
 				return -1;
 			}
 		}
-        } else if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_G723_1) {
+	} else if (ast_format_cmp(ast_channel_rawreadformat(ast), ast_format_g723) == AST_FORMAT_CMP_EQUAL) {
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (p->lastinput.id != AST_FORMAT_G723_1) {
-			ast_format_set(&p->lastinput, AST_FORMAT_G723_1, 0);
+		if (!p->lastinput || (ast_format_cmp(p->lastinput, ast_format_g723) != AST_FORMAT_CMP_EQUAL)) {
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(ast_format_g723);
 			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_channel_rawreadformat(ast)->id == AST_FORMAT_SLINEAR) {
+	} else if (ast_format_cmp(ast_channel_rawreadformat(ast), ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (p->lastinput.id != AST_FORMAT_SLINEAR) {
-			ast_format_set(&p->lastinput, AST_FORMAT_SLINEAR, 0);
+		if (!p->lastinput || (ast_format_cmp(p->lastinput, ast_format_slin) != AST_FORMAT_CMP_EQUAL)) {
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(ast_format_slin);
 			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_channel_rawreadformat(ast)->id == AST_FORMAT_ULAW) {
+	} else if (ast_format_cmp(ast_channel_rawreadformat(ast), ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (p->lastinput.id != AST_FORMAT_ULAW) {
-			ast_format_set(&p->lastinput, AST_FORMAT_ULAW, 0);
+		if (!p->lastinput || (ast_format_cmp(p->lastinput, ast_format_ulaw) != AST_FORMAT_CMP_EQUAL)) {
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(ast_format_ulaw);
 			if (ioctl(p->fd, PHONE_REC_CODEC, ULAW)) {
 				ast_log(LOG_WARNING, "Failed to set codec to uLaw\n");
 				return -1;
@@ -441,16 +451,17 @@
 		}
 	} else if (p->mode == MODE_FXS) {
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (ast_format_cmp(&p->lastinput, ast_channel_rawreadformat(ast)) == AST_FORMAT_CMP_NOT_EQUAL) {
-			ast_format_copy(&p->lastinput, ast_channel_rawreadformat(ast));
+		if (!p->lastinput || (ast_format_cmp(p->lastinput, ast_channel_rawreadformat(ast)) == AST_FORMAT_CMP_NOT_EQUAL)) {
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(ast_channel_rawreadformat(ast));
 			if (ioctl(p->fd, PHONE_REC_CODEC, ast_channel_rawreadformat(ast))) {
 				ast_log(LOG_WARNING, "Failed to set codec to %s\n", 
-					ast_getformatname(ast_channel_rawreadformat(ast)));
+					ast_format_get_name(ast_channel_rawreadformat(ast)));
 				return -1;
 			}
 		}
 	} else {
-		ast_log(LOG_WARNING, "Can't do format %s\n", ast_getformatname(ast_channel_rawreadformat(ast)));
+		ast_log(LOG_WARNING, "Can't do format %s\n", ast_format_get_name(ast_channel_rawreadformat(ast)));
 		return -1;
 	}
 	if (ioctl(p->fd, PHONE_REC_START)) {
@@ -601,13 +612,13 @@
 	}
 	p->fr.samples = 240;
 	p->fr.datalen = res;
-	p->fr.frametype = AST_FORMAT_GET_TYPE(p->lastinput.id) == AST_FORMAT_TYPE_AUDIO ?
-		AST_FRAME_VOICE : AST_FORMAT_GET_TYPE(p->lastinput.id) == AST_FORMAT_TYPE_IMAGE ?
+	p->fr.frametype = ast_format_get_type(p->lastinput) == AST_MEDIA_TYPE_AUDIO ?
+		AST_FRAME_VOICE : ast_format_get_type(p->lastinput) == AST_MEDIA_TYPE_IMAGE ?
 		AST_FRAME_IMAGE : AST_FRAME_VIDEO;
-	ast_format_copy(&p->fr.subclass.format, &p->lastinput);
+	p->fr.subclass.format = p->lastinput;
 	p->fr.offset = AST_FRIENDLY_OFFSET;
 	/* Byteswap from little-endian to native-endian */
-	if (p->fr.subclass.format.id == AST_FORMAT_SLINEAR)
+	if (ast_format_cmp(p->fr.subclass.format, ast_format_slin) == AST_FORMAT_CMP_EQUAL)
 		ast_frame_byteswap_le(&p->fr);
 	return &p->fr;
 }
@@ -669,14 +680,6 @@
 			ast_log(LOG_WARNING, "Don't know what to do with  frame type '%d'\n", frame->frametype);
 		return 0;
 	}
-	if (!(frame->subclass.format.id == AST_FORMAT_G723_1 ||
-		frame->subclass.format.id == AST_FORMAT_SLINEAR ||
-		frame->subclass.format.id == AST_FORMAT_ULAW ||
-		frame->subclass.format.id == AST_FORMAT_G729A) &&
-	    p->mode != MODE_FXS) {
-		ast_log(LOG_WARNING, "Cannot handle frames in %s format\n", ast_getformatname(&frame->subclass.format));
-		return -1;
-	}
 #if 0
 	/* If we're not in up mode, go into up mode now */
 	if (ast->_state != AST_STATE_UP) {
@@ -689,8 +692,8 @@
 		return 0;
 	}
 #endif	
-	if (frame->subclass.format.id == AST_FORMAT_G729A) {
-		if (p->lastformat.id != AST_FORMAT_G729A) {
+	if (ast_format_cmp(frame->subclass.format, ast_format_g729) == AST_FORMAT_CMP_EQUAL) {
+		if (!p->lastformat || (ast_format_cmp(p->lastformat, ast_format_g729) != AST_FORMAT_CMP_EQUAL)) {
 			ioctl(p->fd, PHONE_PLAY_STOP);
 			ioctl(p->fd, PHONE_REC_STOP);
 			if (ioctl(p->fd, PHONE_PLAY_CODEC, G729)) {
@@ -701,8 +704,10 @@
 				ast_log(LOG_WARNING, "Unable to set G729 mode\n");
 				return -1;
 			}
-			ast_format_set(&p->lastformat, AST_FORMAT_G729A, 0);
-			ast_format_set(&p->lastinput, AST_FORMAT_G729A, 0);
+			ao2_cleanup(p->lastformat);
+			p->lastformat = ast_format_copy(ast_format_g729);
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(ast_format_g729);
 			/* Reset output buffer */
 			p->obuflen = 0;
 			codecset = 1;
@@ -712,8 +717,8 @@
 			return -1;
 		}
 		maxfr = 80;
-        } else if (frame->subclass.format.id == AST_FORMAT_G723_1) {
-		if (p->lastformat.id != AST_FORMAT_G723_1) {
+    } else if (ast_format_cmp(frame->subclass.format, ast_format_g723) == AST_FORMAT_CMP_EQUAL) {
+		if (!p->lastformat || (ast_format_cmp(p->lastformat, ast_format_g723) != AST_FORMAT_CMP_EQUAL)) {
 			ioctl(p->fd, PHONE_PLAY_STOP);
 			ioctl(p->fd, PHONE_REC_STOP);
 			if (ioctl(p->fd, PHONE_PLAY_CODEC, G723_63)) {
@@ -724,8 +729,10 @@
 				ast_log(LOG_WARNING, "Unable to set G723.1 mode\n");
 				return -1;
 			}
-			ast_format_set(&p->lastformat, AST_FORMAT_G723_1, 0);
-			ast_format_set(&p->lastinput, AST_FORMAT_G723_1, 0);
+			ao2_cleanup(p->lastformat);
+			p->lastformat = ast_format_copy(ast_format_g723);
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(ast_format_g723);
 			/* Reset output buffer */
 			p->obuflen = 0;
 			codecset = 1;
@@ -735,8 +742,8 @@
 			return -1;
 		}
 		maxfr = 24;
-	} else if (frame->subclass.format.id == AST_FORMAT_SLINEAR) {
-		if (p->lastformat.id != AST_FORMAT_SLINEAR) {
+	} else if (ast_format_cmp(frame->subclass.format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
+		if (!p->lastformat || (ast_format_cmp(p->lastformat, ast_format_slin) != AST_FORMAT_CMP_EQUAL)) {
 			ioctl(p->fd, PHONE_PLAY_STOP);
 			ioctl(p->fd, PHONE_REC_STOP);
 			if (ioctl(p->fd, PHONE_PLAY_CODEC, LINEAR16)) {
@@ -747,15 +754,17 @@
 				ast_log(LOG_WARNING, "Unable to set 16-bit linear mode\n");
 				return -1;
 			}
-			ast_format_set(&p->lastformat, AST_FORMAT_SLINEAR, 0);
-			ast_format_set(&p->lastinput, AST_FORMAT_SLINEAR, 0);
+			ao2_cleanup(p->lastformat);
+			p->lastformat = ast_format_copy(ast_format_slin);
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(ast_format_slin);
 			codecset = 1;
 			/* Reset output buffer */
 			p->obuflen = 0;
 		}
 		maxfr = 480;
-	} else if (frame->subclass.format.id == AST_FORMAT_ULAW) {
-		if (p->lastformat.id != AST_FORMAT_ULAW) {
+	} else if (ast_format_cmp(frame->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
+		if (!p->lastformat || (ast_format_cmp(p->lastformat, ast_format_ulaw) != AST_FORMAT_CMP_EQUAL)) {
 			ioctl(p->fd, PHONE_PLAY_STOP);
 			ioctl(p->fd, PHONE_REC_STOP);
 			if (ioctl(p->fd, PHONE_PLAY_CODEC, ULAW)) {
@@ -766,29 +775,33 @@
 				ast_log(LOG_WARNING, "Unable to set uLaw mode\n");
 				return -1;
 			}
-			ast_format_set(&p->lastformat, AST_FORMAT_ULAW, 0);
-			ast_format_set(&p->lastinput, AST_FORMAT_ULAW, 0);
+			ao2_cleanup(p->lastformat);
+			p->lastformat = ast_format_copy(ast_format_ulaw);
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(ast_format_ulaw);
 			codecset = 1;
 			/* Reset output buffer */
 			p->obuflen = 0;
 		}
 		maxfr = 240;
 	} else {
-		if (ast_format_cmp(&p->lastformat, &frame->subclass.format) != AST_FORMAT_CMP_EQUAL) {
+		if (!p->lastformat || (ast_format_cmp(p->lastformat, frame->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
 			ioctl(p->fd, PHONE_PLAY_STOP);
 			ioctl(p->fd, PHONE_REC_STOP);
-			if (ioctl(p->fd, PHONE_PLAY_CODEC, (int) frame->subclass.format.id)) {
+			if (ioctl(p->fd, PHONE_PLAY_CODEC, ast_format_get_original_id(frame->subclass.format))) {
 				ast_log(LOG_WARNING, "Unable to set %s mode\n",
-					ast_getformatname(&frame->subclass.format));
+					ast_format_get_name(frame->subclass.format));
 				return -1;
 			}
-			if (ioctl(p->fd, PHONE_REC_CODEC, (int) frame->subclass.format.id)) {
+			if (ioctl(p->fd, PHONE_REC_CODEC, ast_format_get_original_id(frame->subclass.format))) {
 				ast_log(LOG_WARNING, "Unable to set %s mode\n",
-					ast_getformatname(&frame->subclass.format));
+					ast_format_get_name(frame->subclass.format));
 				return -1;
 			}
-			ast_format_copy(&p->lastformat, &frame->subclass.format);
-			ast_format_copy(&p->lastinput, &frame->subclass.format);
+			ao2_cleanup(p->lastformat);
+			p->lastformat = ast_format_copy(frame->subclass.format);
+			ao2_cleanup(p->lastinput);
+			p->lastinput = ast_format_copy(frame->subclass.format);
 			codecset = 1;
 			/* Reset output buffer */
 			p->obuflen = 0;
@@ -857,11 +870,13 @@
 
 static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *cntx, const char *linkedid)
 {
+	struct ast_format_cap *caps = NULL;
 	struct ast_channel *tmp;
 	struct phone_codec_data queried_codec;
-	struct ast_format tmpfmt;
+	struct ast_format *tmpfmt;
+	caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
 	tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, "", i->ext, i->context, linkedid, 0, "Phone/%s", i->dev + 5);
-	if (tmp) {
+	if (tmp && caps) {
 		ast_channel_lock(tmp);
 		ast_channel_tech_set(tmp, cur_tech);
 		ast_channel_set_fd(tmp, 0, i->fd);
@@ -869,18 +884,20 @@
 		if (i->mode == MODE_FXS &&
 		    ioctl(i->fd, PHONE_QUERY_CODEC, &queried_codec) == 0) {
 			if (queried_codec.type == LINEAR16) {
-				ast_format_cap_add(ast_channel_nativeformats(tmp), ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
-				ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
-				ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+				ast_format_cap_add(caps, ast_format_slin, 0);
 			} else {
-				ast_format_cap_remove(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+				ast_format_cap_remove(prefcap, ast_format_slin);
+				ast_format_cap_append_by_type(caps, prefcap, AST_MEDIA_TYPE_UNKNOWN);
 			}
 		} else {
-			ast_format_cap_copy(ast_channel_nativeformats(tmp), prefcap);
-			ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
-			ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
-			ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
-		}
+			ast_format_cap_append_by_type(caps, prefcap, AST_MEDIA_TYPE_UNKNOWN);
+		}
+		ast_best_codec(caps, &tmpfmt);
+		ast_channel_nativeformats_set(tmp, caps);
+		ao2_ref(caps, -1);
+		ast_channel_set_rawreadformat(tmp, tmpfmt);
+		ast_channel_set_rawwriteformat(tmp, tmpfmt);
+		ao2_ref(tmpfmt, -1);
 		/* no need to call ast_setstate: the channel_alloc already did its job */
 		if (state == AST_STATE_RING)
 			ast_channel_rings_set(tmp, 1);
@@ -913,8 +930,10 @@
 				ast_hangup(tmp);
 			}
 		}
-	} else
+	} else {
+		ao2_cleanup(caps);
 		ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
+	}
 	return tmp;
 }
 
@@ -989,7 +1008,8 @@
 				ioctl(i->fd, PHONE_PLAY_STOP);
 				ioctl(i->fd, PHONE_PLAY_CODEC, ULAW);
 				ioctl(i->fd, PHONE_PLAY_START);
-				ast_format_clear(&i->lastformat);
+				ao2_cleanup(i->lastformat);
+				i->lastformat = NULL;
 			} else if (i->mode == MODE_SIGMA) {
 				ast_module_ref(ast_module_info->self);
 				/* Reset the extension */
@@ -1010,7 +1030,8 @@
 			ioctl(i->fd, PHONE_PLAY_STOP);
 			ioctl(i->fd, PHONE_REC_STOP);
 			i->dialtone = 0;
-			ast_format_clear(&i->lastformat);
+			ao2_cleanup(i->lastformat);
+			i->lastformat = NULL;
 		}
 	}
 	if (phonee.bits.pstn_ring) {
@@ -1222,8 +1243,10 @@
 		flags = fcntl(tmp->fd, F_GETFL);
 		fcntl(tmp->fd, F_SETFL, flags | O_NONBLOCK);
 		tmp->owner = NULL;
-		ast_format_clear(&tmp->lastformat);
-		ast_format_clear(&tmp->lastinput);
+		ao2_cleanup(tmp->lastformat);
+		tmp->lastformat = NULL;
+		ao2_cleanup(tmp->lastinput);
+		tmp->lastinput = NULL;
 		tmp->ministate = 0;
 		memset(tmp->ext, 0, sizeof(tmp->ext));
 		ast_copy_string(tmp->language, language, sizeof(tmp->language));
@@ -1256,7 +1279,7 @@
 	}
 	p = iflist;
 	while(p) {
-		if (p->mode == MODE_FXS || (ast_format_cap_has_joint(cap, phone_tech.capabilities))) {
+		if (p->mode == MODE_FXS || (ast_format_cap_iscompatible(cap, phone_tech.capabilities))) {
 			size_t length = strlen(p->dev + 5);
     		if (strncmp(name, p->dev + 5, length) == 0 &&
     		    !isalnum(name[length])) {
@@ -1272,7 +1295,7 @@
 	ast_mutex_unlock(&iflock);
 	restart_monitor();
 	if (tmp == NULL) {
-		if (!(ast_format_cap_has_joint(cap, phone_tech.capabilities))) {
+		if (!(ast_format_cap_iscompatible(cap, phone_tech.capabilities))) {
 			char buf[256];
 			ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), cap));
 			return NULL;
@@ -1357,9 +1380,10 @@
 		return -1;
 	}
 
-	phone_tech.capabilities = ast_format_cap_destroy(phone_tech.capabilities);
-	phone_tech_fxs.capabilities = ast_format_cap_destroy(phone_tech_fxs.capabilities);
-	prefcap = ast_format_cap_destroy(prefcap);
+	ao2_ref(phone_tech.capabilities, -1);
+	ao2_ref(phone_tech_fxs.capabilities, -1);
+	ao2_ref(prefcap, -1);
+
 	return 0;
 }
 
@@ -1376,21 +1400,21 @@
 	int mode = MODE_IMMEDIATE;
 	int txgain = DEFAULT_GAIN, rxgain = DEFAULT_GAIN; /* default gain 1.0 */
 	struct ast_flags config_flags = { 0 };
-	struct ast_format tmpfmt;
-
-	if (!(phone_tech.capabilities = ast_format_cap_alloc(0))) {
+
+	if (!(phone_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_cap_add(phone_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_G723_1, 0));
-	ast_format_cap_add(phone_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
-	ast_format_cap_add(phone_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
-	ast_format_cap_add(phone_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_G729A, 0));
-
-	if (!(prefcap = ast_format_cap_alloc(0))) {
+
+	ast_format_cap_add(phone_tech.capabilities, ast_format_g723, 0);
+	ast_format_cap_add(phone_tech.capabilities, ast_format_slin, 0);
+	ast_format_cap_add(phone_tech.capabilities, ast_format_ulaw, 0);
+	ast_format_cap_add(phone_tech.capabilities, ast_format_g729, 0);
+
+	if (!(prefcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_cap_copy(prefcap, phone_tech.capabilities);
-	if (!(phone_tech_fxs.capabilities = ast_format_cap_alloc(0))) {
+	ast_format_cap_append_by_type(prefcap, phone_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
+	if (!(phone_tech_fxs.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
@@ -1440,7 +1464,7 @@
 				mode = MODE_IMMEDIATE;
 			else if (!strncasecmp(v->value, "fxs", 3)) {
 				mode = MODE_FXS;
-				ast_format_cap_remove_bytype(prefcap, AST_FORMAT_TYPE_AUDIO); /* All non-voice */
+				ast_format_cap_remove_bytype(prefcap, AST_MEDIA_TYPE_AUDIO); /* All non-voice */
 			}
 			else if (!strncasecmp(v->value, "fx", 2))
 				mode = MODE_FXO;
@@ -1450,18 +1474,21 @@
 			ast_copy_string(context, v->value, sizeof(context));
 		} else if (!strcasecmp(v->name, "format")) {
 			if (!strcasecmp(v->value, "g729")) {
-				ast_format_cap_set(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_G729A, 0));
+				ast_format_cap_remove_bytype(prefcap, AST_MEDIA_TYPE_UNKNOWN);
+				ast_format_cap_add(prefcap, ast_format_g729, 0);
 			} else if (!strcasecmp(v->value, "g723.1")) {
-				ast_format_cap_set(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_G723_1, 0));
+				ast_format_cap_remove_bytype(prefcap, AST_MEDIA_TYPE_UNKNOWN);
+				ast_format_cap_add(prefcap, ast_format_g723, 0);
 			} else if (!strcasecmp(v->value, "slinear")) {
-				ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0);
 				if (mode == MODE_FXS) {
-					ast_format_cap_add(prefcap, &tmpfmt);
+					ast_format_cap_add(prefcap, ast_format_slin, 0);
 				} else {
-					ast_format_cap_set(prefcap, &tmpfmt);
+					ast_format_cap_remove_bytype(prefcap, AST_MEDIA_TYPE_UNKNOWN);
+					ast_format_cap_add(prefcap, ast_format_slin, 0);
 				}
 			} else if (!strcasecmp(v->value, "ulaw")) {
-				ast_format_cap_set(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
+				ast_format_cap_remove_bytype(prefcap, AST_MEDIA_TYPE_UNKNOWN);
+				ast_format_cap_add(prefcap, ast_format_ulaw, 0);
 			} else
 				ast_log(LOG_WARNING, "Unknown format '%s'\n", v->value);
 		} else if (!strcasecmp(v->name, "echocancel")) {
@@ -1485,7 +1512,7 @@
 	ast_mutex_unlock(&iflock);
 
 	if (mode == MODE_FXS) {
-		ast_format_cap_copy(phone_tech_fxs.capabilities, prefcap);
+		ast_format_cap_append_by_type(phone_tech_fxs.capabilities, prefcap, AST_MEDIA_TYPE_UNKNOWN);
 		cur_tech = &phone_tech_fxs;
 	} else
 		cur_tech = (struct ast_channel_tech *) &phone_tech;

Modified: team/group/media_formats-reviewed/channels/chan_vpb.cc
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/channels/chan_vpb.cc?view=diff&rev=411573&r1=411572&r2=411573
==============================================================================
--- team/group/media_formats-reviewed/channels/chan_vpb.cc (original)
+++ team/group/media_formats-reviewed/channels/chan_vpb.cc Sun Mar 30 07:11:54 2014
@@ -71,6 +71,7 @@
 #include "asterisk/dsp.h"
 #include "asterisk/features.h"
 #include "asterisk/musiconhold.h"
+#include "asterisk/format_cache.h"
 }
 
 #include <sys/socket.h>
@@ -766,11 +767,10 @@
 #endif
 		vpb_record_buf_start(p->handle, VPB_MULAW);
 		while ((rc == 0) && (sam_count < 8000 * 3)) {
-			struct ast_format tmpfmt;
 			vrc = vpb_record_buf_sync(p->handle, (char*)buf, sizeof(buf));
 			if (vrc != VPB_OK)
 				ast_log(LOG_ERROR, "%s: Caller ID couldn't read audio buffer!\n", p->dev);
-			rc = callerid_feed(cs, (unsigned char *)buf, sizeof(buf), ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
+			rc = callerid_feed(cs, (unsigned char *)buf, sizeof(buf), ast_format_ulaw);
 #ifdef ANALYSE_CID
 			vpb_wave_write(ws, (char *)buf, sizeof(buf)); 
 #endif
@@ -2070,46 +2070,41 @@
 
 static inline AudioCompress ast2vpbformat(struct ast_format *format)
 {
-	switch (format->id) {
-	case AST_FORMAT_ALAW:
+	if (ast_format_cmp(format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
 		return VPB_ALAW;
-	case AST_FORMAT_SLINEAR:
+	} else if (ast_format_cmp(format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
 		return VPB_LINEAR;
-	case AST_FORMAT_ULAW:
+	} else if (ast_format_cmp(format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
 		return VPB_MULAW;
-	case AST_FORMAT_ADPCM:
+	} else if (ast_format_cmp(format, ast_format_adpcm) == AST_FORMAT_CMP_EQUAL) {
 		return VPB_OKIADPCM;
-	default:
+	} else {
 		return VPB_RAW;
 	}
 }
 
 static inline const char * ast2vpbformatname(struct ast_format *format)
 {
-	switch(format->id) {
-	case AST_FORMAT_ALAW:
+	if (ast_format_cmp(format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
 		return "AST_FORMAT_ALAW:VPB_ALAW";
-	case AST_FORMAT_SLINEAR:
+	} else if (ast_format_cmp(format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
 		return "AST_FORMAT_SLINEAR:VPB_LINEAR";
-	case AST_FORMAT_ULAW:
+	} else if (ast_format_cmp(format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
 		return "AST_FORMAT_ULAW:VPB_MULAW";
-	case AST_FORMAT_ADPCM:
+	} else if (ast_format_cmp(format, ast_format_adpcm) == AST_FORMAT_CMP_EQUAL) {
 		return "AST_FORMAT_ADPCM:VPB_OKIADPCM";
-	default:
+	} else {
 		return "UNKN:UNKN";
 	}
 }
 
 static inline int astformatbits(struct ast_format *format)
 {
-	switch (format->id) {
-	case AST_FORMAT_SLINEAR:
+	if (ast_format_cmp(format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
 		return 16;
-	case AST_FORMAT_ADPCM:
+	} else if (ast_format_cmp(format, ast_format_adpcm) == AST_FORMAT_CMP_EQUAL) {
 		return 4;
-	case AST_FORMAT_ALAW:
-	case AST_FORMAT_ULAW:
-	default:
+	} else {
 		return 8;
 	}
 }
@@ -2146,7 +2141,8 @@
 /*		ast_mutex_unlock(&p->lock); */
 		return 0;
 	} else if (ast_channel_state(ast) != AST_STATE_UP) {
-		ast_verb(4, "%s: vpb_write: Attempt to Write frame type[%d]subclass[%s] on not up chan(state[%d])\n", ast_channel_name(ast), frame->frametype, ast_getformatname(&frame->subclass.format), ast_channel_state(ast));
+		ast_verb(4, "%s: vpb_write: Attempt to Write frame type[%d]subclass[%s] on not up chan(state[%d])\n",
+			ast_channel_name(ast), frame->frametype, ast_format_get_name(frame->subclass.format), ast_channel_state(ast));
 		p->lastoutput = -1;
 /*		ast_mutex_unlock(&p->lock); */
 		return 0;
@@ -2154,9 +2150,10 @@
 /*	ast_debug(1, "%s: vpb_write: Checked frame type..\n", p->dev); */
 
 
-	fmt = ast2vpbformat(&frame->subclass.format);
+	fmt = ast2vpbformat(frame->subclass.format);
 	if (fmt < 0) {
-		ast_log(LOG_WARNING, "%s: vpb_write: Cannot handle frames of %s format!\n", ast_channel_name(ast), ast_getformatname(&frame->subclass.format));
+		ast_log(LOG_WARNING, "%s: vpb_write: Cannot handle frames of %s format!\n", ast_channel_name(ast),
+			ast_format_get_name(frame->subclass.format));
 		return -1;
 	}
 
@@ -2180,7 +2177,7 @@
 	/* Check if we have set up the play_buf */
 	if (p->lastoutput == -1) {
 		vpb_play_buf_start(p->handle, fmt);
-		ast_verb(2, "%s: vpb_write: Starting play mode (codec=%d)[%s]\n", p->dev, fmt, ast2vpbformatname(&frame->subclass.format));
+		ast_verb(2, "%s: vpb_write: Starting play mode (codec=%d)[%s]\n", p->dev, fmt, ast2vpbformatname(frame->subclass.format));
 		p->lastoutput = fmt;
 		ast_mutex_unlock(&p->play_lock);
 		return 0;
@@ -2230,7 +2227,7 @@
 	struct ast_frame *fr = &p->fr;
 	char *readbuf = ((char *)p->buf) + AST_FRIENDLY_OFFSET;
 	int bridgerec = 0;
-	struct ast_format tmpfmt;
+	struct ast_format *tmpfmt;
 	int readlen, res, trycnt=0;
 	AudioCompress fmt;
 	int ignore_dtmf;
@@ -2315,22 +2312,22 @@
 		ast_mutex_unlock(&p->play_dtmf_lock);
 
 		if (p->owner) {
-			ast_format_copy(&tmpfmt, ast_channel_rawreadformat(p->owner));
+			tmpfmt = ast_channel_rawreadformat(p->owner);
 		} else {
-			ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0);
-		}
-		fmt = ast2vpbformat(&tmpfmt);
+			tmpfmt = ast_format_slin;
+		}
+		fmt = ast2vpbformat(tmpfmt);
 		if (fmt < 0) {
-			ast_log(LOG_WARNING, "%s: Record failure (unsupported format %s)\n", p->dev, ast_getformatname(&tmpfmt));
+			ast_log(LOG_WARNING, "%s: Record failure (unsupported format %s)\n", p->dev, ast_format_get_name(tmpfmt));
 			return NULL;
 		}
-		readlen = VPB_SAMPLES * astformatbits(&tmpfmt) / 8;
+		readlen = VPB_SAMPLES * astformatbits(tmpfmt) / 8;
 
 		if (p->lastinput == -1) {
 			vpb_record_buf_start(p->handle, fmt);
 /*			vpb_reset_record_fifo_alarm(p->handle); */
 			p->lastinput = fmt;
-			ast_verb(2, "%s: Starting record mode (codec=%d)[%s]\n", p->dev, fmt, ast2vpbformatname(&tmpfmt));
+			ast_verb(2, "%s: Starting record mode (codec=%d)[%s]\n", p->dev, fmt, ast2vpbformatname(tmpfmt));
 			continue;
 		} else if (p->lastinput != fmt) {
 			vpb_record_buf_finish(p->handle);
@@ -2349,7 +2346,7 @@
 				a_gain_vector(p->rxswgain - MAX_VPB_GAIN, (short *)readbuf, readlen / sizeof(short));
 			ast_verb(6, "%s: chanreads: applied gain\n", p->dev);
 
-			ast_format_copy(&fr->subclass.format, &tmpfmt);
+			fr->subclass.format = tmpfmt;
 			fr->data.ptr = readbuf;
 			fr->datalen = readlen;
 			fr->frametype = AST_FRAME_VOICE;
@@ -2429,7 +2426,6 @@
 	struct ast_channel *tmp; 
 	char cid_num[256];
 	char cid_name[256];
-	struct ast_format tmpfmt;
 
 	if (me->owner) {
 	    ast_log(LOG_WARNING, "Called vpb_new on owned channel (%s) ?!\n", me->dev);
@@ -2452,9 +2448,9 @@
 		 * they are all converted to/from linear in the vpb code. Best for us to use
 		 * linear since we can then adjust volume in this modules.
 		 */
-		ast_format_cap_add(ast_channel_nativeformats(tmp), ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
-		ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
-		ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+		ast_channel_nativeformats_set(tmp, vpb_tech.capabilities);
+		ast_channel_set_rawreadformat(tmp, ast_format_slin);
+		ast_channel_set_rawwriteformat(tmp, ast_format_slin);
 		if (state == AST_STATE_RING) {
 			ast_channel_rings_set(tmp, 1);
 			cid_name[0] = '\0';
@@ -2508,11 +2504,8 @@
 	char *sepstr, *name;
 	const char *s;
 	int group = -1;
-	struct ast_format slin;
-
-	ast_format_set(&slin, AST_FORMAT_SLINEAR, 0);
-
-	if (!(ast_format_cap_iscompatible(cap, &slin))) {
+
+	if (!(ast_format_cap_iscompatible_format(cap, ast_format_slin))) {
 		char tmp[256];
 		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), cap));
 		return NULL;
@@ -2636,8 +2629,10 @@
 		ast_free(bridges);
 	}
 
-	ast_format_cap_destroy(vpb_tech.capabilities);
-	ast_format_cap_destroy(vpb_tech_indicate.capabilities);
+	ao2_ref(vpb_tech.capabilities, -1);
+	vpb_tech.capabilities = NULL;
+	ao2_ref(vpb_tech_indicate.capabilities, -1);
+	vpb_tech_indicate.capabilities = NULL;
 	return 0;
 }
 
@@ -2671,19 +2666,18 @@
 	int bal2 = -1; 
 	int bal3 = -1;
 	char * callerid = NULL;
-	struct ast_format tmpfmt;
 	int num_cards = 0;
 
-	vpb_tech.capabilities = ast_format_cap_alloc((enum ast_format_cap_flags) 0);
+	vpb_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
 	if (!vpb_tech.capabilities) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	vpb_tech_indicate.capabilities = ast_format_cap_alloc((enum ast_format_cap_flags) 0);
+	vpb_tech_indicate.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
 	if (!vpb_tech_indicate.capabilities) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_cap_add(vpb_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
-	ast_format_cap_add(vpb_tech_indicate.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+	ast_format_cap_add(vpb_tech.capabilities, ast_format_slin, 0);
+	ast_format_cap_add(vpb_tech_indicate.capabilities, ast_format_slin, 0);
 	try {
 		num_cards = vpb_get_num_cards();
 	} catch (std::exception e) {

Modified: team/group/media_formats-reviewed/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/channel.h?view=diff&rev=411573&r1=411572&r2=411573
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/channel.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/channel.h Sun Mar 30 07:11:54 2014
@@ -2062,7 +2062,7 @@
  * \retval on success, pointer to result structure
  * \retval on failure, NULL
  */
-struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format *result);
+struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format **result);
 
 
 /*!

Modified: team/group/media_formats-reviewed/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/format.h?view=diff&rev=411573&r1=411572&r2=411573
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/format.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/format.h Sun Mar 30 07:11:54 2014
@@ -222,6 +222,15 @@
 unsigned int ast_format_get_codec_id(const struct ast_format *format);
 
 /*!
+ * \brief Get the original Asterisk identifier associated with a format
+ *
+ * \param format The media format
+ *
+ * \return original identifier
+ */
+uint64_t ast_format_get_original_id(const struct ast_format *format);
+
+/*!
  * \brief Get the codec name associated with a format
  *
  * \param format The media format

Modified: team/group/media_formats-reviewed/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/format.c?view=diff&rev=411573&r1=411572&r2=411573
==============================================================================
--- team/group/media_formats-reviewed/main/format.c (original)
+++ team/group/media_formats-reviewed/main/format.c Sun Mar 30 07:11:54 2014
@@ -260,6 +260,11 @@
 	return format->codec->id;
 }
 
+uint64_t ast_format_get_original_id(const struct ast_format *format)
+{
+	return format->codec->original_id;
+}
+
 const char *ast_format_get_name(const struct ast_format *format)
 {
 	return format->codec->name;




More information about the svn-commits mailing list