text: !function a(o,s,c){function d(t,e){if(!s[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(u)return u(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=s[t]={exports:{}};o[t][0].call(i.exports,function(e){return d(o[t][1][e]||e)},i,i.exports,a,o,s,c)}return s[t].exports}for(var u="function"==typeof require&&require,e=0;e<c.length;e++)d(c[e]);return d}({1:[function(e,t,r){"use strict";var N=e("sdp");function c(e,t,r,n,i){var a=N.writeRtpDescription(e.kind,t);if(a+=N.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=N.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":i||"active"),a+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var s="msid:"+(n?n.id:"-")+" "+o+"\r\n";a+="a="+s,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+N.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+N.localCName+"\r\n"),a}function f(d,u){var p={codecs:[],headerExtensions:[],fecMechanisms:[]},l=function(e,t){e=parseInt(e,10);for(var r=0;r<t.length;r++)if(t[r].payloadType===e||t[r].preferredPayloadType===e)return t[r]};return d.codecs.forEach(function(r){for(var e=0;e<u.codecs.length;e++){var t=u.codecs[e];if(r.name.toLowerCase()===t.name.toLowerCase()&&r.clockRate===t.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&t.parameters.apt&&(n=r,i=t,a=d.codecs,o=u.codecs,c=s=void 0,s=l(n.parameters.apt,a),c=l(i.parameters.apt,o),!s||!c||s.name.toLowerCase()!==c.name.toLowerCase()))continue;(t=JSON.parse(JSON.stringify(t))).numChannels=Math.min(r.numChannels,t.numChannels),p.codecs.push(t),t.rtcpFeedback=t.rtcpFeedback.filter(function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}var n,i,a,o,s,c}),d.headerExtensions.forEach(function(e){for(var t=0;t<u.headerExtensions.length;t++){var r=u.headerExtensions[t];if(e.uri===r.uri){p.headerExtensions.push(r);break}}}),p}function a(e,t,r){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(r)}function A(e,t){var r=e.getRemoteCandidates().find(function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type});return r||e.addRemoteCandidate(t),!r}function m(e,t){var r=new Error(t);return r.name=e,r.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],r}t.exports=function(D,L){function j(e,t){t.addTrack(e),t.dispatchEvent(new D.MediaStreamTrackEvent("addtrack",{track:e}))}function i(e,t,r,n){var i=new Event("track");i.track=t,i.receiver=r,i.transceiver={receiver:r},i.streams=n,D.setTimeout(function(){e._dispatchEvent("track",i)})}var n=function(e){var t,n,i,r=this,a=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){r[e]=a[e].bind(a)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",e=JSON.parse(JSON.stringify(e||{})),this.usingBundle="max-bundle"===e.bundlePolicy,"negotiate"===e.rtcpMuxPolicy)throw m("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(e.rtcpMuxPolicy||(e.rtcpMuxPolicy="require"),e.iceTransportPolicy){case"all":case"relay":break;default:e.iceTransportPolicy="all"}switch(e.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:e.bundlePolicy="balanced"}if(e.iceServers=(t=e.iceServers||[],n=L,i=!1,(t=JSON.parse(JSON.stringify(t))).filter(function(e){if(e&&(e.urls||e.url)){var t=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var r="string"==typeof t;return r&&(t=[t]),t=t.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||i?0===e.indexOf("stun:")&&14393<=n&&-1===e.indexOf("?transport=udp"):i=!0}),delete e.url,e.urls=r?t[0]:t,!!t.length}})),this._iceGatherers=[],e.iceCandidatePoolSize)for(var o=e.iceCandidatePoolSize;0<o;o--)this._iceGatherers.push(new D.RTCIceGatherer({iceServers:e.iceServers,gatherPolicy:e.iceTransportPolicy}));else e.iceCandidatePoolSize=0;this._config=e,this.transceivers=[],this._sdpSessionId=N.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(n.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(n.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),n.prototype.onicecandidate=null,n.prototype.onaddstream=null,n.prototype.ontrack=null,n.prototype.onremovestream=null,n.prototype.onsignalingstatechange=null,n.prototype.oniceconnectionstatechange=null,n.prototype.onconnectionstatechange=null,n.prototype.onicegatheringstatechange=null,n.prototype.onnegotiationneeded=null,n.prototype.ondatachannel=null,n.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},n.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},n.prototype.getConfiguration=function(){return this._config},n.prototype.getLocalStreams=function(){return this.localStreams},n.prototype.getRemoteStreams=function(){return this.remoteStreams},n.prototype._createTransceiver=function(e,t){var r=0<this.transceivers.length,n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&r)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();n.iceTransport=i.iceTransport,n.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(n),n},n.prototype.addTrack=function(t,e){if(this._isClosed)throw m("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find(function(e){return e.track===t}))throw m("InvalidAccessError","Track already exists.");for(var n=0;n<this.transceivers.length;n++)this.transceivers[n].track||this.transceivers[n].kind!==t.kind||(r=this.transceivers[n]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(e)&&this.localStreams.push(e),r.track=t,r.stream=e,r.rtpSender=new D.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},n.prototype.addStream=function(t){var r=this;if(15025<=L)t.getTracks().forEach(function(e){r.addTrack(e,t)});else{var n=t.clone();t.getTracks().forEach(function(e,t){var r=n.getTracks()[t];e.addEventListener("enabled",function(e){r.enabled=e.enabled})}),n.getTracks().forEach(function(e){r.addTrack(e,n)})}},n.prototype.removeTrack=function(t){if(this._isClosed)throw m("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof D.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var e=this.transceivers.find(function(e){return e.rtpSender===t});if(!e)throw m("InvalidAccessError","Sender was not created by this connection.");var r=e.stream;e.rtpSender.stop(),e.rtpSender=null,e.track=null,e.stream=null,-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&-1<this.localStreams.indexOf(r)&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},n.prototype.removeStream=function(e){var r=this;e.getTracks().forEach(function(t){var e=r.getSenders().find(function(e){return e.track===t});e&&r.removeTrack(e)})},n.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},n.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},n.prototype._createIceGatherer=function(r,e){var n=this;if(e&&0<r)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new D.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[r].bufferedCandidateEvents=[],this.transceivers[r].bufferCandidates=function(e){var t=!e.candidate||0===Object.keys(e.candidate).length;i.state=t?"completed":"gathering",null!==n.transceivers[r].bufferedCandidateEvents&&n.transceivers[r].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[r].bufferCandidates),i},n.prototype._gather=function(s,c){var d=this,u=this.transceivers[c].iceGatherer;if(!u.onlocalcandidate){var e=this.transceivers[c].bufferedCandidateEvents;this.transceivers[c].bufferedCandidateEvents=null,u.removeEventListener("localcandidate",this.transceivers[c].bufferCandidates),u.onlocalcandidate=function(e){if(!(d.usingBundle&&0<c)){var t=new Event("icecandidate");t.candidate={sdpMid:s,sdpMLineIndex:c};var r=e.candidate,n=!r||0===Object.keys(r).length;if(n)"new"!==u.state&&"gathering"!==u.state||(u.state="completed");else{"new"===u.state&&(u.state="gathering"),r.component=1,r.ufrag=u.getLocalParameters().usernameFragment;var i=N.writeCandidate(r);t.candidate=Object.assign(t.candidate,N.parseCandidate(i)),t.candidate.candidate=i,t.candidate.toJSON=function(){return{candidate:t.candidate.candidate,sdpMid:t.candidate.sdpMid,sdpMLineIndex:t.candidate.sdpMLineIndex,usernameFragment:t.candidate.usernameFragment}}}var a=N.getMediaSections(d._localDescription.sdp);a[t.candidate.sdpMLineIndex]+=n?"a=end-of-candidates\r\n":"a="+t.candidate.candidate+"\r\n",d._localDescription.sdp=N.getDescription(d._localDescription.sdp)+a.join("");var o=d.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==d.iceGatheringState&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),n||d._dispatchEvent("icecandidate",t),o&&(d._dispatchEvent("icecandidate",new Event("icecandidate")),d.iceGatheringState="complete",d._emitGatheringStateChange())}},D.setTimeout(function(){e.forEach(function(e){u.onlocalcandidate(e)})},0)}},n.prototype._createIceAndDtlsTransports=function(){var e=this,t=new D.RTCIceTransport(null);t.onicestatechange=function(){e._updateIceConnectionState(),e._updateConnectionState()};var r=new D.RTCDtlsTransport(t);return r.ondtlsstatechange=function(){e._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),e._updateConnectionState()},{iceTransport:t,dtlsTransport:r}},n.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var n=this.transceivers[e].dtlsTransport;n&&(delete n.ondtlsstatechange,delete n.onerror,delete this.transceivers[e].dtlsTransport)},n.prototype._transceive=function(e,t,r){var n=f(e.localCapabilities,e.remoteCapabilities);t&&e.rtpSender&&(n.encodings=e.sendEncodingParameters,n.rtcp={cname:N.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(n.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(n)),r&&e.rtpReceiver&&0<n.codecs.length&&("video"===e.kind&&e.recvEncodingParameters&&L<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length?n.encodings=e.recvEncodingParameters:n.encodings=[{}],n.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(n.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(n.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(n))},n.prototype.setLocalDescription=function(e){var t,p,l=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(m("TypeError",'Unsupported type "'+e.type+'"'));if(!a("setLocalDescription",e.type,l.signalingState)||l._isClosed)return Promise.reject(m("InvalidStateError","Can not set local "+e.type+" in state "+l.signalingState));if("offer"===e.type)t=N.splitSections(e.sdp),p=t.shift(),t.forEach(function(e,t){var r=N.parseRtpParameters(e);l.transceivers[t].localCapabilities=r}),l.transceivers.forEach(function(e,t){l._gather(e.mid,t)});else if("answer"===e.type){t=N.splitSections(l._remoteDescription.sdp),p=t.shift();var h=0<N.matchPrefix(p,"a=ice-lite").length;t.forEach(function(e,t){var r=l.transceivers[t],n=r.iceGatherer,i=r.iceTransport,a=r.dtlsTransport,o=r.localCapabilities,s=r.remoteCapabilities;if(!(N.isRejected(e)&&0===N.matchPrefix(e,"a=bundle-only").length)&&!r.rejected){var c=N.getIceParameters(e,p),d=N.getDtlsParameters(e,p);h&&(d.role="server"),l.usingBundle&&0!==t||(l._gather(r.mid,t),"new"===i.state&&i.start(n,c,h?"controlling":"controlled"),"new"===a.state&&a.start(d));var u=f(o,s);l._transceive(r,0<u.codecs.length,!1)}})}return l._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?l._updateSignalingState("have-local-offer"):l._updateSignalingState("stable"),Promise.resolve()},n.prototype.setRemoteDescription=function(k){var w=this;if(-1===["offer","answer"].indexOf(k.type))return Promise.reject(m("TypeError",'Unsupported type "'+k.type+'"'));if(!a("setRemoteDescription",k.type,w.signalingState)||w._isClosed)return Promise.reject(m("InvalidStateError","Can not set remote "+k.type+" in state "+w.signalingState));var _={};w.remoteStreams.forEach(function(e){_[e.id]=e});var I=[],e=N.splitSections(k.sdp),O=e.shift(),x=0<N.matchPrefix(O,"a=ice-lite").length,M=0<N.matchPrefix(O,"a=group:BUNDLE ").length;w.usingBundle=M;var t=N.matchPrefix(O,"a=ice-options:")[0];return w.canTrickleIceCandidates=!!t&&0<=t.substr(14).split(" ").indexOf("trickle"),e.forEach(function(e,t){var r=N.splitLines(e),n=N.getKind(e),i=N.isRejected(e)&&0===N.matchPrefix(e,"a=bundle-only").length,a=r[0].substr(2).split(" ")[2],o=N.getDirection(e,O),s=N.parseMsid(e),c=N.getMid(e)||N.generateIdentifier();if(i||"application"===n&&("DTLS/SCTP"===a||"UDP/DTLS/SCTP"===a))w.transceivers[t]={mid:c,kind:n,protocol:a,rejected:!0};else{var d,u,p,l,h,f,m,v,g;!i&&w.transceivers[t]&&w.transceivers[t].rejected&&(w.transceivers[t]=w._createTransceiver(n,!0));var y,C,T=N.parseRtpParameters(e);i||(y=N.getIceParameters(e,O),(C=N.getDtlsParameters(e,O)).role="client"),m=N.parseRtpEncodingParameters(e);var S=N.parseRtcpParameters(e),R=0<N.matchPrefix(e,"a=end-of-candidates",O).length,b=N.matchPrefix(e,"a=candidate:").map(function(e){return N.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===k.type||"answer"===k.type)&&!i&&M&&0<t&&w.transceivers[t]&&(w._disposeIceAndDtlsTransports(t),w.transceivers[t].iceGatherer=w.transceivers[0].iceGatherer,w.transceivers[t].iceTransport=w.transceivers[0].iceTransport,w.transceivers[t].dtlsTransport=w.transceivers[0].dtlsTransport,w.transceivers[t].rtpSender&&w.transceivers[t].rtpSender.setTransport(w.transceivers[0].dtlsTransport),w.transceivers[t].rtpReceiver&&w.transceivers[t].rtpReceiver.setTransport(w.transceivers[0].dtlsTransport)),"offer"!==k.type||i)"answer"!==k.type||i||(u=(d=w.transceivers[t]).iceGatherer,p=d.iceTransport,l=d.dtlsTransport,h=d.rtpReceiver,f=d.sendEncodingParameters,v=d.localCapabilities,w.transceivers[t].recvEncodingParameters=m,w.transceivers[t].remoteCapabilities=T,w.transceivers[t].rtcpParameters=S,b.length&&"new"===p.state&&(!x&&!R||M&&0!==t?b.forEach(function(e){A(d.iceTransport,e)}):p.setRemoteCandidates(b)),M&&0!==t||("new"===p.state&&p.start(u,y,"controlling"),"new"===l.state&&l.start(C)),w._transceive(d,"sendrecv"===o||"recvonly"===o,"sendrecv"===o||"sendonly"===o),!h||"sendrecv"!==o&&"sendonly"!==o?delete d.rtpReceiver:(g=h.track,s?(_[s.stream]||(_[s.stream]=new D.MediaStream),j(g,_[s.stream]),I.push([g,h,_[s.stream]])):(_.default||(_.default=new D.MediaStream),j(g,_.default),I.push([g,h,_.default]))));else{(d=w.transceivers[t]||w._createTransceiver(n)).mid=c,d.iceGatherer||(d.iceGatherer=w._createIceGatherer(t,M)),b.length&&"new"===d.iceTransport.state&&(!R||M&&0!==t?b.forEach(function(e){A(d.iceTransport,e)}):d.iceTransport.setRemoteCandidates(b)),v=D.RTCRtpReceiver.getCapabilities(n),L<15019&&(v.codecs=v.codecs.filter(function(e){return"rtx"!==e.name})),f=d.sendEncodingParameters||[{ssrc:1001*(2*t+2)}];var E,P=!1;if("sendrecv"===o||"sendonly"===o){if(P=!d.rtpReceiver,h=d.rtpReceiver||new D.RTCRtpReceiver(d.dtlsTransport,n),P)g=h.track,s&&"-"===s.stream||(s?(_[s.stream]||(_[s.stream]=new D.MediaStream,Object.defineProperty(_[s.stream],"id",{get:function(){return s.stream}})),Object.defineProperty(g,"id",{get:function(){return s.track}}),E=_[s.stream]):(_.default||(_.default=new D.MediaStream),E=_.default)),E&&(j(g,E),d.associatedRemoteMediaStreams.push(E)),I.push([g,h,E])}else d.rtpReceiver&&d.rtpReceiver.track&&(d.associatedRemoteMediaStreams.forEach(function(e){var t,r,n=e.getTracks().find(function(e){return e.id===d.rtpReceiver.track.id});n&&(t=n,(r=e).removeTrack(t),r.dispatchEvent(new D.MediaStreamTrackEvent("removetrack",{track:t})))}),d.associatedRemoteMediaStreams=[]);d.localCapabilities=v,d.remoteCapabilities=T,d.rtpReceiver=h,d.rtcpParameters=S,d.sendEncodingParameters=f,d.recvEncodingParameters=m,w._transceive(w.transceivers[t],!1,P)}}}),void 0===w._dtlsRole&&(w._dtlsRole="offer"===k.type?"active":"passive"),w._remoteDescription={type:k.type,sdp:k.sdp},"offer"===k.type?w._updateSignalingState("have-remote-offer"):w._updateSignalingState("stable"),Object.keys(_).forEach(function(e){var n=_[e];if(n.getTracks().length){if(-1===w.remoteStreams.indexOf(n)){w.remoteStreams.push(n);var t=new Event("addstream");t.stream=n,D.setTimeout(function(){w._dispatchEvent("addstream",t)})}I.forEach(function(e){var t=e[0],r=e[1];n.id===e[2].id&&i(w,t,r,[n])})}}),I.forEach(function(e){e[2]||i(w,e[0],e[1],[])}),D.setTimeout(function(){w&&w.transceivers&&w.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&0<e.iceTransport.getRemoteCandidates().length&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},n.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},n.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},n.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,D.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},n.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++}),e="new",0<t.failed?e="failed":0<t.checking?e="checking":0<t.disconnected?e="disconnected":0<t.new?e="new":0<t.connected?e="connected":0<t.completed&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}},n.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",0<t.failed?e="failed":0<t.connecting?e="connecting":0<t.disconnected?e="disconnected":0<t.new?e="new":0<t.connected&&(e="connected"),e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}},n.prototype.createOffer=function(){var s=this;if(s._isClosed)return Promise.reject(m("InvalidStateError","Can not call createOffer after close"));var t=s.transceivers.filter(function(e){return"audio"===e.kind}).length,r=s.transceivers.filter(function(e){return"video"===e.kind}).length,e=arguments[0];if(e){if(e.mandatory||e.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==e.offerToReceiveAudio&&(t=!0===e.offerToReceiveAudio?1:!1===e.offerToReceiveAudio?0:e.offerToReceiveAudio),void 0!==e.offerToReceiveVideo&&(r=!0===e.offerToReceiveVideo?1:!1===e.offerToReceiveVideo?0:e.offerToReceiveVideo)}for(s.transceivers.forEach(function(e){"audio"===e.kind?--t<0&&(e.wantReceive=!1):"video"===e.kind&&--r<0&&(e.wantReceive=!1)});0<t||0<r;)0<t&&(s._createTransceiver("audio"),t--),0<r&&(s._createTransceiver("video"),r--);var n=N.writeSessionBoilerplate(s._sdpSessionId,s._sdpSessionVersion++);s.transceivers.forEach(function(e,t){var r=e.track,n=e.kind,i=e.mid||N.generateIdentifier();e.mid=i,e.iceGatherer||(e.iceGatherer=s._createIceGatherer(t,s.usingBundle));var a=D.RTCRtpSender.getCapabilities(n);L<15019&&(a.codecs=a.codecs.filter(function(e){return"rtx"!==e.name})),a.codecs.forEach(function(t){"H264"===t.name&&void 0===t.parameters["level-asymmetry-allowed"]&&(t.parameters["level-asymmetry-allowed"]="1"),e.remoteCapabilities&&e.remoteCapabilities.codecs&&e.remoteCapabilities.codecs.forEach(function(e){t.name.toLowerCase()===e.name.toLowerCase()&&t.clockRate===e.clockRate&&(t.preferredPayloadType=e.payloadType)})}),a.headerExtensions.forEach(function(t){(e.remoteCapabilities&&e.remoteCapabilities.headerExtensions||[]).forEach(function(e){t.uri===e.uri&&(t.id=e.id)})});var o=e.sendEncodingParameters||[{ssrc:1001*(2*t+1)}];r&&15019<=L&&"video"===n&&!o[0].rtx&&(o[0].rtx={ssrc:o[0].ssrc+1}),e.wantReceive&&(e.rtpReceiver=new D.RTCRtpReceiver(e.dtlsTransport,n)),e.localCapabilities=a,e.sendEncodingParameters=o}),"max-compat"!==s._config.bundlePolicy&&(n+="a=group:BUNDLE "+s.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),n+="a=ice-options:trickle\r\n",s.transceivers.forEach(function(e,t){n+=c(e,e.localCapabilities,"offer",e.stream,s._dtlsRole),n+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===s.iceGatheringState||0!==t&&s.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,n+="a="+N.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(n+="a=end-of-candidates\r\n"))});var i=new D.RTCSessionDescription({type:"offer",sdp:n});return Promise.resolve(i)},n.prototype.createAnswer=function(){var i=this;if(i._isClosed)return Promise.reject(m("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==i.signalingState&&"have-local-pranswer"!==i.signalingState)return Promise.reject(m("InvalidStateError","Can not call createAnswer in signalingState "+i.signalingState));var a=N.writeSessionBoilerplate(i._sdpSessionId,i._sdpSessionVersion++);i.usingBundle&&(a+="a=group:BUNDLE "+i.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n");var o=N.getMediaSections(i._remoteDescription.sdp).length;i.transceivers.forEach(function(e,t){if(!(o<t+1)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?a+="m=application 0 DTLS/SCTP 5000\r\n":a+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?a+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(a+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(a+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var r;if(e.stream)"audio"===e.kind?r=e.stream.getAudioTracks()[0]:"video"===e.kind&&(r=e.stream.getVideoTracks()[0]),r&&15019<=L&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var n=f(e.localCapabilities,e.remoteCapabilities);!n.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=c(e,n,"answer",e.stream,i._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}});var e=new D.RTCSessionDescription({type:"answer",sdp:a});return Promise.resolve(e)},n.prototype.addIceCandidate=function(c){var d,u=this;return c&&void 0===c.sdpMLineIndex&&!c.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(e,t){if(!u._remoteDescription)return t(m("InvalidStateError","Can not add ICE candidate without a remote description"));if(c&&""!==c.candidate){var r=c.sdpMLineIndex;if(c.sdpMid)for(var n=0;n<u.transceivers.length;n++)if(u.transceivers[n].mid===c.sdpMid){r=n;break}var i=u.transceivers[r];if(!i)return t(m("OperationError","Can not add ICE candidate"));if(i.rejected)return e();var a=0<Object.keys(c.candidate).length?N.parseCandidate(c.candidate):{};if("tcp"===a.protocol&&(0===a.port||9===a.port))return e();if(a.component&&1!==a.component)return e();if((0===r||0<r&&i.iceTransport!==u.transceivers[0].iceTransport)&&!A(i.iceTransport,a))return t(m("OperationError","Can not add ICE candidate"));var o=c.candidate.trim();0===o.indexOf("a=")&&(o=o.substr(2)),(d=N.getMediaSections(u._remoteDescription.sdp))[r]+="a="+(a.type?o:"end-of-candidates")+"\r\n",u._remoteDescription.sdp=N.getDescription(u._remoteDescription.sdp)+d.join("")}else for(var s=0;s<u.transceivers.length&&(u.transceivers[s].rejected||(u.transceivers[s].iceTransport.addRemoteCandidate({}),(d=N.getMediaSections(u._remoteDescription.sdp))[s]+="a=end-of-candidates\r\n",u._remoteDescription.sdp=N.getDescription(u._remoteDescription.sdp)+d.join(""),!u.usingBundle));s++);e()})},n.prototype.getStats=function(t){if(t&&t instanceof D.MediaStreamTrack){var r=null;if(this.transceivers.forEach(function(e){e.rtpSender&&e.rtpSender.track===t?r=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(r=e.rtpReceiver)}),!r)throw m("InvalidAccessError","Invalid selector.");return r.getStats()}var n=[];return this.transceivers.forEach(function(t){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(e){t[e]&&n.push(t[e].getStats())})}),Promise.all(n).then(function(e){var t=new Map;return e.forEach(function(e){e.forEach(function(e){t.set(e.id,e)})}),t})};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(e){var t=D[e];if(t&&t.prototype&&t.prototype.getStats){var r=t.prototype.getStats;t.prototype.getStats=function(){return r.apply(this).then(function(r){var n=new Map;return Object.keys(r).forEach(function(e){var t;r[e].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(t=r[e]).type]||t.type,n.set(e,r[e])}),n})}}});var e=["createOffer","createAnswer"];return e.forEach(function(e){var r=n.prototype[e];n.prototype[e]=function(){var t=arguments;return"function"==typeof t[0]||"function"==typeof t[1]?r.apply(this,[arguments[2]]).then(function(e){"function"==typeof t[0]&&t[0].apply(null,[e])},function(e){"function"==typeof t[1]&&t[1].apply(null,[e])}):r.apply(this,arguments)}}),(e=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(e){var r=n.prototype[e];n.prototype[e]=function(){var t=arguments;return"function"==typeof t[1]||"function"==typeof t[2]?r.apply(this,arguments).then(function(){"function"==typeof t[1]&&t[1].apply(null)},function(e){"function"==typeof t[2]&&t[2].apply(null,[e])}):r.apply(this,arguments)}}),["getStats"].forEach(function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)}):t.apply(this,arguments)}}),n}},{sdp:2}],2:[function(e,t,r){"use strict";var u={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};u.localCName=u.generateIdentifier(),u.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},u.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(0<t?"m="+e:e).trim()+"\r\n"})},u.getDescription=function(e){var t=u.splitSections(e);return t&&t[0]},u.getMediaSections=function(e){var t=u.splitSections(e);return t.shift(),t},u.matchPrefix=function(e,t){return u.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},u.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=parseInt(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:r[t[n]]=t[n+1]}return r},u.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.ip),t.push(e.port);var r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},u.parseIceOptions=function(e){return e.substr(14).split(" ")},u.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},u.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},u.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:0<t[0].indexOf("/")?t[0].split("/")[1]:"sendrecv",uri:t[1]}},u.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},u.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<n.length;i++)r[(t=n[i].trim().split("="))[0].trim()]=t[1];return r},u.writeFmtp=function(t){var e="",r=t.payloadType;if(void 0!==t.preferredPayloadType&&(r=t.preferredPayloadType),t.parameters&&Object.keys(t.parameters).length){var n=[];Object.keys(t.parameters).forEach(function(e){t.parameters[e]?n.push(e+"="+t.parameters[e]):n.push(e)}),e+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return e},u.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},u.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},u.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},n=e.indexOf(":",t);return-1<n?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},u.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},u.getMid=function(e){var t=u.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},u.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},u.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:u.matchPrefix(e+t,"a=fingerprint:").map(u.parseFingerprint)}},u.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),r},u.getIceParameters=function(e,t){var r=u.splitLines(e);return{usernameFragment:(r=r.concat(u.splitLines(t))).filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:r.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},u.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},u.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=u.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],a=u.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(a){var o=u.parseRtpMap(a),s=u.matchPrefix(e,"a=fmtp:"+i+" ");switch(o.parameters=s.length?u.parseFmtp(s[0]):{},o.rtcpFeedback=u.matchPrefix(e,"a=rtcp-fb:"+i+" ").map(u.parseRtcpFb),t.codecs.push(o),o.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(o.name.toUpperCase())}}}return u.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(u.parseExtmap(e))}),t},u.writeRtpDescription=function(e,t){var r="";r+="m="+e+" ",r+=0<t.codecs.length?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){r+=u.writeRtpMap(e),r+=u.writeFmtp(e),r+=u.writeRtcpFb(e)});var n=0;return t.codecs.forEach(function(e){e.maxptime>n&&(n=e.maxptime)}),0<n&&(r+="a=maxptime:"+n+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){r+=u.writeExtmap(e)}),r},u.parseRtpEncodingParameters=function(e){var r,n=[],t=u.parseRtpParameters(e),i=-1!==t.fecMechanisms.indexOf("RED"),a=-1!==t.fecMechanisms.indexOf("ULPFEC"),o=u.matchPrefix(e,"a=ssrc:").map(function(e){return u.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),s=0<o.length&&o[0].ssrc,c=u.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});0<c.length&&1<c[0].length&&c[0][0]===s&&(r=c[0][1]),t.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};s&&r&&(t.rtx={ssrc:r}),n.push(t),i&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:r,mechanism:a?"red+ulpfec":"red"},n.push(t))}}),0===n.length&&s&&n.push({ssrc:s});var d=u.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=d})),n},u.parseRtcpParameters=function(e){var t={},r=u.matchPrefix(e,"a=ssrc:").map(function(e){return u.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var n=u.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=0<n.length,t.compound=0===n.length;var i=u.matchPrefix(e,"a=rtcp-mux");return t.mux=0<i.length,t},u.parseMsid=function(e){var t,r=u.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var n=u.matchPrefix(e,"a=ssrc:").map(function(e){return u.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return 0<n.length?{stream:(t=n[0].value.split(" "))[0],track:t[1]}:void 0},u.generateSessionId=function(){return Math.random().toString().substr(2,21)},u.writeSessionBoilerplate=function(e,t){var r=void 0!==t?t:2;return"v=0\r\no=thisisadapterortc "+(e||u.generateSessionId())+" "+r+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},u.writeMediaSection=function(e,t,r,n){var i=u.writeRtpDescription(e.kind,t);if(i+=u.writeIceParameters(e.iceGatherer.getLocalParameters()),i+=u.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),i+="a=mid:"+e.mid+"\r\n",e.direction?i+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?i+="a=sendrecv\r\n":e.rtpSender?i+="a=sendonly\r\n":e.rtpReceiver?i+="a=recvonly\r\n":i+="a=inactive\r\n",e.rtpSender){var a="msid:"+n.id+" "+e.rtpSender.track.id+"\r\n";i+="a="+a,i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,i+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+u.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+u.localCName+"\r\n"),i},u.getDirection=function(e,t){for(var r=u.splitLines(e),n=0;n<r.length;n++)switch(r[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[n].substr(2)}return t?u.getDirection(t):"sendrecv"},u.getKind=function(e){return u.splitLines(e)[0].split(" ")[0].substr(2)},u.isRejected=function(e){return"0"===e.split(" ",2)[1]},u.parseMLine=function(e){var t=u.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}},u.parseOLine=function(e){var t=u.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:parseInt(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},u.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=u.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},"object"==typeof t&&(t.exports=u)},{}],3:[function(r,n,e){(function(e){"use strict";var t=r("./adapter_factory.js");n.exports=t({window:e.window})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./adapter_factory.js":4}],4:[function(h,e,t){"use strict";var f=h("./utils");e.exports=function(e,t){var r=e&&e.window,n={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0};for(var i in t)hasOwnProperty.call(t,i)&&(n[i]=t[i]);var a=f.log,o=f.detectBrowser(r),s=h("./chrome/chrome_shim")||null,c=h("./edge/edge_shim")||null,d=h("./firefox/firefox_shim")||null,u=h("./safari/safari_shim")||null,p=h("./common_shim")||null,l={browserDetails:o,commonShim:p,extractVersion:f.extractVersion,disableLog:f.disableLog,disableWarnings:f.disableWarnings};switch(o.browser){case"chrome":if(!s||!s.shimPeerConnection||!n.shimChrome)return a("Chrome shim is not included in this adapter release."),l;a("adapter.js shimming chrome."),l.browserShim=s,p.shimCreateObjectURL(r),s.shimGetUserMedia(r),s.shimMediaStream(r),s.shimSourceObject(r),s.shimPeerConnection(r),s.shimOnTrack(r),s.shimAddTrackRemoveTrack(r),s.shimGetSendersWithDtmf(r),s.shimSenderReceiverGetStats(r),s.fixNegotiationNeeded(r),p.shimRTCIceCandidate(r),p.shimMaxMessageSize(r),p.shimSendThrowTypeError(r);break;case"firefox":if(!d||!d.shimPeerConnection||!n.shimFirefox)return a("Firefox shim is not included in this adapter release."),l;a("adapter.js shimming firefox."),l.browserShim=d,p.shimCreateObjectURL(r),d.shimGetUserMedia(r),d.shimSourceObject(r),d.shimPeerConnection(r),d.shimOnTrack(r),d.shimRemoveStream(r),d.shimSenderGetStats(r),d.shimReceiverGetStats(r),d.shimRTCDataChannel(r),p.shimRTCIceCandidate(r),p.shimMaxMessageSize(r),p.shimSendThrowTypeError(r);break;case"edge":if(!c||!c.shimPeerConnection||!n.shimEdge)return a("MS edge shim is not included in this adapter release."),l;a("adapter.js shimming edge."),l.browserShim=c,p.shimCreateObjectURL(r),c.shimGetUserMedia(r),c.shimPeerConnection(r),c.shimReplaceTrack(r),p.shimMaxMessageSize(r),p.shimSendThrowTypeError(r);break;case"safari":if(!u||!n.shimSafari)return a("Safari shim is not included in this adapter release."),l;a("adapter.js shimming safari."),l.browserShim=u,p.shimCreateObjectURL(r),u.shimRTCIceServerUrls(r),u.shimCreateOfferLegacy(r),u.shimCallbacksAPI(r),u.shimLocalStreamsAPI(r),u.shimRemoteStreamsAPI(r),u.shimTrackEventTransceiver(r),u.shimGetUserMedia(r),p.shimRTCIceCandidate(r),p.shimMaxMessageSize(r),p.shimSendThrowTypeError(r);break;default:a("Unsupported browser!")}return l}},{"./chrome/chrome_shim":5,"./common_shim":7,"./edge/edge_shim":8,"./firefox/firefox_shim":11,"./safari/safari_shim":13,"./utils":14}],5:[function(e,t,r){"use strict";var c=e("../utils.js"),n=c.log;function i(r,t,e){var n=e?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var a=[];return r.forEach(function(e){"track"===e.type&&e.trackIdentifier===t.id&&a.push(e)}),a.forEach(function(t){r.forEach(function(e){e.type===n&&e.trackId===t.id&&function t(r,n,i){n&&!i.has(n.id)&&(i.set(n.id,n),Object.keys(n).forEach(function(e){e.endsWith("Id")?t(r,r.get(n[e]),i):e.endsWith("Ids")&&n[e].forEach(function(e){t(r,r.get(e),i)})}))}(r,e,i)})}),i}t.exports={shimGetUserMedia:e("./getusermedia"),shimMediaStream:function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},shimOnTrack:function(a){if("object"!=typeof a||!a.RTCPeerConnection||"ontrack"in a.RTCPeerConnection.prototype)"RTCRtpTransceiver"in a||c.wrapPeerConnectionEvent(a,"track",function(e){return e.transceiver||(e.transceiver={receiver:e.receiver}),e});else{Object.defineProperty(a.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var e=a.RTCPeerConnection.prototype.setRemoteDescription;a.RTCPeerConnection.prototype.setRemoteDescription=function(){var i=this;return i._ontrackpoly||(i._ontrackpoly=function(n){n.stream.addEventListener("addtrack",function(t){var e;e=a.RTCPeerConnection.prototype.getReceivers?i.getReceivers().find(function(e){return e.track&&e.track.id===t.track.id}):{track:t.track};var r=new Event("track");r.track=t.track,r.receiver=e,r.transceiver={receiver:e},r.streams=[n.stream],i.dispatchEvent(r)}),n.stream.getTracks().forEach(function(t){var e;e=a.RTCPeerConnection.prototype.getReceivers?i.getReceivers().find(function(e){return e.track&&e.track.id===t.id}):{track:t};var r=new Event("track");r.track=t,r.receiver=e,r.transceiver={receiver:e},r.streams=[n.stream],i.dispatchEvent(r)})},i.addEventListener("addstream",i._ontrackpoly)),e.apply(i,arguments)}}},shimGetSendersWithDtmf:function(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var n=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,t){var r=i.apply(this,arguments);return r||(r=n(this,e),this._senders.push(r)),r};var r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;t._senders=t._senders||[],a.apply(t,[e]),e.getTracks().forEach(function(e){t._senders.push(n(t,e))})};var t=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var r=this;r._senders=r._senders||[],t.apply(r,[e]),e.getTracks().forEach(function(t){var e=r._senders.find(function(e){return e.track===t});e&&r._senders.splice(r._senders.indexOf(e),1)})}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var o=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var t=this,e=o.apply(t,[]);return e.forEach(function(e){e._pc=t}),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},shimSenderReceiverGetStats:function(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var r=e.RTCPeerConnection.prototype.getSenders;r&&(e.RTCPeerConnection.prototype.getSenders=function(){var t=this,e=r.apply(t,[]);return e.forEach(function(e){e._pc=t}),e});var t=e.RTCPeerConnection.prototype.addTrack;t&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=t.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var t=this;return this._pc.getStats().then(function(e){return i(e,t.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var t=this,e=n.apply(t,[]);return e.forEach(function(e){e._pc=t}),e}),c.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){var t=this;return this._pc.getStats().then(function(e){return i(e,t.track,!1)})}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(0<arguments.length&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,i=arguments[0];return this.getSenders().forEach(function(e){e.track===i&&(t?n=!0:t=e)}),this.getReceivers().forEach(function(e){return e.track===i&&(r?n=!0:r=e),e.track===i}),n||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(this,arguments)}}}},shimSourceObject:function(e){var r=e&&e.URL;"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this._srcObject},set:function(e){var t=this;this._srcObject=e,this.src&&r.revokeObjectURL(this.src),e?(this.src=r.createObjectURL(e),e.addEventListener("addtrack",function(){t.src&&r.revokeObjectURL(t.src),t.src=r.createObjectURL(e)}),e.addEventListener("removetrack",function(){t.src&&r.revokeObjectURL(t.src),t.src=r.createObjectURL(e)})):this.src=""}}))},shimAddTrackRemoveTrackWithNative:function(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(e){return t._shimmedLocalStreams[e][0]})};var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,t){if(!t)return n.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=n.apply(this,arguments);return this._shimmedLocalStreams[t.id]?-1===this._shimmedLocalStreams[t.id].indexOf(r)&&this._shimmedLocalStreams[t.id].push(r):this._shimmedLocalStreams[t.id]=[t,r],r};var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(t){if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError")});var t=r.getSenders();i.apply(this,arguments);var n=r.getSenders().filter(function(e){return-1===t.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(n)};var t=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],t.apply(this,arguments)};var a=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(r){var n=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},r&&Object.keys(this._shimmedLocalStreams).forEach(function(e){var t=n._shimmedLocalStreams[e].indexOf(r);-1!==t&&n._shimmedLocalStreams[e].splice(t,1),1===n._shimmedLocalStreams[e].length&&delete n._shimmedLocalStreams[e]}),a.apply(this,arguments)}},shimAddTrackRemoveTrack:function(o){var e=c.detectBrowser(o);if(o.RTCPeerConnection.prototype.addTrack&&65<=e.version)return this.shimAddTrackRemoveTrackWithNative(o);var r=o.RTCPeerConnection.prototype.getLocalStreams;o.RTCPeerConnection.prototype.getLocalStreams=function(){var t=this,e=r.apply(this);return t._reverseStreams=t._reverseStreams||{},e.map(function(e){return t._reverseStreams[e.id]})};var n=o.RTCPeerConnection.prototype.addStream;o.RTCPeerConnection.prototype.addStream=function(e){var r=this;if(r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{},e.getTracks().forEach(function(t){if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError")}),!r._reverseStreams[e.id]){var t=new o.MediaStream(e.getTracks());r._streams[e.id]=t,r._reverseStreams[t.id]=e,e=t}n.apply(r,[e])};var i=o.RTCPeerConnection.prototype.removeStream;function a(n,e){var i=e.sdp;return Object.keys(n._reverseStreams||[]).forEach(function(e){var t=n._reverseStreams[e],r=n._streams[t.id];i=i.replace(new RegExp(r.id,"g"),t.id)}),new RTCSessionDescription({type:e.type,sdp:i})}o.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._streams=t._streams||{},t._reverseStreams=t._reverseStreams||{},i.apply(t,[t._streams[e.id]||e]),delete t._reverseStreams[t._streams[e.id]?t._streams[e.id].id:e.id],delete t._streams[e.id]},o.RTCPeerConnection.prototype.addTrack=function(t,e){var r=this;if("closed"===r.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single  stream which is associated with the specified track.","NotSupportedError");if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError");r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{};var i=r._streams[e.id];if(i)i.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var a=new o.MediaStream([t]);r._streams[e.id]=a,r._reverseStreams[a.id]=e,r.addStream(a)}return r.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(e){var t=o.RTCPeerConnection.prototype[e];o.RTCPeerConnection.prototype[e]=function(){var r=this,n=arguments;return arguments.length&&"function"==typeof arguments[0]?t.apply(r,[function(e){var t=a(r,e);n[0].apply(null,[t])},function(e){n[1]&&n[1].apply(null,e)},arguments[2]]):t.apply(r,arguments).then(function(e){return a(r,e)})}});var t=o.RTCPeerConnection.prototype.setLocalDescription;o.RTCPeerConnection.prototype.setLocalDescription=function(){var n,e,i;return arguments.length&&arguments[0].type&&(arguments[0]=(n=this,e=arguments[0],i=e.sdp,Object.keys(n._reverseStreams||[]).forEach(function(e){var t=n._reverseStreams[e],r=n._streams[t.id];i=i.replace(new RegExp(t.id,"g"),r.id)}),new RTCSessionDescription({type:e.type,sdp:i}))),t.apply(this,arguments)};var s=Object.getOwnPropertyDescriptor(o.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(o.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=s.get.apply(this);return""===e.type?e:a(this,e)}}),o.RTCPeerConnection.prototype.removeTrack=function(t){var r,n=this;if("closed"===n.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!t._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(t._pc===n))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");n._streams=n._streams||{},Object.keys(n._streams).forEach(function(e){n._streams[e].getTracks().find(function(e){return t.track===e})&&(r=n._streams[e])}),r&&(1===r.getTracks().length?n.removeStream(n._reverseStreams[r.id]):r.removeTrack(t.track),n.dispatchEvent(new Event("negotiationneeded")))}},shimPeerConnection:function(r){var e=c.detectBrowser(r);if(!r.RTCPeerConnection&&r.webkitRTCPeerConnection)r.RTCPeerConnection=function(e,t){return n("PeerConnection"),e&&e.iceTransportPolicy&&(e.iceTransports=e.iceTransportPolicy),new r.webkitRTCPeerConnection(e,t)},r.RTCPeerConnection.prototype=r.webkitRTCPeerConnection.prototype,r.webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(r.RTCPeerConnection,"generateCertificate",{get:function(){return r.webkitRTCPeerConnection.generateCertificate}});else{var a=r.RTCPeerConnection;r.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var r=[],n=0;n<e.iceServers.length;n++){var i=e.iceServers[n];!i.hasOwnProperty("urls")&&i.hasOwnProperty("url")?(c.deprecated("RTCIceServer.url","RTCIceServer.urls"),(i=JSON.parse(JSON.stringify(i))).urls=i.url,r.push(i)):r.push(e.iceServers[n])}e.iceServers=r}return new a(e,t)},r.RTCPeerConnection.prototype=a.prototype,Object.defineProperty(r.RTCPeerConnection,"generateCertificate",{get:function(){return a.generateCertificate}})}var s=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(e,t,r){var n=this,i=arguments;if(0<arguments.length&&"function"==typeof e)return s.apply(this,arguments);if(0===s.length&&(0===arguments.length||"function"!=typeof e))return s.apply(this,[]);var a=function(e){var n={};return e.result().forEach(function(t){var r={id:t.id,timestamp:t.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[t.type]||t.type};t.names().forEach(function(e){r[e]=t.stat(e)}),n[r.id]=r}),n},o=function(t){return new Map(Object.keys(t).map(function(e){return[e,t[e]]}))};if(2<=arguments.length){return s.apply(this,[function(e){i[1](o(a(e)))},e])}return new Promise(function(t,e){s.apply(n,[function(e){t(o(a(e)))},e])}).then(t,r)},e.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var i=r.RTCPeerConnection.prototype[e];r.RTCPeerConnection.prototype[e]=function(){var r=arguments,n=this,e=new Promise(function(e,t){i.apply(n,[r[0],e,t])});return r.length<2?e:e.then(function(){r[1].apply(null,[])},function(e){3<=r.length&&r[2].apply(null,[e])})}}),e.version<52&&["createOffer","createAnswer"].forEach(function(e){var i=r.RTCPeerConnection.prototype[e];r.RTCPeerConnection.prototype[e]=function(){var r=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var n=1===arguments.length?arguments[0]:void 0;return new Promise(function(e,t){i.apply(r,[e,t,n])})}return i.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=r.RTCPeerConnection.prototype[e];r.RTCPeerConnection.prototype[e]=function(){return arguments[0]=new("addIceCandidate"===e?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}});var t=r.RTCPeerConnection.prototype.addIceCandidate;r.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}},fixNegotiationNeeded:function(e){c.wrapPeerConnectionEvent(e,"negotiationneeded",function(e){if("stable"===e.target.signalingState)return e})},shimGetDisplayMedia:function(e,r){"getDisplayMedia"in e.navigator||("function"==typeof r?navigator.getDisplayMedia=function(t){return r(t).then(function(e){return t.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,maxFrameRate:t.video.frameRate||3}},navigator.mediaDevices.getUserMedia(t)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}},{"../utils.js":14,"./getusermedia":6}],6:[function(e,t,r){"use strict";var a=e("../utils.js"),d=a.log;t.exports=function(e){var o=a.detectBrowser(e),s=e&&e.navigator,c=function(i){if("object"!=typeof i||i.mandatory||i.optional)return i;var a={};return Object.keys(i).forEach(function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var r="object"==typeof i[t]?i[t]:{ideal:i[t]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var n=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){a.optional=a.optional||[];var e={};"number"==typeof r.ideal?(e[n("min",t)]=r.ideal,a.optional.push(e),(e={})[n("max",t)]=r.ideal):e[n("",t)]=r.ideal,a.optional.push(e)}void 0!==r.exact&&"number"!=typeof r.exact?(a.mandatory=a.mandatory||{},a.mandatory[n("",t)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(a.mandatory=a.mandatory||{},a.mandatory[n(e,t)]=r[e])})}}),i.advanced&&(a.optional=(a.optional||[]).concat(i.advanced)),a},n=function(r,n){if(61<=o.version)return n(r);if((r=JSON.parse(JSON.stringify(r)))&&"object"==typeof r.audio){var e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};e((r=JSON.parse(JSON.stringify(r))).audio,"autoGainControl","googAutoGainControl"),e(r.audio,"noiseSuppression","googNoiseSuppression"),r.audio=c(r.audio)}if(r&&"object"==typeof r.video){var i=r.video.facingMode;i=i&&("object"==typeof i?i:{ideal:i});var a,t=o.version<66;if(i&&("user"===i.exact||"environment"===i.exact||"user"===i.ideal||"environment"===i.ideal)&&(!s.mediaDevices.getSupportedConstraints||!s.mediaDevices.getSupportedConstraints().facingMode||t))if(delete r.video.facingMode,"environment"===i.exact||"environment"===i.ideal?a=["back","rear"]:"user"!==i.exact&&"user"!==i.ideal||(a=["front"]),a)return s.mediaDevices.enumerateDevices().then(function(e){var t=(e=e.filter(function(e){return"videoinput"===e.kind})).find(function(t){return a.some(function(e){return-1!==t.label.toLowerCase().indexOf(e)})});return!t&&e.length&&-1!==a.indexOf("back")&&(t=e[e.length-1]),t&&(r.video.deviceId=i.exact?{exact:t.deviceId}:{ideal:t.deviceId}),r.video=c(r.video),d("chrome: "+JSON.stringify(r)),n(r)});r.video=c(r.video)}return d("chrome: "+JSON.stringify(r)),n(r)},i=function(e){return 64<=o.version?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};s.getUserMedia=function(e,t,r){n(e,function(e){s.webkitGetUserMedia(e,t,function(e){r&&r(i(e))})})};var t=function(r){return new Promise(function(e,t){s.getUserMedia(r,e,t)})};if(s.mediaDevices||(s.mediaDevices={getUserMedia:t,enumerateDevices:function(){return new Promise(function(t){var r={audio:"audioinput",video:"videoinput"};return e.MediaStreamTrack.getSources(function(e){t(e.map(function(e){return{label:e.label,kind:r[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),s.mediaDevices.getUserMedia){var r=s.mediaDevices.getUserMedia.bind(s.mediaDevices);s.mediaDevices.getUserMedia=function(e){return n(e,function(t){return r(t).then(function(e){if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return e},function(e){return Promise.reject(i(e))})})}}else s.mediaDevices.getUserMedia=function(e){return t(e)};void 0===s.mediaDevices.addEventListener&&(s.mediaDevices.addEventListener=function(){d("Dummy mediaDevices.addEventListener called.")}),void 0===s.mediaDevices.removeEventListener&&(s.mediaDevices.removeEventListener=function(){d("Dummy mediaDevices.removeEventListener called.")})}},{"../utils.js":14}],7:[function(e,t,r){"use strict";var p=e("sdp"),c=e("./utils");t.exports={shimRTCIceCandidate:function(t){if(t.RTCIceCandidate&&!(t.RTCIceCandidate&&"foundation"in t.RTCIceCandidate.prototype)){var i=t.RTCIceCandidate;t.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var t=new i(e),r=p.parseCandidate(e.candidate),n=Object.assign(t,r);return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new i(e)},t.RTCIceCandidate.prototype=i.prototype,c.wrapPeerConnectionEvent(t,"icecandidate",function(e){return e.candidate&&Object.defineProperty(e,"candidate",{value:new t.RTCIceCandidate(e.candidate),writable:"false"}),e})}},shimCreateObjectURL:function(e){var t=e&&e.URL;if("object"==typeof e&&e.HTMLMediaElement&&"srcObject"in e.HTMLMediaElement.prototype&&t.createObjectURL&&t.revokeObjectURL){var r=t.createObjectURL.bind(t),n=t.revokeObjectURL.bind(t),i=new Map,a=0;t.createObjectURL=function(e){if("getTracks"in e){var t="polyblob:"+ ++a;return i.set(t,e),c.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream"),t}return r(e)},t.revokeObjectURL=function(e){n(e),i.delete(e)};var o=Object.getOwnPropertyDescriptor(e.HTMLMediaElement.prototype,"src");Object.defineProperty(e.HTMLMediaElement.prototype,"src",{get:function(){return o.get.apply(this)},set:function(e){return this.srcObject=i.get(e)||null,o.set.apply(this,[e])}});var s=e.HTMLMediaElement.prototype.setAttribute;e.HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=i.get(arguments[1])||null),s.apply(this,arguments)}}},shimMaxMessageSize:function(e){if(!e.RTCSctpTransport&&e.RTCPeerConnection){var d=c.detectBrowser(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var u=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e,t,r,n;if(this._sctp=null,r=arguments[0],(n=p.splitSections(r.sdp)).shift(),n.some(function(e){var t=p.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})){var i,a=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),o=(e=a,t=65536,"firefox"===d.browser&&(t=d.version<57?-1===e?16384:2147483637:d.version<60?57===d.version?65535:65536:2147483637),t),s=function(e,t){var r=65536;"firefox"===d.browser&&57===d.version&&(r=65535);var n=p.matchPrefix(e.sdp,"a=max-message-size:");return 0<n.length?r=parseInt(n[0].substr(19),10):"firefox"===d.browser&&-1!==t&&(r=2147483637),r}(arguments[0],a);i=0===o&&0===s?Number.POSITIVE_INFINITY:0===o||0===s?Math.max(o,s):Math.min(o,s);var c={};Object.defineProperty(c,"maxMessageSize",{get:function(){return i}}),this._sctp=c}return u.apply(this,arguments)}}},shimSendThrowTypeError:function(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e,this),e},c.wrapPeerConnectionEvent(e,"datachannel",function(e){return r(e.channel,e.target),e})}function r(r,n){var i=r.send;r.send=function(){var e=arguments[0],t=e.length||e.size||e.byteLength;if("open"===r.readyState&&n.sctp&&t>n.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+n.sctp.maxMessageSize+" bytes)");return i.apply(r,arguments)}}}}},{"./utils":14,sdp:2}],8:[function(e,t,r){"use strict";var i=e("../utils"),a=e("./filtericeservers"),o=e("rtcpeerconnection-shim");t.exports={shimGetUserMedia:e("./getusermedia"),shimPeerConnection:function(e){var t=i.detectBrowser(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var r=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){r.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);var n=o(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=a(e.iceServers)),new n(e)},e.RTCPeerConnection.prototype=n.prototype},shimReplaceTrack:function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}}},{"../utils":14,"./filtericeservers":9,"./getusermedia":10,"rtcpeerconnection-shim":1}],9:[function(e,t,r){"use strict";var a=e("../utils");t.exports=function(e,n){var i=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var t=e.urls||e.url;e.url&&!e.urls&&a.deprecated("RTCIceServer.url","RTCIceServer.urls");var r="string"==typeof t;return r&&(t=[t]),t=t.filter(function(e){return 0===e.indexOf("turn:")&&-1!==e.indexOf("transport=udp")&&-1===e.indexOf("turn:[")&&!i?i=!0:0===e.indexOf("stun:")&&14393<=n&&-1===e.indexOf("?transport=udp")}),delete e.url,e.urls=r?t[0]:t,!!t.length}})}},{"../utils":14}],10:[function(e,t,r){"use strict";t.exports=function(e){var t=e&&e.navigator,r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch(function(e){return Promise.reject({name:{PermissionDeniedError:"NotAllowedError"}[(t=e).name]||t.name,message:t.message,constraint:t.constraint,toString:function(){return this.name}});var t})}}},{}],11:[function(e,t,r){"use strict";var n=e("../utils");t.exports={shimGetUserMedia:e("./getusermedia"),shimOnTrack:function(e){"object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(r){r.stream.getTracks().forEach(function(e){var t=new Event("track");t.track=e,t.receiver={track:e},t.transceiver={receiver:t.receiver},t.streams=[r.stream],this.dispatchEvent(t)}.bind(this))}.bind(this))},enumerable:!0,configurable:!0}),"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimSourceObject:function(e){"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(s){var c=n.detectBrowser(s);if("object"==typeof s&&(s.RTCPeerConnection||s.mozRTCPeerConnection)){s.RTCPeerConnection||(s.RTCPeerConnection=function(e,t){if(c.version<38&&e&&e.iceServers){for(var r=[],n=0;n<e.iceServers.length;n++){var i=e.iceServers[n];if(i.hasOwnProperty("urls"))for(var a=0;a<i.urls.length;a++){var o={url:i.urls[a]};0===i.urls[a].indexOf("turn")&&(o.username=i.username,o.credential=i.credential),r.push(o)}else r.push(e.iceServers[n])}e.iceServers=r}return new s.mozRTCPeerConnection(e,t)},s.RTCPeerConnection.prototype=s.mozRTCPeerConnection.prototype,s.mozRTCPeerConnection.generateCertificate&&Object.defineProperty(s.RTCPeerConnection,"generateCertificate",{get:function(){return s.mozRTCPeerConnection.generateCertificate}}),s.RTCSessionDescription=s.mozRTCSessionDescription,s.RTCIceCandidate=s.mozRTCIceCandidate),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=s.RTCPeerConnection.prototype[e];s.RTCPeerConnection.prototype[e]=function(){return arguments[0]=new("addIceCandidate"===e?s.RTCIceCandidate:s.RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}});var e=s.RTCPeerConnection.prototype.addIceCandidate;s.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?e.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())};var a={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=s.RTCPeerConnection.prototype.getStats;s.RTCPeerConnection.prototype.getStats=function(e,i,t){return r.apply(this,[e||null]).then(function(r){var t,n;if(c.version<48&&(t=r,n=new Map,Object.keys(t).forEach(function(e){n.set(e,t[e]),n[e]=t[e]}),r=n),c.version<53&&!i)try{r.forEach(function(e){e.type=a[e.type]||e.type})}catch(e){if("TypeError"!==e.name)throw e;r.forEach(function(e,t){r.set(t,Object.assign({},e,{type:a[e.type]||e.type}))})}return r}).then(i,t)}}},shimSenderGetStats:function(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&!(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)){var r=e.RTCPeerConnection.prototype.getSenders;r&&(e.RTCPeerConnection.prototype.getSenders=function(){var t=this,e=r.apply(t,[]);return e.forEach(function(e){e._pc=t}),e});var t=e.RTCPeerConnection.prototype.addTrack;t&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=t.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}},shimReceiverGetStats:function(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&!(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)){var r=e.RTCPeerConnection.prototype.getReceivers;r&&(e.RTCPeerConnection.prototype.getReceivers=function(){var t=this,e=r.apply(t,[]);return e.forEach(function(e){e._pc=t}),e}),n.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}},shimRemoveStream:function(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){var r=this;n.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(e){e.track&&-1!==t.getTracks().indexOf(e.track)&&r.removeTrack(e)})})},shimRTCDataChannel:function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},shimGetDisplayMedia:function(e,r){"getDisplayMedia"in e.navigator||(navigator.getDisplayMedia=function(e){if(!e||!e.video){var t=new DOMException("getDisplayMedia without video constraints is undefined");return t.name="NotFoundError",t.code=8,Promise.reject(t)}return!0===e.video?e.video={mediaSource:r}:e.video.mediaSource=r,navigator.mediaDevices.getUserMedia(e)})}}},{"../utils":14,"./getusermedia":12}],12:[function(e,t,r){"use strict";var l=e("../utils"),h=l.log;t.exports=function(e){var i=l.detectBrowser(e),a=e&&e.navigator,t=e&&e.MediaStreamTrack,o=function(e){return{name:{InternalError:"NotReadableError",NotSupportedError:"TypeError",PermissionDeniedError:"NotAllowedError",SecurityError:"NotAllowedError"}[e.name]||e.name,message:{"The operation is insecure.":"The request is not allowed by the user agent or the platform in the current context."}[e.message]||e.message,constraint:e.constraint,toString:function(){return this.name+(this.message&&": ")+this.message}}},n=function(e,t,r){var n=function(n){if("object"!=typeof n||n.require)return n;var i=[];return Object.keys(n).forEach(function(e){if("require"!==e&&"advanced"!==e&&"mediaSource"!==e){var t=n[e]="object"==typeof n[e]?n[e]:{ideal:n[e]};if(void 0===t.min&&void 0===t.max&&void 0===t.exact||i.push(e),void 0!==t.exact&&("number"==typeof t.exact?t.min=t.max=t.exact:n[e]=t.exact,delete t.exact),void 0!==t.ideal){n.advanced=n.advanced||[];var r={};"number"==typeof t.ideal?r[e]={min:t.ideal,max:t.ideal}:r[e]=t.ideal,n.advanced.push(r),delete t.ideal,Object.keys(t).length||delete n[e]}}}),i.length&&(n.require=i),n};return e=JSON.parse(JSON.stringify(e)),i.version<38&&(h("spec: "+JSON.stringify(e)),e.audio&&(e.audio=n(e.audio)),e.video&&(e.video=n(e.video)),h("ff37: "+JSON.stringify(e))),a.mozGetUserMedia(e,t,function(e){r(o(e))})};if(a.mediaDevices||(a.mediaDevices={getUserMedia:function(r){return new Promise(function(e,t){n(r,e,t)})},addEventListener:function(){},removeEventListener:function(){}}),a.mediaDevices.enumerateDevices=a.mediaDevices.enumerateDevices||function(){return new Promise(function(e){e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})},i.version<41){var r=a.mediaDevices.enumerateDevices.bind(a.mediaDevices);a.mediaDevices.enumerateDevices=function(){return r().then(void 0,function(e){if("NotFoundError"===e.name)return[];throw e})}}if(i.version<49){var s=a.mediaDevices.getUserMedia.bind(a.mediaDevices);a.mediaDevices.getUserMedia=function(t){return s(t).then(function(e){if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(function(e){e.stop()}),new DOMException("The object can not be found here.","NotFoundError");return e},function(e){return Promise.reject(o(e))})}}if(!(55<i.version&&"autoGainControl"in a.mediaDevices.getSupportedConstraints())){var c=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},d=a.mediaDevices.getUserMedia.bind(a.mediaDevices);if(a.mediaDevices.getUserMedia=function(e){return"object"==typeof e&&"object"==typeof e.audio&&(e=JSON.parse(JSON.stringify(e)),c(e.audio,"autoGainControl","mozAutoGainControl"),c(e.audio,"noiseSuppression","mozNoiseSuppression")),d(e)},t&&t.prototype.getSettings){var u=t.prototype.getSettings;t.prototype.getSettings=function(){var e=u.apply(this,arguments);return c(e,"mozAutoGainControl","autoGainControl"),c(e,"mozNoiseSuppression","noiseSuppression"),e}}if(t&&t.prototype.applyConstraints){var p=t.prototype.applyConstraints;t.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==typeof e&&(e=JSON.parse(JSON.stringify(e)),c(e,"autoGainControl","mozAutoGainControl"),c(e,"noiseSuppression","mozNoiseSuppression")),p.apply(this,[e])}}}a.getUserMedia=function(e,t,r){if(i.version<44)return n(e,t,r);l.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),a.mediaDevices.getUserMedia(e).then(t,r)}}},{"../utils":14}],13:[function(e,t,r){"use strict";var o=e("../utils");t.exports={shimLocalStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),"getStreamById"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getStreamById=function(t){var r=null;return this._localStreams&&this._localStreams.forEach(function(e){e.id===t&&(r=e)}),this._remoteStreams&&this._remoteStreams.forEach(function(e){e.id===t&&(r=e)}),r}),!("addStream"in e.RTCPeerConnection.prototype)){var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(t){this._localStreams||(this._localStreams=[]),-1===this._localStreams.indexOf(t)&&this._localStreams.push(t);var r=this;t.getTracks().forEach(function(e){n.call(r,e,t)})},e.RTCPeerConnection.prototype.addTrack=function(e,t){return t&&(this._localStreams?-1===this._localStreams.indexOf(t)&&this._localStreams.push(t):this._localStreams=[t]),n.call(this,e,t)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);var t=this._localStreams.indexOf(e);if(-1!==t){this._localStreams.splice(t,1);var r=this,n=e.getTracks();this.getSenders().forEach(function(e){-1!==n.indexOf(e.track)&&r.removeTrack(e)})}})}},shimRemoteStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){this._onaddstream&&this.removeEventListener("addstream",this._onaddstream),this.addEventListener("addstream",this._onaddstream=e)}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach(function(e){if(r._remoteStreams||(r._remoteStreams=[]),!(0<=r._remoteStreams.indexOf(e))){r._remoteStreams.push(e);var t=new Event("addstream");t.stream=e,r.dispatchEvent(t)}})}),t.apply(r,arguments)}}},shimCallbacksAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,i=t.createOffer,a=t.createAnswer,o=t.setLocalDescription,s=t.setRemoteDescription,c=t.addIceCandidate;t.createOffer=function(e,t){var r=2<=arguments.length?arguments[2]:e,n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n},t.createAnswer=function(e,t){var r=2<=arguments.length?arguments[2]:e,n=a.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n};var r=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=r,r=function(e,t,r){var n=s.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=r,r=function(e,t,r){var n=c.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=r}},shimGetUserMedia:function(e){var n=e&&e.navigator;n.getUserMedia||(n.webkitGetUserMedia?n.getUserMedia=n.webkitGetUserMedia.bind(n):n.mediaDevices&&n.mediaDevices.getUserMedia&&(n.getUserMedia=function(e,t,r){n.mediaDevices.getUserMedia(e).then(t,r)}.bind(n)))},shimRTCIceServerUrls:function(e){var a=e.RTCPeerConnection;e.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var r=[],n=0;n<e.iceServers.length;n++){var i=e.iceServers[n];!i.hasOwnProperty("urls")&&i.hasOwnProperty("url")?(o.deprecated("RTCIceServer.url","RTCIceServer.urls"),(i=JSON.parse(JSON.stringify(i))).urls=i.url,delete i.url,r.push(i)):r.push(e.iceServers[n])}e.iceServers=r}return new a(e,t)},e.RTCPeerConnection.prototype=a.prototype,"generateCertificate"in e.RTCPeerConnection&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return a.generateCertificate}})},shimTrackEventTransceiver:function(e){"object"==typeof e&&e.RTCPeerConnection&&"receiver"in e.RTCTrackEvent.prototype&&!e.RTCTransceiver&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimCreateOfferLegacy:function(e){var i=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){var t=this;if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var r=t.getTransceivers().find(function(e){return e.sender.track&&"audio"===e.sender.track.kind});!1===e.offerToReceiveAudio&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveAudio||r||t.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var n=t.getTransceivers().find(function(e){return e.sender.track&&"video"===e.sender.track.kind});!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection("sendonly"):"recvonly"===n.direction&&n.setDirection("inactive"):!0!==e.offerToReceiveVideo||n||t.addTransceiver("video")}return i.apply(t,arguments)}}}},{"../utils":14}],14:[function(e,t,r){"use strict";var n=!0,i=!0;function a(e,t,r){var n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}t.exports={extractVersion:a,wrapPeerConnectionEvent:function(e,n,i){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,a=t.addEventListener;t.addEventListener=function(e,r){if(e!==n)return a.apply(this,arguments);var t=function(e){var t=i(e);t&&r(t)};return this._eventMap=this._eventMap||{},this._eventMap[r]=t,a.apply(this,[e,t])};var o=t.removeEventListener;t.removeEventListener=function(e,t){if(e!==n||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);var r=this._eventMap[t];return delete this._eventMap[t],o.apply(this,[e,r])},Object.defineProperty(t,"on"+n,{get:function(){return this["_on"+n]},set:function(e){this["_on"+n]&&(this.removeEventListener(n,this["_on"+n]),delete this["_on"+n]),e&&this.addEventListener(n,this["_on"+n]=e)},enumerable:!0,configurable:!0})}},disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(n=e)?"adapter.js logging disabled":"adapter.js logging enabled"},disableWarnings:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(i=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))},log:function(){if("object"==typeof window){if(n)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},deprecated:function(e,t){i&&console.warn(e+" is deprecated, please use "+t+" instead.")},detectBrowser:function(e){var t=e&&e.navigator,r={browser:null,version:null};if(void 0===e||!e.navigator)return r.browser="Not a browser.",r;if(t.mozGetUserMedia)r.browser="firefox",r.version=a(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia)r.browser="chrome",r.version=a(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))r.browser="edge",r.version=a(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return r.browser="Not a supported browser.",r;r.browser="safari",r.version=a(t.userAgent,/AppleWebKit\/(\d+)\./,1)}return r}}},{}],15:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.SUITES=r.TESTS=void 0,r.buildMicroSuite=function(e,t){var r=new p.default(m.MICROPHONE,e);t.includes(f.AUDIOCAPTURE)||r.add(new l.default(r,f.AUDIOCAPTURE,function(e){var t=new n.default(e);t.run()}));return r},r.buildCameraSuite=function(e,t){var r=new p.default(m.CAMERA,e);t.includes(f.CHECKRESOLUTION240)||r.add(new l.default(r,f.CHECKRESOLUTION240,function(e){var t=new a.default(e,[[320,240]]);t.run()}));t.includes(f.CHECKRESOLUTION480)||r.add(new l.default(r,f.CHECKRESOLUTION480,function(e){var t=new a.default(e,[[640,480]]);t.run()}));t.includes(f.CHECKRESOLUTION720)||r.add(new l.default(r,f.CHECKRESOLUTION720,function(e){var t=new a.default(e,[[1280,720]]);t.run()}));t.includes(f.CHECKSUPPORTEDRESOLUTIONS)||r.add(new l.default(r,f.CHECKSUPPORTEDRESOLUTIONS,function(e){var t=new a.default(e,[[160,120],[320,180],[320,240],[640,360],[640,480],[768,576],[1024,576],[1280,720],[1280,768],[1280,800],[1920,1080],[1920,1200],[3840,2160],[4096,2160]]);t.run()}));return r},r.buildNetworkSuite=function(e,t){var r=new p.default(m.NETWORK,e);t.includes(f.UDPENABLED)||r.add(new l.default(r,f.UDPENABLED,function(e){var t=new o.default(e,"udp",null,u.default.isRelay);t.run()}));t.includes(f.TCPENABLED)||r.add(new l.default(r,f.TCPENABLED,function(e){var t=new o.default(e,"tcp",null,u.default.isRelay);t.run()}));t.includes(f.IPV6ENABLED)||r.add(new l.default(r,f.IPV6ENABLED,function(e){var t=new o.default(e,null,{optional:[{googIPv6:!0}]},u.default.isIpv6);t.run()}));return r},r.buildConnectivitySuite=function(e,t){var r=new p.default(m.CONNECTIVITY,e);t.includes(f.RELAYCONNECTIVITY)||r.add(new l.default(r,f.RELAYCONNECTIVITY,function(e){var t=new i.default(e,u.default.isRelay);t.run()}));t.includes(f.REFLEXIVECONNECTIVITY)||r.add(new l.default(r,f.REFLEXIVECONNECTIVITY,function(e){var t=new i.default(e,u.default.isReflexive);t.run()}));t.includes(f.HOSTCONNECTIVITY)||r.add(new l.default(r,f.HOSTCONNECTIVITY,function(e){var t=new i.default(e,u.default.isHost);t.start()}));return r},r.buildThroughputSuite=function(e,t){var r=new p.default(m.THROUGHPUT,e);t.includes(f.DATATHROUGHPUT)||r.add(new l.default(r,f.DATATHROUGHPUT,function(e){var t=new s.default(e);t.run()}));t.includes(f.VIDEOBANDWIDTH)||r.add(new l.default(r,f.VIDEOBANDWIDTH,function(e){var t=new c.default(e);t.run()}));t.includes(f.NETWORKLATENCY)||r.add(new l.default(r,f.NETWORKLATENCY,function(e){var t=new d.default(e,u.default.isNotHostCandidate);t.run()}));t.includes(f.NETWORKLATENCYRELAY)||r.add(new l.default(r,f.NETWORKLATENCYRELAY,function(e){var t=new d.default(e,u.default.isRelay);t.run()}));return r};var n=h(e("../unit/mic.js")),i=h(e("../unit/conn.js")),a=h(e("../unit/camresolutions.js")),o=h(e("../unit/net.js")),s=h(e("../unit/dataBandwidth.js")),c=h(e("../unit/videoBandwidth.js")),d=h(e("../unit/wifiPeriodicScan.js")),u=h(e("../util/call.js")),p=h(e("./suite.js")),l=h(e("./testCase.js"));function h(e){return e&&e.__esModule?e:{default:e}}var f=r.TESTS={AUDIOCAPTURE:"Audio capture",CHECKRESOLUTION240:"Check resolution 320x240",CHECKRESOLUTION480:"Check resolution 640x480",CHECKRESOLUTION720:"Check resolution 1280x720",CHECKSUPPORTEDRESOLUTIONS:"Check supported resolutions",DATATHROUGHPUT:"Data throughput",IPV6ENABLED:"Ipv6 enabled",NETWORKLATENCY:"Network latency",NETWORKLATENCYRELAY:"Network latency - Relay",UDPENABLED:"Udp enabled",TCPENABLED:"Tcp enabled",VIDEOBANDWIDTH:"Video bandwidth",RELAYCONNECTIVITY:"Relay connectivity",REFLEXIVECONNECTIVITY:"Reflexive connectivity",HOSTCONNECTIVITY:"Host connectivity"},m=r.SUITES={CAMERA:"Camera",MICROPHONE:"Microphone",NETWORK:"Network",CONNECTIVITY:"Connectivity",THROUGHPUT:"Throughput"}},{"../unit/camresolutions.js":20,"../unit/conn.js":21,"../unit/dataBandwidth.js":22,"../unit/mic.js":23,"../unit/net.js":24,"../unit/videoBandwidth.js":25,"../unit/wifiPeriodicScan.js":26,"../util/call.js":29,"./suite.js":16,"./testCase.js":17}],16:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=function(){function r(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this.name=e,this.settings=t,this.tests=[]}return n(r,[{key:"getName",value:function(){return this.name}},{key:"getTests",value:function(){return this.tests}},{key:"add",value:function(e){this.tests.push(e)}}]),r}();r.default=i},{}],17:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var n=function(){function n(e,t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this.suite=e,this.settings=this.suite.settings,this.name=t,this.fn=r,this.progress=0,this.status="waiting",this.logs=[]}return i(n,[{key:"setProgress",value:function(e){this.progress=e,this.callbacks.onTestProgress(this.suite.name,this.name,e)}},{key:"getName",value:function(){return this.name}},{key:"getLogs",value:function(){return this.logs}},{key:"run",value:function(e,t){this.logs=[],this.status="waiting",this.callbacks=e,this.doneCallback=t,this.setProgress(0),this.fn(this)}},{key:"reportInfo",value:function(e){this.callbacks.onTestReport(this.suite.name,this.name,"info",e),this.logs.push({type:"info",message:e})}},{key:"reportSuccess",value:function(e){this.callbacks.onTestReport(this.suite.name,this.name,"success",e),this.logs.push({type:"success",message:e}),this.status="success"}},{key:"reportError",value:function(e){this.callbacks.onTestReport(this.suite.name,this.name,"error",e),this.logs.push({type:"error",message:e}),this.status="error"}},{key:"reportWarning",value:function(e){this.callbacks.onTestReport(this.suite.name,this.name,"warning",e),this.logs.push({type:"warning",message:e}),this.status="warning"}},{key:"reportFatal",value:function(e){this.callbacks.onTestReport(this.suite.name,this.name,"error",e),this.logs.push({type:"error",message:e}),this.status="error"}},{key:"done",value:function(){this.progress<100&&this.setProgress(100),this.callbacks.onTestResult(this.suite.name,this.name,this.status),this.doneCallback()}},{key:"doGetUserMedia",value:function(e,t,r){var n=this;try{navigator.mediaDevices.getUserMedia(e).then(function(e){n.getDeviceName_(e.getVideoTracks()),n.getDeviceName_(e.getAudioTracks());t.apply(this,arguments)}).catch(function(e){r?r.apply(this,arguments):n.reportFatal("Failed to get access to local media due to error: "+e.name)})}catch(e){return this.reportFatal("getUserMedia failed with exception: "+e.message)}}},{key:"setTimeoutWithProgressBar",value:function(e,t){var r=window.performance.now(),n=this,i=setInterval(function(){var e=window.performance.now();n.setProgress(100*(e-r)/t)},100),a=function(){clearInterval(i),n.setProgress(100),e()},o=setTimeout(a,t);return function(){clearTimeout(o),a()}}},{key:"getDeviceName_",value:function(e){return 0===e.length?null:e[0].label}}]),n}();r.default=n},{}],18:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}(),a=function(e){{if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}}(e("./config")),o=e("webrtc-adapter"),s=(n=o)&&n.__esModule?n:{default:n};function c(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.getTests(),t=this,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.callbacks,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(){return t.shouldStop},i=setTimeout.bind(null,function(){return n()?(t.shouldStop=!1,void r.onStopped()):(t._current+=1,r.onGlobalProgress(t._current,e.length-t._current),t._current===e.length?(t.state="completed",void r.onComplete()):void e[t._current].run(r,i))});i()}function d(){if(this._current=-1,this.suites=[],!this.filter.includes(this.SUITES.MICROPHONE)){var e=a.buildMicroSuite(this.config,this.filter);this.suites.push(e)}if(!this.filter.includes(this.SUITES.CAMERA)){var t=a.buildCameraSuite(this.config,this.filter);this.suites.push(t)}if(!this.filter.includes(this.SUITES.NETWORK)){var r=a.buildNetworkSuite(this.config,this.filter);this.suites.push(r)}if(!this.filter.includes(this.SUITES.CONNECTIVITY)){var n=a.buildConnectivitySuite(this.config,this.filter);this.suites.push(n)}if(!this.filter.includes(this.SUITES.THROUGHPUT)){var i=a.buildThroughputSuite(this.config,this.filter);this.suites.push(i)}}var u=function(){function r(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this.SUITES=a.SUITES,this.TESTS=a.TESTS,this.config=e,this.filter=t,this.state="stopped",this._current=-1,this.suites=[],this._runAllSequentially=c,this._initTests=d,this.callbacks={onTestProgress:function(){},onGlobalProgress:function(){},onTestResult:function(){},onTestReport:function(){},onStopped:function(){},onComplete:function(){}},this._initTests()}return i(r,[{key:"getSuites",value:function(){return this.suites}},{key:"getTests",value:function(){return this.suites.reduce(function(e,t){return e.concat(t.getTests())},[])}},{key:"onTestProgress",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){};this.callbacks.onTestProgress=e}},{key:"onGlobalProgress",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){};this.callbacks.onGlobalProgress=e}},{key:"onTestResult",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){};this.callbacks.onTestResult=e}},{key:"onTestReport",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){};this.callbacks.onTestReport=e}},{key:"onStopped",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){};this.callbacks.onStopped=e}},{key:"onComplete",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){};this.callbacks.onComplete=e}},{key:"start",value:function(){this.getTests();this.shouldStop=!1,this._current=-1,this.state="started",this._runAllSequentially()}},{key:"pause",value:function(){this.shouldStop=!0,this.state="paused"}},{key:"resume",value:function(){this.shouldStop=!1,this.state="started",this._runAllSequentially()}},{key:"stop",value:function(){this.shouldStop=!0,this._current=-1,this.state="stopped",this._initTests()}}]),r}();u.ADAPTER=s.default,u.SUITES=a.SUITES,u.TESTS=a.TESTS,window.TestRTC=u,r.default=u},{"./config":15,"webrtc-adapter":3}],19:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var s=i(e("../util/VideoFrameChecker.js")),c=i(e("../util/Call.js")),n=i(e("../util/report.js")),l=e("../util/util.js");function i(e){return e&&e.__esModule?e:{default:e}}var h=new n.default;function a(e,t){this.test=e,this.resolutions=t,this.currentResolution=0,this.isMuted=!1,this.isShuttingDown=!1}a.prototype={run:function(){this.startGetUserMedia(this.resolutions[this.currentResolution])},startGetUserMedia:function(t){var e={audio:!1,video:{width:{exact:t[0]},height:{exact:t[1]}}};navigator.mediaDevices.getUserMedia(e).then(function(e){1<this.resolutions.length?(this.test.reportSuccess("Supported: "+t[0]+"x"+t[1]),e.getTracks().forEach(function(e){e.stop()}),this.maybeContinueGetUserMedia()):this.collectAndAnalyzeStats_(e,t)}.bind(this)).catch(function(e){1<this.resolutions.length?this.test.reportInfo(t[0]+"x"+t[1]+" not supported"):this.test.reportError("getUserMedia failed with error: "+e.name),this.maybeContinueGetUserMedia()}.bind(this))},maybeContinueGetUserMedia:function(){this.currentResolution!==this.resolutions.length?(this.test.setProgress(this.currentResolution/this.resolutions.length*100),this.startGetUserMedia(this.resolutions[this.currentResolution++])):this.test.done()},collectAndAnalyzeStats_:function(e,t){var r=e.getVideoTracks();if(r.length<1)return this.test.reportError("No video track in returned stream."),void this.maybeContinueGetUserMedia();var n=r[0];"function"==typeof n.addEventListener&&(n.addEventListener("ended",function(){this.isShuttingDown||this.test.reportError("Video track ended, camera stopped working")}.bind(this)),n.addEventListener("mute",function(){this.isShuttingDown||(this.test.reportWarning("Your camera reported itself as muted."),this.isMuted=!0)}.bind(this)),n.addEventListener("unmute",function(){this.isShuttingDown||(this.test.reportInfo("Your camera reported itself as unmuted."),this.isMuted=!1)}.bind(this)));var i=document.createElement("video");i.setAttribute("autoplay",""),i.setAttribute("muted",""),i.width=t[0],i.height=t[1],i.srcObject=e;var a=new s.default(i),o=new c.default(null,this.test);o.pc1.addStream(e),o.establishConnection(),o.gatherStats(o.pc1,null,e,this.onCallEnded_.bind(this,t,i,e,a),100),this.test.setTimeoutWithProgressBar(this.endCall_.bind(this,o,e),8e3)},onCallEnded_:function(e,t,r,n,i,a){this.analyzeStats_(e,t,r,n,i,a),n.stop(),this.test.done()},analyzeStats_:function(e,t,r,n,i,a){var o=[],s=[],c=[],d={},u=n.frameStats;for(var p in i)"ssrc"===i[p].type&&0<parseInt(i[p].googFrameRateInput)&&(o.push(parseInt(i[p].googAvgEncodeMs)),s.push(parseInt(i[p].googFrameRateInput)),c.push(parseInt(i[p].googFrameRateSent)));d.cameraName=r.getVideoTracks()[0].label||NaN,d.actualVideoWidth=t.videoWidth,d.actualVideoHeight=t.videoHeight,d.mandatoryWidth=e[0],d.mandatoryHeight=e[1],d.encodeSetupTimeMs=this.extractEncoderSetupTime_(i,a),d.avgEncodeTimeMs=(0,l.arrayAverage)(o),d.minEncodeTimeMs=(0,l.arrayMin)(o),d.maxEncodeTimeMs=(0,l.arrayMax)(o),d.avgInputFps=(0,l.arrayAverage)(s),d.minInputFps=(0,l.arrayMin)(s),d.maxInputFps=(0,l.arrayMax)(s),d.avgSentFps=(0,l.arrayAverage)(c),d.minSentFps=(0,l.arrayMin)(c),d.maxSentFps=(0,l.arrayMax)(c),d.isMuted=this.isMuted,d.testedFrames=u.numFrames,d.blackFrames=u.numBlackFrames,d.frozenFrames=u.numFrozenFrames,h.traceEventInstant("video-stats",d),this.testExpectations_(d)},endCall_:function(e,t){this.isShuttingDown=!0,t.getTracks().forEach(function(e){e.stop()}),e.close()},extractEncoderSetupTime_:function(e,t){for(var r=0;r!==e.length;r++)if("ssrc"===e[r].type&&0<parseInt(e[r].googFrameRateInput))return JSON.stringify(t[r]-t[0]);return NaN},resolutionMatchesIndependentOfRotationOrCrop_:function(e,t,r,n){var i=Math.min(r,n);return e===r&&t===n||e===n&&t===r||e===i&&n===i},testExpectations_:function(e){var t=[];for(var r in e)e.hasOwnProperty(r)&&("number"==typeof e[r]&&isNaN(e[r])?t.push(r):this.test.reportInfo(r+": "+e[r]));0!==t.length&&this.test.reportInfo("Not available: "+t.join(", ")),isNaN(e.avgSentFps)?this.test.reportInfo("Cannot verify sent FPS."):e.avgSentFps<5?this.test.reportError("Low average sent FPS: "+e.avgSentFps):this.test.reportSuccess("Average FPS above threshold"),this.resolutionMatchesIndependentOfRotationOrCrop_(e.actualVideoWidth,e.actualVideoHeight,e.mandatoryWidth,e.mandatoryHeight)?this.test.reportSuccess("Captured video using expected resolution."):this.test.reportError("Incorrect captured resolution."),0===e.testedFrames?this.test.reportError("Could not analyze any video frame."):(e.blackFrames>e.testedFrames/3&&this.test.reportError("Camera delivering lots of black frames."),e.frozenFrames>e.testedFrames/3&&this.test.reportError("Camera delivering lots of frozen frames."))}},r.default=a},{"../util/Call.js":27,"../util/VideoFrameChecker.js":28,"../util/report.js":30,"../util/util.js":33}],20:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{"../util/Call.js":27,"../util/VideoFrameChecker.js":28,"../util/report.js":30,"../util/util.js":33,dup:19}],21:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("../util/Call.js"),a=(n=i)&&n.__esModule?n:{default:n};function o(e,t){this.test=e,this.iceCandidateFilter=t,this.timeout=null,this.parsedCandidates=[],this.call=null}o.prototype={run:function(){a.default.asyncCreateTurnConfig(this.start.bind(this),this.test.reportFatal.bind(this.test),this.test)},start:function(e){this.call=new a.default(e,this.test),this.call.setIceCandidateFilter(this.iceCandidateFilter),this.call.pc1.addEventListener("icecandidate",function(e){if(e.candidate){var t=a.default.parseCandidate(e.candidate.candidate);this.parsedCandidates.push(t),this.iceCandidateFilter(t)&&this.test.reportInfo("Gathered candidate of Type: "+t.type+" Protocol: "+t.protocol+" Address: "+t.address)}}.bind(this));var t=this.call.pc1.createDataChannel(null);t.addEventListener("open",function(){t.send("hello")}),t.addEventListener("message",function(e){"world"!==e.data?this.test.reportError("Invalid data transmitted."):this.test.reportSuccess("Data successfully transmitted between peers."),this.hangup()}.bind(this)),this.call.pc2.addEventListener("datachannel",function(e){var t=e.channel;t.addEventListener("message",function(e){"hello"!==e.data?this.hangup("Invalid data transmitted."):t.send("world")}.bind(this))}.bind(this)),this.call.establishConnection(),this.timeout=setTimeout(this.hangup.bind(this,"Timed out"),5e3)},findParsedCandidateOfSpecifiedType:function(e){for(var t in this.parsedCandidates)if(e(this.parsedCandidates[t]))return e(this.parsedCandidates[t])},hangup:function(e){e&&("Timed out"===e&&this.iceCandidateFilter.toString()===a.default.isReflexive.toString()&&this.findParsedCandidateOfSpecifiedType(a.default.isReflexive)?this.test.reportWarning("Could not connect using reflexive candidates, likely due to the network environment/configuration."):this.test.reportError(e)),clearTimeout(this.timeout),this.call.close(),this.test.done()}},r.default=o},{"../util/Call.js":27}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("../util/Call.js"),a=(n=i)&&n.__esModule?n:{default:n};function o(e){this.test=e,this.testDurationSeconds=5,this.startTime=null,this.sentPayloadBytes=0,this.receivedPayloadBytes=0,this.stopSending=!1,this.samplePacket="";for(var t=0;1024!==t;++t)this.samplePacket+="h";this.maxNumberOfPacketsToSend=1,this.bytesToKeepBuffered=1024*this.maxNumberOfPacketsToSend,this.lastBitrateMeasureTime=null,this.lastReceivedPayloadBytes=0,this.call=null,this.senderChannel=null,this.receiveChannel=null}o.prototype={run:function(){a.default.asyncCreateTurnConfig(this.start.bind(this),this.test.reportFatal.bind(this.test),this.test)},start:function(e){this.call=new a.default(e,this.test),this.call.setIceCandidateFilter(a.default.isRelay),this.senderChannel=this.call.pc1.createDataChannel(null),this.senderChannel.addEventListener("open",this.sendingStep.bind(this)),this.call.pc2.addEventListener("datachannel",this.onReceiverChannel.bind(this)),this.call.establishConnection()},onReceiverChannel:function(e){this.receiveChannel=e.channel,this.receiveChannel.addEventListener("message",this.onMessageReceived.bind(this))},sendingStep:function(){var e=new Date;this.startTime||(this.startTime=e,this.lastBitrateMeasureTime=e);for(var t=0;t!==this.maxNumberOfPacketsToSend&&!(this.senderChannel.bufferedAmount>=this.bytesToKeepBuffered);++t)this.sentPayloadBytes+=this.samplePacket.length,this.senderChannel.send(this.samplePacket);e-this.startTime>=1e3*this.testDurationSeconds?(this.test.setProgress(100),this.stopSending=!0):(this.test.setProgress((e-this.startTime)/(10*this.testDurationSeconds)),setTimeout(this.sendingStep.bind(this),1))},onMessageReceived:function(e){this.receivedPayloadBytes+=e.data.length;var t=new Date;if(1e3<=t-this.lastBitrateMeasureTime){var r=(this.receivedPayloadBytes-this.lastReceivedPayloadBytes)/(t-this.lastBitrateMeasureTime);r=Math.round(1e3*r*8)/1e3,this.test.reportSuccess("Transmitting at "+r+" kbps."),this.lastReceivedPayloadBytes=this.receivedPayloadBytes,this.lastBitrateMeasureTime=t}if(this.stopSending&&this.sentPayloadBytes===this.receivedPayloadBytes){this.call.close(),this.call=null;var n=Math.round(10*(t-this.startTime))/1e4,i=8*this.receivedPayloadBytes/1e3;this.test.reportSuccess("Total transmitted: "+i+" kilo-bits in "+n+" seconds."),this.test.done()}}},r.default=o},{"../util/Call.js":27}],23:[function(e,t,r){"use strict";function n(e){this.test=e,this.inputChannelCount=6,this.outputChannelCount=2,this.bufferSize=0,this.constraints={audio:{optional:[{echoCancellation:!1}]}},this.collectSeconds=2,this.silentThreshold=1/32767,this.lowVolumeThreshold=-60,this.monoDetectThreshold=1/65536,this.clipCountThreshold=6,this.clipThreshold=1,this.collectedAudio=[];for(var t=this.collectedSampleCount=0;t<this.inputChannelCount;++t)this.collectedAudio[t]=[];try{window.AudioContext=window.AudioContext||window.webkitAudioContext,this.audioContext=new AudioContext}catch(e){console.error("Failed to instantiate an audio context, error: "+e)}}Object.defineProperty(r,"__esModule",{value:!0}),n.prototype={run:function(){void 0===this.audioContext?(this.test.reportError("WebAudio is not supported, test cannot run."),this.test.done()):this.test.doGetUserMedia(this.constraints,this.gotStream.bind(this))},gotStream:function(e){this.checkAudioTracks(e)?this.createAudioBuffer(e):this.test.done()},checkAudioTracks:function(e){var t=(this.stream=e).getAudioTracks();return t.length<1?(this.test.reportError("No audio track in returned stream."),!1):(this.test.reportSuccess("Audio track created using device="+t[0].label),!0)},createAudioBuffer:function(){this.audioSource=this.audioContext.createMediaStreamSource(this.stream),this.scriptNode=this.audioContext.createScriptProcessor(this.bufferSize,this.inputChannelCount,this.outputChannelCount),this.audioSource.connect(this.scriptNode),this.scriptNode.connect(this.audioContext.destination),this.scriptNode.onaudioprocess=this.collectAudio.bind(this),this.stopCollectingAudio=this.test.setTimeoutWithProgressBar(this.onStopCollectingAudio.bind(this),5e3)},collectAudio:function(e){for(var t=e.inputBuffer.length,r=!0,n=0;n<e.inputBuffer.numberOfChannels;n++){var i,a=e.inputBuffer.getChannelData(n),o=Math.abs(a[0]),s=Math.abs(a[t-1]);o>this.silentThreshold||s>this.silentThreshold?((i=new Float32Array(t)).set(a),r=!1):i=new Float32Array,this.collectedAudio[n].push(i)}r||(this.collectedSampleCount+=t,this.collectedSampleCount/e.inputBuffer.sampleRate>=this.collectSeconds&&this.stopCollectingAudio())},onStopCollectingAudio:function(){this.stream.getAudioTracks()[0].stop(),this.audioSource.disconnect(this.scriptNode),this.scriptNode.disconnect(this.audioContext.destination),this.analyzeAudio(this.collectedAudio),this.test.done()},analyzeAudio:function(e){for(var t=[],r=0;r<e.length;r++)this.channelStats(r,e[r])&&t.push(r);0===t.length?this.test.reportError("No active input channels detected. Microphone is most likely muted or broken, please check if muted in the sound settings or physically on the device. Then rerun the test."):this.test.reportSuccess("Active audio input channels: "+t.length),2===t.length&&this.detectMono(e[t[0]],e[t[1]])},channelStats:function(e,t){for(var r=0,n=0,i=0,a=0,o=0;o<t.length;o++){var s=t[o];if(0<s.length){for(var c=0,d=0,u=0;u<s.length;u++)d+=(c=Math.abs(s[u]))*c,(r=Math.max(r,c))>=this.clipThreshold?(i++,a=Math.max(a,i)):i=0;d=Math.sqrt(d/s.length),n=Math.max(n,d)}}if(r>this.silentThreshold){var p=this.dBFS(r),l=this.dBFS(n);return this.test.reportInfo("Channel "+e+" levels: "+p.toFixed(1)+" dB (peak), "+l.toFixed(1)+" dB (RMS)"),l<this.lowVolumeThreshold&&this.test.reportError("Microphone input level is low, increase input volume or move closer to the microphone."),a>this.clipCountThreshold&&this.test.reportWarning("Clipping detected! Microphone input level is high. Decrease input volume or move away from the microphone."),!0}return!1},detectMono:function(e,t){for(var r=0,n=0;n<e.length;n++){var i=e[n],a=t[n];if(i.length===a.length)for(var o=0;o<i.length;o++)Math.abs(i[o]-a[o])>this.monoDetectThreshold&&r++;else r++}0<r?this.test.reportInfo("Stereo microphone detected."):this.test.reportInfo("Mono microphone detected.")},dBFS:function(e){var t=20*Math.log(e)/Math.log(10);return Math.round(10*t)/10}},r.default=n},{}],24:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("../util/Call.js"),a=(n=i)&&n.__esModule?n:{default:n};var o=function(e,t,r,n){this.test=e,this.protocol=t,this.params=r,this.iceCandidateFilter=n};o.prototype={run:function(){this.iceCandidateFilter.toString()===a.default.isIpv6.toString()?this.gatherCandidates(null,this.params,this.iceCandidateFilter):a.default.asyncCreateTurnConfig(this.start.bind(this),this.test.reportFatal.bind(this.test),this.test)},start:function(e){this.filterConfig(e,this.protocol),this.gatherCandidates(e,this.params,this.iceCandidateFilter)},filterConfig:function(e,t){for(var r="transport="+t,n=[],i=0;i<e.iceServers.length;++i){for(var a=e.iceServers[i],o=[],s=0;s<a.urls.length;++s){var c=a.urls[s];-1!==c.indexOf(r)?o.push(c):-1===c.indexOf("?transport=")&&c.startsWith("turn")&&o.push(c+"?"+r)}0!==o.length&&(a.urls=o,n.push(a))}e.iceServers=n},gatherCandidates:function(e,r,n){var i;try{i=new RTCPeerConnection(e,r)}catch(e){return null!==r&&r.optional[0].googIPv6?this.test.reportWarning("Failed to create peer connection, IPv6 might not be setup/supported on the network."):this.test.reportError("Failed to create peer connection: "+e),void this.test.done()}i.addEventListener("icecandidate",function(e){if("closed"!==e.currentTarget.signalingState)if(e.candidate){var t=a.default.parseCandidate(e.candidate.candidate);n(t)&&(this.test.reportSuccess("Gathered candidate of Type: "+t.type+" Protocol: "+t.protocol+" Address: "+t.address),i.close(),i=null,this.test.done())}else i.close(),(i=null)!==r&&r.optional[0].googIPv6?this.test.reportWarning("Failed to gather IPv6 candidates, it might not be setup/supported on the network."):this.test.reportError("Failed to gather specified candidates"),this.test.done()}.bind(this)),this.createAudioOnlyReceiveOffer(i)},createAudioOnlyReceiveOffer:function(t){function r(){}t.createOffer({offerToReceiveAudio:1}).then(function(e){t.setLocalDescription(e).then(r,r)},r)}},r.default=o},{"../util/Call.js":27}],25:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=a(e("webrtc-adapter")),n=a(e("../util/stats.js")),i=a(e("../util/call.js"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e){this.test=e,this.maxVideoBitrateKbps=2e3,this.durationMs=4e4,this.statStepMs=100,this.bweStats=new n.default(.75*this.maxVideoBitrateKbps*1e3),this.rttStats=new n.default,this.packetsLost=-1,this.nackCount=-1,this.pliCount=-1,this.qpSum=-1,this.packetsSent=-1,this.packetsReceived=-1,this.framesEncoded=-1,this.framesDecoded=-1,this.framesSent=-1,this.bytesSent=-1,this.videoStats=[],this.startTime=null,this.call=null,this.constraints={audio:!1,video:{optional:[{minWidth:1280},{minHeight:720}]}}}s.prototype={run:function(){i.default.asyncCreateTurnConfig(this.start.bind(this),this.test.reportFatal.bind(this.test),this.test)},start:function(e){this.call=new i.default(e,this.test),this.call.setIceCandidateFilter(i.default.isRelay),this.call.disableVideoFec(),this.call.constrainVideoBitrate(this.maxVideoBitrateKbps),this.test.doGetUserMedia(this.constraints,this.gotStream.bind(this))},gotStream:function(e){this.call.pc1.addStream(e),this.call.establishConnection(),this.startTime=new Date,this.localStream=e.getVideoTracks()[0],setTimeout(this.gatherStats.bind(this),this.statStepMs)},gatherStats:function(){var e=new Date;if(e-this.startTime>this.durationMs)return this.test.setProgress(100),void this.hangup();this.call.statsGatheringRunning||this.call.gatherStats(this.call.pc1,this.call.pc2,this.localStream,this.gotStats.bind(this)),this.test.setProgress(100*(e-this.startTime)/this.durationMs),setTimeout(this.gatherStats.bind(this),this.statStepMs)},gotStats:function(e,t,r,n){if("chrome"===o.default.browserDetails.browser)for(var i in e)void 0!==e[i].connection&&(this.bweStats.add(e[i].connection.timestamp,parseInt(e[i].connection.availableOutgoingBitrate)),this.rttStats.add(e[i].connection.timestamp,parseInt(1e3*e[i].connection.currentRoundTripTime)),this.videoStats[0]=e[i].video.local.frameWidth,this.videoStats[1]=e[i].video.local.frameHeight,this.nackCount=e[i].video.local.nackCount,this.packetsLost=r[i].video.remote.packetsLost,this.qpSum=r[i].video.remote.qpSum,this.pliCount=e[i].video.local.pliCount,this.packetsSent=e[i].video.local.packetsSent,this.packetsReceived=r[i].video.remote.packetsReceived,this.framesEncoded=e[i].video.local.framesEncoded,this.framesDecoded=r[i].video.remote.framesDecoded);else if("firefox"===o.default.browserDetails.browser)for(var a in e)"outbound_rtcp_video_0"===e[a].id?(this.rttStats.add(Date.parse(e[a].timestamp),parseInt(e[a].mozRtt)),this.jitter=e[a].jitter,this.packetsLost=e[a].packetsLost):"outbound_rtp_video_0"===e[a].id&&(this.videoStats[0]="Not supported on Firefox",this.videoStats[1]="Not supported on Firefox",this.bitrateMean=e[a].bitrateMean,this.bitrateStdDev=e[a].bitrateStdDev,this.framerateMean=e[a].framerateMean);else this.test.reportError("Only Firefox and Chrome getStats implementations are supported.");this.completed()},hangup:function(){this.call.pc1.getLocalStreams()[0].getTracks().forEach(function(e){e.stop()}),this.call.close(),this.call=null},completed:function(){"chrome"===o.default.browserDetails.browser?this.videoStats[0]<2&&this.videoStats[1]<2?this.test.reportError("Camera failure: "+this.videoStats[0]+"x"+this.videoStats[1]+". Cannot test bandwidth without a working  camera."):(this.test.reportSuccess("Video resolution: "+this.videoStats[0]+"x"+this.videoStats[1]),this.test.reportInfo("Send bandwidth estimate average: "+Math.round(this.bweStats.getAverage()/1e3)+" kbps"),this.test.reportInfo("Send bandwidth estimate max: "+this.bweStats.getMax()/1e3+" kbps"),this.test.reportInfo("Send bandwidth ramp-up time: "+this.bweStats.getRampUpTime()+" ms"),this.test.reportInfo("Packets sent: "+this.packetsSent),this.test.reportInfo("Packets received: "+this.packetsReceived),this.test.reportInfo("NACK count: "+this.nackCount),this.test.reportInfo("Picture loss indications: "+this.pliCount),this.test.reportInfo("Quality predictor sum: "+this.qpSum),this.test.reportInfo("Frames encoded: "+this.framesEncoded),this.test.reportInfo("Frames decoded: "+this.framesDecoded)):"firefox"===o.default.browserDetails.browser&&(0<parseInt(this.framerateMean)?this.test.reportSuccess("Frame rate mean: "+parseInt(this.framerateMean)):this.test.reportError("Frame rate mean is 0, cannot test bandwidth without a working camera."),this.test.reportInfo("Send bitrate mean: "+parseInt(this.bitrateMean)/1e3+" kbps"),this.test.reportInfo("Send bitrate standard deviation: "+parseInt(this.bitrateStdDev)/1e3+" kbps")),this.test.reportInfo("RTT average: "+this.rttStats.getAverage()+" ms"),this.test.reportInfo("RTT max: "+this.rttStats.getMax()+" ms"),this.test.reportInfo("Packets lost: "+this.packetsLost),this.test.done()}},r.default=s},{"../util/call.js":29,"../util/stats.js":32,"webrtc-adapter":3}],26:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=o(e("../util/call.js")),i=o(e("../util/report.js")),a=e("../util/util.js");function o(e){return e&&e.__esModule?e:{default:e}}var s=new i.default;function c(e,t){this.test=e,this.candidateFilter=t,this.testDurationMs=3e5,this.sendIntervalMs=100,this.delays=[],this.recvTimeStamps=[],this.running=!1,this.call=null,this.senderChannel=null,this.receiveChannel=null}c.prototype={run:function(){n.default.asyncCreateTurnConfig(this.start.bind(this),this.test.reportFatal.bind(this.test),this.test)},start:function(e){this.running=!0,this.call=new n.default(e,this.test),this.call.setIceCandidateFilter(this.candidateFilter),this.senderChannel=this.call.pc1.createDataChannel({ordered:!1,maxRetransmits:0}),this.senderChannel.addEventListener("open",this.send.bind(this)),this.call.pc2.addEventListener("datachannel",this.onReceiverChannel.bind(this)),this.call.establishConnection(),this.test.setTimeoutWithProgressBar(this.finishTest.bind(this),this.testDurationMs)},onReceiverChannel:function(e){this.receiveChannel=e.channel,this.receiveChannel.addEventListener("message",this.receive.bind(this))},send:function(){this.running&&(this.senderChannel.send(""+Date.now()),setTimeout(this.send.bind(this),this.sendIntervalMs))},receive:function(e){if(this.running){var t=parseInt(e.data),r=Date.now()-t;this.recvTimeStamps.push(t),this.delays.push(r)}},finishTest:function(){s.traceEventInstant("periodic-delay",{delays:this.delays,recvTimeStamps:this.recvTimeStamps}),this.running=!1,this.call.close(),this.call=null;var e=(0,a.arrayAverage)(this.delays),t=(0,a.arrayMax)(this.delays),r=(0,a.arrayMin)(this.delays);this.test.reportInfo("Average delay: "+e+" ms."),this.test.reportInfo("Min delay: "+r+" ms."),this.test.reportInfo("Max delay: "+t+" ms."),this.delays.length<.8*this.testDurationMs/this.sendIntervalMs?this.test.reportError("Not enough samples gathered. Keep the page on  the foreground while the test is running."):this.test.reportSuccess("Collected "+this.delays.length+" delay samples."),2*(r+100)<t&&this.test.reportError("There is a big difference between the min and max delay of packets. Your network appears unstable."),this.test.done()}},r.default=c},{"../util/call.js":29,"../util/report.js":30,"../util/util.js":33}],27:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var h=i(e("webrtc-adapter")),n=i(e("./report.js")),f=e("./util.js");function i(e){return e&&e.__esModule?e:{default:e}}var a=new n.default;function o(e,t){this.test=t,this.traceEvent=a.traceEventAsync("call"),this.traceEvent({config:e}),this.statsGatheringRunning=!1,this.pc1=new RTCPeerConnection(e),this.pc2=new RTCPeerConnection(e),this.pc1.addEventListener("icecandidate",this.onIceCandidate_.bind(this,this.pc2)),this.pc2.addEventListener("icecandidate",this.onIceCandidate_.bind(this,this.pc1)),this.iceCandidateFilter_=o.noFilter}o.prototype={establishConnection:function(){this.traceEvent({state:"start"}),this.pc1.createOffer().then(this.gotOffer_.bind(this),this.test.reportFatal.bind(this.test))},close:function(){this.traceEvent({state:"end"}),this.pc1.close(),this.pc2.close()},setIceCandidateFilter:function(e){this.iceCandidateFilter_=e},constrainVideoBitrate:function(e){this.constrainVideoBitrateKbps_=e},disableVideoFec:function(){this.constrainOfferToRemoveVideoFec_=!0},gatherStats:function(e,t,r,n){var i=[],a=[],o=[],s=[],c=this,d=100;function u(){if("closed"===e.signalingState)return c.statsGatheringRunning=!1,void n(i,o,a,s);e.getStats().then(l).catch(function(e){c.test.reportError("Could not gather stats: "+e),c.statsGatheringRunning=!1,n(i,o)}.bind(c)),t&&t.getStats().then(p)}function p(e){if("chrome"===h.default.browserDetails.browser){var t=(0,f.enumerateStats)(e,c.localTrackIds,c.remoteTrackIds);a.push(t),s.push(Date.now())}else if("firefox"===h.default.browserDetails.browser)for(var r in e){var n=e[r];a.push(n),s.push(Date.now())}else c.test.reportError("Only Firefox and Chrome getStats implementations are supported.")}function l(e){if("chrome"===h.default.browserDetails.browser){var t=(0,f.enumerateStats)(e,c.localTrackIds,c.remoteTrackIds);i.push(t),o.push(Date.now())}else if("firefox"===h.default.browserDetails.browser)for(var r in e){var n=e[r];i.push(n),o.push(Date.now())}else c.test.reportError("Only Firefox and Chrome getStats implementations are supported.");setTimeout(u,d)}c.localTrackIds={audio:"",video:""},c.remoteTrackIds={audio:"",video:""},e.getSenders().forEach(function(e){"audio"===e.track.kind?c.localTrackIds.audio=e.track.id:"video"===e.track.kind&&(c.localTrackIds.video=e.track.id)}.bind(c)),t&&t.getReceivers().forEach(function(e){"audio"===e.track.kind?c.remoteTrackIds.audio=e.track.id:"video"===e.track.kind&&(c.remoteTrackIds.video=e.track.id)}.bind(c)),this.statsGatheringRunning=!0,u()},gotOffer_:function(e){this.constrainOfferToRemoveVideoFec_&&(e.sdp=e.sdp.replace(/(m=video 1 [^\r]+)(116 117)(\r\n)/g,"$1\r\n"),e.sdp=e.sdp.replace(/a=rtpmap:116 red\/90000\r\n/g,""),e.sdp=e.sdp.replace(/a=rtpmap:117 ulpfec\/90000\r\n/g,""),e.sdp=e.sdp.replace(/a=rtpmap:98 rtx\/90000\r\n/g,""),e.sdp=e.sdp.replace(/a=fmtp:98 apt=116\r\n/g,"")),this.pc1.setLocalDescription(e),this.pc2.setRemoteDescription(e),this.pc2.createAnswer().then(this.gotAnswer_.bind(this),this.test.reportFatal.bind(this.test))},gotAnswer_:function(e){this.constrainVideoBitrateKbps_&&(e.sdp=e.sdp.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+this.constrainVideoBitrateKbps_+"\r\n")),this.pc2.setLocalDescription(e),this.pc1.setRemoteDescription(e)},onIceCandidate_:function(e,t){if(t.candidate){var r=o.parseCandidate(t.candidate.candidate);this.iceCandidateFilter_(r)&&e.addIceCandidate(t.candidate)}}},o.noFilter=function(){return!0},o.isRelay=function(e){return"relay"===e.type},o.isNotHostCandidate=function(e){return"host"!==e.type},o.isReflexive=function(e){return"srflx"===e.type},o.isHost=function(e){return"host"===e.type},o.isIpv6=function(e){return-1!==e.address.indexOf(":")},o.parseCandidate=function(e){var t="candidate:",r=e.indexOf(t)+t.length,n=e.substr(r).split(" ");return{type:n[7],protocol:n[2],address:n[4]}},o.cachedIceServers_=null,o.cachedIceConfigFetchTime_=null,o.asyncCreateTurnConfig=function(e,t,r){var n=r.settings,i={iceServers:[{username:n.turnUsername||"",credential:n.turnCredential||"",urls:n.turnURI.split(",")}]};a.traceEventInstant("turn-config",i),setTimeout(e.bind(null,i),0)},o.asyncCreateStunConfig=function(e,t){var r={iceServers:[{urls:currentTest.settings.stunURI.split(",")}]};a.traceEventInstant("stun-config",r),setTimeout(e.bind(null,r),0)},r.default=o},{"./report.js":30,"./util.js":33,"webrtc-adapter":3}],28:[function(e,t,r){"use strict";var n,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=e("./ssim.js"),o=(n=a)&&n.__esModule?n:{default:n};function s(e){this.frameStats={numFrozenFrames:0,numBlackFrames:0,numFrames:0},this.running_=!0,this.nonBlackPixelLumaThreshold=20,this.previousFrame_=[],this.identicalFrameSsimThreshold=.985,this.frameComparator=new o.default,this.canvas_=document.createElement("canvas"),this.videoElement_=e,this.listener_=this.checkVideoFrame_.bind(this),this.videoElement_.addEventListener("play",this.listener_,!1)}s.prototype={stop:function(){this.videoElement_.removeEventListener("play",this.listener_),this.running_=!1},getCurrentImageData_:function(){this.canvas_.width=this.videoElement_.width,this.canvas_.height=this.videoElement_.height;var e=this.canvas_.getContext("2d");return e.drawImage(this.videoElement_,0,0,this.canvas_.width,this.canvas_.height),e.getImageData(0,0,this.canvas_.width,this.canvas_.height)},checkVideoFrame_:function(){if(this.running_&&!this.videoElement_.ended){var e=this.getCurrentImageData_();this.isBlackFrame_(e.data,e.data.length)&&this.frameStats.numBlackFrames++,this.frameComparator.calculate(this.previousFrame_,e.data)>this.identicalFrameSsimThreshold&&this.frameStats.numFrozenFrames++,this.previousFrame_=e.data,this.frameStats.numFrames++,setTimeout(this.checkVideoFrame_.bind(this),20)}},isBlackFrame_:function(e,t){for(var r=this.nonBlackPixelLumaThreshold,n=0,i=4;i<t;i+=4)if(r*i/4<(n+=.21*e[i]+.72*e[i+1]+.07*e[i+2]))return!1;return!0}},"object"===(void 0===r?"undefined":i(r))&&(t.exports=s)},{"./ssim.js":31}],29:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{"./report.js":30,"./util.js":33,dup:27,"webrtc-adapter":3}],30:[function(e,t,r){"use strict";function n(){this.output_=[],this.nextAsyncId_=0,this.nativeLog_=console.log.bind(console),console.log=this.logHook_.bind(this),window.addEventListener("error",this.onWindowError_.bind(this)),this.traceEventInstant("system-info",n.getSystemInfo())}Object.defineProperty(r,"__esModule",{value:!0}),n.prototype={traceEventInstant:function(e,t){this.output_.push({ts:Date.now(),name:e,args:t})},traceEventWithId:function(e,t,r){this.output_.push({ts:Date.now(),name:e,id:t,args:r})},traceEventAsync:function(e){return this.traceEventWithId.bind(this,e,this.nextAsyncId_++)},logTestRunResult:function(e,t){ga("send",{hitType:"event",eventCategory:"Test",eventAction:t,eventLabel:e,nonInteraction:1})},generate:function(e){var t={title:"WebRTC Troubleshooter bug report",description:e||null};return this.getContent_(t)},getContent_:function(e){var t=[];return this.appendEventsAsString_([e],t),this.appendEventsAsString_(this.output_,t),"["+t.join(",\n")+"]"},appendEventsAsString_:function(e,t){for(var r=0;r!==e.length;++r)t.push(JSON.stringify(e[r]))},onWindowError_:function(e){this.traceEventInstant("error",{message:e.message,filename:e.filename+":"+e.lineno})},logHook_:function(){this.traceEventInstant("log",arguments),this.nativeLog_.apply(null,arguments)}},n.getSystemInfo=function(){var e,t,r,n=navigator.userAgent,i=navigator.appName,a=""+parseFloat(navigator.appVersion);return-1!==(t=n.indexOf("Chrome"))?(i="Chrome",a=n.substring(t+7)):-1!==(t=n.indexOf("MSIE"))?(i="Microsoft Internet Explorer",a=n.substring(t+5)):-1!==(t=n.indexOf("Trident"))?(i="Microsoft Internet Explorer",a=n.substring(t+8)):-1!==(t=n.indexOf("Firefox"))?i="Firefox":-1!==(t=n.indexOf("Safari"))?(i="Safari",a=n.substring(t+7),-1!==(t=n.indexOf("Version"))&&(a=n.substring(t+8))):(e=n.lastIndexOf(" ")+1)<(t=n.lastIndexOf("/"))&&(i=n.substring(e,t),a=n.substring(t+1),i.toLowerCase()===i.toUpperCase()&&(i=navigator.appName)),-1!==(r=a.indexOf(";"))&&(a=a.substring(0,r)),-1!==(r=a.indexOf(" "))&&(a=a.substring(0,r)),{browserName:i,browserVersion:a,platform:navigator.platform}},r.default=n},{}],31:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function i(){}i.prototype={statistics:function(e){var t,r=0;for(t=0;t<e.length;++t)r+=e[t];var n=r/(e.length-1),i=0;for(t=1;t<e.length;++t)i=e[t-1]-n,r+=e[t]+i*i;return{mean:n,variance:r/e.length}},covariance:function(e,t,r,n){for(var i=0,a=0;a<e.length;a+=1)i+=(e[a]-r)*(t[a]-n);return i/e.length},calculate:function(e,t){if(e.length!==t.length)return 0;var r=6.502500000000001,n=.03*255*(.03*255),i=n/2,a=this.statistics(e),o=a.mean,s=a.variance,c=Math.sqrt(s),d=this.statistics(t),u=d.mean,p=d.variance,l=Math.sqrt(p);return(2*o*u+r)/(o*o+u*u+r)*((2*c*l+n)/(s+p+n))*((this.covariance(e,t,o,u)+i)/(c*l+i))}},"object"===(void 0===r?"undefined":n(r))&&(t.exports=i)},{}],32:[function(e,t,r){"use strict";function n(e){this.startTime_=0,this.sum_=0,this.count_=0,this.max_=0,this.rampUpThreshold_=e,this.rampUpTime_=1/0}Object.defineProperty(r,"__esModule",{value:!0}),n.prototype={add:function(e,t){0===this.startTime_&&(this.startTime_=e),this.sum_+=t,this.max_=Math.max(this.max_,t),this.rampUpTime_===1/0&&t>this.rampUpThreshold_&&(this.rampUpTime_=e),this.count_++},getAverage:function(){return 0===this.count_?0:Math.round(this.sum_/this.count_)},getMax:function(){return this.max_},getRampUpTime:function(){return Math.round(this.rampUpTime_-this.startTime_)}},r.default=n},{}],33:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.arrayAverage=function(e){for(var t=e.length,r=0,n=0;n<t;n++)r+=e[n];return Math.floor(r/t)},r.arrayMax=function(e){if(0===e.length)return NaN;return Math.max.apply(Math,e)},r.arrayMin=function(e){if(0===e.length)return NaN;return Math.min.apply(Math,e)},r.enumerateStats=function(e,r,n){var i={audio:{local:{audioLevel:0,bytesSent:0,clockRate:0,codecId:"",mimeType:"",packetsSent:0,payloadType:0,timestamp:0,trackId:"",transportId:""},remote:{audioLevel:0,bytesReceived:0,clockRate:0,codecId:"",fractionLost:0,jitter:0,mimeType:"",packetsLost:-1,packetsReceived:0,payloadType:0,timestamp:0,trackId:"",transportId:""}},video:{local:{bytesSent:0,clockRate:0,codecId:"",firCount:0,framesEncoded:0,frameHeight:0,framesSent:-1,frameWidth:0,nackCount:0,packetsSent:-1,payloadType:0,pliCount:0,qpSum:0,timestamp:0,trackId:"",transportId:""},remote:{bytesReceived:-1,clockRate:0,codecId:"",firCount:-1,fractionLost:0,frameHeight:0,framesDecoded:0,framesDropped:0,framesReceived:0,frameWidth:0,nackCount:-1,packetsLost:-1,packetsReceived:0,payloadType:0,pliCount:-1,qpSum:0,timestamp:0,trackId:"",transportId:""}},connection:{availableOutgoingBitrate:0,bytesReceived:0,bytesSent:0,consentRequestsSent:0,currentRoundTripTime:0,localCandidateId:"",localCandidateType:"",localIp:"",localPort:0,localPriority:0,localProtocol:"",remoteCandidateId:"",remoteCandidateType:"",remoteIp:"",remotePort:0,remotePriority:0,remoteProtocol:"",requestsReceived:0,requestsSent:0,responsesReceived:0,responsesSent:0,timestamp:0,totalRoundTripTime:0}};e&&(e.forEach(function(e,t){switch(e.type){case"outbound-rtp":e.hasOwnProperty("trackId")&&(1!==e.trackId.indexOf(r.audio)&""!==r.audio?(i.audio.local.bytesSent=e.bytesSent,i.audio.local.codecId=e.codecId,i.audio.local.packetsSent=e.packetsSent,i.audio.local.timestamp=e.timestamp,i.audio.local.trackId=e.trackId,i.audio.local.transportId=e.transportId):1!==e.trackId.indexOf(r.video)&""!==r.video&&(i.video.local.bytesSent=e.bytesSent,i.video.local.codecId=e.codecId,i.video.local.firCount=e.firCount,i.video.local.framesEncoded=e.framesEncoded,i.video.local.framesSent=e.framesSent,i.video.local.packetsSent=e.packetsSent,i.video.local.pliCount=e.pliCount,i.video.local.qpSum=e.qpSum,i.video.local.timestamp=e.timestamp,i.video.local.trackId=e.trackId,i.video.local.transportId=e.transportId));break;case"inbound-rtp":e.hasOwnProperty("trackId")&&(1!==e.trackId.indexOf(n.audio)&""!==n.audio&&(i.audio.remote.bytesReceived=e.bytesReceived,i.audio.remote.codecId=e.codecId,i.audio.remote.fractionLost=e.fractionLost,i.audio.remote.jitter=e.jitter,i.audio.remote.packetsLost=e.packetsLost,i.audio.remote.packetsReceived=e.packetsReceived,i.audio.remote.timestamp=e.timestamp,i.audio.remote.trackId=e.trackId,i.audio.remote.transportId=e.transportId),1!==e.trackId.indexOf(n.video)&""!==n.video&&(i.video.remote.bytesReceived=e.bytesReceived,i.video.remote.codecId=e.codecId,i.video.remote.firCount=e.firCount,i.video.remote.fractionLost=e.fractionLost,i.video.remote.nackCount=e.nackCount,i.video.remote.packetsLost=e.packetsLost,i.video.remote.packetsReceived=e.packetsReceived,i.video.remote.pliCount=e.pliCount,i.video.remote.qpSum=e.qpSum,i.video.remote.timestamp=e.timestamp,i.video.remote.trackId=e.trackId,i.video.remote.transportId=e.transportId));break;case"candidate-pair":e.hasOwnProperty("availableOutgoingBitrate")&&(i.connection.availableOutgoingBitrate=e.availableOutgoingBitrate,i.connection.bytesReceived=e.bytesReceived,i.connection.bytesSent=e.bytesSent,i.connection.consentRequestsSent=e.consentRequestsSent,i.connection.currentRoundTripTime=e.currentRoundTripTime,i.connection.localCandidateId=e.localCandidateId,i.connection.remoteCandidateId=e.remoteCandidateId,i.connection.requestsReceived=e.requestsReceived,i.connection.requestsSent=e.requestsSent,i.connection.responsesReceived=e.responsesReceived,i.connection.responsesSent=e.responsesSent,i.connection.timestamp=e.timestamp,i.connection.totalRoundTripTime=e.totalRoundTripTime);break;default:return}}.bind()),e.forEach(function(e){switch(e.type){case"track":e.hasOwnProperty("trackIdentifier")&&(1!==e.trackIdentifier.indexOf(r.video)&""!==r.video&&(i.video.local.frameHeight=e.frameHeight,i.video.local.framesSent=e.framesSent,i.video.local.frameWidth=e.frameWidth),1!==e.trackIdentifier.indexOf(n.video)&""!==n.video&&(i.video.remote.frameHeight=e.frameHeight,i.video.remote.framesDecoded=e.framesDecoded,i.video.remote.framesDropped=e.framesDropped,i.video.remote.framesReceived=e.framesReceived,i.video.remote.frameWidth=e.frameWidth),1!==e.trackIdentifier.indexOf(r.audio)&""!==r.audio&&(i.audio.local.audioLevel=e.audioLevel),1!==e.trackIdentifier.indexOf(n.audio)&""!==n.audio&&(i.audio.remote.audioLevel=e.audioLevel));break;case"codec":e.hasOwnProperty("id")&&(1!==e.id.indexOf(i.audio.local.codecId)&""!==r.audio&&(i.audio.local.clockRate=e.clockRate,i.audio.local.mimeType=e.mimeType,i.audio.local.payloadType=e.payloadType),1!==e.id.indexOf(i.audio.remote.codecId)&""!==n.audio&&(i.audio.remote.clockRate=e.clockRate,i.audio.remote.mimeType=e.mimeType,i.audio.remote.payloadType=e.payloadType),1!==e.id.indexOf(i.video.local.codecId)&""!==r.video&&(i.video.local.clockRate=e.clockRate,i.video.local.mimeType=e.mimeType,i.video.local.payloadType=e.payloadType),1!==e.id.indexOf(i.video.remote.codecId)&""!==n.video&&(i.video.remote.clockRate=e.clockRate,i.video.remote.mimeType=e.mimeType,i.video.remote.payloadType=e.payloadType));break;case"local-candidate":e.hasOwnProperty("id")&&-1!==e.id.indexOf(i.connection.localCandidateId)&&(i.connection.localIp=e.ip,i.connection.localPort=e.port,i.connection.localPriority=e.priority,i.connection.localProtocol=e.protocol,i.connection.localType=e.candidateType);break;case"remote-candidate":e.hasOwnProperty("id")&&-1!==e.id.indexOf(i.connection.remoteCandidateId)&&(i.connection.remoteIp=e.ip,i.connection.remotePort=e.port,i.connection.remotePriority=e.priority,i.connection.remoteProtocol=e.protocol,i.connection.remoteType=e.candidateType);break;default:return}}.bind()));return i}},{}],34:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{"./ssim.js":31,dup:28}]},{},[15,16,17,18,19,21,22,23,24,25,26,29,30,31,32,33,34]);