Commit d7a1c2d6 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

IAX codecs negociation according to user config

parent a421cde9
......@@ -35,16 +35,6 @@ IAXCall::setFormat(int format)
{
_format = format;
switch(format) {
/*case AST_FORMAT_ULAW:
setAudioCodec(_codecMap.getCodec(PAYLOAD_CODEC_ULAW)); break;
case AST_FORMAT_GSM:
setAudioCodec(_codecMap.getCodec(PAYLOAD_CODEC_GSM)); break;
case AST_FORMAT_ALAW:
setAudioCodec(_codecMap.getCodec(PAYLOAD_CODEC_ALAW)); break;
case AST_FORMAT_ILBC:
setAudioCodec(_codecMap.getCodec(PAYLOAD_CODEC_ILBC_20)); break;
case AST_FORMAT_SPEEX:
setAudioCodec(_codecMap.getCodec(PAYLOAD_CODEC_SPEEX_8000)); break;*/
case AST_FORMAT_ULAW:
setAudioCodec(PAYLOAD_CODEC_ULAW); break;
case AST_FORMAT_GSM:
......@@ -65,12 +55,12 @@ IAXCall::setFormat(int format)
int
IAXCall::getSupportedFormat()
{
CodecMap map = getCodecMap().getCodecMap();
CodecOrder map = getCodecMap().getActiveCodecs();
int format = 0;
int iter;
CodecMap::iterator iter = map.begin();
while(iter != map.end()) {
switch(iter->first) {
for(iter=0 ; iter < map.size() ; iter++){
switch(map[iter]) {
case PAYLOAD_CODEC_ULAW:
format |= AST_FORMAT_ULAW; break;
case PAYLOAD_CODEC_GSM:
......@@ -80,11 +70,11 @@ IAXCall::getSupportedFormat()
case PAYLOAD_CODEC_ILBC_20:
format |= AST_FORMAT_ILBC; break;
case PAYLOAD_CODEC_SPEEX_8000:
format |= AST_FORMAT_SPEEX; break;
format |= AST_FORMAT_SPEEX;
break;
default:
break;
}
iter++;
}
return format;
......@@ -93,18 +83,19 @@ IAXCall::getSupportedFormat()
int
IAXCall::getFirstMatchingFormat(int needles)
{
CodecMap map = getCodecMap().getCodecMap();
CodecOrder map = getCodecMap().getActiveCodecs();
int format = 0;
int iter;
CodecMap::iterator iter = map.begin();
while(iter != map.end()) {
switch(iter->first) {
for(iter=0 ; iter < map.size() ; iter++) {
switch(map[iter]) {
case PAYLOAD_CODEC_ULAW:
format = AST_FORMAT_ULAW; break;
case PAYLOAD_CODEC_GSM:
format = AST_FORMAT_GSM; break;
case PAYLOAD_CODEC_ALAW:
format = AST_FORMAT_ALAW; break;
format = AST_FORMAT_ALAW;
break;
case PAYLOAD_CODEC_ILBC_20:
format = AST_FORMAT_ILBC; break;
case PAYLOAD_CODEC_SPEEX_8000:
......@@ -112,11 +103,10 @@ IAXCall::getFirstMatchingFormat(int needles)
default:
break;
}
// Return the first that matches
if (format & needles)
return format;
iter++;
}
return 0;
}
......@@ -515,6 +515,8 @@ Call*
IAXVoIPLink::newOutgoingCall(const CallID& id, const std::string& toUrl)
{
IAXCall* call = new IAXCall(id, Call::Outgoing);
call->setCodecMap(Manager::instance().getCodecDescriptorMap());
if (call) {
call->setPeerNumber(toUrl);
......@@ -957,6 +959,7 @@ IAXVoIPLink::iaxHandlePrecallEvent(iax_event* event)
call->setCodecMap(Manager::instance().getCodecDescriptorMap());
call->setConnectionState(Call::Progressing);
if (event->ies.calling_number)
call->setPeerNumber(std::string(event->ies.calling_number));
if (event->ies.calling_name)
......@@ -1008,3 +1011,12 @@ IAXVoIPLink::iaxHandlePrecallEvent(iax_event* event)
}
int
IAXVoIPLink::iaxCodecMapToFormat(IAXCall* call)
{
CodecOrder map = call->getCodecMap().getActiveCodecs();
printf("taytciatcia = %i\n", map.size());
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment