Current Path : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/bitrix/js/im/call/ |
Current File : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/bitrix/js/im/call/util.min.js |
(function(){BX.namespace("BX.Call");if(BX.Call.Util){return}var e="/bitrix/js/im/images/blank.gif";BX.Call.Util={userData:{},usersInProcess:{},updateUserData:function(e){var r=[];var t=this;for(var a=0;a<e.length;a++){if(this.userData.hasOwnProperty(e[a])){continue}r.push(e[a])}var n=new Promise(function(e,a){if(r.length===0){return e()}BX.CallEngine.getRestClient().callMethod("im.user.list.get",{ID:r,AVATAR_HR:"Y"}).then(function(r){var a=r.answer.result;if(BX.type.isPlainObject(a)){for(var n in a){t.userData[n]=a[n];delete t.usersInProcess[n]}}e()}).catch(function(e){a(e.answer)})});for(var a=0;a<r.length;a++){this.usersInProcess[r[a]]=n}return n},getDateForLog:function(){var e=new Date;return e.getFullYear()+"-"+this.lpad(e.getMonth(),2,"0")+"-"+this.lpad(e.getDate(),2,"0")+" "+this.lpad(e.getHours(),2,"0")+":"+this.lpad(e.getMinutes(),2,"0")+":"+this.lpad(e.getSeconds(),2,"0")+"."+e.getMilliseconds()},getTimeForLog:function(){var e=new Date;return this.lpad(e.getHours(),2,"0")+":"+this.lpad(e.getMinutes(),2,"0")+":"+this.lpad(e.getSeconds(),2,"0")+"."+e.getMilliseconds()},lpad:function(e,r,t){e=e.toString();t=t||" ";if(e.length>r){return e}var a="";for(var n=0;n<r-e.length;n++){a+=t}return a+e},getUser:function(e){var r=this;return new Promise(function(t,a){if(r.userData.hasOwnProperty(e)){return t(r.userData[e])}else if(r.usersInProcess.hasOwnProperty(e)){r.usersInProcess[e].then(function(){return t(r.userData[e])})}else{r.updateUserData([e]).then(function(){return t(r.userData[e])})}})},getUserName:function(e){var r=this;return new Promise(function(t,a){if(r.userData.hasOwnProperty(e)){return t(r.userData[e].name?r.userData[e].name:"")}else if(r.usersInProcess.hasOwnProperty(e)){r.usersInProcess[e].then(function(){return t(r.userData[e].name?r.userData[e].name:"")})}else{r.updateUserData([e]).then(function(){return t(r.userData[e].name?r.userData[e].name:"")})}})},getUserAvatar:function(e){var r=this;return new Promise(function(a,n){if(r.userData.hasOwnProperty(e)){return a(r.userData[e].avatar_hr&&!t(r.userData[e].avatar_hr)?r.userData[e].avatar_hr:"")}else if(r.usersInProcess.hasOwnProperty(e)){r.usersInProcess[e].then(function(){return a(r.userData[e].avatar_hr&&!t(r.userData[e].avatar_hr)?r.userData[e].avatar_hr:"")})}else{r.updateUserData([e]).then(function(){return a(r.userData[e].avatar_hr&&!t(r.userData[e].avatar_hr)?r.userData[e].avatar_hr:"")})}})},getUserAvatars:function(e){var r=this;return new Promise(function(a,n){r.updateUserData(e).then(function(){var n={};e.forEach(function(e){n[e]=r.userData[e].avatar_hr&&!t(r.userData[e].avatar_hr)?r.userData[e].avatar_hr:""});return a(n)})})},getCustomMessage:function(e,r){var t;if(!BX.type.isPlainObject(r)){r={}}if(r.gender&&BX.message.hasOwnProperty(e+"_"+r.gender)){t=BX.message(e+"_"+r.gender)}else{t=BX.message(e)}r=this.convertKeysToUpper(r);return t.replace(/#.+?#/gm,function(e){var t=e.substr(1,e.length-2);return r.hasOwnProperty(t)?r[t]:e})},convertKeysToUpper:function(e){var r=BX.util.objectClone(e);for(var t in r){var a=t.toUpperCase();if(a!=t){r[a]=r[t];delete r[t]}}return r},appendChildren:function(e,r){r.forEach(function(r){e.appendChild(r)})},containsVideoTrack:function(e){if(!(e instanceof MediaStream))return false;return e.getVideoTracks().length>0},findBestElementSize:function(e,r,t){var a=0;for(var n=1;n<=t;n++){var s=this.getFilledArea(e,r,t,n);if(s.area>a){a=s.area;var i=s.elementWidth;var u=s.elementHeight}if(s.area<a){break}}return{width:i,height:u}},getFilledArea:function(e,r,t,a){var n=Math.ceil(t/a);var s=e/n;var i=r/a;var u=i/s;var o=9/16;var l;var c;if(u<o){l=i;c=s*(u/o)}else{c=s;l=i*(o/u)}var h=c*l*t;return{area:h,elementWidth:c,elementHeight:l}},isWebRTCSupported:function(){return typeof webkitRTCPeerConnection!="undefined"||typeof mozRTCPeerConnection!="undefined"||typeof RTCPeerConnection!="undefined"},isCallServerAllowed:function(){return BX.message("call_server_enabled")==="Y"},getUserLimit:function(){if(this.isCallServerAllowed()){return parseInt(BX.message("call_server_max_users"))}return parseInt(BX.message("turn_server_max_users"))},getMaxBitrate:function(e){switch(e){case BX.Call.Quality.VeryHigh:return 0;case BX.Call.Quality.High:return 1e3;case BX.Call.Quality.Medium:return 500;case BX.Call.Quality.Low:return 250;case BX.Call.Quality.VeryLow:return 100}},getMaxResolution:function(e,r){switch(e){case BX.Call.Quality.VeryHigh:return r?{width:1280,height:720}:{width:640,height:360};case BX.Call.Quality.High:return{width:640,height:360};case BX.Call.Quality.Medium:return{width:320,height:180};case BX.Call.Quality.Low:return{width:160,height:90};case BX.Call.Quality.VeryLow:return{width:160,height:90}}},alterSDP:function(e,t){if(!t){return}var a=e.split("\n");var n=[];var s=false;for(var i=0;i<a.length;i++){var u=a[i];s=s||(u.match(/m=video/)!==null?i:false);if(!s){continue}var o=/a=rtpmap:(\d+)\s(.+)/.exec(u);if(o){n.push({rtpmap:o[1],codec:o[2]})}}if(!s){return}a[s]=r(a[s],n,t);return a.join("\n")}};function r(e,r,t){debugger;var a=e.split(" ");var n=a.slice(3);var s={};r.forEach(function(e){s[e.rtpmap]=e.codec});n.sort(function(e,r){e=e.trim();r=r.trim();var t=s[e];var a=s[r];if(t.substr(0,4)==="H264"&&a.substr(0,4)!=="H264"){return-1}else if(t.substr(0,4)!=="H264"&&a.substr(0,4)==="H264"){return 1}else{return e-r}});var i=a.slice(0,3).concat(n);return i.join(" ")}function t(r){return typeof r!=="string"||r==""||r.endsWith(e)}})(); //# sourceMappingURL=util.map.js