From f91fe91c181f86227ec5ab8448175508e8b1f105 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Thu, 4 Oct 2007 20:49:13 +0000 Subject: [PATCH] support for extra headers in dialout calls git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@513 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- apps/examples/di_dialer/DIDial.cpp | 2 ++ core/AmSession.cpp | 10 +++++----- core/AmSession.h | 4 ++-- core/AmSessionContainer.cpp | 2 +- core/AmUAC.cpp | 2 ++ core/AmUAC.h | 1 + doc/CHANGELOG | 2 ++ 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/examples/di_dialer/DIDial.cpp b/apps/examples/di_dialer/DIDial.cpp index 62583738..347db8f7 100644 --- a/apps/examples/di_dialer/DIDial.cpp +++ b/apps/examples/di_dialer/DIDial.cpp @@ -162,6 +162,7 @@ string DIDial::dialout_auth(const string& application, AmSession* s = AmUAC::dialout(user.c_str(), application, to, "<" + from + ">", from, "<" + to + ">", string(""), // callid + string(""), // xtra hdrs a); if (s) return s->getLocalTag(); @@ -191,6 +192,7 @@ string DIDial::dialout_pin(const string& application, "sip:"+it->second.user+"@"+it->second.realm, "second.realm + ">", string(""), // callid + string(""), // xtra hdrs a); if (s) return s->getLocalTag(); diff --git a/core/AmSession.cpp b/core/AmSession.cpp index f746acfa..775de536 100644 --- a/core/AmSession.cpp +++ b/core/AmSession.cpp @@ -751,19 +751,19 @@ void AmSession::sendUpdate() dlg.update(""); } -void AmSession::sendReinvite(bool updateSDP) +void AmSession::sendReinvite(bool updateSDP, const string& headers) { if (updateSDP) { rtp_str.setLocalIP(AmConfig::LocalIP); string sdp_body; sdp.genResponse(AmConfig::LocalIP,rtp_str.getLocalPort(),sdp_body); - dlg.reinvite("", "application/sdp", sdp_body); + dlg.reinvite(headers, "application/sdp", sdp_body); } else { - dlg.reinvite("", "", ""); + dlg.reinvite(headers, "", ""); } } -int AmSession::sendInvite() +int AmSession::sendInvite(const string& headers) { // set local IP first, so that IP is set when // getLocalPort/setLocalPort may bind @@ -771,7 +771,7 @@ int AmSession::sendInvite() // generate SDP string sdp_body; sdp.genRequest(AmConfig::LocalIP,rtp_str.getLocalPort(),sdp_body); - return dlg.invite("", "application/sdp", sdp_body); + return dlg.invite(headers, "application/sdp", sdp_body); } void AmSession::setOnHold(bool hold) diff --git a/core/AmSession.h b/core/AmSession.h index 65dc4d8c..8a35a804 100644 --- a/core/AmSession.h +++ b/core/AmSession.h @@ -309,9 +309,9 @@ public: /** send an UPDATE in the session */ void sendUpdate(); /** send a Re-INVITE (if connected) */ - void sendReinvite(bool updateSDP = true); + void sendReinvite(bool updateSDP = true, const string& headers = ""); /** send an INVITE */ - int sendInvite(); + int sendInvite(const string& headers = ""); /** set the session on/off hold */ void setOnHold(bool hold); diff --git a/core/AmSessionContainer.cpp b/core/AmSessionContainer.cpp index 33e4edc4..f755406f 100644 --- a/core/AmSessionContainer.cpp +++ b/core/AmSessionContainer.cpp @@ -186,7 +186,7 @@ AmSession* AmSessionContainer::startSessionUAC(AmSipRequest& req, AmArg* session session->setCallgroup(req.from_tag); session->setNegotiateOnReply(true); - if (int err = session->sendInvite()) { + if (int err = session->sendInvite(req.hdrs)) { ERROR("INVITE could not be sent: error code = %d.\n", err); delete session; diff --git a/core/AmUAC.cpp b/core/AmUAC.cpp index afd5fdfb..8969aba8 100644 --- a/core/AmUAC.cpp +++ b/core/AmUAC.cpp @@ -38,6 +38,7 @@ AmSession* AmUAC::dialout(const string& user, const string& from_uri, const string& to, const string& local_tag, + const string& hdrs, AmArg* session_params) { AmSipRequest req; @@ -56,6 +57,7 @@ AmSession* AmUAC::dialout(const string& user, req.to = to; req.to_tag = ""; req.callid = AmSession::getNewId() + "@" + AmConfig::LocalIP; + req.hdrs = hdrs; // set outbound proxy as next hop if (!AmConfig::OutboundProxy.empty()) diff --git a/core/AmUAC.h b/core/AmUAC.h index 23d59c49..4fe815ae 100644 --- a/core/AmUAC.h +++ b/core/AmUAC.h @@ -45,6 +45,7 @@ class AmUAC { const string& from_uri, const string& to, const string& local_tag = "", + const string& hdrs = "", AmArg* session_params = NULL); }; diff --git a/doc/CHANGELOG b/doc/CHANGELOG index d40c5d00..4dc111e8 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -1,5 +1,7 @@ Changelog for SEMS + - support for extra headers in dialout sessions + - support for setting the URI of a session in SDP - early media receiving example