Hello Daniel-Constantin,
Thank you for your response.
When I try that:
if (is_method("INVITE") && status == 200) {
$var(s) = " ";
$var(codec) = $(rb{line.sw,a=rtpmap}{s.select,1,$var(s)});
}
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
0(18567) ERROR: <core> [core/pvapi.c:1105]: pv_parse_spec2(): bad tr in
pvar name "rb"
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)
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)})
ERROR: bad config file (1 errors)
0(18567) INFO: <core> [core/sctp_core.c:53]: sctp_core_destroy(): SCTP API
not initialized
But with the following code, I have no issue
if (is_method("INVITE") && status == 200) {
$var(codec) = $(rb{line.sw,a=rtpmap}{s.select,1, });
}
Abdoul OSSENI
Le ven. 22 nov. 2019 à 11:56, Daniel-Constantin Mierla <miconda(a)gmail.com>
a écrit :
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
Listsr-users@lists.kamailio.orghttps://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla --
www.asipto.comwww.twitter.com/miconda --
www.linkedin.com/in/miconda
Kamailio World Conference - April 27-29, 2020, in Berlin --
www.kamailioworld.com