Added new XDebug macro for those messages that generate LOT of output like

in long running loops.
Implemented non-branch transaction matching in SIP.
Fixed handling of multi-tone chan.dtmf messages in PHP.


git-svn-id: http://yate.null.ro/svn/yate/trunk@236 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2005-01-27 21:26:00 +00:00
parent cad8e75d71
commit 704351f1b7
13 changed files with 66 additions and 28 deletions

View File

@ -259,7 +259,7 @@ void SIPTransaction::setResponse(int code, const char* reason)
bool SIPTransaction::processMessage(SIPMessage* message, const String& branch)
{
if (!message)
if (!(message && m_firstMessage))
return false;
DDebug("SIPTransaction",DebugAll,"processMessage(%p,'%s') [%p]",
message,branch.c_str(),this);
@ -276,7 +276,7 @@ bool SIPTransaction::processMessage(SIPMessage* message, const String& branch)
(getCallID() != message->getHeaderValue("Call-ID")) ||
(getDialogTag() != message->getParamValue("To","tag")))
return false;
Debug("SIPTransaction",DebugInfo,"Found non-branch ACK response to our 2xx");
Debug("SIPTransaction",DebugAll,"Found non-branch ACK response to our 2xx");
}
else if (getMethod() != message->method) {
if (!(isIncoming() && isInvite() && message->isACK()))
@ -284,8 +284,19 @@ bool SIPTransaction::processMessage(SIPMessage* message, const String& branch)
}
}
else {
Debug("SIPTransaction",DebugWarn,"Non-branch matching not implemented!");
return false;
if (getMethod() != message->method) {
if (!(isIncoming() && isInvite() && message->isACK()))
return false;
}
if ((m_firstMessage->getCSeq() != message->getCSeq()) ||
(getURI() != message->uri) ||
(getCallID() != message->getHeaderValue("Call-ID")) ||
(m_firstMessage->getHeaderValue("From") != message->getHeaderValue("From")) ||
(m_firstMessage->getHeaderValue("To") != message->getHeaderValue("To")) ||
(m_firstMessage->getHeaderValue("Via") != message->getHeaderValue("Via")))
return false;
if (message->isACK() && (getDialogTag() != message->getParamValue("To","tag")))
return false;
}
if (isOutgoing() != message->isAnswer()) {
Debug("SIPTransaction",DebugAll,"Ignoring retransmitted %s %p '%s' in [%p]",

View File

@ -225,7 +225,7 @@ void ExtModSource::run()
data.assign(data.data(),r);
long long dly = tpos - Time::now();
if (dly > 0) {
DDebug("ExtModSource",DebugAll,"Sleeping for %lld usec",dly);
XDebug("ExtModSource",DebugAll,"Sleeping for %lld usec",dly);
::usleep((unsigned long)dly);
}
Forward(data,m_total);

View File

@ -116,7 +116,7 @@ void GsmCodec::Consume(const DataBlock &data, unsigned long timeDelta)
}
timeDelta = frames*sizeof(gsm_block) / 2;
}
DDebug("GsmCodec",DebugAll,"%scoding %d frames of %d input bytes (consumed %d) in %d output bytes",
XDebug("GsmCodec",DebugAll,"%scoding %d frames of %d input bytes (consumed %d) in %d output bytes",
m_encoding ? "en" : "de",frames,m_data.length(),consumed,outdata.length());
if (frames) {
m_data.cut(-consumed);

View File

@ -1320,7 +1320,7 @@ BOOL YateH323AudioConsumer::Read(void *buf, PINDEX len)
if (len > 0) {
::memcpy(buf,m_buffer.data(),len);
m_buffer.assign(len+(char *)m_buffer.data(),m_buffer.length()-len);
DDebug("YateH323AudioConsumer",DebugAll,"Pulled %d bytes from buffer [%p]",len,this);
XDebug("YateH323AudioConsumer",DebugAll,"Pulled %d bytes from buffer [%p]",len,this);
break;
}
else

View File

@ -358,7 +358,7 @@ void YateIAXEndPoint::run(void)
s_mutex.unlock();
if (!e)
break;
DDebug("IAX Event",DebugAll,"event %d/%d",e->etype,e->subclass);
XDebug("IAX Event",DebugAll,"event %d/%d",e->etype,e->subclass);
YateIAXConnection *conn = 0;
// We first take care of the special events
switch(e->etype) {
@ -731,7 +731,7 @@ bool YateIAXConnection::startRouting(iax_event *e)
// Handle regular connection events with a valid session
void YateIAXConnection::handleEvent(iax_event *event)
{
DDebug("IAX Event",DebugAll,"Connection event %d/%d in [%p]",event->etype,event->subclass,this);
XDebug("IAX Event",DebugAll,"Connection event %d/%d in [%p]",event->etype,event->subclass,this);
switch(event->etype) {
case IAX_EVENT_ACCEPT:
Debug("IAX",DebugInfo,"ACCEPT inside a call [%p]",this);

View File

@ -201,7 +201,7 @@ void OssSource::run()
data.assign(data.data(),r);
long long dly = tpos - Time::now();
if (dly > 0) {
DDebug("OssSource",DebugAll,"Sleeping for %lld usec",dly);
XDebug("OssSource",DebugAll,"Sleeping for %lld usec",dly);
::usleep((unsigned long)dly);
}
Forward(data,data.length()/2);

View File

@ -224,7 +224,7 @@ void ToneSource::run()
}
long long dly = tpos - Time::now();
if (dly > 0) {
DDebug("ToneSource",DebugAll,"Sleeping for %lld usec",dly);
XDebug("ToneSource",DebugAll,"Sleeping for %lld usec",dly);
::usleep((unsigned long)dly);
}
Forward(m_data,m_data.length()/2);

View File

@ -247,7 +247,7 @@ void WaveSource::run()
}
long long dly = tpos - Time::now();
if (dly > 0) {
DDebug("WaveSource",DebugAll,"Sleeping for %lld usec",dly);
XDebug("WaveSource",DebugAll,"Sleeping for %lld usec",dly);
::usleep((unsigned long)dly);
}
Forward(m_data,m_data.length()*8000/m_brate);

View File

@ -901,7 +901,7 @@ void ZapSource::run()
int fd = m_owner->fd();
if (fd != -1) {
rd = ::read(fd,m_buf.data(),m_buf.length());
DDebug(DebugAll,"ZapSource read %d bytes",rd);
XDebug(DebugAll,"ZapSource read %d bytes",rd);
if (rd > 0) {
switch (m_owner->law()) {
case -1:
@ -932,7 +932,7 @@ void ZapSource::run()
void ZapConsumer::Consume(const DataBlock &data, unsigned long timeDelta)
{
int fd = m_owner->fd();
DDebug(DebugAll,"ZapConsumer fd=%d datalen=%u",fd,data.length());
XDebug(DebugAll,"ZapConsumer fd=%d datalen=%u",fd,data.length());
if ((fd != -1) && !data.null()) {
DataBlock blk;
switch (m_owner->law()) {

View File

@ -123,10 +123,10 @@ while ($state != "") {
$ev=Yate::GetEvent();
/* If Yate disconnected us then exit cleanly */
if ($ev == "EOF")
break;
break;
/* No need to handle empty events in this application */
if ($ev == "")
continue;
continue;
/* If we reached here we should have a valid object */
switch ($ev->type) {
case "incoming":

View File

@ -12,11 +12,11 @@ require_once("libyate.php");
/* Always the first action to do */
Yate::Init();
/* Install a handler for the engine generated timer message */
Yate::Install("chan.dtmf",10);
/* Install handlers for the DTMF and wave EOF messages */
Yate::Install("chan.dtmf");
Yate::Install("chan.notify");
$ourcallid = "external/" . uniqid(rand(),1);
$ourcallid = "playrec/" . uniqid(rand(),1);
$partycallid = "";
$state = "call";
$dir = "/tmp";
@ -131,16 +131,14 @@ while ($state != "") {
$ev=Yate::GetEvent();
/* If Yate disconnected us then exit cleanly */
if ($ev == "EOF")
break;
break;
/* Empty events are normal in non-blocking operation.
This is an opportunity to do idle tasks and check timers */
if ($ev == "")
continue;
continue;
/* If we reached here we should have a valid object */
switch ($ev->type) {
case "incoming":
// Yate::Output("PHP Message: " . $ev->name . " our id: " . $ev->params["id"] . " target id: " . $ev->params["targetid"]);
// Yate::Output("current state: " . $state);
switch ($ev->name) {
case "call.execute":
$partycallid = $ev->params["id"];
@ -168,7 +166,9 @@ while ($state != "") {
case "chan.dtmf":
if ($ev->params["targetid"] == $ourcallid ) {
gotDTMF($ev->params["text"]);
$text = $ev->params["text"];
for ($i = 0; $i < strlen($text); $i++)
gotDTMF($text[$i]);
$ev->handled = true;
}
break;

View File

@ -13,7 +13,7 @@ require_once("libyate.php");
Yate::Init();
/* Install handlers for the wave end and dtmf notify messages */
Yate::Install("chan.dtmf",10);
Yate::Install("chan.dtmf");
Yate::Install("chan.notify");
$ourcallid = "voicemail/" . uniqid(rand(),1);
@ -328,10 +328,10 @@ while ($state != "") {
$ev=Yate::GetEvent();
/* If Yate disconnected us then exit cleanly */
if ($ev == "EOF")
break;
break;
/* No need to handle empty events in this application */
if ($ev == "")
continue;
continue;
/* If we reached here we should have a valid object */
switch ($ev->type) {
case "incoming":
@ -368,7 +368,9 @@ while ($state != "") {
case "chan.dtmf":
if ($ev->params["targetid"] == $ourcallid ) {
gotDTMF($ev->params["text"]);
$text = $ev->params["text"];
for ($i = 0; $i < strlen($text); $i++)
gotDTMF($text[$i]);
$ev->handled = true;
}
break;

View File

@ -103,6 +103,20 @@ bool DDebug(int level, const char *format, ...);
*/
bool DDebug(const char *facility, int level, const char *format, ...);
/**
* Convenience macro.
* Does the same as @ref Debug if XDEBUG is #defined (compiling for extra
* debugging) else it does not get compiled at all.
*/
bool XDebug(int level, const char *format, ...);
/**
* Convenience macro.
* Does the same as @ref Debug if XDEBUG is #defined (compiling for extra
* debugging) else it does not get compiled at all.
*/
bool XDebug(const char *facility, int level, const char *format, ...);
/**
* Convenience macro.
* Does the same as @ref Debug if NDEBUG is not #defined
@ -118,12 +132,23 @@ bool NDebug(int level, const char *format, ...);
bool NDebug(const char *facility, int level, const char *format, ...);
#endif
#ifdef XDEBUG
#undef DEBUG
#define DEBUG
#endif
#ifdef DEBUG
#define DDebug(arg...) Debug(arg)
#else
#define DDebug(arg...)
#endif
#ifdef XDEBUG
#define XDebug(arg...) Debug(arg)
#else
#define XDebug(arg...)
#endif
#ifndef NDEBUG
#define NDebug(arg...) Debug(arg)
#else