Commit bec1a6ce authored by Emmanuel Milou's avatar Emmanuel Milou

SIP codecs negociation with user choices

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