[asterisk-dev] Advanced Codec Negotiation: Need info and uses cases

Alex Hermann alex-lists at wenlex.nl
Thu Jun 25 05:39:03 CDT 2020


On woensdag 3 juni 2020 22:17:52 CEST George Joseph wrote:
> Now let's talk about format preference order.

I haven't seen my use case pass by yet, so I'll throw it in...

My use case is where Asterisk is functioning as a sort of SBC and needs 
to respect both party's codec preference, disallow unwanted codecs and 
reduce transcoding when possible.

So, Alice should get to talk in her preferred codec, and Bob in his. The  
"allow" list of Asterisk is only used to filter out unwanted codecs. The 
ordering of codecs in the "allow" list is mostly ignored.

To reduce transcoding The offer to Bob should contain the codecs in the 
order Alice offered them.


Asterisk (13) forces the order of the "allow" list on each leg, so I 
have patched my Asterisk 13 with PJSIP to do approximately the above. 
This behaviour is best put under a config option like 
"prefer_remote_codec_order" on the endpoint.


My Asterisk uses the following steps:

1) Retain the codec order from the offer received from Alice.
2) Filter out all codecs from the offer that are not in the allow list 
for Alice
3) Merge the list from step 2 with the allow list from Bob, but keep the 
ordering from the offer from Alice (prepend Alice's received list to 
Bob's and remove duplicates).
4) Filter list from step 3 with the allow list from Bob.

The offer to Bob now contains all the codecs in his allow list, with the 
common codecs between Alice and Bob at the top of the list in the order 
Alice sent them.

5) On receiving the answer from Bob, retain his codec ordering
6) Answer Bob with the received codec ordering from himself
7) Use Bob's most preferred codec in his call leg
8) Answer Alice with the received codec ordering from herself
9) Use Alice's most preferred codec in her call leg

10) When Alice or Bob decides to switch the actual codec in the RTP to 
another codec from the negotioted list, adjust the codec on that leg 
only (to keep codecs symmetric), but don't change anything on the 
bridged leg.
-- 
Alex Hermann





More information about the asterisk-dev mailing list