Code simplification

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@118614 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Philippe Sultan 18 years ago
parent a06df81624
commit 2ab8f076bf

@ -956,7 +956,7 @@ static int jingle_newcall(struct jingle *client, ikspak *pak)
struct jingle_pvt *p, *tmp = client->p; struct jingle_pvt *p, *tmp = client->p;
struct ast_channel *chan; struct ast_channel *chan;
int res; int res;
iks *payload_type; iks *codec;
/* Make sure our new call doesn't exist yet */ /* Make sure our new call doesn't exist yet */
while (tmp) { while (tmp) {
@ -974,45 +974,47 @@ static int jingle_newcall(struct jingle *client, ikspak *pak)
return -1; return -1;
} }
chan = jingle_new(client, p, AST_STATE_DOWN, pak->from->user); chan = jingle_new(client, p, AST_STATE_DOWN, pak->from->user);
if (chan) { if (!chan) {
ast_mutex_lock(&p->lock); jingle_free_pvt(client, p);
ast_copy_string(p->them, pak->from->full, sizeof(p->them)); return -1;
if (iks_find_attrib(pak->query, JINGLE_SID)) { }
ast_copy_string(p->sid, iks_find_attrib(pak->query, JINGLE_SID), ast_mutex_lock(&p->lock);
sizeof(p->sid)); ast_copy_string(p->them, pak->from->full, sizeof(p->them));
} if (iks_find_attrib(pak->query, JINGLE_SID)) {
ast_copy_string(p->sid, iks_find_attrib(pak->query, JINGLE_SID),
sizeof(p->sid));
}
payload_type = iks_child(iks_child(iks_child(iks_child(pak->x)))); /* codec points to the first <payload-type/> tag */
while (payload_type) { codec = iks_child(iks_child(iks_child(iks_child(pak->x))));
ast_rtp_set_m_type(p->rtp, atoi(iks_find_attrib(payload_type, "id"))); while (codec) {
ast_rtp_set_rtpmap_type(p->rtp, atoi(iks_find_attrib(payload_type, "id")), "audio", iks_find_attrib(payload_type, "name"), 0); ast_rtp_set_m_type(p->rtp, atoi(iks_find_attrib(codec, "id")));
payload_type = iks_next(payload_type); ast_rtp_set_rtpmap_type(p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
} codec = iks_next(codec);
}
ast_mutex_unlock(&p->lock); ast_mutex_unlock(&p->lock);
ast_setstate(chan, AST_STATE_RING); ast_setstate(chan, AST_STATE_RING);
res = ast_pbx_start(chan); res = ast_pbx_start(chan);
switch (res) { switch (res) {
case AST_PBX_FAILED: case AST_PBX_FAILED:
ast_log(LOG_WARNING, "Failed to start PBX :(\n"); ast_log(LOG_WARNING, "Failed to start PBX :(\n");
jingle_response(client, pak, "service-unavailable", NULL); jingle_response(client, pak, "service-unavailable", NULL);
break; break;
case AST_PBX_CALL_LIMIT: case AST_PBX_CALL_LIMIT:
ast_log(LOG_WARNING, "Failed to start PBX (call limit reached) \n"); ast_log(LOG_WARNING, "Failed to start PBX (call limit reached) \n");
jingle_response(client, pak, "service-unavailable", NULL); jingle_response(client, pak, "service-unavailable", NULL);
break; break;
case AST_PBX_SUCCESS: case AST_PBX_SUCCESS:
jingle_response(client, pak, NULL, NULL); jingle_response(client, pak, NULL, NULL);
jingle_create_candidates(client, p, jingle_create_candidates(client, p,
iks_find_attrib(pak->query, JINGLE_SID), iks_find_attrib(pak->query, JINGLE_SID),
iks_find_attrib(pak->x, "from")); iks_find_attrib(pak->x, "from"));
/* nothing to do */ /* nothing to do */
break; break;
}
} else {
jingle_free_pvt(client, p);
} }
return 1; return 1;
} }

Loading…
Cancel
Save