[Spce-user] using replace_body_all to replace media attriubutes in SDP

Andrew Pogrebennyk apogrebennyk at sipwise.com
Thu Nov 17 06:11:01 EST 2016

Hi Matthew,
what happens is that kamailio memorizes the changes as the "lumps" and
should flush/apply them before sending the message out. But proxy passes
the message body to rtpengine and replaces it with rtpengine answer so
the changes are lost or may result in broken SDP if lump overwrites it.

So if you are doing the replacement in proxy.cfg you should remember to
call msg_apply_changes() after your changes and before the
rtpengine_offer call, but you should be aware that msg_apply_changes()
is very sensible to placement, e.g. it must be executed before
transaction is created and before record_route().

I'd say that you can do replace_body_all(..) and msg_apply_changes() in
ROUTE_OUTBOUND before record_route() but I would rather suggest moving
it to the lb/kamailio.cfg where there is no such problem.

Hope this helps,

On 15/11/16 23:00, Matthew Ogden wrote:
> Hi
> I'm trying to remove some excess baggage on invites and reINVITEs.
> As per :
> https://lists.sipwise.com/pipermail/spce-user/2012-November/002516.html
> We run strictly only a set ptime, but I have some boxes adding
> maxptime:150 that are out of my control.
> I've tried adding  replace_body_all("a=maxptime:150\r?\n", ""); or just
> even 
> replace_body_all("a=maxptime:150", "");
> in ROUTE_OUTBOUND and branch_route[BRANCH_ROUTE_SBC]
> I am also logging the section for example:
>           if(has_body("application/sdp"))
>                {
>                        #remove long unneeded infrom from SDP
>                        xlog("L_INFO", "Removing info of maxptime from
> SDP - [% logreq -%]\n");
>                        replace_body_all("a=maxptime:150\r\n", "");
>               }
> It shows in the log, but the ptime still pushes through on the main INVITE.
> Most critically this should work on loose routing (indialog reinvites),
> but I cant even get it to work on normal routing!
> Any ideas what I'm doing wrong?
> Kind Regards

More information about the Spce-user mailing list