Copy parameters to the disconnect list after prerouting.

This allows setting parameters in chan.hangup and CDR for calls cancelled during routing.


git-svn-id: http://yate.null.ro/svn/yate/trunk@5174 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2012-07-02 15:30:52 +00:00
parent 11cd48f1b1
commit fbb10ee055
1 changed files with 11 additions and 3 deletions

View File

@ -68,6 +68,8 @@ static Mutex s_callidMutex(false,"CallID");
// of call endpoints at the same time
static Mutex s_mutex(true,"CallEndpoint");
static const String s_audioType = "audio";
static const String s_copyParams = "copyparams";
CallEndpoint::CallEndpoint(const char* id)
: m_peer(0), m_id(id), m_mutex(0)
@ -596,7 +598,7 @@ Message* Channel::message(const char* name, const NamedList* original, const cha
Message* msg = message(name,minimal,data);
if (original) {
if (!params)
params = original->getValue(YSTRING("copyparams"));
params = original->getValue(s_copyParams);
if (!null(params))
msg->copyParams(*original,params);
}
@ -829,7 +831,7 @@ void Channel::callRejected(const char* error, const char* reason, const Message*
{
Debug(this,DebugMild,"Call rejected error='%s' reason='%s' [%p]",error,reason,this);
if (msg) {
const String* cp = msg->getParam(YSTRING("copyparams"));
const String* cp = msg->getParam(s_copyParams);
if (!TelEngine::null(cp)) {
s_paramMutex.lock();
parameters().copyParams(*msg,*cp);
@ -1602,6 +1604,12 @@ bool Router::route()
Debug(m_driver,DebugInfo,"Connection '%s' vanished while prerouting!",m_id.c_str());
return false;
}
const String* cp = m_msg->getParam(s_copyParams);
if (!TelEngine::null(cp)) {
Channel::paramMutex().lock();
chan->parameters().copyParams(*m_msg,*cp);
Channel::paramMutex().unlock();
}
bool dropCall = ok && ((m_msg->retValue() == YSTRING("-")) || (m_msg->retValue() == YSTRING("error")));
if (dropCall)
chan->callRejected(m_msg->getValue(YSTRING("error"),"unknown"),
@ -1658,7 +1666,7 @@ bool Router::route()
const char* reason = m_msg->getValue(YSTRING("reason"),
((s_noconn == error) ? "Could not connect to target" : (const char*)0));
Message m(s_disconnected);
const String* cp = m_msg->getParam(YSTRING("copyparams"));
const String* cp = m_msg->getParam(s_copyParams);
if (!TelEngine::null(cp))
m.copyParams(*m_msg,*cp);
chan->complete(m);