[asterisk-commits] rmudgett: branch rmudgett/iax_fracks r419913 - in /team/rmudgett/iax_fracks/c...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 1 21:46:47 CDT 2014


Author: rmudgett
Date: Fri Aug  1 21:46:43 2014
New Revision: 419913

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419913
Log:
chan_iax2: Minor tweaks

Modified:
    team/rmudgett/iax_fracks/channels/chan_iax2.c
    team/rmudgett/iax_fracks/channels/iax2/codec_pref.c
    team/rmudgett/iax_fracks/channels/iax2/format_compatibility.c
    team/rmudgett/iax_fracks/channels/iax2/include/format_compatibility.h

Modified: team/rmudgett/iax_fracks/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/iax_fracks/channels/chan_iax2.c?view=diff&rev=419913&r1=419912&r2=419913
==============================================================================
--- team/rmudgett/iax_fracks/channels/chan_iax2.c (original)
+++ team/rmudgett/iax_fracks/channels/chan_iax2.c Fri Aug  1 21:46:43 2014
@@ -1830,6 +1830,10 @@
 		}
 
 		pref_format = ast_format_compatibility_bitfield2format(pref_bitfield);
+		if (!pref_format) {
+			/* The bitfield is not associated with any format. */
+			continue;
+		}
 		found_format = ast_format_cap_get_compatible_format(cap, pref_format);
 		if (found_format) {
 			break;
@@ -4610,7 +4614,6 @@
 {
 	struct iax2_peer *peer;
 	int res = -1;
-	struct iax2_codec_pref ourprefs;
 
 	ast_clear_flag64(cai, IAX_SENDANI | IAX_TRUNK);
 	cai->sockfd = defaultsockfd;
@@ -4636,18 +4639,19 @@
 		 * However, move the calling channel's native codec to
 		 * the top of the preference list.
 		 */
-		ourprefs = prefs_global;
+		cai->prefs = prefs_global;
 		if (c) {
 			int i;
 
 			for (i = 0; i < ast_format_cap_count(ast_channel_nativeformats(c)); i++) {
 				struct ast_format *format = ast_format_cap_get_format(
 					ast_channel_nativeformats(c), i);
-				iax2_codec_pref_prepend(&ourprefs, format, ast_format_cap_get_format_framing(ast_channel_nativeformats(c), format), 1);
+				iax2_codec_pref_prepend(&cai->prefs, format,
+					ast_format_cap_get_format_framing(ast_channel_nativeformats(c), format),
+					1);
 				ao2_ref(format, -1);
 			}
 		}
-		cai->prefs = ourprefs;
 		return 0;
 	}
 
@@ -4668,7 +4672,7 @@
 	cai->encmethods = peer->encmethods;
 	cai->sockfd = peer->sockfd;
 	cai->adsi = peer->adsi;
-	ourprefs = peer->prefs;
+	cai->prefs = peer->prefs;
 	/* Move the calling channel's native codec to the top of the preference list */
 	if (c) {
 		int i;
@@ -4676,11 +4680,12 @@
 		for (i = 0; i < ast_format_cap_count(ast_channel_nativeformats(c)); i++) {
 			struct ast_format *tmpfmt = ast_format_cap_get_format(
 				ast_channel_nativeformats(c), i);
-			iax2_codec_pref_prepend(&ourprefs, tmpfmt, ast_format_cap_get_format_framing(ast_channel_nativeformats(c), tmpfmt), 1);
+			iax2_codec_pref_prepend(&cai->prefs, tmpfmt,
+				ast_format_cap_get_format_framing(ast_channel_nativeformats(c), tmpfmt),
+				1);
 			ao2_ref(tmpfmt, -1);
 		}
 	}
-	cai->prefs = ourprefs;
 	ast_copy_string(cai->context, peer->context, sizeof(cai->context));
 	ast_copy_string(cai->peercontext, peer->peercontext, sizeof(cai->peercontext));
 	ast_copy_string(cai->username, peer->username, sizeof(cai->username));
@@ -10854,7 +10859,7 @@
 									if(ast_test_flag64(iaxs[fr->callno], IAX_CODEC_NOPREFS)) {
 										using_prefs = ast_test_flag64(iaxs[fr->callno], IAX_CODEC_NOCAP) ? "reqonly" : "disabled";
 										memset(&pref, 0, sizeof(pref));
-										format = iax2_format_compatibility_bitfield2best(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+										format = iax2_format_compatibility_best(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
 										strcpy(caller_pref_buf,"disabled");
 										strcpy(host_pref_buf,"disabled");
 									} else {
@@ -10870,7 +10875,7 @@
 											}
 											format = iax2_codec_choose(&pref, iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
 										} else /* if no codec_prefs IE do it the old way */
-											format = iax2_format_compatibility_bitfield2best(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+											format = iax2_format_compatibility_best(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
 									}
 								}
 
@@ -11316,7 +11321,7 @@
 									memset(&pref, 0, sizeof(pref));
 									format = ast_test_flag64(iaxs[fr->callno], IAX_CODEC_NOCAP)
 										? iaxs[fr->callno]->peerformat
-										: iax2_format_compatibility_bitfield2best(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+										: iax2_format_compatibility_best(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
 									strcpy(caller_pref_buf,"disabled");
 									strcpy(host_pref_buf,"disabled");
 								} else {
@@ -11332,7 +11337,7 @@
 										}
 										format = iax2_codec_choose(&pref, iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
 									} else /* if no codec_prefs IE do it the old way */
-										format = iax2_format_compatibility_bitfield2best(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+										format = iax2_format_compatibility_best(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
 								}
 							}
 							if (!format) {

Modified: team/rmudgett/iax_fracks/channels/iax2/codec_pref.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/iax_fracks/channels/iax2/codec_pref.c?view=diff&rev=419913&r1=419912&r2=419913
==============================================================================
--- team/rmudgett/iax_fracks/channels/iax2/codec_pref.c (original)
+++ team/rmudgett/iax_fracks/channels/iax2/codec_pref.c Fri Aug  1 21:46:43 2014
@@ -104,10 +104,8 @@
 		}
 
 		pref_format = ast_format_compatibility_bitfield2format(pref_bitfield);
-		if (pref_format) {
-			if (ast_format_cap_append(cap, pref_format, pref->framing[idx])) {
-				return -1;
-			}
+		if (pref_format && ast_format_cap_append(cap, pref_format, pref->framing[idx])) {
+			return -1;
 		}
 	}
 	return 0;
@@ -123,11 +121,11 @@
 		int idx;
 
 		for (idx = 0; bitfield && idx < ARRAY_LEN(prefs->order); ++idx) {
-			if (!prefs->order[idx]) {
+			best_bitfield = iax2_codec_pref_order_value_to_format_bitfield(prefs->order[idx]);
+			if (!best_bitfield) {
 				break;
 			}
 
-			best_bitfield = iax2_codec_pref_order_value_to_format_bitfield(prefs->order[idx]);
 			if (best_bitfield & bitfield) {
 				format = ast_format_compatibility_bitfield2format(best_bitfield);
 				if (format && ast_format_cap_append(cap, format, prefs->framing[idx])) {
@@ -142,7 +140,7 @@
 
 	/* Add the hard coded "best" codecs. */
 	while (bitfield) {
-		best_bitfield = iax2_format_compatibility_bitfield2best(bitfield);
+		best_bitfield = iax2_format_compatibility_best(bitfield);
 		if (!best_bitfield) {
 			/* No more codecs considered best. */
 			break;
@@ -304,12 +302,12 @@
 	for (idx = ARRAY_LEN(pref->order); idx--;) {
 		uint64_t pref_bitfield;
 
-		if (!pref->order[idx]) {
+		pref_bitfield = iax2_codec_pref_order_value_to_format_bitfield(pref->order[idx]);
+		if (!pref_bitfield) {
 			continue;
 		}
 
 		/* If this format isn't in the bitfield, remove it from the prefs. */
-		pref_bitfield = iax2_codec_pref_order_value_to_format_bitfield(pref->order[idx]);
 		if (!(pref_bitfield & bitfield)) {
 			codec_pref_remove_index(pref, idx);
 		}
@@ -441,7 +439,7 @@
 
 	/* Add the "best" codecs first. */
 	while (working_bitfield) {
-		best_bitfield = iax2_format_compatibility_bitfield2best(working_bitfield);
+		best_bitfield = iax2_format_compatibility_best(working_bitfield);
 		if (!best_bitfield) {
 			/* No more codecs considered best. */
 			break;

Modified: team/rmudgett/iax_fracks/channels/iax2/format_compatibility.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/iax_fracks/channels/iax2/format_compatibility.c?view=diff&rev=419913&r1=419912&r2=419913
==============================================================================
--- team/rmudgett/iax_fracks/channels/iax2/format_compatibility.c (original)
+++ team/rmudgett/iax_fracks/channels/iax2/format_compatibility.c Fri Aug  1 21:46:43 2014
@@ -78,15 +78,14 @@
 	return 0;
 }
 
-uint64_t iax2_format_compatibility_bitfield2best(uint64_t formats)
+uint64_t iax2_format_compatibility_best(uint64_t formats)
 {
 	/*
 	 * This just our opinion, expressed in code.  We are
 	 * asked to choose the best codec to use, given no
 	 * information.
 	 */
-	static const uint64_t best[] =
-	{
+	static const uint64_t best[] = {
 		/*! Okay, ulaw is used by all telephony equipment, so start with it */
 		AST_FORMAT_ULAW,
 		/*! Unless of course, you're a silly European, so then prefer ALAW */

Modified: team/rmudgett/iax_fracks/channels/iax2/include/format_compatibility.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/iax_fracks/channels/iax2/include/format_compatibility.h?view=diff&rev=419913&r1=419912&r2=419913
==============================================================================
--- team/rmudgett/iax_fracks/channels/iax2/include/format_compatibility.h (original)
+++ team/rmudgett/iax_fracks/channels/iax2/include/format_compatibility.h Fri Aug  1 21:46:43 2014
@@ -60,6 +60,6 @@
  * \retval non-zero Best format out of the given formats.
  * \retval zero No formats present or no formats considered best.
  */
-uint64_t iax2_format_compatibility_bitfield2best(uint64_t formats);
+uint64_t iax2_format_compatibility_best(uint64_t formats);
 
 #endif /* _IAX2_FORMAT_COMPATIBILITY_H */




More information about the asterisk-commits mailing list