[asterisk-dev] codec negotiation (bug #4825)

Jorrit Kronjee j.kronjee at infopact.nl
Thu Jun 1 06:36:32 MST 2006


Hello list,

I've been debugging a small bug in the codec negotiation, which wasn't
fixed in the patch made by 'bamby'. The problem occurs in the following
situation:

UA1 = our carrier
A* = our asterisk
UA2 = our customer

1.) UA1 -> A* : INVITE ALAW, G729
2.) A* -> UA2 : INVITE ALAW, G729, A, B, ...
3.) UA2 -> A* : OK G729
4.) A* -> UA1 : OK G729, ALAW
5.) UA1 -> A* : REINVITE ALAW, G729
6.) A* -> UA1 : OK ALAW, G729

As you can see in the first four steps, codec negotiation goes great. It
takes into account what codecs both parties (UA1 en UA2) want to use and
tries to refrain from transcoding.

However, our carrier is a bit stubborn (see step 5) and that's when
asterisk succumbs (step 6) and starts trancoding (UA2 <-> G.729 <-> A*
<-> G.711 <-> UA1).

I've discovered that this behaviour can be changed by actually
removing/disabling the following code in channels/chan_sip.c:

        /* Prefer the codec we were requested to use, first, no matter
what */
        pref_codec = ast_codec_pref_index_audio(capability, 0);
        if (pref_codec) {
                add_codec_to_sdp(p, pref_codec, 8000,
                                 &m_audio_next, &m_audio_left,
                                 &a_audio_next, &a_audio_left,
                                 debug);
                alreadysent |= pref_codec;
        }
        pref_codec = ast_codec_pref_index_video(capability, 0);
        if (pref_codec) {
                add_codec_to_sdp(p, pref_codec, 90000,
                                 &m_video_next, &m_video_left,
                                 &a_video_next, &a_video_left,
                                 debug);
                alreadysent |= pref_codec;
        }

And from what I've seen, this works fine. However, I wonder what it's
supposed to be doing anyway. I've found a similar piece of code in the
non-patched version of asterisk with the same comment attached to it
("Prefer the codec we were requested to use, first, no matter what"). My
question is, when would we be in this no-matter-what-situation? And is
this situation still applicable with the new codec negotiation patch?

Thanks in advance.

Jorrit

-- 
System Developer

Infopact Network Solutions
Hoogvlietsekerkweg 170
3194 AM  Rotterdam Hoogvliet
tel. +31 (0)88 - 4636700
fax. +31 (0)88 - 4636799
mob. +31 (0)6 - 14105968
j.kronjee at infopact.nl
http://www.infopact.nl/




More information about the asterisk-dev mailing list