Support changing formats from routing for inbound Jingle calls.

git-svn-id: http://yate.null.ro/svn/yate/trunk@5180 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2012-07-05 11:09:13 +00:00
parent 456c588c97
commit f268caafdc
3 changed files with 28 additions and 0 deletions

View File

@ -428,6 +428,21 @@ void JGRtpMediaList::setMedia(const JGRtpMediaList& src, const String& only)
TelEngine::destruct(f);
}
// Filter media list, remove unwanted types
void JGRtpMediaList::filterMedia(const String& only)
{
if (only.null())
return;
ObjList* f = only.split(',',false);
ListIterator iter(*this);
while (JGRtpMedia* media = static_cast<JGRtpMedia*>(iter.get())) {
const String& name = media->m_synonym.null() ? media->m_name : media->m_synonym;
if (!(f->find(name)))
remove(media);
}
TelEngine::destruct(f);
}
// Find a data payload by its id
JGRtpMedia* JGRtpMediaList::findMedia(const String& id)
{

View File

@ -307,6 +307,12 @@ public:
*/
void setMedia(const JGRtpMediaList& src, const String& only = String::empty());
/**
* Filter media list preserving only some formats
* @param only List of synonyms to preserve, do not filter media if this parameter is empty
*/
void filterMedia(const String& only);
/**
* Find a data payload by its id
* @param id Identifier of media to find

View File

@ -1167,6 +1167,13 @@ bool YJGConnection::callRouted(Message& msg)
DDebug(this,DebugCall,"callRouted [%p]",this);
// Update ringing
m_ringFlags = getRinging(msg,this,m_ringFlags);
// Update formats
const String& formats = msg[YSTRING("formats")];
if (formats) {
m_audioFormats.filterMedia(formats);
for (ObjList* o = m_audioContents.skipNull(); o; o = o->skipNext())
static_cast<JGSessionContent*>(o->get())->m_rtpMedia.filterMedia(formats);
}
return Channel::callRouted(msg);
}