Skip to content
Snippets Groups Projects
Commit d7a1c2d6 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

IAX codecs negociation according to user config

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