<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hi,<br><br></div>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.<br><br></div><div>This is how an SDP looks like:<br></div>v=0<br>o=hiQ9200 2990220150519102450 1229717573 IN IP4 1.2.3.4<br>s=Phone Call<br>c=IN IP4 1.2.3.4<br>t=0 0<br>m=audio 40174 RTP/AVP 8 0 18 96 97 13 100 98 99<br>a=rtpmap:8 PCMA/8000<br>a=fmtp:8 vad=no<br>a=rtpmap:0 PCMU/8000<br>a=fmtp:0 vad=no<br>a=rtpmap:18 G729/8000<br>a=fmtp:18 annexb=yes<br>a=rtpmap:96 G726-32/8000<br>a=rtpmap:97 AAL2-G726-32/8000<br>a=rtpmap:100 telephone-event/8000<br>a=fmtp:100 0-15<br>a=rtpmap:98 PCMA/8000<br>a=gpmd:98 vbd=yes<br>a=rtpmap:99 PCMU/8000<br>a=gpmd:99 vbd=yes<br>a=sqn: 0<br>a=cdsc: 1 image udptl t38<br>a=sendrecv<br>a=pmft: T38<br>a=ptime:20<br><br></div>I tried something like that (expecting that the number doesn't change):<br><br>if (sdp_get_line_startswith("$avp(badcodec)", "a=rtpmap:98 PCMA")) {<br><br></div>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.<br><br></div>So I thought I'll make it more generically:<br><br>sdp_get("$avp(sdp)");<br>if ($avp(sdp) =~ "a=rtpmap:([1-9][0-9][0-9]?) PCMA") {<br>    sdp_remove_codecs_by_id("$missingvariable");<br>}<br><br></div>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?<br><br></div><div>(Other approaches for my problem would be welcome, too.)<br></div><div><br></div>Thanks in advance.<br></div>Best Regards,<br></div>Sebastian<br></div>