[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r301728 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 13 10:06:52 CST 2011


Author: dvossel
Date: Thu Jan 13 10:06:45 2011
New Revision: 301728

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=301728
Log:
fixes an issue with format allow and disallow config parsing

Modified:
    team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c
    team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
    team/dvossel/fixtheworld_phase1_step3/main/format_pref.c
    team/dvossel/fixtheworld_phase1_step3/main/frame.c

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c?view=diff&rev=301728&r1=301727&r2=301728
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c Thu Jan 13 10:06:45 2011
@@ -4385,7 +4385,6 @@
 	ast_string_field_free_memory(peer);
 
 	peer->caps = ast_cap_destroy(peer->caps);
-	sip_cfg.caps = ast_cap_destroy(sip_cfg.caps);
 }
 
 /*! \brief Update peer data in database (if used) */
@@ -29333,6 +29332,8 @@
 	sip_unregister_tests();
 
 	ast_cap_destroy(sip_tech.capabilities);
+	sip_cfg.caps = ast_cap_destroy(sip_cfg.caps);
+
 	return 0;
 }
 

Modified: team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_cap.c?view=diff&rev=301728&r1=301727&r2=301728
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_cap.c Thu Jan 13 10:06:45 2011
@@ -171,7 +171,7 @@
 	if (!cap) {
 		return 1;
 	}
-	return ao2_container_count(cap->formats) > 0 ? 1 : 0;
+	return ao2_container_count(cap->formats) == 0 ? 1 : 0;
 }
 
 static int find_exact_cb(void *obj, void *arg, int flag)
@@ -256,7 +256,7 @@
 
 void ast_cap_remove_all(struct ast_cap *cap)
 {
-	ao2_callback(cap->formats, OBJ_NODATA | OBJ_UNLINK, NULL, NULL);
+	ao2_callback(cap->formats, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, NULL, NULL);
 }
 
 int ast_cap_iscompatible(const struct ast_cap *cap, const struct ast_format *format)

Modified: team/dvossel/fixtheworld_phase1_step3/main/format_pref.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_pref.c?view=diff&rev=301728&r1=301727&r2=301728
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_pref.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_pref.c Thu Jan 13 10:06:45 2011
@@ -94,7 +94,7 @@
 
 struct ast_format *ast_codec_pref_index(struct ast_codec_pref *pref, int idx, struct ast_format *result)
 {
-	if ((idx >= 0) && (idx < sizeof(pref->order))) {
+	if ((idx >= 0) && (idx < sizeof(pref->order)) && pref->formats[idx].id) {
 		ast_format_copy(&pref->formats[idx], result);
 	} else {
 		return NULL;

Modified: team/dvossel/fixtheworld_phase1_step3/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/frame.c?view=diff&rev=301728&r1=301727&r2=301728
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/frame.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/frame.c Thu Jan 13 10:06:45 2011
@@ -987,7 +987,7 @@
 
 int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_cap *cap, const char *list, int allowing) 
 {
-	int errors = 0, framems = 0;
+	int errors = 0, framems = 0, all = 0;
 	char *parse = NULL, *this = NULL, *psize = NULL;
 	struct ast_format format;
 
@@ -1004,31 +1004,41 @@
 				ast_log(LOG_WARNING, "Bad packetization value for codec %s\n", this);
 			}
 		}
-/* XXX todohere, all the 'all' case back. if this is still here for the review, say something*/
-		if (!ast_getformatbyname(this, &format)) {
+		all = strcasecmp(this, "all") ? 0 : 1;
+
+		if (!all && !ast_getformatbyname(this, &format)) {
 			ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", this);
 			errors++;
 			continue;
 		}
 
 		if (cap) {
-			if (allowing)
-				ast_cap_add(cap, &format);
-			else
-				ast_cap_remove(cap, &format);
+			if (allowing) {
+				if (all) {
+					ast_cap_add_all(cap);
+				} else {
+					ast_cap_add(cap, &format);
+				}
+			} else {
+				if (all) {
+					ast_cap_remove_all(cap);
+				} else {
+					ast_cap_remove(cap, &format);
+				}
+			}
 		}
 
 		/* Set up a preference list for audio. Do not include video in preferences 
 		   since we can not transcode video and have to use whatever is offered
 		 */
 		if (pref && (AST_FORMAT_GET_TYPE(format.id) == AST_FORMAT_TYPE_AUDIO)) {
-			if (strcasecmp(this, "all")) {
+			if (!all) {
 				if (allowing) {
 					ast_codec_pref_append(pref, &format);
 					ast_codec_pref_setsize(pref, &format, framems);
+				} else {
+					ast_codec_pref_remove(pref, &format);
 				}
-				else
-					ast_codec_pref_remove(pref, &format);
 			} else if (!allowing) {
 				memset(pref, 0, sizeof(*pref));
 			}




More information about the asterisk-commits mailing list