[asterisk-commits] file: branch group/media_formats r408871 - in /team/group/media_formats: apps...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 24 07:55:04 CST 2014


Author: file
Date: Mon Feb 24 07:55:02 2014
New Revision: 408871

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=408871
Log:
Remove bitfield from codec and keep it nice and self contained.

Modified:
    team/group/media_formats/apps/app_meetme.c
    team/group/media_formats/channels/chan_phone.c
    team/group/media_formats/codecs/codec_dahdi.c
    team/group/media_formats/include/asterisk/codec.h
    team/group/media_formats/include/asterisk/format_compatibility.h
    team/group/media_formats/main/codec_builtin.c
    team/group/media_formats/main/format_compatibility.c

Modified: team/group/media_formats/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/apps/app_meetme.c?view=diff&rev=408871&r1=408870&r2=408871
==============================================================================
--- team/group/media_formats/apps/app_meetme.c (original)
+++ team/group/media_formats/apps/app_meetme.c Mon Feb 24 07:55:02 2014
@@ -77,6 +77,7 @@
 #include "asterisk/stasis_channels.h"
 #include "asterisk/stasis_message_router.h"
 #include "asterisk/json.h"
+#include "asterisk/format_compatibility.h"
 
 #include "enter.h"
 #include "leave.h"
