芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/public_html/cepali/lib/amd/build/adapter.min.js
define([],function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g
=14393&&a.indexOf("?transport=udp")===-1}),delete a.url,a.urls=e?d[0]:d,!!d.length}})}function f(a,b){var c={codecs:[],headerExtensions:[],fecMechanisms:[]},d=function(a,b){a=parseInt(a,10);for(var c=0;c
0;g--)this._iceGatherers.push(new a.RTCIceGatherer({iceServers:c.iceServers,gatherPolicy:c.iceTransportPolicy}));else c.iceCandidatePoolSize=0;this._config=c,this.transceivers=[],this._sdpSessionId=j.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};m.prototype.onicecandidate=null,m.prototype.onaddstream=null,m.prototype.ontrack=null,m.prototype.onremovestream=null,m.prototype.onsignalingstatechange=null,m.prototype.oniceconnectionstatechange=null,m.prototype.onconnectionstatechange=null,m.prototype.onicegatheringstatechange=null,m.prototype.onnegotiationneeded=null,m.prototype.ondatachannel=null,m.prototype._dispatchEvent=function(a,b){this._isClosed||(this.dispatchEvent(b),"function"==typeof this["on"+a]&&this["on"+a](b))},m.prototype._emitGatheringStateChange=function(){var a=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",a)},m.prototype.getConfiguration=function(){return this._config},m.prototype.getLocalStreams=function(){return this.localStreams},m.prototype.getRemoteStreams=function(){return this.remoteStreams},m.prototype._createTransceiver=function(a,b){var c=this.transceivers.length>0,d={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:a,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&c)d.iceTransport=this.transceivers[0].iceTransport,d.dtlsTransport=this.transceivers[0].dtlsTransport;else{var e=this._createIceAndDtlsTransports();d.iceTransport=e.iceTransport,d.dtlsTransport=e.dtlsTransport}return b||this.transceivers.push(d),d},m.prototype.addTrack=function(b,c){if(this._isClosed)throw i("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var d=this.transceivers.find(function(a){return a.track===b});if(d)throw i("InvalidAccessError","Track already exists.");for(var e,f=0;f
=15025)a.getTracks().forEach(function(b){c.addTrack(b,a)});else{var d=a.clone();a.getTracks().forEach(function(a,b){var c=d.getTracks()[b];a.addEventListener("enabled",function(a){c.enabled=a.enabled})}),d.getTracks().forEach(function(a){c.addTrack(a,d)})}},m.prototype.removeTrack=function(b){if(this._isClosed)throw i("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(b instanceof a.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var c=this.transceivers.find(function(a){return a.rtpSender===b});if(!c)throw i("InvalidAccessError","Sender was not created by this connection.");var d=c.stream;c.rtpSender.stop(),c.rtpSender=null,c.track=null,c.stream=null;var e=this.transceivers.map(function(a){return a.stream});e.indexOf(d)===-1&&this.localStreams.indexOf(d)>-1&&this.localStreams.splice(this.localStreams.indexOf(d),1),this._maybeFireNegotiationNeeded()},m.prototype.removeStream=function(a){var b=this;a.getTracks().forEach(function(a){var c=b.getSenders().find(function(b){return b.track===a});c&&b.removeTrack(c)})},m.prototype.getSenders=function(){return this.transceivers.filter(function(a){return!!a.rtpSender}).map(function(a){return a.rtpSender})},m.prototype.getReceivers=function(){return this.transceivers.filter(function(a){return!!a.rtpReceiver}).map(function(a){return a.rtpReceiver})},m.prototype._createIceGatherer=function(b,c){var d=this;if(c&&b>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var e=new a.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(e,"state",{value:"new",writable:!0}),this.transceivers[b].bufferedCandidateEvents=[],this.transceivers[b].bufferCandidates=function(a){var c=!a.candidate||0===Object.keys(a.candidate).length;e.state=c?"completed":"gathering",null!==d.transceivers[b].bufferedCandidateEvents&&d.transceivers[b].bufferedCandidateEvents.push(a)},e.addEventListener("localcandidate",this.transceivers[b].bufferCandidates),e},m.prototype._gather=function(b,c){var d=this,e=this.transceivers[c].iceGatherer;if(!e.onlocalcandidate){var f=this.transceivers[c].bufferedCandidateEvents;this.transceivers[c].bufferedCandidateEvents=null,e.removeEventListener("localcandidate",this.transceivers[c].bufferCandidates),e.onlocalcandidate=function(a){if(!(d.usingBundle&&c>0)){var f=new Event("icecandidate");f.candidate={sdpMid:b,sdpMLineIndex:c};var g=a.candidate,h=!g||0===Object.keys(g).length;if(h)"new"!==e.state&&"gathering"!==e.state||(e.state="completed");else{"new"===e.state&&(e.state="gathering"),g.component=1,g.ufrag=e.getLocalParameters().usernameFragment;var i=j.writeCandidate(g);f.candidate=Object.assign(f.candidate,j.parseCandidate(i)),f.candidate.candidate=i,f.candidate.toJSON=function(){return{candidate:f.candidate.candidate,sdpMid:f.candidate.sdpMid,sdpMLineIndex:f.candidate.sdpMLineIndex,usernameFragment:f.candidate.usernameFragment}}}var k=j.getMediaSections(d.localDescription.sdp);h?k[f.candidate.sdpMLineIndex]+="a=end-of-candidates\r\n":k[f.candidate.sdpMLineIndex]+="a="+f.candidate.candidate+"\r\n",d.localDescription.sdp=j.getDescription(d.localDescription.sdp)+k.join("");var l=d.transceivers.every(function(a){return a.iceGatherer&&"completed"===a.iceGatherer.state});"gathering"!==d.iceGatheringState&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),h||d._dispatchEvent("icecandidate",f),l&&(d._dispatchEvent("icecandidate",new Event("icecandidate")),d.iceGatheringState="complete",d._emitGatheringStateChange())}},a.setTimeout(function(){f.forEach(function(a){e.onlocalcandidate(a)})},0)}},m.prototype._createIceAndDtlsTransports=function(){var b=this,c=new a.RTCIceTransport(null);c.onicestatechange=function(){b._updateIceConnectionState(),b._updateConnectionState()};var d=new a.RTCDtlsTransport(c);return d.ondtlsstatechange=function(){b._updateConnectionState()},d.onerror=function(){Object.defineProperty(d,"state",{value:"failed",writable:!0}),b._updateConnectionState()},{iceTransport:c,dtlsTransport:d}},m.prototype._disposeIceAndDtlsTransports=function(a){var b=this.transceivers[a].iceGatherer;b&&(delete b.onlocalcandidate,delete this.transceivers[a].iceGatherer);var c=this.transceivers[a].iceTransport;c&&(delete c.onicestatechange,delete this.transceivers[a].iceTransport);var d=this.transceivers[a].dtlsTransport;d&&(delete d.ondtlsstatechange,delete d.onerror,delete this.transceivers[a].dtlsTransport)},m.prototype._transceive=function(a,c,d){var e=f(a.localCapabilities,a.remoteCapabilities);c&&a.rtpSender&&(e.encodings=a.sendEncodingParameters,e.rtcp={cname:j.localCName,compound:a.rtcpParameters.compound},a.recvEncodingParameters.length&&(e.rtcp.ssrc=a.recvEncodingParameters[0].ssrc),a.rtpSender.send(e)),d&&a.rtpReceiver&&e.codecs.length>0&&("video"===a.kind&&a.recvEncodingParameters&&b<15019&&a.recvEncodingParameters.forEach(function(a){delete a.rtx}),a.recvEncodingParameters.length?e.encodings=a.recvEncodingParameters:e.encodings=[{}],e.rtcp={compound:a.rtcpParameters.compound},a.rtcpParameters.cname&&(e.rtcp.cname=a.rtcpParameters.cname),a.sendEncodingParameters.length&&(e.rtcp.ssrc=a.sendEncodingParameters[0].ssrc),a.rtpReceiver.receive(e))},m.prototype.setLocalDescription=function(a){var b=this;if(["offer","answer"].indexOf(a.type)===-1)return Promise.reject(i("TypeError",'Unsupported type "'+a.type+'"'));if(!g("setLocalDescription",a.type,b.signalingState)||b._isClosed)return Promise.reject(i("InvalidStateError","Can not set local "+a.type+" in state "+b.signalingState));var c,d;if("offer"===a.type)c=j.splitSections(a.sdp),d=c.shift(),c.forEach(function(a,c){var d=j.parseRtpParameters(a);b.transceivers[c].localCapabilities=d}),b.transceivers.forEach(function(a,c){b._gather(a.mid,c)});else if("answer"===a.type){c=j.splitSections(b.remoteDescription.sdp),d=c.shift();var e=j.matchPrefix(d,"a=ice-lite").length>0;c.forEach(function(a,c){var g=b.transceivers[c],h=g.iceGatherer,i=g.iceTransport,k=g.dtlsTransport,l=g.localCapabilities,m=g.remoteCapabilities,n=j.isRejected(a)&&0===j.matchPrefix(a,"a=bundle-only").length;if(!n&&!g.rejected){var o=j.getIceParameters(a,d),p=j.getDtlsParameters(a,d);e&&(p.role="server"),b.usingBundle&&0!==c||(b._gather(g.mid,c),"new"===i.state&&i.start(h,o,e?"controlling":"controlled"),"new"===k.state&&k.start(p));var q=f(l,m);b._transceive(g,q.codecs.length>0,!1)}})}return b.localDescription={type:a.type,sdp:a.sdp},"offer"===a.type?b._updateSignalingState("have-local-offer"):b._updateSignalingState("stable"),Promise.resolve()},m.prototype.setRemoteDescription=function(d){var e=this;if(["offer","answer"].indexOf(d.type)===-1)return Promise.reject(i("TypeError",'Unsupported type "'+d.type+'"'));if(!g("setRemoteDescription",d.type,e.signalingState)||e._isClosed)return Promise.reject(i("InvalidStateError","Can not set remote "+d.type+" in state "+e.signalingState));var f={};e.remoteStreams.forEach(function(a){f[a.id]=a});var m=[],n=j.splitSections(d.sdp),o=n.shift(),p=j.matchPrefix(o,"a=ice-lite").length>0,q=j.matchPrefix(o,"a=group:BUNDLE ").length>0;e.usingBundle=q;var r=j.matchPrefix(o,"a=ice-options:")[0];return r?e.canTrickleIceCandidates=r.substr(14).split(" ").indexOf("trickle")>=0:e.canTrickleIceCandidates=!1,n.forEach(function(g,i){var l=j.splitLines(g),n=j.getKind(g),r=j.isRejected(g)&&0===j.matchPrefix(g,"a=bundle-only").length,s=l[0].substr(2).split(" ")[2],t=j.getDirection(g,o),u=j.parseMsid(g),v=j.getMid(g)||j.generateIdentifier();if("application"===n&&"DTLS/SCTP"===s||r)return void(e.transceivers[i]={mid:v,kind:n,rejected:!0});!r&&e.transceivers[i]&&e.transceivers[i].rejected&&(e.transceivers[i]=e._createTransceiver(n,!0));var w,x,y,z,A,B,C,D,E,F,G,H=j.parseRtpParameters(g);r||(F=j.getIceParameters(g,o),G=j.getDtlsParameters(g,o),G.role="client"),C=j.parseRtpEncodingParameters(g);var I=j.parseRtcpParameters(g),J=j.matchPrefix(g,"a=end-of-candidates",o).length>0,K=j.matchPrefix(g,"a=candidate:").map(function(a){return j.parseCandidate(a)}).filter(function(a){return 1===a.component});if(("offer"===d.type||"answer"===d.type)&&!r&&q&&i>0&&e.transceivers[i]&&(e._disposeIceAndDtlsTransports(i),e.transceivers[i].iceGatherer=e.transceivers[0].iceGatherer,e.transceivers[i].iceTransport=e.transceivers[0].iceTransport,e.transceivers[i].dtlsTransport=e.transceivers[0].dtlsTransport,e.transceivers[i].rtpSender&&e.transceivers[i].rtpSender.setTransport(e.transceivers[0].dtlsTransport),e.transceivers[i].rtpReceiver&&e.transceivers[i].rtpReceiver.setTransport(e.transceivers[0].dtlsTransport)),"offer"!==d.type||r)"answer"!==d.type||r||(w=e.transceivers[i],x=w.iceGatherer,y=w.iceTransport,z=w.dtlsTransport,A=w.rtpReceiver,B=w.sendEncodingParameters,D=w.localCapabilities,e.transceivers[i].recvEncodingParameters=C,e.transceivers[i].remoteCapabilities=H,e.transceivers[i].rtcpParameters=I,K.length&&"new"===y.state&&(!p&&!J||q&&0!==i?K.forEach(function(a){h(w.iceTransport,a)}):y.setRemoteCandidates(K)),q&&0!==i||("new"===y.state&&y.start(x,F,"controlling"),"new"===z.state&&z.start(G)),e._transceive(w,"sendrecv"===t||"recvonly"===t,"sendrecv"===t||"sendonly"===t),!A||"sendrecv"!==t&&"sendonly"!==t?delete w.rtpReceiver:(E=A.track,u?(f[u.stream]||(f[u.stream]=new a.MediaStream),c(E,f[u.stream]),m.push([E,A,f[u.stream]])):(f["default"]||(f["default"]=new a.MediaStream),c(E,f["default"]),m.push([E,A,f["default"]]))));else{w=e.transceivers[i]||e._createTransceiver(n),w.mid=v,w.iceGatherer||(w.iceGatherer=e._createIceGatherer(i,q)),K.length&&"new"===w.iceTransport.state&&(!J||q&&0!==i?K.forEach(function(a){h(w.iceTransport,a)}):w.iceTransport.setRemoteCandidates(K)),D=a.RTCRtpReceiver.getCapabilities(n),b<15019&&(D.codecs=D.codecs.filter(function(a){return"rtx"!==a.name})),B=w.sendEncodingParameters||[{ssrc:1001*(2*i+2)}];var L=!1;if("sendrecv"===t||"sendonly"===t){if(L=!w.rtpReceiver,A=w.rtpReceiver||new a.RTCRtpReceiver(w.dtlsTransport,n),L){var M;E=A.track,u&&"-"===u.stream||(u?(f[u.stream]||(f[u.stream]=new a.MediaStream,Object.defineProperty(f[u.stream],"id",{get:function(){return u.stream}})),Object.defineProperty(E,"id",{get:function(){return u.track}}),M=f[u.stream]):(f["default"]||(f["default"]=new a.MediaStream),M=f["default"])),M&&(c(E,M),w.associatedRemoteMediaStreams.push(M)),m.push([E,A,M])}}else w.rtpReceiver&&w.rtpReceiver.track&&(w.associatedRemoteMediaStreams.forEach(function(a){var b=a.getTracks().find(function(a){return a.id===w.rtpReceiver.track.id});b&&k(b,a)}),w.associatedRemoteMediaStreams=[]);w.localCapabilities=D,w.remoteCapabilities=H,w.rtpReceiver=A,w.rtcpParameters=I,w.sendEncodingParameters=B,w.recvEncodingParameters=C,e._transceive(e.transceivers[i],!1,L)}}),void 0===e._dtlsRole&&(e._dtlsRole="offer"===d.type?"active":"passive"),e.remoteDescription={type:d.type,sdp:d.sdp},"offer"===d.type?e._updateSignalingState("have-remote-offer"):e._updateSignalingState("stable"),Object.keys(f).forEach(function(b){var c=f[b];if(c.getTracks().length){if(e.remoteStreams.indexOf(c)===-1){e.remoteStreams.push(c);var d=new Event("addstream");d.stream=c,a.setTimeout(function(){e._dispatchEvent("addstream",d)})}m.forEach(function(a){var b=a[0],d=a[1];c.id===a[2].id&&l(e,b,d,[c])})}}),m.forEach(function(a){a[2]||l(e,a[0],a[1],[])}),a.setTimeout(function(){e&&e.transceivers&&e.transceivers.forEach(function(a){a.iceTransport&&"new"===a.iceTransport.state&&a.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),a.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},m.prototype.close=function(){this.transceivers.forEach(function(a){a.iceTransport&&a.iceTransport.stop(),a.dtlsTransport&&a.dtlsTransport.stop(),a.rtpSender&&a.rtpSender.stop(),a.rtpReceiver&&a.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},m.prototype._updateSignalingState=function(a){this.signalingState=a;var b=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",b)},m.prototype._maybeFireNegotiationNeeded=function(){var b=this;"stable"===this.signalingState&&this.needNegotiation!==!0&&(this.needNegotiation=!0,a.setTimeout(function(){if(b.needNegotiation){b.needNegotiation=!1;var a=new Event("negotiationneeded");b._dispatchEvent("negotiationneeded",a)}},0))},m.prototype._updateIceConnectionState=function(){var a,b={"new":0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(a){b[a.iceTransport.state]++}),a="new",b.failed>0?a="failed":b.checking>0?a="checking":b.disconnected>0?a="disconnected":b["new"]>0?a="new":b.connected>0?a="connected":b.completed>0&&(a="completed"),a!==this.iceConnectionState){this.iceConnectionState=a;var c=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",c)}},m.prototype._updateConnectionState=function(){var a,b={"new":0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(a){b[a.iceTransport.state]++,b[a.dtlsTransport.state]++}),b.connected+=b.completed,a="new",b.failed>0?a="failed":b.connecting>0?a="connecting":b.disconnected>0?a="disconnected":b["new"]>0?a="new":b.connected>0&&(a="connected"),a!==this.connectionState){this.connectionState=a;var c=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",c)}},m.prototype.createOffer=function(){var c=this;if(c._isClosed)return Promise.reject(i("InvalidStateError","Can not call createOffer after close"));var e=c.transceivers.filter(function(a){return"audio"===a.kind}).length,f=c.transceivers.filter(function(a){return"video"===a.kind}).length,g=arguments[0];if(g){if(g.mandatory||g.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==g.offerToReceiveAudio&&(e=g.offerToReceiveAudio===!0?1:g.offerToReceiveAudio===!1?0:g.offerToReceiveAudio),void 0!==g.offerToReceiveVideo&&(f=g.offerToReceiveVideo===!0?1:g.offerToReceiveVideo===!1?0:g.offerToReceiveVideo)}for(c.transceivers.forEach(function(a){"audio"===a.kind?(e--,e<0&&(a.wantReceive=!1)):"video"===a.kind&&(f--,f<0&&(a.wantReceive=!1))});e>0||f>0;)e>0&&(c._createTransceiver("audio"),e--),f>0&&(c._createTransceiver("video"),f--);var h=j.writeSessionBoilerplate(c._sdpSessionId,c._sdpSessionVersion++);c.transceivers.forEach(function(d,e){var f=d.track,g=d.kind,h=d.mid||j.generateIdentifier();d.mid=h,d.iceGatherer||(d.iceGatherer=c._createIceGatherer(e,c.usingBundle));var i=a.RTCRtpSender.getCapabilities(g);b<15019&&(i.codecs=i.codecs.filter(function(a){return"rtx"!==a.name})),i.codecs.forEach(function(a){"H264"===a.name&&void 0===a.parameters["level-asymmetry-allowed"]&&(a.parameters["level-asymmetry-allowed"]="1"),d.remoteCapabilities&&d.remoteCapabilities.codecs&&d.remoteCapabilities.codecs.forEach(function(b){a.name.toLowerCase()===b.name.toLowerCase()&&a.clockRate===b.clockRate&&(a.preferredPayloadType=b.payloadType)})}),i.headerExtensions.forEach(function(a){var b=d.remoteCapabilities&&d.remoteCapabilities.headerExtensions||[];b.forEach(function(b){a.uri===b.uri&&(a.id=b.id)})});var k=d.sendEncodingParameters||[{ssrc:1001*(2*e+1)}];f&&b>=15019&&"video"===g&&!k[0].rtx&&(k[0].rtx={ssrc:k[0].ssrc+1}),d.wantReceive&&(d.rtpReceiver=new a.RTCRtpReceiver(d.dtlsTransport,g)),d.localCapabilities=i,d.sendEncodingParameters=k}),"max-compat"!==c._config.bundlePolicy&&(h+="a=group:BUNDLE "+c.transceivers.map(function(a){return a.mid}).join(" ")+"\r\n"),h+="a=ice-options:trickle\r\n",c.transceivers.forEach(function(a,b){h+=d(a,a.localCapabilities,"offer",a.stream,c._dtlsRole),h+="a=rtcp-rsize\r\n",!a.iceGatherer||"new"===c.iceGatheringState||0!==b&&c.usingBundle||(a.iceGatherer.getLocalCandidates().forEach(function(a){a.component=1,h+="a="+j.writeCandidate(a)+"\r\n"}),"completed"===a.iceGatherer.state&&(h+="a=end-of-candidates\r\n"))});var k=new a.RTCSessionDescription({type:"offer",sdp:h});return Promise.resolve(k)},m.prototype.createAnswer=function(){var c=this;if(c._isClosed)return Promise.reject(i("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==c.signalingState&&"have-local-pranswer"!==c.signalingState)return Promise.reject(i("InvalidStateError","Can not call createAnswer in signalingState "+c.signalingState));var e=j.writeSessionBoilerplate(c._sdpSessionId,c._sdpSessionVersion++);c.usingBundle&&(e+="a=group:BUNDLE "+c.transceivers.map(function(a){return a.mid}).join(" ")+"\r\n");var g=j.getMediaSections(c.remoteDescription.sdp).length;c.transceivers.forEach(function(a,h){if(!(h+1>g)){if(a.rejected)return"application"===a.kind?e+="m=application 0 DTLS/SCTP 5000\r\n":"audio"===a.kind?e+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===a.kind&&(e+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(e+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+a.mid+"\r\n");if(a.stream){var i;"audio"===a.kind?i=a.stream.getAudioTracks()[0]:"video"===a.kind&&(i=a.stream.getVideoTracks()[0]),i&&b>=15019&&"video"===a.kind&&!a.sendEncodingParameters[0].rtx&&(a.sendEncodingParameters[0].rtx={ssrc:a.sendEncodingParameters[0].ssrc+1})}var j=f(a.localCapabilities,a.remoteCapabilities),k=j.codecs.filter(function(a){return"rtx"===a.name.toLowerCase()}).length;!k&&a.sendEncodingParameters[0].rtx&&delete a.sendEncodingParameters[0].rtx,e+=d(a,j,"answer",a.stream,c._dtlsRole),a.rtcpParameters&&a.rtcpParameters.reducedSize&&(e+="a=rtcp-rsize\r\n")}});var h=new a.RTCSessionDescription({type:"answer",sdp:e});return Promise.resolve(h)},m.prototype.addIceCandidate=function(a){var b,c=this;return a&&void 0===a.sdpMLineIndex&&!a.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(d,e){if(!c.remoteDescription)return e(i("InvalidStateError","Can not add ICE candidate without a remote description"));if(a&&""!==a.candidate){var f=a.sdpMLineIndex;if(a.sdpMid)for(var g=0;g
0?j.parseCandidate(a.candidate):{};if("tcp"===l.protocol&&(0===l.port||9===l.port))return d();if(l.component&&1!==l.component)return d();if((0===f||f>0&&k.iceTransport!==c.transceivers[0].iceTransport)&&!h(k.iceTransport,l))return e(i("OperationError","Can not add ICE candidate"));var m=a.candidate.trim();0===m.indexOf("a=")&&(m=m.substr(2)),b=j.getMediaSections(c.remoteDescription.sdp),b[f]+="a="+(l.type?m:"end-of-candidates")+"\r\n",c.remoteDescription.sdp=j.getDescription(c.remoteDescription.sdp)+b.join("")}else for(var n=0;n
0?"m="+a:a).trim()+"\r\n"})},d.getDescription=function(a){var b=d.splitSections(a);return b&&b[0]},d.getMediaSections=function(a){var b=d.splitSections(a);return b.shift(),b},d.matchPrefix=function(a,b){return d.splitLines(a).filter(function(a){return 0===a.indexOf(b)})},d.parseCandidate=function(a){var b;b=0===a.indexOf("a=candidate:")?a.substring(12).split(" "):a.substring(10).split(" ");for(var c={foundation:b[0],component:parseInt(b[1],10),protocol:b[2].toLowerCase(),priority:parseInt(b[3],10),ip:b[4],port:parseInt(b[5],10),type:b[7]},d=8;d
0?b[0].split("/")[1]:"sendrecv",uri:b[1]}},d.writeExtmap=function(a){return"a=extmap:"+(a.id||a.preferredId)+(a.direction&&"sendrecv"!==a.direction?"/"+a.direction:"")+" "+a.uri+"\r\n"},d.parseFmtp=function(a){for(var b,c={},d=a.substr(a.indexOf(" ")+1).split(";"),e=0;e
-1?(c.attribute=a.substr(b+1,d-b-1),c.value=a.substr(d+1)):c.attribute=a.substr(b+1),c},d.getMid=function(a){var b=d.matchPrefix(a,"a=mid:")[0];if(b)return b.substr(6)},d.parseFingerprint=function(a){var b=a.substr(14).split(" ");return{algorithm:b[0].toLowerCase(),value:b[1]}},d.getDtlsParameters=function(a,b){var c=d.matchPrefix(a+b,"a=fingerprint:");return{role:"auto",fingerprints:c.map(d.parseFingerprint)}},d.writeDtlsParameters=function(a,b){ var c="a=setup:"+b+"\r\n";return a.fingerprints.forEach(function(a){c+="a=fingerprint:"+a.algorithm+" "+a.value+"\r\n"}),c},d.getIceParameters=function(a,b){var c=d.splitLines(a);c=c.concat(d.splitLines(b));var e={usernameFragment:c.filter(function(a){return 0===a.indexOf("a=ice-ufrag:")})[0].substr(12),password:c.filter(function(a){return 0===a.indexOf("a=ice-pwd:")})[0].substr(10)};return e},d.writeIceParameters=function(a){return"a=ice-ufrag:"+a.usernameFragment+"\r\na=ice-pwd:"+a.password+"\r\n"},d.parseRtpParameters=function(a){for(var b={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},c=d.splitLines(a),e=c[0].split(" "),f=3;f
0?"9":"0",c+=" UDP/TLS/RTP/SAVPF ",c+=b.codecs.map(function(a){return void 0!==a.preferredPayloadType?a.preferredPayloadType:a.payloadType}).join(" ")+"\r\n",c+="c=IN IP4 0.0.0.0\r\n",c+="a=rtcp:9 IN IP4 0.0.0.0\r\n",b.codecs.forEach(function(a){c+=d.writeRtpMap(a),c+=d.writeFmtp(a),c+=d.writeRtcpFb(a)});var e=0;return b.codecs.forEach(function(a){a.maxptime>e&&(e=a.maxptime)}),e>0&&(c+="a=maxptime:"+e+"\r\n"),c+="a=rtcp-mux\r\n",b.headerExtensions.forEach(function(a){c+=d.writeExtmap(a)}),c},d.parseRtpEncodingParameters=function(a){var b,c=[],e=d.parseRtpParameters(a),f=e.fecMechanisms.indexOf("RED")!==-1,g=e.fecMechanisms.indexOf("ULPFEC")!==-1,h=d.matchPrefix(a,"a=ssrc:").map(function(a){return d.parseSsrcMedia(a)}).filter(function(a){return"cname"===a.attribute}),i=h.length>0&&h[0].ssrc,j=d.matchPrefix(a,"a=ssrc-group:FID").map(function(a){var b=a.split(" ");return b.shift(),b.map(function(a){return parseInt(a,10)})});j.length>0&&j[0].length>1&&j[0][0]===i&&(b=j[0][1]),e.codecs.forEach(function(a){if("RTX"===a.name.toUpperCase()&&a.parameters.apt){var d={ssrc:i,codecPayloadType:parseInt(a.parameters.apt,10),rtx:{ssrc:b}};c.push(d),f&&(d=JSON.parse(JSON.stringify(d)),d.fec={ssrc:b,mechanism:g?"red+ulpfec":"red"},c.push(d))}}),0===c.length&&i&&c.push({ssrc:i});var k=d.matchPrefix(a,"b=");return k.length&&(k=0===k[0].indexOf("b=TIAS:")?parseInt(k[0].substr(7),10):0===k[0].indexOf("b=AS:")?1e3*parseInt(k[0].substr(5),10)*.95-16e3:void 0,c.forEach(function(a){a.maxBitrate=k})),c},d.parseRtcpParameters=function(a){var b={},c=d.matchPrefix(a,"a=ssrc:").map(function(a){return d.parseSsrcMedia(a)}).filter(function(a){return"cname"===a.attribute})[0];c&&(b.cname=c.value,b.ssrc=c.ssrc);var e=d.matchPrefix(a,"a=rtcp-rsize");b.reducedSize=e.length>0,b.compound=0===e.length;var f=d.matchPrefix(a,"a=rtcp-mux");return b.mux=f.length>0,b},d.parseMsid=function(a){var b,c=d.matchPrefix(a,"a=msid:");if(1===c.length)return b=c[0].substr(7).split(" "),{stream:b[0],track:b[1]};var e=d.matchPrefix(a,"a=ssrc:").map(function(a){return d.parseSsrcMedia(a)}).filter(function(a){return"msid"===a.attribute});return e.length>0?(b=e[0].value.split(" "),{stream:b[0],track:b[1]}):void 0},d.generateSessionId=function(){return Math.random().toString().substr(2,21)},d.writeSessionBoilerplate=function(a,b){var c,e=void 0!==b?b:2;return c=a?a:d.generateSessionId(),"v=0\r\no=thisisadapterortc "+c+" "+e+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},d.writeMediaSection=function(a,b,c,e){var f=d.writeRtpDescription(a.kind,b);if(f+=d.writeIceParameters(a.iceGatherer.getLocalParameters()),f+=d.writeDtlsParameters(a.dtlsTransport.getLocalParameters(),"offer"===c?"actpass":"active"),f+="a=mid:"+a.mid+"\r\n",f+=a.direction?"a="+a.direction+"\r\n":a.rtpSender&&a.rtpReceiver?"a=sendrecv\r\n":a.rtpSender?"a=sendonly\r\n":a.rtpReceiver?"a=recvonly\r\n":"a=inactive\r\n",a.rtpSender){var g="msid:"+e.id+" "+a.rtpSender.track.id+"\r\n";f+="a="+g,f+="a=ssrc:"+a.sendEncodingParameters[0].ssrc+" "+g,a.sendEncodingParameters[0].rtx&&(f+="a=ssrc:"+a.sendEncodingParameters[0].rtx.ssrc+" "+g,f+="a=ssrc-group:FID "+a.sendEncodingParameters[0].ssrc+" "+a.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return f+="a=ssrc:"+a.sendEncodingParameters[0].ssrc+" cname:"+d.localCName+"\r\n",a.rtpSender&&a.sendEncodingParameters[0].rtx&&(f+="a=ssrc:"+a.sendEncodingParameters[0].rtx.ssrc+" cname:"+d.localCName+"\r\n"),f},d.getDirection=function(a,b){for(var c=d.splitLines(a),e=0;e
=65)return this.shimAddTrackRemoveTrackWithNative(a);var f=a.RTCPeerConnection.prototype.getLocalStreams;a.RTCPeerConnection.prototype.getLocalStreams=function(){var a=this,b=f.apply(this);return a._reverseStreams=a._reverseStreams||{},b.map(function(b){return a._reverseStreams[b.id]})};var g=a.RTCPeerConnection.prototype.addStream;a.RTCPeerConnection.prototype.addStream=function(b){var c=this;if(c._streams=c._streams||{},c._reverseStreams=c._reverseStreams||{},b.getTracks().forEach(function(a){var b=c.getSenders().find(function(b){return b.track===a});if(b)throw new DOMException("Track already exists.","InvalidAccessError")}),!c._reverseStreams[b.id]){var d=new a.MediaStream(b.getTracks());c._streams[b.id]=d,c._reverseStreams[d.id]=b,b=d}g.apply(c,[b])};var h=a.RTCPeerConnection.prototype.removeStream;a.RTCPeerConnection.prototype.removeStream=function(a){var b=this;b._streams=b._streams||{},b._reverseStreams=b._reverseStreams||{},h.apply(b,[b._streams[a.id]||a]),delete b._reverseStreams[b._streams[a.id]?b._streams[a.id].id:a.id],delete b._streams[a.id]},a.RTCPeerConnection.prototype.addTrack=function(b,c){var d=this;if("closed"===d.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var e=[].slice.call(arguments,1);if(1!==e.length||!e[0].getTracks().find(function(a){return a===b}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var f=d.getSenders().find(function(a){return a.track===b});if(f)throw new DOMException("Track already exists.","InvalidAccessError");d._streams=d._streams||{},d._reverseStreams=d._reverseStreams||{};var g=d._streams[c.id];if(g)g.addTrack(b),Promise.resolve().then(function(){d.dispatchEvent(new Event("negotiationneeded"))});else{var h=new a.MediaStream([b]);d._streams[c.id]=h,d._reverseStreams[h.id]=c,d.addStream(h)}return d.getSenders().find(function(a){return a.track===b})},["createOffer","createAnswer"].forEach(function(c){var d=a.RTCPeerConnection.prototype[c];a.RTCPeerConnection.prototype[c]=function(){var a=this,c=arguments,e=arguments.length&&"function"==typeof arguments[0];return e?d.apply(a,[function(d){var e=b(a,d);c[0].apply(null,[e])},function(a){c[1]&&c[1].apply(null,a)},arguments[2]]):d.apply(a,arguments).then(function(c){return b(a,c)})}});var i=a.RTCPeerConnection.prototype.setLocalDescription;a.RTCPeerConnection.prototype.setLocalDescription=function(){var a=this;return arguments.length&&arguments[0].type?(arguments[0]=c(a,arguments[0]),i.apply(a,arguments)):i.apply(a,arguments)};var j=Object.getOwnPropertyDescriptor(a.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(a.RTCPeerConnection.prototype,"localDescription",{get:function(){var a=this,c=j.get.apply(this);return""===c.type?c:b(a,c)}}),a.RTCPeerConnection.prototype.removeTrack=function(a){var b=this;if("closed"===b.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!a._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");var c=a._pc===b;if(!c)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");b._streams=b._streams||{};var d;Object.keys(b._streams).forEach(function(c){var e=b._streams[c].getTracks().find(function(b){return a.track===b});e&&(d=b._streams[c])}),d&&(1===d.getTracks().length?b.removeStream(b._reverseStreams[d.id]):d.removeTrack(a.track),b.dispatchEvent(new Event("negotiationneeded")))}},shimPeerConnection:function(a){var b=d.detectBrowser(a);if(!a.RTCPeerConnection&&a.webkitRTCPeerConnection)a.RTCPeerConnection=function(b,c){return e("PeerConnection"),b&&b.iceTransportPolicy&&(b.iceTransports=b.iceTransportPolicy),new a.webkitRTCPeerConnection(b,c)},a.RTCPeerConnection.prototype=a.webkitRTCPeerConnection.prototype,a.webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(a.RTCPeerConnection,"generateCertificate",{get:function(){return a.webkitRTCPeerConnection.generateCertificate}});else{var c=a.RTCPeerConnection;a.RTCPeerConnection=function(a,b){if(a&&a.iceServers){for(var e=[],f=0;f
0&&"function"==typeof a)return f.apply(this,arguments);if(0===f.length&&(0===arguments.length||"function"!=typeof arguments[0]))return f.apply(this,[]);var g=function(a){var b={},c=a.result();return c.forEach(function(a){var c={id:a.id,timestamp:a.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[a.type]||a.type};a.names().forEach(function(b){c[b]=a.stat(b)}),b[c.id]=c}),b},h=function(a){return new Map(Object.keys(a).map(function(b){return[b,a[b]]}))};if(arguments.length>=2){var i=function(a){e[1](h(g(a)))};return f.apply(this,[i,arguments[0]])}return new Promise(function(a,b){f.apply(d,[function(b){a(h(g(b)))},b])}).then(b,c)},b.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(b){var c=a.RTCPeerConnection.prototype[b];a.RTCPeerConnection.prototype[b]=function(){var a=arguments,b=this,d=new Promise(function(d,e){c.apply(b,[a[0],d,e])});return a.length<2?d:d.then(function(){a[1].apply(null,[])},function(b){a.length>=3&&a[2].apply(null,[b])})}}),b.version<52&&["createOffer","createAnswer"].forEach(function(b){var c=a.RTCPeerConnection.prototype[b];a.RTCPeerConnection.prototype[b]=function(){var a=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var b=1===arguments.length?arguments[0]:void 0;return new Promise(function(d,e){c.apply(a,[d,e,b])})}return c.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(b){var c=a.RTCPeerConnection.prototype[b];a.RTCPeerConnection.prototype[b]=function(){return arguments[0]=new("addIceCandidate"===b?a.RTCIceCandidate:a.RTCSessionDescription)(arguments[0]),c.apply(this,arguments)}});var g=a.RTCPeerConnection.prototype.addIceCandidate;a.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?g.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}}},{"../utils.js":13,"./getusermedia":6}],6:[function(a,b,c){"use strict";var d=a("../utils.js"),e=d.log;b.exports=function(a){var b=d.detectBrowser(a),c=a&&a.navigator,f=function(a){if("object"!=typeof a||a.mandatory||a.optional)return a;var b={};return Object.keys(a).forEach(function(c){if("require"!==c&&"advanced"!==c&&"mediaSource"!==c){var d="object"==typeof a[c]?a[c]:{ideal:a[c]};void 0!==d.exact&&"number"==typeof d.exact&&(d.min=d.max=d.exact);var e=function(a,b){return a?a+b.charAt(0).toUpperCase()+b.slice(1):"deviceId"===b?"sourceId":b};if(void 0!==d.ideal){b.optional=b.optional||[];var f={};"number"==typeof d.ideal?(f[e("min",c)]=d.ideal,b.optional.push(f),f={},f[e("max",c)]=d.ideal,b.optional.push(f)):(f[e("",c)]=d.ideal,b.optional.push(f))}void 0!==d.exact&&"number"!=typeof d.exact?(b.mandatory=b.mandatory||{},b.mandatory[e("",c)]=d.exact):["min","max"].forEach(function(a){void 0!==d[a]&&(b.mandatory=b.mandatory||{},b.mandatory[e(a,c)]=d[a])})}}),a.advanced&&(b.optional=(b.optional||[]).concat(a.advanced)),b},g=function(a,d){if(b.version>=61)return d(a);if(a=JSON.parse(JSON.stringify(a)),a&&"object"==typeof a.audio){var g=function(a,b,c){b in a&&!(c in a)&&(a[c]=a[b],delete a[b])};a=JSON.parse(JSON.stringify(a)),g(a.audio,"autoGainControl","googAutoGainControl"),g(a.audio,"noiseSuppression","googNoiseSuppression"),a.audio=f(a.audio)}if(a&&"object"==typeof a.video){var h=a.video.facingMode;h=h&&("object"==typeof h?h:{ideal:h});var i=b.version<66;if(h&&("user"===h.exact||"environment"===h.exact||"user"===h.ideal||"environment"===h.ideal)&&(!c.mediaDevices.getSupportedConstraints||!c.mediaDevices.getSupportedConstraints().facingMode||i)){delete a.video.facingMode;var j;if("environment"===h.exact||"environment"===h.ideal?j=["back","rear"]:"user"!==h.exact&&"user"!==h.ideal||(j=["front"]),j)return c.mediaDevices.enumerateDevices().then(function(b){b=b.filter(function(a){return"videoinput"===a.kind});var c=b.find(function(a){return j.some(function(b){return a.label.toLowerCase().indexOf(b)!==-1})});return!c&&b.length&&j.indexOf("back")!==-1&&(c=b[b.length-1]),c&&(a.video.deviceId=h.exact?{exact:c.deviceId}:{ideal:c.deviceId}),a.video=f(a.video),e("chrome: "+JSON.stringify(a)),d(a)})}a.video=f(a.video)}return e("chrome: "+JSON.stringify(a)),d(a)},h=function(a){return{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[a.name]||a.name,message:a.message,constraint:a.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},i=function(a,b,d){g(a,function(a){c.webkitGetUserMedia(a,b,function(a){d&&d(h(a))})})};c.getUserMedia=i;var j=function(a){return new Promise(function(b,d){c.getUserMedia(a,b,d)})};if(c.mediaDevices||(c.mediaDevices={getUserMedia:j,enumerateDevices:function(){return new Promise(function(b){var c={audio:"audioinput",video:"videoinput"};return a.MediaStreamTrack.getSources(function(a){b(a.map(function(a){return{label:a.label,kind:c[a.kind],deviceId:a.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),c.mediaDevices.getUserMedia){var k=c.mediaDevices.getUserMedia.bind(c.mediaDevices);c.mediaDevices.getUserMedia=function(a){return g(a,function(a){return k(a).then(function(b){if(a.audio&&!b.getAudioTracks().length||a.video&&!b.getVideoTracks().length)throw b.getTracks().forEach(function(a){a.stop()}),new DOMException("","NotFoundError");return b},function(a){return Promise.reject(h(a))})})}}else c.mediaDevices.getUserMedia=function(a){return j(a)};"undefined"==typeof c.mediaDevices.addEventListener&&(c.mediaDevices.addEventListener=function(){e("Dummy mediaDevices.addEventListener called.")}),"undefined"==typeof c.mediaDevices.removeEventListener&&(c.mediaDevices.removeEventListener=function(){e("Dummy mediaDevices.removeEventListener called.")})}},{"../utils.js":13}],7:[function(a,b,c){"use strict";var d=a("sdp"),e=a("./utils");b.exports={shimRTCIceCandidate:function(a){if(a.RTCIceCandidate&&!(a.RTCIceCandidate&&"foundation"in a.RTCIceCandidate.prototype)){var b=a.RTCIceCandidate;a.RTCIceCandidate=function(a){if("object"==typeof a&&a.candidate&&0===a.candidate.indexOf("a=")&&(a=JSON.parse(JSON.stringify(a)),a.candidate=a.candidate.substr(2)),a.candidate&&a.candidate.length){var c=new b(a),e=d.parseCandidate(a.candidate),f=Object.assign(c,e);return f.toJSON=function(){return{candidate:f.candidate,sdpMid:f.sdpMid,sdpMLineIndex:f.sdpMLineIndex,usernameFragment:f.usernameFragment}},f}return new b(a)},a.RTCIceCandidate.prototype=b.prototype,e.wrapPeerConnectionEvent(a,"icecandidate",function(b){return b.candidate&&Object.defineProperty(b,"candidate",{value:new a.RTCIceCandidate(b.candidate),writable:"false"}),b})}},shimCreateObjectURL:function(a){var b=a&&a.URL;if("object"==typeof a&&a.HTMLMediaElement&&"srcObject"in a.HTMLMediaElement.prototype&&b.createObjectURL&&b.revokeObjectURL){var c=b.createObjectURL.bind(b),d=b.revokeObjectURL.bind(b),f=new Map,g=0;b.createObjectURL=function(a){if("getTracks"in a){var b="polyblob:"+ ++g;return f.set(b,a),e.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream"),b}return c(a)},b.revokeObjectURL=function(a){d(a),f["delete"](a)};var h=Object.getOwnPropertyDescriptor(a.HTMLMediaElement.prototype,"src");Object.defineProperty(a.HTMLMediaElement.prototype,"src",{get:function(){return h.get.apply(this)},set:function(a){return this.srcObject=f.get(a)||null,h.set.apply(this,[a])}});var i=a.HTMLMediaElement.prototype.setAttribute;a.HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=f.get(arguments[1])||null),i.apply(this,arguments)}}},shimMaxMessageSize:function(a){if(!a.RTCSctpTransport&&a.RTCPeerConnection){var b=e.detectBrowser(a);"sctp"in a.RTCPeerConnection.prototype||Object.defineProperty(a.RTCPeerConnection.prototype,"sctp",{get:function(){return"undefined"==typeof this._sctp?null:this._sctp}});var c=function(a){var b=d.splitSections(a.sdp);return b.shift(),b.some(function(a){var b=d.parseMLine(a);return b&&"application"===b.kind&&b.protocol.indexOf("SCTP")!==-1})},f=function(a){var b=a.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===b||b.length<2)return-1;var c=parseInt(b[1],10);return c!==c?-1:c},g=function(a){var c=65536;return"firefox"===b.browser&&(c=b.version<57?a===-1?16384:2147483637:57===b.version?65535:65536),c},h=function(a,c){var e=65536;"firefox"===b.browser&&57===b.version&&(e=65535);var f=d.matchPrefix(a.sdp,"a=max-message-size:");return f.length>0?e=parseInt(f[0].substr(19),10):"firefox"===b.browser&&c!==-1&&(e=2147483637),e},i=a.RTCPeerConnection.prototype.setRemoteDescription;a.RTCPeerConnection.prototype.setRemoteDescription=function(){var a=this;if(a._sctp=null,c(arguments[0])){var b,d=f(arguments[0]),e=g(d),j=h(arguments[0],d);b=0===e&&0===j?Number.POSITIVE_INFINITY:0===e||0===j?Math.max(e,j):Math.min(e,j);var k={};Object.defineProperty(k,"maxMessageSize",{get:function(){return b}}),a._sctp=k}return i.apply(a,arguments)}}},shimSendThrowTypeError:function(a){if(a.RTCPeerConnection&&"createDataChannel"in a.RTCPeerConnection.prototype){var b=a.RTCPeerConnection.prototype.createDataChannel;a.RTCPeerConnection.prototype.createDataChannel=function(){var a=this,c=b.apply(a,arguments),d=c.send;return c.send=function(){var b=this,c=arguments[0],e=c.length||c.size||c.byteLength;if(e>a.sctp.maxMessageSize)throw new DOMException("Message too large (can send a maximum of "+a.sctp.maxMessageSize+" bytes)","TypeError");return d.apply(b,arguments)},c}}}}},{"./utils":13,sdp:2}],8:[function(a,b,c){"use strict";var d=a("../utils"),e=a("rtcpeerconnection-shim");b.exports={shimGetUserMedia:a("./getusermedia"),shimPeerConnection:function(a){var b=d.detectBrowser(a);if(a.RTCIceGatherer&&(a.RTCIceCandidate||(a.RTCIceCandidate=function(a){return a}),a.RTCSessionDescription||(a.RTCSessionDescription=function(a){return a}),b.version<15025)){var c=Object.getOwnPropertyDescriptor(a.MediaStreamTrack.prototype,"enabled");Object.defineProperty(a.MediaStreamTrack.prototype,"enabled",{set:function(a){c.set.call(this,a);var b=new Event("enabled");b.enabled=a,this.dispatchEvent(b)}})}!a.RTCRtpSender||"dtmf"in a.RTCRtpSender.prototype||Object.defineProperty(a.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new a.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),a.RTCDtmfSender&&!a.RTCDTMFSender&&(a.RTCDTMFSender=a.RTCDtmfSender),a.RTCPeerConnection=e(a,b.version)},shimReplaceTrack:function(a){!a.RTCRtpSender||"replaceTrack"in a.RTCRtpSender.prototype||(a.RTCRtpSender.prototype.replaceTrack=a.RTCRtpSender.prototype.setTrack)}}},{"../utils":13,"./getusermedia":9,"rtcpeerconnection-shim":1}],9:[function(a,b,c){"use strict";b.exports=function(a){var b=a&&a.navigator,c=function(a){return{name:{PermissionDeniedError:"NotAllowedError"}[a.name]||a.name,message:a.message,constraint:a.constraint,toString:function(){return this.name}}},d=b.mediaDevices.getUserMedia.bind(b.mediaDevices);b.mediaDevices.getUserMedia=function(a){return d(a)["catch"](function(a){return Promise.reject(c(a))})}}},{}],10:[function(a,b,c){"use strict";var d=a("../utils");b.exports={shimGetUserMedia:a("./getusermedia"),shimOnTrack:function(a){"object"!=typeof a||!a.RTCPeerConnection||"ontrack"in a.RTCPeerConnection.prototype||Object.defineProperty(a.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(a){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=a),this.addEventListener("addstream",this._ontrackpoly=function(a){a.stream.getTracks().forEach(function(b){var c=new Event("track");c.track=b,c.receiver={track:b},c.transceiver={receiver:c.receiver},c.streams=[a.stream],this.dispatchEvent(c)}.bind(this))}.bind(this))}}),"object"==typeof a&&a.RTCTrackEvent&&"receiver"in a.RTCTrackEvent.prototype&&!("transceiver"in a.RTCTrackEvent.prototype)&&Object.defineProperty(a.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimSourceObject:function(a){"object"==typeof a&&(!a.HTMLMediaElement||"srcObject"in a.HTMLMediaElement.prototype||Object.defineProperty(a.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(a){this.mozSrcObject=a}}))},shimPeerConnection:function(a){var b=d.detectBrowser(a);if("object"==typeof a&&(a.RTCPeerConnection||a.mozRTCPeerConnection)){ a.RTCPeerConnection||(a.RTCPeerConnection=function(c,d){if(b.version<38&&c&&c.iceServers){for(var e=[],f=0;f
55&&"autoGainControl"in c.mediaDevices.getSupportedConstraints())){var l=function(a,b,c){b in a&&!(c in a)&&(a[c]=a[b],delete a[b])},m=c.mediaDevices.getUserMedia.bind(c.mediaDevices);if(c.mediaDevices.getUserMedia=function(a){return"object"==typeof a&&"object"==typeof a.audio&&(a=JSON.parse(JSON.stringify(a)),l(a.audio,"autoGainControl","mozAutoGainControl"),l(a.audio,"noiseSuppression","mozNoiseSuppression")),m(a)},f&&f.prototype.getSettings){var n=f.prototype.getSettings;f.prototype.getSettings=function(){var a=n.apply(this,arguments);return l(a,"mozAutoGainControl","autoGainControl"),l(a,"mozNoiseSuppression","noiseSuppression"),a}}if(f&&f.prototype.applyConstraints){var o=f.prototype.applyConstraints;f.prototype.applyConstraints=function(a){return"audio"===this.kind&&"object"==typeof a&&(a=JSON.parse(JSON.stringify(a)),l(a,"autoGainControl","mozAutoGainControl"),l(a,"noiseSuppression","mozNoiseSuppression")),o.apply(this,[a])}}}c.getUserMedia=function(a,e,f){return b.version<44?h(a,e,f):(d.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),void c.mediaDevices.getUserMedia(a).then(e,f))}}},{"../utils":13}],12:[function(a,b,c){"use strict";var d=a("../utils");b.exports={shimLocalStreamsAPI:function(a){if("object"==typeof a&&a.RTCPeerConnection){if("getLocalStreams"in a.RTCPeerConnection.prototype||(a.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),"getStreamById"in a.RTCPeerConnection.prototype||(a.RTCPeerConnection.prototype.getStreamById=function(a){var b=null;return this._localStreams&&this._localStreams.forEach(function(c){c.id===a&&(b=c)}),this._remoteStreams&&this._remoteStreams.forEach(function(c){c.id===a&&(b=c)}),b}),!("addStream"in a.RTCPeerConnection.prototype)){var b=a.RTCPeerConnection.prototype.addTrack;a.RTCPeerConnection.prototype.addStream=function(a){this._localStreams||(this._localStreams=[]),this._localStreams.indexOf(a)===-1&&this._localStreams.push(a);var c=this;a.getTracks().forEach(function(d){b.call(c,d,a)})},a.RTCPeerConnection.prototype.addTrack=function(a,c){return c&&(this._localStreams?this._localStreams.indexOf(c)===-1&&this._localStreams.push(c):this._localStreams=[c]),b.call(this,a,c)}}"removeStream"in a.RTCPeerConnection.prototype||(a.RTCPeerConnection.prototype.removeStream=function(a){this._localStreams||(this._localStreams=[]);var b=this._localStreams.indexOf(a);if(b!==-1){this._localStreams.splice(b,1);var c=this,d=a.getTracks();this.getSenders().forEach(function(a){d.indexOf(a.track)!==-1&&c.removeTrack(a)})}})}},shimRemoteStreamsAPI:function(a){"object"==typeof a&&a.RTCPeerConnection&&("getRemoteStreams"in a.RTCPeerConnection.prototype||(a.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),"onaddstream"in a.RTCPeerConnection.prototype||Object.defineProperty(a.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(a){var b=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=a),this.addEventListener("track",this._onaddstreampoly=function(a){a.streams.forEach(function(a){if(b._remoteStreams||(b._remoteStreams=[]),!(b._remoteStreams.indexOf(a)>=0)){b._remoteStreams.push(a);var c=new Event("addstream");c.stream=a,b.dispatchEvent(c)}})})}}))},shimCallbacksAPI:function(a){if("object"==typeof a&&a.RTCPeerConnection){var b=a.RTCPeerConnection.prototype,c=b.createOffer,d=b.createAnswer,e=b.setLocalDescription,f=b.setRemoteDescription,g=b.addIceCandidate;b.createOffer=function(a,b){var d=arguments.length>=2?arguments[2]:arguments[0],e=c.apply(this,[d]);return b?(e.then(a,b),Promise.resolve()):e},b.createAnswer=function(a,b){var c=arguments.length>=2?arguments[2]:arguments[0],e=d.apply(this,[c]);return b?(e.then(a,b),Promise.resolve()):e};var h=function(a,b,c){var d=e.apply(this,[a]);return c?(d.then(b,c),Promise.resolve()):d};b.setLocalDescription=h,h=function(a,b,c){var d=f.apply(this,[a]);return c?(d.then(b,c),Promise.resolve()):d},b.setRemoteDescription=h,h=function(a,b,c){var d=g.apply(this,[a]);return c?(d.then(b,c),Promise.resolve()):d},b.addIceCandidate=h}},shimGetUserMedia:function(a){var b=a&&a.navigator;b.getUserMedia||(b.webkitGetUserMedia?b.getUserMedia=b.webkitGetUserMedia.bind(b):b.mediaDevices&&b.mediaDevices.getUserMedia&&(b.getUserMedia=function(a,c,d){b.mediaDevices.getUserMedia(a).then(c,d)}.bind(b)))},shimRTCIceServerUrls:function(a){var b=a.RTCPeerConnection;a.RTCPeerConnection=function(a,c){if(a&&a.iceServers){for(var e=[],f=0;f
=c&&parseInt(d[c],10)}function e(a,b,c){if(a.RTCPeerConnection){var d=a.RTCPeerConnection.prototype,e=d.addEventListener;d.addEventListener=function(a,d){if(a!==b)return e.apply(this,arguments);var f=function(a){d(c(a))};return this._eventMap=this._eventMap||{},this._eventMap[d]=f,e.apply(this,[a,f])};var f=d.removeEventListener;d.removeEventListener=function(a,c){if(a!==b||!this._eventMap||!this._eventMap[c])return f.apply(this,arguments);var d=this._eventMap[c];return delete this._eventMap[c],f.apply(this,[a,d])},Object.defineProperty(d,"on"+b,{get:function(){return this["_on"+b]},set:function(a){this["_on"+b]&&(this.removeEventListener(b,this["_on"+b]),delete this["_on"+b]),a&&this.addEventListener(b,this["_on"+b]=a)}})}}var f=!0,g=!0;b.exports={extractVersion:d,wrapPeerConnectionEvent:e,disableLog:function(a){return"boolean"!=typeof a?new Error("Argument type: "+typeof a+". Please use a boolean."):(f=a,a?"adapter.js logging disabled":"adapter.js logging enabled")},disableWarnings:function(a){return"boolean"!=typeof a?new Error("Argument type: "+typeof a+". Please use a boolean."):(g=!a,"adapter.js deprecation warnings "+(a?"disabled":"enabled"))},log:function(){if("object"==typeof window){if(f)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},deprecated:function(a,b){g&&console.warn(a+" is deprecated, please use "+b+" instead.")},detectBrowser:function(a){var b=a&&a.navigator,c={};if(c.browser=null,c.version=null,"undefined"==typeof a||!a.navigator)return c.browser="Not a browser.",c;if(b.mozGetUserMedia)c.browser="firefox",c.version=d(b.userAgent,/Firefox\/(\d+)\./,1);else if(b.webkitGetUserMedia)c.browser="chrome",c.version=d(b.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(b.mediaDevices&&b.userAgent.match(/Edge\/(\d+).(\d+)$/))c.browser="edge",c.version=d(b.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!a.RTCPeerConnection||!b.userAgent.match(/AppleWebKit\/(\d+)\./))return c.browser="Not a supported browser.",c;c.browser="safari",c.version=d(b.userAgent,/AppleWebKit\/(\d+)\./,1)}return c}}},{}]},{},[3])(3)});