Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- route[RTP_MANAGE] {
- if(!is_method("INVITE|UPDATE|BYE|CANCEL"))
- return;
- if (is_method("BYE|CANCEL")) {
- rtpengine_delete();
- xlog("Average MOS of the entire call is $rtpstat(MOS-average)\r\n");
- xlog("Average MOS of caller is $(rtpstat(MOS-average)[$ft])\r\n");
- xlog("Average MOS of callee is $(rtpstat(MOS-average)[$tt])\r\n");
- xlog("Min MOS of caller is $(rtpstat(MOS-min)[$ft]) reported at $(rtpstat(MOS-min-at)[$ft])\r\n");
- }
- if(cache_fetch("redis:wss-grp","wss-frompbx", $var(wss-frompbx))) {
- xlog("[$rm] fetched var ~> $avp(wss-frompbx)\n");
- cache_remove("redis:wss-grp","wss-frompbx");
- }
- if(cache_fetch("redis:wss-grp","tls-frompbx", $var(tls-frompbx))) {
- xlog("[$rm] fetched var ~> $var(tls-frompbx)\n");
- cache_remove("redis:wss-grp","tls-frompbx");
- }
- if(cache_fetch("redis:wss-grp","tcp-frompbx", $var(tcp-frompbx))) {
- xlog("[$rm] fetched var ~> $var(tcp-frompbx)\n");
- cache_remove("redis:wss-grp","tcp-frompbx");
- }
- if(is_method("INVITE|UPDATE|ACK") && has_body("application/sdp")) {
- if(isflagset("FLAG_FROM_FS")) {
- if($var(wss-frompbx)) {
- $var(usr_check) = "wss_" + $tU;
- }
- if($var(tls-frompbx)) {
- $var(usr_check_tls) = "tls_" + $(tU{s.select,0,%});
- xlog("[$rm] User check ~> [$var(usr_check_tls)]\n");
- }
- if($var(tcp-frompbx)) {
- $var(usr_check_tcp) = "tcp_" + $(tU{s.select,0,%});
- xlog("[$rm] User check ~> [$var(usr_check_tcp)]\n");
- }
- $var(dir) = "in-iface=internal out-iface=external";
- $var(codec_flag_frompbx) = "codec-strip-G722 codec-strip-CN codec-strip-G726 codec-strip-PCMA transcode-opus";
- $var(wss_codec_trans) = "transcode-VP8 transcode-H264";
- $var(trns) = "UDP/TLS/RTP/SAVPF SDES-no";
- $var(transport) = "";
- if($var(tls-frompbx)==$var(usr_check_tls)) {
- $var(transport) = "tls";
- if(!codec_exists("opus")) {
- $var(codec_flag_frompbx_tls) = "transcode-opus";
- }
- rtpengine_offer("replace-origin replace-session-connection $var(codec_flag_frompbx_tls) RTP/SAVP ICE=remove $var(dir)");
- } else if($var(wss-frompbx)==$var(usr_check)) {
- $var(transport) = "wss";
- rtpengine_offer(" $var(wss_codec_trans) $var(codec_flag_frompbx) replace-session-connection replace-origin $var(trns) $var(dir)");
- } else if($var(tcp-frompbx)==$var(usr_check_tcp)) {
- $var(transport) = "tcp";
- rtpengine_offer("replace-origin replace-session-connection RTP/AVP ICE=remove $var(dir)");
- } else if(isflagset("FLAG_MOBILE_USER")) {
- $var(transport) = "tls MobileFlag";
- rtpengine_offer("RTP/SAVP replace-session-connection replace-origin $var(codec_flag_frompbx) ICE=remove $var(dir)");
- }
- xlog("[$rm] Call going from LAN SouceIP <$si> to WAN with transport set ~> [$var(transport)]\n");
- t_on_reply("2");
- } else {
- if(!codec_exists("pcmu")) {
- $var(codec_flag_topbx) = "transcode-PCMU";
- }
- $var(dir) = "in-iface=external out-iface=internal";
- if(search_body("RTP/SAVP")) {
- cache_store("redis:wss-grp","rtp_trns", "secure_$fU", 100);
- } else {
- cache_store("redis:wss-grp","rtp_trns", "plain_$fU", 100);
- }
- # Determine mobile user codec
- if(isflagset("FLAG_MOBILE_USER")) {
- xlog("[$rm] Call going from WAN SouceIP <$si> to LAN ~> MobileFlagSet\n");
- rtpengine_offer("replace-origin external internal RTP/AVP $var(codec_flag_topbx) ICE=remove $var(dir)");
- } else {
- xlog("[$rm] Call going from WAN SouceIP <$si> to LAN\n");
- rtpengine_offer("replace-origin external internal RTP/AVP ICE=remove $var(dir)");
- }
- t_on_reply("3");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement