[asterisk-commits] branch mogorman/asterisk-xmpp r9325 - in /team/mogorman/asterisk-xmpp: channe...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Feb 9 14:08:39 MST 2006


Author: mogorman
Date: Thu Feb  9 15:08:38 2006
New Revision: 9325

URL: http://svn.digium.com/view/asterisk?rev=9325&view=rev
Log:
SWEET!!! it worked...

Modified:
    team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
    team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h

Modified: team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_xmpp.c?rev=9325&r1=9324&r2=9325&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_xmpp.c Thu Feb  9 15:08:38 2006
@@ -106,7 +106,7 @@
 };
 
 
-int flipflop = 0;
+static int flipflop = 0;
 static struct xmpp_pvt *xmpp_alloc(char *data, int format);
 
 static int xmpp_queue_frame(struct xmpp_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us)
@@ -174,13 +174,17 @@
 static int xmpp_create_candidates(struct axi_client *client,ikspak *pak)
 {
 	if(!client->candidates) { /*send standard candidates*/
-		iks *iq1, *iq2, *jingle1, *jingle2, *candidate1, *candidate2;
+		iks *iq1, *iq2, *iq3, *jingle1, *jingle2, *jingle3, *candidate1, *candidate2, *candidate3;
 		iq1 = iks_new("iq");
 		iq2 = iks_new("iq");
+		iq3 = iks_new("iq");
 		jingle1 = iks_new(GOOGLE_NODE);
 		jingle2 = iks_new(GOOGLE_NODE);
+		jingle3 = iks_new(GOOGLE_NODE);
 		candidate1 = iks_new("candidate");
 		candidate2 = iks_new("candidate");
+		candidate3 = iks_new("candidate");
+
 		iks_insert_attrib(iq1,"from", client->jid->full);
 		iks_insert_attrib(iq1,"to", iks_find_attrib(pak->x,"from"));
 		iks_insert_attrib(iq1,"type", "set");
@@ -191,15 +195,26 @@
 		iks_insert_attrib(iq2,"type", "set");
 		iks_insert_attrib(iq2,"id", client->mid);
 		axi_increment_mid(client->mid);
-		
+		iks_insert_attrib(iq3,"from", client->jid->full);
+		iks_insert_attrib(iq3,"to", iks_find_attrib(pak->x,"from"));
+		iks_insert_attrib(iq3,"type", "set");
+		iks_insert_attrib(iq3,"id", client->mid);
+		axi_increment_mid(client->mid);
+	
 		iks_insert_attrib(jingle1,"type", "candidates");
 		iks_insert_attrib(jingle1,"id", iks_find_attrib(pak->query,GOOGLE_SID));
+		iks_insert_attrib(jingle1,"initiator",iks_find_attrib(pak->x,"from"));
 		iks_insert_attrib(jingle1,"xmlns", GOOGLE_NS);
 		iks_insert_attrib(jingle2,"type", "candidates");
 		iks_insert_attrib(jingle2,"id", iks_find_attrib(pak->query,GOOGLE_SID));
+		iks_insert_attrib(jingle2,"initiator",iks_find_attrib(pak->x,"from"));
 		iks_insert_attrib(jingle2,"xmlns", GOOGLE_NS);
-	
-		iks_insert_attrib(candidate1, "type", "candidates");
+		iks_insert_attrib(jingle3,"type", "candidates");
+		iks_insert_attrib(jingle3,"id", iks_find_attrib(pak->query,GOOGLE_SID));
+		iks_insert_attrib(jingle3,"initiator",iks_find_attrib(pak->x,"from"));
+		iks_insert_attrib(jingle3,"xmlns", GOOGLE_NS);
+
+		iks_insert_attrib(candidate1, "name", "rtp");
 		iks_insert_attrib(candidate1, "address", client->localip);
 		iks_insert_attrib(candidate1, "port", "1234"); /*FIX ME*/
 		iks_insert_attrib(candidate1, "username", "abcdefghijk23456");
@@ -209,7 +224,7 @@
 		iks_insert_attrib(candidate1, "type", "local");
 		iks_insert_attrib(candidate1, "network", "0");
 		iks_insert_attrib(candidate1, "generation", "0");
-		iks_insert_attrib(candidate2, "type", "candidates");
+		iks_insert_attrib(candidate2, "name", "rtp");
 		iks_insert_attrib(candidate2, "address", client->externip);
 		iks_insert_attrib(candidate2, "port", "1235");
 		iks_insert_attrib(candidate2, "username", "dasasdf432kjhkjl");
@@ -219,6 +234,16 @@
 		iks_insert_attrib(candidate2, "type", "stun");
 		iks_insert_attrib(candidate2, "network", "0");
 		iks_insert_attrib(candidate2, "generation", "0");
+		iks_insert_attrib(candidate3, "name", "rtp");
+		iks_insert_attrib(candidate3, "address", client->localip);
+		iks_insert_attrib(candidate3, "port", "19295"); /*FIX ME*/
+		iks_insert_attrib(candidate3, "username", "aeeeefghijk23456");
+		iks_insert_attrib(candidate3, "password", "sdf432kjhhijk2ka");
+		iks_insert_attrib(candidate3, "preference", "0.5");
+		iks_insert_attrib(candidate3, "protocol", "ssltcp");
+		iks_insert_attrib(candidate3, "type", "relay");
+		iks_insert_attrib(candidate3, "network", "0");
+		iks_insert_attrib(candidate3, "generation", "0");
 
 
 
@@ -236,23 +261,68 @@
 		iks_delete(candidate2);
 		iks_delete(jingle2);
 		iks_delete(iq2);
-
+		iks_insert_node(iq3,jingle3);
+		iks_insert_node(jingle3,candidate3);
+		iks_send(client->p,iq3);
+		iks_delete(candidate3);
+		iks_delete(jingle3);
+		iks_delete(iq3);
 	}
 }
 
 static int xmpp_accept_call(struct axi_client *client, ikspak *pak)
 {
 	struct xmpp_pvt *tmp = client->xmpps;
-	iks *iq, *jingle, *description, *codec;
+	iks *iq, *jingle, *description, *payload_ipcmwb, *payload_isac, *payload_eg711u , *payload_eg711a, *payload_pcmu, *payload_pcma, *payload_ilbc, *payload_g723, *payload_red, *payload_audio, *payload_cn;
 	while(tmp) {
 		if(!strcasecmp(tmp->sid,iks_find_attrib(pak->query,GOOGLE_SID))) {
 			iq = iks_new("iq");
 			jingle = iks_new(GOOGLE_NODE);
-			codec = iks_new("payload-type");
-			iks_insert_attrib(codec,"id","0");
-			iks_insert_attrib(codec,"name","PCMU");
-			iks_insert_attrib(codec,"xmlns","http://www.google.com/session/phone");
-
+			payload_pcmu= iks_new("payload-type");
+			iks_insert_attrib(payload_pcmu,"id","0");
+			iks_insert_attrib(payload_pcmu,"name","PCMU");
+			iks_insert_attrib(payload_pcmu,"xmlns","http://www.google.com/session/phone");
+			payload_ipcmwb= iks_new("payload-type");
+			iks_insert_attrib(payload_ipcmwb,"id","97");
+			iks_insert_attrib(payload_ipcmwb,"name","IPCMWB");
+			iks_insert_attrib(payload_ipcmwb,"xmlns","http://www.google.com/session/phone");
+			payload_isac= iks_new("payload-type");
+			iks_insert_attrib(payload_isac,"id","103");
+			iks_insert_attrib(payload_isac,"name","ISAC");
+			iks_insert_attrib(payload_isac,"xmlns","http://www.google.com/session/phone");
+			payload_eg711u= iks_new("payload-type");
+			iks_insert_attrib(payload_eg711u,"id","100");
+			iks_insert_attrib(payload_eg711u,"name","EG711U");
+			iks_insert_attrib(payload_eg711u,"xmlns","http://www.google.com/session/phone");
+			payload_eg711a= iks_new("payload-type");
+			iks_insert_attrib(payload_eg711a,"id","101");
+			iks_insert_attrib(payload_eg711a,"name","EG711A");
+			iks_insert_attrib(payload_eg711a,"xmlns","http://www.google.com/session/phone");
+			payload_pcma= iks_new("payload-type");
+			iks_insert_attrib(payload_pcma,"id","8");
+			iks_insert_attrib(payload_pcma,"name","PCMA");
+			iks_insert_attrib(payload_pcma,"xmlns","http://www.google.com/session/phone");
+			payload_ilbc= iks_new("payload-type");
+			iks_insert_attrib(payload_ilbc,"id","102");
+			iks_insert_attrib(payload_ilbc,"name","iLBC");
+			iks_insert_attrib(payload_ilbc,"xmlns","http://www.google.com/session/phone");
+			payload_g723= iks_new("payload-type");
+			iks_insert_attrib(payload_g723,"id","4");
+			iks_insert_attrib(payload_g723,"name","G723");
+			iks_insert_attrib(payload_g723,"xmlns","http://www.google.com/session/phone");
+			payload_red= iks_new("payload-type");
+			iks_insert_attrib(payload_red,"id","117");
+			iks_insert_attrib(payload_red,"name","red");
+			iks_insert_attrib(payload_red,"xmlns","http://www.google.com/session/phone");
+			payload_audio= iks_new("payload-type");
+			iks_insert_attrib(payload_audio,"id","106");
+			iks_insert_attrib(payload_audio,"name","audio/telephone-event");
+			iks_insert_attrib(payload_audio,"xmlns","http://www.google.com/session/phone");
+			payload_cn= iks_new("payload-type");
+			iks_insert_attrib(payload_cn,"id","13");
+			iks_insert_attrib(payload_cn,"name","CN");
+			iks_insert_attrib(payload_cn,"xmlns","http://www.google.com/session/phone");
+			
 			description = iks_new("description");
 			iks_insert_attrib(description,"xmlns","http://google.com/session/phone");
 			
@@ -268,10 +338,31 @@
 			iks_insert_attrib(jingle, GOOGLE_SID, tmp->sid);
 			iks_insert_node(iq,jingle);
 			iks_insert_node(jingle,description);
-			iks_insert_node(description,codec);
+			iks_insert_node(description,payload_ipcmwb);
+			iks_insert_node(description,payload_isac);
+			iks_insert_node(description,payload_eg711u);
+			iks_insert_node(description,payload_eg711a);
+			iks_insert_node(description,payload_pcmu);
+			iks_insert_node(description,payload_pcma);
+			iks_insert_node(description,payload_ilbc);
+			iks_insert_node(description,payload_g723);
+			iks_insert_node(description,payload_red);
+			iks_insert_node(description,payload_audio);
+			iks_insert_node(description,payload_cn);
+
 			iks_send(client->p,iq);
+			iks_delete(payload_ipcmwb);
+			iks_delete(payload_isac);
+			iks_delete(payload_eg711u);
+			iks_delete(payload_eg711a);
+			iks_delete(payload_pcmu);
+			iks_delete(payload_pcma);
+			iks_delete(payload_ilbc);
+			iks_delete(payload_g723);
+			iks_delete(payload_red);
+			iks_delete(payload_audio);
+			iks_delete(payload_cn);
 			iks_delete(description);
-			iks_delete(codec);
 			iks_delete(jingle);
 			iks_delete(iq);
 		}
@@ -320,7 +411,7 @@
 	iks_insert_attrib(accept,"type","result");
 	iks_insert_attrib(accept,JINGLE_FROM,client->jid->full);
 	iks_insert_attrib(accept,"to",iks_find_attrib(pak->x,JINGLE_FROM));
-	iks_insert_attrib(accept,"id",client->mid);
+	iks_insert_attrib(accept,"id",iks_find_attrib(pak->x,"id"));
 	iks_send(client->p,accept);
 	iks_delete(accept);
 	xmpp_create_candidates(client,pak);
@@ -329,8 +420,9 @@
 
 static int xmpp_add_candidate(struct axi_client *client,ikspak *pak)
 {
+	ast_verbose("woot woot woot\n");
 	struct xmpp_pvt *p =NULL,*tmp = client->xmpps;
-	struct axi_candidate *newcandidate = NULL, *tmpcan = NULL;
+	struct axi_candidate *newcandidate = NULL;
 	iks *candidate_node = NULL;
 	iks *receipt = NULL;
 	newcandidate = (struct axi_candidate *)malloc(sizeof(struct axi_candidate));
@@ -344,10 +436,16 @@
 	newcandidate->preference = atof(iks_find_attrib(candidate_node, "preference"));
 	if(!strcasecmp(iks_find_attrib(candidate_node, "protocol"),"udp"))
 		newcandidate->protocol = AXI_PROTOCOL_UDP;
+	if(!strcasecmp(iks_find_attrib(candidate_node, "protocol"),"ssltcp"))
+		newcandidate->protocol = AXI_PROTOCOL_SSLTCP;
+
 	if(!strcasecmp(iks_find_attrib(candidate_node, "type"),"stun"))
 		newcandidate->type = AXI_CONNECT_STUN;
-	if(!strcasecmp(iks_find_attrib(candidate_node, "type"),"stun"))
+	if(!strcasecmp(iks_find_attrib(candidate_node, "type"),"local"))
 		newcandidate->type = AXI_CONNECT_LOCAL;
+	if(!strcasecmp(iks_find_attrib(candidate_node, "type"),"relay"))
+		newcandidate->type = AXI_CONNECT_RELAY;
+
 	newcandidate->network = atoi(iks_find_attrib(candidate_node, "network"));
 	newcandidate->generation = atoi(iks_find_attrib(candidate_node, "generation"));
 	newcandidate->next = NULL;
@@ -360,18 +458,13 @@
 	}
 
 	if(!p) {
+		ast_verbose("NO MATCH\n");
 		return -1;
 	} else {
-		tmpcan = p->candidates;
-		if(tmpcan) {
-			while(tmpcan->next) {
-				if(tmpcan->next)
-					tmpcan->next;
-			}
-			tmpcan->next = newcandidate;
-		} else
-			p->candidates = newcandidate;
-		
+		newcandidate->next = p->candidates;
+		p->candidates = newcandidate;
+
+		ast_verbose("sending\n");	
 		receipt = iks_new("iq");
 		iks_insert_attrib(receipt,"type","result");
 		iks_insert_attrib(receipt,JINGLE_FROM,client->jid->full);
@@ -700,12 +793,14 @@
 		xmpp_answer2(client, pak);
 	if(iks_find_with_attrib(pak->x,GOOGLE_NODE,"type",GOOGLE_NEGOTIATE)) {
 		xmpp_add_candidate(client,pak);
-		if(flipflop) {
-			flipflop--;
+		if(flipflop == 2) {
+			flipflop = 0;
 			xmpp_accept_call(client,pak);
 		}
-		else
+		else {
+			ast_verbose("COUNT IS %d\n",flipflop);
 			flipflop++;
+		}
 	}
 	if(node)
 		iks_delete(node);

Modified: team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h?rev=9325&r1=9324&r2=9325&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h (original)
+++ team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h Thu Feb  9 15:08:38 2006
@@ -46,11 +46,13 @@
 
 enum axi_protocol {
 	AXI_PROTOCOL_UDP=1,
+	AXI_PROTOCOL_SSLTCP=2,
 };
 
 enum axi_connect_type {
 	AXI_CONNECT_STUN=1,
 	AXI_CONNECT_LOCAL=2,
+	AXI_CONNECT_RELAY=3,
 };
 
 struct axi_candidate {



More information about the asterisk-commits mailing list