Dynamically removing remote unsupported capabilities from H323.
Fully asynchronous wave consumer disconnect. git-svn-id: http://yate.null.ro/svn/yate/trunk@189 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
571a21b578
commit
9ee4f7f33f
|
@ -286,13 +286,14 @@ public:
|
|||
virtual void OnUserInputString(const PString &value);
|
||||
virtual BOOL OpenAudioChannel(BOOL isEncoding, unsigned bufferSize,
|
||||
H323AudioCodec &codec);
|
||||
virtual void OnSetLocalCapabilities();
|
||||
#ifdef NEED_RTP_QOS_PARAM
|
||||
H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability,H323Channel::Directions dir,unsigned sessionID,const H245_H2250LogicalChannelParameters *param,RTP_QOS * rtpqos = NULL);
|
||||
virtual H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability,H323Channel::Directions dir,unsigned sessionID,const H245_H2250LogicalChannelParameters *param,RTP_QOS * rtpqos = NULL);
|
||||
#else
|
||||
H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability,H323Channel::Directions dir,unsigned sessionID,const H245_H2250LogicalChannelParameters *param);
|
||||
virtual H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability,H323Channel::Directions dir,unsigned sessionID,const H245_H2250LogicalChannelParameters *param);
|
||||
#endif
|
||||
BOOL OnStartLogicalChannel(H323Channel & channel);
|
||||
BOOL OnCreateLogicalChannel(const H323Capability & capability, H323Channel::Directions dir, unsigned & errorCode ) ;
|
||||
virtual BOOL OnStartLogicalChannel(H323Channel & channel);
|
||||
virtual BOOL OnCreateLogicalChannel(const H323Capability & capability, H323Channel::Directions dir, unsigned & errorCode ) ;
|
||||
BOOL StartExternalRTP(const char* remoteIP, WORD remotePort, H323Channel::Directions dir, YateH323_ExternalRTPChannel* chan);
|
||||
void OnStoppedExternal(H323Channel::Directions dir);
|
||||
void SetRemoteAddress(const char* remoteIP, WORD remotePort);
|
||||
|
@ -994,7 +995,7 @@ H323Channel *YateH323Connection::CreateRealTimeLogicalChannel(const H323Capabili
|
|||
|
||||
// disallow codecs not supported by remote receiver
|
||||
if (s_passtrough && !(m_formats.null() || (m_formats.find(format) >= 0))) {
|
||||
Debug(DebugInfo,"Refusing '%s' not in remote '%s'",format,m_formats.c_str());
|
||||
Debug(DebugWarn,"Refusing '%s' not in remote '%s'",format,m_formats.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1040,6 +1041,33 @@ H323Channel *YateH323Connection::CreateRealTimeLogicalChannel(const H323Capabili
|
|||
#endif
|
||||
}
|
||||
|
||||
void YateH323Connection::OnSetLocalCapabilities()
|
||||
{
|
||||
Debug(DebugAll,"YateH323Connection::OnSetLocalCapabilities() [%p]",this);
|
||||
H323Connection::OnSetLocalCapabilities();
|
||||
if (m_formats.null())
|
||||
return;
|
||||
// remote has a list of supported codecs - remove unsupported capabilities
|
||||
bool nocodecs = true;
|
||||
for (int i = 0; i < localCapabilities.GetSize(); i++) {
|
||||
const char* format = 0;
|
||||
String fname;
|
||||
decodeCapability(localCapabilities[i],&format,0,&fname);
|
||||
if (format) {
|
||||
if (m_formats.find(format) < 0) {
|
||||
Debug(DebugAll,"Removing capability '%s' (%s) not in remote '%s'",
|
||||
fname.c_str(),format,m_formats.c_str());
|
||||
localCapabilities.Remove(fname.c_str());
|
||||
i--;
|
||||
}
|
||||
else
|
||||
nocodecs = false;
|
||||
}
|
||||
}
|
||||
if (nocodecs)
|
||||
Debug(DebugWarn,"No codecs remaining for H323 connection [%p]",this);
|
||||
}
|
||||
|
||||
BOOL YateH323Connection::OnStartLogicalChannel(H323Channel & channel)
|
||||
{
|
||||
Debug(DebugInfo,"YateH323Connection::OnStartLogicalChannel(%p) [%p]",&channel,this);
|
||||
|
@ -1070,7 +1098,7 @@ BOOL YateH323Connection::decodeCapability(const H323Capability & capability, con
|
|||
break;
|
||||
}
|
||||
}
|
||||
Debug(DebugInfo,"capability '%s' format '%s' payload %d",fname.c_str(),format,pload);
|
||||
DDebug(DebugAll,"capability '%s' format '%s' payload %d",fname.c_str(),format,pload);
|
||||
if (format) {
|
||||
if (capabName)
|
||||
*capabName = fname;
|
||||
|
|
|
@ -88,15 +88,15 @@ private:
|
|||
static int s_nextid;
|
||||
};
|
||||
|
||||
class ChanDisconnector : public Thread
|
||||
class ConsDisconnector : public Thread
|
||||
{
|
||||
public:
|
||||
ChanDisconnector(DataEndpoint *chan)
|
||||
: m_chan(chan) { }
|
||||
virtual void run()
|
||||
{ m_chan->disconnect(); }
|
||||
ConsDisconnector(DataEndpoint *chan, const String& id)
|
||||
: m_chan(chan), m_id(id) { }
|
||||
virtual void run();
|
||||
private:
|
||||
DataEndpoint *m_chan;
|
||||
String m_id;
|
||||
};
|
||||
|
||||
class WaveHandler : public MessageHandler
|
||||
|
@ -243,7 +243,7 @@ void WaveSource::run()
|
|||
Debug(DebugAll,"WaveSource [%p] end of data [%p] [%s] ",this,m_chan,m_id.c_str());
|
||||
if (m_chan && !m_id.null()) {
|
||||
Message *m = new Message("chan.notify");
|
||||
m->addParam("id",m_id);
|
||||
m->addParam("targetid",m_id);
|
||||
m->userData(m_chan);
|
||||
Engine::enqueue(m);
|
||||
m_chan->setSource();
|
||||
|
@ -305,15 +305,9 @@ void WaveConsumer::Consume(const DataBlock &data, unsigned long timeDelta)
|
|||
::close(m_fd);
|
||||
m_fd = -1;
|
||||
}
|
||||
if (m_chan && !m_id.null()) {
|
||||
m_chan->setConsumer();
|
||||
Message *m = new Message("chan.notify");
|
||||
m->addParam("id",m_id);
|
||||
m->userData(m_chan);
|
||||
Engine::enqueue(m);
|
||||
}
|
||||
if (m_chan) {
|
||||
ChanDisconnector *disc = new ChanDisconnector(m_chan);
|
||||
ConsDisconnector *disc = new ConsDisconnector(m_chan,m_id);
|
||||
m_chan = 0;
|
||||
if (disc->error()) {
|
||||
Debug(DebugFail,"Error creating disconnector thread %p",disc);
|
||||
delete disc;
|
||||
|
@ -325,6 +319,20 @@ void WaveConsumer::Consume(const DataBlock &data, unsigned long timeDelta)
|
|||
}
|
||||
}
|
||||
|
||||
void ConsDisconnector::run()
|
||||
{
|
||||
DDebug(DebugAll,"ConsDisconnector chan=%p id='%s'",m_chan,m_id.c_str());
|
||||
if (m_id) {
|
||||
m_chan->setConsumer();
|
||||
Message *m = new Message("chan.notify");
|
||||
m->addParam("targetid",m_id);
|
||||
m->userData(m_chan);
|
||||
Engine::enqueue(m);
|
||||
}
|
||||
else
|
||||
m_chan->disconnect();
|
||||
}
|
||||
|
||||
Mutex mutex;
|
||||
int WaveChan::s_nextid = 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue