[svn-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r301781 - in /team/dvossel/f...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jan 13 17:06:53 CST 2011


Author: dvossel
Date: Thu Jan 13 17:06:48 2011
New Revision: 301781

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=301781
Log:
addition of ast_cap_copy2 function

Modified:
    team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c
    team/dvossel/fixtheworld_phase1_step3/main/channel.c
    team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.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=301781&r1=301780&r2=301781
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c Thu Jan 13 17:06:48 2011
@@ -6604,8 +6604,12 @@
 
 	/* Set the native formats for audio  and merge in video */
 	ast_codec_choose(&i->prefs, what, 1, &fmt);
-	ast_cap_append(tmp->nativeformats, video);
-	ast_cap_append(tmp->nativeformats, text);
+	if (video) {
+		ast_cap_append(tmp->nativeformats, video);
+	}
+	if (text) {
+		ast_cap_append(tmp->nativeformats, text);
+	}
 	ast_cap_add(tmp->nativeformats, &fmt);
 	ast_debug(3, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, tmp->nativeformats));
 	ast_debug(3, "*** Joint capabilities are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, i->jointcaps));
@@ -8701,12 +8705,8 @@
 			}
 			/* We are now ready to change the sip session and p->rtp and p->vrtp with the offered codecs, since
 			   they are acceptable */
-			ast_cap_remove_all(p->jointcaps);
-			ast_cap_append(p->jointcaps, newjointcapability);                /* Our joint codec profile for this call */
-
-			ast_cap_remove_all(p->peercaps);
-			ast_cap_append(p->peercaps, newpeercapability);                  /* The other sides capability in latest offer */
-
+			ast_cap_copy2(p->jointcaps, newjointcapability);                /* Our joint codec profile for this call */
+			ast_cap_copy2(p->peercaps, newpeercapability);                  /* The other sides capability in latest offer */
 			p->jointnoncodeccapability = newnoncodeccapability;     /* DTMF capabilities */
 
 			if (ast_test_flag(&p->flags[1], SIP_PAGE2_PREFERRED_CODEC)) { /* respond with single most preferred joint codec, limiting the other side's choice */
@@ -15297,13 +15297,8 @@
 		p->amaflags = peer->amaflags;
 		p->callgroup = peer->callgroup;
 		p->pickupgroup = peer->pickupgroup;
-
-		ast_cap_remove_all(p->caps);
-		ast_cap_append(p->caps, peer->caps);
-
-		ast_cap_remove_all(p->jointcaps);
-		ast_cap_append(p->jointcaps, peer->caps);
-
+		ast_cap_copy2(p->caps, peer->caps);
+		ast_cap_copy2(p->jointcaps, peer->caps);
 		p->prefs = peer->prefs;
  		if (peer->maxforwards > 0) {
 			p->maxforwards = peer->maxforwards;
@@ -21533,8 +21528,7 @@
 				}
 				ast_queue_control(p->owner, AST_CONTROL_SRCUPDATE);
 			} else {
-				ast_cap_remove_all(p->jointcaps);
-				ast_cap_append(p->jointcaps, p->caps);
+				ast_cap_copy2(p->jointcaps, p->caps);
 				ast_debug(1, "Hm....  No sdp for the moment\n");
 				/* Some devices signal they want to be put off hold by sending a re-invite
 				   *without* an SDP, which is supposed to mean "Go back to your state"
@@ -21616,8 +21610,7 @@
 				goto request_invite_cleanup;
 			}
 		} else {	/* No SDP in invite, call control session */
-			ast_cap_remove_all(p->jointcaps);
-			ast_cap_append(p->jointcaps, p->caps);
+			ast_cap_copy2(p->jointcaps, p->caps);
 			ast_debug(2, "No SDP in Invite, third party call control\n");
 		}
 
@@ -25958,8 +25951,7 @@
 	ast_string_field_set(peer, engine, default_engine);
 	ast_sockaddr_setnull(&peer->addr);
 	ast_sockaddr_setnull(&peer->defaddr);
-	ast_cap_remove_all(peer->caps);
-	ast_cap_append(peer->caps, sip_cfg.caps);
+	ast_cap_copy2(peer->caps, sip_cfg.caps);
 	peer->maxcallbitrate = default_maxcallbitrate;
 	peer->rtptimeout = global_rtptimeout;
 	peer->rtpholdtimeout = global_rtpholdtimeout;
@@ -26752,6 +26744,8 @@
 static void sip_set_default_format_capabilities(struct ast_cap *cap)
 {
 	struct ast_format tmp_fmt;
+
+	ast_cap_remove_all(cap);
 	ast_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
 	ast_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_TESTLAW, 0));
 	ast_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_ALAW, 0));
@@ -26914,10 +26908,7 @@
 	/* Reset channel settings to default before re-configuring */
 	sip_cfg.allow_external_domains = DEFAULT_ALLOW_EXT_DOM;				/* Allow external invites */
 	sip_cfg.regcontext[0] = '\0';
-
-	ast_cap_remove_all(sip_cfg.caps);
 	sip_set_default_format_capabilities(sip_cfg.caps);
-
 	sip_cfg.regextenonqualify = DEFAULT_REGEXTENONQUALIFY;
 	sip_cfg.notifyringing = DEFAULT_NOTIFYRINGING;
 	sip_cfg.notifycid = DEFAULT_NOTIFYCID;
@@ -28032,8 +28023,7 @@
 		changed = 1;
 	}
 	if (cap && !(ast_cap_is_empty(cap) && !(ast_cap_identical(p->redircaps, cap)))) {
-		ast_cap_remove_all(p->redircaps);
-		ast_cap_append(p->redircaps, cap);
+		ast_cap_copy2(p->redircaps, cap);
 		changed = 1;
 	}
 	if (changed && !ast_test_flag(&p->flags[0], SIP_GOTREFER) && !ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {

Modified: team/dvossel/fixtheworld_phase1_step3/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/channel.c?view=diff&rev=301781&r1=301780&r2=301781
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/channel.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/channel.c Thu Jan 13 17:06:48 2011
@@ -7398,10 +7398,8 @@
 				return AST_BRIDGE_FAILED;
 			}
 
-			ast_cap_remove_all(o0nativeformats);
-			ast_cap_remove_all(o0nativeformats);
-			ast_cap_append(o0nativeformats, c0->nativeformats);
-			ast_cap_append(o1nativeformats, c1->nativeformats);
+			ast_cap_copy2(o0nativeformats, c0->nativeformats);
+			ast_cap_copy2(o1nativeformats, c1->nativeformats);
 		}
 
 		update_bridge_vars(c0, c1);

Modified: team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c?view=diff&rev=301781&r1=301780&r2=301781
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c Thu Jan 13 17:06:48 2011
@@ -604,6 +604,14 @@
 		}
 	}
 
+	/* test copy2 */
+	ast_cap_copy2(cap2, cap_joint);
+	if (!ast_cap_identical(cap2, cap_joint)) {
+		ast_test_status_update(test, "ast_cap_copy2 failed\n");
+		res = AST_TEST_FAIL;
+		goto test3_cleanup;
+	}
+
 test3_cleanup:
 	ast_cap_destroy(cap1);
 	ast_cap_destroy(cap2);




More information about the svn-commits mailing list