[svn-commits] qwell: branch qwell/gtalk_jingle-merge r56208 -
/team/qwell/gtalk_jingle-merg...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Thu Feb 22 10:22:34 MST 2007
Author: qwell
Date: Thu Feb 22 11:22:34 2007
New Revision: 56208
URL: http://svn.digium.com/view/asterisk?view=rev&rev=56208
Log:
s/gtalk/jingle/g
Some other small fixes...
Modified:
team/qwell/gtalk_jingle-merge/channels/chan_jingle.c
Modified: team/qwell/gtalk_jingle-merge/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/qwell/gtalk_jingle-merge/channels/chan_jingle.c?view=diff&rev=56208&r1=56207&r2=56208
==============================================================================
--- team/qwell/gtalk_jingle-merge/channels/chan_jingle.c (original)
+++ team/qwell/gtalk_jingle-merge/channels/chan_jingle.c Thu Feb 22 11:22:34 2007
@@ -20,7 +20,7 @@
*
* \author Matt O'Gorman <mogorman at digium.com>
*
- * \brief Gtalk Channel Driver, until google/libjingle works with jingle spec
+ * \brief Jingle Channel Driver
*
* \ingroup channel_drivers
*/
@@ -72,11 +72,9 @@
#include "asterisk/astobj.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/jabber.h"
-
-#define GOOGLE_CONFIG "gtalk.conf"
-
-#define GOOGLE_NS "http://www.google.com/session"
-
+#include "asterisk/jingle.h"
+
+#define JINGLE_CONFIG "jingle.conf"
/*! Global jitterbuffer configuration - by default, jb is disabled */
static struct ast_jb_conf default_jbconf =
@@ -88,21 +86,21 @@
};
static struct ast_jb_conf global_jbconf;
-enum gtalk_protocol {
+enum jingle_protocol {
AJI_PROTOCOL_UDP = 1,
AJI_PROTOCOL_SSLTCP = 2,
};
-enum gtalk_connect_type {
+enum jingle_connect_type {
AJI_CONNECT_STUN = 1,
AJI_CONNECT_LOCAL = 2,
AJI_CONNECT_RELAY = 3,
};
-struct gtalk_pvt {
+struct jingle_pvt {
ast_mutex_t lock; /*!< Channel private lock */
time_t laststun;
- struct gtalk *parent; /*!< Parent client */
+ struct jingle *parent; /*!< Parent client */
char sid[100];
char us[100];
char them[100];
@@ -112,8 +110,8 @@
int alreadygone;
int capability;
struct ast_codec_pref prefs;
- struct gtalk_candidate *theircandidates;
- struct gtalk_candidate *ourcandidates;
+ struct jingle_candidate *theircandidates;
+ struct jingle_candidate *ourcandidates;
char cid_num[80]; /*!< Caller ID num */
char cid_name[80]; /*!< Caller ID name */
char exten[80]; /*!< Called extension */
@@ -122,29 +120,29 @@
struct ast_rtp *vrtp; /*!< RTP video session */
int jointcapability; /*!< Supported capability at both ends (codecs ) */
int peercapability;
- struct gtalk_pvt *next; /* Next entity */
+ struct jingle_pvt *next; /* Next entity */
};
-struct gtalk_candidate {
+struct jingle_candidate {
char name[100];
- enum gtalk_protocol protocol;
+ enum jingle_protocol protocol;
double preference;
char username[100];
char password[100];
- enum gtalk_connect_type type;
+ enum jingle_connect_type type;
char network[6];
int generation;
char ip[16];
int port;
int receipt;
- struct gtalk_candidate *next;
+ struct jingle_candidate *next;
};
-struct gtalk {
- ASTOBJ_COMPONENTS(struct gtalk);
+struct jingle {
+ ASTOBJ_COMPONENTS(struct jingle);
struct aji_client *connection;
struct aji_buddy *buddy;
- struct gtalk_pvt *p;
+ struct jingle_pvt *p;
struct ast_codec_pref prefs;
int amaflags; /*!< AMA Flags */
char user[100];
@@ -159,57 +157,56 @@
char musicclass[MAX_MUSICCLASS]; /*!< Music on Hold class */
};
-struct gtalk_container {
- ASTOBJ_CONTAINER_COMPONENTS(struct gtalk);
+struct jingle_container {
+ ASTOBJ_CONTAINER_COMPONENTS(struct jingle);
};
-static const char desc[] = "Gtalk Channel";
+static const char desc[] = "Jingle Channel";
static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
-AST_MUTEX_DEFINE_STATIC(gtalklock); /*!< Protect the interface list (of gtalk_pvt's) */
+AST_MUTEX_DEFINE_STATIC(jinglelock); /*!< Protect the interface list (of jingle_pvt's) */
/* Forward declarations */
-static struct ast_channel *gtalk_request(const char *type, int format, void *data, int *cause);
-static int gtalk_digit(struct ast_channel *ast, char digit, unsigned int duration);
-static int gtalk_digit_begin(struct ast_channel *ast, char digit);
-static int gtalk_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
-static int gtalk_call(struct ast_channel *ast, char *dest, int timeout);
-static int gtalk_hangup(struct ast_channel *ast);
-static int gtalk_answer(struct ast_channel *ast);
-static int gtalk_newcall(struct gtalk *client, ikspak *pak);
-static struct ast_frame *gtalk_read(struct ast_channel *ast);
-static int gtalk_write(struct ast_channel *ast, struct ast_frame *f);
-static int gtalk_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
-static int gtalk_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
-static int gtalk_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
-static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const char *them, const char *sid);
-static int gtalk_do_reload(int fd, int argc, char **argv);
-static int gtalk_show_channels(int fd, int argc, char **argv);
+static struct ast_channel *jingle_request(const char *type, int format, void *data, int *cause);
+static int jingle_digit_begin(struct ast_channel *ast, char digit);
+static int jingle_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
+static int jingle_call(struct ast_channel *ast, char *dest, int timeout);
+static int jingle_hangup(struct ast_channel *ast);
+static int jingle_answer(struct ast_channel *ast);
+static int jingle_newcall(struct jingle *client, ikspak *pak);
+static struct ast_frame *jingle_read(struct ast_channel *ast);
+static int jingle_write(struct ast_channel *ast, struct ast_frame *f);
+static int jingle_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
+static int jingle_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static int jingle_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
+static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *us, const char *them, const char *sid);
+static int jingle_do_reload(int fd, int argc, char **argv);
+static int jingle_show_channels(int fd, int argc, char **argv);
/*----- RTP interface functions */
-static int gtalk_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
+static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active);
-static enum ast_rtp_get_result gtalk_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp);
-static int gtalk_get_codec(struct ast_channel *chan);
+static enum ast_rtp_get_result jingle_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp);
+static int jingle_get_codec(struct ast_channel *chan);
/*! \brief PBX interface structure for channel registration */
-static const struct ast_channel_tech gtalk_tech = {
- .type = "Gtalk",
- .description = "Gtalk Channel Driver",
+static const struct ast_channel_tech jingle_tech = {
+ .type = "Jingle",
+ .description = "Jingle Channel Driver",
.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
- .requester = gtalk_request,
- .send_digit_begin = gtalk_digit_begin,
- .send_digit_end = gtalk_digit_end,
+ .requester = jingle_request,
+ .send_digit_begin = jingle_digit_begin,
+ .send_digit_end = jingle_digit_end,
.bridge = ast_rtp_bridge,
- .call = gtalk_call,
- .hangup = gtalk_hangup,
- .answer = gtalk_answer,
- .read = gtalk_read,
- .write = gtalk_write,
- .exception = gtalk_read,
- .indicate = gtalk_indicate,
- .fixup = gtalk_fixup,
- .send_html = gtalk_sendhtml,
+ .call = jingle_call,
+ .hangup = jingle_hangup,
+ .answer = jingle_answer,
+ .read = jingle_read,
+ .write = jingle_write,
+ .exception = jingle_read,
+ .indicate = jingle_indicate,
+ .fixup = jingle_fixup,
+ .send_html = jingle_sendhtml,
.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER
};
@@ -221,41 +218,41 @@
/*! \brief RTP driver interface */
-static struct ast_rtp_protocol gtalk_rtp = {
- type: "Gtalk",
- get_rtp_info: gtalk_get_rtp_peer,
- set_rtp_peer: gtalk_set_rtp_peer,
- get_codec: gtalk_get_codec,
+static struct ast_rtp_protocol jingle_rtp = {
+ type: "Jingle",
+ get_rtp_info: jingle_get_rtp_peer,
+ set_rtp_peer: jingle_set_rtp_peer,
+ get_codec: jingle_get_codec,
};
static const char debug_usage[] =
-"Usage: gtalk show channels\n"
-" Shows current state of the Gtalk channels.\n";
+"Usage: jingle show channels\n"
+" Shows current state of the Jingle channels.\n";
static const char reload_usage[] =
-"Usage: gtalk reload\n"
-" Reload gtalk channel driver.\n";
-
-
-static struct ast_cli_entry gtalk_cli[] = {
- {{ "gtalk", "reload", NULL}, gtalk_do_reload, "Enable Jabber debugging", reload_usage },
- {{ "gtalk", "show", "channels", NULL}, gtalk_show_channels, "Show GoogleTalk Channels", debug_usage },
+"Usage: jingle reload\n"
+" Reload jingle channel driver.\n";
+
+
+static struct ast_cli_entry jingle_cli[] = {
+ {{ "jingle", "reload", NULL}, jingle_do_reload, "Reload Jingle channel driver", reload_usage },
+ {{ "jingle", "show", "channels", NULL}, jingle_show_channels, "Show Jingle Channels", debug_usage },
};
static char externip[16];
-static struct gtalk_container gtalk_list;
-
-static void gtalk_member_destroy(struct gtalk *obj)
+static struct jingle_container jingles;
+
+static void jingle_member_destroy(struct jingle *obj)
{
free(obj);
}
-static struct gtalk *find_gtalk(char *name, char *connection)
-{
- struct gtalk *gtalk = NULL;
+static struct jingle *find_jingle(char *name, char *connection)
+{
+ struct jingle *jingle = NULL;
char *domain = NULL , *s = NULL;
if(strchr(connection, '@')) {
@@ -263,34 +260,35 @@
domain = strsep(&s, "@");
ast_verbose("OOOOH domain = %s\n", domain);
}
- gtalk = ASTOBJ_CONTAINER_FIND(>alk_list, name);
- if (!gtalk && strchr(name, '@'))
- gtalk = ASTOBJ_CONTAINER_FIND_FULL(>alk_list, name, user,,, strcasecmp);
-
- if (!gtalk) { /* guest call */
- ASTOBJ_CONTAINER_TRAVERSE(>alk_list, 1, {
+
+ jingle = ASTOBJ_CONTAINER_FIND(&jingles, name);
+ if (!jingle && strchr(name, '@'))
+ jingle = ASTOBJ_CONTAINER_FIND_FULL(&jingles, name, user,,, strcasecmp);
+
+ if (!jingle) { /* guest call */
+ ASTOBJ_CONTAINER_TRAVERSE(&jingles, 1, {
ASTOBJ_RDLOCK(iterator);
if (!strcasecmp(iterator->name, "guest")) {
if (!strcasecmp(iterator->connection->jid->partial, connection)) {
- gtalk = iterator;
+ jingle = iterator;
} else if (!strcasecmp(iterator->connection->name, connection)) {
- gtalk = iterator;
+ jingle = iterator;
} else if (iterator->connection->component && !strcasecmp(iterator->connection->user,domain)) {
- gtalk = iterator;
+ jingle = iterator;
}
}
ASTOBJ_UNLOCK(iterator);
- if (gtalk)
+ if (jingle)
break;
});
}
- return gtalk;
-}
-
-
-static int add_codec_to_answer(const struct gtalk_pvt *p, int codec, iks *dcodecs)
+ return jingle;
+}
+
+
+static int add_codec_to_answer(const struct jingle_pvt *p, int codec, iks *dcodecs)
{
char *format = ast_getformatname(codec);
@@ -334,7 +332,6 @@
iks_insert_attrib(payload_pcma, "name", "PCMA");
iks_insert_attrib(payload_pcma, "clockrate","8000");
iks_insert_attrib(payload_pcma, "bitrate","64000");
- 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, "clockrate","8000");
@@ -382,31 +379,35 @@
return 0;
}
-static int gtalk_invite(struct gtalk_pvt *p, char *to, char *from, char *sid, int initiator)
-{
- struct gtalk *client = p->parent;
- iks *iq, *gtalk, *dcodecs, *payload_telephone, *transport;
+static int jingle_invite(struct jingle_pvt *p)
+{
+ struct jingle *client = p->parent;
+ iks *iq, *jingle, *dcodecs;
+ iks *transport, *payload_telephone, *payload_cn;
int x;
int pref_codec = 0;
int alreadysent = 0;
-
iq = iks_new("iq");
- gtalk = iks_new("session");
+ jingle = iks_new("session");
dcodecs = iks_new("description");
transport = iks_new("transport");
payload_telephone = iks_new("payload-type");
- if (!(iq && gtalk && dcodecs && transport && payload_telephone)){
+ payload_cn = iks_new("payload-type");
+
+ if (!(iq && jingle && dcodecs && transport && payload_telephone && payload_cn)) {
if(iq)
iks_delete(iq);
- if(gtalk)
- iks_delete(gtalk);
+ if(jingle)
+ iks_delete(jingle);
if(dcodecs)
iks_delete(dcodecs);
if(transport)
iks_delete(transport);
if(payload_telephone)
iks_delete(payload_telephone);
+ if(payload_cn)
+ iks_delete(payload_cn);
ast_log(LOG_ERROR, "Could not allocate iksemel nodes\n");
return 0;
@@ -429,33 +430,40 @@
iks_insert_attrib(payload_telephone, "name", "telephone-event");
iks_insert_attrib(payload_telephone, "clockrate", "8000");
+ iks_insert_attrib(payload_cn, "id", "13");
+ iks_insert_attrib(payload_cn, "name", "CN");
+ iks_insert_attrib(payload_cn, "clockrate", "8000");
+
iks_insert_attrib(transport,"xmlns","http://www.google.com/transport/p2p");
-
+
iks_insert_attrib(iq, "type", "set");
- iks_insert_attrib(iq, "to", to);
- iks_insert_attrib(iq, "from", from);
+ iks_insert_attrib(iq, "to", (p->them) ? p->them : client->user);
+ iks_insert_attrib(iq, "from", p->us);
iks_insert_attrib(iq, "id", client->connection->mid);
ast_aji_increment_mid(client->connection->mid);
- iks_insert_attrib(gtalk, "xmlns", "http://www.google.com/session");
- iks_insert_attrib(gtalk, "type",initiator ? "initiate": "accept");
- iks_insert_attrib(gtalk, "initiator", initiator ? from : to);
- iks_insert_attrib(gtalk, "id", sid);
- iks_insert_node(iq, gtalk);
- iks_insert_node(gtalk, dcodecs);
- iks_insert_node(gtalk, transport);
+ iks_insert_attrib(jingle, "xmlns", "http://www.google.com/session");
+ iks_insert_attrib(jingle, "type", p->initiator ? "initiate": "accept");
+ iks_insert_attrib(jingle, "initiator", p->initiator ? p->us : p->them);
+ iks_insert_attrib(jingle, "id", p->sid);
+ iks_insert_node(iq, jingle);
+ iks_insert_node(jingle, dcodecs);
+ iks_insert_node(jingle, transport);
iks_insert_node(dcodecs, payload_telephone);
+ iks_insert_node(dcodecs, payload_cn);
iks_send(client->connection->p, iq);
+ iks_delete(transport);
iks_delete(payload_telephone);
- iks_delete(transport);
+ iks_delete(payload_cn);
+
iks_delete(dcodecs);
- iks_delete(gtalk);
+ iks_delete(jingle);
iks_delete(iq);
return 1;
}
-static int gtalk_invite_response(struct gtalk_pvt *p, char *to , char *from, char *sid, int initiator)
+static int jingle_invite_response(struct jingle_pvt *p, int initiator)
{
iks *iq, *session, *transport;
iq = iks_new("iq");
@@ -471,14 +479,14 @@
ast_log(LOG_ERROR, " Unable to allocate IKS node\n");
return -1;
}
- iks_insert_attrib(iq, "from", from);
- iks_insert_attrib(iq, "to", to);
+ iks_insert_attrib(iq, "from", p->us);
+ iks_insert_attrib(iq, "to", p->them);
iks_insert_attrib(iq, "type", "set");
iks_insert_attrib(iq, "id",p->parent->connection->mid);
ast_aji_increment_mid(p->parent->connection->mid);
iks_insert_attrib(session, "type", "transport-accept");
- iks_insert_attrib(session, "id", sid);
- iks_insert_attrib(session, "initiator", initiator ? from : to);
+ iks_insert_attrib(session, "id", p->sid);
+ iks_insert_attrib(session, "initiator", initiator ? p->us : p->them);
iks_insert_attrib(session, "xmlns", "http://www.google.com/session");
iks_insert_attrib(transport, "xmlns", "http://www.google.com/transport/p2p");
iks_insert_node(iq,session);
@@ -491,9 +499,9 @@
}
-static int gtalk_ringing_ack(void *data, ikspak *pak)
-{
- struct gtalk_pvt *p = data;
+static int jingle_ringing_ack(void *data, ikspak *pak)
+{
+ struct jingle_pvt *p = data;
if (p->ringrule)
iks_filter_remove_rule(p->parent->connection->f, p->ringrule);
@@ -503,29 +511,29 @@
return IKS_FILTER_EAT;
}
-static int gtalk_answer(struct ast_channel *ast)
-{
- struct gtalk_pvt *p = ast->tech_pvt;
+static int jingle_answer(struct ast_channel *ast)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
int res = 0;
if (option_debug)
ast_log(LOG_DEBUG, "Answer!\n");
ast_mutex_lock(&p->lock);
- gtalk_invite(p, p->them, p->us,p->sid, 0);
+ jingle_invite(p);
ast_mutex_unlock(&p->lock);
return res;
}
-static enum ast_rtp_get_result gtalk_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
-{
- struct gtalk_pvt *p = chan->tech_pvt;
+static enum ast_rtp_get_result jingle_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
+{
+ struct jingle_pvt *p = chan->tech_pvt;
enum ast_rtp_get_result res = AST_RTP_GET_FAILED;
if (!p)
return res;
ast_mutex_lock(&p->lock);
- if (p->rtp){
+ if (p->rtp) {
*rtp = p->rtp;
res = AST_RTP_TRY_NATIVE;
}
@@ -534,15 +542,15 @@
return res;
}
-static int gtalk_get_codec(struct ast_channel *chan)
-{
- struct gtalk_pvt *p = chan->tech_pvt;
+static int jingle_get_codec(struct ast_channel *chan)
+{
+ struct jingle_pvt *p = chan->tech_pvt;
return p->peercapability;
}
-static int gtalk_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
-{
- struct gtalk_pvt *p;
+static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
+{
+ struct jingle_pvt *p;
p = chan->tech_pvt;
if (!p)
@@ -560,7 +568,7 @@
return 0;
}
-static int gtalk_response(struct gtalk *client, char *from, ikspak *pak, const char *reasonstr, const char *reasonstr2)
+static int jingle_response(struct jingle *client, char *from, ikspak *pak, const char *reasonstr, const char *reasonstr2)
{
iks *response = NULL, *error = NULL, *reason = NULL;
int res = -1;
@@ -592,9 +600,9 @@
return res;
}
-static int gtalk_is_answered(struct gtalk *client, ikspak *pak)
-{
- struct gtalk_pvt *tmp;
+static int jingle_is_answered(struct jingle *client, ikspak *pak)
+{
+ struct jingle_pvt *tmp;
char *from;
if (option_debug)
ast_log(LOG_DEBUG, "The client is %s\n", client->name);
@@ -613,13 +621,13 @@
ast_queue_control(tmp->owner, AST_CONTROL_ANSWER);
} else
ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
- gtalk_response(client, from, pak, NULL, NULL);
+ jingle_response(client, from, pak, NULL, NULL);
return 1;
}
-static int gtalk_handle_dtmf(struct gtalk *client, ikspak *pak)
-{
- struct gtalk_pvt *tmp;
+static int jingle_handle_dtmf(struct jingle *client, ikspak *pak)
+{
+ struct jingle_pvt *tmp;
iks *dtmfnode = NULL;
char *dtmf;
char *from;
@@ -635,9 +643,9 @@
if (tmp) {
if(iks_find_with_attrib(pak->x, "dtmf-method", "method", "rtp")) {
- gtalk_response(client, from, pak,
+ jingle_response(client, from, pak,
"feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'",
- "unsupported-dtmf-method xmlns='http://jabber.org/protocol/gtalk/info/dtmf#errors'");
+ "unsupported-dtmf-method xmlns='http://jabber.org/protocol/jingle/info/dtmf#errors'");
return -1;
}
if ((dtmfnode = iks_find(pak->x, "dtmf"))) {
@@ -646,33 +654,33 @@
struct ast_frame f = {AST_FRAME_DTMF_BEGIN, };
f.subclass = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
} else if(iks_find_with_attrib(pak->x, "dtmf", "action", "button-down")) {
struct ast_frame f = {AST_FRAME_DTMF_END, };
f.subclass = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
} else if(iks_find_attrib(pak->x, "dtmf")) { /* 250 millasecond default */
struct ast_frame f = {AST_FRAME_DTMF, };
f.subclass = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
}
}
}
- gtalk_response(client, from, pak, NULL, NULL);
+ jingle_response(client, from, pak, NULL, NULL);
return 1;
} else
ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
- gtalk_response(client, from, pak, NULL, NULL);
+ jingle_response(client, from, pak, NULL, NULL);
return 1;
}
-static int gtalk_hangup_farend(struct gtalk *client, ikspak *pak)
-{
- struct gtalk_pvt *tmp;
+static int jingle_hangup_farend(struct jingle *client, ikspak *pak)
+{
+ struct jingle_pvt *tmp;
char *from;
if (option_debug)
@@ -692,27 +700,27 @@
ast_queue_hangup(tmp->owner);
} else
ast_log(LOG_NOTICE, "Whoa, didn't find call!\n");
- gtalk_response(client, from, pak, NULL, NULL);
+ jingle_response(client, from, pak, NULL, NULL);
return 1;
}
-static int gtalk_create_candidates(struct gtalk *client, struct gtalk_pvt *p, char *sid, char *from, char *to)
-{
- struct gtalk_candidate *tmp;
+static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p, char *sid, char *from, char *to)
+{
+ struct jingle_candidate *tmp;
struct aji_client *c = client->connection;
- struct gtalk_candidate *ours1 = NULL, *ours2 = NULL;
+ struct jingle_candidate *ours1 = NULL, *ours2 = NULL;
struct sockaddr_in sin;
struct sockaddr_in dest;
struct in_addr us;
- iks *iq, *gtalk, *candidate, *transport;
+ iks *iq, *jingle, *candidate, *transport;
char user[17], pass[17], preference[5], port[7];
iq = iks_new("iq");
- gtalk = iks_new("session");
+ jingle = iks_new("session");
candidate = iks_new("candidate");
transport = iks_new("transport");
- if (!iq || !gtalk || !candidate || !transport) {
+ if (!iq || !jingle || !candidate || !transport) {
ast_log(LOG_ERROR, "Memory allocation error\n");
goto safeout;
}
@@ -722,8 +730,8 @@
goto safeout;
iks_insert_attrib(transport, "xmlns","http://www.google.com/transport/p2p");
- iks_insert_node(iq, gtalk);
- iks_insert_node(gtalk,transport);
+ iks_insert_node(iq, jingle);
+ iks_insert_node(jingle,transport);
iks_insert_node(transport, candidate);
for (; p; p = p->next) {
@@ -732,14 +740,14 @@
}
if (!p) {
- ast_log(LOG_NOTICE, "No matching gtalk session - SID %s!\n", sid);
+ ast_log(LOG_NOTICE, "No matching jingle session - SID %s!\n", sid);
goto safeout;
}
ast_rtp_get_us(p->rtp, &sin);
ast_find_ourip(&us, bindaddr);
- /* Setup our gtalk candidates */
+ /* Setup our jingle candidates */
ast_copy_string(ours1->name, "rtp", sizeof(ours1->name));
ours1->port = ntohs(sin.sin_port);
ours1->preference = 1;
@@ -782,10 +790,10 @@
iks_insert_attrib(iq, "type", "set");
iks_insert_attrib(iq, "id", c->mid);
ast_aji_increment_mid(c->mid);
- iks_insert_attrib(gtalk, "type", "transport-info");
- iks_insert_attrib(gtalk, "id", sid);
- iks_insert_attrib(gtalk, "initiator", (p->initiator) ? to : from);
- iks_insert_attrib(gtalk, "xmlns", GOOGLE_NS);
+ iks_insert_attrib(jingle, "type", "transport-info");
+ iks_insert_attrib(jingle, "id", sid);
+ iks_insert_attrib(jingle, "initiator", (p->initiator) ? to : from);
+ iks_insert_attrib(jingle, "xmlns", "http://www.google.com/session");
iks_insert_attrib(candidate, "name", tmp->name);
iks_insert_attrib(candidate, "address", tmp->ip);
iks_insert_attrib(candidate, "port", port);
@@ -815,8 +823,8 @@
free(ours2);
if (iq)
iks_delete(iq);
- if (gtalk)
- iks_delete(gtalk);
+ if (jingle)
+ iks_delete(jingle);
if (candidate)
iks_delete(candidate);
if(transport)
@@ -824,9 +832,9 @@
return 1;
}
-static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const char *them, const char *sid)
-{
- struct gtalk_pvt *tmp = NULL;
+static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *us, const char *them, const char *sid)
+{
+ struct jingle_pvt *tmp = NULL;
struct aji_resource *resources = NULL;
struct aji_buddy *buddy;
char idroster[200];
@@ -850,7 +858,7 @@
if (resources)
snprintf(idroster, sizeof(idroster), "%s/%s", them, resources->resource);
else {
- ast_log(LOG_ERROR, "no gtalk capable clients to talk to.\n");
+ ast_log(LOG_ERROR, "no jingle capable clients to talk to.\n");
return NULL;
}
}
@@ -882,15 +890,15 @@
exten = tmp->us;
ast_copy_string(tmp->exten, exten, sizeof(tmp->exten));
ast_mutex_init(&tmp->lock);
- ast_mutex_lock(>alklock);
+ ast_mutex_lock(&jinglelock);
tmp->next = client->p;
client->p = tmp;
- ast_mutex_unlock(>alklock);
+ ast_mutex_unlock(&jinglelock);
return tmp;
}
-/*! \brief Start new gtalk channel */
-static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i, int state, const char *title)
+/*! \brief Start new jingle channel */
+static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *i, int state, const char *title)
{
struct ast_channel *tmp;
int fmt;
@@ -901,16 +909,15 @@
n2 = title;
else
n2 = i->us;
- tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, "Gtalk/%s-%04lx", n2, ast_random() & 0xffff);
+ tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, "Jingle/%s-%04lx", n2, ast_random() & 0xffff);
if (!tmp) {
- ast_log(LOG_WARNING, "Unable to allocate Gtalk channel structure!\n");
+ ast_log(LOG_WARNING, "Unable to allocate Jingle channel structure!\n");
return NULL;
}
- tmp->tech = >alk_tech;
+ tmp->tech = &jingle_tech;
/* Select our native format based on codec preference until we receive
something from another device to the contrary. */
-/* ast_verbose("XXXXXXXXXXXXX\nXXX i->jointcapability = %X\nXXX i->capability = %X\nXXX global_capability %X\n XXXXXXXXXXXX\n",i->jointcapability,i->capability,global_capability); */
if (i->jointcapability)
what = i->jointcapability;
else if (i->capability)
@@ -974,7 +981,7 @@
return tmp;
}
-static int gtalk_action(struct gtalk *client, struct gtalk_pvt *p, const char *action)
+static int jingle_action(struct jingle *client, struct jingle_pvt *p, const char *action)
{
iks *request, *session = NULL;
int res = -1;
@@ -1002,9 +1009,9 @@
return res;
}
-static void gtalk_free_candidates(struct gtalk_candidate *candidate)
-{
- struct gtalk_candidate *last;
+static void jingle_free_candidates(struct jingle_candidate *candidate)
+{
+ struct jingle_candidate *last;
while (candidate) {
last = candidate;
candidate = candidate->next;
@@ -1012,9 +1019,9 @@
}
}
-static void gtalk_free_pvt(struct gtalk *client, struct gtalk_pvt *p)
-{
- struct gtalk_pvt *cur, *prev = NULL;
+static void jingle_free_pvt(struct jingle *client, struct jingle_pvt *p)
+{
+ struct jingle_pvt *cur, *prev = NULL;
cur = client->p;
while (cur) {
if (cur == p) {
@@ -1035,14 +1042,14 @@
ast_rtp_destroy(p->rtp);
if (p->vrtp)
ast_rtp_destroy(p->vrtp);
- gtalk_free_candidates(p->theircandidates);
+ jingle_free_candidates(p->theircandidates);
free(p);
}
-static int gtalk_newcall(struct gtalk *client, ikspak *pak)
-{
- struct gtalk_pvt *p, *tmp = client->p;
+static int jingle_newcall(struct jingle *client, ikspak *pak)
+{
+ struct jingle_pvt *p, *tmp = client->p;
struct ast_channel *chan;
int res;
iks *codec;
@@ -1055,18 +1062,18 @@
while (tmp) {
if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid)) {
ast_log(LOG_NOTICE, "Ignoring duplicate call setup on SID %s\n", tmp->sid);
- gtalk_response(client, from, pak, "out-of-order", NULL);
+ jingle_response(client, from, pak, "out-of-order", NULL);
return -1;
}
tmp = tmp->next;
}
- p = gtalk_alloc(client, from, pak->from->full, iks_find_attrib(pak->query, "id"));
+ p = jingle_alloc(client, from, pak->from->full, iks_find_attrib(pak->query, "id"));
if (!p) {
- ast_log(LOG_WARNING, "Unable to allocate gtalk structure!\n");
+ ast_log(LOG_WARNING, "Unable to allocate jingle structure!\n");
return -1;
}
- chan = gtalk_new(client, p, AST_STATE_DOWN, 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->them, pak->from->full, sizeof(p->them));
@@ -1090,28 +1097,28 @@
switch (res) {
case AST_PBX_FAILED:
ast_log(LOG_WARNING, "Failed to start PBX :(\n");
- gtalk_response(client, from, pak, "service-unavailable", NULL);
+ jingle_response(client, from, pak, "service-unavailable", NULL);
break;
case AST_PBX_CALL_LIMIT:
ast_log(LOG_WARNING, "Failed to start PBX (call limit reached) \n");
- gtalk_response(client, from, pak, "service-unavailable", NULL);
+ jingle_response(client, from, pak, "service-unavailable", NULL);
break;
case AST_PBX_SUCCESS:
- gtalk_response(client, from, pak, NULL, NULL);
- gtalk_invite_response(p, p->them, p->us,p->sid, 0);
- gtalk_create_candidates(client, p, p->sid, p->them, p->us);
+ jingle_response(client, from, pak, NULL, NULL);
+ jingle_invite_response(p, 0);
+ jingle_create_candidates(client, p, p->sid, p->them, p->us);
/* nothing to do */
break;
}
} else {
- gtalk_free_pvt(client, p);
+ jingle_free_pvt(client, p);
}
return 1;
}
-static int gtalk_update_stun(struct gtalk *client, struct gtalk_pvt *p)
-{
- struct gtalk_candidate *tmp;
+static int jingle_update_stun(struct jingle *client, struct jingle_pvt *p)
+{
+ struct jingle_candidate *tmp;
struct hostent *hp;
struct ast_hostent ahp;
struct sockaddr_in sin;
@@ -1136,11 +1143,11 @@
return 1;
}
-static int gtalk_add_candidate(struct gtalk *client, ikspak *pak)
-{
- struct gtalk_pvt *p = NULL, *tmp = NULL;
+static int jingle_add_candidate(struct jingle *client, ikspak *pak)
+{
+ struct jingle_pvt *p = NULL, *tmp = NULL;
struct aji_client *c = client->connection;
- struct gtalk_candidate *newcandidate = NULL;
+ struct jingle_candidate *newcandidate = NULL;
iks *traversenodes = NULL, *receipt = NULL;
char *from;
@@ -1204,7 +1211,7 @@
newcandidate->next = p->theircandidates;
p->theircandidates = newcandidate;
p->laststun = 0;
- gtalk_update_stun(p->parent, p);
+ jingle_update_stun(p->parent, p);
newcandidate = NULL;
}
traversenodes = iks_next(traversenodes);
@@ -1221,14 +1228,14 @@
return 1;
}
-static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pvt *p)
+static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_pvt *p)
{
struct ast_frame *f;
if (!p->rtp)
return &ast_null_frame;
f = ast_rtp_read(p->rtp);
- gtalk_update_stun(p->parent, p);
+ jingle_update_stun(p->parent, p);
if (p->owner) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
@@ -1243,29 +1250,28 @@
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
if (option_debug && f && (f->frametype == AST_FRAME_DTMF))
- if (option_debug)
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
} */
}
}
return f;
}
-static struct ast_frame *gtalk_read(struct ast_channel *ast)
+static struct ast_frame *jingle_read(struct ast_channel *ast)
{
struct ast_frame *fr;
- struct gtalk_pvt *p = ast->tech_pvt;
+ struct jingle_pvt *p = ast->tech_pvt;
ast_mutex_lock(&p->lock);
- fr = gtalk_rtp_read(ast, p);
+ fr = jingle_rtp_read(ast, p);
ast_mutex_unlock(&p->lock);
return fr;
}
/*! \brief Send frame to media channel (rtp) */
-static int gtalk_write(struct ast_channel *ast, struct ast_frame *frame)
-{
- struct gtalk_pvt *p = ast->tech_pvt;
+static int jingle_write(struct ast_channel *ast, struct ast_frame *frame)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
int res = 0;
switch (frame->frametype) {
@@ -1298,7 +1304,7 @@
return 0;
break;
default:
- ast_log(LOG_WARNING, "Can't send %d type frames with Gtalk write\n",
+ ast_log(LOG_WARNING, "Can't send %d type frames with Jingle write\n",
frame->frametype);
return 0;
}
@@ -1306,9 +1312,9 @@
return res;
}
-static int gtalk_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
-{
- struct gtalk_pvt *p = newchan->tech_pvt;
+static int jingle_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
+{
+ struct jingle_pvt *p = newchan->tech_pvt;
ast_mutex_lock(&p->lock);
if ((p->owner != oldchan)) {
@@ -1321,7 +1327,7 @@
return 0;
}
-static int gtalk_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
+static int jingle_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
{
int res = 0;
@@ -1340,30 +1346,20 @@
return res;
}
-static int gtalk_digit_begin(struct ast_channel *chan, char digit)
-{
- return gtalk_digit(chan, digit, 0);
-}
-
-static int gtalk_digit_end(struct ast_channel *chan, char digit, unsigned int duration)
-{
- return gtalk_digit(chan, digit, duration);
-}
-
-static int gtalk_digit(struct ast_channel *ast, char digit, unsigned int duration)
-{
- struct gtalk_pvt *p = ast->tech_pvt;
- struct gtalk *client = p->parent;
- iks *iq, *gtalk, *dtmf;
+static int jingle_digit(struct ast_channel *ast, char digit, unsigned int duration)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
+ struct jingle *client = p->parent;
+ iks *iq, *jingle, *dtmf;
char buffer[2] = {digit, '\0'};
iq = iks_new("iq");
- gtalk = iks_new("gtalk");
+ jingle = iks_new("jingle");
dtmf = iks_new("dtmf");
- if(!iq || !gtalk || !dtmf) {
+ if(!iq || !jingle || !dtmf) {
if(iq)
iks_delete(iq);
- if(gtalk)
- iks_delete(gtalk);
+ if(jingle)
+ iks_delete(jingle);
if(dtmf)
iks_delete(dtmf);
ast_log(LOG_ERROR, "Did not send dtmf do to memory issue\n");
@@ -1375,14 +1371,14 @@
iks_insert_attrib(iq, "from", p->us);
iks_insert_attrib(iq, "id", client->connection->mid);
ast_aji_increment_mid(client->connection->mid);
- iks_insert_attrib(gtalk, "xmlns", "http://jabber.org/protocol/gtalk");
- iks_insert_attrib(gtalk, "action", "content-info");
- iks_insert_attrib(gtalk, "initiator", p->initiator ? p->us: p->them);
- iks_insert_attrib(gtalk, "sid", p->sid);
- iks_insert_attrib(dtmf, "xmlns", "http://jabber.org/protocol/gtalk/info/dtmf");
+ iks_insert_attrib(jingle, "xmlns", "http://jabber.org/protocol/jingle");
+ iks_insert_attrib(jingle, "action", "content-info");
+ iks_insert_attrib(jingle, "initiator", p->initiator ? p->us : p->them);
+ iks_insert_attrib(jingle, "sid", p->sid);
+ iks_insert_attrib(dtmf, "xmlns", "http://jabber.org/protocol/jingle/info/dtmf");
iks_insert_attrib(dtmf, "code", buffer);
- iks_insert_node(iq, gtalk);
- iks_insert_node(gtalk, dtmf);
+ iks_insert_node(iq, jingle);
+ iks_insert_node(jingle, dtmf);
ast_mutex_lock(&p->lock);
if (ast->dtmff.frametype == AST_FRAME_DTMF_BEGIN) {
@@ -1392,23 +1388,33 @@
}
iks_send(client->connection->p, iq);
iks_delete(iq);
- iks_delete(gtalk);
+ iks_delete(jingle);
iks_delete(dtmf);
ast_mutex_unlock(&p->lock);
return 0;
}
-static int gtalk_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
-{
- ast_log(LOG_NOTICE, "XXX Implement gtalk sendhtml XXX\n");
+static int jingle_digit_begin(struct ast_channel *ast, char digit)
+{
+ return jingle_digit(ast, digit, 0);
+}
+
+static int jingle_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
+{
+ return jingle_digit(ast, digit, duration);
+}
+
+static int jingle_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
+{
+ ast_log(LOG_NOTICE, "XXX Implement jingle sendhtml XXX\n");
return -1;
}
/* Not in use right now.
-static int gtalk_auto_congest(void *nothing)
-{
- struct gtalk_pvt *p = nothing;
+static int jingle_auto_congest(void *nothing)
+{
+ struct jingle_pvt *p = nothing;
ast_mutex_lock(&p->lock);
if (p->owner) {
@@ -1425,12 +1431,12 @@
/*! \brief Initiate new call, part of PBX interface
* dest is the dial string */
-static int gtalk_call(struct ast_channel *ast, char *dest, int timeout)
-{
- struct gtalk_pvt *p = ast->tech_pvt;
+static int jingle_call(struct ast_channel *ast, char *dest, int timeout)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
- ast_log(LOG_WARNING, "gtalk_call called on %s, neither down nor reserved\n", ast->name);
+ ast_log(LOG_WARNING, "jingle_call called on %s, neither down nor reserved\n", ast->name);
return -1;
}
@@ -1438,42 +1444,42 @@
p->jointcapability = p->capability;
if (!p->ringrule) {
ast_copy_string(p->ring, p->parent->connection->mid, sizeof(p->ring));
- p->ringrule = iks_filter_add_rule(p->parent->connection->f, gtalk_ringing_ack, p,
+ p->ringrule = iks_filter_add_rule(p->parent->connection->f, jingle_ringing_ack, p,
IKS_RULE_ID, p->ring, IKS_RULE_DONE);
} else
ast_log(LOG_WARNING, "Whoa, already have a ring rule!\n");
- gtalk_invite(p, p->them, p->us, p->sid, 1);
- gtalk_create_candidates(p->parent, p, p->sid, p->them, p->us);
+ jingle_invite(p);
+ jingle_create_candidates(p->parent, p, p->sid, p->them, p->us);
return 0;
}
-/*! \brief Hangup a call through the gtalk proxy channel */
-static int gtalk_hangup(struct ast_channel *ast)
-{
- struct gtalk_pvt *p = ast->tech_pvt;
- struct gtalk *client;
+/*! \brief Hangup a call through the jingle proxy channel */
+static int jingle_hangup(struct ast_channel *ast)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
+ struct jingle *client;
ast_mutex_lock(&p->lock);
client = p->parent;
p->owner = NULL;
ast->tech_pvt = NULL;
if (!p->alreadygone)
- gtalk_action(client, p, "terminate");
+ jingle_action(client, p, "terminate");
ast_mutex_unlock(&p->lock);
- gtalk_free_pvt(client, p);
+ jingle_free_pvt(client, p);
ast_module_unref(ast_module_info->self);
return 0;
}
/*! \brief Part of PBX interface */
-static struct ast_channel *gtalk_request(const char *type, int format, void *data, int *cause)
-{
- struct gtalk_pvt *p = NULL;
- struct gtalk *client = NULL;
+static struct ast_channel *jingle_request(const char *type, int format, void *data, int *cause)
+{
+ struct jingle_pvt *p = NULL;
+ struct jingle *client = NULL;
char *sender = NULL, *to = NULL, *s = NULL;
struct ast_channel *chan = NULL;
@@ -1484,77 +1490,77 @@
if (sender && (sender[0] != '\0'))
to = strsep(&s, "/");
if (!to) {
- ast_log(LOG_ERROR, "Bad arguments in Gtalk Dialstring: %s\n", (char*) data);
+ ast_log(LOG_ERROR, "Bad arguments in Jingle Dialstring: %s\n", (char*) data);
return NULL;
}
}
}
- client = find_gtalk(to, sender);
+ client = find_jingle(to, sender);
if (!client) {
ast_log(LOG_WARNING, "Could not find recipient.\n");
return NULL;
}
ASTOBJ_WRLOCK(client);
- p = gtalk_alloc(client, strchr(sender, '@') ? sender : client->connection->jid->full, strchr(to, '@') ? to : client->user, NULL);
+ p = jingle_alloc(client, strchr(sender, '@') ? sender : client->connection->jid->full, strchr(to, '@') ? to : client->user, NULL);
if (p)
- chan = gtalk_new(client, p, AST_STATE_DOWN, to);
+ chan = jingle_new(client, p, AST_STATE_DOWN, to);
ASTOBJ_UNLOCK(client);
return chan;
}
-/*! \brief CLI command "gtalk show channels" */
-static int gtalk_show_channels(int fd, int argc, char **argv)
+/*! \brief CLI command "jingle show channels" */
+static int jingle_show_channels(int fd, int argc, char **argv)
{
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_mutex_lock(>alklock);
-// if (!gtalk_list->p)
- ast_cli(fd, "No gtalk channels in use\n");
- ast_mutex_unlock(>alklock);
+ ast_mutex_lock(&jinglelock);
+// if (!jingles->p)
[... 289 lines stripped ...]
More information about the svn-commits
mailing list