<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Vorformatiert Zchn";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.HTMLVorformatiertZchn
        {mso-style-name:"HTML Vorformatiert Zchn";
        mso-style-priority:99;
        mso-style-link:"HTML Vorformatiert";
        font-family:Consolas;
        mso-fareast-language:DE;}
span.E-MailFormatvorlage21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hello Abdoul,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">this line looks like a bug in Kamailio:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"> 0(18567) CRITICAL: <core> [core/mem/q_malloc.c:514]: qm_free(): BUG: freeing already freed pointer (0x7fb9a0606010), called from core: core/pvapi.c: tr_param_free(1833), first free pv: pv_trans.c: tr_parse_string(2425)
 – ignoring<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Please open an issue in our github tracker about it, with the cfg to reproduce it would be best.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Henning</span><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">-- <o:p>
</o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Henning Westerholt –
</span><span style="mso-fareast-language:EN-US"><a href="https://skalatan.de/blog/"><span lang="EN-GB" style="color:#0563C1">https://skalatan.de/blog/</span></a></span><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Kamailio services –
</span><span style="mso-fareast-language:EN-US"><a href="https://gilawa.com/"><span lang="EN-GB" style="color:#0563C1">https://gilawa.com</span></a></span><span style="mso-fareast-language:EN-US">
<span lang="EN-GB"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span lang="EN-GB">Kamailio Merchandising – </span><a href="https://skalatan.de/merchandising"><span lang="EN-GB" style="color:#0563C1">https://skalatan.de/merchandising</span></a>
<span lang="EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b> sr-users <sr-users-bounces@lists.kamailio.org>
<b>On Behalf Of </b>Abdoul Osséni<br>
<b>Sent:</b> Friday, November 22, 2019 3:14 PM<br>
<b>To:</b> Daniel-Constantin Mierla <miconda@gmail.com><br>
<b>Cc:</b> Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org><br>
<b>Subject:</b> Re: [SR-Users] How to get the audio codec used for each established call.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Hello Daniel-Constantin,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Thank you for your response.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">When I try that:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<p class="MsoNormal" style="margin-left:35.4pt">if (is_method("INVITE") && status == 200) {<br>
$var(s) = " ";<br>
$var(codec) = $(rb{line.sw,a=rtpmap}{s.select,1,$var(s)});<br>
}<br>
<br>
<br>
 0(18567) CRITICAL: <core> [core/mem/q_malloc.c:514]: qm_free(): BUG: freeing already freed pointer (0x7fb9a0606010), called from core: core/pvapi.c: tr_param_free(1833), first free pv: pv_trans.c: tr_parse_string(2425) - ignoring<br>
 0(18567) ERROR: <core> [core/pvapi.c:1105]: pv_parse_spec2(): bad tr in pvar name "rb"<br>
 0(18567) ERROR: <core> [core/pvapi.c:1131]: pv_parse_spec2(): invalid parsing in [$(rb{line.sw,a=rtpmap}{s.select,1,$var(s)})] at (4)<br>
 0(18567) CRITICAL: <core> [core/cfg.y:3537]: yyerror_at(): parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 840, column 17-59: Can't get from cache: $(rb{line.sw,a=rtpmap}{s.select,1,$var(s)})<br>
ERROR: bad config file (1 errors)<br>
 0(18567) INFO: <core> [core/sctp_core.c:53]: sctp_core_destroy(): SCTP API not initialized<br>
<br>
But with the following code, I have no issue<br>
if (is_method("INVITE") && status == 200) {<br>
$var(codec) = $(rb{line.sw,a=rtpmap}{s.select,1, });<br>
}<br>
<br clear="all">
<o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:9.5pt">Abdoul OSSENI</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Le ven. 22 nov. 2019 à 11:56, Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com">miconda@gmail.com</a>> a écrit :<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p style="margin-left:35.4pt">Hello,<o:p></o:p></p>
<p style="margin-left:35.4pt">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.<o:p></o:p></p>
<p style="margin-left:35.4pt">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:<o:p></o:p></p>
<p style="margin-left:35.4pt">m=<media> <port> <transport> <format list> <o:p></o:p></p>
<p style="margin-left:35.4pt">For example<o:p></o:p></p>
<p style="margin-left:35.4pt">m=audio 11424 RTP/AVP 8 101<o:p></o:p></p>
<p style="margin-left:35.4pt">The the next line should give the first codec id:<o:p></o:p></p>
<p style="margin-left:35.4pt">$(rb{line.sw,m=}{s.select,3, })<o:p></o:p></p>
<p style="margin-left:35.4pt">Note that there is a space after '3,'. If doesnt work, try:<o:p></o:p></p>
<p style="margin-left:35.4pt">$var(s) = " ";<o:p></o:p></p>
<p style="margin-left:35.4pt">$(rb{line.sw,m=}{s.select,3,$var(s)})<o:p></o:p></p>
<p style="margin-left:35.4pt">Read more about used transformations at:<o:p></o:p></p>
<p style="margin-left:35.4pt">  * <a href="https://www.kamailio.org/wiki/cookbooks/5.3.x/transformations" target="_blank">
https://www.kamailio.org/wiki/cookbooks/5.3.x/transformations</a><o:p></o:p></p>
<p style="margin-left:35.4pt">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.<o:p></o:p></p>
<p style="margin-left:35.4pt">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.<o:p></o:p></p>
<p style="margin-left:35.4pt">Cheers,<br>
Daniel<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">On 22.11.19 11:12, Abdoul Osséni wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-left:35.4pt">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:9.5pt">I</span><o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<pre style="margin-left:35.4pt">_______________________________________________<o:p></o:p></pre>
<pre style="margin-left:35.4pt">Kamailio (SER) - Users Mailing List<o:p></o:p></pre>
<pre style="margin-left:35.4pt"><a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><o:p></o:p></pre>
<pre style="margin-left:35.4pt"><a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><o:p></o:p></pre>
</blockquote>
<pre style="margin-left:35.4pt">-- <o:p></o:p></pre>
<pre style="margin-left:35.4pt">Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a><o:p></o:p></pre>
<pre style="margin-left:35.4pt"><a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a><o:p></o:p></pre>
<pre style="margin-left:35.4pt">Kamailio World Conference - April 27-29, 2020, in Berlin -- <a href="http://www.kamailioworld.com" target="_blank">www.kamailioworld.com</a><o:p></o:p></pre>
</div>
</blockquote>
</div>
</div>
</body>
</html>