[OpenSIPS-Users] Opensips and rtpengine_play_media not absorbing ACK

Bogdan-Andrei Iancu bogdan at opensips.org
Mon Nov 13 09:40:53 UTC 2023


Hi there,

trying to maintain a dialog stateful UAS from script level may be 
something difficult and painful to do. Maybe you should take a look at 
the UAC/UAS support provided by the b2b_entities module in OpenSIPS 3.4:
https://blog.opensips.org/2023/03/22/api-driven-sip-user-agent-end-point-with-opensips-3-4/

Regards,

Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
   https://www.opensips-solutions.com
   https://www.siphub.com

On 11/11/23 3:26 AM, Kevin Kennedy wrote:
> I was able to send the BYE to the call by adding a parameter in the 
> dialog module to timeout the dialog with a short time letting the 
> announcement play, and added the create_dialog with the flag of B to 
> send BYE on dialog timeout at the beginning of the route.  Now that 
> the transactions are working correctly, I can use the same route for 
> the calls with SDP as well and tighten up the script.  Thanks for 
> helping out with some code examples, and letting me update on my 
> progress on this thread.  Hopefully this can help someone else out 
> having a similar problem when trying to use Opensips with RTPENGINE as 
> an announcement server.
>
> modparam("dialog", "default_timeout", 12)
>
> route["RTPENGINE"]{
>     if (has_body("application/sdp")) {
>         create_dialog("B");
>         rtpengine_offer();
>         $json(reply) := $rtpquery;
> $var(port)=$json_pretty(reply/tags/$ft/medias[0]/streams[0]/local port);
> $var(addr)=$json_pretty(reply/tags/$ft/medias[0]/streams[0]/local 
> address);
>         remove_body_part();
> append_to_reply("Contact:<sip:$rU@$socket_in(ip):$socket_in(port)>\r\n");
>         append_to_reply("Content-Type: application/sdp\r\n");
>         $var(body) = $(rb{re.subst,/(IP4.).*/\1$var(addr)/g});
>         $var(body) = $(var(body){re.subst,/(audio.)...../\1$var(port)/g});
>         t_reply_with_body(200, "OK", $var(body));
>         rtpengine_play_media("call-id=$ci from-tag=$ft 
> file=/etc/rtpengine/unk_num.wav");
>         exit;
>     } else {
>         create_dialog("B");
>         $var(newbody) = ("v=0\r\no=Opensips " + $Ts + " 0 IN IP4 " + 
> $socket_in(ip) + "\r\ns=-\r\nc=IN IP4 " + $socket_in(ip) + "\r\nt=0 
> 0\r\nm=audio " + $sp + " RTP/AVP 0 101\r\na=sendrecv\r\na=rtpmap:0 
> PCMU/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\n");
>         rtpengine_offer("from-tag=$ft replace-session-connection 
> trust-address replace-origin codec-strip-g729",,$var(body),$var(newbody));
>         $json(reply) := $rtpquery;
> $var(port)=$json_pretty(reply/tags/$ft/medias[0]/streams[0]/local port);
> $var(addr)=$json_pretty(reply/tags/$ft/medias[0]/streams[0]/local 
> address);
> append_to_reply("Contact:<sip:$rU@$socket_in(ip):$socket_in(port)\r\n");
>         append_to_reply("Content-Type: application/sdp\r\n");
>         $var(body) = $(var(body){re.subst,/(audio.)...../\1$var(port)/g});
>         t_reply_with_body(200, "OK", $var(body));
>         rtpengine_play_media("call-id=$ci from-tag=$ft 
> file=/etc/rtpengine/unk_num.wav");
>         exit;
>     }
>
> }
>
> Thank you.
>
> Kevin
>
> On Fri, Nov 10, 2023 at 4:54 PM Kevin Kennedy <kennedy4260 at gmail.com 
> <mailto:kennedy4260 at gmail.com>> wrote:
>
>     Looks like if I put t_newtran(); in the main route this created
>     the transaction and allowed the ACK to be recognized.  Now How do
>     I force Opensips to send a BYE.
>
>     Thank you.
>
>     On Fri, Nov 10, 2023 at 11:44 AM Kevin Kennedy
>     <kennedy4260 at gmail.com <mailto:kennedy4260 at gmail.com>> wrote:
>
>
>
>
>                                     I was able to get audio, The
>                                     problem I was having is the
>                                     Originator string in the SDP. 
>                                     However, I am still having the
>                                     same issue with accepting the ACK
>                                     from the Originator and not
>                                     resending the 200OK.  Can someone
>                                     please help with this issue?
>
>                                     Thank you
>
>                                     *Code snippet for the Late Media
>                                     route*
>                                     route["LateMedia3"]{
>                                         if (has_body("application/sdp")) {
>                                             xlog("######## Entered
>                                     route LateMedia3 with Fake SDP
>                                     from Originator ########\r\n");
>                                     rtpengine_offer();
>                                             $json(reply) := $rtpquery;
>                                     $var(port)=$json_pretty(reply/tags/$ft/medias[0]/streams[0]/local
>                                     port);
>                                     $var(addr)=$json_pretty(reply/tags/$ft/medias[0]/streams[0]/local
>                                     address);
>                                     remove_body_part();
>                                     append_to_reply("Contact:<sip:$rU@$socket_in(ip):$socket_in(port);user=phone>\r\n");
>                                     append_to_reply("Content-Type:
>                                     application/sdp\r\n");
>                                     $var(body) =
>                                     $(rb{re.subst,/(IP4.).*/\1$var(addr)/g});
>                                             $var(body) =
>                                     $(var(body){re.subst,/(audio.)...../\1$var(port)/g});
>                                     t_reply_with_body(200, "OK",
>                                     $var(body));
>                                     rtpengine_play_media("call-id=$ci
>                                     from-tag=$ft
>                                     file=/etc/rtpengine/unk_num.wav");
>                                             async(sleep(10), after_media);
>                                          } else {
>                                             xlog("######## Entered
>                                     route LateMedia3 No SDP received,
>                                     Create one from variable
>                                     ########\r\n");
>                                             $var(newbody) =
>                                     ("v=0\r\no=Opensips " + $Ts + " 0
>                                     IN IP4
>                                     10.255.100.147\r\ns=-\r\nc=IN IP4
>                                     10.255.100.147\r\nt=0 0\r\nm=audio
>                                     3140 RTP/AVP 0 101\r\na
>                                     =sendrecv\r\na=rtpmap:0
>                                     PCMU/8000\r\na=rtpmap:101
>                                     telephone-event/8000\r\na=fmtp:101
>                                     0-15\r\n");
>                                     xlog("#########################
>                                     Body to RTPENGINE is
>                                     ###########################\r\n$var(newbody)\r\n");
>                                     rtpengine_offer("from-tag=$ft
>                                     replace-session-connection
>                                     trust-address replace-origin
>                                     codec-strip-g729",,$var(body),$var(newbody));
>                                     xlog("#########################
>                                     Body from RTPENGINE is
>                                     ###########################\r\n$var(body)\r\n");
>                                             $json(reply) := $rtpquery;
>                                     $var(port)=$json_pretty(reply/tags/$ft/medias[0]/streams[0]/local
>                                     port);
>                                     $var(addr)=$json_pretty(reply/tags/$ft/medias[0]/streams[0]/local
>                                     address);
>                                     append_to_reply("Contact:<sip:$rU@$socket_in(ip):$socket_in(port);transport=udp>\r\n");
>                                     append_to_reply("Content-Type:
>                                     application/sdp\r\n");
>                                     $var(body) =
>                                     $(var(body){re.subst,/(IP4.).*/\1$var(addr)/g});
>                                             $var(body) =
>                                     $(var(body){re.subst,/(audio.)...../\1$var(port)/g});
>                                     xlog("#########################
>                                     Body being sent in Reply is
>                                     ######################\r\n$var(body)\r\n");
>                                     t_reply_with_body(200, "OK",
>                                     $var(body));
>                                     rtpengine_play_media("call-id=$ci
>                                     from-tag=$ft
>                                     file=/etc/rtpengine/unk_num.wav");
>                                     async(sleep(10), after_media);
>                                             }
>                                     }
>
>                                     route[after_media]
>                                         { if (t_was_cancelled()) {
>                                     rtpengine_delete();
>                                             exit;
>                                         } else {
>                                     rtpengine_delete();
>                                     sl_send_reply(486,"Busy here");
>                                             exit;
>                                         }
>                                     }
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20231113/c2691579/attachment-0001.html>


More information about the Users mailing list