Advertisement
Guest User

Untitled

a guest
Apr 26th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. route[RTP_MANAGE] {
  2. if(!is_method("INVITE|UPDATE|BYE|CANCEL"))
  3. return;
  4.  
  5. if (is_method("BYE|CANCEL")) {
  6. rtpengine_delete();
  7. xlog("Average MOS of the entire call is $rtpstat(MOS-average)\r\n");
  8. xlog("Average MOS of caller is $(rtpstat(MOS-average)[$ft])\r\n");
  9. xlog("Average MOS of callee is $(rtpstat(MOS-average)[$tt])\r\n");
  10. xlog("Min MOS of caller is $(rtpstat(MOS-min)[$ft]) reported at $(rtpstat(MOS-min-at)[$ft])\r\n");
  11. }
  12. if(cache_fetch("redis:wss-grp","wss-frompbx", $var(wss-frompbx))) {
  13. xlog("[$rm] fetched var ~> $avp(wss-frompbx)\n");
  14. cache_remove("redis:wss-grp","wss-frompbx");
  15. }
  16.  
  17. if(cache_fetch("redis:wss-grp","tls-frompbx", $var(tls-frompbx))) {
  18. xlog("[$rm] fetched var ~> $var(tls-frompbx)\n");
  19. cache_remove("redis:wss-grp","tls-frompbx");
  20. }
  21.  
  22. if(cache_fetch("redis:wss-grp","tcp-frompbx", $var(tcp-frompbx))) {
  23. xlog("[$rm] fetched var ~> $var(tcp-frompbx)\n");
  24. cache_remove("redis:wss-grp","tcp-frompbx");
  25. }
  26.  
  27. if(is_method("INVITE|UPDATE|ACK") && has_body("application/sdp")) {
  28. if(isflagset("FLAG_FROM_FS")) {
  29. if($var(wss-frompbx)) {
  30. $var(usr_check) = "wss_" + $tU;
  31. }
  32. if($var(tls-frompbx)) {
  33. $var(usr_check_tls) = "tls_" + $(tU{s.select,0,%});
  34. xlog("[$rm] User check ~> [$var(usr_check_tls)]\n");
  35. }
  36. if($var(tcp-frompbx)) {
  37. $var(usr_check_tcp) = "tcp_" + $(tU{s.select,0,%});
  38. xlog("[$rm] User check ~> [$var(usr_check_tcp)]\n");
  39. }
  40. $var(dir) = "in-iface=internal out-iface=external";
  41. $var(codec_flag_frompbx) = "codec-strip-G722 codec-strip-CN codec-strip-G726 codec-strip-PCMA transcode-opus";
  42. $var(wss_codec_trans) = "transcode-VP8 transcode-H264";
  43. $var(trns) = "UDP/TLS/RTP/SAVPF SDES-no";
  44. $var(transport) = "";
  45. if($var(tls-frompbx)==$var(usr_check_tls)) {
  46. $var(transport) = "tls";
  47. if(!codec_exists("opus")) {
  48. $var(codec_flag_frompbx_tls) = "transcode-opus";
  49. }
  50. rtpengine_offer("replace-origin replace-session-connection $var(codec_flag_frompbx_tls) RTP/SAVP ICE=remove $var(dir)");
  51. } else if($var(wss-frompbx)==$var(usr_check)) {
  52. $var(transport) = "wss";
  53. rtpengine_offer(" $var(wss_codec_trans) $var(codec_flag_frompbx) replace-session-connection replace-origin $var(trns) $var(dir)");
  54. } else if($var(tcp-frompbx)==$var(usr_check_tcp)) {
  55. $var(transport) = "tcp";
  56. rtpengine_offer("replace-origin replace-session-connection RTP/AVP ICE=remove $var(dir)");
  57. } else if(isflagset("FLAG_MOBILE_USER")) {
  58. $var(transport) = "tls MobileFlag";
  59. rtpengine_offer("RTP/SAVP replace-session-connection replace-origin $var(codec_flag_frompbx) ICE=remove $var(dir)");
  60. }
  61. xlog("[$rm] Call going from LAN SouceIP <$si> to WAN with transport set ~> [$var(transport)]\n");
  62. t_on_reply("2");
  63. } else {
  64. if(!codec_exists("pcmu")) {
  65. $var(codec_flag_topbx) = "transcode-PCMU";
  66. }
  67. $var(dir) = "in-iface=external out-iface=internal";
  68. if(search_body("RTP/SAVP")) {
  69. cache_store("redis:wss-grp","rtp_trns", "secure_$fU", 100);
  70. } else {
  71. cache_store("redis:wss-grp","rtp_trns", "plain_$fU", 100);
  72. }
  73. # Determine mobile user codec
  74. if(isflagset("FLAG_MOBILE_USER")) {
  75. xlog("[$rm] Call going from WAN SouceIP <$si> to LAN ~> MobileFlagSet\n");
  76. rtpengine_offer("replace-origin external internal RTP/AVP $var(codec_flag_topbx) ICE=remove $var(dir)");
  77. } else {
  78. xlog("[$rm] Call going from WAN SouceIP <$si> to LAN\n");
  79. rtpengine_offer("replace-origin external internal RTP/AVP ICE=remove $var(dir)");
  80. }
  81. t_on_reply("3");
  82. }
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement