/
var
/
www
/
html
/
lgpd
/
lib
/
amd
/
build
/
Upload File
HOME
function _typeof(e){if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(e){return typeof e}}else{_typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}define ("core/adapter",[],function(){return function c(d,e,t){function r(i,o){if(!e[i]){if(!d[i]){var s="function"==typeof require&&require;if(!o&&s)return s(i,!0);if(n)return n(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=e[i]={exports:{}};d[i][0].call(p.exports,function(t){var e=d[i][1][t];return r(e?e:t)},p,p.exports,c,d,e,t)}return e[i].exports}for(var n="function"==typeof require&&require,a=0;a<t.length;a++){r(t[a])}return r}({1:[function(e,t){'use strict';var d=e("sdp");function r(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type}function a(e,t,r,a,n){var i=d.writeRtpDescription(e.kind,t);i+=d.writeIceParameters(e.iceGatherer.getLocalParameters());i+=d.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":n||"active");i+="a=mid:"+e.mid+"\r\n";if(e.rtpSender&&e.rtpReceiver){i+="a=sendrecv\r\n"}else if(e.rtpSender){i+="a=sendonly\r\n"}else if(e.rtpReceiver){i+="a=recvonly\r\n"}else{i+="a=inactive\r\n"}if(e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var s="msid:"+(a?a.id:"-")+" "+o+"\r\n";i+="a="+s;i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s;if(e.sendEncodingParameters[0].rtx){i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s;i+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n"}}i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+d.localCName+"\r\n";if(e.rtpSender&&e.sendEncodingParameters[0].rtx){i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+d.localCName+"\r\n"}return i}function n(e,t){var r=!1;e=JSON.parse(JSON.stringify(e));return e.filter(function(e){if(e&&(e.urls||e.url)){var a=e.urls||e.url;if(e.url&&!e.urls){console.warn("RTCIceServer.url is deprecated! Use urls instead.")}var n="string"==typeof a;if(n){a=[a]}a=a.filter(function(e){var a=0===e.indexOf("turn:")&&-1!==e.indexOf("transport=udp")&&-1===e.indexOf("turn:[")&&!r;if(a){r=!0;return!0}return 0===e.indexOf("stun:")&&14393<=t&&-1===e.indexOf("?transport=udp")});delete e.url;e.urls=n?a[0]:a;return!!a.length}})}function i(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},a=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]}}},n=function(e,t,r,n){var i=a(e.parameters.apt,r),o=a(t.parameters.apt,n);return i&&o&&i.name.toLowerCase()===o.name.toLowerCase()};e.codecs.forEach(function(a){for(var o=0,s;o<t.codecs.length;o++){s=t.codecs[o];if(a.name.toLowerCase()===s.name.toLowerCase()&&a.clockRate===s.clockRate){if("rtx"===a.name.toLowerCase()&&a.parameters&&s.parameters.apt){if(!n(a,s,e.codecs,t.codecs)){continue}}s=JSON.parse(JSON.stringify(s));s.numChannels=Math.min(a.numChannels,s.numChannels);r.codecs.push(s);s.rtcpFeedback=s.rtcpFeedback.filter(function(e){for(var t=0;t<a.rtcpFeedback.length;t++){if(a.rtcpFeedback[t].type===e.type&&a.rtcpFeedback[t].parameter===e.parameter){return!0}}return!1});break}}});e.headerExtensions.forEach(function(e){for(var a=0,n;a<t.headerExtensions.length;a++){n=t.headerExtensions[a];if(e.uri===n.uri){r.headerExtensions.push(n);break}}});return r}function o(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 s(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});if(!r){e.addRemoteCandidate(t)}return!r}function c(t,r){var a=new Error(r);a.name=t;a.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[t];return a}t.exports=function(e,t){function p(t,r){r.addTrack(t);r.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function m(t,r){r.removeTrack(t);r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}function l(t,r,a,n){var i=new Event("track");i.track=r;i.receiver=a;i.transceiver={receiver:a};i.streams=n;e.setTimeout(function(){t._dispatchEvent("track",i)})}var g=function(r){var a=this,o=document.createDocumentFragment();["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){a[e]=o[e].bind(o)});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";r=JSON.parse(JSON.stringify(r||{}));this.usingBundle="max-bundle"===r.bundlePolicy;if("negotiate"===r.rtcpMuxPolicy){throw c("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported")}else if(!r.rtcpMuxPolicy){r.rtcpMuxPolicy="require"}switch(r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all";break;}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced";break;}r.iceServers=n(r.iceServers||[],t);this._iceGatherers=[];if(r.iceCandidatePoolSize){for(var s=r.iceCandidatePoolSize;0<s;s--){this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}))}}else{r.iceCandidatePoolSize=0}this._config=r;this.transceivers=[];this._sdpSessionId=d.generateSessionId();this._sdpSessionVersion=0;this._dtlsRole=void 0;this._isClosed=!1};Object.defineProperty(g.prototype,"localDescription",{configurable:!0,get:function get(){return this._localDescription}});Object.defineProperty(g.prototype,"remoteDescription",{configurable:!0,get:function get(){return this._remoteDescription}});g.prototype.onicecandidate=null;g.prototype.onaddstream=null;g.prototype.ontrack=null;g.prototype.onremovestream=null;g.prototype.onsignalingstatechange=null;g.prototype.oniceconnectionstatechange=null;g.prototype.onconnectionstatechange=null;g.prototype.onicegatheringstatechange=null;g.prototype.onnegotiationneeded=null;g.prototype.ondatachannel=null;g.prototype._dispatchEvent=function(e,t){if(this._isClosed){return}this.dispatchEvent(t);if("function"==typeof this["on"+e]){this["on"+e](t)}};g.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)};g.prototype.getConfiguration=function(){return this._config};g.prototype.getLocalStreams=function(){return this.localStreams};g.prototype.getRemoteStreams=function(){return this.remoteStreams};g.prototype._createTransceiver=function(e,t){var r=0<this.transceivers.length,a={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){a.iceTransport=this.transceivers[0].iceTransport;a.dtlsTransport=this.transceivers[0].dtlsTransport}else{var n=this._createIceAndDtlsTransports();a.iceTransport=n.iceTransport;a.dtlsTransport=n.dtlsTransport}if(!t){this.transceivers.push(a)}return a};g.prototype.addTrack=function(t,r){if(this._isClosed){throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.")}var a=this.transceivers.find(function(e){return e.track===t});if(a){throw c("InvalidAccessError","Track already exists.")}for(var n,o=0;o<this.transceivers.length;o++){if(!this.transceivers[o].track&&this.transceivers[o].kind===t.kind){n=this.transceivers[o]}}if(!n){n=this._createTransceiver(t.kind)}this._maybeFireNegotiationNeeded();if(-1===this.localStreams.indexOf(r)){this.localStreams.push(r)}n.track=t;n.stream=r;n.rtpSender=new e.RTCRtpSender(t,n.dtlsTransport);return n.rtpSender};g.prototype.addStream=function(e){var r=this;if(15025<=t){e.getTracks().forEach(function(t){r.addTrack(t,e)})}else{var a=e.clone();e.getTracks().forEach(function(e,t){var r=a.getTracks()[t];e.addEventListener("enabled",function(e){r.enabled=e.enabled})});a.getTracks().forEach(function(e){r.addTrack(e,a)})}};g.prototype.removeTrack=function(r){if(this._isClosed){throw c("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.")}if(!(r instanceof e.RTCRtpSender)){throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.")}var a=this.transceivers.find(function(e){return e.rtpSender===r});if(!a){throw c("InvalidAccessError","Sender was not created by this connection.")}var n=a.stream;a.rtpSender.stop();a.rtpSender=null;a.track=null;a.stream=null;var i=this.transceivers.map(function(e){return e.stream});if(-1===i.indexOf(n)&&-1<this.localStreams.indexOf(n)){this.localStreams.splice(this.localStreams.indexOf(n),1)}this._maybeFireNegotiationNeeded()};g.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var r=t.getSenders().find(function(t){return t.track===e});if(r){t.removeTrack(r)}})};g.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})};g.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})};g.prototype._createIceGatherer=function(t,r){var a=this;if(r&&0<t){return this.transceivers[0].iceGatherer}else if(this._iceGatherers.length){return this._iceGatherers.shift()}var n=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});Object.defineProperty(n,"state",{value:"new",writable:!0});this.transceivers[t].bufferedCandidateEvents=[];this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;n.state=r?"completed":"gathering";if(null!==a.transceivers[t].bufferedCandidateEvents){a.transceivers[t].bufferedCandidateEvents.push(e)}};n.addEventListener("localcandidate",this.transceivers[t].bufferCandidates);return n};g.prototype._gather=function(t,r){var a=this,n=this.transceivers[r].iceGatherer;if(n.onlocalcandidate){return}var i=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null;n.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates);n.onlocalcandidate=function(e){if(a.usingBundle&&0<r){return}var i=new Event("icecandidate");i.candidate={sdpMid:t,sdpMLineIndex:r};var o=e.candidate,s=!o||0===Object.keys(o).length;if(s){if("new"===n.state||"gathering"===n.state){n.state="completed"}}else{if("new"===n.state){n.state="gathering"}o.component=1;o.ufrag=n.getLocalParameters().usernameFragment;var c=d.writeCandidate(o);i.candidate=Object.assign(i.candidate,d.parseCandidate(c));i.candidate.candidate=c;i.candidate.toJSON=function(){return{candidate:i.candidate.candidate,sdpMid:i.candidate.sdpMid,sdpMLineIndex:i.candidate.sdpMLineIndex,usernameFragment:i.candidate.usernameFragment}}}var p=d.getMediaSections(a._localDescription.sdp);if(!s){p[i.candidate.sdpMLineIndex]+="a="+i.candidate.candidate+"\r\n"}else{p[i.candidate.sdpMLineIndex]+="a=end-of-candidates\r\n"}a._localDescription.sdp=d.getDescription(a._localDescription.sdp)+p.join("");var m=a.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});if("gathering"!==a.iceGatheringState){a.iceGatheringState="gathering";a._emitGatheringStateChange()}if(!s){a._dispatchEvent("icecandidate",i)}if(m){a._dispatchEvent("icecandidate",new Event("icecandidate"));a.iceGatheringState="complete";a._emitGatheringStateChange()}};e.setTimeout(function(){i.forEach(function(t){n.onlocalcandidate(t)})},0)};g.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState();t._updateConnectionState()};var a=new e.RTCDtlsTransport(r);a.ondtlsstatechange=function(){t._updateConnectionState()};a.onerror=function(){Object.defineProperty(a,"state",{value:"failed",writable:!0});t._updateConnectionState()};return{iceTransport:r,dtlsTransport:a}};g.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;if(t){delete t.onlocalcandidate;delete this.transceivers[e].iceGatherer}var r=this.transceivers[e].iceTransport;if(r){delete r.onicestatechange;delete this.transceivers[e].iceTransport}var a=this.transceivers[e].dtlsTransport;if(a){delete a.ondtlsstatechange;delete a.onerror;delete this.transceivers[e].dtlsTransport}};g.prototype._transceive=function(e,r,a){var n=i(e.localCapabilities,e.remoteCapabilities);if(r&&e.rtpSender){n.encodings=e.sendEncodingParameters;n.rtcp={cname:d.localCName,compound:e.rtcpParameters.compound};if(e.recvEncodingParameters.length){n.rtcp.ssrc=e.recvEncodingParameters[0].ssrc}e.rtpSender.send(n)}if(a&&e.rtpReceiver&&0<n.codecs.length){if("video"===e.kind&&e.recvEncodingParameters&&15019>t){e.recvEncodingParameters.forEach(function(e){delete e.rtx})}if(e.recvEncodingParameters.length){n.encodings=e.recvEncodingParameters}else{n.encodings=[{}]}n.rtcp={compound:e.rtcpParameters.compound};if(e.rtcpParameters.cname){n.rtcp.cname=e.rtcpParameters.cname}if(e.sendEncodingParameters.length){n.rtcp.ssrc=e.sendEncodingParameters[0].ssrc}e.rtpReceiver.receive(n)}};g.prototype.setLocalDescription=function(e){var t=this;if(-1===["offer","answer"].indexOf(e.type)){return Promise.reject(c("TypeError","Unsupported type \""+e.type+"\""))}if(!o("setLocalDescription",e.type,t.signalingState)||t._isClosed){return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+t.signalingState))}var r,a;if("offer"===e.type){r=d.splitSections(e.sdp);a=r.shift();r.forEach(function(e,r){var a=d.parseRtpParameters(e);t.transceivers[r].localCapabilities=a});t.transceivers.forEach(function(e,r){t._gather(e.mid,r)})}else if("answer"===e.type){r=d.splitSections(t._remoteDescription.sdp);a=r.shift();var n=0<d.matchPrefix(a,"a=ice-lite").length;r.forEach(function(e,r){var o=t.transceivers[r],s=o.iceGatherer,c=o.iceTransport,p=o.dtlsTransport,m=o.localCapabilities,l=o.remoteCapabilities,g=d.isRejected(e)&&0===d.matchPrefix(e,"a=bundle-only").length;if(!g&&!o.rejected){var h=d.getIceParameters(e,a),f=d.getDtlsParameters(e,a);if(n){f.role="server"}if(!t.usingBundle||0===r){t._gather(o.mid,r);if("new"===c.state){c.start(s,h,n?"controlling":"controlled")}if("new"===p.state){p.start(f)}}var C=i(m,l);t._transceive(o,0<C.codecs.length,!1)}})}t._localDescription={type:e.type,sdp:e.sdp};if("offer"===e.type){t._updateSignalingState("have-local-offer")}else{t._updateSignalingState("stable")}return Promise.resolve()};g.prototype.setRemoteDescription=function(r){var a=this;if(-1===["offer","answer"].indexOf(r.type)){return Promise.reject(c("TypeError","Unsupported type \""+r.type+"\""))}if(!o("setRemoteDescription",r.type,a.signalingState)||a._isClosed){return Promise.reject(c("InvalidStateError","Can not set remote "+r.type+" in state "+a.signalingState))}var n={};a.remoteStreams.forEach(function(e){n[e.id]=e});var g=[],h=d.splitSections(r.sdp),f=h.shift(),C=0<d.matchPrefix(f,"a=ice-lite").length,v=0<d.matchPrefix(f,"a=group:BUNDLE ").length;a.usingBundle=v;var y=d.matchPrefix(f,"a=ice-options:")[0];if(y){a.canTrickleIceCandidates=0<=y.substr(14).split(" ").indexOf("trickle")}else{a.canTrickleIceCandidates=!1}h.forEach(function(o,c){var l=d.splitLines(o),h=d.getKind(o),y=d.isRejected(o)&&0===d.matchPrefix(o,"a=bundle-only").length,u=l[0].substr(2).split(" ")[2],T=d.getDirection(o,f),S=d.parseMsid(o),R=d.getMid(o)||d.generateIdentifier();if(y||"application"===h&&("DTLS/SCTP"===u||"UDP/DTLS/SCTP"===u)){a.transceivers[c]={mid:R,kind:h,protocol:u,rejected:!0};return}if(!y&&a.transceivers[c]&&a.transceivers[c].rejected){a.transceivers[c]=a._createTransceiver(h,!0)}var P,E,k,b,_,x,M,L,I,D=d.parseRtpParameters(o),w,j;if(!y){w=d.getIceParameters(o,f);j=d.getDtlsParameters(o,f);j.role="client"}M=d.parseRtpEncodingParameters(o);var O=d.parseRtcpParameters(o),U=0<d.matchPrefix(o,"a=end-of-candidates",f).length,A=d.matchPrefix(o,"a=candidate:").map(function(e){return d.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===r.type||"answer"===r.type)&&!y&&v&&0<c&&a.transceivers[c]){a._disposeIceAndDtlsTransports(c);a.transceivers[c].iceGatherer=a.transceivers[0].iceGatherer;a.transceivers[c].iceTransport=a.transceivers[0].iceTransport;a.transceivers[c].dtlsTransport=a.transceivers[0].dtlsTransport;if(a.transceivers[c].rtpSender){a.transceivers[c].rtpSender.setTransport(a.transceivers[0].dtlsTransport)}if(a.transceivers[c].rtpReceiver){a.transceivers[c].rtpReceiver.setTransport(a.transceivers[0].dtlsTransport)}}if("offer"===r.type&&!y){P=a.transceivers[c]||a._createTransceiver(h);P.mid=R;if(!P.iceGatherer){P.iceGatherer=a._createIceGatherer(c,v)}if(A.length&&"new"===P.iceTransport.state){if(U&&(!v||0===c)){P.iceTransport.setRemoteCandidates(A)}else{A.forEach(function(e){s(P.iceTransport,e)})}}L=e.RTCRtpReceiver.getCapabilities(h);if(15019>t){L.codecs=L.codecs.filter(function(e){return"rtx"!==e.name})}x=P.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var G=!1;if("sendrecv"===T||"sendonly"===T){G=!P.rtpReceiver;_=P.rtpReceiver||new e.RTCRtpReceiver(P.dtlsTransport,h);if(G){var N;I=_.track;if(S&&"-"===S.stream){}else if(S){if(!n[S.stream]){n[S.stream]=new e.MediaStream;Object.defineProperty(n[S.stream],"id",{get:function get(){return S.stream}})}Object.defineProperty(I,"id",{get:function get(){return S.track}});N=n[S.stream]}else{if(!n.default){n.default=new e.MediaStream}N=n.default}if(N){p(I,N);P.associatedRemoteMediaStreams.push(N)}g.push([I,_,N])}}else if(P.rtpReceiver&&P.rtpReceiver.track){P.associatedRemoteMediaStreams.forEach(function(e){var t=e.getTracks().find(function(e){return e.id===P.rtpReceiver.track.id});if(t){m(t,e)}});P.associatedRemoteMediaStreams=[]}P.localCapabilities=L;P.remoteCapabilities=D;P.rtpReceiver=_;P.rtcpParameters=O;P.sendEncodingParameters=x;P.recvEncodingParameters=M;a._transceive(a.transceivers[c],!1,G)}else if("answer"===r.type&&!y){P=a.transceivers[c];E=P.iceGatherer;k=P.iceTransport;b=P.dtlsTransport;_=P.rtpReceiver;x=P.sendEncodingParameters;L=P.localCapabilities;a.transceivers[c].recvEncodingParameters=M;a.transceivers[c].remoteCapabilities=D;a.transceivers[c].rtcpParameters=O;if(A.length&&"new"===k.state){if((C||U)&&(!v||0===c)){k.setRemoteCandidates(A)}else{A.forEach(function(e){s(P.iceTransport,e)})}}if(!v||0===c){if("new"===k.state){k.start(E,w,"controlling")}if("new"===b.state){b.start(j)}}var F=i(P.localCapabilities,P.remoteCapabilities),z=F.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length;if(!z&&P.sendEncodingParameters[0].rtx){delete P.sendEncodingParameters[0].rtx}a._transceive(P,"sendrecv"===T||"recvonly"===T,"sendrecv"===T||"sendonly"===T);if(_&&("sendrecv"===T||"sendonly"===T)){I=_.track;if(S){if(!n[S.stream]){n[S.stream]=new e.MediaStream}p(I,n[S.stream]);g.push([I,_,n[S.stream]])}else{if(!n.default){n.default=new e.MediaStream}p(I,n.default);g.push([I,_,n.default])}}else{delete P.rtpReceiver}}});if(a._dtlsRole===void 0){a._dtlsRole="offer"===r.type?"active":"passive"}a._remoteDescription={type:r.type,sdp:r.sdp};if("offer"===r.type){a._updateSignalingState("have-remote-offer")}else{a._updateSignalingState("stable")}Object.keys(n).forEach(function(t){var r=n[t];if(r.getTracks().length){if(-1===a.remoteStreams.indexOf(r)){a.remoteStreams.push(r);var i=new Event("addstream");i.stream=r;e.setTimeout(function(){a._dispatchEvent("addstream",i)})}g.forEach(function(e){var t=e[0],n=e[1];if(r.id!==e[2].id){return}l(a,t,n,[r])})}});g.forEach(function(e){if(e[2]){return}l(a,e[0],e[1],[])});e.setTimeout(function(){if(!(a&&a.transceivers)){return}a.transceivers.forEach(function(e){if(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);return Promise.resolve()};g.prototype.close=function(){this.transceivers.forEach(function(e){if(e.iceTransport){e.iceTransport.stop()}if(e.dtlsTransport){e.dtlsTransport.stop()}if(e.rtpSender){e.rtpSender.stop()}if(e.rtpReceiver){e.rtpReceiver.stop()}});this._isClosed=!0;this._updateSignalingState("closed")};g.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)};g.prototype._maybeFireNegotiationNeeded=function(){var t=this;if("stable"!==this.signalingState||!0===this.needNegotiation){return}this.needNegotiation=!0;e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0)};g.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};this.transceivers.forEach(function(e){t[e.iceTransport.state]++});e="new";if(0<t.failed){e="failed"}else if(0<t.checking){e="checking"}else if(0<t.disconnected){e="disconnected"}else if(0<t.new){e="new"}else if(0<t.connected){e="connected"}else if(0<t.completed){e="completed"}if(e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}};g.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};this.transceivers.forEach(function(e){t[e.iceTransport.state]++;t[e.dtlsTransport.state]++});t.connected+=t.completed;e="new";if(0<t.failed){e="failed"}else if(0<t.connecting){e="connecting"}else if(0<t.disconnected){e="disconnected"}else if(0<t.new){e="new"}else if(0<t.connected){e="connected"}if(e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}};g.prototype.createOffer=function(){var r=this;if(r._isClosed){return Promise.reject(c("InvalidStateError","Can not call createOffer after close"))}var n=r.transceivers.filter(function(e){return"audio"===e.kind}).length,i=r.transceivers.filter(function(e){return"video"===e.kind}).length,o=arguments[0];if(o){if(o.mandatory||o.optional){throw new TypeError("Legacy mandatory/optional constraints not supported.")}if(o.offerToReceiveAudio!==void 0){if(!0===o.offerToReceiveAudio){n=1}else if(!1===o.offerToReceiveAudio){n=0}else{n=o.offerToReceiveAudio}}if(o.offerToReceiveVideo!==void 0){if(!0===o.offerToReceiveVideo){i=1}else if(!1===o.offerToReceiveVideo){i=0}else{i=o.offerToReceiveVideo}}}r.transceivers.forEach(function(e){if("audio"===e.kind){n--;if(0>n){e.wantReceive=!1}}else if("video"===e.kind){i--;if(0>i){e.wantReceive=!1}}});while(0<n||0<i){if(0<n){r._createTransceiver("audio");n--}if(0<i){r._createTransceiver("video");i--}}var s=d.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach(function(a,n){var i=a.track,o=a.kind,s=a.mid||d.generateIdentifier();a.mid=s;if(!a.iceGatherer){a.iceGatherer=r._createIceGatherer(n,r.usingBundle)}var c=e.RTCRtpSender.getCapabilities(o);if(15019>t){c.codecs=c.codecs.filter(function(e){return"rtx"!==e.name})}c.codecs.forEach(function(e){if("H264"===e.name&&e.parameters["level-asymmetry-allowed"]===void 0){e.parameters["level-asymmetry-allowed"]="1"}if(a.remoteCapabilities&&a.remoteCapabilities.codecs){a.remoteCapabilities.codecs.forEach(function(t){if(e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate){e.preferredPayloadType=t.payloadType}})}});c.headerExtensions.forEach(function(e){var t=a.remoteCapabilities&&a.remoteCapabilities.headerExtensions||[];t.forEach(function(t){if(e.uri===t.uri){e.id=t.id}})});var p=a.sendEncodingParameters||[{ssrc:1001*(2*n+1)}];if(i){if(15019<=t&&"video"===o&&!p[0].rtx){p[0].rtx={ssrc:p[0].ssrc+1}}}if(a.wantReceive){a.rtpReceiver=new e.RTCRtpReceiver(a.dtlsTransport,o)}a.localCapabilities=c;a.sendEncodingParameters=p});if("max-compat"!==r._config.bundlePolicy){s+="a=group:BUNDLE "+r.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"}s+="a=ice-options:trickle\r\n";r.transceivers.forEach(function(e,t){s+=a(e,e.localCapabilities,"offer",e.stream,r._dtlsRole);s+="a=rtcp-rsize\r\n";if(e.iceGatherer&&"new"!==r.iceGatheringState&&(0===t||!r.usingBundle)){e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1;s+="a="+d.writeCandidate(e)+"\r\n"});if("completed"===e.iceGatherer.state){s+="a=end-of-candidates\r\n"}}});var p=new e.RTCSessionDescription({type:"offer",sdp:s});return Promise.resolve(p)};g.prototype.createAnswer=function(){var r=this;if(r._isClosed){return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"))}if(!("have-remote-offer"===r.signalingState||"have-local-pranswer"===r.signalingState)){return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState))}var n=d.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);if(r.usingBundle){n+="a=group:BUNDLE "+r.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"}n+="a=ice-options:trickle\r\n";var o=d.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach(function(e,s){if(s+1>o){return}if(e.rejected){if("application"===e.kind){if("DTLS/SCTP"===e.protocol){n+="m=application 0 DTLS/SCTP 5000\r\n"}else{n+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n"}}else if("audio"===e.kind){n+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n"}else if("video"===e.kind){n+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"}n+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n";return}if(e.stream){var c;if("audio"===e.kind){c=e.stream.getAudioTracks()[0]}else if("video"===e.kind){c=e.stream.getVideoTracks()[0]}if(c){if(15019<=t&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx){e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1}}}}var d=i(e.localCapabilities,e.remoteCapabilities),p=d.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length;if(!p&&e.sendEncodingParameters[0].rtx){delete e.sendEncodingParameters[0].rtx}n+=a(e,d,"answer",e.stream,r._dtlsRole);if(e.rtcpParameters&&e.rtcpParameters.reducedSize){n+="a=rtcp-rsize\r\n"}});var s=new e.RTCSessionDescription({type:"answer",sdp:n});return Promise.resolve(s)};g.prototype.addIceCandidate=function(e){var t=this,r;if(e&&!(e.sdpMLineIndex!==void 0||e.sdpMid)){return Promise.reject(new TypeError("sdpMLineIndex or sdpMid required"))}return new Promise(function(a,n){if(!t._remoteDescription){return n(c("InvalidStateError","Can not add ICE candidate without a remote description"))}else if(!e||""===e.candidate){for(var o=0;o<t.transceivers.length;o++){if(t.transceivers[o].rejected){continue}t.transceivers[o].iceTransport.addRemoteCandidate({});r=d.getMediaSections(t._remoteDescription.sdp);r[o]+="a=end-of-candidates\r\n";t._remoteDescription.sdp=d.getDescription(t._remoteDescription.sdp)+r.join("");if(t.usingBundle){break}}}else{var p=e.sdpMLineIndex;if(e.sdpMid){for(var m=0;m<t.transceivers.length;m++){if(t.transceivers[m].mid===e.sdpMid){p=m;break}}}var l=t.transceivers[p];if(l){if(l.rejected){return a()}var g=0<Object.keys(e.candidate).length?d.parseCandidate(e.candidate):{};if("tcp"===g.protocol&&(0===g.port||9===g.port)){return a()}if(g.component&&1!==g.component){return a()}if(0===p||0<p&&l.iceTransport!==t.transceivers[0].iceTransport){if(!s(l.iceTransport,g)){return n(c("OperationError","Can not add ICE candidate"))}}var h=e.candidate.trim();if(0===h.indexOf("a=")){h=h.substr(2)}r=d.getMediaSections(t._remoteDescription.sdp);r[p]+="a="+(g.type?h:"end-of-candidates")+"\r\n";t._remoteDescription.sdp=d.getDescription(t._remoteDescription.sdp)+r.join("")}else{return n(c("OperationError","Can not add ICE candidate"))}}a()})};g.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var r=null;this.transceivers.forEach(function(e){if(e.rtpSender&&e.rtpSender.track===t){r=e.rtpSender}else if(e.rtpReceiver&&e.rtpReceiver.track===t){r=e.rtpReceiver}});if(!r){throw c("InvalidAccessError","Invalid selector.")}return r.getStats()}var a=[];this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){if(e[t]){a.push(e[t].getStats())}})});return Promise.all(a).then(function(e){var t=new Map;e.forEach(function(e){e.forEach(function(e){t.set(e.id,e)})});return t})};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(t){var a=e[t];if(a&&a.prototype&&a.prototype.getStats){var n=a.prototype.getStats;a.prototype.getStats=function(){return n.apply(this).then(function(e){var t=new Map;Object.keys(e).forEach(function(a){e[a].type=r(e[a]);t.set(a,e[a])});return t})}}});var h=["createOffer","createAnswer"];h.forEach(function(e){var t=g.prototype[e];g.prototype[e]=function(){var e=arguments;if("function"==typeof e[0]||"function"==typeof e[1]){return t.apply(this,[arguments[2]]).then(function(t){if("function"==typeof e[0]){e[0].apply(null,[t])}},function(t){if("function"==typeof e[1]){e[1].apply(null,[t])}})}return t.apply(this,arguments)}});h=["setLocalDescription","setRemoteDescription","addIceCandidate"];h.forEach(function(e){var t=g.prototype[e];g.prototype[e]=function(){var e=arguments;if("function"==typeof e[1]||"function"==typeof e[2]){return t.apply(this,arguments).then(function(){if("function"==typeof e[1]){e[1].apply(null)}},function(t){if("function"==typeof e[2]){e[2].apply(null,[t])}})}return t.apply(this,arguments)}});["getStats"].forEach(function(e){var t=g.prototype[e];g.prototype[e]=function(){var e=arguments;if("function"==typeof e[1]){return t.apply(this,arguments).then(function(){if("function"==typeof e[1]){e[1].apply(null)}})}return t.apply(this,arguments)}});return g}},{sdp:2}],2:[function(e,t){'use strict';var r={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};r.localCName=r.generateIdentifier();r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})};r.splitSections=function(e){var t=e.split("\nm=");return t.map(function(e,t){return(0<t?"m="+e:e).trim()+"\r\n"})};r.getDescription=function(e){var t=r.splitSections(e);return t&&t[0]};r.getMediaSections=function(e){var t=r.splitSections(e);t.shift();return t};r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})};r.parseCandidate=function(e){var t;if(0===e.indexOf("a=candidate:")){t=e.substring(12).split(" ")}else{t=e.substring(10).split(" ")}for(var r={foundation:t[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},a=8;a<t.length;a+=2){switch(t[a]){case"raddr":r.relatedAddress=t[a+1];break;case"rport":r.relatedPort=parseInt(t[a+1],10);break;case"tcptype":r.tcpType=t[a+1];break;case"ufrag":r.ufrag=t[a+1];r.usernameFragment=t[a+1];break;default:r[t[a]]=t[a+1];break;}}return r};r.writeCandidate=function(e){var t=[e.foundation,e.component,e.protocol.toUpperCase(),e.priority,e.address||e.ip,e.port],r=e.type;t.push("typ");t.push(r);if("host"!==r&&e.relatedAddress&&e.relatedPort){t.push("raddr");t.push(e.relatedAddress);t.push("rport");t.push(e.relatedPort)}if(e.tcpType&&"tcp"===e.protocol.toLowerCase()){t.push("tcptype");t.push(e.tcpType)}if(e.usernameFragment||e.ufrag){t.push("ufrag");t.push(e.usernameFragment||e.ufrag)}return"candidate:"+t.join(" ")};r.parseIceOptions=function(e){return e.substr(14).split(" ")};r.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:parseInt(t.shift(),10)};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;return r};r.writeRtpMap=function(e){var t=e.payloadType;if(e.preferredPayloadType!==void 0){t=e.preferredPayloadType}var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"};r.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]}};r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"};r.parseFmtp=function(e){for(var t={},r,a=e.substr(e.indexOf(" ")+1).split(";"),n=0;n<a.length;n++){r=a[n].trim().split("=");t[r[0].trim()]=r[1]}return t};r.writeFmtp=function(e){var t="",r=e.payloadType;if(e.preferredPayloadType!==void 0){r=e.preferredPayloadType}if(e.parameters&&Object.keys(e.parameters).length){var a=[];Object.keys(e.parameters).forEach(function(t){if(e.parameters[t]){a.push(t+"="+e.parameters[t])}else{a.push(t)}});t+="a=fmtp:"+r+" "+a.join(";")+"\r\n"}return t};r.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}};r.writeRtcpFb=function(e){var t="",r=e.payloadType;if(e.preferredPayloadType!==void 0){r=e.preferredPayloadType}if(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"})}return t};r.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},a=e.indexOf(":",t);if(-1<a){r.attribute=e.substr(t+1,a-t-1);r.value=e.substr(a+1)}else{r.attribute=e.substr(t+1)}return r};r.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}};r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t){return t.substr(6)}};r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}};r.getDtlsParameters=function(e,t){var a=r.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:a.map(r.parseFingerprint)}};r.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";e.fingerprints.forEach(function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"});return r};r.getIceParameters=function(e,t){var a=r.splitLines(e);a=a.concat(r.splitLines(t));var n={usernameFragment:a.filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:a.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)};return n};r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"};r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},a=r.splitLines(e),n=a[0].split(" "),o=3;o<n.length;o++){var s=n[o],c=r.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(c){var d=r.parseRtpMap(c),p=r.matchPrefix(e,"a=fmtp:"+s+" ");d.parameters=p.length?r.parseFmtp(p[0]):{};d.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(r.parseRtcpFb);t.codecs.push(d);switch(d.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(d.name.toUpperCase());break;default:break;}}}r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))});return t};r.writeRtpDescription=function(e,t){var a="";a+="m="+e+" ";a+=0<t.codecs.length?"9":"0";a+=" UDP/TLS/RTP/SAVPF ";a+=t.codecs.map(function(e){if(e.preferredPayloadType!==void 0){return e.preferredPayloadType}return e.payloadType}).join(" ")+"\r\n";a+="c=IN IP4 0.0.0.0\r\n";a+="a=rtcp:9 IN IP4 0.0.0.0\r\n";t.codecs.forEach(function(e){a+=r.writeRtpMap(e);a+=r.writeFmtp(e);a+=r.writeRtcpFb(e)});var n=0;t.codecs.forEach(function(e){if(e.maxptime>n){n=e.maxptime}});if(0<n){a+="a=maxptime:"+n+"\r\n"}a+="a=rtcp-mux\r\n";if(t.headerExtensions){t.headerExtensions.forEach(function(e){a+=r.writeExtmap(e)})}return a};r.parseRtpEncodingParameters=function(e){var t=[],a=r.parseRtpParameters(e),n=-1!==a.fecMechanisms.indexOf("RED"),i=-1!==a.fecMechanisms.indexOf("ULPFEC"),o=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),s=0<o.length&&o[0].ssrc,c,d=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.substr(17).split(" ");return t.map(function(e){return parseInt(e,10)})});if(0<d.length&&1<d[0].length&&d[0][0]===s){c=d[0][1]}a.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};if(s&&c){r.rtx={ssrc:c}}t.push(r);if(n){r=JSON.parse(JSON.stringify(r));r.fec={ssrc:s,mechanism:i?"red+ulpfec":"red"};t.push(r)}}});if(0===t.length&&s){t.push({ssrc:s})}var p=r.matchPrefix(e,"b=");if(p.length){if(0===p[0].indexOf("b=TIAS:")){p=parseInt(p[0].substr(7),10)}else if(0===p[0].indexOf("b=AS:")){p=.95*(1e3*parseInt(p[0].substr(5),10))-16000}else{p=void 0}t.forEach(function(e){e.maxBitrate=p})}return t};r.parseRtcpParameters=function(e){var t={},a=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];if(a){t.cname=a.value;t.ssrc=a.ssrc}var n=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=0<n.length;t.compound=0===n.length;var i=r.matchPrefix(e,"a=rtcp-mux");t.mux=0<i.length;return t};r.parseMsid=function(e){var t,a=r.matchPrefix(e,"a=msid:");if(1===a.length){t=a[0].substr(7).split(" ");return{stream:t[0],track:t[1]}}var n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});if(0<n.length){t=n[0].value.split(" ");return{stream:t[0],track:t[1]}}};r.generateSessionId=function(){return Math.random().toString().substr(2,21)};r.writeSessionBoilerplate=function(e,t,a){var n,i=t!==void 0?t:2;if(e){n=e}else{n=r.generateSessionId()}return"v=0\r\no="+(a||"thisisadapterortc")+" "+n+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"};r.writeMediaSection=function(e,t,a,n){var i=r.writeRtpDescription(e.kind,t);i+=r.writeIceParameters(e.iceGatherer.getLocalParameters());i+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===a?"actpass":"active");i+="a=mid:"+e.mid+"\r\n";if(e.direction){i+="a="+e.direction+"\r\n"}else if(e.rtpSender&&e.rtpReceiver){i+="a=sendrecv\r\n"}else if(e.rtpSender){i+="a=sendonly\r\n"}else if(e.rtpReceiver){i+="a=recvonly\r\n"}else{i+="a=inactive\r\n"}if(e.rtpSender){var o="msid:"+n.id+" "+e.rtpSender.track.id+"\r\n";i+="a="+o;i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o;if(e.sendEncodingParameters[0].rtx){i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o;i+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n"}}i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n";if(e.rtpSender&&e.sendEncodingParameters[0].rtx){i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"}return i};r.getDirection=function(e,t){for(var a=r.splitLines(e),n=0;n<a.length;n++){switch(a[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return a[n].substr(2);default:}}if(t){return r.getDirection(t)}return"sendrecv"};r.getKind=function(e){var t=r.splitLines(e),a=t[0].split(" ");return a[0].substr(2)};r.isRejected=function(e){return"0"===e.split(" ",2)[1]};r.parseMLine=function(e){var t=r.splitLines(e),a=t[0].substr(2).split(" ");return{kind:a[0],port:parseInt(a[1],10),protocol:a[2],fmt:a.slice(3).join(" ")}};r.parseOLine=function(e){var t=r.matchPrefix(e,"o=")[0],a=t.substr(2).split(" ");return{username:a[0],sessionId:a[1],sessionVersion:parseInt(a[2],10),netType:a[3],addressType:a[4],address:a[5]}};r.isValidSDP=function(e){if("string"!=typeof e||0===e.length){return!1}for(var t=r.splitLines(e),a=0;a<t.length;a++){if(2>t[a].length||"="!==t[a].charAt(1)){return!1}}return!0};if("object"===_typeof(t)){t.exports=r}},{}],3:[function(e,t){(function(r){'use strict';var a=e("./adapter_factory.js");t.exports=a({window:r.window})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./adapter_factory.js":4}],4:[function(e,t){'use strict';var r=e("./utils");t.exports=function(t,a){var n=t&&t.window,i={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0};for(var o in a){if(hasOwnProperty.call(a,o)){i[o]=a[o]}}var s=r.log,c=r.detectBrowser(n),d=e("./chrome/chrome_shim")||null,p=e("./edge/edge_shim")||null,m=e("./firefox/firefox_shim")||null,l=e("./safari/safari_shim")||null,g=e("./common_shim")||null,h={browserDetails:c,commonShim:g,extractVersion:r.extractVersion,disableLog:r.disableLog,disableWarnings:r.disableWarnings};switch(c.browser){case"chrome":if(!d||!d.shimPeerConnection||!i.shimChrome){s("Chrome shim is not included in this adapter release.");return h}s("adapter.js shimming chrome.");h.browserShim=d;g.shimCreateObjectURL(n);d.shimGetUserMedia(n);d.shimMediaStream(n);d.shimSourceObject(n);d.shimPeerConnection(n);d.shimOnTrack(n);d.shimAddTrackRemoveTrack(n);d.shimGetSendersWithDtmf(n);d.shimSenderReceiverGetStats(n);d.fixNegotiationNeeded(n);g.shimRTCIceCandidate(n);g.shimMaxMessageSize(n);g.shimSendThrowTypeError(n);break;case"firefox":if(!m||!m.shimPeerConnection||!i.shimFirefox){s("Firefox shim is not included in this adapter release.");return h}s("adapter.js shimming firefox.");h.browserShim=m;g.shimCreateObjectURL(n);m.shimGetUserMedia(n);m.shimSourceObject(n);m.shimPeerConnection(n);m.shimOnTrack(n);m.shimRemoveStream(n);m.shimSenderGetStats(n);m.shimReceiverGetStats(n);m.shimRTCDataChannel(n);g.shimRTCIceCandidate(n);g.shimMaxMessageSize(n);g.shimSendThrowTypeError(n);break;case"edge":if(!p||!p.shimPeerConnection||!i.shimEdge){s("MS edge shim is not included in this adapter release.");return h}s("adapter.js shimming edge.");h.browserShim=p;g.shimCreateObjectURL(n);p.shimGetUserMedia(n);p.shimPeerConnection(n);p.shimReplaceTrack(n);g.shimMaxMessageSize(n);g.shimSendThrowTypeError(n);break;case"safari":if(!l||!i.shimSafari){s("Safari shim is not included in this adapter release.");return h}s("adapter.js shimming safari.");h.browserShim=l;g.shimCreateObjectURL(n);l.shimRTCIceServerUrls(n);l.shimCreateOfferLegacy(n);l.shimCallbacksAPI(n);l.shimLocalStreamsAPI(n);l.shimRemoteStreamsAPI(n);l.shimTrackEventTransceiver(n);l.shimGetUserMedia(n);g.shimRTCIceCandidate(n);g.shimMaxMessageSize(n);g.shimSendThrowTypeError(n);break;default:s("Unsupported browser!");break;}return h}},{"./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){'use strict';var n=e("../utils.js"),i=n.log;function r(e,t,a){if(!t||a.has(t.id)){return}a.set(t.id,t);Object.keys(t).forEach(function(n){if(n.endsWith("Id")){r(e,e.get(t[n]),a)}else if(n.endsWith("Ids")){t[n].forEach(function(t){r(e,e.get(t),a)})}})}function a(e,t,a){var n=a?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t){return i}var o=[];e.forEach(function(e){if("track"===e.type&&e.trackIdentifier===t.id){o.push(e)}});o.forEach(function(t){e.forEach(function(a){if(a.type===n&&a.trackId===t.id){r(e,a,i)}})});return i}t.exports={shimGetUserMedia:e("./getusermedia"),shimMediaStream:function shimMediaStream(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},shimOnTrack:function shimOnTrack(t){if("object"===_typeof(t)&&t.RTCPeerConnection&&!("ontrack"in t.RTCPeerConnection.prototype)){Object.defineProperty(t.RTCPeerConnection.prototype,"ontrack",{get:function get(){return this._ontrack},set:function set(e){if(this._ontrack){this.removeEventListener("track",this._ontrack)}this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var r=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){var a=this;if(!a._ontrackpoly){a._ontrackpoly=function(r){r.stream.addEventListener("addtrack",function(e){var n;if(t.RTCPeerConnection.prototype.getReceivers){n=a.getReceivers().find(function(t){return t.track&&t.track.id===e.track.id})}else{n={track:e.track}}var i=new Event("track");i.track=e.track;i.receiver=n;i.transceiver={receiver:n};i.streams=[r.stream];a.dispatchEvent(i)});r.stream.getTracks().forEach(function(e){var n;if(t.RTCPeerConnection.prototype.getReceivers){n=a.getReceivers().find(function(t){return t.track&&t.track.id===e.id})}else{n={track:e}}var i=new Event("track");i.track=e;i.receiver=n;i.transceiver={receiver:n};i.streams=[r.stream];a.dispatchEvent(i)})};a.addEventListener("addstream",a._ontrackpoly)}return r.apply(a,arguments)}}else{n.wrapPeerConnectionEvent(t,"track",function(t){if(!t.transceiver){Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}})}return t})}},shimGetSendersWithDtmf:function shimGetSendersWithDtmf(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){if(this._dtmf===void 0){if("audio"===t.kind){this._dtmf=e.createDTMFSender(t)}else{this._dtmf=null}}return this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){this._senders=this._senders||[];return this._senders.slice()};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e){var a=this,n=r.apply(a,arguments);if(!n){n=t(a,e);a._senders.push(n)}return n};var a=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;a.apply(t,arguments);var r=t._senders.indexOf(e);if(-1!==r){t._senders.splice(r,1)}}}var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;r._senders=r._senders||[];n.apply(r,[e]);e.getTracks().forEach(function(e){r._senders.push(t(r,e))})};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._senders=t._senders||[];i.apply(t,[e]);e.getTracks().forEach(function(e){var r=t._senders.find(function(t){return t.track===e});if(r){t._senders.splice(t._senders.indexOf(r),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 e=this,t=o.apply(e,[]);t.forEach(function(t){t._pc=e});return t};Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function get(){if(this._dtmf===void 0){if("audio"===this.track.kind){this._dtmf=this._pc.createDTMFSender(this.track)}else{this._dtmf=null}}return this._dtmf}})}},shimSenderReceiverGetStats:function shimSenderReceiverGetStats(e){if(!("object"===_typeof(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver)){return}if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;if(t){e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(e,[]);r.forEach(function(t){t._pc=e});return r}}var r=e.RTCPeerConnection.prototype.addTrack;if(r){e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);e._pc=this;return e}}e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return a(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var i=e.RTCPeerConnection.prototype.getReceivers;if(i){e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=i.apply(e,[]);t.forEach(function(t){t._pc=e});return t}}n.wrapPeerConnectionEvent(e,"track",function(t){t.receiver._pc=t.srcElement;return t});e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return a(t,e.track,!1)})}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype)){return}var o=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var t=this;if(0<arguments.length&&arguments[0]instanceof e.MediaStreamTrack){var a=arguments[0],n,i,s;t.getSenders().forEach(function(e){if(e.track===a){if(n){s=!0}else{n=e}}});t.getReceivers().forEach(function(e){if(e.track===a){if(i){s=!0}else{i=e}}return e.track===a});if(s||n&&i){return Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError"))}else if(n){return n.getStats()}else if(i){return i.getStats()}return Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return o.apply(t,arguments)}},shimSourceObject:function shimSourceObject(e){var t=e&&e.URL;if("object"===_typeof(e)){if(e.HTMLMediaElement&&!("srcObject"in e.HTMLMediaElement.prototype)){Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function get(){return this._srcObject},set:function set(e){var r=this;this._srcObject=e;if(this.src){t.revokeObjectURL(this.src)}if(!e){this.src="";return}this.src=t.createObjectURL(e);e.addEventListener("addtrack",function(){if(r.src){t.revokeObjectURL(r.src)}r.src=t.createObjectURL(e)});e.addEventListener("removetrack",function(){if(r.src){t.revokeObjectURL(r.src)}r.src=t.createObjectURL(e)})}})}}},shimAddTrackRemoveTrackWithNative:function shimAddTrackRemoveTrackWithNative(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{};return Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r){return t.apply(this,arguments)}this._shimmedLocalStreams=this._shimmedLocalStreams||{};var a=t.apply(this,arguments);if(!this._shimmedLocalStreams[r.id]){this._shimmedLocalStreams[r.id]=[r,a]}else if(-1===this._shimmedLocalStreams[r.id].indexOf(a)){this._shimmedLocalStreams[r.id].push(a)}return a};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{};e.getTracks().forEach(function(e){var r=t.getSenders().find(function(t){return t.track===e});if(r){throw new DOMException("Track already exists.","InvalidAccessError")}});var a=t.getSenders();r.apply(this,arguments);var n=t.getSenders().filter(function(e){return-1===a.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(n)};var a=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{};delete this._shimmedLocalStreams[e.id];return a.apply(this,arguments)};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{};if(e){Object.keys(this._shimmedLocalStreams).forEach(function(r){var a=t._shimmedLocalStreams[r].indexOf(e);if(-1!==a){t._shimmedLocalStreams[r].splice(a,1)}if(1===t._shimmedLocalStreams[r].length){delete t._shimmedLocalStreams[r]}})}return n.apply(this,arguments)}},shimAddTrackRemoveTrack:function shimAddTrackRemoveTrack(e){var a=n.detectBrowser(e);if(e.RTCPeerConnection.prototype.addTrack&&65<=a.version){return this.shimAddTrackRemoveTrackWithNative(e)}var i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=i.apply(this);e._reverseStreams=e._reverseStreams||{};return t.map(function(t){return e._reverseStreams[t.id]})};var o=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;r._streams=r._streams||{};r._reverseStreams=r._reverseStreams||{};t.getTracks().forEach(function(e){var t=r.getSenders().find(function(t){return t.track===e});if(t){throw new DOMException("Track already exists.","InvalidAccessError")}});if(!r._reverseStreams[t.id]){var a=new e.MediaStream(t.getTracks());r._streams[t.id]=a;r._reverseStreams[a.id]=t;t=a}o.apply(r,[t])};var s=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._streams=t._streams||{};t._reverseStreams=t._reverseStreams||{};s.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]};e.RTCPeerConnection.prototype.addTrack=function(r,a){var n=this;if("closed"===n.signalingState){throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError")}var t=[].slice.call(arguments,1);if(1!==t.length||!t[0].getTracks().find(function(e){return e===r})){throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError")}var i=n.getSenders().find(function(e){return e.track===r});if(i){throw new DOMException("Track already exists.","InvalidAccessError")}n._streams=n._streams||{};n._reverseStreams=n._reverseStreams||{};var o=n._streams[a.id];if(o){o.addTrack(r);Promise.resolve().then(function(){n.dispatchEvent(new Event("negotiationneeded"))})}else{var s=new e.MediaStream([r]);n._streams[a.id]=s;n._reverseStreams[s.id]=a;n.addStream(s)}return n.getSenders().find(function(e){return e.track===r})};function t(e,t){var r=t.sdp;Object.keys(e._reverseStreams||[]).forEach(function(t){var a=e._reverseStreams[t],n=e._streams[a.id];r=r.replace(new RegExp(n.id,"g"),a.id)});return new RTCSessionDescription({type:t.type,sdp:r})}function r(e,t){var r=t.sdp;Object.keys(e._reverseStreams||[]).forEach(function(t){var a=e._reverseStreams[t],n=e._streams[a.id];r=r.replace(new RegExp(a.id,"g"),n.id)});return new RTCSessionDescription({type:t.type,sdp:r})}["createOffer","createAnswer"].forEach(function(r){var a=e.RTCPeerConnection.prototype[r];e.RTCPeerConnection.prototype[r]=function(){var e=this,r=arguments,n=arguments.length&&"function"==typeof arguments[0];if(n){return a.apply(e,[function(a){var n=t(e,a);r[0].apply(null,[n])},function(e){if(r[1]){r[1].apply(null,e)}},arguments[2]])}return a.apply(e,arguments).then(function(r){return t(e,r)})}});var c=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this;if(!arguments.length||!arguments[0].type){return c.apply(e,arguments)}arguments[0]=r(e,arguments[0]);return c.apply(e,arguments)};var d=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function get(){var e=this,r=d.get.apply(this);if(""===r.type){return r}return t(e,r)}});e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===t.signalingState){throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError")}if(!e._pc){throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError")}var r=e._pc===t;if(!r){throw new DOMException("Sender was not created by this connection.","InvalidAccessError")}t._streams=t._streams||{};var a;Object.keys(t._streams).forEach(function(r){var n=t._streams[r].getTracks().find(function(t){return e.track===t});if(n){a=t._streams[r]}});if(a){if(1===a.getTracks().length){t.removeStream(t._reverseStreams[a.id])}else{a.removeTrack(e.track)}t.dispatchEvent(new Event("negotiationneeded"))}}},shimPeerConnection:function shimPeerConnection(e){var t=n.detectBrowser(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection){e.RTCPeerConnection=function(t,r){i("PeerConnection");if(t&&t.iceTransportPolicy){t.iceTransports=t.iceTransportPolicy}return new e.webkitRTCPeerConnection(t,r)};e.RTCPeerConnection.prototype=e.webkitRTCPeerConnection.prototype;if(e.webkitRTCPeerConnection.generateCertificate){Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function get(){return e.webkitRTCPeerConnection.generateCertificate}})}}var r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(e,t,a){var n=this,i=arguments;if(0<arguments.length&&"function"==typeof e){return r.apply(this,arguments)}if(0===r.length&&(0===arguments.length||"function"!=typeof arguments[0])){return r.apply(this,[])}var o=function(e){var t={},r=e.result();r.forEach(function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){r[t]=e.stat(t)});t[r.id]=r});return t},s=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(2<=arguments.length){var c=function(e){i[1](s(o(e)))};return r.apply(this,[c,arguments[0]])}return new Promise(function(e,t){r.apply(n,[function(t){e(s(o(t)))},t])}).then(t,a)};if(51>t.version){["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=arguments,t=this,a=new Promise(function(a,n){r.apply(t,[e[0],a,n])});if(2>e.length){return a}return a.then(function(){e[1].apply(null,[])},function(t){if(3<=e.length){e[2].apply(null,[t])}})}})}if(52>t.version){["createOffer","createAnswer"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this;if(1>arguments.length||1===arguments.length&&"object"===_typeof(arguments[0])){var t=1===arguments.length?arguments[0]:void 0;return new Promise(function(a,n){r.apply(e,[a,n,t])})}return r.apply(this,arguments)}})}["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]);return r.apply(this,arguments)}});var a=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){if(!arguments[0]){if(arguments[1]){arguments[1].apply(null)}return Promise.resolve()}return a.apply(this,arguments)}},fixNegotiationNeeded:function fixNegotiationNeeded(e){n.wrapPeerConnectionEvent(e,"negotiationneeded",function(t){var e=t.target;if("stable"!==e.signalingState){return}return t})},shimGetDisplayMedia:function shimGetDisplayMedia(e,t){if("getDisplayMedia"in e.navigator){return}if("function"!=typeof t){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}navigator.getDisplayMedia=function(e){return t(e).then(function(t){e.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:e.video.frameRate||3}};return navigator.mediaDevices.getUserMedia(e)})}}}},{"../utils.js":14,"./getusermedia":6}],6:[function(e,t){'use strict';var r=e("../utils.js"),a=r.log;t.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,i=function(e){if("object"!==_typeof(e)||e.mandatory||e.optional){return e}var t={};Object.keys(e).forEach(function(a){if("require"===a||"advanced"===a||"mediaSource"===a){return}var n="object"===_typeof(e[a])?e[a]:{ideal:e[a]};if(n.exact!==void 0&&"number"==typeof n.exact){n.min=n.max=n.exact}var r=function(e,t){if(e){return e+t.charAt(0).toUpperCase()+t.slice(1)}return"deviceId"===t?"sourceId":t};if(n.ideal!==void 0){t.optional=t.optional||[];var i={};if("number"==typeof n.ideal){i[r("min",a)]=n.ideal;t.optional.push(i);i={};i[r("max",a)]=n.ideal;t.optional.push(i)}else{i[r("",a)]=n.ideal;t.optional.push(i)}}if(n.exact!==void 0&&"number"!=typeof n.exact){t.mandatory=t.mandatory||{};t.mandatory[r("",a)]=n.exact}else{["min","max"].forEach(function(e){if(n[e]!==void 0){t.mandatory=t.mandatory||{};t.mandatory[r(e,a)]=n[e]}})}});if(e.advanced){t.optional=(t.optional||[]).concat(e.advanced)}return t},o=function(e,r){if(61<=t.version){return r(e)}e=JSON.parse(JSON.stringify(e));if(e&&"object"===_typeof(e.audio)){var o=function(e,t,r){if(t in e&&!(r in e)){e[r]=e[t];delete e[t]}};e=JSON.parse(JSON.stringify(e));o(e.audio,"autoGainControl","googAutoGainControl");o(e.audio,"noiseSuppression","googNoiseSuppression");e.audio=i(e.audio)}if(e&&"object"===_typeof(e.video)){var s=e.video.facingMode;s=s&&("object"===_typeof(s)?s:{ideal:s});var c=66>t.version;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&!(n.mediaDevices.getSupportedConstraints&&n.mediaDevices.getSupportedConstraints().facingMode&&!c)){delete e.video.facingMode;var p;if("environment"===s.exact||"environment"===s.ideal){p=["back","rear"]}else if("user"===s.exact||"user"===s.ideal){p=["front"]}if(p){return n.mediaDevices.enumerateDevices().then(function(t){t=t.filter(function(e){return"videoinput"===e.kind});var n=t.find(function(e){return p.some(function(t){return-1!==e.label.toLowerCase().indexOf(t)})});if(!n&&t.length&&-1!==p.indexOf("back")){n=t[t.length-1]}if(n){e.video.deviceId=s.exact?{exact:n.deviceId}:{ideal:n.deviceId}}e.video=i(e.video);a("chrome: "+JSON.stringify(e));return r(e)})}}e.video=i(e.video)}a("chrome: "+JSON.stringify(e));return r(e)},s=function(r){if(64<=t.version){return r}return{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[r.name]||r.name,message:r.message,constraint:r.constraint||r.constraintName,toString:function toString(){return this.name+(this.message&&": ")+this.message}}};n.getUserMedia=function getUserMedia_(e,t,r){o(e,function(e){n.webkitGetUserMedia(e,t,function(t){if(r){r(s(t))}})})};var c=function(e){return new Promise(function(t,r){n.getUserMedia(e,t,r)})};if(!n.mediaDevices){n.mediaDevices={getUserMedia:c,enumerateDevices:function enumerateDevices(){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 getSupportedConstraints(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}}if(!n.mediaDevices.getUserMedia){n.mediaDevices.getUserMedia=function(e){return c(e)}}else{var d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return o(e,function(e){return d(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length){t.getTracks().forEach(function(e){e.stop()});throw new DOMException("","NotFoundError")}return t},function(t){return Promise.reject(s(t))})})}}if("undefined"==typeof n.mediaDevices.addEventListener){n.mediaDevices.addEventListener=function(){a("Dummy mediaDevices.addEventListener called.")}}if("undefined"==typeof n.mediaDevices.removeEventListener){n.mediaDevices.removeEventListener=function(){a("Dummy mediaDevices.removeEventListener called.")}}}},{"../utils.js":14}],7:[function(e,t){'use strict';var r=e("sdp"),a=e("./utils");t.exports={shimRTCIceCandidate:function shimRTCIceCandidate(t){if(!t.RTCIceCandidate||t.RTCIceCandidate&&"foundation"in t.RTCIceCandidate.prototype){return}var n=t.RTCIceCandidate;t.RTCIceCandidate=function(e){if("object"===_typeof(e)&&e.candidate&&0===e.candidate.indexOf("a=")){e=JSON.parse(JSON.stringify(e));e.candidate=e.candidate.substr(2)}if(e.candidate&&e.candidate.length){var t=new n(e),a=r.parseCandidate(e.candidate),i=Object.assign(t,a);i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}};return i}return new n(e)};t.RTCIceCandidate.prototype=n.prototype;a.wrapPeerConnectionEvent(t,"icecandidate",function(r){if(r.candidate){Object.defineProperty(r,"candidate",{value:new t.RTCIceCandidate(r.candidate),writable:"false"})}return r})},shimCreateObjectURL:function shimCreateObjectURL(e){var t=e&&e.URL;if(!("object"===_typeof(e)&&e.HTMLMediaElement&&"srcObject"in e.HTMLMediaElement.prototype&&t.createObjectURL&&t.revokeObjectURL)){return}var r=t.createObjectURL.bind(t),n=t.revokeObjectURL.bind(t),i=new Map,o=0;t.createObjectURL=function(e){if("getTracks"in e){var t="polyblob:"+ ++o;i.set(t,e);a.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream");return t}return r(e)};t.revokeObjectURL=function(e){n(e);i.delete(e)};var s=Object.getOwnPropertyDescriptor(e.HTMLMediaElement.prototype,"src");Object.defineProperty(e.HTMLMediaElement.prototype,"src",{get:function get(){return s.get.apply(this)},set:function set(e){this.srcObject=i.get(e)||null;return s.set.apply(this,[e])}});var c=e.HTMLMediaElement.prototype.setAttribute;e.HTMLMediaElement.prototype.setAttribute=function(){if(2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()){this.srcObject=i.get(arguments[1])||null}return c.apply(this,arguments)}},shimMaxMessageSize:function shimMaxMessageSize(e){if(e.RTCSctpTransport||!e.RTCPeerConnection){return}var t=a.detectBrowser(e);if(!("sctp"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function get(){return"undefined"==typeof this._sctp?null:this._sctp}})}var n=function(e){var t=r.splitSections(e.sdp);t.shift();return t.some(function(e){var t=r.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})},i=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||2>t.length){return-1}var r=parseInt(t[1],10);return r!==r?-1:r},o=function(e){var r=65536;if("firefox"===t.browser){if(57>t.version){if(-1===e){r=16384}else{r=2147483637}}else if(60>t.version){r=57===t.version?65535:65536}else{r=2147483637}}return r},s=function(e,a){var n=65536;if("firefox"===t.browser&&57===t.version){n=65535}var i=r.matchPrefix(e.sdp,"a=max-message-size:");if(0<i.length){n=parseInt(i[0].substr(19),10)}else if("firefox"===t.browser&&-1!==a){n=2147483637}return n},c=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;e._sctp=null;if(n(arguments[0])){var t=i(arguments[0]),r=o(t),a=s(arguments[0],t),d;if(0===r&&0===a){d=Number.POSITIVE_INFINITY}else if(0===r||0===a){d=Math.max(r,a)}else{d=Math.min(r,a)}var p={};Object.defineProperty(p,"maxMessageSize",{get:function get(){return d}});e._sctp=p}return c.apply(e,arguments)}},shimSendThrowTypeError:function shimSendThrowTypeError(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype)){return}function t(e,t){var r=e.send;e.send=function(){var a=arguments[0],n=a.length||a.size||a.byteLength;if("open"===e.readyState&&t.sctp&&n>t.sctp.maxMessageSize){throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)")}return r.apply(e,arguments)}}var r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=this,a=r.apply(e,arguments);t(a,e);return a};a.wrapPeerConnectionEvent(e,"datachannel",function(r){t(r.channel,r.target);return r})}}},{"./utils":14,sdp:2}],8:[function(e,t){'use strict';var r=e("../utils"),a=e("./filtericeservers"),n=e("rtcpeerconnection-shim");t.exports={shimGetUserMedia:e("./getusermedia"),shimPeerConnection:function shimPeerConnection(e){var t=r.detectBrowser(e);if(e.RTCIceGatherer){if(!e.RTCIceCandidate){e.RTCIceCandidate=function(e){return e}}if(!e.RTCSessionDescription){e.RTCSessionDescription=function(e){return e}}if(15025>t.version){var i=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function set(e){i.set.call(this,e);var t=new Event("enabled");t.enabled=e;this.dispatchEvent(t)}})}}if(e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function get(){if(this._dtmf===void 0){if("audio"===this.track.kind){this._dtmf=new e.RTCDtmfSender(this)}else if("video"===this.track.kind){this._dtmf=null}}return this._dtmf}})}if(e.RTCDtmfSender&&!e.RTCDTMFSender){e.RTCDTMFSender=e.RTCDtmfSender}var o=n(e,t.version);e.RTCPeerConnection=function(e){if(e&&e.iceServers){e.iceServers=a(e.iceServers)}return new o(e)};e.RTCPeerConnection.prototype=o.prototype},shimReplaceTrack:function shimReplaceTrack(e){if(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){'use strict';var r=e("../utils");t.exports=function(e,t){var a=!1;e=JSON.parse(JSON.stringify(e));return e.filter(function(e){if(e&&(e.urls||e.url)){var n=e.urls||e.url;if(e.url&&!e.urls){r.deprecated("RTCIceServer.url","RTCIceServer.urls")}var i="string"==typeof n;if(i){n=[n]}n=n.filter(function(e){var r=0===e.indexOf("turn:")&&-1!==e.indexOf("transport=udp")&&-1===e.indexOf("turn:[")&&!a;if(r){a=!0;return!0}return 0===e.indexOf("stun:")&&14393<=t&&-1===e.indexOf("?transport=udp")});delete e.url;e.urls=i?n[0]:n;return!!n.length}})}},{"../utils":14}],10:[function(e,t){'use strict';t.exports=function(e){var t=e&&e.navigator,r=function(t){return{name:{PermissionDeniedError:"NotAllowedError"}[t.name]||t.name,message:t.message,constraint:t.constraint,toString:function toString(){return this.name}}},a=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return a(e).catch(function(t){return Promise.reject(r(t))})}}},{}],11:[function(e,t){'use strict';var r=e("../utils");t.exports={shimGetUserMedia:e("./getusermedia"),shimOnTrack:function shimOnTrack(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function get(){return this._ontrack},set:function set(e){if(this._ontrack){this.removeEventListener("track",this._ontrack);this.removeEventListener("addstream",this._ontrackpoly)}this.addEventListener("track",this._ontrack=e);this.addEventListener("addstream",this._ontrackpoly=function(t){t.stream.getTracks().forEach(function(e){var r=new Event("track");r.track=e;r.receiver={track:e};r.transceiver={receiver:r.receiver};r.streams=[t.stream];this.dispatchEvent(r)}.bind(this))}.bind(this))},enumerable:!0,configurable:!0})}if("object"===_typeof(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)){Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function get(){return{receiver:this.receiver}}})}},shimSourceObject:function shimSourceObject(e){if("object"===_typeof(e)){if(e.HTMLMediaElement&&!("srcObject"in e.HTMLMediaElement.prototype)){Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function get(){return this.mozSrcObject},set:function set(e){this.mozSrcObject=e}})}}},shimPeerConnection:function shimPeerConnection(e){var t=r.detectBrowser(e);if("object"!==_typeof(e)||!(e.RTCPeerConnection||e.mozRTCPeerConnection)){return}if(!e.RTCPeerConnection){e.RTCPeerConnection=function(r,a){if(38>t.version){if(r&&r.iceServers){for(var n=[],o=0,s;o<r.iceServers.length;o++){s=r.iceServers[o];if(s.hasOwnProperty("urls")){for(var c=0,d;c<s.urls.length;c++){d={url:s.urls[c]};if(0===s.urls[c].indexOf("turn")){d.username=s.username;d.credential=s.credential}n.push(d)}}else{n.push(r.iceServers[o])}}r.iceServers=n}}return new e.mozRTCPeerConnection(r,a)};e.RTCPeerConnection.prototype=e.mozRTCPeerConnection.prototype;if(e.mozRTCPeerConnection.generateCertificate){Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function get(){return e.mozRTCPeerConnection.generateCertificate}})}e.RTCSessionDescription=e.mozRTCSessionDescription;e.RTCIceCandidate=e.mozRTCIceCandidate}["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]);return r.apply(this,arguments)}});var a=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){if(!arguments[0]){if(arguments[1]){arguments[1].apply(null)}return Promise.resolve()}return a.apply(this,arguments)};var n=function(e){var t=new Map;Object.keys(e).forEach(function(r){t.set(r,e[r]);t[r]=e[r]});return t},o={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},s=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(e,r,a){return s.apply(this,[e||null]).then(function(a){if(48>t.version){a=n(a)}if(53>t.version&&!r){try{a.forEach(function(e){e.type=o[e.type]||e.type})}catch(t){if("TypeError"!==t.name){throw t}a.forEach(function(e,t){a.set(t,Object.assign({},e,{type:o[e.type]||e.type}))})}}return a}).then(r,a)}},shimSenderGetStats:function shimSenderGetStats(e){if(!("object"===_typeof(e)&&e.RTCPeerConnection&&e.RTCRtpSender)){return}if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype){return}var t=e.RTCPeerConnection.prototype.getSenders;if(t){e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(e,[]);r.forEach(function(t){t._pc=e});return r}}var r=e.RTCPeerConnection.prototype.addTrack;if(r){e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);e._pc=this;return e}}e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}},shimReceiverGetStats:function shimReceiverGetStats(e){if(!("object"===_typeof(e)&&e.RTCPeerConnection&&e.RTCRtpSender)){return}if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype){return}var t=e.RTCPeerConnection.prototype.getReceivers;if(t){e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(e,[]);r.forEach(function(t){t._pc=e});return r}}r.wrapPeerConnectionEvent(e,"track",function(t){t.receiver._pc=t.srcElement;return t});e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}},shimRemoveStream:function shimRemoveStream(e){if(!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype){return}e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;r.deprecated("removeStream","removeTrack");this.getSenders().forEach(function(r){if(r.track&&-1!==e.getTracks().indexOf(r.track)){t.removeTrack(r)}})}},shimRTCDataChannel:function shimRTCDataChannel(e){if(e.DataChannel&&!e.RTCDataChannel){e.RTCDataChannel=e.DataChannel}},shimGetDisplayMedia:function shimGetDisplayMedia(e,t){if("getDisplayMedia"in e.navigator){return}navigator.getDisplayMedia=function(e){if(!(e&&e.video)){var r=new DOMException("getDisplayMedia without video constraints is undefined");r.name="NotFoundError";r.code=8;return Promise.reject(r)}if(!0===e.video){e.video={mediaSource:t}}else{e.video.mediaSource=t}return navigator.mediaDevices.getUserMedia(e)}}}},{"../utils":14,"./getusermedia":12}],12:[function(e,t){'use strict';var r=e("../utils"),a=r.log;t.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,i=e&&e.MediaStreamTrack,o=function(t){return{name:{InternalError:"NotReadableError",NotSupportedError:"TypeError",PermissionDeniedError:"NotAllowedError",SecurityError:"NotAllowedError"}[t.name]||t.name,message:{"The operation is insecure.":"The request is not allowed by the user agent or the platform in the current context."}[t.message]||t.message,constraint:t.constraint,toString:function toString(){return this.name+(this.message&&": ")+this.message}}},s=function(e,r,i){var s=function(e){if("object"!==_typeof(e)||e.require){return e}var t=[];Object.keys(e).forEach(function(a){if("require"===a||"advanced"===a||"mediaSource"===a){return}var n=e[a]="object"===_typeof(e[a])?e[a]:{ideal:e[a]};if(n.min!==void 0||n.max!==void 0||n.exact!==void 0){t.push(a)}if(n.exact!==void 0){if("number"==typeof n.exact){n.min=n.max=n.exact}else{e[a]=n.exact}delete n.exact}if(n.ideal!==void 0){e.advanced=e.advanced||[];var r={};if("number"==typeof n.ideal){r[a]={min:n.ideal,max:n.ideal}}else{r[a]=n.ideal}e.advanced.push(r);delete n.ideal;if(!Object.keys(n).length){delete e[a]}}});if(t.length){e.require=t}return e};e=JSON.parse(JSON.stringify(e));if(38>t.version){a("spec: "+JSON.stringify(e));if(e.audio){e.audio=s(e.audio)}if(e.video){e.video=s(e.video)}a("ff37: "+JSON.stringify(e))}return n.mozGetUserMedia(e,r,function(t){i(o(t))})},c=function(e){return new Promise(function(t,r){s(e,t,r)})};if(!n.mediaDevices){n.mediaDevices={getUserMedia:c,addEventListener:function addEventListener(){},removeEventListener:function removeEventListener(){}}}n.mediaDevices.enumerateDevices=n.mediaDevices.enumerateDevices||function(){return new Promise(function(e){e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})};if(41>t.version){var d=n.mediaDevices.enumerateDevices.bind(n.mediaDevices);n.mediaDevices.enumerateDevices=function(){return d().then(void 0,function(t){if("NotFoundError"===t.name){return[]}throw t})}}if(49>t.version){var p=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return p(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length){t.getTracks().forEach(function(e){e.stop()});throw new DOMException("The object can not be found here.","NotFoundError")}return t},function(t){return Promise.reject(o(t))})}}if(!(55<t.version&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var m=function(e,t,r){if(t in e&&!(r in e)){e[r]=e[t];delete e[t]}},l=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){if("object"===_typeof(e)&&"object"===_typeof(e.audio)){e=JSON.parse(JSON.stringify(e));m(e.audio,"autoGainControl","mozAutoGainControl");m(e.audio,"noiseSuppression","mozNoiseSuppression")}return l(e)};if(i&&i.prototype.getSettings){var g=i.prototype.getSettings;i.prototype.getSettings=function(){var e=g.apply(this,arguments);m(e,"mozAutoGainControl","autoGainControl");m(e,"mozNoiseSuppression","noiseSuppression");return e}}if(i&&i.prototype.applyConstraints){var h=i.prototype.applyConstraints;i.prototype.applyConstraints=function(e){if("audio"===this.kind&&"object"===_typeof(e)){e=JSON.parse(JSON.stringify(e));m(e,"autoGainControl","mozAutoGainControl");m(e,"noiseSuppression","mozNoiseSuppression")}return h.apply(this,[e])}}}n.getUserMedia=function(e,a,i){if(44>t.version){return s(e,a,i)}r.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia");n.mediaDevices.getUserMedia(e).then(a,i)}}},{"../utils":14}],13:[function(e,t){'use strict';var r=e("../utils");t.exports={shimLocalStreamsAPI:function shimLocalStreamsAPI(e){if("object"!==_typeof(e)||!e.RTCPeerConnection){return}if(!("getLocalStreams"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.getLocalStreams=function(){if(!this._localStreams){this._localStreams=[]}return this._localStreams}}if(!("getStreamById"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.getStreamById=function(e){var t=null;if(this._localStreams){this._localStreams.forEach(function(r){if(r.id===e){t=r}})}if(this._remoteStreams){this._remoteStreams.forEach(function(r){if(r.id===e){t=r}})}return t}}if(!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){if(!this._localStreams){this._localStreams=[]}if(-1===this._localStreams.indexOf(e)){this._localStreams.push(e)}var r=this;e.getTracks().forEach(function(a){t.call(r,a,e)})};e.RTCPeerConnection.prototype.addTrack=function(e,r){if(r){if(!this._localStreams){this._localStreams=[r]}else if(-1===this._localStreams.indexOf(r)){this._localStreams.push(r)}}return t.call(this,e,r)}}if(!("removeStream"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.removeStream=function(e){if(!this._localStreams){this._localStreams=[]}var t=this._localStreams.indexOf(e);if(-1===t){return}this._localStreams.splice(t,1);var r=this,a=e.getTracks();this.getSenders().forEach(function(e){if(-1!==a.indexOf(e.track)){r.removeTrack(e)}})}}},shimRemoteStreamsAPI:function shimRemoteStreamsAPI(e){if("object"!==_typeof(e)||!e.RTCPeerConnection){return}if(!("getRemoteStreams"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}}if(!("onaddstream"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function get(){return this._onaddstream},set:function set(e){if(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 e=this;if(!this._onaddstreampoly){this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(function(t){if(!e._remoteStreams){e._remoteStreams=[]}if(0<=e._remoteStreams.indexOf(t)){return}e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t;e.dispatchEvent(r)})})}return t.apply(e,arguments)}}},shimCallbacksAPI:function shimCallbacksAPI(e){if("object"!==_typeof(e)||!e.RTCPeerConnection){return}var t=e.RTCPeerConnection.prototype,r=t.createOffer,a=t.createAnswer,n=t.setLocalDescription,i=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){var a=2<=arguments.length?arguments[2]:arguments[0],n=r.apply(this,[a]);if(!t){return n}n.then(e,t);return Promise.resolve()};t.createAnswer=function(e,t){var r=2<=arguments.length?arguments[2]:arguments[0],n=a.apply(this,[r]);if(!t){return n}n.then(e,t);return Promise.resolve()};var s=function(e,t,r){var a=n.apply(this,[e]);if(!r){return a}a.then(t,r);return Promise.resolve()};t.setLocalDescription=s;s=function(e,t,r){var a=i.apply(this,[e]);if(!r){return a}a.then(t,r);return Promise.resolve()};t.setRemoteDescription=s;s=function(e,t,r){var a=o.apply(this,[e]);if(!r){return a}a.then(t,r);return Promise.resolve()};t.addIceCandidate=s},shimGetUserMedia:function shimGetUserMedia(e){var t=e&&e.navigator;if(!t.getUserMedia){if(t.webkitGetUserMedia){t.getUserMedia=t.webkitGetUserMedia.bind(t)}else if(t.mediaDevices&&t.mediaDevices.getUserMedia){t.getUserMedia=function(e,r,a){t.mediaDevices.getUserMedia(e).then(r,a)}.bind(t)}}},shimRTCIceServerUrls:function shimRTCIceServerUrls(e){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,a){if(e&&e.iceServers){for(var n=[],o=0,s;o<e.iceServers.length;o++){s=e.iceServers[o];if(!s.hasOwnProperty("urls")&&s.hasOwnProperty("url")){r.deprecated("RTCIceServer.url","RTCIceServer.urls");s=JSON.parse(JSON.stringify(s));s.urls=s.url;delete s.url;n.push(s)}else{n.push(e.iceServers[o])}}e.iceServers=n}return new t(e,a)};e.RTCPeerConnection.prototype=t.prototype;if("generateCertificate"in e.RTCPeerConnection){Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function get(){return t.generateCertificate}})}},shimTrackEventTransceiver:function shimTrackEventTransceiver(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&"receiver"in e.RTCTrackEvent.prototype&&!e.RTCTransceiver){Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function get(){return{receiver:this.receiver}}})}},shimCreateOfferLegacy:function shimCreateOfferLegacy(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){var r=this;if(e){if("undefined"!=typeof e.offerToReceiveAudio){e.offerToReceiveAudio=!!e.offerToReceiveAudio}var a=r.getTransceivers().find(function(e){return e.sender.track&&"audio"===e.sender.track.kind});if(!1===e.offerToReceiveAudio&&a){if("sendrecv"===a.direction){if(a.setDirection){a.setDirection("sendonly")}else{a.direction="sendonly"}}else if("recvonly"===a.direction){if(a.setDirection){a.setDirection("inactive")}else{a.direction="inactive"}}}else if(!0===e.offerToReceiveAudio&&!a){r.addTransceiver("audio")}if("undefined"!=typeof e.offerToReceiveVideo){e.offerToReceiveVideo=!!e.offerToReceiveVideo}var n=r.getTransceivers().find(function(e){return e.sender.track&&"video"===e.sender.track.kind});if(!1===e.offerToReceiveVideo&&n){if("sendrecv"===n.direction){n.setDirection("sendonly")}else if("recvonly"===n.direction){n.setDirection("inactive")}}else if(!0===e.offerToReceiveVideo&&!n){r.addTransceiver("video")}}return t.apply(r,arguments)}}}},{"../utils":14}],14:[function(e,t){'use strict';var a=!0,n=!0;function r(e,t,r){var a=e.match(t);return a&&a.length>=r&&parseInt(a[r],10)}t.exports={extractVersion:r,wrapPeerConnectionEvent:function(e,t,r){if(!e.RTCPeerConnection){return}var a=e.RTCPeerConnection.prototype,n=a.addEventListener;a.addEventListener=function(e,a){if(e!==t){return n.apply(this,arguments)}var i=function(t){var e=r(t);if(e){a(e)}};this._eventMap=this._eventMap||{};this._eventMap[a]=i;return n.apply(this,[e,i])};var i=a.removeEventListener;a.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[r]){return i.apply(this,arguments)}var a=this._eventMap[r];delete this._eventMap[r];return i.apply(this,[e,a])};Object.defineProperty(a,"on"+t,{get:function get(){return this["_on"+t]},set:function set(e){if(this["_on"+t]){this.removeEventListener(t,this["_on"+t]);delete this["_on"+t]}if(e){this.addEventListener(t,this["_on"+t]=e)}},enumerable:!0,configurable:!0})},disableLog:function disableLog(e){if("boolean"!=typeof e){return new Error("Argument type: "+_typeof(e)+". Please use a boolean.")}a=e;return e?"adapter.js logging disabled":"adapter.js logging enabled"},disableWarnings:function disableWarnings(e){if("boolean"!=typeof e){return new Error("Argument type: "+_typeof(e)+". Please use a boolean.")}n=!e;return"adapter.js deprecation warnings "+(e?"disabled":"enabled")},log:function log(){if("object"===("undefined"==typeof window?"undefined":_typeof(window))){if(a){return}if("undefined"!=typeof console&&"function"==typeof console.log){console.log.apply(console,arguments)}}},deprecated:function deprecated(e,t){if(!n){return}console.warn(e+" is deprecated, please use "+t+" instead.")},detectBrowser:function detectBrowser(e){var t=e&&e.navigator,a={};a.browser=null;a.version=null;if("undefined"==typeof e||!e.navigator){a.browser="Not a browser.";return a}if(t.mozGetUserMedia){a.browser="firefox";a.version=r(t.userAgent,/Firefox\/(\d+)\./,1)}else if(t.webkitGetUserMedia){a.browser="chrome";a.version=r(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2)}else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/)){a.browser="edge";a.version=r(t.userAgent,/Edge\/(\d+).(\d+)$/,2)}else if(e.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./)){a.browser="safari";a.version=r(t.userAgent,/AppleWebKit\/(\d+)\./,1)}else{a.browser="Not a supported browser.";return a}return a}}},{}]},{},[3])(3)}); //# sourceMappingURL=adapter.min.js.map