Thursday, 18 September 2014

opensips.cfg file example with use_media_proxy and end_media_session.

By vm  |  03:49 No comments

opensips.cfg file with use_media_proxy() and end_media_session()  :
  1. # log levels:
  2. # 1 warn
  3. # 2 notice
  4. # 3 info
  5. # 4 debug (default)
  6.                                    # globals
  7. listen=udp:sip.example.com:5060
  8. fifo="/tmp/openser_fifo"
  9.  
  10.                                  # load modules
  11. loadmodule "/usr/lib/openser/modules/sl.so"
  12. loadmodule "/usr/lib/openser/modules/tm.so"
  13. loadmodule "/usr/lib/openser/modules/rr.so"
  14. loadmodule "/usr/lib/openser/modules/maxfwd.so"
  15. loadmodule "/usr/lib/openser/modules/usrloc.so"
  16. loadmodule "/usr/lib/openser/modules/registrar.so"
  17. loadmodule "/usr/lib/openser/modules/textops.so"
  18. loadmodule "/usr/lib/openser/modules/auth.so"
  19. loadmodule "/usr/lib/openser/modules/domain.so"
  20. loadmodule "/usr/lib/openser/modules/mediaproxy.so"
  21. loadmodule "/usr/lib/openser/modules/acc.so"
  22. loadmodule "/usr/lib/openser/modules/exec.so"
  23. loadmodule "/usr/lib/openser/modules/xlog.so"
  24.  
  25.  
  26.                                 # module params
  27. # rr
  28. # add value to ;lr param to make some broken UAs happy
  29. modparam("rr""enable_full_lr"1)
  30.  
  31. # mediaproxy
  32. #modparam("mediaproxy", "mediaproxy_socket", "/var/run/proxydispatcher.sock")
  33. #modparam("mediaproxy", "natping_interval", 60)
  34. modparam("registrar""nat_flag"2)
  35.  
  36.                            # request routing logic
  37. alias="example.com"
  38. alias="voip.example.com"
  39. route
  40. {
  41.     # sanity checks
  42.     if (!mf_process_maxfwd_header("10"))
  43.     {
  44.         sl_send_reply("483","Too Many Hops");
  45.         exit;
  46.     }
  47.     if (msg:len >= max_len)
  48.     {
  49.         sl_send_reply("513""Message too big");
  50.         exit;
  51.     }
  52.  
  53.     # apply loose (normal) routing rules
  54.     loose_route();
  55.  
  56.     # NAT test
  57.     if (client_nat_test("3") && !search("^Route:"))
  58.     {
  59.         setflag(2)# flag for NAT
  60.         force_rport();
  61.         fix_contact();
  62.         append_hf("P-hint: NAT\r\n");
  63.     }
  64.  
  65.     # outbound routing if not for me
  66.     lookup("aliases");
  67.     if (uri != myself)
  68.     {
  69.         route(1);
  70.         exit;
  71.     }
  72.  
  73.     # Registration
  74.     if (method == "REGISTER")
  75.     {
  76.         save("location")# simple no-auth registration
  77.         exit;
  78.     }
  79.  
  80.     if (method == "INVITE")
  81.     {
  82.         # enable Record-Route
  83.         record_route();
  84.  
  85.         # Is this to one of our numbers
  86.         if (lookup("location"))
  87.         {
  88.             append_hf("P-hint: userloc applied\r\n");
  89.         }
  90.         else
  91.         {
  92.             sl_send_reply("404","Not found");
  93.         }
  94.     }
  95.     route(1);
  96. }
  97.  
  98.  
  99. route[1]
  100. {
  101.     if (isflagset(2))
  102.     {
  103.         if (method == "INVITE")
  104.         {
  105.             t_on_reply("1");
  106.             t_on_failure("1");
  107.             use_media_proxy();
  108.         }
  109.         else if (method == "BYE" || method == "CANCEL")
  110.         {
  111.             end_media_session();
  112.         }
  113.     }
  114.  
  115.     # send it out now; use stateful forwarding as it works reliably
  116.     # even for UDP2TCP
  117.     if (!t_relay())
  118.     {
  119.         sl_reply_error();
  120.     }
  121.     exit;
  122. }
  123.  
  124. onreply_route[1]
  125. {
  126.     if (status =~ "(183)|(2[0-9][0-9])")
  127.     {
  128.         if (client_nat_test("1"))
  129.         {
  130.             fix_contact();
  131.         }
  132.         use_media_proxy();
  133.     }
  134. }
  135.  
  136. failure_route[1]
  137. {
  138.     end_media_session();
  139. }
  140.  
  141. # The perl filetype works pretty well for this
  142. # vim: filetype=perl







vm Author: vm

Hello, I am Author, decode to know more: In commodo magna nisl, ac porta turpis blandit quis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In commodo magna nisl, ac porta turpis blandit quis. Lorem ipsum dolor sit amet.

Related Posts

0 comments:

E-mail Newsletter

Sign up now to receive breaking news and to hear what's new with us.

Recent Articles

© 2014 VOIP4Learn. WP themonic converted by Bloggertheme9. Powered by Blogger.