Feature: Send CDR status immediately after answer.

Feature: Can disable periodic status updates but still send one on answer.
Bugfix: CDR status messages are sent for inbound call leg too.
Bugfix: extraneous answer events must not cause a status interval timer restart.


git-svn-id: http://voip.null.ro/svn/yate@5377 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2013-01-16 13:18:28 +00:00
parent bdcf1ed2ee
commit fd644474a5
2 changed files with 19 additions and 8 deletions

View File

@ -14,11 +14,16 @@
; status_interval: int: The time interval in seconds to emit call cdr status messages
; Note: If status is set to false this interval will be ignored
; If this interval is set to 0 a single cdr status is emitted at answer time
; Default 60s
; Min 60s
; Max 600s
;status_interval=60
; status_answer: bool: Emit cdr status message immediately when the call is answered
; If set to false the first cdr status is sent after status_interval
;status_answer=true
[parameters]
; Each line consists of name=bool where name is the name of the parameter being
@ -48,7 +53,7 @@
; MM | %m -> Month as a decimal number (01-12)
; DD | %d -> Day of the month (01-31)
; HH | %H -> Hour in 24h format (00-23)
; mm | %M -> Hour in 24h format (00-23)
; mm | %M -> Minute (00-59)
; SS | %S -> Second (00-60)
; Note the value is rounded
; UTC -> If present the time will represent the UTC time. If is missing

View File

@ -199,6 +199,7 @@ static int s_seq = 0;
static String s_runId;
static bool s_cdrUpdates = true;
static bool s_cdrStatus = false;
static bool s_statusAnswer = true;
static unsigned int s_statusUpdate = 60000;
static StatusThread* s_updaterThread = 0;
@ -591,8 +592,8 @@ bool CdrHandler::received(Message &msg)
}
if (b) {
rval = b->update(msg,type,msg.msgTime().usec());
if (type == CdrAnswer)
b->m_statusTime = Time::msecNow() + s_statusUpdate;
if (type == CdrAnswer && !b->m_statusTime)
b->m_statusTime = Time::msecNow() + (s_statusAnswer ? 0 : s_statusUpdate);
} else
Debug("cdrbuild",level,"Got message '%s' for untracked id '%s'",
msg.c_str(),id.c_str());
@ -603,6 +604,8 @@ bool CdrHandler::received(Message &msg)
if (id && (b = CdrBuilder::find(id))) {
b->update(type,msg.msgTime().usec(),msg.getValue("status"));
b->emit();
if (type == CdrAnswer && !b->m_statusTime)
b->m_statusTime = Time::msecNow() + (s_statusAnswer ? 0 : s_statusUpdate);
}
}
return rval;
@ -660,9 +663,9 @@ void StatusThread::run()
CdrBuilder* cdr = static_cast<CdrBuilder*>(o->get());
if (cdr->getStatus() != YSTRING("answered"))
continue;
if (cdr->m_statusTime < now.msec()) {
if (cdr->m_statusTime && (cdr->m_statusTime < now.msec())) {
cdr->emit("status");
cdr->m_statusTime = now.msec() + s_statusUpdate;
cdr->m_statusTime = s_statusUpdate ? (now.msec() + s_statusUpdate) : (u_int64_t)-1;
}
}
s_mutex.unlock();
@ -674,9 +677,9 @@ void StatusThread::run()
Time t;
for (ObjList* o = s_cdrs.skipNull();o;o = o->skipNext()) {
CdrBuilder* cdr = static_cast<CdrBuilder*>(o->get());
if (cdr->m_statusTime && cdr->m_statusTime < t.msec()) {
if (cdr->m_statusTime && (cdr->m_statusTime < t.msec())) {
cdr->emit("status");
cdr->m_statusTime = t.msec() + s_statusUpdate;
cdr->m_statusTime = s_statusUpdate ? (t.msec() + s_statusUpdate) : (u_int64_t)-1;
}
}
}
@ -873,8 +876,11 @@ void CdrBuildPlugin::initialize()
}
s_cdrUpdates = cfg.getBoolValue("general","updates",true);
s_cdrStatus = cfg.getBoolValue("general","status",false);
s_statusAnswer = cfg.getBoolValue("general","status_answer",true);
int sUpdate = cfg.getIntValue("general","status_interval",60);
if (sUpdate < 60)
if (sUpdate <= 0)
s_statusUpdate = 0;
else if (sUpdate < 60)
s_statusUpdate = 60000;
else if (sUpdate > 600)
s_statusUpdate = 600000;