<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,</p>
<p>use msg_apply_changes just after replace_body_str(), eventually
before loose routing processing for requests within dialog.</p>
<p>Cheers,<br>
Daniel<br>
</p>
<div class="moz-cite-prefix">On 01.06.20 13:34, George
Diamantopoulos wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAPcKEYOboM36Q7o+nJrSGW6nzxsk+AAtf2s-FRWtyKEDNNXy7A@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hello all,</div>
<div><br>
</div>
<div>I'm facing one of those cases where I need to edit the body
of a SIP message, which is then to be fed to rtpengine for
processing. Although I've taken every precaution I've read
about on this list and elsewhere, I can't prevent the edited
line from appearing twice in the outgoing message.</div>
<div><br>
</div>
<div>The configuration file used is huge, so I'm going to try to
provide a high-level overview here. But first, the things (I
think) I know to be requirements, and which I have striven to
meet:</div>
<div>
<ul>
<li>If SDP is to be edited, then all such processing is to
be carried out in such a way in the script, so that
msg_apply_changes() is run as many times as needed before
rtpengine offer/answer/manage is called.</li>
<li>rtpengine offer/answer/manage is to be called only once
per script iteration</li>
<li>msg_apply_changes can only be called in a request route,
or in the core reply_route (i.e. <b>not</b> in tm-managed
on_reply_route[XXX] blocks)</li>
</ul>
<div>In my case, additionally the following are true:</div>
<div>
<ul>
<li>SDP processing (other than the one performed by
rtpengine) takes place in one common route for all cases
where it needs to happen. These are two at the moment in
my scenario:<br>
</li>
<ul>
<li>Early in the WITHINDLG route (of the example config
file)</li>
<li>After the sanity checks in the reply_route (of the
example config file)</li>
</ul>
<li>msg_apply changes() is called once, for each script
iteration:</li>
<ul>
<li>right before rtpengine_manage() is called, provided
that t_is_request_route() returns true (so that I
don't accidentally call it from a branch route or
anything)</li>
<ul>
<li>rtpengine_manage() is called in its own route,
which is very similar to the example config file's
"NATMANAGE" route. Since NATMANAGE is called in all
branch and on_reply_routes, I employ
t_is_request_route() here to make sure it won't
execute in those cases.</li>
</ul>
<li>at the end of the "core" reply_route</li>
</ul>
</ul>
<div>Now regarding the actual config-file-controlled SDP
manipulation, it only consists of a single call to
replace_body_str(). The purpose is to edit a line in the
message body from something like:</div>
<div>
<ul>
<li>a=fmtp:101 0-16</li>
</ul>
</div>
<div>to something along the lines of:</div>
<div>
<ul>
<li>a=fmtp:101 0-15</li>
</ul>
<div>For replies, this works as expected.</div>
<div><br>
</div>
<div>For in-dialog requests, however, I end up with both
the original and the edited lines:</div>
<div style="margin-left:40px"><span
style="font-family:monospace">a=fmtp:101 0-16 (the
original line)<br>
</span></div>
<div style="margin-left:40px"><span
style="font-family:monospace">... other SDP stuff ...<br>
</span></div>
<div style="margin-left:40px"><span
style="font-family:monospace">a=fmtp:101 0-15 (the
edited line)</span></div>
<br>
</div>
<div>If anyone could point out any misconceptions I have
about msg_apply_changes, SDP rewriting from the script and
rtp_engine_X() interoperability, I would be more than
grateful.</div>
<div><br>
</div>
<div>Thank you in advance and I apologize for the long read.</div>
<div><br>
</div>
<div>Best regards,</div>
<div>George Diamantopoulos<br>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
</body>
</html>