Pick only the already offered formats from an arbitrary list of media formats.
This removes the possibility of accidentally answering with a codec that was not offered. git-svn-id: http://voip.null.ro/svn/yate@3347 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
62eeb68836
commit
3f364ef2bd
|
@ -73,15 +73,41 @@ bool SDPMedia::update(const char* formats, int rport, int lport)
|
|||
DDebug(DebugAll,"SDPMedia::update('%s',%d,%d) [%p]",formats,rport,lport,this);
|
||||
bool chg = false;
|
||||
String tmp(formats);
|
||||
if (m_formats != tmp) {
|
||||
if ((tmp.find(',') < 0) && m_formats && m_formats.find(tmp) < 0)
|
||||
Debug(DebugInfo,"Not changing to '%s' from '%s' [%p]",
|
||||
formats,m_formats.c_str(),this);
|
||||
else {
|
||||
if (tmp && (m_formats != tmp)) {
|
||||
if (tmp.find(',') < 0) {
|
||||
// single format received, check if acceptable
|
||||
if (m_formats && m_formats.find(tmp) < 0) {
|
||||
Debug(DebugNote,"Not changing to '%s' from '%s' [%p]",
|
||||
formats,m_formats.c_str(),this);
|
||||
tmp.clear();
|
||||
}
|
||||
}
|
||||
else if (m_formats) {
|
||||
// from received list keep only already offered formats
|
||||
ObjList* l1 = tmp.split(',',false);
|
||||
ObjList* l2 = m_formats.split(',',false);
|
||||
for (ObjList* fmt = l1->skipNull(); fmt; ) {
|
||||
if (l2->find(fmt->get()->toString()))
|
||||
fmt = fmt->skipNext();
|
||||
else {
|
||||
fmt->remove();
|
||||
fmt = fmt->skipNull();
|
||||
}
|
||||
}
|
||||
tmp.clear();
|
||||
tmp.append(l1,",");
|
||||
TelEngine::destruct(l1);
|
||||
TelEngine::destruct(l2);
|
||||
if (tmp.null())
|
||||
Debug(DebugNote,"Not changing formats '%s' [%p]",m_formats.c_str(),this);
|
||||
}
|
||||
if (tmp && (m_formats != tmp)) {
|
||||
chg = true;
|
||||
m_formats = tmp;
|
||||
int q = m_formats.find(',');
|
||||
m_format = m_formats.substr(0,q);
|
||||
Debug(DebugInfo,"Choosing offered '%s' format '%s' [%p]",
|
||||
c_str(),m_format.c_str(),this);
|
||||
}
|
||||
}
|
||||
if (rport >= 0) {
|
||||
|
|
|
@ -547,7 +547,7 @@ void SDPSession::updateFormats(const NamedList& msg, bool changeMedia)
|
|||
if (rtp) {
|
||||
if (rtp->update(*p))
|
||||
Debug(m_parser,DebugNote,"Formats for '%s' changed to '%s' [%p]",
|
||||
tmp.c_str(),p->c_str(),this);
|
||||
tmp.c_str(),rtp->formats().c_str(),this);
|
||||
}
|
||||
else if (*p) {
|
||||
Debug(m_parser,DebugNote,"Got formats '%s' for absent media '%s' [%p]",
|
||||
|
|
Loading…
Reference in New Issue