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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 21 03:08:07 MST 2006


Author: mogorman
Date: Fri Apr 21 05:08:07 2006
New Revision: 21815

URL: http://svn.digium.com/view/asterisk?rev=21815&view=rev
Log:
 i think outbound works but cant test it

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=21815&r1=21814&r2=21815&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_jingle.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_jingle.c Fri Apr 21 05:08:07 2006
@@ -209,7 +209,9 @@
 	int pref_codec = 0;
 	int alreadysent = 0;
 	
-	ast_verbose("EEP %s!\n",client->connection->mid);
+	if(p->initiator)
+		return 1;
+
 	iq = iks_new("iq");
 	jingle = iks_new(GOOGLE_NODE);
 	description = iks_new("description");
@@ -373,6 +375,7 @@
 	tmp = client->p;
 	/* Make sure our new call doesn't exist yet */
 	while(tmp) {
+		ast_verbose("FFFFF %s\n",tmp->sid);
 		if (iks_find_with_attrib(pak->x, GOOGLE_NODE,GOOGLE_SID, tmp->sid)) {
 			break;
 		}
@@ -389,7 +392,7 @@
 	return 1;
 }
 
-static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p, ikspak *pak)
+static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p,char *sid, char *from)
 {
 	struct jingle_candidate *tmp;
 	struct aji_client *c = client->connection;
@@ -417,7 +420,7 @@
 	iks_insert_node(jingle,candidate);
 		
 	while(p) {
-		if(!strcasecmp(p->sid,iks_find_attrib(pak->query,GOOGLE_SID))) {
+		if(!strcasecmp(p->sid,sid)) {
 			break;
 		}
 		p = p->next;
@@ -472,13 +475,13 @@
 		snprintf(port, sizeof(port),"%d",tmp->port);
 		snprintf(preference,sizeof(preference),"%.2f",tmp->preference);
 		iks_insert_attrib(iq,"from", c->jid->full);
-		iks_insert_attrib(iq,"to", iks_find_attrib(pak->x,"from"));
+		iks_insert_attrib(iq,"to", from);
 		iks_insert_attrib(iq,"type", "set");
 		iks_insert_attrib(iq,"id", c->mid);
 		ast_aji_increment_mid(c->mid);
 		iks_insert_attrib(jingle,"type", "candidates");
-		iks_insert_attrib(jingle,"id", iks_find_attrib(pak->query,GOOGLE_SID));
-		iks_insert_attrib(jingle,"initiator",iks_find_attrib(pak->x,"from"));
+		iks_insert_attrib(jingle,"id", sid);
+		iks_insert_attrib(jingle,"initiator",(p->initiator)?c->jid->full:from);
 		iks_insert_attrib(jingle,"xmlns", GOOGLE_NS);
 		iks_insert_attrib(candidate, "name", tmp->name);
 		iks_insert_attrib(candidate, "address",tmp->ip);
@@ -753,7 +756,7 @@
 		ast_log(LOG_WARNING, "Unable to allocate jingle structure!\n");
 		return -1;
 	}
-	chan = jingle_new(client, p, AST_STATE_RING, pak->from->user);
+	chan = jingle_new(client, p, AST_STATE_DOWN, pak->from->user);
 	if (chan) {
 		ast_mutex_lock(&p->lock);
 		ast_copy_string(p->from, pak->from->full, sizeof(p->from));
@@ -768,9 +771,9 @@
 			ast_verbose("yatta!!\n");
 			codec= iks_next(codec);
 		}
-		jingle_create_candidates(client, p, pak);
+		jingle_create_candidates(client, p, iks_find_attrib(pak->query,GOOGLE_SID), iks_find_attrib(pak->x,"from"));
 		ast_mutex_unlock(&p->lock);
-		ast_setstate(chan, AST_STATE_DOWN);
+		ast_setstate(chan, AST_STATE_RING);
 		res = ast_pbx_start(chan);
 
 		switch (res) {
@@ -1010,7 +1013,38 @@
 	struct aji_client *client = NULL;
 	jingle = p->parent;
 	client = jingle->connection;
-	jingle_accept_call(jingle, p);
+	iks *iq, *desc, *session;
+	iks *payload_eg711u , *payload_pcmu;
+	ast_verbose("I am here right?\n");
+	iq = iks_new("iq");
+	desc = iks_new("description");
+	session = iks_new("session");
+	iks_insert_attrib(iq,"type","set");
+	iks_insert_attrib(iq,"to",p->from);
+	iks_insert_attrib(iq,"from",client->jid->full);
+	iks_insert_attrib(iq,"id",client->mid);
+	ast_aji_increment_mid(client->mid);
+	iks_insert_attrib(session,"type","initiate");
+	iks_insert_attrib(session, "id", p->sid);
+	iks_insert_attrib(session,"initiator",client->jid->full);
+	iks_insert_attrib(session,"xmlns","http://www.google.com/session");
+	iks_insert_attrib(desc,"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");
+	payload_eg711u = iks_new("payload-type");
+	iks_insert_attrib(payload_eg711u,"id","100");
+	iks_insert_attrib(payload_eg711u,"name","EG711U");
+	iks_insert_node(desc,payload_pcmu);
+	iks_insert_node(desc,payload_eg711u);
+	iks_insert_node(iq,session);
+	iks_insert_node(session,desc);
+	iks_send(client->p,iq);
+	iks_free(iq);
+	iks_free(desc);
+	iks_free(session);
+	iks_free(payload_eg711u);
+	iks_free(payload_pcmu);
 	return 0;
 }
 
@@ -1051,6 +1085,8 @@
 	 	ast_setstate(ast, AST_STATE_RING);
 		p->jointcapability = p->capability;
 		jingle_transmit_invite(p);
+		jingle_create_candidates(p->parent, p,p->sid, p->from);
+
 	 return 0;
 }
 



More information about the asterisk-commits mailing list