[asterisk-commits] branch mogorman/asterisk-xmpp r10604 - in
/team/mogorman/asterisk-xmpp: chann...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Feb 20 21:41:29 MST 2006
Author: mogorman
Date: Mon Feb 20 22:41:28 2006
New Revision: 10604
URL: http://svn.digium.com/view/asterisk?rev=10604&view=rev
Log:
procss_sdp done
Modified:
team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h
team/mogorman/asterisk-xmpp/res/res_xmpp.c
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=10604&r1=10603&r2=10604&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_xmpp.c Mon Feb 20 22:41:28 2006
@@ -61,6 +61,7 @@
#include "asterisk/musiconhold.h"
#include "asterisk/manager.h"
#include "asterisk/stringfields.h"
+#include "asterisk/utils.h"
#include "asterisk/xmpp.h"
static const char desc[] = "XMPP Channel";
@@ -198,6 +199,31 @@
ast_mutex_unlock(&rand_lock);
return val;
+}
+
+static int xmpp_bridge_call(struct axi_client *client,ikspak *pak)
+{
+ char *data, sid[100];
+ struct xmpp_pvt *p = client->xmpps;
+
+ ast_verbose("ONLY A Little further %s\n",(iks_find_attrib(pak->x,"id")));
+ data = iks_find_attrib(pak->x,"id");
+ data = data + 9;
+ ast_copy_string(sid,data,sizeof(sid));
+ while(p) {
+ if(!strcasecmp(p->sid,sid)) {
+ break;
+ }
+ p = p->next;
+ }
+
+ return 1;
+}
+
+static int xmpp_hangup_farend(struct axi_client *client,ikspak *pak)
+{
+ ast_verbose("END CALL\n");
+ return 1;
}
static int xmpp_create_candidates(struct axi_client *client,ikspak *pak)
@@ -321,7 +347,7 @@
return 1;
}
-static void add_codec_to_candidate(const struct xmpp_pvt *p, int codec, iks *description)
+static void add_codec_to_answer(const struct xmpp_pvt *p, int codec, iks *description)
{
ast_verbose("Adding codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
if(!strcasecmp("ulaw",ast_getformatname(codec))) {
@@ -376,7 +402,7 @@
int x;
int pref_codec = 0;
int alreadysent = 0;
-
+ char mid[50];
while(tmp) {
if(!strcasecmp(tmp->sid,iks_find_attrib(pak->query,GOOGLE_SID))) {
iq = iks_new("iq");
@@ -392,9 +418,9 @@
if (alreadysent & pref_codec)
continue;
if (pref_codec <= AST_FORMAT_MAX_AUDIO)
- add_codec_to_candidate(tmp, pref_codec, description);
+ add_codec_to_answer(tmp, pref_codec, description);
else
- add_codec_to_candidate(tmp, pref_codec, description);
+ add_codec_to_answer(tmp, pref_codec, description);
alreadysent |= pref_codec;
}
/* payload_ipcmwb= iks_new("payload-type");
@@ -422,8 +448,8 @@
iks_insert_attrib(iq,"type","set");
iks_insert_attrib(iq,"from",client->jid->full);
iks_insert_attrib(iq,"to",iks_find_attrib(pak->x,"from"));
- iks_insert_attrib(iq,"id",client->mid);
- axi_increment_mid(client->mid);
+ snprintf(mid,sizeof(mid),"j:active:%s",tmp->sid);
+ iks_insert_attrib(iq,"id",mid);
iks_insert_attrib(jingle, "xmlns", GOOGLE_NS);
iks_insert_attrib(jingle, "action", JINGLE_ACCEPT);
@@ -472,8 +498,8 @@
static int xmpp_answer2(struct axi_client *client,ikspak *pak)
{
struct xmpp_pvt *p ,*tmp = client->xmpps;
- iks *accept;
-// char *data = "1234 at local";
+ iks *accept, *codec;
+ codec = iks_child(iks_child(iks_child(pak->x)));
while(tmp) {
if(iks_find_with_attrib(pak->x,GOOGLE_NODE,GOOGLE_SID,tmp->sid))
{
@@ -487,6 +513,13 @@
ast_copy_string(p->from,iks_find_attrib(pak->x,"from"),sizeof(p->from));
if(iks_find_attrib(pak->query,GOOGLE_SID)) {
ast_copy_string(p->sid,iks_find_attrib(pak->query,GOOGLE_SID),sizeof(p->sid));
+ }
+
+ while(codec) {
+ ast_rtp_set_m_type(p->rtp, atoi(iks_find_attrib(codec,"id")));
+ ast_rtp_set_rtpmap_type(p->rtp, atoi(iks_find_attrib(codec,"id")), "audio", iks_find_attrib(codec,"name"));
+ ast_verbose("yatta!!\n");
+ codec= iks_next(codec);
}
ast_mutex_unlock(&p->lock);
accept = iks_new("iq");
@@ -511,6 +544,8 @@
iks *candidate_node = NULL;
iks *receipt = NULL;
newcandidate = (struct axi_candidate *)malloc(sizeof(struct axi_candidate));
+ if(!newcandidate)
+ return NULL;
memset(newcandidate,0,sizeof(struct axi_candidate));
candidate_node = iks_find(pak->query,"candidate");
ast_copy_string(newcandidate->name,iks_find_attrib(candidate_node, "name"),sizeof(newcandidate->name));
@@ -879,11 +914,12 @@
static int xmpp_parser(struct axi_client *client, iks *node)
{
+ ast_verbose("WOOHOO!!!\n");
ikspak *pak;
pak = iks_packet(node);
if(iks_find_with_attrib(pak->x,GOOGLE_NODE,"type",JINGLE_INITIATE))
xmpp_answer2(client, pak);
- if(iks_find_with_attrib(pak->x,GOOGLE_NODE,"type",GOOGLE_NEGOTIATE)) {
+ else if(iks_find_with_attrib(pak->x,GOOGLE_NODE,"type",GOOGLE_NEGOTIATE)) {
xmpp_add_candidate(client,pak);
if(flipflop == 2) {
flipflop = 0;
@@ -894,6 +930,14 @@
flipflop++;
}
}
+ else if(iks_find_with_attrib(pak->x,GOOGLE_NODE,"type","terminate")) {
+ xmpp_hangup_farend(client, pak);
+ }
+
+ else if(pak->subtype==IKS_TYPE_RESULT) {
+ xmpp_bridge_call(client,pak);
+ }
+
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=10604&r1=10603&r2=10604&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h (original)
+++ team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h Mon Feb 20 22:41:28 2006
@@ -98,8 +98,6 @@
struct ast_channel *owner; /* Master Channel */
struct ast_rtp *rtp; /*!< RTP Session */
struct xmpp_pvt *next; /* Next entity */
-
-
};
struct axi_client {
Modified: team/mogorman/asterisk-xmpp/res/res_xmpp.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/res/res_xmpp.c?rev=10604&r1=10603&r2=10604&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/res/res_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/res/res_xmpp.c Mon Feb 20 22:41:28 2006
@@ -290,7 +290,7 @@
ikspak *pak;
pak=iks_packet(node);
- iks_filter_packet (client->f,pak);
+// iks_filter_packet (client->f,pak);
switch(type) {
case IKS_NODE_START:
if(client->usetls &&!iks_is_secure(client->p)) {
@@ -305,7 +305,8 @@
iks_insert_attrib(auth,"id",client->mid);
axi_increment_mid(client->mid);
iks_send(client->p,auth);
- iks_delete(auth);
+ if(auth)
+ iks_delete(auth);
}
break;
@@ -324,7 +325,8 @@
auth = iks_make_resource_bind(client->jid);
axi_increment_mid(client->mid);
iks_send(client->p,auth);
- iks_delete(auth);
+ if(auth)
+ iks_delete(auth);
}
if(features & IKS_STREAM_SESSION) {
iks_filter_add_rule (client->f, axi_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
@@ -332,7 +334,8 @@
iks_insert_attrib(auth,"id","auth");
axi_increment_mid(client->mid);
iks_send(client->p,auth);
- iks_delete(auth);
+ if(auth)
+ iks_delete(auth);
}
} else {
features=axi_highest_bit(features);
@@ -407,6 +410,9 @@
break;
}
}
+
+ iks_filter_packet (client->f,pak);
+
if (node)
iks_delete(node);
if(client)
@@ -434,6 +440,18 @@
if(iks_packet(node)->subtype==IKS_TYPE_SET) {
if(iks_find_with_attrib(iks_packet(node)->x,GOOGLE_NODE,"xmlns",GOOGLE_NS))
jingle_callback(client,iks_copy(node));
+ }
+ if(iks_packet(node)->subtype==IKS_TYPE_RESULT) {
+ char *data;
+ ast_verbose("RESULTITH TO THE QUERY!!\n");
+ data = iks_find_attrib(iks_packet(node)->x, "id");
+ if(data) {
+ ast_verbose("STEP 2 %s \n", data);
+ if(strstr(data,"j:")) {
+ if(strstr(data,"active:"))
+ jingle_callback(client,iks_copy(node));
+ }
+ }
}
}
@@ -525,7 +543,8 @@
message_packet=iks_make_msg(IKS_TYPE_CHAT, address, message);
iks_insert_attrib(message_packet,"from",client->jid->full);
res =iks_send(client->p,message_packet);
- iks_delete(message_packet);
+ if(message_packet)
+ iks_delete(message_packet);
} else
ast_verbose("We arent connected dont send\n");
return 1;
@@ -554,8 +573,10 @@
iks_insert_attrib(p1,"to",room);
iks_insert_node(p1,priority);
res =iks_send(client->p,p1);
- iks_delete(p1);
- iks_delete(priority);
+ if(p1)
+ iks_delete(p1);
+ if(priority)
+ iks_delete(priority);
p2 = iks_new("presence");
priority2= iks_new("priority");
@@ -563,8 +584,10 @@
iks_insert_attrib(p2,"to",room);
iks_insert_node(p2,priority2);
res =iks_send(client->p,p2);
- iks_delete(p2);
- iks_delete(priority2);
+ if(p2)
+ iks_delete(p2);
+ if(priority2)
+ iks_delete(priority2);
return 1;
}
int ast_axi_invite_chat(struct axi_client *client, char *user, char *room, char *message)
@@ -583,9 +606,12 @@
iks_insert_node(invite,body);
iks_insert_node(invite,namespace);
res =iks_send(client->p,invite);
- iks_delete(body);
- iks_delete(namespace);
- iks_delete(invite);
+ if(body)
+ iks_delete(body);
+ if(namespace)
+ iks_delete(namespace);
+ if(invite)
+ iks_delete(invite);
return 1;
}
@@ -668,7 +694,8 @@
axi_increment_mid(client->mid);
iks_insert_attrib(send,"from",client->user);
res =iks_send(client->p,send);
- iks_delete(send);
+ if(send)
+ iks_delete(send);
if(client){
ASTOBJ_UNREF(client,axi_client_destroy);
}
@@ -707,10 +734,14 @@
iks_insert_node(regquery,reguser);
iks_insert_node(regquery,regpass);
res =iks_send(client->p,regiq);
- iks_delete(regiq);
- iks_delete(regquery);
- iks_delete(reguser);
- iks_delete(regpass);
+ if(regiq)
+ iks_delete(regiq);
+ if(regquery)
+ iks_delete(regquery);
+ if(reguser)
+ iks_delete(reguser);
+ if(regpass)
+ iks_delete(regpass);
if(client) {
ASTOBJ_UNREF(client,axi_client_destroy);
}
@@ -744,9 +775,12 @@
iks_insert_node(removeiq,removequery);
iks_insert_node(removequery,removeitem);
res =iks_send(client->p, removeiq);
- iks_delete(removeiq);
- iks_delete(removequery);
- iks_delete(removeitem);
+ if(removeiq)
+ iks_delete(removeiq);
+ if(removequery)
+ iks_delete(removequery);
+ if(removeitem)
+ iks_delete(removeitem);
break;
case AXI_REGISTER:
ast_verbose("REGISTER THIS USER %s\n",iterator->name);
@@ -760,7 +794,8 @@
iks_insert_attrib(send,"to",iterator->host);
iks_insert_attrib(send,"from",client->user);
res =iks_send(client->p,send);
- iks_delete(send);
+ if(send)
+ iks_delete(send);
}
iterator->on_roster=AXI_DONOTHING;
break;
@@ -805,7 +840,7 @@
if(!flag)
if(client->pruneregister>=2)
iterator->on_roster=AXI_REGISTER;
- iks_delete(x);
+// iks_delete(x);
ASTOBJ_UNLOCK(iterator);
});
@@ -849,12 +884,12 @@
x = iks_next(x);
}
- iks_delete(x);
+// iks_delete(x);
axi_pruneregister(client);
- iks_filter_remove_hook(client->f,axi_filter_roster);
+// iks_filter_remove_hook(client->f,axi_filter_roster);
if(client)
ASTOBJ_UNREF(client, axi_client_destroy);
-
+ ast_verbose("beep\n");
return IKS_FILTER_EAT;
}
@@ -881,7 +916,8 @@
iks_insert_attrib(roster,"id","roster");
axi_set_presence(client,client->jid->full,1,"im available");
iks_send(client->p,roster);
- iks_delete(roster);
+ if(roster)
+ iks_delete(roster);
iks_filter_remove_hook(client->f,axi_client_connect);
}
@@ -1000,8 +1036,10 @@
iks_insert_node(presence,cnode);
// iks_insert_attrib(presence,"from", user);
res =iks_send(client->p, presence);
- iks_delete(cnode);
- iks_delete(presence);
+ if(cnode)
+ iks_delete(cnode);
+ if(presence)
+ iks_delete(presence);
}
static int axi_do_debug_component(int fd, int argc, char *argv[])
More information about the asterisk-commits
mailing list