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:
parent
cad8e75d71
commit
704351f1b7
|
@ -259,7 +259,7 @@ void SIPTransaction::setResponse(int code, const char* reason)
|
||||||
|
|
||||||
bool SIPTransaction::processMessage(SIPMessage* message, const String& branch)
|
bool SIPTransaction::processMessage(SIPMessage* message, const String& branch)
|
||||||
{
|
{
|
||||||
if (!message)
|
if (!(message && m_firstMessage))
|
||||||
return false;
|
return false;
|
||||||
DDebug("SIPTransaction",DebugAll,"processMessage(%p,'%s') [%p]",
|
DDebug("SIPTransaction",DebugAll,"processMessage(%p,'%s') [%p]",
|
||||||
message,branch.c_str(),this);
|
message,branch.c_str(),this);
|
||||||
|
@ -276,7 +276,7 @@ bool SIPTransaction::processMessage(SIPMessage* message, const String& branch)
|
||||||
(getCallID() != message->getHeaderValue("Call-ID")) ||
|
(getCallID() != message->getHeaderValue("Call-ID")) ||
|
||||||
(getDialogTag() != message->getParamValue("To","tag")))
|
(getDialogTag() != message->getParamValue("To","tag")))
|
||||||
return false;
|
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) {
|
else if (getMethod() != message->method) {
|
||||||
if (!(isIncoming() && isInvite() && message->isACK()))
|
if (!(isIncoming() && isInvite() && message->isACK()))
|
||||||
|
@ -284,8 +284,19 @@ bool SIPTransaction::processMessage(SIPMessage* message, const String& branch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Debug("SIPTransaction",DebugWarn,"Non-branch matching not implemented!");
|
if (getMethod() != message->method) {
|
||||||
return false;
|
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()) {
|
if (isOutgoing() != message->isAnswer()) {
|
||||||
Debug("SIPTransaction",DebugAll,"Ignoring retransmitted %s %p '%s' in [%p]",
|
Debug("SIPTransaction",DebugAll,"Ignoring retransmitted %s %p '%s' in [%p]",
|
||||||
|
|
|
@ -225,7 +225,7 @@ void ExtModSource::run()
|
||||||
data.assign(data.data(),r);
|
data.assign(data.data(),r);
|
||||||
long long dly = tpos - Time::now();
|
long long dly = tpos - Time::now();
|
||||||
if (dly > 0) {
|
if (dly > 0) {
|
||||||
DDebug("ExtModSource",DebugAll,"Sleeping for %lld usec",dly);
|
XDebug("ExtModSource",DebugAll,"Sleeping for %lld usec",dly);
|
||||||
::usleep((unsigned long)dly);
|
::usleep((unsigned long)dly);
|
||||||
}
|
}
|
||||||
Forward(data,m_total);
|
Forward(data,m_total);
|
||||||
|
|
|
@ -116,7 +116,7 @@ void GsmCodec::Consume(const DataBlock &data, unsigned long timeDelta)
|
||||||
}
|
}
|
||||||
timeDelta = frames*sizeof(gsm_block) / 2;
|
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());
|
m_encoding ? "en" : "de",frames,m_data.length(),consumed,outdata.length());
|
||||||
if (frames) {
|
if (frames) {
|
||||||
m_data.cut(-consumed);
|
m_data.cut(-consumed);
|
||||||
|
|
|
@ -1320,7 +1320,7 @@ BOOL YateH323AudioConsumer::Read(void *buf, PINDEX len)
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
::memcpy(buf,m_buffer.data(),len);
|
::memcpy(buf,m_buffer.data(),len);
|
||||||
m_buffer.assign(len+(char *)m_buffer.data(),m_buffer.length()-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;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -358,7 +358,7 @@ void YateIAXEndPoint::run(void)
|
||||||
s_mutex.unlock();
|
s_mutex.unlock();
|
||||||
if (!e)
|
if (!e)
|
||||||
break;
|
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;
|
YateIAXConnection *conn = 0;
|
||||||
// We first take care of the special events
|
// We first take care of the special events
|
||||||
switch(e->etype) {
|
switch(e->etype) {
|
||||||
|
@ -731,7 +731,7 @@ bool YateIAXConnection::startRouting(iax_event *e)
|
||||||
// Handle regular connection events with a valid session
|
// Handle regular connection events with a valid session
|
||||||
void YateIAXConnection::handleEvent(iax_event *event)
|
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) {
|
switch(event->etype) {
|
||||||
case IAX_EVENT_ACCEPT:
|
case IAX_EVENT_ACCEPT:
|
||||||
Debug("IAX",DebugInfo,"ACCEPT inside a call [%p]",this);
|
Debug("IAX",DebugInfo,"ACCEPT inside a call [%p]",this);
|
||||||
|
|
|
@ -201,7 +201,7 @@ void OssSource::run()
|
||||||
data.assign(data.data(),r);
|
data.assign(data.data(),r);
|
||||||
long long dly = tpos - Time::now();
|
long long dly = tpos - Time::now();
|
||||||
if (dly > 0) {
|
if (dly > 0) {
|
||||||
DDebug("OssSource",DebugAll,"Sleeping for %lld usec",dly);
|
XDebug("OssSource",DebugAll,"Sleeping for %lld usec",dly);
|
||||||
::usleep((unsigned long)dly);
|
::usleep((unsigned long)dly);
|
||||||
}
|
}
|
||||||
Forward(data,data.length()/2);
|
Forward(data,data.length()/2);
|
||||||
|
|
|
@ -224,7 +224,7 @@ void ToneSource::run()
|
||||||
}
|
}
|
||||||
long long dly = tpos - Time::now();
|
long long dly = tpos - Time::now();
|
||||||
if (dly > 0) {
|
if (dly > 0) {
|
||||||
DDebug("ToneSource",DebugAll,"Sleeping for %lld usec",dly);
|
XDebug("ToneSource",DebugAll,"Sleeping for %lld usec",dly);
|
||||||
::usleep((unsigned long)dly);
|
::usleep((unsigned long)dly);
|
||||||
}
|
}
|
||||||
Forward(m_data,m_data.length()/2);
|
Forward(m_data,m_data.length()/2);
|
||||||
|
|
|
@ -247,7 +247,7 @@ void WaveSource::run()
|
||||||
}
|
}
|
||||||
long long dly = tpos - Time::now();
|
long long dly = tpos - Time::now();
|
||||||
if (dly > 0) {
|
if (dly > 0) {
|
||||||
DDebug("WaveSource",DebugAll,"Sleeping for %lld usec",dly);
|
XDebug("WaveSource",DebugAll,"Sleeping for %lld usec",dly);
|
||||||
::usleep((unsigned long)dly);
|
::usleep((unsigned long)dly);
|
||||||
}
|
}
|
||||||
Forward(m_data,m_data.length()*8000/m_brate);
|
Forward(m_data,m_data.length()*8000/m_brate);
|
||||||
|
|
|
@ -901,7 +901,7 @@ void ZapSource::run()
|
||||||
int fd = m_owner->fd();
|
int fd = m_owner->fd();
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
rd = ::read(fd,m_buf.data(),m_buf.length());
|
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) {
|
if (rd > 0) {
|
||||||
switch (m_owner->law()) {
|
switch (m_owner->law()) {
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -932,7 +932,7 @@ void ZapSource::run()
|
||||||
void ZapConsumer::Consume(const DataBlock &data, unsigned long timeDelta)
|
void ZapConsumer::Consume(const DataBlock &data, unsigned long timeDelta)
|
||||||
{
|
{
|
||||||
int fd = m_owner->fd();
|
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()) {
|
if ((fd != -1) && !data.null()) {
|
||||||
DataBlock blk;
|
DataBlock blk;
|
||||||
switch (m_owner->law()) {
|
switch (m_owner->law()) {
|
||||||
|
|
|
@ -123,10 +123,10 @@ while ($state != "") {
|
||||||
$ev=Yate::GetEvent();
|
$ev=Yate::GetEvent();
|
||||||
/* If Yate disconnected us then exit cleanly */
|
/* If Yate disconnected us then exit cleanly */
|
||||||
if ($ev == "EOF")
|
if ($ev == "EOF")
|
||||||
break;
|
break;
|
||||||
/* No need to handle empty events in this application */
|
/* No need to handle empty events in this application */
|
||||||
if ($ev == "")
|
if ($ev == "")
|
||||||
continue;
|
continue;
|
||||||
/* If we reached here we should have a valid object */
|
/* If we reached here we should have a valid object */
|
||||||
switch ($ev->type) {
|
switch ($ev->type) {
|
||||||
case "incoming":
|
case "incoming":
|
||||||
|
|
|
@ -12,11 +12,11 @@ require_once("libyate.php");
|
||||||
/* Always the first action to do */
|
/* Always the first action to do */
|
||||||
Yate::Init();
|
Yate::Init();
|
||||||
|
|
||||||
/* Install a handler for the engine generated timer message */
|
/* Install handlers for the DTMF and wave EOF messages */
|
||||||
Yate::Install("chan.dtmf",10);
|
Yate::Install("chan.dtmf");
|
||||||
Yate::Install("chan.notify");
|
Yate::Install("chan.notify");
|
||||||
|
|
||||||
$ourcallid = "external/" . uniqid(rand(),1);
|
$ourcallid = "playrec/" . uniqid(rand(),1);
|
||||||
$partycallid = "";
|
$partycallid = "";
|
||||||
$state = "call";
|
$state = "call";
|
||||||
$dir = "/tmp";
|
$dir = "/tmp";
|
||||||
|
@ -131,16 +131,14 @@ while ($state != "") {
|
||||||
$ev=Yate::GetEvent();
|
$ev=Yate::GetEvent();
|
||||||
/* If Yate disconnected us then exit cleanly */
|
/* If Yate disconnected us then exit cleanly */
|
||||||
if ($ev == "EOF")
|
if ($ev == "EOF")
|
||||||
break;
|
break;
|
||||||
/* Empty events are normal in non-blocking operation.
|
/* Empty events are normal in non-blocking operation.
|
||||||
This is an opportunity to do idle tasks and check timers */
|
This is an opportunity to do idle tasks and check timers */
|
||||||
if ($ev == "")
|
if ($ev == "")
|
||||||
continue;
|
continue;
|
||||||
/* If we reached here we should have a valid object */
|
/* If we reached here we should have a valid object */
|
||||||
switch ($ev->type) {
|
switch ($ev->type) {
|
||||||
case "incoming":
|
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) {
|
switch ($ev->name) {
|
||||||
case "call.execute":
|
case "call.execute":
|
||||||
$partycallid = $ev->params["id"];
|
$partycallid = $ev->params["id"];
|
||||||
|
@ -168,7 +166,9 @@ while ($state != "") {
|
||||||
|
|
||||||
case "chan.dtmf":
|
case "chan.dtmf":
|
||||||
if ($ev->params["targetid"] == $ourcallid ) {
|
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;
|
$ev->handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -13,7 +13,7 @@ require_once("libyate.php");
|
||||||
Yate::Init();
|
Yate::Init();
|
||||||
|
|
||||||
/* Install handlers for the wave end and dtmf notify messages */
|
/* Install handlers for the wave end and dtmf notify messages */
|
||||||
Yate::Install("chan.dtmf",10);
|
Yate::Install("chan.dtmf");
|
||||||
Yate::Install("chan.notify");
|
Yate::Install("chan.notify");
|
||||||
|
|
||||||
$ourcallid = "voicemail/" . uniqid(rand(),1);
|
$ourcallid = "voicemail/" . uniqid(rand(),1);
|
||||||
|
@ -328,10 +328,10 @@ while ($state != "") {
|
||||||
$ev=Yate::GetEvent();
|
$ev=Yate::GetEvent();
|
||||||
/* If Yate disconnected us then exit cleanly */
|
/* If Yate disconnected us then exit cleanly */
|
||||||
if ($ev == "EOF")
|
if ($ev == "EOF")
|
||||||
break;
|
break;
|
||||||
/* No need to handle empty events in this application */
|
/* No need to handle empty events in this application */
|
||||||
if ($ev == "")
|
if ($ev == "")
|
||||||
continue;
|
continue;
|
||||||
/* If we reached here we should have a valid object */
|
/* If we reached here we should have a valid object */
|
||||||
switch ($ev->type) {
|
switch ($ev->type) {
|
||||||
case "incoming":
|
case "incoming":
|
||||||
|
@ -368,7 +368,9 @@ while ($state != "") {
|
||||||
|
|
||||||
case "chan.dtmf":
|
case "chan.dtmf":
|
||||||
if ($ev->params["targetid"] == $ourcallid ) {
|
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;
|
$ev->handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
25
yatengine.h
25
yatengine.h
|
@ -103,6 +103,20 @@ bool DDebug(int level, const char *format, ...);
|
||||||
*/
|
*/
|
||||||
bool DDebug(const char *facility, 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.
|
* Convenience macro.
|
||||||
* Does the same as @ref Debug if NDEBUG is not #defined
|
* 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, ...);
|
bool NDebug(const char *facility, int level, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XDEBUG
|
||||||
|
#undef DEBUG
|
||||||
|
#define DEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DDebug(arg...) Debug(arg)
|
#define DDebug(arg...) Debug(arg)
|
||||||
#else
|
#else
|
||||||
#define DDebug(arg...)
|
#define DDebug(arg...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XDEBUG
|
||||||
|
#define XDebug(arg...) Debug(arg)
|
||||||
|
#else
|
||||||
|
#define XDebug(arg...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#define NDebug(arg...) Debug(arg)
|
#define NDebug(arg...) Debug(arg)
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue