<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>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.</p>
    <p>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:</p>
    <p>m=<media> <port> <transport> <format
      list> <br>
    </p>
    <p>For example<br>
    </p>
    <p>m=audio 11424 RTP/AVP 8 101<br>
    </p>
    <p>The the next line should give the first codec id:</p>
    <p>$(rb{line.sw,m=}{s.select,3, })</p>
    <p>Note that there is a space after '3,'. If doesnt work, try:</p>
    <p>$var(s) = " ";</p>
    <p>$(rb{line.sw,m=}{s.select,3,$var(s)})</p>
    <p>Read more about used transformations at:</p>
    <p>  * <a
        href="https://www.kamailio.org/wiki/cookbooks/5.3.x/transformations">https://www.kamailio.org/wiki/cookbooks/5.3.x/transformations</a></p>
    <p>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.</p>
    <p>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.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 22.11.19 11:12, Abdoul Osséni wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CABc7nxv6=jaUoJvJRj7zKy7270vrEGC23hGVmzphpsZg=aupdA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hello all,<br>
        <br>
        I try to save in the CDR the audio codec used for each
        established call.<br>
        <br>
        Can you help me?<br>
        <br>
        Regards<br>
        <br>
        Abdoul.<span style="font-size:12.8px">I</span></div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio World Conference - April 27-29, 2020, in Berlin -- <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
  </body>
</html>