Hello,

there can be many codecs that are selected/offered via SDP, the one actually used can be seen in the RTP headers, but Kamailio doesn't relay RTP itself.

If you know that in your deployment there is going to be only one codec selected via sdp, then the right place is to take it from the SDP of 200ok, when the INVITE request has SDP, or from ACK SDP if the 200ok was the first with SDP. It is in the media (m=) line, which has the format:

m=<media> <port> <transport> <format list>

For example

m=audio 11424 RTP/AVP 8 101

The the next line should give the first codec id:

$(rb{line.sw,m=}{s.select,3, })

Note that there is a space after '3,'. If doesnt work, try:

$var(s) = " ";

$(rb{line.sw,m=}{s.select,3,$var(s)})

Read more about used transformations at:

  * https://www.kamailio.org/wiki/cookbooks/5.3.x/transformations

However, you may need to do further processing if you want the name of the codec, specially for those that have dynamic id, so you need to find the mapping in the a=rtpmap line.

You can use embedded scripting (lua, python, javascript, ... see the app_NAME modules) to parse the body ($rb variable) and extract what you want from there, then set back in an variable (recommended $avp() or $xavp()) that you set to extra accounting parameter of acc module.

Cheers,
Daniel

On 22.11.19 11:12, Abdoul Osséni wrote:
Hello all,

I try to save in the CDR the audio codec used for each established call.

Can you help me?

Regards

Abdoul.I

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com