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

SIP codecs negociation with user choices

parent 3e65410e
...@@ -68,19 +68,15 @@ CodecDescriptor::getCodecName(CodecType payload) ...@@ -68,19 +68,15 @@ CodecDescriptor::getCodecName(CodecType payload)
} }
bool bool
CodecDescriptor::isSupported(CodecType payload) CodecDescriptor::isActive(CodecType payload)
{ {
CodecMap::iterator iter = _codecMap.begin(); int i;
while(iter!=_codecMap.end()) { for(i=0 ; i < _codecOrder.size() ; i++)
if (iter->first == payload) { {
// codec is already in the map --> nothing to do if(_codecOrder[i] == payload)
_debug("Codec with payload %i already in the map\n", payload); return true;
//break;
return true;
}
iter++;
} }
return false; return false;
} }
void void
......
...@@ -91,7 +91,7 @@ public: ...@@ -91,7 +91,7 @@ public:
* @return true if the codec specified is supported * @return true if the codec specified is supported
* false otherwise * false otherwise
*/ */
bool isSupported(CodecType payload); bool isActive(CodecType payload);
/** /**
* Remove the codec with payload payload from the list * Remove the codec with payload payload from the list
......
...@@ -353,17 +353,18 @@ SIPCall::sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg) ...@@ -353,17 +353,18 @@ SIPCall::sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg)
remote_med_m_payloads = &(remote_med->m_payloads); remote_med_m_payloads = &(remote_med->m_payloads);
#endif #endif
while (!osip_list_eol(remote_med_m_payloads, iPayload) && iPayload < 2) { //while (!osip_list_eol(remote_med_m_payloads, iPayload) && iPayload < 2) {
while (!osip_list_eol(remote_med_m_payloads, iPayload)) {
tmp = (char *)osip_list_get(remote_med_m_payloads, iPayload); tmp = (char *)osip_list_get(remote_med_m_payloads, iPayload);
if (tmp!=NULL) { if (tmp!=NULL) {
int payload = atoi(tmp); int payload = atoi(tmp);
_debug("remote payload = %s\n", tmp); _debug("remote payload = %s\n", tmp);
CodecType audiocodec = (CodecType)payload; CodecType audiocodec = (CodecType)payload;
//if (audiocodec != NULL && audiocodec->isActive()) { if (audiocodec != (CodecType)-1 && _codecMap.isActive(audiocodec)) {
if (audiocodec != (CodecType)-1 && _codecMap.isSupported(audiocodec)) { _debug("PAYLOAD = %i", payload);
listCodec << payload << " "; listCodec << payload << " ";
//listRtpMap << "a=rtpmap:" << payload << " " << audiocodec->getCodecName() << "/" << audiocodec->getClockRate(); //listRtpMap << "a=rtpmap:" << payload << " " << audiocodec->getCodecName() << "/" << audiocodec->getClockRate();
listRtpMap << "a=rtpmap:" << payload << " " << _codecMap.getCodecName(audiocodec) << "/" << 8000; listRtpMap << "a=rtpmap:" << payload << " " << _codecMap.getCodecName(audiocodec) << "/" << _codecMap.getSampleRate(audiocodec);
// TODO: manage a way to get the channel infos // TODO: manage a way to get the channel infos
/*if ( audiocodec->getChannel() != 1) { /*if ( audiocodec->getChannel() != 1) {
listRtpMap << "/" << audiocodec->getChannel(); listRtpMap << "/" << audiocodec->getChannel();
...@@ -586,7 +587,7 @@ SIPCall::setAudioCodecFromSDP(sdp_media_t* remote_med, int tid) ...@@ -586,7 +587,7 @@ SIPCall::setAudioCodecFromSDP(sdp_media_t* remote_med, int tid)
if (tmp != NULL ) { if (tmp != NULL ) {
int payload = atoi(tmp); int payload = atoi(tmp);
// stop if we find a correct codec // stop if we find a correct codec
if (_codecMap.isSupported((CodecType)payload)){ if (_codecMap.isActive((CodecType)payload)){
break; break;
} }
} }
......
...@@ -943,32 +943,32 @@ SIPVoIPLink::SIPStartCall(SIPCall* call, const std::string& subject) ...@@ -943,32 +943,32 @@ SIPVoIPLink::SIPStartCall(SIPCall* call, const std::string& subject)
std::ostringstream media_audio; std::ostringstream media_audio;
std::ostringstream rtpmap_attr; std::ostringstream rtpmap_attr;
int payload; CodecType payload;
int nbChannel; int nbChannel;
int iter;
// Set rtpmap according to the supported codec order // Set rtpmap according to the supported codec order
CodecMap map = call->getCodecMap().getCodecMap(); //CodecMap map = call->getCodecMap().getCodecMap();
//CodecMap map = Manager::instance().getCodecDescriptorMap(); CodecOrder map = call->getCodecMap().getActiveCodecs();
CodecMap::iterator iter = map.begin();
for(iter=0 ; iter < map.size() ; iter++){
while(iter != map.end()) { if(map[iter] != -1){
//if (iter->second!=0 && iter->second->isActive()) { payload = map[iter];
if(iter->first != -1){ // add each payload in the list of payload
payload = iter->first; media_audio << payload << " ";
// add each payload in the list of payload
media_audio << payload << " "; rtpmap_attr << "a=rtpmap:" << payload << " " <<
call->getCodecMap().getCodecName(payload) << "/" << call->getCodecMap().getSampleRate(payload);
rtpmap_attr << "a=rtpmap:" << payload << " " <<
iter->second.data() << "/" << call->getCodecMap().getSampleRate(iter->first); //TODO add channel infos
/*nbChannel = iter->second->getChannel();
/*nbChannel = iter->second->getChannel(); if (nbChannel!=1) {
if (nbChannel!=1) { rtpmap_attr << "/" << nbChannel;
rtpmap_attr << "/" << nbChannel; }*/
}*/ rtpmap_attr << "\r\n";
rtpmap_attr << "\r\n"; }
}
// go to next codec // go to next codec
iter++; //*iter++;
} }
// http://www.antisip.com/documentation/eXosip2/group__howto1__initialize.html // http://www.antisip.com/documentation/eXosip2/group__howto1__initialize.html
......
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