Module: sems Branch: rco/offer_answer Commit: df112a619f614711bd3493d2e28b9e404c774ad0 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=df112a619f614711bd3493d2e28b9e404c774ad0
Author: Raphael Coeffic <[email protected]> Committer: Raphael Coeffic <[email protected]> Date: Fri Jun 4 15:50:57 2010 +0200 simplified AmSipDialog::send_200_ack() parameters: only the INVITE cseq is needed. --- core/AmB2BSession.cpp | 9 +++------ core/AmSession.cpp | 11 ++++------- core/AmSipDialog.cpp | 16 +++++++++++----- core/AmSipDialog.h | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index cb867cc..0c0f983 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -164,10 +164,7 @@ void AmB2BSession::onB2BEvent(B2BEvent* ev) } } else { // is_answer - send 200 ACK - // todo: use that from uas_trans? - trans_ticket tt; // not used for ACK - AmSipTransaction trans("INVITE", body_ev->r_cseq, tt); - if (dlg.send_200_ack(trans, body_ev->content_type, body_ev->body, + if (dlg.send_200_ack(body_ev->r_cseq, body_ev->content_type, body_ev->body, "" /* hdrs - todo */, SIP_FLAGS_VERBATIM)) { ERROR("sending ACK with SDP\n"); } @@ -330,8 +327,8 @@ void AmB2BSession::relaySip(const AmSipRequest& req) return; } DBG("sending relayed ACK\n"); - dlg.send_200_ack(AmSipTransaction(t->second.method, t->first,t->second.tt), - req.content_type, req.body, req.hdrs, SIP_FLAGS_VERBATIM); + dlg.send_200_ack(t->first /*cseq*/, req.content_type, req.body, + req.hdrs, SIP_FLAGS_VERBATIM); relayed_req.erase(t); } } diff --git a/core/AmSession.cpp b/core/AmSession.cpp index dfbc1de..7c34729 100644 --- a/core/AmSession.cpp +++ b/core/AmSession.cpp @@ -673,14 +673,12 @@ void AmSession::onSipRequest(const AmSipRequest& req) onInvite(req); if(detached.get() && !getStopped()){ - onSessionStart(req); - if(input || output || local_input || local_output) - AmMediaProcessor::instance()->addSession(this, callgroup); + AmMediaProcessor::instance()->addSession(this, callgroup); else { - DBG("no audio input and output set. " - "Session will not be attached to MediaProcessor.\n"); + DBG("no audio input and output set. " + "Session will not be attached to MediaProcessor.\n"); } } } @@ -800,8 +798,7 @@ void AmSession::onSipReply(const AmSipReply& reply, int old_dlg_status) void AmSession::onInvite2xx(const AmSipReply& reply) { - AmSipTransaction* t = dlg.get_uac_trans(reply.cseq); - if(t) dlg.send_200_ack(*t); + dlg.send_200_ack(reply.cseq); } void AmSession::onNo2xxACK(unsigned int cseq) diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index c7070ee..1dbdc34 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -45,6 +45,7 @@ AmSipDialog::AmSipDialog(AmSipDialogEventHandler* h) outbound_proxy(AmConfig::OutboundProxy), force_outbound_proxy(AmConfig::ForceOutboundProxy) { + assert(h); } AmSipDialog::~AmSipDialog() @@ -282,7 +283,7 @@ void AmSipDialog::updateStatus(const AmSipReply& reply) hdl->onInvite2xx(reply); } else { - send_200_ack(t); + send_200_ack(t.cseq); } } else { @@ -679,7 +680,7 @@ int AmSipDialog::drop() return 1; } -int AmSipDialog::send_200_ack(const AmSipTransaction& t, +int AmSipDialog::send_200_ack(unsigned int inv_cseq, const string& content_type, const string& body, const string& hdrs, @@ -692,10 +693,15 @@ int AmSipDialog::send_200_ack(const AmSipTransaction& t, // acceptable, the UAC core MUST generate a valid answer in the ACK and // then send a BYE immediately." + if (uac_trans.find(inv_cseq) == uac_trans.end()) { + ERROR("trying to ACK a non-existing transaction (cseq=%i;local_tag=%s)\n",inv_cseq,local_tag.c_str()); + return -1; + } + string m_hdrs = hdrs; if(hdl) - hdl->onSendRequest("ACK",content_type,body,m_hdrs,flags,t.cseq); + hdl->onSendRequest("ACK",content_type,body,m_hdrs,flags,inv_cseq); AmSipRequest req; @@ -710,7 +716,7 @@ int AmSipDialog::send_200_ack(const AmSipTransaction& t, if(!remote_tag.empty()) req.to += ";tag=" + remote_tag; - req.cseq = t.cseq;// should be the same as the INVITE + req.cseq = inv_cseq;// should be the same as the INVITE req.callid = callid; req.contact = getContactHdr(); @@ -737,7 +743,7 @@ int AmSipDialog::send_200_ack(const AmSipTransaction& t, if (SipCtrlInterface::send(req)) return -1; - uac_trans.erase(t.cseq); + uac_trans.erase(inv_cseq); return 0; } diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h index f4c2990..5d27722 100644 --- a/core/AmSipDialog.h +++ b/core/AmSipDialog.h @@ -156,7 +156,7 @@ class AmSipDialog bool r_cseq_i; unsigned int r_cseq; // last remote CSeq - AmSipDialog(AmSipDialogEventHandler* h=0); + AmSipDialog(AmSipDialogEventHandler* h); ~AmSipDialog(); bool getUACTransPending() { return !uac_trans.empty(); } @@ -185,7 +185,7 @@ class AmSipDialog const string& hdrs = "", int flags = 0); - int send_200_ack(const AmSipTransaction& t, + int send_200_ack(unsigned int inv_cseq, const string& content_type = "", const string& body = "", const string& hdrs = "", _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
