Hello list,
Can anybody suggest the way to remove a line/attribute from SDP that matches some pattern (regexp), some kind of "grep -v" for SDP ? I'm trying to remove unnecessary ICE candidates from the SDP body and only thing I know is the IP address of the candidate I need to remove.
I was trying to use avp_subst() + set_body() or subst_body() but didn't get valid SDP.
kamailio-3.2.4.
Hi Vitaliy,
On 05/14/2014 06:51 AM, Vitaliy Aleksandrov wrote:
Hello list,
Can anybody suggest the way to remove a line/attribute from SDP that matches some pattern (regexp), some kind of "grep -v" for SDP ? I'm trying to remove unnecessary ICE candidates from the SDP body and only thing I know is the IP address of the candidate I need to remove.
I was trying to use avp_subst() + set_body() or subst_body() but didn't get valid SDP.
You might be able to pull it off using the various subst and other textops functions:
http://kamailio.org/docs/modules/4.1.x/modules/textops.html
http://kamailio.org/docs/modules/4.1.x/modules/textopsx.html#textopsx.f.remo...
But those may not be sophisticated enough to do the trick, in which case you might just need to pass this SDP body off to a third-party scripting language like Perl or Python. There, you can make the modifications you want, return a new SDP body to Kamailio, remove the old SDP body, and append your new one.
Cheers,
-- Alex
I can share my solution, using app_python. I'm using this in production environment during 2 years.
loadmodule "app_python.so" modparam("app_python", "script_name", "/opt/kamailio/python/sdp.py") modparam("app_python", "mod_init_function", "mod_init") modparam("app_python", "child_init_method", "child_init")
and put in route(): python_exec("ParseSDP", $mb);
Here I shared sdp.py: http://paste.debian.net/99473/
Note, that it is just for reference only, you need to know what to remove/replace. That script is not exactly what are you're looking for!
I absolutely forgot about the possibility of embedding scripting languages to configuration. Lua did the trick.
Thanks for the right direction and example.
I can share my solution, using app_python. I'm using this in production environment during 2 years.
loadmodule "app_python.so" modparam("app_python", "script_name", "/opt/kamailio/python/sdp.py") modparam("app_python", "mod_init_function", "mod_init") modparam("app_python", "child_init_method", "child_init")
and put in route(): python_exec("ParseSDP", $mb);
Here I shared sdp.py: http://paste.debian.net/99473/
Note, that it is just for reference only, you need to know what to remove/replace. That script is not exactly what are you're looking for!
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Can anybody suggest the way to remove a line/attribute from SDP that matches some pattern (regexp), some kind of "grep -v" for SDP ?
Another possibility might be to intentionally mangle an SDP offer so that it's unrecognizable.
Background: Asterisk is our VM and Media server. We had a case where we were using SRTP between handsets, but Asterisk would crash if a handset offered SRTP and Asterisk didn't have the SRTP module loaded. Our temporary workaround was to mangle the SDP offer so that Asterisk didn't see the offending SRTP offer.
This route replaces any "RTP/SAVP" with "RTP/GARBAGIO". Which Asterisk doesn't recognize, and therefore didn't invoke the bad behavior. We found this easier and lighter weight than trying to remove the line entirely, quite suitable for the temporary hack we needed.
route[INSECUREFWD] { if (method=="INVITE") { subst("/^m=audio(.+)RTP/SAVP/m=audio\1RTP/GARBAGIO/"); } route(FORWARD); }
-- Jorj