You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3 lines
76 KiB
3 lines
76 KiB
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<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(a,b,c,d,e){var f=j.writeRtpDescription(a.kind,b);if(f+=j.writeIceParameters(a.iceGatherer.getLocalParameters()),f+=j.writeDtlsParameters(a.dtlsTransport.getLocalParameters(),"offer"===c?"actpass":e||"active"),f+="a=mid:"+a.mid+"\r\n",f+=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=a.rtpSender._initialTrackId||a.rtpSender.track.id;a.rtpSender._initialTrackId=g;var h="msid:"+(d?d.id:"-")+" "+g+"\r\n";f+="a="+h,f+="a=ssrc:"+a.sendEncodingParameters[0].ssrc+" "+h,a.sendEncodingParameters[0].rtx&&(f+="a=ssrc:"+a.sendEncodingParameters[0].rtx.ssrc+" "+h,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:"+j.localCName+"\r\n",a.rtpSender&&a.sendEncodingParameters[0].rtx&&(f+="a=ssrc:"+a.sendEncodingParameters[0].rtx.ssrc+" cname:"+j.localCName+"\r\n"),f}function e(a,b){var c=!1;return a=JSON.parse(JSON.stringify(a)),a.filter(function(a){if(a&&(a.urls||a.url)){var d=a.urls||a.url;a.url&&!a.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var e="string"==typeof d;return e&&(d=[d]),d=d.filter(function(a){var d=0===a.indexOf("turn:")&&a.indexOf("transport=udp")!==-1&&a.indexOf("turn:[")===-1&&!c;return d?(c=!0,!0):0===a.indexOf("stun:")&&b>=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<b.length;c++)if(b[c].payloadType===a||b[c].preferredPayloadType===a)return b[c]},e=function(a,b,c,e){var f=d(a.parameters.apt,c),g=d(b.parameters.apt,e);return f&&g&&f.name.toLowerCase()===g.name.toLowerCase()};return a.codecs.forEach(function(d){for(var f=0;f<b.codecs.length;f++){var g=b.codecs[f];if(d.name.toLowerCase()===g.name.toLowerCase()&&d.clockRate===g.clockRate){if("rtx"===d.name.toLowerCase()&&d.parameters&&g.parameters.apt&&!e(d,g,a.codecs,b.codecs))continue;g=JSON.parse(JSON.stringify(g)),g.numChannels=Math.min(d.numChannels,g.numChannels),c.codecs.push(g),g.rtcpFeedback=g.rtcpFeedback.filter(function(a){for(var b=0;b<d.rtcpFeedback.length;b++)if(d.rtcpFeedback[b].type===a.type&&d.rtcpFeedback[b].parameter===a.parameter)return!0;return!1});break}}}),a.headerExtensions.forEach(function(a){for(var d=0;d<b.headerExtensions.length;d++){var e=b.headerExtensions[d];if(a.uri===e.uri){c.headerExtensions.push(e);break}}}),c}function g(a,b,c){return{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"]}}[b][a].indexOf(c)!==-1}function h(a,b){var c=a.getRemoteCandidates().find(function(a){return b.foundation===a.foundation&&b.ip===a.ip&&b.port===a.port&&b.priority===a.priority&&b.protocol===a.protocol&&b.type===a.type});return c||a.addRemoteCandidate(b),!c}function i(a,b){var c=new Error(b);return c.name=a,c.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[a],c}var j=a("sdp");b.exports=function(a,b){function c(b,c){c.addTrack(b),c.dispatchEvent(new a.MediaStreamTrackEvent("addtrack",{track:b}))}function k(b,c){c.removeTrack(b),c.dispatchEvent(new a.MediaStreamTrackEvent("removetrack",{track:b}))}function l(b,c,d,e){var f=new Event("track");f.track=c,f.receiver=d,f.transceiver={receiver:d},f.streams=e,a.setTimeout(function(){b._dispatchEvent("track",f)})}var m=function(c){var d=this,f=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(a){d[a]=f[a].bind(f)}),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",c=JSON.parse(JSON.stringify(c||{})),this.usingBundle="max-bundle"===c.bundlePolicy,"negotiate"===c.rtcpMuxPolicy)throw i("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(c.rtcpMuxPolicy||(c.rtcpMuxPolicy="require"),c.iceTransportPolicy){case"all":case"relay":break;default:c.iceTransportPolicy="all"}switch(c.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:c.bundlePolicy="balanced"}if(c.iceServers=e(c.iceServers||[],b),this._iceGatherers=[],c.iceCandidatePoolSize)for(var g=c.iceCandidatePoolSize;g>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<this.transceivers.length;f++)this.transceivers[f].track||this.transceivers[f].kind!==b.kind||(e=this.transceivers[f]);return e||(e=this._createTransceiver(b.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(c)===-1&&this.localStreams.push(c),e.track=b,e.stream=c,e.rtpSender=new a.RTCRtpSender(b,e.dtlsTransport),e.rtpSender},m.prototype.addStream=function(a){var c=this;if(b>=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<c.transceivers.length;g++)if(c.transceivers[g].mid===a.sdpMid){f=g;break}var k=c.transceivers[f];if(!k)return e(i("OperationError","Can not add ICE candidate"));if(k.rejected)return d();var l=Object.keys(a.candidate).length>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<c.transceivers.length&&(c.transceivers[n].rejected||(c.transceivers[n].iceTransport.addRemoteCandidate({}),b=j.getMediaSections(c.remoteDescription.sdp),b[n]+="a=end-of-candidates\r\n",c.remoteDescription.sdp=j.getDescription(c.remoteDescription.sdp)+b.join(""),!c.usingBundle));n++);d()})},m.prototype.getStats=function(){var a=[];this.transceivers.forEach(function(b){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(c){b[c]&&a.push(b[c].getStats())})});var b=function(a){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[a.type]||a.type};return new Promise(function(c){var d=new Map;Promise.all(a).then(function(a){a.forEach(function(a){Object.keys(a).forEach(function(c){a[c].type=b(a[c]),d.set(c,a[c])})}),c(d)})})};var n=["createOffer","createAnswer"];return n.forEach(function(a){var b=m.prototype[a];m.prototype[a]=function(){var a=arguments;return"function"==typeof a[0]||"function"==typeof a[1]?b.apply(this,[arguments[2]]).then(function(b){"function"==typeof a[0]&&a[0].apply(null,[b])},function(b){"function"==typeof a[1]&&a[1].apply(null,[b])}):b.apply(this,arguments)}}),n=["setLocalDescription","setRemoteDescription","addIceCandidate"],n.forEach(function(a){var b=m.prototype[a];m.prototype[a]=function(){var a=arguments;return"function"==typeof a[1]||"function"==typeof a[2]?b.apply(this,arguments).then(function(){"function"==typeof a[1]&&a[1].apply(null)},function(b){"function"==typeof a[2]&&a[2].apply(null,[b])}):b.apply(this,arguments)}}),["getStats"].forEach(function(a){var b=m.prototype[a];m.prototype[a]=function(){var a=arguments;return"function"==typeof a[1]?b.apply(this,arguments).then(function(){"function"==typeof a[1]&&a[1].apply(null)}):b.apply(this,arguments)}}),m}},{sdp:2}],2:[function(a,b,c){"use strict";var d={};d.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},d.localCName=d.generateIdentifier(),d.splitLines=function(a){return a.trim().split("\n").map(function(a){return a.trim()})},d.splitSections=function(a){var b=a.split("\nm=");return b.map(function(a,b){return(b>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<b.length;d+=2)switch(b[d]){case"raddr":c.relatedAddress=b[d+1];break;case"rport":c.relatedPort=parseInt(b[d+1],10);break;case"tcptype":c.tcpType=b[d+1];break;case"ufrag":c.ufrag=b[d+1],c.usernameFragment=b[d+1];break;default:c[b[d]]=b[d+1]}return c},d.writeCandidate=function(a){var b=[];b.push(a.foundation),b.push(a.component),b.push(a.protocol.toUpperCase()),b.push(a.priority),b.push(a.ip),b.push(a.port);var c=a.type;return b.push("typ"),b.push(c),"host"!==c&&a.relatedAddress&&a.relatedPort&&(b.push("raddr"),b.push(a.relatedAddress),b.push("rport"),b.push(a.relatedPort)),a.tcpType&&"tcp"===a.protocol.toLowerCase()&&(b.push("tcptype"),b.push(a.tcpType)),(a.usernameFragment||a.ufrag)&&(b.push("ufrag"),b.push(a.usernameFragment||a.ufrag)),"candidate:"+b.join(" ")},d.parseIceOptions=function(a){return a.substr(14).split(" ")},d.parseRtpMap=function(a){var b=a.substr(9).split(" "),c={payloadType:parseInt(b.shift(),10)};return b=b[0].split("/"),c.name=b[0],c.clockRate=parseInt(b[1],10),c.numChannels=3===b.length?parseInt(b[2],10):1,c},d.writeRtpMap=function(a){var b=a.payloadType;return void 0!==a.preferredPayloadType&&(b=a.preferredPayloadType),"a=rtpmap:"+b+" "+a.name+"/"+a.clockRate+(1!==a.numChannels?"/"+a.numChannels:"")+"\r\n"},d.parseExtmap=function(a){var b=a.substr(9).split(" ");return{id:parseInt(b[0],10),direction:b[0].indexOf("/")>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<d.length;e++)b=d[e].trim().split("="),c[b[0].trim()]=b[1];return c},d.writeFmtp=function(a){var b="",c=a.payloadType;if(void 0!==a.preferredPayloadType&&(c=a.preferredPayloadType),a.parameters&&Object.keys(a.parameters).length){var d=[];Object.keys(a.parameters).forEach(function(b){d.push(b+"="+a.parameters[b])}),b+="a=fmtp:"+c+" "+d.join(";")+"\r\n"}return b},d.parseRtcpFb=function(a){var b=a.substr(a.indexOf(" ")+1).split(" ");return{type:b.shift(),parameter:b.join(" ")}},d.writeRtcpFb=function(a){var b="",c=a.payloadType;return void 0!==a.preferredPayloadType&&(c=a.preferredPayloadType),a.rtcpFeedback&&a.rtcpFeedback.length&&a.rtcpFeedback.forEach(function(a){b+="a=rtcp-fb:"+c+" "+a.type+(a.parameter&&a.parameter.length?" "+a.parameter:"")+"\r\n"}),b},d.parseSsrcMedia=function(a){var b=a.indexOf(" "),c={ssrc:parseInt(a.substr(7,b-7),10)},d=a.indexOf(":",b);return d>-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<e.length;f++){var g=e[f],h=d.matchPrefix(a,"a=rtpmap:"+g+" ")[0];if(h){var i=d.parseRtpMap(h),j=d.matchPrefix(a,"a=fmtp:"+g+" ");switch(i.parameters=j.length?d.parseFmtp(j[0]):{},i.rtcpFeedback=d.matchPrefix(a,"a=rtcp-fb:"+g+" ").map(d.parseRtcpFb),b.codecs.push(i),i.name.toUpperCase()){case"RED":case"ULPFEC":b.fecMechanisms.push(i.name.toUpperCase())}}}return d.matchPrefix(a,"a=extmap:").forEach(function(a){b.headerExtensions.push(d.parseExtmap(a))}),b},d.writeRtpDescription=function(a,b){var c="";c+="m="+a+" ",c+=b.codecs.length>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<c.length;e++)switch(c[e]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return c[e].substr(2)}return b?d.getDirection(b):"sendrecv"},d.getKind=function(a){var b=d.splitLines(a),c=b[0].split(" ");return c[0].substr(2)},d.isRejected=function(a){return"0"===a.split(" ",2)[1]},d.parseMLine=function(a){var b=d.splitLines(a),c=b[0].substr(2).split(" ");return{kind:c[0],port:parseInt(c[1],10),protocol:c[2],fmt:c.slice(3).join(" ")}},d.parseOLine=function(a){var b=d.matchPrefix(a,"o=")[0],c=b.substr(2).split(" ");return{username:c[0],sessionId:c[1],sessionVersion:parseInt(c[2],10),netType:c[3],addressType:c[4],address:c[5]}},"object"==typeof b&&(b.exports=d)},{}],3:[function(a,b,c){(function(c){"use strict";var d=a("./adapter_factory.js");b.exports=d({window:c.window})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./adapter_factory.js":4}],4:[function(a,b,c){"use strict";var d=a("./utils");b.exports=function(b,c){var e=b&&b.window,f={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0};for(var g in c)hasOwnProperty.call(c,g)&&(f[g]=c[g]);var h=d.log,i=d.detectBrowser(e),j=a("./chrome/chrome_shim")||null,k=a("./edge/edge_shim")||null,l=a("./firefox/firefox_shim")||null,m=a("./safari/safari_shim")||null,n=a("./common_shim")||null,o={browserDetails:i,commonShim:n,extractVersion:d.extractVersion,disableLog:d.disableLog,disableWarnings:d.disableWarnings};switch(i.browser){case"chrome":if(!j||!j.shimPeerConnection||!f.shimChrome)return h("Chrome shim is not included in this adapter release."),o;h("adapter.js shimming chrome."),o.browserShim=j,n.shimCreateObjectURL(e),j.shimGetUserMedia(e),j.shimMediaStream(e),j.shimSourceObject(e),j.shimPeerConnection(e),j.shimOnTrack(e),j.shimAddTrackRemoveTrack(e),j.shimGetSendersWithDtmf(e),n.shimRTCIceCandidate(e),n.shimMaxMessageSize(e),n.shimSendThrowTypeError(e);break;case"firefox":if(!l||!l.shimPeerConnection||!f.shimFirefox)return h("Firefox shim is not included in this adapter release."),o;h("adapter.js shimming firefox."),o.browserShim=l,n.shimCreateObjectURL(e),l.shimGetUserMedia(e),l.shimSourceObject(e),l.shimPeerConnection(e),l.shimOnTrack(e),l.shimRemoveStream(e),n.shimRTCIceCandidate(e),n.shimMaxMessageSize(e),n.shimSendThrowTypeError(e);break;case"edge":if(!k||!k.shimPeerConnection||!f.shimEdge)return h("MS edge shim is not included in this adapter release."),o;h("adapter.js shimming edge."),o.browserShim=k,n.shimCreateObjectURL(e),k.shimGetUserMedia(e),k.shimPeerConnection(e),k.shimReplaceTrack(e),n.shimMaxMessageSize(e),n.shimSendThrowTypeError(e);break;case"safari":if(!m||!f.shimSafari)return h("Safari shim is not included in this adapter release."),o;h("adapter.js shimming safari."),o.browserShim=m,n.shimCreateObjectURL(e),m.shimRTCIceServerUrls(e),m.shimCallbacksAPI(e),m.shimLocalStreamsAPI(e),m.shimRemoteStreamsAPI(e),m.shimTrackEventTransceiver(e),m.shimGetUserMedia(e),m.shimCreateOfferLegacy(e),n.shimRTCIceCandidate(e),n.shimMaxMessageSize(e),n.shimSendThrowTypeError(e);break;default:h("Unsupported browser!")}return o}},{"./chrome/chrome_shim":5,"./common_shim":7,"./edge/edge_shim":8,"./firefox/firefox_shim":10,"./safari/safari_shim":12,"./utils":13}],5:[function(a,b,c){"use strict";var d=a("../utils.js"),e=d.log;b.exports={shimGetUserMedia:a("./getusermedia"),shimMediaStream:function(a){a.MediaStream=a.MediaStream||a.webkitMediaStream},shimOnTrack:function(a){if("object"!=typeof a||!a.RTCPeerConnection||"ontrack"in a.RTCPeerConnection.prototype)"RTCRtpTransceiver"in a||d.wrapPeerConnectionEvent(a,"track",function(a){return a.transceiver||(a.transceiver={receiver:a.receiver}),a});else{Object.defineProperty(a.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(a){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=a)}});var b=a.RTCPeerConnection.prototype.setRemoteDescription;a.RTCPeerConnection.prototype.setRemoteDescription=function(){var c=this;return c._ontrackpoly||(c._ontrackpoly=function(b){b.stream.addEventListener("addtrack",function(d){var e;e=a.RTCPeerConnection.prototype.getReceivers?c.getReceivers().find(function(a){return a.track&&a.track.id===d.track.id}):{track:d.track};var f=new Event("track");f.track=d.track,f.receiver=e,f.transceiver={receiver:e},f.streams=[b.stream],c.dispatchEvent(f)}),b.stream.getTracks().forEach(function(d){var e;e=a.RTCPeerConnection.prototype.getReceivers?c.getReceivers().find(function(a){return a.track&&a.track.id===d.id}):{track:d};var f=new Event("track");f.track=d,f.receiver=e,f.transceiver={receiver:e},f.streams=[b.stream],c.dispatchEvent(f)})},c.addEventListener("addstream",c._ontrackpoly)),b.apply(c,arguments)}}},shimGetSendersWithDtmf:function(a){if("object"==typeof a&&a.RTCPeerConnection&&!("getSenders"in a.RTCPeerConnection.prototype)&&"createDTMFSender"in a.RTCPeerConnection.prototype){var b=function(a,b){return{track:b,get dtmf(){return void 0===this._dtmf&&("audio"===b.kind?this._dtmf=a.createDTMFSender(b):this._dtmf=null),this._dtmf},_pc:a}};if(!a.RTCPeerConnection.prototype.getSenders){a.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var c=a.RTCPeerConnection.prototype.addTrack;a.RTCPeerConnection.prototype.addTrack=function(a,d){var e=this,f=c.apply(e,arguments);return f||(f=b(e,a),e._senders.push(f)),f};var d=a.RTCPeerConnection.prototype.removeTrack;a.RTCPeerConnection.prototype.removeTrack=function(a){var b=this;d.apply(b,arguments);var c=b._senders.indexOf(a);c!==-1&&b._senders.splice(c,1)}}var e=a.RTCPeerConnection.prototype.addStream;a.RTCPeerConnection.prototype.addStream=function(a){var c=this;c._senders=c._senders||[],e.apply(c,[a]),a.getTracks().forEach(function(a){c._senders.push(b(c,a))})};var f=a.RTCPeerConnection.prototype.removeStream;a.RTCPeerConnection.prototype.removeStream=function(a){var b=this;b._senders=b._senders||[],f.apply(b,[a]),a.getTracks().forEach(function(a){var c=b._senders.find(function(b){return b.track===a});c&&b._senders.splice(b._senders.indexOf(c),1)})}}else if("object"==typeof a&&a.RTCPeerConnection&&"getSenders"in a.RTCPeerConnection.prototype&&"createDTMFSender"in a.RTCPeerConnection.prototype&&a.RTCRtpSender&&!("dtmf"in a.RTCRtpSender.prototype)){var g=a.RTCPeerConnection.prototype.getSenders;a.RTCPeerConnection.prototype.getSenders=function(){var a=this,b=g.apply(a,[]);return b.forEach(function(b){b._pc=a}),b},Object.defineProperty(a.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},shimSourceObject:function(a){var b=a&&a.URL;"object"==typeof a&&(!a.HTMLMediaElement||"srcObject"in a.HTMLMediaElement.prototype||Object.defineProperty(a.HTMLMediaElement.prototype,"srcObject",{get:function(){return this._srcObject},set:function(a){var c=this;return this._srcObject=a,this.src&&b.revokeObjectURL(this.src),a?(this.src=b.createObjectURL(a),a.addEventListener("addtrack",function(){c.src&&b.revokeObjectURL(c.src),c.src=b.createObjectURL(a)}),void a.addEventListener("removetrack",function(){c.src&&b.revokeObjectURL(c.src),c.src=b.createObjectURL(a)})):void(this.src="")}}))},shimAddTrackRemoveTrackWithNative:function(a){a.RTCPeerConnection.prototype.getLocalStreams=function(){var a=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(b){return a._shimmedLocalStreams[b][0]})};var b=a.RTCPeerConnection.prototype.addTrack;a.RTCPeerConnection.prototype.addTrack=function(a,c){if(!c)return b.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var d=b.apply(this,arguments);return this._shimmedLocalStreams[c.id]?this._shimmedLocalStreams[c.id].indexOf(d)===-1&&this._shimmedLocalStreams[c.id].push(d):this._shimmedLocalStreams[c.id]=[c,d],d};var c=a.RTCPeerConnection.prototype.addStream;a.RTCPeerConnection.prototype.addStream=function(a){var b=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(function(a){var c=b.getSenders().find(function(b){return b.track===a});if(c)throw new DOMException("Track already exists.","InvalidAccessError")});var d=b.getSenders();c.apply(this,arguments);var e=b.getSenders().filter(function(a){return d.indexOf(a)===-1});this._shimmedLocalStreams[a.id]=[a].concat(e)};var d=a.RTCPeerConnection.prototype.removeStream;a.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],d.apply(this,arguments)};var e=a.RTCPeerConnection.prototype.removeTrack;a.RTCPeerConnection.prototype.removeTrack=function(a){var b=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(function(c){var d=b._shimmedLocalStreams[c].indexOf(a);d!==-1&&b._shimmedLocalStreams[c].splice(d,1),1===b._shimmedLocalStreams[c].length&&delete b._shimmedLocalStreams[c]}),e.apply(this,arguments)}},shimAddTrackRemoveTrack:function(a){function b(a,b){var c=b.sdp;return Object.keys(a._reverseStreams||[]).forEach(function(b){var d=a._reverseStreams[b],e=a._streams[d.id];c=c.replace(new RegExp(e.id,"g"),d.id)}),new RTCSessionDescription({type:b.type,sdp:c})}function c(a,b){var c=b.sdp;return Object.keys(a._reverseStreams||[]).forEach(function(b){var d=a._reverseStreams[b],e=a._streams[d.id];c=c.replace(new RegExp(d.id,"g"),e.id)}),new RTCSessionDescription({type:b.type,sdp:c})}var e=d.detectBrowser(a);if(a.RTCPeerConnection.prototype.addTrack&&e.version>=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<a.iceServers.length;f++){var g=a.iceServers[f];!g.hasOwnProperty("urls")&&g.hasOwnProperty("url")?(d.deprecated("RTCIceServer.url","RTCIceServer.urls"),g=JSON.parse(JSON.stringify(g)),g.urls=g.url,e.push(g)):e.push(a.iceServers[f])}a.iceServers=e}return new c(a,b)},a.RTCPeerConnection.prototype=c.prototype,Object.defineProperty(a.RTCPeerConnection,"generateCertificate",{get:function(){return c.generateCertificate}})}var f=a.RTCPeerConnection.prototype.getStats;a.RTCPeerConnection.prototype.getStats=function(a,b,c){var d=this,e=arguments;if(arguments.length>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<c.iceServers.length;f++){var g=c.iceServers[f];if(g.hasOwnProperty("urls"))for(var h=0;h<g.urls.length;h++){var i={url:g.urls[h]};0===g.urls[h].indexOf("turn")&&(i.username=g.username,i.credential=g.credential),e.push(i)}else e.push(c.iceServers[f])}c.iceServers=e}return new a.mozRTCPeerConnection(c,d)},a.RTCPeerConnection.prototype=a.mozRTCPeerConnection.prototype,a.mozRTCPeerConnection.generateCertificate&&Object.defineProperty(a.RTCPeerConnection,"generateCertificate",{get:function(){return a.mozRTCPeerConnection.generateCertificate}}),a.RTCSessionDescription=a.mozRTCSessionDescription,a.RTCIceCandidate=a.mozRTCIceCandidate),["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 c=a.RTCPeerConnection.prototype.addIceCandidate;a.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?c.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())};var e=function(a){var b=new Map;return Object.keys(a).forEach(function(c){b.set(c,a[c]),b[c]=a[c]}),b},f={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},g=a.RTCPeerConnection.prototype.getStats;a.RTCPeerConnection.prototype.getStats=function(a,c,d){return g.apply(this,[a||null]).then(function(a){if(b.version<48&&(a=e(a)),b.version<53&&!c)try{a.forEach(function(a){a.type=f[a.type]||a.type})}catch(d){if("TypeError"!==d.name)throw d;a.forEach(function(b,c){a.set(c,Object.assign({},b,{type:f[b.type]||b.type}))})}return a}).then(c,d)}}},shimRemoveStream:function(a){!a.RTCPeerConnection||"removeStream"in a.RTCPeerConnection.prototype||(a.RTCPeerConnection.prototype.removeStream=function(a){var b=this;d.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(c){c.track&&a.getTracks().indexOf(c.track)!==-1&&b.removeTrack(c)})})}}},{"../utils":13,"./getusermedia":11}],11:[function(a,b,c){"use strict";var d=a("../utils"),e=d.log;b.exports=function(a){var b=d.detectBrowser(a),c=a&&a.navigator,f=a&&a.MediaStreamTrack,g=function(a){return{name:{InternalError:"NotReadableError",NotSupportedError:"TypeError",PermissionDeniedError:"NotAllowedError",SecurityError:"NotAllowedError"}[a.name]||a.name,message:{"The operation is insecure.":"The request is not allowed by the user agent or the platform in the current context."}[a.message]||a.message,constraint:a.constraint,toString:function(){return this.name+(this.message&&": ")+this.message}}},h=function(a,d,f){var h=function(a){if("object"!=typeof a||a.require)return a;var b=[];return Object.keys(a).forEach(function(c){if("require"!==c&&"advanced"!==c&&"mediaSource"!==c){var d=a[c]="object"==typeof a[c]?a[c]:{ideal:a[c]};if(void 0===d.min&&void 0===d.max&&void 0===d.exact||b.push(c),void 0!==d.exact&&("number"==typeof d.exact?d.min=d.max=d.exact:a[c]=d.exact,delete d.exact),void 0!==d.ideal){a.advanced=a.advanced||[];var e={};"number"==typeof d.ideal?e[c]={min:d.ideal,max:d.ideal}:e[c]=d.ideal,a.advanced.push(e),delete d.ideal,Object.keys(d).length||delete a[c]}}}),b.length&&(a.require=b),a};return a=JSON.parse(JSON.stringify(a)),b.version<38&&(e("spec: "+JSON.stringify(a)),a.audio&&(a.audio=h(a.audio)),a.video&&(a.video=h(a.video)),e("ff37: "+JSON.stringify(a))),c.mozGetUserMedia(a,d,function(a){f(g(a))})},i=function(a){return new Promise(function(b,c){h(a,b,c)})};if(c.mediaDevices||(c.mediaDevices={getUserMedia:i,addEventListener:function(){},removeEventListener:function(){}}),c.mediaDevices.enumerateDevices=c.mediaDevices.enumerateDevices||function(){return new Promise(function(a){var b=[{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}];a(b)})},b.version<41){var j=c.mediaDevices.enumerateDevices.bind(c.mediaDevices);c.mediaDevices.enumerateDevices=function(){return j().then(void 0,function(a){if("NotFoundError"===a.name)return[];throw a})}}if(b.version<49){var k=c.mediaDevices.getUserMedia.bind(c.mediaDevices);c.mediaDevices.getUserMedia=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("The object can not be found here.","NotFoundError");return b},function(a){return Promise.reject(g(a))})}}if(!(b.version>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<a.iceServers.length;f++){var g=a.iceServers[f];!g.hasOwnProperty("urls")&&g.hasOwnProperty("url")?(d.deprecated("RTCIceServer.url","RTCIceServer.urls"),g=JSON.parse(JSON.stringify(g)),g.urls=g.url,delete g.url,e.push(g)):e.push(a.iceServers[f])}a.iceServers=e}return new b(a,c)},a.RTCPeerConnection.prototype=b.prototype,"generateCertificate"in a.RTCPeerConnection&&Object.defineProperty(a.RTCPeerConnection,"generateCertificate",{get:function(){return b.generateCertificate}})},shimTrackEventTransceiver:function(a){"object"==typeof a&&a.RTCPeerConnection&&"receiver"in a.RTCTrackEvent.prototype&&!a.RTCTransceiver&&Object.defineProperty(a.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimCreateOfferLegacy:function(a){var b=a.RTCPeerConnection.prototype.createOffer;a.RTCPeerConnection.prototype.createOffer=function(a){var c=this;if(a){"undefined"!=typeof a.offerToReceiveAudio&&(a.offerToReceiveAudio=!!a.offerToReceiveAudio);var d=c.getTransceivers().find(function(a){return a.sender.track&&"audio"===a.sender.track.kind});a.offerToReceiveAudio===!1&&d?"sendrecv"===d.direction?d.setDirection?d.setDirection("sendonly"):d.direction="sendonly":"recvonly"===d.direction&&(d.setDirection?d.setDirection("inactive"):d.direction="inactive"):a.offerToReceiveAudio!==!0||d||c.addTransceiver("audio"),"undefined"!=typeof a.offerToReceiveAudio&&(a.offerToReceiveVideo=!!a.offerToReceiveVideo);var e=c.getTransceivers().find(function(a){return a.sender.track&&"video"===a.sender.track.kind});a.offerToReceiveVideo===!1&&e?"sendrecv"===e.direction?e.setDirection("sendonly"):"recvonly"===e.direction&&e.setDirection("inactive"):a.offerToReceiveVideo!==!0||e||c.addTransceiver("video")}return b.apply(c,arguments)}}}},{"../utils":13}],13:[function(a,b,c){"use strict";function d(a,b,c){var d=a.match(b);return d&&d.length>=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)});
|