@@ -4298,7 +4299,7 @@
 						 )) {
 						int idx;
 						for (idx = 0; idx < AST_FRAME_BITS; idx++) {
-							if (ast_channel_rawwriteformat(chan)->codec->original_id & (1 << idx)) {
+							if (ast_format_compatibility_format2bitfield(ast_channel_rawwriteformat(chan)) & (1 << idx)) {
 								break;
 							}
 						}

Modified: team/group/media_formats/channels/chan_phone.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_phone.c?view=diff&rev=408871&r1=408870&r2=408871
==============================================================================
--- team/group/media_formats/channels/chan_phone.c (original)
+++ team/group/media_formats/channels/chan_phone.c Mon Feb 24 07:55:02 2014
@@ -68,6 +68,7 @@
 #include "asterisk/stringfields.h"
 #include "asterisk/musiconhold.h"
 #include "asterisk/format_cache.h"
+#include "asterisk/format_compatibility.h"
 
 #include "chan_phone.h"
 
@@ -788,12 +789,12 @@
 		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, frame->subclass.format->codec->original_id)) {
+			if (ioctl(p->fd, PHONE_PLAY_CODEC, ast_format_compatibility_format2bitfield(frame->subclass.format))) {
 				ast_log(LOG_WARNING, "Unable to set %s mode\n",
 					frame->subclass.format->codec->name);
 				return -1;
 			}
-			if (ioctl(p->fd, PHONE_REC_CODEC, frame->subclass.format->codec->original_id)) {
+			if (ioctl(p->fd, PHONE_REC_CODEC, ast_format_compatibility_format2bitfield(frame->subclass.format))) {
 				ast_log(LOG_WARNING, "Unable to set %s mode\n",
 					frame->subclass.format->codec->name);
 				return -1;

Modified: team/group/media_formats/codecs/codec_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/codecs/codec_dahdi.c?view=diff&rev=408871&r1=408870&r2=408871
==============================================================================
--- team/group/media_formats/codecs/codec_dahdi.c (original)
+++ team/group/media_formats/codecs/codec_dahdi.c Mon Feb 24 07:55:02 2014
@@ -51,6 +51,7 @@
 #include "asterisk/utils.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/ulaw.h"
+#include "asterisk/format_compatibility.h"
 
 #define BUFFER_SIZE 8000
 
@@ -500,11 +501,11 @@
 		return -1;
 	}
 
-	dahdip->fmts.srcfmt = src_codec->original_id;
-	dahdip->fmts.dstfmt = dst_codec->original_id;
+	dahdip->fmts.srcfmt = ast_format_compatibility_codec2bitfield(src_codec);
+	dahdip->fmts.dstfmt = ast_format_compatibility_codec2bitfield(dst_codec);
 
 	pvt->f.frametype = AST_FRAME_VOICE;
-	pvt->f.subclass.format = ast_format_copy(dahdi_format_to_cached(dst_codec->original_id));
+	pvt->f.subclass.format = ast_format_copy(dahdi_format_to_cached(dahdip->fmts.dstfmt));
 	pvt->f.mallocd = 0;
 	pvt->f.offset = AST_FRIENDLY_OFFSET;
 	pvt->f.src = pvt->t->name;
@@ -587,9 +588,9 @@
 
 static int is_encoder(struct translator *zt)
 {
-	if ((zt->t.core_src_codec->original_id == DAHDI_FORMAT_ULAW) ||
-		(zt->t.core_src_codec->original_id == DAHDI_FORMAT_ALAW) ||
-		(zt->t.core_src_codec->original_id == DAHDI_FORMAT_SLINEAR)) {
+	if ((zt->t.core_src_codec == ast_format_ulaw->codec) ||
+		(zt->t.core_src_codec == ast_format_alaw->codec) ||
+		(zt->t.core_src_codec == ast_format_slin->codec)) {
 		return 1;
 	} else {
 		return 0;
@@ -644,10 +645,10 @@
 
 	AST_LIST_LOCK(&translators);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, cur, entry) {
-		if (cur->t.core_src_codec->original_id != src)
+		if (ast_format_compatibility_codec2bitfield(cur->t.core_src_codec) != src)
 			continue;
 
-		if (cur->t.core_dst_codec->original_id != dst)
+		if (ast_format_compatibility_codec2bitfield(cur->t.core_dst_codec) != dst)
 			continue;
 
 		AST_LIST_REMOVE_CURRENT(entry);

Modified: team/group/media_formats/include/asterisk/codec.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/codec.h?view=diff&rev=408871&r1=408870&r2=408871
==============================================================================
--- team/group/media_formats/include/asterisk/codec.h (original)
+++ team/group/media_formats/include/asterisk/codec.h Mon Feb 24 07:55:02 2014
@@ -39,8 +39,6 @@
 struct ast_codec {
 	/*! \brief Internal unique identifier for this codec, set at registration time (starts at 1) */
 	unsigned int id;
-	/*! \brief Original Asterisk codec identifier */
-	uint64_t original_id;
 	/*! \brief Name for this codec */
 	const char *name;
 	/*! \brief Brief description */

Modified: team/group/media_formats/include/asterisk/format_compatibility.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/format_compatibility.h?view=diff&rev=408871&r1=408870&r2=408871
==============================================================================
--- team/group/media_formats/include/asterisk/format_compatibility.h (original)
+++ team/group/media_formats/include/asterisk/format_compatibility.h Mon Feb 24 07:55:02 2014
@@ -27,6 +27,7 @@
 #define _AST_FORMAT_COMPATIBILITY_H_
 
 struct ast_format;
+struct ast_codec;
 struct ast_format_cap;
 
 /*!
@@ -38,6 +39,16 @@
  * \retval zero format not supported
  */
 uint64_t ast_format_compatibility_format2bitfield(const struct ast_format *format);
+
+/*!
+ * \brief Convert a codec structure to its respective bitfield
+ *
+ * \param codec The media codec
+ *
+ * \retval non-zero success
+ * \retval zero format not supported
+ */
+uint64_t ast_format_compatibility_codec2bitfield(const struct ast_codec *codec);
 
 /*!
  * \brief Convert a bitfield to its respective format structure

Modified: team/group/media_formats/main/codec_builtin.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/codec_builtin.c?view=diff&rev=408871&r1=408870&r2=408871
==============================================================================
--- team/group/media_formats/main/codec_builtin.c (original)
+++ team/group/media_formats/main/codec_builtin.c Mon Feb 24 07:55:02 2014
@@ -92,7 +92,6 @@
 	.name = "g723",
 	.description = "G.723.1",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 0),
 	.sample_rate = 8000,
 	.minimum_ms = 30,
 	.maximum_ms = 300,
@@ -116,7 +115,6 @@
 	.name = "ulaw",
 	.description = "G.711 u-law",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 2),
 	.sample_rate = 8000,
 	.minimum_ms = 10,
 	.maximum_ms = 150,
@@ -130,7 +128,6 @@
 	.name = "alaw",
 	.description = "G.711 a-law",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 3),
 	.sample_rate = 8000,
 	.minimum_ms = 10,
 	.maximum_ms = 150,
@@ -154,7 +151,6 @@
 	.name = "gsm",
 	.description = "GSM",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 1),
 	.sample_rate = 8000,
 	.minimum_ms = 20,
 	.maximum_ms = 300,
@@ -178,7 +174,6 @@
 	.name = "g726",
 	.description = "G.726 RFC3551",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 11),
 	.sample_rate = 8000,
 	.minimum_ms = 10,
 	.maximum_ms = 300,
@@ -192,7 +187,6 @@
 	.name = "g726aal2",
 	.description = "G.726 AAL2",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 4),
 	.sample_rate = 8000,
 	.minimum_ms = 10,
 	.maximum_ms = 300,
@@ -206,7 +200,6 @@
 	.name = "adpcm",
 	.description = "ADPCM",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 5),
 	.sample_rate = 8000,
 	.minimum_ms = 10,
 	.maximum_ms = 300,
@@ -230,7 +223,6 @@
 	.name = "slin",
 	.description = "16 bit Signed Linear PCM",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 6),
 	.sample_rate = 8000,
 	.minimum_ms = 10,
 	.maximum_ms = 70,
@@ -257,7 +249,6 @@
 	.name = "slin",
 	.description = "16 bit Signed Linear PCM (16kHz)",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 15),
 	.sample_rate = 16000,
 	.minimum_ms = 10,
 	.maximum_ms = 70,
@@ -359,7 +350,6 @@
 	.name = "lpc10",
 	.description = "LPC10",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 7),
 	.sample_rate = 8000,
 	.minimum_ms = 20,
 	.maximum_ms = 20,
@@ -382,7 +372,6 @@
 	.name = "g729",
 	.description = "G.729A",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 8),
 	.sample_rate = 8000,
 	.minimum_ms = 10,
 	.maximum_ms = 230,
@@ -510,7 +499,6 @@
 	.name = "speex",
 	.description = "SpeeX",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 9),
 	.sample_rate = 8000,
 	.minimum_ms = 10,
 	.maximum_ms = 60,
@@ -528,7 +516,6 @@
 	.name = "speex",
 	.description = "SpeeX 16khz",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 33),
 	.sample_rate = 16000,
 	.minimum_ms = 10,
 	.maximum_ms = 60,
@@ -563,7 +550,6 @@
 	.name = "ilbc",
 	.description = "iLBC",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 10),
 	.sample_rate = 8000,
 	.minimum_ms = 30,
 	.maximum_ms = 30,
@@ -576,7 +562,6 @@
 	.name = "g722",
 	.description = "G722",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 12),
 	.sample_rate = 16000,
 	.minimum_ms = 10,
 	.maximum_ms = 150,
@@ -600,7 +585,6 @@
 	.name = "siren7",
 	.description = "ITU G.722.1 (Siren7, licensed from Polycom)",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 13),
 	.sample_rate = 16000,
 	.minimum_ms = 20,
 	.maximum_ms = 80,
@@ -624,7 +608,6 @@
 	.name = "siren14",
 	.description = "ITU G.722.1 Annex C, (Siren14, licensed from Polycom)",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 14),
 	.sample_rate = 32000,
 	.minimum_ms = 20,
 	.maximum_ms = 80,
@@ -638,7 +621,6 @@
 	.name = "testlaw",
 	.description = "G.711 test-law",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 47),
 	.sample_rate = 8000,
 	.minimum_ms = 10,
 	.maximum_ms = 150,
@@ -662,7 +644,6 @@
 	.name = "g719",
 	.description = "ITU G.719",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 32),
 	.sample_rate = 48000,
 	.minimum_ms = 20,
 	.maximum_ms = 80,
@@ -676,7 +657,6 @@
 	.name = "opus",
 	.description = "Opus Codec",
 	.type = AST_MEDIA_TYPE_AUDIO,
-	.original_id = (1ULL << 34),
 	.sample_rate = 48000,
 	.minimum_ms = 20,
 	.maximum_ms = 60,
@@ -688,70 +668,60 @@
 	.name = "jpeg",
 	.description = "JPEG image",
 	.type = AST_MEDIA_TYPE_IMAGE,
-	.original_id = (1ULL << 16),
 };
 
 static struct ast_codec png = {
 	.name = "png",
 	.description = "PNG Image",
 	.type = AST_MEDIA_TYPE_IMAGE,
-	.original_id = (1ULL << 17),
 };
 
 static struct ast_codec h261 = {
 	.name = "h261",
 	.description = "H.261 video",
 	.type = AST_MEDIA_TYPE_VIDEO,
-	.original_id = (1ULL << 18),
 };
 
 static struct ast_codec h263 = {
 	.name = "h263",
 	.description = "H.263 video",
 	.type = AST_MEDIA_TYPE_VIDEO,
-	.original_id = (1ULL << 19),
 };
 
 static struct ast_codec h263p = {
 	.name = "h263p",
 	.description = "H.263+ video",
 	.type = AST_MEDIA_TYPE_VIDEO,
-	.original_id = (1ULL << 20),
 };
 
 static struct ast_codec h264 = {
 	.name = "h264",
 	.description = "H.264 video",
 	.type = AST_MEDIA_TYPE_VIDEO,
-	.original_id = (1ULL << 21),
 };
 
 static struct ast_codec mpeg4 = {
 	.name = "mpeg4",
 	.description = "MPEG4 video",
 	.type = AST_MEDIA_TYPE_VIDEO,
-	.original_id = (1ULL << 22),
 };
 
 static struct ast_codec vp8 = {
 	.name = "vp8",
 	.description = "VP8 video",
 	.type = AST_MEDIA_TYPE_VIDEO,
-	.original_id = (1ULL << 23),
 };
 
 static struct ast_codec t140red = {
 	.name = "red",
 	.description = "T.140 Realtime Text with redundancy",
 	.type = AST_MEDIA_TYPE_TEXT,
-	.original_id = (1ULL << 26),
 };
 
 static struct ast_codec t140 = {
 	.name = "t140",
 	.description = "Passthrough T.140 Realtime Text",
 	.type = AST_MEDIA_TYPE_TEXT,
-	.original_id = (1ULL << 27),
 };
 
 int ast_codec_builtin_init(void)

Modified: team/group/media_formats/main/format_compatibility.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/format_compatibility.c?view=diff&rev=408871&r1=408870&r2=408871
==============================================================================
--- team/group/media_formats/main/format_compatibility.c (original)
+++ team/group/media_formats/main/format_compatibility.c Mon Feb 24 07:55:02 2014
@@ -48,7 +48,7 @@
 		return (1ULL << 3);
 	} else if (ast_format_cmp(format, ast_format_g726_aal2) == AST_FORMAT_CMP_EQUAL) {
 		return (1ULL << 4);
-	} else if (ast_format_cmp(format, ast_format_g726_adpcm) == AST_FORMAT_CMP_EQUAL) {
+	} else if (ast_format_cmp(format, ast_format_adpcm) == AST_FORMAT_CMP_EQUAL) {
 		return (1ULL << 5);
 	} else if (ast_format_cmp(format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
 		return (1ULL << 6);
@@ -97,6 +97,73 @@
 	} else if (ast_format_cmp(format, ast_format_t140_red) == AST_FORMAT_CMP_EQUAL) {
 		return (1ULL << 26);
 	} else if (ast_format_cmp(format, ast_format_t140) == AST_FORMAT_CMP_EQUAL) {
+		return (1ULL << 27);
+	}
+
+	return 0;
+}
+
+uint64_t ast_format_compatibility_codec2bitfield(const struct ast_codec *codec)
+{
+	if (codec == ast_format_g723->codec) {
+		return (1ULL << 0);
+	} else if (codec == ast_format_gsm->codec) {
+		return (1ULL << 1);
+	} else if (codec == ast_format_ulaw->codec) {
+		return (1ULL << 2);
+	} else if (codec == ast_format_alaw->codec) {
+		return (1ULL << 3);
+	} else if (codec == ast_format_g726_aal2->codec) {
+		return (1ULL << 4);
+	} else if (codec == ast_format_adpcm->codec) {
+		return (1ULL << 5);
+	} else if (codec == ast_format_slin->codec) {
+		return (1ULL << 6);
+	} else if (codec == ast_format_lpc10->codec) {
+		return (1ULL << 7);
+	} else if (codec == ast_format_g729->codec) {
+		return (1ULL << 8);
+	} else if (codec == ast_format_speex->codec) {
+		return (1ULL << 9);
+	} else if (codec == ast_format_ilbc->codec) {
+		return (1ULL << 10);
+	} else if (codec == ast_format_g726->codec) {
+		return (1ULL << 11);
+	} else if (codec == ast_format_g722->codec) {
+		return (1ULL << 12);
+	} else if (codec == ast_format_siren7->codec) {
+		return (1ULL << 13);
+	} else if (codec == ast_format_siren14->codec) {
+		return (1ULL << 14);
+	} else if (codec == ast_format_slin16->codec) {
+		return (1ULL << 15);
+	} else if (codec == ast_format_g719->codec) {
+		return (1ULL << 32);
+	} else if (codec == ast_format_speex16->codec) {
+		return (1ULL << 33);
+	} else if (codec == ast_format_opus->codec) {
+		return (1ULL << 34);
+	} else if (codec == ast_format_testlaw->codec) {
+		return (1ULL << 47);
+	} else if (codec == ast_format_h261->codec) {
+		return (1ULL << 18);
+	} else if (codec == ast_format_h263->codec) {
+		return (1ULL << 19);
+	} else if (codec == ast_format_h263p->codec) {
+		return (1ULL << 20);
+	} else if (codec == ast_format_h264->codec) {
+		return (1ULL << 21);
+	} else if (codec == ast_format_mp4->codec) {
+		return (1ULL << 22);
+	} else if (codec == ast_format_vp8->codec) {
+		return (1ULL << 23);
+	} else if (codec == ast_format_jpeg->codec) {
+		return (1ULL << 16);
+	} else if (codec == ast_format_png->codec) {
+		return (1ULL << 17);
+	} else if (codec == ast_format_t140_red->codec) {
+		return (1ULL << 26);
+	} else if (codec == ast_format_t140->codec) {
 		return (1ULL << 27);
 	}
 




More information about the asterisk-commits mailing list