File manager - Edit - /home/web/vm-3fadc827.na4u.ru/www/bitrix/modules/im/install/js/im/call/vendor/janus.min.js
Back
Janus.sessions={};Janus.extensionId="hapfgfdkleiggjjpfpenajgdnfckjpaj";Janus.isExtensionEnabled=function(){if(window.navigator.userAgent.match("Chrome")){var e=parseInt(window.navigator.userAgent.match(/Chrome\/(.*) /)[1],10);var n=33;if(window.navigator.userAgent.match("Linux"))n=35;if(e>=26&&e<=n){return true}return Janus.checkJanusExtension()}else{return true}};Janus.useDefaultDependencies=function(e){var n=e&&e.fetch||fetch;var r=e&&e.Promise||Promise;var a=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,n){return new a(e,n)},isArray:function(e){return Array.isArray(e)},checkJanusExtension:function(){return document.querySelector("#janus-extension-installed")!==null},webRTCAdapter:e&&e.adapter||adapter,httpAPICall:function(e,a){var t={method:a.verb,cache:"no-cache"};var s;if(a.withCredentials!==undefined){t.credentials=a.withCredentials===true?"include":a.withCredentials?a.withCredentials:"omit"}if(a.body!==undefined){t.body=JSON.stringify(a.body)}var i=n(e,t).catch(function(e){return r.reject({message:"Probably a network error, is the gateway down?",error:e})});if(a.timeout!==undefined){var o=new r(function(e,n){s=setTimeout(function(){clearTimeout(s);return n({message:"Request timed out",timeout:a.timeout})},a.timeout)});i=r.race([i,o])}i.then(function(e){if(e.ok){if(typeof a.success===typeof Janus.noop){return e.json().then(function(e){a.success(e);clearTimeout(s)}).catch(function(n){console.error(n,e);return r.reject({message:"Failed to parse response body",error:n,response:e})})}}else{return r.reject({message:"API call failed",response:e})}}).catch(function(e){if(typeof a.error===typeof Janus.noop){a.error(e.message||"<< internal error >>",e)}});return i}}};Janus.useOldDependencies=function(e){var n=e&&e.jQuery||jQuery;var r=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,n){return new r(e,n)},isArray:function(e){return n.isArray(e)},checkJanusExtension:function(){return n("#janus-extension-installed").length>0},webRTCAdapter:e&&e.adapter||adapter,httpAPICall:function(e,r){var a=r.body!==undefined?{contentType:"application/json",data:JSON.stringify(r.body)}:{};var t=r.withCredentials!==undefined?{xhrFields:{withCredentials:r.withCredentials}}:{};return n.ajax(n.extend(a,t,{url:e,type:r.verb,cache:false,dataType:"json",async:r.async,timeout:r.timeout,success:function(e){if(typeof r.success===typeof Janus.noop){try{r.success(e)}catch(e){console.error(e)}}},error:function(e,n,a){if(typeof r.error===typeof Janus.noop){try{r.error(n,a)}catch(e){console.error(e)}}}}))}}};Janus.noop=function(){};Janus.init=function(e){e=e||{};e.callback=typeof e.callback=="function"?e.callback:Janus.noop;if(Janus.initDone===true){e.callback()}else{if(typeof console=="undefined"||typeof console.log=="undefined")console={log:function(){}};Janus.trace=Janus.noop;Janus.debug=Janus.noop;Janus.vdebug=Janus.noop;Janus.log=Janus.noop;Janus.warn=Janus.noop;Janus.error=Janus.noop;if(e.debug===true||e.debug==="all"){Janus.trace=console.trace.bind(console);Janus.debug=console.debug.bind(console);Janus.vdebug=console.debug.bind(console);Janus.log=console.log.bind(console);Janus.warn=console.warn.bind(console);Janus.error=console.error.bind(console)}else if(Array.isArray(e.debug)){for(var n in e.debug){var r=e.debug[n];switch(r){case"trace":Janus.trace=console.trace.bind(console);break;case"debug":Janus.debug=console.debug.bind(console);break;case"vdebug":Janus.vdebug=console.debug.bind(console);break;case"log":Janus.log=console.log.bind(console);break;case"warn":Janus.warn=console.warn.bind(console);break;case"error":Janus.error=console.error.bind(console);break;default:console.error("Unknown debugging option '"+r+"' (supported: 'trace', 'debug', 'vdebug', 'log', warn', 'error')");break}}}Janus.log("Initializing library");var a=e.dependencies||Janus.useDefaultDependencies();Janus.isArray=a.isArray;Janus.webRTCAdapter=a.webRTCAdapter;Janus.httpAPICall=a.httpAPICall;Janus.checkJanusExtension=a.checkJanusExtension;Janus.newWebSocket=a.newWebSocket;Janus.listDevices=function(e,n){e=typeof e=="function"?e:Janus.noop;if(n==null)n={audio:true,video:true};if(navigator.mediaDevices){navigator.mediaDevices.getUserMedia(n).then(function(n){navigator.mediaDevices.enumerateDevices().then(function(r){Janus.debug(r);e(r);try{var a=n.getTracks();for(var t in a){var s=a[t];if(s!==null&&s!==undefined)s.stop()}}catch(e){}})}).catch(function(n){Janus.error(n);e([])})}else{Janus.warn("navigator.mediaDevices unavailable");e([])}};Janus.attachMediaStream=function(e,n){if(Janus.webRTCAdapter.browserDetails.browser==="chrome"){var r=Janus.webRTCAdapter.browserDetails.version;if(r>=43){e.srcObject=n}else if(typeof e.src!=="undefined"){e.src=URL.createObjectURL(n)}else{Janus.error("Error attaching stream to element")}}else{e.srcObject=n}};Janus.reattachMediaStream=function(e,n){if(Janus.webRTCAdapter.browserDetails.browser==="chrome"){var r=Janus.webRTCAdapter.browserDetails.version;if(r>=43){e.srcObject=n.srcObject}else if(typeof e.src!=="undefined"){e.src=n.src}else{Janus.error("Error reattaching stream to element")}}else{e.srcObject=n.srcObject}};var t=window.onbeforeunload;window.onbeforeunload=function(){Janus.log("Closing window");for(var e in Janus.sessions){if(Janus.sessions[e]!==null&&Janus.sessions[e]!==undefined&&Janus.sessions[e].destroyOnUnload){Janus.log("Destroying session "+e);Janus.sessions[e].destroy({asyncRequest:false})}}if(t&&typeof t=="function")t()};Janus.initDone=true;e.callback()}};Janus.isWebrtcSupported=function(){return window.RTCPeerConnection!==undefined&&window.RTCPeerConnection!==null&&navigator.getUserMedia!==undefined&&navigator.getUserMedia!==null};Janus.randomString=function(e){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var r="";for(var a=0;a<e;a++){var t=Math.floor(Math.random()*n.length);r+=n.substring(t,t+1)}return r};function Janus(e){if(Janus.initDone===undefined){e.error("Library not initialized");return{}}if(!Janus.isWebrtcSupported()){e.error("WebRTC not supported by this browser");return{}}Janus.log("Library initialized: "+Janus.initDone);e=e||{};e.success=typeof e.success=="function"?e.success:Janus.noop;e.error=typeof e.error=="function"?e.error:Janus.noop;e.destroyed=typeof e.destroyed=="function"?e.destroyed:Janus.noop;if(e.server===null||e.server===undefined){e.error("Invalid gateway url");return{}}var n=false;var r=null;var a={};var t=null;var s=null,i=0;var o=e.server;if(Janus.isArray(o)){Janus.log("Multiple servers provided ("+o.length+"), will use the first that works");o=null;s=e.server;Janus.debug(s)}else{if(o.indexOf("ws")===0){n=true;Janus.log("Using WebSockets to contact Janus: "+o)}else{n=false;Janus.log("Using REST API to contact Janus: "+o)}}var u=e.iceServers;if(u===undefined||u===null)u=[{urls:"stun:stun.l.google.com:19302"}];var d=e.iceTransportPolicy;var l=e.bundlePolicy;var c=e.ipv6;if(c===undefined||c===null)c=false;var f=false;if(e.withCredentials!==undefined&&e.withCredentials!==null)f=e.withCredentials===true;var g=null;if(e.max_poll_events!==undefined&&e.max_poll_events!==null)g=e.max_poll_events;if(g<1)g=1;var m=null;if(e.token!==undefined&&e.token!==null)m=e.token;var v=null;if(e.apisecret!==undefined&&e.apisecret!==null)v=e.apisecret;this.destroyOnUnload=true;if(e.destroyOnUnload!==undefined&&e.destroyOnUnload!==null)this.destroyOnUnload=e.destroyOnUnload===true;var p=false;var b=null;var J={};var w=this;var h=0;var y={};A(e);this.getServer=function(){return o};this.isConnected=function(){return p};this.getSessionId=function(){return b};this.destroy=function(e){C(e)};this.attach=function(e){D(e)};function S(){if(b==null)return;Janus.debug("Long poll...");if(!p){Janus.warn("Is the gateway down? (connected=false)");return}var n=o+"/"+b+"?rid="+(new Date).getTime();if(g!==undefined&&g!==null)n=n+"&maxev="+g;if(m!==null&&m!==undefined)n=n+"&token="+m;if(v!==null&&v!==undefined)n=n+"&apisecret="+v;Janus.httpAPICall(n,{verb:"GET",withCredentials:f,success:k,timeout:6e4,error:function(n,r){Janus.error(n+": "+r);h++;if(h>3){p=false;e.error("Lost connection to the gateway (is it down?)");return}S()}})}function k(e,r){h=0;if(!n&&b!==undefined&&b!==null&&r!==true)setTimeout(S,200);if(!n&&Janus.isArray(e)){for(var a=0;a<e.length;a++){k(e[a],true)}return}if(e["janus"]==="keepalive"){Janus.vdebug("Got a keepalive on session "+b);return}else if(e["janus"]==="ack"){Janus.debug("Got an ack on session "+b);Janus.debug(e);var t=e["transaction"];if(t!==null&&t!==undefined){var s=y[t];if(s!==null&&s!==undefined){s(e)}delete y[t]}return}else if(e["janus"]==="success"){Janus.debug("Got a success on session "+b);Janus.debug(e);var t=e["transaction"];if(t!==null&&t!==undefined){var s=y[t];if(s!==null&&s!==undefined){s(e)}delete y[t]}return}else if(e["janus"]==="webrtcup"){Janus.debug("Got a webrtcup event on session "+b);Janus.debug(e);var i=e["sender"];if(i===undefined||i===null){Janus.warn("Missing sender...");return}var o=J[i];if(o===undefined||o===null){Janus.debug("This handle is not attached to this session");return}o.webrtcState(true);return}else if(e["janus"]==="hangup"){Janus.debug("Got a hangup event on session "+b);Janus.debug(e);var i=e["sender"];if(i===undefined||i===null){Janus.warn("Missing sender...");return}var o=J[i];if(o===undefined||o===null){Janus.debug("This handle is not attached to this session");return}o.webrtcState(false,e["reason"]);o.hangup()}else if(e["janus"]==="detached"){Janus.debug("Got a detached event on session "+b);Janus.debug(e);var i=e["sender"];if(i===undefined||i===null){Janus.warn("Missing sender...");return}var o=J[i];if(o===undefined||o===null){return}o.detached=true;o.ondetached();o.detach()}else if(e["janus"]==="media"){Janus.debug("Got a media event on session "+b);Janus.debug(e);var i=e["sender"];if(i===undefined||i===null){Janus.warn("Missing sender...");return}var o=J[i];if(o===undefined||o===null){Janus.debug("This handle is not attached to this session");return}o.mediaState(e["type"],e["receiving"])}else if(e["janus"]==="slowlink"){Janus.debug("Got a slowlink event on session "+b);Janus.debug(e);var i=e["sender"];if(i===undefined||i===null){Janus.warn("Missing sender...");return}var o=J[i];if(o===undefined||o===null){Janus.debug("This handle is not attached to this session");return}o.slowLink(e["uplink"],e["nacks"])}else if(e["janus"]==="error"){Janus.error("Ooops: "+e["error"].code+" "+e["error"].reason);Janus.debug(e);var t=e["transaction"];if(t!==null&&t!==undefined){var s=y[t];if(s!==null&&s!==undefined){s(e)}delete y[t]}return}else if(e["janus"]==="event"){Janus.debug("Got a plugin event on session "+b);Janus.debug(e);var i=e["sender"];if(i===undefined||i===null){Janus.warn("Missing sender...");return}var u=e["plugindata"];if(u===undefined||u===null){Janus.warn("Missing plugindata...");return}Janus.debug(" -- Event is coming from "+i+" ("+u["plugin"]+")");var d=u["data"];Janus.debug(d);var o=J[i];if(o===undefined||o===null){Janus.warn("This handle is not attached to this session");return}var l=e["jsep"];if(l!==undefined&&l!==null){Janus.debug("Handling SDP as well...");Janus.debug(l)}var c=o.onmessage;if(c!==null&&c!==undefined){Janus.debug("Notifying application...");c(d,l)}else{Janus.debug("No provided notification callback")}}else{Janus.warn("Unknown message/event '"+e["janus"]+"' on session "+b);Janus.debug(e)}}function T(){if(o===null||!n||!p)return;t=setTimeout(T,3e4);var e={janus:"keepalive",session_id:b,transaction:Janus.randomString(12)};if(m!==null&&m!==undefined)e["token"]=m;if(v!==null&&v!==undefined)e["apisecret"]=v;r.send(JSON.stringify(e))}function A(u){var d=Janus.randomString(12);var l={janus:"create",transaction:d};if(m!==null&&m!==undefined)l["token"]=m;if(v!==null&&v!==undefined)l["apisecret"]=v;if(o===null&&Janus.isArray(s)){o=s[i];if(o.indexOf("ws")===0){n=true;Janus.log("Server #"+(i+1)+": trying WebSockets to contact Janus ("+o+")")}else{n=false;Janus.log("Server #"+(i+1)+": trying REST API to contact Janus ("+o+")")}}if(n){r=Janus.newWebSocket(o,"janus-protocol");a={error:function(){debugger;Janus.error("Error connecting to the Janus WebSockets server... "+o);if(Janus.isArray(s)){i++;if(i==s.length){u.error("Error connecting to any of the provided Janus servers: Is the gateway down?");return}o=null;setTimeout(function(){A(u)},200);return}u.error("Error connecting to the Janus WebSockets server: Is the gateway down?")},open:function(){y[d]=function(e){Janus.debug(e);if(e["janus"]!=="success"){Janus.error("Ooops: "+e["error"].code+" "+e["error"].reason);u.error(e["error"].reason);return}t=setTimeout(T,3e4);p=true;b=e.data["id"];Janus.log("Created session: "+b);Janus.sessions[b]=w;u.success()};r.send(JSON.stringify(l))},message:function(e){k(JSON.parse(e.data))},close:function(){if(o===null||!p){return}p=false;e.error("Lost connection to the gateway (is it down?)")}};for(var c in a){r.addEventListener(c,a[c])}return}Janus.httpAPICall(o,{verb:"POST",withCredentials:f,body:l,success:function(e){Janus.debug(e);if(e["janus"]!=="success"){Janus.error("Ooops: "+e["error"].code+" "+e["error"].reason);u.error(e["error"].reason);return}p=true;b=e.data["id"];Janus.log("Created session: "+b);Janus.sessions[b]=w;S();u.success()},error:function(e,n){Janus.error(e+": "+n);if(Janus.isArray(s)){i++;if(i==s.length){u.error("Error connecting to any of the provided Janus servers: Is the gateway down?");return}o=null;setTimeout(function(){A(u)},200);return}if(n==="")u.error(e+": Is the gateway down?");else u.error(e+": "+n)}})}function C(s){s=s||{};s.success=typeof s.success=="function"?s.success:Janus.noop;var i=true;if(s.asyncRequest!==undefined&&s.asyncRequest!==null)i=s.asyncRequest===true;Janus.log("Destroying session "+b+" (async="+i+")");if(!p){Janus.warn("Is the gateway down? (connected=false)");s.success();return}if(b===undefined||b===null){Janus.warn("No session to destroy");s.success();e.destroyed();return}delete Janus.sessions[b];var u={janus:"destroy",transaction:Janus.randomString(12)};if(m!==null&&m!==undefined)u["token"]=m;if(v!==null&&v!==undefined)u["apisecret"]=v;if(n){u["session_id"]=b;var d=function(){for(var e in a){r.removeEventListener(e,a[e])}r.removeEventListener("message",l);r.removeEventListener("error",c);if(t){clearTimeout(t)}r.close()};var l=function(n){var r=JSON.parse(n.data);if(r.session_id==u.session_id&&r.transaction==u.transaction){d();s.success();e.destroyed()}};var c=function(n){d();s.error("Failed to destroy the gateway: Is the gateway down?");e.destroyed()};r.addEventListener("message",l);r.addEventListener("error",c);r.send(JSON.stringify(u));return}Janus.httpAPICall(o+"/"+b,{verb:"POST",async:i,withCredentials:f,body:u,success:function(n){Janus.log("Destroyed session:");Janus.debug(n);b=null;p=false;if(n["janus"]!=="success"){Janus.error("Ooops: "+n["error"].code+" "+n["error"].reason)}s.success();e.destroyed()},error:function(n,r){Janus.error(n+": "+r);b=null;p=false;s.success();e.destroyed()}})}function D(e){e=e||{};e.success=typeof e.success=="function"?e.success:Janus.noop;e.error=typeof e.error=="function"?e.error:Janus.noop;e.consentDialog=typeof e.consentDialog=="function"?e.consentDialog:Janus.noop;e.iceState=typeof e.iceState=="function"?e.iceState:Janus.noop;e.mediaState=typeof e.mediaState=="function"?e.mediaState:Janus.noop;e.webrtcState=typeof e.webrtcState=="function"?e.webrtcState:Janus.noop;e.slowLink=typeof e.slowLink=="function"?e.slowLink:Janus.noop;e.onmessage=typeof e.onmessage=="function"?e.onmessage:Janus.noop;e.onlocalstream=typeof e.onlocalstream=="function"?e.onlocalstream:Janus.noop;e.onremotestream=typeof e.onremotestream=="function"?e.onremotestream:Janus.noop;e.ondata=typeof e.ondata=="function"?e.ondata:Janus.noop;e.ondataopen=typeof e.ondataopen=="function"?e.ondataopen:Janus.noop;e.oncleanup=typeof e.oncleanup=="function"?e.oncleanup:Janus.noop;e.ondetached=typeof e.ondetached=="function"?e.ondetached:Janus.noop;if(!p){Janus.warn("Is the gateway down? (connected=false)");e.error("Is the gateway down? (connected=false)");return}var a=e.plugin;if(a===undefined||a===null){Janus.error("Invalid plugin");e.error("Invalid plugin");return}var t=e.opaqueId;var s=Janus.randomString(12);var i={janus:"attach",plugin:a,opaque_id:t,transaction:s};if(m!==null&&m!==undefined)i["token"]=m;if(v!==null&&v!==undefined)i["apisecret"]=v;if(n){y[s]=function(n){Janus.debug(n);if(n["janus"]!=="success"){Janus.error("Ooops: "+n["error"].code+" "+n["error"].reason);e.error("Ooops: "+n["error"].code+" "+n["error"].reason);return}var r=n.data["id"];Janus.log("Created handle: "+r);var t={session:w,plugin:a,id:r,detached:false,webrtcStuff:{started:false,myStream:null,streamExternal:false,remoteStream:null,mySdp:null,mediaConstraints:null,pc:null,dataChannel:null,dtmfSender:null,trickle:true,iceDone:false,volume:{value:null,timer:null},bitrate:{value:null,bsnow:null,bsbefore:null,tsnow:null,tsbefore:null,timer:null}},getId:function(){return r},getPlugin:function(){return a},getVolume:function(){return N(r)},isAudioMuted:function(){return U(r,false)},muteAudio:function(){return W(r,false,true)},unmuteAudio:function(){return W(r,false,false)},isVideoMuted:function(){return U(r,true)},muteVideo:function(){return W(r,true,true)},unmuteVideo:function(){return W(r,true,false)},getBitrate:function(){return q(r)},send:function(e){I(r,e)},data:function(e){x(r,e)},dtmf:function(e){j(r,e)},consentDialog:e.consentDialog,iceState:e.iceState,mediaState:e.mediaState,webrtcState:e.webrtcState,slowLink:e.slowLink,onmessage:e.onmessage,createOffer:function(e){M(r,e)},createAnswer:function(e){M(r,e)},handleRemoteJsep:function(e){P(r,e)},onlocalstream:e.onlocalstream,onremotestream:e.onremotestream,ondata:e.ondata,ondataopen:e.ondataopen,oncleanup:e.oncleanup,ondetached:e.ondetached,hangup:function(e){G(r,e===true)},detach:function(e){O(r,e)}};J[r]=t;e.success(t)};i["session_id"]=b;r.send(JSON.stringify(i));return}Janus.httpAPICall(o+"/"+b,{verb:"POST",withCredentials:f,body:i,success:function(n){Janus.debug(n);if(n["janus"]!=="success"){Janus.error("Ooops: "+n["error"].code+" "+n["error"].reason);e.error("Ooops: "+n["error"].code+" "+n["error"].reason);return}var r=n.data["id"];Janus.log("Created handle: "+r);var t={session:w,plugin:a,id:r,detached:false,webrtcStuff:{started:false,myStream:null,streamExternal:false,remoteStream:null,mySdp:null,mediaConstraints:null,pc:null,dataChannel:null,dtmfSender:null,trickle:true,iceDone:false,volume:{value:null,timer:null},bitrate:{value:null,bsnow:null,bsbefore:null,tsnow:null,tsbefore:null,timer:null}},getId:function(){return r},getPlugin:function(){return a},getVolume:function(){return N(r)},isAudioMuted:function(){return U(r,false)},muteAudio:function(){return W(r,false,true)},unmuteAudio:function(){return W(r,false,false)},isVideoMuted:function(){return U(r,true)},muteVideo:function(){return W(r,true,true)},unmuteVideo:function(){return W(r,true,false)},getBitrate:function(){return q(r)},send:function(e){I(r,e)},data:function(e){x(r,e)},dtmf:function(e){j(r,e)},consentDialog:e.consentDialog,iceState:e.iceState,mediaState:e.mediaState,webrtcState:e.webrtcState,slowLink:e.slowLink,onmessage:e.onmessage,createOffer:function(e){M(r,e)},createAnswer:function(e){M(r,e)},handleRemoteJsep:function(e){P(r,e)},onlocalstream:e.onlocalstream,onremotestream:e.onremotestream,ondata:e.ondata,ondataopen:e.ondataopen,oncleanup:e.oncleanup,ondetached:e.ondetached,hangup:function(e){G(r,e===true)},detach:function(e){O(r,e)}};J[r]=t;e.success(t)},error:function(e,n){Janus.error(e+": "+n)}})}function I(e,a){a=a||{};a.success=typeof a.success=="function"?a.success:Janus.noop;a.error=typeof a.error=="function"?a.error:Janus.noop;if(!p){Janus.warn("Is the gateway down? (connected=false)");a.error("Is the gateway down? (connected=false)");return}var t=a.message;var s=a.jsep;var i=Janus.randomString(12);var u={janus:"message",body:t,transaction:i};if(m!==null&&m!==undefined)u["token"]=m;if(v!==null&&v!==undefined)u["apisecret"]=v;if(s!==null&&s!==undefined)u.jsep=s;Janus.debug("Sending message to plugin (handle="+e+"):");Janus.debug(u);if(n){u["session_id"]=b;u["handle_id"]=e;y[i]=function(e){Janus.debug("Message sent!");Janus.debug(e);if(e["janus"]==="success"){var n=e["plugindata"];if(n===undefined||n===null){Janus.warn("Request succeeded, but missing plugindata...");a.success();return}Janus.log("Synchronous transaction successful ("+n["plugin"]+")");var r=n["data"];Janus.debug(r);a.success(r);return}else if(e["janus"]!=="ack"){if(e["error"]!==undefined&&e["error"]!==null){Janus.error("Ooops: "+e["error"].code+" "+e["error"].reason);a.error(e["error"].code+" "+e["error"].reason)}else{Janus.error("Unknown error");a.error("Unknown error")}return}a.success()};r.send(JSON.stringify(u));return}Janus.httpAPICall(o+"/"+b+"/"+e,{verb:"POST",withCredentials:f,body:u,success:function(e){Janus.debug("Message sent!");Janus.debug(e);if(e["janus"]==="success"){var n=e["plugindata"];if(n===undefined||n===null){Janus.warn("Request succeeded, but missing plugindata...");a.success();return}Janus.log("Synchronous transaction successful ("+n["plugin"]+")");var r=n["data"];Janus.debug(r);a.success(r);return}else if(e["janus"]!=="ack"){if(e["error"]!==undefined&&e["error"]!==null){Janus.error("Ooops: "+e["error"].code+" "+e["error"].reason);a.error(e["error"].code+" "+e["error"].reason)}else{Janus.error("Unknown error");a.error("Unknown error")}return}a.success()},error:function(e,n){Janus.error(e+": "+n);a.error(e+": "+n)}})}function R(e,a){if(!p){Janus.warn("Is the gateway down? (connected=false)");return}var t={janus:"trickle",candidate:a,transaction:Janus.randomString(12)};if(m!==null&&m!==undefined)t["token"]=m;if(v!==null&&v!==undefined)t["apisecret"]=v;Janus.vdebug("Sending trickle candidate (handle="+e+"):");Janus.vdebug(t);if(n){t["session_id"]=b;t["handle_id"]=e;r.send(JSON.stringify(t));return}Janus.httpAPICall(o+"/"+b+"/"+e,{verb:"POST",withCredentials:f,body:t,success:function(e){Janus.vdebug("Candidate sent!");Janus.vdebug(e);if(e["janus"]!=="ack"){Janus.error("Ooops: "+e["error"].code+" "+e["error"].reason);return}},error:function(e,n){Janus.error(e+": "+n)}})}function x(e,n){n=n||{};n.success=typeof n.success=="function"?n.success:Janus.noop;n.error=typeof n.error=="function"?n.error:Janus.noop;var r=J[e];if(r===null||r===undefined||r.webrtcStuff===null||r.webrtcStuff===undefined){Janus.warn("Invalid handle");n.error("Invalid handle");return}var a=r.webrtcStuff;var t=n.text;if(t===null||t===undefined){Janus.warn("Invalid text");n.error("Invalid text");return}Janus.log("Sending string on data channel: "+t);a.dataChannel.send(t);n.success()}function j(e,n){n=n||{};n.success=typeof n.success=="function"?n.success:Janus.noop;n.error=typeof n.error=="function"?n.error:Janus.noop;var r=J[e];if(r===null||r===undefined||r.webrtcStuff===null||r.webrtcStuff===undefined){Janus.warn("Invalid handle");n.error("Invalid handle");return}var a=r.webrtcStuff;if(a.dtmfSender===null||a.dtmfSender===undefined){if(a.myStream!==undefined&&a.myStream!==null){var t=a.myStream.getAudioTracks();if(t!==null&&t!==undefined&&t.length>0){var s=t[0];a.dtmfSender=a.pc.createDTMFSender(s);Janus.log("Created DTMF Sender");a.dtmfSender.ontonechange=function(e){Janus.debug("Sent DTMF tone: "+e.tone)}}}if(a.dtmfSender===null||a.dtmfSender===undefined){Janus.warn("Invalid DTMF configuration");n.error("Invalid DTMF configuration");return}}var i=n.dtmf;if(i===null||i===undefined){Janus.warn("Invalid DTMF parameters");n.error("Invalid DTMF parameters");return}var o=i.tones;if(o===null||o===undefined){Janus.warn("Invalid DTMF string");n.error("Invalid DTMF string");return}var u=i.duration;if(u===null||u===undefined)u=500;var d=i.gap;if(d===null||d===undefined)d=50;Janus.debug("Sending DTMF string "+o+" (duration "+u+"ms, gap "+d+"ms)");a.dtmfSender.insertDTMF(o,u,d)}function O(e,a){a=a||{};a.success=typeof a.success=="function"?a.success:Janus.noop;a.error=typeof a.error=="function"?a.error:Janus.noop;var t=true;if(a.asyncRequest!==undefined&&a.asyncRequest!==null)t=a.asyncRequest===true;Janus.log("Destroying handle "+e+" (async="+t+")");G(e);if(J[e].detached){delete J[e];a.success();return}if(!p){Janus.warn("Is the gateway down? (connected=false)");a.error("Is the gateway down? (connected=false)");return}var s={janus:"detach",transaction:Janus.randomString(12)};if(m!==null&&m!==undefined)s["token"]=m;if(v!==null&&v!==undefined)s["apisecret"]=v;if(n){s["session_id"]=b;s["handle_id"]=e;r.send(JSON.stringify(s));delete J[e];a.success();return}Janus.httpAPICall(o+"/"+b+"/"+e,{verb:"POST",async:t,withCredentials:f,body:s,success:function(n){Janus.log("Destroyed handle:");Janus.debug(n);if(n["janus"]!=="success"){Janus.error("Ooops: "+n["error"].code+" "+n["error"].reason)}delete J[e];a.success()},error:function(n,r){Janus.error(n+": "+r);delete J[e];a.success()}})}function V(e,n,r,a,t){var s=J[e];if(s===null||s===undefined||s.webrtcStuff===null||s.webrtcStuff===undefined){Janus.warn("Invalid handle");a.error("Invalid handle");return}var i=s.webrtcStuff;Janus.debug("streamsDone:",t);if(t){Janus.debug(" -- Audio tracks:",t.getAudioTracks());Janus.debug(" -- Video tracks:",t.getVideoTracks())}var o=false;if(!i.myStream||!r.update||i.streamExternal){i.myStream=t;o=true}else{if((!r.update&&H(r)||r.update&&(r.addAudio||r.replaceAudio))&&t.getAudioTracks()&&t.getAudioTracks().length){Janus.log("Adding audio track:",t.getAudioTracks()[0]);i.myStream.addTrack(t.getAudioTracks()[0]);i.pc.addTrack(t.getAudioTracks()[0],t)}if((!r.update&&Y(r)||r.update&&(r.addVideo||r.replaceVideo))&&t.getVideoTracks()&&t.getVideoTracks().length){Janus.log("Adding video track:",t.getVideoTracks()[0]);i.myStream.addTrack(t.getVideoTracks()[0]);i.pc.addTrack(t.getVideoTracks()[0],t)}}if(!i.pc){var f={iceServers:u,iceTransportPolicy:d,bundlePolicy:l};var g={optional:[{DtlsSrtpKeyAgreement:true}]};if(c===true){g.optional.push({googIPv6:true})}if(a.rtcConstraints&&typeof a.rtcConstraints==="object"){Janus.debug("Adding custom PeerConnection constraints:",a.rtcConstraints);for(var m in a.rtcConstraints){g.optional.push(a.rtcConstraints[m])}}if(Janus.webRTCAdapter.browserDetails.browser==="edge"){f.bundlePolicy="max-bundle"}Janus.log("Creating PeerConnection");Janus.debug(g);i.pc=new RTCPeerConnection(f,g);Janus.debug(i.pc);if(i.pc.getStats){i.volume.value=0;i.bitrate.value="0 kbits/sec"}Janus.log("Preparing local SDP and gathering candidates (trickle="+i.trickle+")");i.pc.oniceconnectionstatechange=function(e){if(i.pc)s.iceState(i.pc.iceConnectionState)};i.pc.onicecandidate=function(n){if(n.candidate==null||Janus.webRTCAdapter.browserDetails.browser==="edge"&&n.candidate.candidate.indexOf("endOfCandidates")>0){Janus.log("End of candidates.");i.iceDone=true;if(i.trickle===true){R(e,{completed:true})}else{L(e,a)}}else{var r={candidate:n.candidate.candidate,sdpMid:n.candidate.sdpMid,sdpMLineIndex:n.candidate.sdpMLineIndex};if(i.trickle===true){R(e,r)}}};i.pc.ontrack=function(e){Janus.log("Handling Remote Track");Janus.debug(e);if(!e.streams)return;i.remoteStream=e.streams[0];s.onremotestream(i.remoteStream);if(e.track&&!e.track.onended){Janus.log("Adding onended callback to track:",e.track);e.track.onended=function(e){Janus.log("Remote track removed:",e);if(i.remoteStream){i.remoteStream.removeTrack(e.target);s.onremotestream(i.remoteStream)}}}}}if(o&&t!==null&&t!==undefined){Janus.log("Adding local stream");t.getTracks().forEach(function(e){i.pc.addTrack(e,t)})}if(Z(r)&&!i.dataChannel){Janus.log("Creating data channel");var v=function(e){Janus.log("Received message on data channel: "+e.data);s.ondata(e.data)};var p=function(){var e=i.dataChannel!==null?i.dataChannel.readyState:"null";Janus.log("State change on data channel: "+e);if(e==="open"){s.ondataopen()}};var b=function(e){Janus.error("Got error on data channel:",e)};i.dataChannel=i.pc.createDataChannel("JanusDataChannel",{ordered:false});i.dataChannel.onmessage=v;i.dataChannel.onopen=p;i.dataChannel.onclose=p;i.dataChannel.onerror=b}if(i.myStream)s.onlocalstream(i.myStream);if(n===null||n===undefined){E(e,r,a)}else{i.pc.setRemoteDescription(new RTCSessionDescription(n),function(){Janus.log("Remote description accepted!");F(e,r,a)},a.error)}}function M(e,n){n=n||{};n.success=typeof n.success=="function"?n.success:Janus.noop;n.error=typeof n.error=="function"?n.error:_;var r=n.jsep;n.media=n.media||{audio:true,video:true};var a=n.media;var t=J[e];if(t===null||t===undefined||t.webrtcStuff===null||t.webrtcStuff===undefined){Janus.warn("Invalid handle");n.error("Invalid handle");return}var s=t.webrtcStuff;s.trickle=$(n.trickle);if(s.pc===undefined||s.pc===null){a.update=false}else if(s.pc!==undefined&&s.pc!==null){Janus.log("Updating existing media session");a.update=true;if(n.stream!==null&&n.stream!==undefined){if(n.stream!==s.myStream){Janus.log("Renegotiation involves a new external stream")}}else{if(a.addAudio){a.replaceAudio=false;a.removeAudio=false;a.audioSend=true;if(s.myStream&&s.myStream.getAudioTracks()&&s.myStream.getAudioTracks().length){Janus.error("Can't add audio stream, there already is one");n.error("Can't add audio stream, there already is one");return}}else if(a.removeAudio){a.replaceAudio=false;a.addAudio=false;a.audioSend=false}else if(a.replaceAudio){a.addAudio=false;a.removeAudio=false;a.audioSend=true}if(s.myStream===null||s.myStream===undefined){if(a.replaceAudio){a.replaceAudio=false;a.addAudio=true;a.audioSend=true}if(H(a))a.addAudio=true}else{if(s.myStream.getAudioTracks()===null||s.myStream.getAudioTracks()===undefined||s.myStream.getAudioTracks().length===0){if(a.replaceAudio){a.replaceAudio=false;a.addAudio=true;a.audioSend=true}if(H(a))a.addAudio=true}}if(a.addVideo){a.replaceVideo=false;a.removeVideo=false;a.videoSend=true;if(s.myStream&&s.myStream.getVideoTracks()&&s.myStream.getVideoTracks().length){Janus.error("Can't add video stream, there already is one");n.error("Can't add video stream, there already is one");return}}else if(a.removeVideo){a.replaceVideo=false;a.addVideo=false;a.videoSend=false}else if(a.replaceVideo){a.addVideo=false;a.removeVideo=false;a.videoSend=true}if(s.myStream===null||s.myStream===undefined){if(a.replaceVideo){a.replaceVideo=false;a.addVideo=true;a.videoSend=true}if(Y(a))a.addVideo=true}else{if(s.myStream.getVideoTracks()===null||s.myStream.getVideoTracks()===undefined||s.myStream.getVideoTracks().length===0){if(a.replaceVideo){a.replaceVideo=false;a.addVideo=true;a.videoSend=true}if(Y(a))a.addVideo=true}}if(a.addData)a.data=true}}if(a.update&&!s.streamExternal){if(a.removeAudio||a.replaceAudio){if(s.myStream&&s.myStream.getAudioTracks()&&s.myStream.getAudioTracks().length){var i=s.myStream.getAudioTracks()[0];Janus.log("Removing audio track:",i);s.myStream.removeTrack(i);try{i.stop()}catch(e){}}if(s.pc.getSenders()&&s.pc.getSenders().length){for(var o in s.pc.getSenders()){var i=s.pc.getSenders()[o];if(i&&i.track&&i.track.kind==="audio"){Janus.log("Removing audio sender:",i);s.pc.removeTrack(i)}}}}if(a.removeVideo||a.replaceVideo){if(s.myStream&&s.myStream.getVideoTracks()&&s.myStream.getVideoTracks().length){var i=s.myStream.getVideoTracks()[0];Janus.log("Removing video track:",i);s.myStream.removeTrack(i);try{i.stop()}catch(e){}}if(s.pc.getSenders()&&s.pc.getSenders().length){for(var o in s.pc.getSenders()){var i=s.pc.getSenders()[o];if(i&&i.track&&i.track.kind==="video"){Janus.log("Removing video sender:",i);s.pc.removeTrack(i)}}}}}if(n.stream!==null&&n.stream!==undefined){var u=n.stream;Janus.log("MediaStream provided by the application");Janus.debug(u);if(a.update){if(s.myStream&&s.myStream!==n.stream&&!s.streamExternal){try{var d=s.myStream.getTracks();for(var l in d){var c=d[l];Janus.log(c);if(c!==null&&c!==undefined)c.stop()}}catch(e){}s.myStream=null}}s.streamExternal=true;V(e,r,a,n,u);return}if(H(a)||Y(a)){var f={mandatory:{},optional:[]};t.consentDialog(true);var g=H(a);if(g===true&&a!=undefined&&a!=null){if(typeof a.audio==="object"){g=a.audio}}var m=Y(a);if(m===true&&a!=undefined&&a!=null){var v=n.simulcast===true?true:false;if(v&&!r&&(a.video===undefined||a.video===false))a.video="hires";if(a.video&&a.video!="screen"&&a.video!="window"){var p=0;var b=0,w=0;if(a.video==="lowres"){b=240;w=240;p=320}else if(a.video==="lowres-16:9"){b=180;w=180;p=320}else if(a.video==="hires"||a.video==="hires-16:9"){b=720;w=720;p=1280;if(navigator.mozGetUserMedia){var h=parseInt(window.navigator.userAgent.match(/Firefox\/(.*)/)[1],10);if(h<38){Janus.warn(a.video+" unsupported, falling back to stdres (old Firefox)");b=480;w=480;p=640}}}else if(a.video==="stdres"){b=480;w=480;p=640}else if(a.video==="stdres-16:9"){b=360;w=360;p=640}else{Janus.log("Default video setting is stdres 4:3");b=480;w=480;p=640}Janus.log("Adding media constraint:",a.video);if(navigator.mozGetUserMedia){var h=parseInt(window.navigator.userAgent.match(/Firefox\/(.*)/)[1],10);if(h<38){m={require:["height","width"],height:{max:w,min:b},width:{max:p,min:p}}}else{m={height:{ideal:b},width:{ideal:p}}}}else{m={mandatory:{maxHeight:w,minHeight:b,maxWidth:p,minWidth:p},optional:[]}}if(typeof a.video==="object"){m=a.video}Janus.debug(m)}else if(a.video==="screen"||a.video==="window"){if(!a.screenshareFrameRate){a.screenshareFrameRate=3}if(window.location.protocol!=="https:"){Janus.warn("Screen sharing only works on HTTPS, try the https:// version of this page");t.consentDialog(false);n.error("Screen sharing only works on HTTPS, try the https:// version of this page");return}var y={};function S(s,i){t.consentDialog(false);if(s){n.error({code:s.code,name:s.name,message:s.message})}else{V(e,r,a,n,i)}}function k(e,n,r){Janus.log("Adding media constraint (screen capture)");Janus.debug(e);navigator.mediaDevices.getUserMedia(e).then(function(e){if(r){navigator.mediaDevices.getUserMedia({audio:true,video:false}).then(function(r){e.addTrack(r.getAudioTracks()[0]);n(null,e)})}else{n(null,e)}}).catch(function(e){t.consentDialog(false);n(e)})}if(Janus.webRTCAdapter.browserDetails.browser==="chrome"){var T=Janus.webRTCAdapter.browserDetails.version;var A=33;if(window.navigator.userAgent.match("Linux"))A=35;if(T>=26&&T<=A){f={video:{mandatory:{googLeakyBucket:true,maxWidth:window.screen.width,maxHeight:window.screen.height,minFrameRate:a.screenshareFrameRate,maxFrameRate:a.screenshareFrameRate,chromeMediaSource:"screen"}},audio:H(a)};k(f,S)}else{var C=window.setTimeout(function(){I=new Error("NavigatorUserMediaError");I.name='The required Chrome extension is not installed: click <a href="#">here</a> to install it. (NOTE: this will need you to refresh the page)';t.consentDialog(false);return n.error(I)},1e3);y[C]=[S,null];window.postMessage({type:"janusGetScreen",id:C},"*")}}else if(window.navigator.userAgent.match("Firefox")){var D=parseInt(window.navigator.userAgent.match(/Firefox\/(.*)/)[1],10);if(D>=33){f={video:{mozMediaSource:a.video,mediaSource:a.video},audio:H(a)};k(f,function(e,n){S(e,n);if(!e){var r=n.currentTime;var a=window.setInterval(function(){if(!n)window.clearInterval(a);if(n.currentTime==r){window.clearInterval(a);if(n.onended){n.onended()}}r=n.currentTime},500)}})}else{var I=new Error("NavigatorUserMediaError");I.name="Your version of Firefox does not support screen sharing, please install Firefox 33 (or more recent versions)";t.consentDialog(false);n.error(I);return}}window.addEventListener("message",function(e){if(e.origin!=window.location.origin)return;if(e.data.type=="janusGotScreen"&&y[e.data.id]){var r=y[e.data.id];var s=r[0];delete y[e.data.id];if(e.data.sourceId===""){var i=new Error("NavigatorUserMediaError");i.name="You cancelled the request for permission, giving up...";t.consentDialog(false);n.error(i)}else{f={audio:false,video:{mandatory:{chromeMediaSource:"desktop",maxWidth:window.screen.width,maxHeight:window.screen.height,minFrameRate:a.screenshareFrameRate,maxFrameRate:a.screenshareFrameRate},optional:[{googLeakyBucket:true},{googTemporalLayeredScreencast:true}]}};f.video.mandatory.chromeMediaSourceId=e.data.sourceId;k(f,s,H(a))}}else if(e.data.type=="janusGetScreenPending"){window.clearTimeout(e.data.id)}});return}}if(a===null||a===undefined||a.video!=="screen"){navigator.mediaDevices.enumerateDevices().then(function(s){var i=s.some(function(e){return e.kind==="audioinput"}),o=s.some(function(e){return e.kind==="videoinput"});var u=H(a);var d=Y(a);var l=z(a);var c=K(a);if(u||d||l||c){var f=u?i:false;var v=d?o:false;if(!f&&!v){t.consentDialog(false);n.error("No capture device found");return false}else if(!f&&l){t.consentDialog(false);n.error("Audio capture is required, but no capture device found");return false}else if(!v&&c){t.consentDialog(false);n.error("Video capture is required, but no capture device found");return false}}navigator.mediaDevices.getUserMedia({audio:i?g:false,video:o?m:false}).then(function(s){t.consentDialog(false);V(e,r,a,n,s)}).catch(function(e){t.consentDialog(false);n.error({code:e.code,name:e.name,message:e.message})})}).catch(function(e){t.consentDialog(false);n.error("enumerateDevices error",e)})}}else{V(e,r,a,n)}}function P(e,n){n=n||{};n.success=typeof n.success=="function"?n.success:Janus.noop;n.error=typeof n.error=="function"?n.error:_;var r=n.jsep;var a=J[e];if(a===null||a===undefined||a.webrtcStuff===null||a.webrtcStuff===undefined){Janus.warn("Invalid handle");n.error("Invalid handle");return}var t=a.webrtcStuff;if(r!==undefined&&r!==null){if(t.pc===null){Janus.warn("Wait, no PeerConnection?? if this is an answer, use createAnswer and not handleRemoteJsep");n.error("No PeerConnection: if this is an answer, use createAnswer and not handleRemoteJsep");return}t.pc.setRemoteDescription(new RTCSessionDescription(r),function(){Janus.log("Remote description accepted!");n.success()},n.error)}else{n.error("Invalid JSEP")}}function E(e,n,r){r=r||{};r.success=typeof r.success=="function"?r.success:Janus.noop;r.error=typeof r.error=="function"?r.error:Janus.noop;var a=J[e];if(a===null||a===undefined||a.webrtcStuff===null||a.webrtcStuff===undefined){Janus.warn("Invalid handle");r.error("Invalid handle");return}var t=a.webrtcStuff;var s=r.simulcast===true?true:false;if(!s){Janus.log("Creating offer (iceDone="+t.iceDone+")")}else{Janus.log("Creating offer (iceDone="+t.iceDone+", simulcast="+s+")")}var i={offerToReceiveAudio:Q(n),offerToReceiveVideo:X(n)};var o=r.iceRestart===true?true:false;if(o){i["iceRestart"]=true}Janus.debug(i);var u=Y(n);if(u&&s&&Janus.webRTCAdapter.browserDetails.browser==="firefox"){Janus.log("Enabling Simulcasting for Firefox (RID)");var d=t.pc.getSenders()[1];Janus.log(d);var l=d.getParameters();Janus.log(l);d.setParameters({encodings:[{rid:"high",active:true,priority:"high",maxBitrate:1e6},{rid:"medium",active:true,priority:"medium",maxBitrate:3e5},{rid:"low",active:true,priority:"low",maxBitrate:1e5}]})}t.pc.createOffer(function(e){Janus.debug(e);Janus.log("Setting local description");if(u&&s){if(Janus.webRTCAdapter.browserDetails.browser==="chrome"){Janus.log("Enabling Simulcasting for Chrome (SDP munging)");e.sdp=B(e.sdp)}else if(Janus.webRTCAdapter.browserDetails.browser!=="firefox"){Janus.warn("simulcast=true, but this is not Chrome nor Firefox, ignoring")}}t.mySdp=e.sdp;t.pc.setLocalDescription(e);t.mediaConstraints=i;if(!t.iceDone&&!t.trickle){Janus.log("Waiting for all candidates...");return}Janus.log("Offer ready");Janus.debug(r);var n={type:e.type,sdp:e.sdp};r.success(n)},r.error,i)}function F(e,n,r){r=r||{};r.success=typeof r.success=="function"?r.success:Janus.noop;r.error=typeof r.error=="function"?r.error:Janus.noop;var a=J[e];if(a===null||a===undefined||a.webrtcStuff===null||a.webrtcStuff===undefined){Janus.warn("Invalid handle");r.error("Invalid handle");return}var t=a.webrtcStuff;var s=r.simulcast===true?true:false;if(!s){Janus.log("Creating answer (iceDone="+t.iceDone+")")}else{Janus.log("Creating answer (iceDone="+t.iceDone+", simulcast="+s+")")}var i=null;if(Janus.webRTCAdapter.browserDetails.browser=="firefox"||Janus.webRTCAdapter.browserDetails.browser=="edge"){i={offerToReceiveAudio:Q(n),offerToReceiveVideo:X(n)}}else{i={mandatory:{OfferToReceiveAudio:Q(n),OfferToReceiveVideo:X(n)}}}Janus.debug(i);var o=Y(n);if(o&&s&&Janus.webRTCAdapter.browserDetails.browser==="firefox"){Janus.log("Enabling Simulcasting for Firefox (RID)");var u=t.pc.getSenders()[1];Janus.log(u);var d=u.getParameters();Janus.log(d);u.setParameters({encodings:[{rid:"high",active:true,priority:"high",maxBitrate:1e6},{rid:"medium",active:true,priority:"medium",maxBitrate:3e5},{rid:"low",active:true,priority:"low",maxBitrate:1e5}]})}t.pc.createAnswer(function(e){Janus.debug(e);Janus.log("Setting local description");if(o&&s){if(Janus.webRTCAdapter.browserDetails.browser==="chrome"){Janus.warn("simulcast=true, but this is an answer, and video breaks in Chrome if we enable it")}else if(Janus.webRTCAdapter.browserDetails.browser!=="firefox"){Janus.warn("simulcast=true, but this is not Chrome nor Firefox, ignoring")}}t.mySdp=e.sdp;t.pc.setLocalDescription(e);t.mediaConstraints=i;if(!t.iceDone&&!t.trickle){Janus.log("Waiting for all candidates...");return}var n={type:e.type,sdp:e.sdp};r.success(n)},r.error,i)}function L(e,n){n=n||{};n.success=typeof n.success=="function"?n.success:Janus.noop;n.error=typeof n.error=="function"?n.error:Janus.noop;var r=J[e];if(r===null||r===undefined||r.webrtcStuff===null||r.webrtcStuff===undefined){Janus.warn("Invalid handle, not sending anything");return}var a=r.webrtcStuff;Janus.log("Sending offer/answer SDP...");if(a.mySdp===null||a.mySdp===undefined){Janus.warn("Local SDP instance is invalid, not sending anything...");return}a.mySdp={type:a.pc.localDescription.type,sdp:a.pc.localDescription.sdp};if(a.trickle===false)a.mySdp["trickle"]=false;Janus.debug(n);a.sdpSent=true;n.success(a.mySdp)}function N(e){var n=J[e];if(n===null||n===undefined||n.webrtcStuff===null||n.webrtcStuff===undefined){Janus.warn("Invalid handle");return 0}var r=n.webrtcStuff;if(r.pc.getStats&&Janus.webRTCAdapter.browserDetails.browser=="chrome"){if(r.remoteStream===null||r.remoteStream===undefined){Janus.warn("Remote stream unavailable");return 0}if(r.volume.timer===null||r.volume.timer===undefined){Janus.log("Starting volume monitor");r.volume.timer=setInterval(function(){r.pc.getStats(function(e){var n=e.result();for(var a=0;a<n.length;a++){var t=n[a];if(t.type=="ssrc"&&t.stat("audioOutputLevel")){r.volume.value=t.stat("audioOutputLevel")}}})},200);return 0}return r.volume.value}else{Janus.log("Getting the remote volume unsupported by browser");return 0}}function U(e,n){var r=J[e];if(r===null||r===undefined||r.webrtcStuff===null||r.webrtcStuff===undefined){Janus.warn("Invalid handle");return true}var a=r.webrtcStuff;if(a.pc===null||a.pc===undefined){Janus.warn("Invalid PeerConnection");return true}if(a.myStream===undefined||a.myStream===null){Janus.warn("Invalid local MediaStream");return true}if(n){if(a.myStream.getVideoTracks()===null||a.myStream.getVideoTracks()===undefined||a.myStream.getVideoTracks().length===0){Janus.warn("No video track");return true}return!a.myStream.getVideoTracks()[0].enabled}else{if(a.myStream.getAudioTracks()===null||a.myStream.getAudioTracks()===undefined||a.myStream.getAudioTracks().length===0){Janus.warn("No audio track");return true}return!a.myStream.getAudioTracks()[0].enabled}}function W(e,n,r){var a=J[e];if(a===null||a===undefined||a.webrtcStuff===null||a.webrtcStuff===undefined){Janus.warn("Invalid handle");return false}var t=a.webrtcStuff;if(t.pc===null||t.pc===undefined){Janus.warn("Invalid PeerConnection");return false}if(t.myStream===undefined||t.myStream===null){Janus.warn("Invalid local MediaStream");return false}if(n){if(t.myStream.getVideoTracks()===null||t.myStream.getVideoTracks()===undefined||t.myStream.getVideoTracks().length===0){Janus.warn("No video track");return false}t.myStream.getVideoTracks()[0].enabled=r?false:true;return true}else{if(t.myStream.getAudioTracks()===null||t.myStream.getAudioTracks()===undefined||t.myStream.getAudioTracks().length===0){Janus.warn("No audio track");return false}t.myStream.getAudioTracks()[0].enabled=r?false:true;return true}}function q(e){var n=J[e];if(n===null||n===undefined||n.webrtcStuff===null||n.webrtcStuff===undefined){Janus.warn("Invalid handle");return"Invalid handle"}var r=n.webrtcStuff;if(r.pc===null||r.pc===undefined)return"Invalid PeerConnection";if(r.pc.getStats){if(r.bitrate.timer===null||r.bitrate.timer===undefined){Janus.log("Starting bitrate timer (via getStats)");r.bitrate.timer=setInterval(function(){r.pc.getStats().then(function(e){e.forEach(function(e){if(!e)return;var n=false;if((e.mediaType==="video"||e.id.toLowerCase().indexOf("video")>-1)&&e.type==="inbound-rtp"&&e.id.indexOf("rtcp")<0){n=true}else if(e.type=="ssrc"&&e.bytesReceived&&(e.googCodecName==="VP8"||e.googCodecName==="")){n=true}if(n){r.bitrate.bsnow=e.bytesReceived;r.bitrate.tsnow=e.timestamp;if(r.bitrate.bsbefore===null||r.bitrate.tsbefore===null){r.bitrate.bsbefore=r.bitrate.bsnow;r.bitrate.tsbefore=r.bitrate.tsnow}else{var a=r.bitrate.tsnow-r.bitrate.tsbefore;if(Janus.webRTCAdapter.browserDetails.browser=="safari")a=a/1e3;var t=Math.round((r.bitrate.bsnow-r.bitrate.bsbefore)*8/a);r.bitrate.value=t+" kbits/sec";r.bitrate.bsbefore=r.bitrate.bsnow;r.bitrate.tsbefore=r.bitrate.tsnow}}})})},1e3);return"0 kbits/sec"}return r.bitrate.value}else{Janus.warn("Getting the video bitrate unsupported by browser");return"Feature unsupported by browser"}}function _(e){Janus.error("WebRTC error:",e)}function G(e,a){Janus.log("Cleaning WebRTC stuff");var t=J[e];if(t===null||t===undefined){return}var s=t.webrtcStuff;if(s!==null&&s!==undefined){if(a===true){var i={janus:"hangup",transaction:Janus.randomString(12)};if(m!==null&&m!==undefined)i["token"]=m;if(v!==null&&v!==undefined)i["apisecret"]=v;Janus.debug("Sending hangup request (handle="+e+"):");Janus.debug(i);if(n){i["session_id"]=b;i["handle_id"]=e;r.send(JSON.stringify(i))}else{Janus.httpAPICall(o+"/"+b+"/"+e,{verb:"POST",withCredentials:f,data:i})}}s.remoteStream=null;if(s.volume.timer)clearInterval(s.volume.timer);s.volume.value=null;if(s.bitrate.timer)clearInterval(s.bitrate.timer);s.bitrate.timer=null;s.bitrate.bsnow=null;s.bitrate.bsbefore=null;s.bitrate.tsnow=null;s.bitrate.tsbefore=null;s.bitrate.value=null;try{if(!s.streamExternal&&s.myStream!==null&&s.myStream!==undefined){Janus.log("Stopping local stream tracks");var u=s.myStream.getTracks();for(var d in u){var l=u[d];Janus.log(l);if(l!==null&&l!==undefined)l.stop()}}}catch(e){}s.streamExternal=false;s.myStream=null;try{s.pc.close()}catch(e){}s.pc=null;s.mySdp=null;s.iceDone=false;s.dataChannel=null;s.dtmfSender=null}t.oncleanup()}function B(e){var n=e.split("\r\n");var r=false;var a=[-1],t=-1;var s=null,i=null,o=null,u=null;var d=-1;for(var l=0;l<n.length;l++){var c=n[l].match(/m=(\w+) */);if(c){var f=c[1];if(f==="video"){if(a[0]<0){r=true}else{d=l;break}}else{if(a[0]>-1){d=l;break}}continue}if(!r)continue;var g=n[l].match(/a=ssrc-group:FID (\d+) (\d+)/);if(g){a[0]=g[1];t=g[2];n.splice(l,1);l--;continue}if(a[0]){var m=n[l].match("a=ssrc:"+a[0]+" cname:(.+)");if(m){s=m[1]}m=n[l].match("a=ssrc:"+a[0]+" msid:(.+)");if(m){i=m[1]}m=n[l].match("a=ssrc:"+a[0]+" mslabel:(.+)");if(m){o=m[1]}m=n[l].match("a=ssrc:"+a+" label:(.+)");if(m){u=m[1]}if(n[l].indexOf("a=ssrc:"+t)===0){n.splice(l,1);l--;continue}if(n[l].indexOf("a=ssrc:"+a[0])===0){n.splice(l,1);l--;continue}}if(n[l].length==0){n.splice(l,1);l--;continue}}if(a[0]<0){d=-1;r=false;for(var l=0;l<n.length;l++){var c=n[l].match(/m=(\w+) */);if(c){var f=c[1];if(f==="video"){if(a[0]<0){r=true}else{d=l;break}}else{if(a[0]>-1){d=l;break}}continue}if(!r)continue;if(a[0]<0){var v=n[l].match(/a=ssrc:(\d+)/);if(v){a[0]=v[1];n.splice(l,1);l--;continue}}else{var m=n[l].match("a=ssrc:"+a[0]+" cname:(.+)");if(m){s=m[1]}m=n[l].match("a=ssrc:"+a[0]+" msid:(.+)");if(m){i=m[1]}m=n[l].match("a=ssrc:"+a[0]+" mslabel:(.+)");if(m){o=m[1]}m=n[l].match("a=ssrc:"+a[0]+" label:(.+)");if(m){u=m[1]}if(n[l].indexOf("a=ssrc:"+t)===0){n.splice(l,1);l--;continue}if(n[l].indexOf("a=ssrc:"+a[0])===0){n.splice(l,1);l--;continue}}if(n[l].length==0){n.splice(l,1);l--;continue}}}if(a[0]<0){Janus.warn("Couldn't find the video SSRC, simulcasting NOT enabled");return e}if(d<0){d=n.length}a[1]=Math.floor(Math.random()*4294967295);a[2]=Math.floor(Math.random()*4294967295);for(var l=0;l<a.length;l++){if(s){n.splice(d,0,"a=ssrc:"+a[l]+" cname:"+s);d++}if(i){n.splice(d,0,"a=ssrc:"+a[l]+" msid:"+i);d++}if(o){n.splice(d,0,"a=ssrc:"+a[l]+" mslabel:"+o);d++}if(u){n.splice(d,0,"a=ssrc:"+a[l]+" label:"+u);d++}}n.splice(d,0,"a=ssrc-group:SIM "+a[0]+" "+a[1]+" "+a[2]);e=n.join("\r\n");if(!e.endsWith("\r\n"))e+="\r\n";return e}function H(e){Janus.debug("isAudioSendEnabled:",e);if(e===undefined||e===null)return true;if(e.audio===false)return false;if(e.audioSend===undefined||e.audioSend===null)return true;return e.audioSend===true}function z(e){Janus.debug("isAudioSendRequired:",e);if(e===undefined||e===null)return false;if(e.audio===false||e.audioSend===false)return false;if(e.failIfNoAudio===undefined||e.failIfNoAudio===null)return false;return e.failIfNoAudio===true}function Q(e){Janus.debug("isAudioRecvEnabled:",e);if(e===undefined||e===null)return true;if(e.audio===false)return false;if(e.audioRecv===undefined||e.audioRecv===null)return true;return e.audioRecv===true}function Y(e){Janus.debug("isVideoSendEnabled:",e);if(e===undefined||e===null)return true;if(e.video===false)return false;if(e.videoSend===undefined||e.videoSend===null)return true;return e.videoSend===true}function K(e){Janus.debug("isVideoSendRequired:",e);if(e===undefined||e===null)return false;if(e.video===false||e.videoSend===false)return false;if(e.failIfNoVideo===undefined||e.failIfNoVideo===null)return false;return e.failIfNoVideo===true}function X(e){Janus.debug("isVideoRecvEnabled:",e);if(e===undefined||e===null)return true;if(e.video===false)return false;if(e.videoRecv===undefined||e.videoRecv===null)return true;return e.videoRecv===true}function Z(e){Janus.debug("isDataEnabled:",e);if(Janus.webRTCAdapter.browserDetails.browser=="edge"){Janus.warn("Edge doesn't support data channels yet");return false}if(e===undefined||e===null)return false;return e.data===true}function $(e){Janus.debug("isTrickleEnabled:",e);if(e===undefined||e===null)return true;return e===true}} //# sourceMappingURL=janus.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.27 |
proxy
|
phpinfo
|
Settings