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