[svn-commits] branch mogorman/asterisk-xmpp r20131 -
/team/mogorman/asterisk-xmpp/channels/
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Fri Apr 14 13:36:29 MST 2006
Author: markster
Date: Fri Apr 14 15:36:28 2006
New Revision: 20131
URL: http://svn.digium.com/view/asterisk?rev=20131&view=rev
Log:
Get answer code isolated into proper answer location!
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=20131&r1=20130&r2=20131&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_jingle.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_jingle.c Fri Apr 14 15:36:28 2006
@@ -193,16 +193,132 @@
return 0;
}
+static void add_codec_to_answer(const struct jingle_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))) {
+ iks *payload_eg711u , *payload_pcmu;
+ 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",GOOGLE_NS);
+ 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",GOOGLE_NS);
+ iks_insert_node(description,payload_pcmu);
+ iks_insert_node(description,payload_eg711u);
+ }
+ if(!strcasecmp("alaw",ast_getformatname(codec))) {
+ iks *payload_eg711a , *payload_pcma;
+ 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",GOOGLE_NS);
+ 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",GOOGLE_NS);
+ iks_insert_node(description,payload_pcma);
+ iks_insert_node(description,payload_eg711a);
+ }
+ if(!strcasecmp("ilbc",ast_getformatname(codec))) {
+ iks *payload_ilbc;
+ 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",GOOGLE_NS);
+ iks_insert_node(description,payload_ilbc);
+ }
+ if(!strcasecmp("g723",ast_getformatname(codec))) {
+ iks *payload_g723;
+ 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",GOOGLE_NS);
+ iks_insert_node(description,payload_g723);
+ }
+ ast_rtp_lookup_code(p->rtp, 1, codec);
+}
+
+static int jingle_accept_call(struct jingle *client, struct jingle_pvt *p)
+{
+ struct jingle_pvt *tmp = client->p;
+ struct aji_client *c = client->connection;
+ iks *iq, *jingle, *description, /* *payload_ipcmwb, *payload_isac,*/ *payload_red, *payload_audio, *payload_cn;
+ int x;
+ int pref_codec = 0;
+ int alreadysent = 0;
+ char mid[50];
+
+ iq = iks_new("iq");
+ jingle = iks_new(GOOGLE_NODE);
+ description = iks_new("description");
+ if (iq && jingle && description) {
+ iks_insert_attrib(description,"xmlns",GOOGLE_NS);
+
+ for (x = 0; x < 32; x++) {
+ if (!(pref_codec = ast_codec_pref_index(&client->prefs, x)))
+ break;
+ if (!(client->capability & pref_codec))
+ continue;
+ if (alreadysent & pref_codec)
+ continue;
+ if (pref_codec <= AST_FORMAT_MAX_AUDIO)
+ add_codec_to_answer(p, pref_codec, description);
+ else
+ add_codec_to_answer(p, pref_codec, description);
+ alreadysent |= pref_codec;
+ }
+ 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",GOOGLE_NS);
+ 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",GOOGLE_NS);
+ 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",GOOGLE_NS);
+
+
+ iks_insert_attrib(iq,"type","set");
+ iks_insert_attrib(iq,"from",c->jid->full);
+ iks_insert_attrib(iq,"to",p->from);
+ 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);
+ iks_insert_attrib(jingle, "initiator", p->initiator ? client->connection->jid->full : p->from);
+ iks_insert_attrib(jingle, GOOGLE_SID, tmp->sid);
+ iks_insert_node(iq,jingle);
+ iks_insert_node(jingle,description);
+ iks_insert_node(description,payload_red);
+ iks_insert_node(description,payload_audio);
+ iks_insert_node(description,payload_cn);
+
+ iks_send(c->p,iq);
+ iks_delete(payload_red);
+ iks_delete(payload_audio);
+ iks_delete(payload_cn);
+ iks_delete(description);
+ iks_delete(jingle);
+ iks_delete(iq);
+ }
+ return 1;
+}
+
static int jingle_answer(struct ast_channel *ast)
{
struct jingle_pvt *p = ast->tech_pvt;
- int isoutbound =1;
- int res = -1;
-
+ struct jingle *client = p->parent;
+ int res = 0;
+ ast_log(LOG_DEBUG, "Answer!\n");
ast_mutex_lock(&p->lock);
- // Pass along answer since somebody answered us
- struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
- res = jingle_queue_frame(p, isoutbound, &answer, ast);
+ jingle_accept_call(client, p);
ast_mutex_unlock(&p->lock);
return res;
}
@@ -539,139 +655,6 @@
return 1;
}
-static void add_codec_to_answer(const struct jingle_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))) {
- iks *payload_eg711u , *payload_pcmu;
- 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",GOOGLE_NS);
- 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",GOOGLE_NS);
- iks_insert_node(description,payload_pcmu);
- iks_insert_node(description,payload_eg711u);
- }
- if(!strcasecmp("alaw",ast_getformatname(codec))) {
- iks *payload_eg711a , *payload_pcma;
- 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",GOOGLE_NS);
- 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",GOOGLE_NS);
- iks_insert_node(description,payload_pcma);
- iks_insert_node(description,payload_eg711a);
- }
- if(!strcasecmp("ilbc",ast_getformatname(codec))) {
- iks *payload_ilbc;
- 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",GOOGLE_NS);
- iks_insert_node(description,payload_ilbc);
- }
- if(!strcasecmp("g723",ast_getformatname(codec))) {
- iks *payload_g723;
- 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",GOOGLE_NS);
- iks_insert_node(description,payload_g723);
- }
- ast_rtp_lookup_code(p->rtp, 1, codec);
-}
-
-static int jingle_accept_call(struct jingle *client, ikspak *pak)
-{
- struct jingle_pvt *tmp = client->p;
- struct aji_client *c = client->connection;
- iks *iq, *jingle, *description, /* *payload_ipcmwb, *payload_isac,*/ *payload_red, *payload_audio, *payload_cn;
- 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");
- jingle = iks_new(GOOGLE_NODE);
- description = iks_new("description");
- iks_insert_attrib(description,"xmlns",GOOGLE_NS);
-
- for (x = 0; x < 32; x++) {
- if (!(pref_codec = ast_codec_pref_index(&client->prefs, x)))
- break;
- if (!(client->capability & pref_codec))
- continue;
- if (alreadysent & pref_codec)
- continue;
- if (pref_codec <= AST_FORMAT_MAX_AUDIO)
- add_codec_to_answer(tmp, pref_codec, description);
- else
- add_codec_to_answer(tmp, pref_codec, description);
- alreadysent |= pref_codec;
- }
-/* 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_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",GOOGLE_NS);
- 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",GOOGLE_NS);
- 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",GOOGLE_NS);
-
-
- iks_insert_attrib(iq,"type","set");
- iks_insert_attrib(iq,"from",c->jid->full);
- iks_insert_attrib(iq,"to",iks_find_attrib(pak->x,"from"));
- 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);
- iks_insert_attrib(jingle, "initiator", iks_find_attrib(pak->x,"from"));
- iks_insert_attrib(jingle, GOOGLE_SID, tmp->sid);
- iks_insert_node(iq,jingle);
- iks_insert_node(jingle,description);
- /* iks_insert_node(description,payload_ipcmwb);
- iks_insert_node(description,payload_isac);*/
- iks_insert_node(description,payload_red);
- iks_insert_node(description,payload_audio);
- iks_insert_node(description,payload_cn);
-
- iks_send(c->p,iq);
- /* iks_delete(payload_ipcmwb);
- iks_delete(payload_isac); */
- iks_delete(payload_red);
- iks_delete(payload_audio);
- iks_delete(payload_cn);
- iks_delete(description);
- iks_delete(jingle);
- iks_delete(iq);
- }
- tmp=tmp->next;
- }
- return 1;
-}
-
static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from, const char *sid)
{
struct jingle_pvt *tmp = client->p;
@@ -687,6 +670,7 @@
return NULL;
}
ast_copy_string(tmp->from, from, sizeof(tmp->from));
+ ast_copy_string(tmp->exten, "s", sizeof(tmp->exten));
if (sid)
ast_copy_string(tmp->sid, sid, sizeof(tmp->sid));
else
@@ -901,6 +885,7 @@
codec= iks_next(codec);
}
ast_mutex_unlock(&p->lock);
+ ast_setstate(chan, AST_STATE_RING);
res = ast_pbx_start(chan);
jingle_create_candidates(client, p, pak);
@@ -1304,7 +1289,6 @@
jingle_add_candidate(client,pak);
if(flipflop == 2) {
flipflop = 0;
- jingle_accept_call(client,pak);
}
else {
ast_verbose("COUNT IS %d\n",flipflop);
More information about the svn-commits
mailing list