[svn-commits] file: branch group/media_formats r410622 - in /team/group/media_formats: chan...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Mar 14 16:23:50 CDT 2014


Author: file
Date: Fri Mar 14 16:23:45 2014
New Revision: 410622

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410622
Log:
After hmming and hawing I've decided to add ast_codec_pref back in to format compatibility.

Modified:
    team/group/media_formats/channels/chan_iax2.c
    team/group/media_formats/include/asterisk/format_compatibility.h

Modified: team/group/media_formats/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_iax2.c?view=diff&rev=410622&r1=410621&r2=410622
==============================================================================
--- team/group/media_formats/channels/chan_iax2.c (original)
+++ team/group/media_formats/channels/chan_iax2.c Fri Mar 14 16:23:45 2014
@@ -116,6 +116,8 @@
 #include "asterisk/stasis.h"
 #include "asterisk/stasis_system.h"
 #include "asterisk/stasis_channels.h"
+#include "asterisk/format_cache.h"
+#include "asterisk/format_compatibility.h"
 
 #include "iax2/include/iax2.h"
 #include "iax2/include/firmware.h"
@@ -347,22 +349,22 @@
 #define IAX_CAPABILITY_FULLBANDWIDTH	0xFFFF
 /* T1, maybe ISDN */
 #define IAX_CAPABILITY_MEDBANDWIDTH (IAX_CAPABILITY_FULLBANDWIDTH & \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_SLINEAR) &      \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_SLINEAR16) &    \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_SIREN7) &       \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_SIREN14) &      \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_G719) &         \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_ULAW) &         \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_ALAW) &         \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_G722))
+                     ~ast_format_compatibility_format2bitfield(ast_format_slin) &      \
+                     ~ast_format_compatibility_format2bitfield(ast_format_slin16) &    \
+                     ~ast_format_compatibility_format2bitfield(ast_format_siren7) &       \
+                     ~ast_format_compatibility_format2bitfield(ast_format_siren14) &      \
+                     ~ast_format_compatibility_format2bitfield(ast_format_g719) &         \
+                     ~ast_format_compatibility_format2bitfield(ast_format_ulaw) &         \
+                     ~ast_format_compatibility_format2bitfield(ast_format_alaw) &         \
+                     ~ast_format_compatibility_format2bitfield(ast_format_g722))
 /* A modem */
 #define IAX_CAPABILITY_LOWBANDWIDTH (IAX_CAPABILITY_MEDBANDWIDTH & \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_G726) &         \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_G726_AAL2) &    \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_ADPCM))
+                     ~ast_format_compatibility_format2bitfield(ast_format_g726) &         \
+                     ~ast_format_compatibility_format2bitfield(ast_format_g726_aal2) &    \
+                     ~ast_format_compatibility_format2bitfield(ast_format_adpcm))
 
 #define IAX_CAPABILITY_LOWFREE      (IAX_CAPABILITY_LOWBANDWIDTH & \
-                     ~ast_format_id_to_old_bitfield(AST_FORMAT_G723_1))
+                     ~ast_format_compatibility_format2bitfield(ast_format_g723))
 
 
 #define DEFAULT_MAXMS		2000		/* Must be faster than 2 seconds by default */
@@ -6385,7 +6387,7 @@
 		/* High two bytes are the same on timestamp, or sending on a trunk */ &&
 	    (f->frametype == AST_FRAME_VOICE)
 		/* is a voice frame */ &&
-		(f->subclass.format.id == ast_format_id_from_old_bitfield(pvt->svoiceformat))
+		(ast_format_cmp(f->subclass.format, ast_format_compatibility_bitfield2format(pvt->svoiceformat)))
 		/* is the same type */ ) {
 			/* Force immediate rather than delayed transmission */
 			now = 1;
@@ -6399,7 +6401,7 @@
 		 * Otherwise send a mini video frame
 		 */
 		if (((fts & 0xFFFF8000L) == (pvt->lastvsent & 0xFFFF8000L)) &&
-		    ((f->subclass.format.id) == ast_format_id_from_old_bitfield(pvt->svideoformat))
+		(ast_format_cmp(f->subclass.format, ast_format_compatibility_bitfield2format(pvt->svideoformat)))
 		   ) {
 			now = 1;
 			sendmini = 1;
@@ -10853,9 +10855,9 @@
 						ast_verb(3, "Format for call is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(iaxs[fr->callno]->owner)));
 
 						/* Setup read/write formats properly. */
-						if (ast_channel_writeformat(iaxs[fr->callno]->owner)->id)
+						if (ast_channel_writeformat(iaxs[fr->callno]->owner))
 							ast_set_write_format(iaxs[fr->callno]->owner, ast_channel_writeformat(iaxs[fr->callno]->owner));
-						if (ast_channel_readformat(iaxs[fr->callno]->owner)->id)
+						if (ast_channel_readformat(iaxs[fr->callno]->owner))
 							ast_set_read_format(iaxs[fr->callno]->owner, ast_channel_readformat(iaxs[fr->callno]->owner));
 						ast_channel_unlock(iaxs[fr->callno]->owner);
 					}
@@ -11648,7 +11650,7 @@
 	if (f.datalen && (f.frametype == AST_FRAME_VOICE)) {
 		f.samples = ast_codec_get_samples(&f);
 		/* We need to byteswap incoming slinear samples from network byte order */
-		if (f.subclass.format.id == AST_FORMAT_SLINEAR)
+		if (ast_format_cmp(f.subclass, ast_format_slin) == AST_FORMAT_CMP_EQUAL)
 			ast_frame_byteswap_be(&f);
 	} else
 		f.samples = 0;
@@ -14452,7 +14454,8 @@
 		ast_context_destroy(con, "IAX2");
 	ast_unload_realtime("iaxpeers");
 
-	iax2_tech.capabilities = ast_format_cap_destroy(iax2_tech.capabilities);
+	ao2_ref(iax2_tech.capabilities, -1);
+	iax2_tech.capabilities = NULL;
 	return 0;
 }
 
@@ -14762,10 +14765,10 @@
 	int x = 0;
 	struct iax2_registry *reg = NULL;
 
-	if (!(iax2_tech.capabilities = ast_format_cap_alloc(0))) {
+	if (!(iax2_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	ast_format_cap_add_all(iax2_tech.capabilities);
+	ast_format_cap_add_all_by_type(iax2_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
 
 	if (load_objects()) {
 		return AST_MODULE_LOAD_FAILURE;

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=410622&r1=410621&r2=410622
==============================================================================
--- team/group/media_formats/include/asterisk/format_compatibility.h (original)
+++ team/group/media_formats/include/asterisk/format_compatibility.h Fri Mar 14 16:23:45 2014
@@ -29,6 +29,14 @@
 struct ast_format;
 struct ast_codec;
 struct ast_format_cap;
+
+#define AST_CODEC_PREF_SIZE 64
+struct ast_codec_pref {
+	/*! This array represents the format id's index in the global format list. */
+	char order[AST_CODEC_PREF_SIZE];
+	/*! This array represents the format's framing size if present. */
+	int framing[AST_CODEC_PREF_SIZE];
+};
 
 /*!
  * \brief Convert a format structure to its respective bitfield




More information about the svn-commits mailing list