Added option to return a data sniffer safe and referenced.
git-svn-id: http://voip.null.ro/svn/yate@6175 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
b2c0b343a5
commit
d71d9f38e4
|
@ -1013,6 +1013,15 @@ bool DataEndpoint::delSniffer(DataConsumer* sniffer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DataConsumer* DataEndpoint::getSniffer(const String& name, bool ref)
|
||||||
|
{
|
||||||
|
if (name.null())
|
||||||
|
return 0;
|
||||||
|
Lock lock(s_dataMutex);
|
||||||
|
DataConsumer* sniffer = static_cast<DataConsumer*>(m_sniffers[name]);
|
||||||
|
return (ref && sniffer && !sniffer->ref()) ? 0 : sniffer;
|
||||||
|
}
|
||||||
|
|
||||||
void DataEndpoint::clearSniffers()
|
void DataEndpoint::clearSniffers()
|
||||||
{
|
{
|
||||||
Lock lock(s_dataMutex);
|
Lock lock(s_dataMutex);
|
||||||
|
|
|
@ -246,15 +246,15 @@ bool AttachHandler::received(Message& msg)
|
||||||
if (snif) {
|
if (snif) {
|
||||||
RefPointer<DataEndpoint> de = ch->setEndpoint();
|
RefPointer<DataEndpoint> de = ch->setEndpoint();
|
||||||
// try to reinit sniffer if one already exists
|
// try to reinit sniffer if one already exists
|
||||||
MrcpConsumer* c = static_cast<MrcpConsumer*>(de->getSniffer(snif));
|
MrcpConsumer* c = static_cast<MrcpConsumer*>(de->getSniffer(snif,true));
|
||||||
if (c)
|
if (c)
|
||||||
c->init(msg);
|
c->init(msg);
|
||||||
else {
|
else {
|
||||||
c = new MrcpConsumer(ch->id(),snif,msg.getValue("format","slin"));
|
c = new MrcpConsumer(ch->id(),snif,msg.getValue("format","slin"));
|
||||||
if (c->init(msg))
|
if (c->init(msg))
|
||||||
de->addSniffer(c);
|
de->addSniffer(c);
|
||||||
c->deref();
|
|
||||||
}
|
}
|
||||||
|
c->deref();
|
||||||
}
|
}
|
||||||
return msg.getBoolValue("single");
|
return msg.getBoolValue("single");
|
||||||
}
|
}
|
||||||
|
|
|
@ -555,7 +555,7 @@ bool AttachHandler::received(Message& msg)
|
||||||
if (snif) {
|
if (snif) {
|
||||||
de = ch->setEndpoint();
|
de = ch->setEndpoint();
|
||||||
// try to reinit sniffer if one already exists
|
// try to reinit sniffer if one already exists
|
||||||
ToneConsumer* c = static_cast<ToneConsumer*>(de->getSniffer(snif));
|
ToneConsumer* c = static_cast<ToneConsumer*>(de->getSniffer(snif,true));
|
||||||
if (c) {
|
if (c) {
|
||||||
c->init();
|
c->init();
|
||||||
c->setFaxDivert(msg);
|
c->setFaxDivert(msg);
|
||||||
|
@ -564,8 +564,8 @@ bool AttachHandler::received(Message& msg)
|
||||||
c = new ToneConsumer(ch->id(),snif);
|
c = new ToneConsumer(ch->id(),snif);
|
||||||
c->setFaxDivert(msg);
|
c->setFaxDivert(msg);
|
||||||
de->addSniffer(c);
|
de->addSniffer(c);
|
||||||
c->deref();
|
|
||||||
}
|
}
|
||||||
|
c->deref();
|
||||||
}
|
}
|
||||||
return msg.getBoolValue("single");
|
return msg.getBoolValue("single");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1054,10 +1054,10 @@ public:
|
||||||
/**
|
/**
|
||||||
* Find a sniffer by name
|
* Find a sniffer by name
|
||||||
* @param name Name of the sniffer to find
|
* @param name Name of the sniffer to find
|
||||||
|
* @param ref Increment the reference counter before returning
|
||||||
* @return Pointer to DataConsumer or NULL if not found
|
* @return Pointer to DataConsumer or NULL if not found
|
||||||
*/
|
*/
|
||||||
inline DataConsumer* getSniffer(const String& name)
|
DataConsumer* getSniffer(const String& name, bool ref = false);
|
||||||
{ return static_cast<DataConsumer*>(m_sniffers[name]); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all sniffers from the list and dereferences them
|
* Removes all sniffers from the list and dereferences them
|
||||||
|
|
Loading…
Reference in New Issue