[SR-Users] Capture a Match from Regex comparison

Sebastian Damm damm at sipgate.de
Fri Jun 19 11:52:07 CEST 2015


Hi,

we have some cases, where we get multiple PCMA lines with different numbers
from a peer. One of our backend systems doesn't handle that correctly. So
what I want to do is detect whether there is a PCMA line with a
non-standard number in the SDP.

This is how an SDP looks like:
v=0
o=hiQ9200 2990220150519102450 1229717573 IN IP4 1.2.3.4
s=Phone Call
c=IN IP4 1.2.3.4
t=0 0
m=audio 40174 RTP/AVP 8 0 18 96 97 13 100 98 99
a=rtpmap:8 PCMA/8000
a=fmtp:8 vad=no
a=rtpmap:0 PCMU/8000
a=fmtp:0 vad=no
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=yes
a=rtpmap:96 G726-32/8000
a=rtpmap:97 AAL2-G726-32/8000
a=rtpmap:100 telephone-event/8000
a=fmtp:100 0-15
a=rtpmap:98 PCMA/8000
a=gpmd:98 vbd=yes
a=rtpmap:99 PCMU/8000
a=gpmd:99 vbd=yes
a=sqn: 0
a=cdsc: 1 image udptl t38
a=sendrecv
a=pmft: T38
a=ptime:20

I tried something like that (expecting that the number doesn't change):

if (sdp_get_line_startswith("$avp(badcodec)", "a=rtpmap:98 PCMA")) {

But this makes Kamailio drop the INVITE when arriving at the line in the
config. I guess, "startswith" stops parsing the line at the colon.

So I thought I'll make it more generically:

sdp_get("$avp(sdp)");
if ($avp(sdp) =~ "a=rtpmap:([1-9][0-9][0-9]?) PCMA") {
    sdp_remove_codecs_by_id("$missingvariable");
}

What I need is to capture the number in the a=rtpmap line so I can delete
the codec by ID. But I couldn't find a way to capture the matches from my
regex comparison. Am I missing something?

(Other approaches for my problem would be welcome, too.)

Thanks in advance.
Best Regards,
Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20150619/1155b189/attachment.html>


More information about the sr-users mailing list