General Category > Yate users hangout place
CDRBuild - Holdtime Modification - 6.0.1
ganapathi:
Hi
As I trying to add holdtime in core level instead of custom patch, but almost calculated the holdtime and debug console emitting the value properly but failed to add into emitting CDR message to get it stored in Database.
Due to clear show fully operational function are hidden with “..” value.
Appreciated if Anybody help me on this.
Yate Version : 6.0.1-dev
SIP Client/IP Phone : For Making Call.
Ysipchan.cpp:
bool YateSIPConnection::reInviteProxy(SIPTransaction* t, MimeSdpBody* sdp, int invite)
{
..
..
..
msg->addParam("audio_changed",String::boolText(audioChg));
msg->addParam("mute",String::boolText(MediaStarted != m_mediaStatus));
// Holdtime Patch START
if( MediaStarted != m_mediaStatus)
msg->addParam("status","hold");
else
msg->addParam("status","unhold");
// Holdtime Patch END
putMedia(*msg);
Engine::enqueue(msg);
..
..
..
}
Cdrbuild.cpp:
Variable Initialization :
class CdrHandler : public MessageHandler
{
public:
CdrHandler(const char *name, int type, int prio = 50)
: MessageHandler(name,prio,__plugin.name()),
m_type(type)
{ }
virtual bool received(Message &msg);
private:
int m_type;
u_int64_t
m_holdsec,
m_hold,
m_unhold;
};
Variable Initialization 2 :
class CdrBuilder : public NamedList
{
public:
..
..
..
private:
u_int64_t
m_start,
m_call,
m_ringing,
m_answer,
m_holdsec,
m_hangup;
..
..
..
}
Variable Initializations 3 :
CdrBuilder::CdrBuilder(const char *name)
: NamedList(name), m_dir("unknown"), m_status("unknown"),
m_first(true), m_write(true)
{
m_statusTime = m_start = m_call = m_ringing = m_answer = m_hangup = m_holdsec = 0;
m_cdrId = ++s_seq;
}
Hold Time Calculation On cdrbuild function :
bool CdrHandler::received(Message &msg)
{
Lock lock(s_mutex);
..
..
..
if (m_type == CdrUpdate) {
const String* oper = msg.getParam(YSTRING("operation"));
const String* TBmute = msg.getParam(YSTRING("mute"));
if (oper && (*oper != YSTRING("cdrbuild")) )
track = false;
if (oper && TBmute && (*TBmute == YSTRING("true")) ) {
track = true;
m_hold = Time::msecNow();
}
if (oper && TBmute && (*TBmute == YSTRING("false") ) && m_hold && ( m_hold > 0 ) ){
track = true;
m_unhold = Time::msecNow();
if(m_holdsec)
m_holdsec = m_holdsec + m_unhold - m_hold;
else
m_holdsec = m_unhold - m_hold;
if(m_holdsec)
Debug("cdrbuild",DebugAll,"TBholdtime is '%lu'",m_holdsec);
}
}
..
..
..
}
Holdtime Emit Function :
void CdrBuilder::emit(const char *operation)
{
..
..
..
m->addParam("ringtime",printTime(buf,t_answer - t_ringing));
m->addParam("holdtime",printTime(buf,m_holdsec)); // Holdtime Emit. This is where I need value to be emit.
m->addParam("status",m_status);
..
..
..
}
marian:
CdrHandler::received():
You are using CdrHandler's data to update hold related status.
CdrHandler is the common message handler, for all cdr messages.
Use CdrBuilder's data !
ganapathi:
So you meant to say my calculation in cdrhandler: received function needs to do on cdrbuilder:emit function itself before emitting the variable with help of cdrbuilder's current data? .
Let me try that then
ganapathi:
Hi
As suggested modified the cdrbuilder emit function like mentioned below.
m->addParam("ringtime",printTime(buf,t_answer - t_ringing));
//HoldTime Calculation
if (String(m_status) == YSTRING("hold") ) {
m_hold = Time::msecNow();
}
if (String(m_status) == YSTRING("unhold") && m_hold && ( m_hold > 0 ) ){
m_unhold = Time::msecNow();
if(m_holdsec)
m_holdsec = m_holdsec + m_unhold - m_hold;
else
m_holdsec = m_unhold - m_hold;
}
m->addParam("holdtime",printTime(buf,m_holdsec));
//
m->addParam("status",m_status);
It should work ?
marian:
Sorry, can't follow!
Please post a diff from svn.
You may use:
svn diff -x -p
Navigation
[0] Message Index
[#] Next page
Go to full version