DevSteven Services

Media negotiation

Answering with the remote SDP's codec priority in Asterisk

When two SIP parties offer and answer codecs, the order matters. Asterisk answers with its own preference. Operators expect their order to be followed, and when it is not, calls renegotiate codecs or start audio late. This change lets the remote SDP set the priority.

The problem

An operator offers AMR-WB, PCMA, PCMU in that order and expects the first codec both sides support. If the platform answers with its own preference, the two ends can land on different codecs, trigger a re-INVITE to fix it, or transcode when no transcoding was needed. The visible effects are wasted signalling, extra traffic and a delay before audio starts.

What stock Asterisk does

When building the joint codec set it intersects the remote offer with its local capabilities and keeps the local order. The remote party's priority is lost.

What we change

The SDP parser records the order of the payload types in the remote offer, and the joint set is built in that order. The answer therefore lists the shared codecs the way the offer did, so both sides pick the same one first time.

; remote offer
m=audio 30000 RTP/AVP 98 8 0

; stock answer, local order
m=audio 16384 RTP/AVP 0 8 98

; answer with remote priority
m=audio 16384 RTP/AVP 98 8 0

Result

  • No time or traffic spent on codec renegotiation.
  • Audio starts sooner.
  • Fewer transcoded calls, because the wideband codec the operator prefers is actually chosen.

Verified in tests on real traffic. It is delivered as its own build version, per customer, on request.

Stackchan_sip on Asterisk 16 LTS
Version3.5

Related

Need this on your platform? Tell us the Asterisk version and the interconnect, and we reply within 24 hours.

Request a quote