[asterisk-commits] branch mogorman/asterisk-xmpp r19701 - /team/mogorman/asterisk-xmpp/channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Apr 12 21:47:08 MST 2006


Author: mogorman
Date: Wed Apr 12 23:47:07 2006
New Revision: 19701

URL: http://svn.digium.com/view/asterisk?rev=19701&view=rev
Log: (empty)

Modified:
    team/mogorman/asterisk-xmpp/channels/chan_jingle.c

Modified: team/mogorman/asterisk-xmpp/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_jingle.c?rev=19701&r1=19700&r2=19701&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_jingle.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_jingle.c Wed Apr 12 23:47:07 2006
@@ -1120,6 +1120,52 @@
 	return 1;
 }
 
+static struct jingle_candidate *jingle_create_candidate(char *args)
+{
+	char *name, *type, *preference, *protocol;
+	struct axi_candidate *res;
+	res= malloc(sizeof(struct axi_candidate));
+	memset(res,0,sizeof(struct axi_candidate));
+	if(args)
+		name = args;
+	if((args = strchr(args,','))) {
+		*args='\0';
+		args++;
+		preference = args;
+	}
+	if((args = strchr(args, ','))) {
+		*args='\0';
+		args++;
+		protocol=args;
+	}
+	if((args = strchr(args, ','))) {
+		*args='\0';
+		args++;
+		type=args;
+	}
+	if(name)
+		ast_copy_string(res->name,name,sizeof(res->name));
+	if(preference) {
+		res->preference = atof(preference);
+	}
+	if(protocol) {
+		if(!strcasecmp("udp",protocol))
+			res->protocol=AXI_PROTOCOL_UDP;
+		if(!strcasecmp("ssltcp",protocol))
+			res->protocol=AXI_PROTOCOL_SSLTCP;
+	}
+	if(type) {
+		if(!strcasecmp("stun",type))
+			res->type = AXI_CONNECT_STUN;
+		if(!strcasecmp("local",type))
+			res->type = AXI_CONNECT_LOCAL;
+		if(!strcasecmp("relay",type))
+			res->type = AXI_CONNECT_RELAY;
+	}
+
+	return res;
+}
+
 static int jingle_create_member(char *label, struct ast_variable *var, int allowguest, struct ast_codec_pref prefs, char *context, struct jingle *member)
 {
 	struct aji_client *client=NULL;
@@ -1131,6 +1177,7 @@
 	member->allowguest=allowguest;
 	member->prefs=prefs;
 	while(var) {
+		struct jingle_candidate *candidate=NULL;
 		if(!strcasecmp(var->name,"username"))
 			ast_copy_string(member->user, var->value, sizeof(member->user));
 		else if(!strcasecmp(var->name,"disallow"))
@@ -1139,6 +1186,13 @@
 			ast_parse_allow_disallow(&member->prefs, &member->capability, var->value, 1);
 		else if (!strcasecmp(var->name, "context"))
 			ast_copy_string(member->context,var->value,sizeof(member->context));
+		else if (!strcasecmp(var->name, "candidate")) {
+			candidate = jingle_create_candidate(var->value);
+			if(candidate) {
+				candidate->next = client->ourcandidates;
+				client->ourcandidates = canidate;
+			}
+		}
 		else if (!strcasecmp(var->name, "connection")) {
 			if((client = ast_aji_get_client(var->value))) {
 		//		client->jingle=member;
@@ -1178,6 +1232,7 @@
 	
 	cat = ast_category_browse(cfg,NULL);
 	for(var = ast_variable_browse(cfg, "general"); var; var = var->next) {
+		struct jingle_candidate *candidate = NULL;
 		if(!strcasecmp(var->name, "allowguest"))
 			allowguest = (ast_true(ast_variable_retrieve(cfg,"general","allowguest")))?1:0;
 		else if (!strcasecmp(var->name, "disallow")) 
@@ -1188,8 +1243,17 @@
 			ast_copy_string(context,var->value,sizeof(context));
 		else if (!strcasecmp(var->name, "externip"))
 			ast_copy_string(externip,var->value,sizeof(externip));
+		else if (!strcasecmp(var->name, "candidate")) {
+			candidate = jingle_create_candidate(var->value);
+			if(candidate) {
+				candidate->next = client->ourcandidates;
+				client->ourcandidates = canidate;
+			}
+		}
+
 	}
 	while(cat) {
+		struct jingle_candidate *candidate = NULL;
 		if(strcasecmp(cat, "general")) {
 			var = ast_variable_browse(cfg, cat);
 			member = (struct jingle *) malloc(sizeof(struct jingle));
@@ -1197,7 +1261,6 @@
 			ASTOBJ_INIT(member);
 			ASTOBJ_WRLOCK(member);
 			if(!strcasecmp(cat, "guest")) {
-				ast_verbose("step guest\n");
 				ast_copy_string(member->name, "guest", sizeof(member->name));
 				ast_copy_string(member->user, "guest", sizeof(member->user));
 				ast_copy_string(member->context, context, sizeof(member->context));
@@ -1210,6 +1273,14 @@
 						ast_parse_allow_disallow(&member->prefs, &member->capability, var->value, 1);
 					else if (!strcasecmp(var->name, "context"))
 						ast_copy_string(member->context,var->value,sizeof(member->context));
+					else if (!strcasecmp(var->name, "candidate")) {
+						candidate = jingle_create_candidate(var->value);
+						if(candidate) {
+							candidate->next = client->ourcandidates;
+							client->ourcandidates = canidate;
+						}
+					}
+
 					var = var->next;
 				}
 				ASTOBJ_UNLOCK(member);



More information about the asterisk-commits mailing list