/*! aliyun webrtc sdk - ver 1.9.0 created:2019-9-24 15:39:06 */ !function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=23)}([function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n-1?(e._systemName="ipad",e._platform="iOS",e._systemVersion=e._getIosSystemVersion(t)):t.indexOf("iphone")>-1?(e._systemName="iphone",e._platform="iOS",e._systemVersion=e._getIosSystemVersion(t)):t.indexOf("android")>-1?(e._platform="Android",e._systemName="Android",e._systemVersion=e._getAndroidSystemVersion(t)):t.indexOf("win")>-1?t.indexOf("windwos nt 10")>-1||t.indexOf("windows 10")?(e._systemName="Windows 10",e._platform="Windows",e._systemVersion="10"):t.indexOf("windows nt 6.1")>-1||t.indexOf("windows 7")>-1?(e._systemName="Windows 7",e._platform="Windows",e._systemVersion="7"):t.indexOf("windows nt 6.0")>-1||t.indexOf("windows vista")>-1?(e._systemName="Windows vista",e._platform="Windows",e._systemVersion="vista"):t.indexOf("widows nt 5.1")>-1||t.indexOf("windows xp")>-1?(e._systemName="Windows xp",e._platform="Windows",e._systemVersion="xp"):(e._platform="Windows",e._systemName="Windows",e._systemVersion="0.0"):t.indexOf("mac")>-1?(e._platform="Mac",e._systemName="Mac",e._systemVersion=e._getMacSystemVersion(t)):t.indexOf("linux")>-1?(e._platform="Linux",e._systemName="Linux",e._systemVersion="0.0"):(e._systemName="unknown",e._platform="Other",e._systemVersion="0.0")}else e._systemName="unknown",e._systemVersion="0.0"}},{key:"_getIosSystemVersion",value:function(e){var t=/OS [\d._]*/gi;return(e.match(t)+"").replace(/[^0-9|_.]/gi,"").replace(/_/gi,".")}},{key:"_getMacSystemVersion",value:function(e){var t=/OS X [\d._]*/gi;return(e.match(t)+"").replace(/[^0-9|_.]/gi,"").replace(/_/gi,".")}},{key:"_getAndroidSystemVersion",value:function(e){return e.substr(e.indexOf("android")+8,e.indexOf(";",e.indexOf("android"))-e.indexOf("android")-8)}},{key:"isMacOS",get:function(){return"Mac"===e.systemName}},{key:"isWindows",get:function(){return e.systemName&&e.systemName.indexOf("Windows")>-1}},{key:"isIos",get:function(){return"iphone"===e.systemName||"ipad"===e.systemName}},{key:"isAndroid",get:function(){return"Android"===e.systemName}},{key:"systemName",get:function(){return e._getSystemInfo(),e._systemName}},{key:"systemVersion",get:function(){return e._getSystemInfo(),e._systemVersion}}]),e}();t.default=a},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n=n&&parseInt(r[n],10)}function i(e,t,n){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var a=function(e){r(n(e))};return this._eventMap=this._eventMap||{},this._eventMap[r]=a,i.apply(this,[e,a])};var a=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[n])return a.apply(this,arguments);var r=this._eventMap[n];return delete this._eventMap[n],a.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}var a=!0,o=!0;e.exports={extractVersion:r,wrapPeerConnectionEvent:i,disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(a=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},disableWarnings:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(o=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))},log:function(){if("object"==typeof window){if(a)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},deprecated:function(e,t){o&&console.warn(e+" is deprecated, please use "+t+" instead.")},detectBrowser:function(e){var t=e&&e.navigator,n={};if(n.browser=null,n.version=null,void 0===e||!e.navigator)return n.browser="Not a browser.",n;if(t.mozGetUserMedia)n.browser="firefox",n.version=r(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia)n.browser="chrome",n.version=r(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))n.browser="edge",n.version=r(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return n.browser="Not a supported browser.",n;n.browser="safari",n.version=r(t.userAgent,/AppleWebKit\/(\d+)\./,1)}return n}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={OnPublisher:"onPublisher",OnMediaStream:"onMediaStream",OnError:"onError",OnUnPublisher:"onUnPublisher",OnLeave:"onLeave",OnJoin:"onJoin",OnConnecting:"OnConnecting",OnConnected:"OnConnected"}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};t=e._getUrl(t,n),r.headers||(r.headers={}),r.headers["Content-Type"]="application/json";var i="";return new Promise(function(n,a){e.request("GET",t,r).then(function(e){return i=e,e.ok?e.json():e.text()}).then(function(t){i.ok?t.code?(t=e._intercept(t),a(t)):n(t.data):a(e._httpErrorMessage(i,t))}).catch(function(t){t=e._httpErrorMessage(t),a(t)})})}},{key:"post",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t=e._getUrl(t,n),i.headers||(i.headers={}),i.body=r,i.headers.Accept="application/json",i.headers["Content-Type"]="application/json";var a="";return new Promise(function(n,r){e.request("POST",t,i).then(function(e){return a=e,e.ok?e.json():e.text()}).then(function(t){a.ok?t.code?(t=e._intercept(t),r(t)):n(t.data):r(e._httpErrorMessage(a,t))}).catch(function(t){t=e._httpErrorMessage(t),r(t)})})}},{key:"request",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"GET",t=arguments[1],n=arguments[2],r=new Headers(n.headers),i={method:e,headers:r},a=new Request(t,i);return fetch(a)}},{key:"requestBody",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"GET",t=arguments[1],n=arguments[2];return fetch(t,{method:e,body:n,headers:new Headers({"Content-Type":"application/json"})})}},{key:"ajaxPost",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return t=e._getUrl(t,n),i.headers||(i.headers={}),i.headers.Accept="application/json",i.headers["Content-Type"]="application/json",e.ajax("POST",t,r,i)}},{key:"logPost",value:function(t,n,r){var i={headers:n};return e.ajax("POST",t,r,i)}},{key:"ajax",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"GET",n=arguments[1],r=arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};"undefined"==typeof XMLHttpRequest&&(window.XMLHttpRequest=function(){try{return new window.ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new window.ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new window.ActiveXObject("Msxml2.XMLHTTP")}catch(e){}throw new Error("This browser does not support XMLHttpRequest.")});var a=new XMLHttpRequest;return new Promise(function(o,s){a.onreadystatechange=function(){if(4===a.readyState)if(200===a.status){var t=JSON.parse(a.responseText);t.code?(t=e._intercept(t),s(t)):o(t)}else s({message:a.responseText||"请求失败:"+n})},a.open(t,n,!0);try{if(i.withCredentials&&(a.withCredentials=!0),i.headers)for(var c in i.headers)a.setRequestHeader(c,i.headers[c])}catch(e){return void s(e)}try{a.send(r)}catch(e){s(e)}})}},{key:"_getUrl",value:function(e,t){var n=[];if(t)for(var r in t)n.push(r+"="+t[r]);var i=n.join("&");return e=(-1!=e.indexOf("?")?e:e+"?")+i}},{key:"_httpErrorMessage",value:function(e,t){return e.message||(e.message="HTTP "+e.status+"("+e.statusText+") : "+t),e}},{key:"_intercept",value:function(e){var t=e.data;return e.code&&(t=t||{},t.data=e.data,t.code=e.code,t.description=e.description,t.message="0x"+Number(e.code).toString(16)+", "+e.description,t.tid&&(t.message+=", tid="+t.tid)),t}}]),e}();t.default=a},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n0&&a0&&o=0;){var c=t[o].indexOf("label:");if(c>0){for(var u=!1,d=0;d0){for(var l=!1,f=0;f-1){u=t[a].split(" ")[0]+" ";for(var l=a;l-1;++l)t[l].indexOf("cname:")>-1?(!0,++a):t[l].indexOf("msid:")>-1?(o=!0,++a):t[l].indexOf("mslabel:")>-1?(s=!0,++a):t[l].indexOf("label")>-1&&(c=!0,++a);if(o||(t.splice(a,0,u+i),++a,++d),!s){var f=i.split(" ")[0];f=f.replace("msid","mslabel"),t.splice(a,0,u+f),++a,++d}c||(t.splice(a,0,u+"label:"+i.split(" ")[1]),++d)}return d}},{key:"maybeSetOpusOptions",value:function(t,n){return"true"===n.opusStereo?t=e.setCodecParam(t,"opus/48000","stereo","1"):"false"===n.opusStereo&&(t=e.removeCodecParam(t,"opus/48000","stereo")),"true"===n.opusFec?t=e.setCodecParam(t,"opus/48000","useinbandfec","1"):"false"===n.opusFec&&(t=e.removeCodecParam(t,"opus/48000","useinbandfec")),"true"===n.opusDtx?t=e.setCodecParam(t,"opus/48000","usedtx","1"):"false"===n.opusDtx&&(t=e.removeCodecParam(t,"opus/48000","usedtx")),n.opusMaxPbr&&(t=e.setCodecParam(t,"opus/48000","maxplaybackrate",n.opusMaxPbr)),t}},{key:"maybeSetAudioSendBitRate",value:function(t,n){return n.audioSendBitrate?e.preferBitRate(t,n.audioSendBitrate,"audio"):t}},{key:"maybeSetAudioReceiveBitRate",value:function(t,n){return n.audioRecvBitrate?(consolog.log("Prefer audio receive bitrate: "+n.audioRecvBitrate),e.preferBitRate(t,n.audioRecvBitrate,"audio")):t}},{key:"maybeSetVideoSendBitRate",value:function(t,n){return n.videoSendBitrate?(cosole.log("Prefer video send bitrate: "+n.videoSendBitrate),e.preferBitRate(t,n.videoSendBitrate,"video")):t}},{key:"maybeSetVideoReceiveBitRate",value:function(t,n){return n.videoRecvBitrate?e.preferBitRate(t,n.videoRecvBitrate,"video"):t}},{key:"preferBitRate",value:function(t,n,r){var i=t.split("\r\n"),a=e.findLine(i,"m=",r);if(null===a)return t;var o=e.findLineInRange(i,a+1,-1,"m=");null===o&&(o=i.length);var s=e.findLineInRange(i,a+1,o,"c=");if(null===s)return t;var c=e.findLineInRange(i,s+1,o,"b=AS");c&&i.splice(c,1);var u="b=AS:"+n;return i.splice(s+1,0,u),t=i.join("\r\n")}},{key:"maybeSetVideoSendInitialBitRate",value:function(t,n){var r=parseInt(n.videoSendInitialBitrate);if(!r)return t;var i=parseInt(r),a=parseInt(n.videoSendBitrate);a&&(r>a&&(r=a,n.videoSendInitialBitrate=r),i=a);var o=t.split("\r\n"),s=e.findLine(o,"m=","video");if(null===s)return t;var c=o[s],u=new RegExp("m=video\\s\\d+\\s[A-Z/]+\\s"),d=c.split(u)[1].split(" ")[0],l=o[e.findLine(o,"a=rtpmap",d)],f=l.split("a=rtpmap:"+d)[1].split("/")[0],p=n.videoSendCodec||f;return t=e.setCodecParam(t,p,"x-google-min-bitrate",n.videoSendInitialBitrate.toString()),t=e.setCodecParam(t,p,"x-google-max-bitrate",i.toString())}},{key:"removePayloadTypeFromMline",value:function(e,t){e=e.split(" ");for(var n=0;n0||e.indexOf("h264")>0)}},{key:"replace42e01fTo42001f",value:function(e){return e}},{key:"supportH264",value:function(e){return-1==e.indexOf("m=video")?-1:e.indexOf("H264")>0||e.indexOf("h264")>0?1:0}},{key:"needUnifiedSDPPlan",value:function(e){var t=e.indexOf("a=mid:");if(t>-1){var n=e.indexOf("\r",t);-1==n&&(n=e.indexOf("\n",t));var r=e.substring(t+6,n);return-1==r.indexOf("audio")&&-1==r.indexOf("video")}return!1}},{key:"DEFAULT_SDP_OFFER_OPTIONS",get:function(){return{offerToReceiveAudio:!0,offerToReceiveVideo:!0}}}]),e}());t.default=o},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:1e3;this.stopMonitor(),this._interval=e,this._startMonitorTimer()}},{key:"stopMonitor",value:function(){this._stopMonitorTimer()}},{key:"releaseMonitor",value:function(){this.stopMonitor(),this._peerConnection&&(this._peerConnection=null)}},{key:"_startMonitorTimer",value:function(){var e=this;this._stopMonitorTimer(),this._timerId=setInterval(function(){e._onMonitorTimer()},this._interval)}},{key:"_stopMonitorTimer",value:function(){this._timerId&&clearInterval(this._timerId),this._timerId=0}},{key:"_onMonitorTimer",value:function(){}},{key:"dispose",value:function(){}}]),e}());t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={SmallVideo:"sophon_video_camera_small",LargeVideo:"sophon_video_camera_large",ScreenShareVideo:"sophon_video_screen_share",SuperVideo:"sophon_video_camera_super",Audio:"sophon_audio"};t.default=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]&&arguments[1];return new Promise(function(n,r){navigator.mediaDevices.getUserMedia(e).then(function(e){n(e)}).catch(function(e){t._handleError(e),r(e)})})}},{key:"_handleError",value:function(e){switch(e.name){case"NotFoundError":e.message="Unable to open your call because no camera and/or microphone were found.";break;case"ConstraintNotSatisfiedError":e.message="The resolution is not supported by your device.";break;case"SecurityError":case"PermissionDeniedError":e.message="Permissions have not been granted to use your camera and microphone, you need to allow the page access to your devices in order to work.";break;default:e.message="Error opening your camera and/or microphone: "+e.message}}},{key:"_setVideoElementAttribute",value:function(e){this._localVideoElement&&(this._localVideoElement.setAttribute("autoplay",""),this._localVideoElement.srcObject=e)}},{key:"_releaseLocalVideoElement",value:function(){this._localVideoElement&&(this._localVideoElement.srcObject=null,this._localVideoElement=null)}},{key:"_releasePreviewStream",value:function(){this._preViewStream&&this._preViewStream.getTracks().forEach(function(e){e.stop()}),this._preViewStream=null}},{key:"_getResolution",value:function(e,t){var n=this,r=this._resolutionArr.length,i=0,a=[];return new Promise(function(o,s){!function c(){var u=n._resolutionArr[i];n._checkResolution(e,t,u.width,u.height).then(function(e){a.push({width:e.width?e.width:u.width,height:e.height?e.height:u.height}),i==r-1?o(a):(i++,c())}).catch(function(e){i==r-1?a.length?o(a):s(e):(i++,c())})}()})}},{key:"_checkResolution",value:function(e,t,n,r){var i={audio:!1,video:{width:{exact:n},height:{exact:r}}};return e&&(i.video.deviceId={exact:e}),new Promise(function(e,t){navigator.mediaDevices.getUserMedia(i).then(function(t){t.getTracks().forEach(function(e){e.stop()}),e({width:n,height:r})}).catch(function(e){t(e)})})}},{key:"_getPreviewConstraints",value:function(){var e={};return this._cameraInfo.deviceId?(e.video={},Object.assign(e.video,this._cameraInfo),Object.assign(e.video,this._videoProfile)):e.video=this._videoProfile,e}},{key:"_getPublishConstraints",value:function(){var e={};return this._cameraInfo.deviceId?(e.video={},Object.assign(e.video,this._cameraInfo),Object.assign(e.video,this._videoProfile)):e.video=this._videoProfile,this._audioInfo.deviceId?(e.audio={},Object.assign(e.audio,this._audioInfo)):e.audio=!0,e}},{key:"_getMediaStream",value:function(e){var t=void 0;return t=e?this._getPreviewConstraints():this._getPublishConstraints(),navigator.mediaDevices.getUserMedia(t)}},{key:"configLocalCameraPublish",set:function(e){this._configLocalCameraPublish=e},get:function(){return this._configLocalCameraPublish}},{key:"configLocalScreenPublish",set:function(e){this._configLocalScreenPublish=e},get:function(){return this._configLocalScreenPublish}},{key:"configLocalAudioPublish",set:function(e){this._configLocalAudioPublish=e},get:function(){return this._configLocalAudioPublish}},{key:"currentCamera",set:function(e){this._cameraInfo=e}},{key:"currentAudioCapture",set:function(e){this._audioInfo=e}},{key:"videoProfile",set:function(e){e&&(this._videoProfile.width=e.width?e.width:this._videoProfile.width,this._videoProfile.height=e.height?e.height:this._videoProfile.height,this._videoProfile.frameRate=e.frameRate?e.frameRate:this._videoProfile.frameRate)}},{key:"audioProfile",set:function(e){this._audioProfile=e}}]),e}();t.default=s},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n3&&void 0!==arguments[3]&&arguments[3];if(this._checkFunction(t)){void 0===this._eventListener[e]&&(this._eventListener[e]=[]);for(var i=this._eventListener[e],a=0;a=0;--r){var i=n[r].func,a=n[r].context;n[r].once&&n.splice(r,1),i.apply(a,e)}}},{key:"_checkFunction",value:function(e){return!(!e||"function"!=typeof e)}}]),e}();t.default=a},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return n=n.concat(r.splitLines(t)),{usernameFragment:n.filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e),i=n[0].split(" "),a=3;a0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),a=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,u=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===c&&(t=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(r.rtx={ssrc:t}),n.push(r),a&&(r=JSON.parse(JSON.stringify(r)),r.fec={ssrc:t,mechanism:o?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&c&&n.push({ssrc:c});var d=r.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=d})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var a=r.matchPrefix(e,"a=rtcp-mux");return t.mux=a.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return t=n[0].substr(7).split(" "),{stream:t[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?(t=i[0].value.split(" "),{stream:t[0],track:t[1]}):void 0},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t){var n=void 0!==t?t:2;return"v=0\r\no=thisisadapterortc "+(e||r.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var a=r.writeRtpDescription(e.kind,t);if(a+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),a+="a=mid:"+e.mid+"\r\n",e.direction?a+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var o="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";a+="a="+o,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),a},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i0?i(e):setTimeout(n,1e3)}()},n,!0),b.default.ajaxPost(T.default.PublishUrl,{appid:n._authInfo.appid,session:n._authInfo.sessionId,callid:n._authInfo.publishCallId,tid:r,server:T.default.serverUrl,token:n._authInfo.token},o).then(function(t){n._setLocalDescription(e).then(function(){}).catch(function(e){a(e)})}).catch(function(e){a(e)})})}},{key:"_updateSDPTrack",value:function(e){if(e){e.split("\r\n")}return e}},{key:"_iceCandidateByOffer",value:function(e,t){var n=this,r=g.default.random(32),i={completed:!!e};return e||(i.candidate={sdpMLineIndex:t.sdpMLineIndex,sdpMid:t.sdpMid,candidate:t.candidate}),new Promise(function(e,t){n._signalingListener&&n._signalingListener.addEventListener(r,function(t){e(t)},n,!0),b.default.ajaxPost(T.default.ICECandidateUrl,{appid:n._authInfo.appid,session:n._authInfo.sessionId,callid:n._authInfo.publishCallId,tid:r,server:T.default.serverUrl,token:n._authInfo.token},JSON.stringify(i)).then(function(e){}).catch(function(e){t(e)})})}},{key:"_releaseMonitor",value:function(){this._pcMonitor&&(this._pcMonitor.stopMonitor(),this._pcMonitor=null)}},{key:"_setEncodParams",value:function(){for(var e=this.conn.getSenders(),t=0;t-1&&t>-1)return this._preferMaster?(this._subscribeStreams.push({mslabel:this._streamConfig[e].mslabel,label:this._streamConfig[e].label,type:this._streamConfig[e].type,temporalLayer:this._streamConfig[e].temporalLayers-1,substream:this._streamConfig[e].substreams-1}),f.default.LargeVideo):(this._subscribeStreams.push({mslabel:this._streamConfig[t].mslabel,label:this._streamConfig[t].label,type:this._streamConfig[t].type,temporalLayer:this._streamConfig[t].temporalLayers-1,substream:this._streamConfig[t].substreams-1}),f.default.SmallVideo);if(e>-1)return this._subscribeStreams.push({mslabel:this._streamConfig[e].mslabel,label:this._streamConfig[e].label,type:this._streamConfig[e].type,temporalLayer:this._streamConfig[e].temporalLayers-1,substream:this._streamConfig[e].substreams-1}),f.default.LargeVideo;if(t>-1)return this._subscribeStreams.push({mslabel:this._streamConfig[t].mslabel,label:this._streamConfig[t].label,type:this._streamConfig[t].type,temporalLayer:this._streamConfig[t].temporalLayers-1,substream:this._streamConfig[t].substreams-1}),f.default.SmallVideo;if(this._streamConfig.length<=2)for(var r=0;rthis._packetsLost?this._packetsLostRate=(i-this._packetsLost)/(n-this._packetsReceived):this._packetsLostRate=0,this._packetsLost=i}this._lastDataReceivedTimeStamp=e,this._bytesReceived=t,this._packetsReceived=n}},{key:"ssrc",get:function(){return this._ssrc}},{key:"packetsLostRate",get:function(){return this._packetsLostRate}},{key:"mimeType",get:function(){return this._mimeType}},{key:"bytesReceivedPerSecond",get:function(){return this._bytesReceivedPerSecond}},{key:"packetsReceivedPerSecond",get:function(){return this._packetsReceivedPerSecond}}]),e}();t.default=a},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nthis._packetsLost?this._packetsLostRate=(i-this._packetsLost)/(n-this._packetsReceived):this._packetsLostRate=0,this._packetsLost=i}this._lastDataReceivedTimeStamp=e,this._bytesReceived=t,this._packetsReceived=n}},{key:"onVideoTrack",value:function(e,t,n,r,i,a){if(this._lastFrameReceivedTimeStamp&&this._framesReceived){var o=(e-this._lastFrameReceivedTimeStamp)/1e3;this._framesReceivedPerSecond=(t-this._framesReceived)/o,this._framesDecodedPerSecond=(i-this._framesDecoded)/o}n&&r&&(this._isVideo=!0),this._lastFrameReceivedTimeStamp=e,this._framesReceived=t,this._framesDecoded=i,this._framesDropped=a}},{key:"onVideoCandidatePair",value:function(e){this._availableBandwidth=e}},{key:"isVideo",get:function(){return this._isVideo}},{key:"frameRate",get:function(){return this._frameRate}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"ssrc",get:function(){return this._ssrc}},{key:"codec",get:function(){return this._mimeType}},{key:"packetsReceived",get:function(){return this._packetsReceived}},{key:"packetsLostRate",get:function(){return this._packetsLostRate}},{key:"mimeType",get:function(){return this._mimeType}},{key:"nackCount",get:function(){return this._nackCount}},{key:"pliCount",get:function(){return this._pliCount}},{key:"firCount",get:function(){return this._firCount}},{key:"bytesReceivedPerSecond",get:function(){return this._bytesReceivedPerSecond}},{key:"packetsReceivedPerSecond",get:function(){return this._packetsReceivedPerSecond}},{key:"availableBandwidth",get:function(){return this._availableBandwidth}}]),e}();t.default=s},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function e(){r(this,e),this.trackid="",this.src="",this.fps=0,this.teb=0,this.vrn=0,this.codec="",this.w=0,this.h=0,this.vps=0};t.default=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function e(t){r(this,e),this.calid=t,this.rtt=-1,this.raddr="",this.asb=1e3,this.video=[],this.audio={src:"",isa:!1,codec:"",aps:0}};t.default=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n0&&(this._availableAuth=this.auth[0]),this._availableAuth},set:function(e){this._availableAuth=e}},{key:"slb",get:function(){return this._slb},set:function(e){this._slb=e,delete this._availableSlb}},{key:"availableSlb",get:function(){return!this._availableSlb&&this.slb&&this.slb.length>0&&(this._availableSlb=this.slb[0]),this._availableSlb},set:function(e){this._availableSlb=e}},{key:"servers",get:function(){return this._servers},set:function(e){this._servers=e,delete this._availableServer}},{key:"availableServer",get:function(){return!this._availableServer&&this.servers&&this.servers.length>0&&(this._availableServer=this.servers[0]),this._availableServer},set:function(e){this._availableServer=e}},{key:"turnInfo",get:function(){return this._turnInfo},set:function(e){this._turnInfo=e}}]),e}();t.default=a},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n-1?(r.push({kind:"videoinput",facingMode:"user",label:"前置摄像头"}),e._videoDeviceMap.user=t.deviceId):t.label.indexOf("back")>-1&&(r.push({kind:"videoinput",facingMode:"environment",label:"后置摄像头"}),e._videoDeviceMap.environment=t.deviceId))});var a={videoDevices:r,audioDevices:i};l.default.reportGetDevice(a),t(a)}).catch(function(e){l.default.reportGetDevice(e),n(e)})})}},{key:"_getPreviewConstraints",value:function(){var e={};return this._cameraInfo.facingMode||this._cameraInfo.deviceId?(e.video={},this._cameraInfo.facingMode?e.video.deviceId=this._videoDeviceMap[this._cameraInfo.facingMode]:Object.assign(e.video,this._cameraInfo),Object.assign(e.video,this._videoProfile)):e.video=this._videoProfile,e}},{key:"_getPublishConstraints",value:function(){var e={};return this._configLocalCameraPublish&&(this._cameraInfo.facingMode||this._cameraInfo.deviceId)?(e.video={},this._cameraInfo.facingMode?e.video.deviceId=this._videoDeviceMap[this._cameraInfo.facingMode]:Object.assign(e.video,this._cameraInfo),Object.assign(e.video,this._videoProfile)):e.video=this._videoProfile,this._audioInfo.deviceId?(e.audio={},Object.assign(e.audio,this._audioInfo)):e.audio=!0,e}},{key:"_initDevice",value:function(){}}]),t}(u.default);t.default=f},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n=0;--t){var n=e[t];if(-1!=n.indexOf("udp")){var r=n.indexOf(":",5),i=n.indexOf("?"),a=n.substring(0,r+1),o=n.substring(i,n.length);y.default.isFirefox?e.splice(t,1,a+"443"+o):e.splice(t,1,a+"80"+o,a+"443"+o,a+"3478"+o,a+"50000"+o)}}return e}},{key:"_getTurnCredential",value:function(){return{username:this._authInfo.userId+"?appid="+this._authInfo.appid+"&session="+this._authInfo.sessionId+"&channel="+this._authInfo.channel+"&nonce="+this._authInfo.nonce+"×tamp="+this._authInfo.timestamp+"&tokensid=false",credential:"hello1234"}}}]),t}(l.default);t.default=k},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n=70&&this._checkBrowserSupportScreenShare()&&(this._supportScreenShare=!0)):(this._isSupport=!1,this._message="MacOS支持Chrome和Safari浏览器"):u.default.isWindows?s.default.isChrome?s.default.browserMainVersion<60?(this._isSupport=!1,this._message="Windows支持Chrome60以上浏览器"):(this._isSupport=!0,s.default.browserMainVersion>=70&&this._checkBrowserSupportScreenShare()&&(this._supportScreenShare=!0)):(this._isSupport=!1,this._message="Windows支持Chrome浏览器"):(this._isSupport=!1,this._message="不支持该操作系统")}},{key:"_checkBrowserSupportScreenShare",value:function(){return!!(navigator&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)}},{key:"supportScreenShare",get:function(){return this._supportScreenShare}},{key:"supportH264",get:function(){return this._supportH264}},{key:"isChecking",get:function(){return 1===this._checkingstatus}},{key:"needSDPUnified",get:function(){return this._needSDPUnified}},{key:"isComplete",get:function(){return 2===this._checkingstatus}},{key:"checkresult",get:function(){return{isSupported:this._isSupport,message:this._message,system:u.default.systemName,browser:s.default.browserName,browser_version:s.default.browserVersion,audioDevice:this._hasAudioDevice,videoDevice:this._hasVideoDevice,supportScreenShare:this._supportScreenShare,supportH264:this._supportH264}}}]),e}();t.default=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:100;this.cancel(),this._canceled=!1,this._longPollingHandle=setTimeout(function(){e._listen()},t)}},{key:"_restart",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;this._canceled||this.start(e)}},{key:"_listen",value:function(){var e=this;this._disposed||new Promise(function(t,n){if(!e._authInfo.userId||!e._authInfo.token)return void t(null);++e._seq,u.default.get(v.default.PollingUrl,{appid:e._authInfo.appid,session:e._authInfo.sessionId,server:v.default.serverUrl,token:e._authInfo.token,seq:e._seq}).then(function(e){e&&33620229==e.code&&"no session"==e.description?n(e):t(e)}).catch(function(t){e._restart(0),n(t)})}).then(function(t){return t.tid&&e.has(t.tid)?(e._restart(0),t):(""!=t.tid&&t.event&&e.response(t.tid,t.event),e._restart(0),t)}).then(function(t){!e._disposed&&t&&(t.tid&&e.has(t.tid)?e.dispatchEvent(t.tid,t):t.tid&&t.event&&e._onSignalingMsg(t.event,t))}).catch(function(t){if(!e._disposed){if(500==t.status&&""!=t.responseText)return void e._onSignalingMsg(p.default.SignalError,t);if(33620229==t.code&&"no session"==t.description)return void(0==e._nosessionIndex?++e._nosessionIndex:e._onSignalingMsg(p.default.SignalError,{message:t.code+"|"+t.description}));if(33620257===t.code&&t.data&&t.data.tid&&e.has(t.data.tid)){var n=t.data.tid;t.data=void 0,e.dispatchEvent(n,t)}e._restart()}})}},{key:"response",value:function(e,t){var n=this;return new Promise(function(r,i){u.default.ajaxPost(v.default.PollingResponseUrl,{appid:n._authInfo.appid,session:n._authInfo.sessionId,server:v.default.serverUrl,token:n._authInfo.token,tid:e},JSON.stringify({code:0,description:"success",data:{event:t,contentType:"sophon",content:"test"}})).then(function(e){return e}).then(function(e){}).catch(function(e){})})}},{key:"_onSignalingMsg",value:function(e,t){switch(e){case p.default.Join:this._onSignalJoin(t);break;case p.default.Publishers:this._onPublisher(t);break;case p.default.Leave:this._onLeave(t);break;case p.default.SignalError:this._onSignalError(t);break;case p.default.Offer:this._onOffer(t);break;case p.default.UnPublish:this._onUnpublish(t)}}},{key:"_onSignalJoin",value:function(e){this._channelInfo.onJoin(e)}},{key:"_onPublisher",value:function(e){e&&this._channelInfo.onPublisher(e.publishers,this._authInfo)}},{key:"_onLeave",value:function(e){this._channelInfo.onLeave(e)}},{key:"_onOffer",value:function(e){this._channelInfo.onOffer(e)}},{key:"_onUnpublish",value:function(e){this._channelInfo.onUnpublish(e)}},{key:"_onSignalError",value:function(e){this._channelInfo.onSignalError(e)}}]),t}(l.default);t.default=m},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={Publishers:"publishers",UnPublish:"unpublish",Offer:"offer",SignalError:"signalError",Leave:"leave",Join:"join",UnSubscribe:"unsubscribe"};t.default=r},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var r=n(3);e.exports=function(e,t){var i=e&&e.window,a={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0};for(var o in t)hasOwnProperty.call(t,o)&&(a[o]=t[o]);var s=r.log,c=r.detectBrowser(i),u=n(59)||null,d=n(61)||null,l=n(65)||null,f=n(67)||null,p=n(68)||null,h={browserDetails:c,commonShim:p,extractVersion:r.extractVersion,disableLog:r.disableLog,disableWarnings:r.disableWarnings};switch(c.browser){case"chrome":if(!u||!u.shimPeerConnection||!a.shimChrome)return s("Chrome shim is not included in this adapter release."),h;s("adapter.js shimming chrome."),h.browserShim=u,p.shimCreateObjectURL(i),u.shimGetUserMedia(i),u.shimMediaStream(i),u.shimSourceObject(i),u.shimPeerConnection(i),u.shimOnTrack(i),u.shimAddTrackRemoveTrack(i),u.shimGetSendersWithDtmf(i),u.shimSenderReceiverGetStats(i),p.shimRTCIceCandidate(i),p.shimMaxMessageSize(i),p.shimSendThrowTypeError(i);break;case"firefox":if(!l||!l.shimPeerConnection||!a.shimFirefox)return s("Firefox shim is not included in this adapter release."),h;s("adapter.js shimming firefox."),h.browserShim=l,p.shimCreateObjectURL(i),l.shimGetUserMedia(i),l.shimSourceObject(i),l.shimPeerConnection(i),l.shimOnTrack(i),l.shimRemoveStream(i),l.shimSenderGetStats(i),l.shimReceiverGetStats(i),l.shimRTCDataChannel(i),p.shimRTCIceCandidate(i),p.shimMaxMessageSize(i),p.shimSendThrowTypeError(i);break;case"edge":if(!d||!d.shimPeerConnection||!a.shimEdge)return s("MS edge shim is not included in this adapter release."),h;s("adapter.js shimming edge."),h.browserShim=d,p.shimCreateObjectURL(i),d.shimGetUserMedia(i),d.shimPeerConnection(i),d.shimReplaceTrack(i),p.shimMaxMessageSize(i),p.shimSendThrowTypeError(i);break;case"safari":if(!f||!a.shimSafari)return s("Safari shim is not included in this adapter release."),h;s("adapter.js shimming safari."),h.browserShim=f,p.shimCreateObjectURL(i),f.shimRTCIceServerUrls(i),f.shimCallbacksAPI(i),f.shimLocalStreamsAPI(i),f.shimRemoteStreamsAPI(i),f.shimTrackEventTransceiver(i),f.shimGetUserMedia(i),f.shimCreateOfferLegacy(i),p.shimRTCIceCandidate(i),p.shimMaxMessageSize(i),p.shimSendThrowTypeError(i);break;default:s("Unsupported browser!")}return h}},function(e,t,n){"use strict";function r(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach(function(i){i.endsWith("Id")?r(e,e.get(t[i]),n):i.endsWith("Ids")&&t[i].forEach(function(t){r(e,e.get(t),n)})}))}function i(e,t,n){var i=n?"outbound-rtp":"inbound-rtp",a=new Map;if(null===t)return a;var o=[];return e.forEach(function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)}),o.forEach(function(t){e.forEach(function(n){n.type===i&&n.trackId===t.id&&r(e,n,a)})}),a}var a=n(3),o=a.log;e.exports={shimGetUserMedia:n(60),shimMediaStream:function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},shimOnTrack:function(e){if("object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)"RTCRtpTransceiver"in e||a.wrapPeerConnectionEvent(e,"track",function(e){return e.transceiver||(e.transceiver={receiver:e.receiver}),e});else{Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return n._ontrackpoly||(n._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.track.id}):{track:r.track};var a=new Event("track");a.track=r.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],n.dispatchEvent(a)}),t.stream.getTracks().forEach(function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.id}):{track:r};var a=new Event("track");a.track=r,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],n.dispatchEvent(a)})},n.addEventListener("addstream",n._ontrackpoly)),t.apply(n,arguments)}}},shimGetSendersWithDtmf:function(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var i=this,a=n.apply(i,arguments);return a||(a=t(i,e),i._senders.push(a)),a};var r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;r.apply(t,arguments);var n=t._senders.indexOf(e);-1!==n&&t._senders.splice(n,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;n._senders=n._senders||[],i.apply(n,[e]),e.getTracks().forEach(function(e){n._senders.push(t(n,e))})};var a=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._senders=t._senders||[],a.apply(t,[e]),e.getTracks().forEach(function(e){var n=t._senders.find(function(t){return t.track===e});n&&t._senders.splice(t._senders.indexOf(n),1)})}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var o=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=o.apply(e,[]);return t.forEach(function(t){t._pc=e}),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},shimSenderReceiverGetStats:function(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(e,[]);return n.forEach(function(t){t._pc=e}),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return i(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var r=e.RTCPeerConnection.prototype.getReceivers;r&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=r.apply(e,[]);return t.forEach(function(t){t._pc=e}),t}),a.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return i(t,e.track,!1)})}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var o=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var t=this;if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var n,r,i,a=arguments[0];return t.getSenders().forEach(function(e){e.track===a&&(n?i=!0:n=e)}),t.getReceivers().forEach(function(e){return e.track===a&&(r?i=!0:r=e),e.track===a}),i||n&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return o.apply(t,arguments)}}}},shimSourceObject:function(e){var t=e&&e.URL;"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this._srcObject},set:function(e){var n=this;if(this._srcObject=e,this.src&&t.revokeObjectURL(this.src),!e)return void(this.src="");this.src=t.createObjectURL(e),e.addEventListener("addtrack",function(){n.src&&t.revokeObjectURL(n.src),n.src=t.createObjectURL(e)}),e.addEventListener("removetrack",function(){n.src&&t.revokeObjectURL(n.src),n.src=t.createObjectURL(e)})}}))},shimAddTrackRemoveTrackWithNative:function(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(e){if(t.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")});var r=t.getSenders();n.apply(this,arguments);var i=t.getSenders().filter(function(e){return-1===r.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(i)};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(function(n){var r=t._shimmedLocalStreams[n].indexOf(e);-1!==r&&t._shimmedLocalStreams[n].splice(r,1),1===t._shimmedLocalStreams[n].length&&delete t._shimmedLocalStreams[n]}),i.apply(this,arguments)}},shimAddTrackRemoveTrack:function(e){function t(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}function n(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})}var r=a.detectBrowser(e);if(e.RTCPeerConnection.prototype.addTrack&&r.version>=65)return this.shimAddTrackRemoveTrackWithNative(e);var i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=i.apply(this);return e._reverseStreams=e._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var o=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(n._streams=n._streams||{},n._reverseStreams=n._reverseStreams||{},t.getTracks().forEach(function(e){if(n.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")}),!n._reverseStreams[t.id]){var r=new e.MediaStream(t.getTracks());n._streams[t.id]=r,n._reverseStreams[r.id]=t,t=r}o.apply(n,[t])};var s=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._streams=t._streams||{},t._reverseStreams=t._reverseStreams||{},s.apply(t,[t._streams[e.id]||e]),delete t._reverseStreams[t._streams[e.id]?t._streams[e.id].id:e.id],delete t._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===r.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError");r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{};var a=r._streams[n.id];if(a)a.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var o=new e.MediaStream([t]);r._streams[n.id]=o,r._reverseStreams[o.id]=n,r.addStream(o)}return r.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(n){var r=e.RTCPeerConnection.prototype[n];e.RTCPeerConnection.prototype[n]=function(){var e=this,n=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(e,[function(r){var i=t(e,r);n[0].apply(null,[i])},function(e){n[1]&&n[1].apply(null,e)},arguments[2]]):r.apply(e,arguments).then(function(n){return t(e,n)})}});var c=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this;return arguments.length&&arguments[0].type?(arguments[0]=n(e,arguments[0]),c.apply(e,arguments)):c.apply(e,arguments)};var u=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=this,n=u.get.apply(this);return""===n.type?n:t(e,n)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===t.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==t)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");t._streams=t._streams||{};var n;Object.keys(t._streams).forEach(function(r){t._streams[r].getTracks().find(function(t){return e.track===t})&&(n=t._streams[r])}),n&&(1===n.getTracks().length?t.removeStream(t._reverseStreams[n.id]):n.removeTrack(e.track),t.dispatchEvent(new Event("negotiationneeded")))}},shimPeerConnection:function(e){var t=a.detectBrowser(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection)e.RTCPeerConnection=function(t,n){return o("PeerConnection"),t&&t.iceTransportPolicy&&(t.iceTransports=t.iceTransportPolicy),new e.webkitRTCPeerConnection(t,n)},e.RTCPeerConnection.prototype=e.webkitRTCPeerConnection.prototype,e.webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return e.webkitRTCPeerConnection.generateCertificate}});else{var n=e.RTCPeerConnection;e.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var r=[],i=0;i0&&"function"==typeof e)return r.apply(this,arguments);if(0===r.length&&(0===arguments.length||"function"!=typeof arguments[0]))return r.apply(this,[]);var o=function(e){var t={};return e.result().forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},s=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){var c=function(e){a[1](s(o(e)))};return r.apply(this,[c,arguments[0]])}return new Promise(function(e,t){r.apply(i,[function(t){e(s(o(t)))},t])}).then(t,n)},t.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=arguments,t=this,r=new Promise(function(r,i){n.apply(t,[e[0],r,i])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}}),t.version<52&&["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var t=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,i){n.apply(e,[r,i,t])})}return n.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}});var i=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}}},function(e,t,n){"use strict";var r=n(3),i=r.log;e.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,a=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var a={};"number"==typeof r.ideal?(a[i("min",n)]=r.ideal,t.optional.push(a),a={},a[i("max",n)]=r.ideal,t.optional.push(a)):(a[i("",n)]=r.ideal,t.optional.push(a))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},o=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){var o=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),o(e.audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=a(e.audio)}if(e&&"object"==typeof e.video){var s=e.video.facingMode;s=s&&("object"==typeof s?s:{ideal:s});var c=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||c)){delete e.video.facingMode;var u;if("environment"===s.exact||"environment"===s.ideal?u=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(u=["front"]),u)return n.mediaDevices.enumerateDevices().then(function(t){t=t.filter(function(e){return"videoinput"===e.kind});var n=t.find(function(e){return u.some(function(t){return-1!==e.label.toLowerCase().indexOf(t)})});return!n&&t.length&&-1!==u.indexOf("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=s.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=a(e.video),i("chrome: "+JSON.stringify(e)),r(e)})}e.video=a(e.video)}return i("chrome: "+JSON.stringify(e)),r(e)},s=function(e){return{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.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},c=function(e,t,r){o(e,function(e){n.webkitGetUserMedia(e,t,function(e){r&&r(s(e))})})};n.getUserMedia=c;var u=function(e){return new Promise(function(t,r){n.getUserMedia(e,t,r)})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:u,enumerateDevices:function(){return new Promise(function(t){var n={audio:"audioinput",video:"videoinput"};return e.MediaStreamTrack.getSources(function(e){t(e.map(function(e){return{label:e.label,kind:n[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),n.mediaDevices.getUserMedia){var d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return o(e,function(e){return d(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(s(e))})})}}else n.mediaDevices.getUserMedia=function(e){return u(e)};void 0===n.mediaDevices.addEventListener&&(n.mediaDevices.addEventListener=function(){i("Dummy mediaDevices.addEventListener called.")}),void 0===n.mediaDevices.removeEventListener&&(n.mediaDevices.removeEventListener=function(){i("Dummy mediaDevices.removeEventListener called.")})}},function(e,t,n){"use strict";var r=n(3),i=n(62),a=n(63);e.exports={shimGetUserMedia:n(64),shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){n.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 o=a(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=i(e.iceServers)),new o(e)},e.RTCPeerConnection.prototype=o.prototype},shimReplaceTrack:function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}}},function(e,t,n){"use strict";var r=n(3);e.exports=function(e,t){var n=!1;return e=JSON.parse(JSON.stringify(e)),e.filter(function(e){if(e&&(e.urls||e.url)){var i=e.urls||e.url;e.url&&!e.urls&&r.deprecated("RTCIceServer.url","RTCIceServer.urls");var a="string"==typeof i;return a&&(i=[i]),i=i.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)}),delete e.url,e.urls=a?i[0]:i,!!i.length}})}},function(e,t,n){"use strict";function r(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type}function i(e,t,n,r,i){var a=d.writeRtpDescription(e.kind,t);if(a+=d.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=d.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":i||"active"),a+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var s="msid:"+(r?r.id:"-")+" "+o+"\r\n";a+="a="+s,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+d.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+d.localCName+"\r\n"),a}function a(e,t){var n=!1;return e=JSON.parse(JSON.stringify(e)),e.filter(function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)}),delete e.url,e.urls=i?r[0]:r,!!r.length}})}function o(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n0;o--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=d.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(p.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(p.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),p.prototype.onicecandidate=null,p.prototype.onaddstream=null,p.prototype.ontrack=null,p.prototype.onremovestream=null,p.prototype.onsignalingstatechange=null,p.prototype.oniceconnectionstatechange=null,p.prototype.onconnectionstatechange=null,p.prototype.onicegatheringstatechange=null,p.prototype.onnegotiationneeded=null,p.prototype.ondatachannel=null,p.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},p.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},p.prototype.getConfiguration=function(){return this._config},p.prototype.getLocalStreams=function(){return this.localStreams},p.prototype.getRemoteStreams=function(){return this.remoteStreams},p.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},p.prototype.addTrack=function(t,n){if(this._isClosed)throw u("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");if(this.transceivers.find(function(e){return e.track===t}))throw u("InvalidAccessError","Track already exists.");for(var r,i=0;i=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},p.prototype.removeTrack=function(t){if(this._isClosed)throw u("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find(function(e){return e.rtpSender===t});if(!n)throw u("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},p.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var n=t.getSenders().find(function(t){return t.track===e});n&&t.removeTrack(n)})},p.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},p.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},p.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},p.prototype._gather=function(t,n){var r=this,i=this.transceivers[n].iceGatherer;if(!i.onlocalcandidate){var a=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,i.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),i.onlocalcandidate=function(e){if(!(r.usingBundle&&n>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:n};var o=e.candidate,s=!o||0===Object.keys(o).length;if(s)"new"!==i.state&&"gathering"!==i.state||(i.state="completed");else{"new"===i.state&&(i.state="gathering"),o.component=1,o.ufrag=i.getLocalParameters().usernameFragment;var c=d.writeCandidate(o);a.candidate=Object.assign(a.candidate,d.parseCandidate(c)),a.candidate.candidate=c,a.candidate.toJSON=function(){return{candidate:a.candidate.candidate,sdpMid:a.candidate.sdpMid,sdpMLineIndex:a.candidate.sdpMLineIndex,usernameFragment:a.candidate.usernameFragment}}}var u=d.getMediaSections(r._localDescription.sdp);u[a.candidate.sdpMLineIndex]+=s?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",r._localDescription.sdp=d.getDescription(r._localDescription.sdp)+u.join("");var l=r.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==r.iceGatheringState&&(r.iceGatheringState="gathering",r._emitGatheringStateChange()),s||r._dispatchEvent("icecandidate",a),l&&(r._dispatchEvent("icecandidate",new Event("icecandidate")),r.iceGatheringState="complete",r._emitGatheringStateChange())}},e.setTimeout(function(){a.forEach(function(e){i.onlocalcandidate(e)})},0)}},p.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},p.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},p.prototype._transceive=function(e,n,r){var i=o(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(i.encodings=e.sendEncodingParameters,i.rtcp={cname:d.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(i.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(i)),r&&e.rtpReceiver&&i.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length?i.encodings=e.recvEncodingParameters:i.encodings=[{}],i.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(i.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(i.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(i))},p.prototype.setLocalDescription=function(e){var t=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(u("TypeError",'Unsupported type "'+e.type+'"'));if(!s("setLocalDescription",e.type,t.signalingState)||t._isClosed)return Promise.reject(u("InvalidStateError","Can not set local "+e.type+" in state "+t.signalingState));var n,r;if("offer"===e.type)n=d.splitSections(e.sdp),r=n.shift(),n.forEach(function(e,n){var r=d.parseRtpParameters(e);t.transceivers[n].localCapabilities=r}),t.transceivers.forEach(function(e,n){t._gather(e.mid,n)});else if("answer"===e.type){n=d.splitSections(t._remoteDescription.sdp),r=n.shift();var i=d.matchPrefix(r,"a=ice-lite").length>0;n.forEach(function(e,n){var a=t.transceivers[n],s=a.iceGatherer,c=a.iceTransport,u=a.dtlsTransport,l=a.localCapabilities,f=a.remoteCapabilities;if(!(d.isRejected(e)&&0===d.matchPrefix(e,"a=bundle-only").length||a.rejected)){var p=d.getIceParameters(e,r),h=d.getDtlsParameters(e,r);i&&(h.role="server"),t.usingBundle&&0!==n||(t._gather(a.mid,n),"new"===c.state&&c.start(s,p,i?"controlling":"controlled"),"new"===u.state&&u.start(h));var v=o(l,f);t._transceive(a,v.codecs.length>0,!1)}})}return t._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?t._updateSignalingState("have-local-offer"):t._updateSignalingState("stable"),Promise.resolve()},p.prototype.setRemoteDescription=function(r){var i=this;if(-1===["offer","answer"].indexOf(r.type))return Promise.reject(u("TypeError",'Unsupported type "'+r.type+'"'));if(!s("setRemoteDescription",r.type,i.signalingState)||i._isClosed)return Promise.reject(u("InvalidStateError","Can not set remote "+r.type+" in state "+i.signalingState));var a={};i.remoteStreams.forEach(function(e){a[e.id]=e});var o=[],p=d.splitSections(r.sdp),h=p.shift(),v=d.matchPrefix(h,"a=ice-lite").length>0,m=d.matchPrefix(h,"a=group:BUNDLE ").length>0;i.usingBundle=m;var _=d.matchPrefix(h,"a=ice-options:")[0];return i.canTrickleIceCandidates=!!_&&_.substr(14).split(" ").indexOf("trickle")>=0,p.forEach(function(s,u){var f=d.splitLines(s),p=d.getKind(s),_=d.isRejected(s)&&0===d.matchPrefix(s,"a=bundle-only").length,g=f[0].substr(2).split(" ")[2],y=d.getDirection(s,h),b=d.parseMsid(s),S=d.getMid(s)||d.generateIdentifier();if(_||"application"===p&&("DTLS/SCTP"===g||"UDP/DTLS/SCTP"===g))return void(i.transceivers[u]={mid:S,kind:p,protocol:g,rejected:!0});!_&&i.transceivers[u]&&i.transceivers[u].rejected&&(i.transceivers[u]=i._createTransceiver(p,!0));var k,C,P,w,T,R,I,O,E,D,M,L=d.parseRtpParameters(s);_||(D=d.getIceParameters(s,h),M=d.getDtlsParameters(s,h),M.role="client"),I=d.parseRtpEncodingParameters(s);var j=d.parseRtcpParameters(s),x=d.matchPrefix(s,"a=end-of-candidates",h).length>0,V=d.matchPrefix(s,"a=candidate:").map(function(e){return d.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===r.type||"answer"===r.type)&&!_&&m&&u>0&&i.transceivers[u]&&(i._disposeIceAndDtlsTransports(u),i.transceivers[u].iceGatherer=i.transceivers[0].iceGatherer,i.transceivers[u].iceTransport=i.transceivers[0].iceTransport,i.transceivers[u].dtlsTransport=i.transceivers[0].dtlsTransport,i.transceivers[u].rtpSender&&i.transceivers[u].rtpSender.setTransport(i.transceivers[0].dtlsTransport),i.transceivers[u].rtpReceiver&&i.transceivers[u].rtpReceiver.setTransport(i.transceivers[0].dtlsTransport)),"offer"!==r.type||_)"answer"!==r.type||_||(k=i.transceivers[u],C=k.iceGatherer,P=k.iceTransport,w=k.dtlsTransport,T=k.rtpReceiver,R=k.sendEncodingParameters,O=k.localCapabilities,i.transceivers[u].recvEncodingParameters=I,i.transceivers[u].remoteCapabilities=L,i.transceivers[u].rtcpParameters=j,V.length&&"new"===P.state&&(!v&&!x||m&&0!==u?V.forEach(function(e){c(k.iceTransport,e)}):P.setRemoteCandidates(V)),m&&0!==u||("new"===P.state&&P.start(C,D,"controlling"),"new"===w.state&&w.start(M)),i._transceive(k,"sendrecv"===y||"recvonly"===y,"sendrecv"===y||"sendonly"===y),!T||"sendrecv"!==y&&"sendonly"!==y?delete k.rtpReceiver:(E=T.track,b?(a[b.stream]||(a[b.stream]=new e.MediaStream),n(E,a[b.stream]),o.push([E,T,a[b.stream]])):(a.default||(a.default=new e.MediaStream),n(E,a.default),o.push([E,T,a.default]))));else{k=i.transceivers[u]||i._createTransceiver(p),k.mid=S,k.iceGatherer||(k.iceGatherer=i._createIceGatherer(u,m)),V.length&&"new"===k.iceTransport.state&&(!x||m&&0!==u?V.forEach(function(e){c(k.iceTransport,e)}):k.iceTransport.setRemoteCandidates(V)),O=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(O.codecs=O.codecs.filter(function(e){return"rtx"!==e.name})),R=k.sendEncodingParameters||[{ssrc:1001*(2*u+2)}];var A=!1;if("sendrecv"===y||"sendonly"===y){if(A=!k.rtpReceiver,T=k.rtpReceiver||new e.RTCRtpReceiver(k.dtlsTransport,p),A){var U;E=T.track,b&&"-"===b.stream||(b?(a[b.stream]||(a[b.stream]=new e.MediaStream,Object.defineProperty(a[b.stream],"id",{get:function(){return b.stream}})),Object.defineProperty(E,"id",{get:function(){return b.track}}),U=a[b.stream]):(a.default||(a.default=new e.MediaStream),U=a.default)),U&&(n(E,U),k.associatedRemoteMediaStreams.push(U)),o.push([E,T,U])}}else k.rtpReceiver&&k.rtpReceiver.track&&(k.associatedRemoteMediaStreams.forEach(function(e){var t=e.getTracks().find(function(e){return e.id===k.rtpReceiver.track.id});t&&l(t,e)}),k.associatedRemoteMediaStreams=[]);k.localCapabilities=O,k.remoteCapabilities=L,k.rtpReceiver=T,k.rtcpParameters=j,k.sendEncodingParameters=R,k.recvEncodingParameters=I,i._transceive(i.transceivers[u],!1,A)}}),void 0===i._dtlsRole&&(i._dtlsRole="offer"===r.type?"active":"passive"),i._remoteDescription={type:r.type,sdp:r.sdp},"offer"===r.type?i._updateSignalingState("have-remote-offer"):i._updateSignalingState("stable"),Object.keys(a).forEach(function(t){var n=a[t];if(n.getTracks().length){if(-1===i.remoteStreams.indexOf(n)){i.remoteStreams.push(n);var r=new Event("addstream");r.stream=n,e.setTimeout(function(){i._dispatchEvent("addstream",r)})}o.forEach(function(e){var t=e[0],r=e[1];n.id===e[2].id&&f(i,t,r,[n])})}}),o.forEach(function(e){e[2]||f(i,e[0],e[1],[])}),e.setTimeout(function(){i&&i.transceivers&&i.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},p.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")},p.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},p.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},p.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++}),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},p.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},p.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(u("InvalidStateError","Can not call createOffer after close"));var r=n.transceivers.filter(function(e){return"audio"===e.kind}).length,a=n.transceivers.filter(function(e){return"video"===e.kind}).length,o=arguments[0];if(o){if(o.mandatory||o.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==o.offerToReceiveAudio&&(r=!0===o.offerToReceiveAudio?1:!1===o.offerToReceiveAudio?0:o.offerToReceiveAudio),void 0!==o.offerToReceiveVideo&&(a=!0===o.offerToReceiveVideo?1:!1===o.offerToReceiveVideo?0:o.offerToReceiveVideo)}for(n.transceivers.forEach(function(e){"audio"===e.kind?--r<0&&(e.wantReceive=!1):"video"===e.kind&&--a<0&&(e.wantReceive=!1)});r>0||a>0;)r>0&&(n._createTransceiver("audio"),r--),a>0&&(n._createTransceiver("video"),a--);var s=d.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach(function(r,i){var a=r.track,o=r.kind,s=r.mid||d.generateIdentifier();r.mid=s,r.iceGatherer||(r.iceGatherer=n._createIceGatherer(i,n.usingBundle));var c=e.RTCRtpSender.getCapabilities(o);t<15019&&(c.codecs=c.codecs.filter(function(e){return"rtx"!==e.name})),c.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),r.remoteCapabilities&&r.remoteCapabilities.codecs&&r.remoteCapabilities.codecs.forEach(function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)})}),c.headerExtensions.forEach(function(e){(r.remoteCapabilities&&r.remoteCapabilities.headerExtensions||[]).forEach(function(t){e.uri===t.uri&&(e.id=t.id)})});var u=r.sendEncodingParameters||[{ssrc:1001*(2*i+1)}];a&&t>=15019&&"video"===o&&!u[0].rtx&&(u[0].rtx={ssrc:u[0].ssrc+1}),r.wantReceive&&(r.rtpReceiver=new e.RTCRtpReceiver(r.dtlsTransport,o)),r.localCapabilities=c,r.sendEncodingParameters=u}),"max-compat"!==n._config.bundlePolicy&&(s+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),s+="a=ice-options:trickle\r\n",n.transceivers.forEach(function(e,t){s+=i(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),s+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,s+="a="+d.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(s+="a=end-of-candidates\r\n"))});var c=new e.RTCSessionDescription({type:"offer",sdp:s});return Promise.resolve(c)},p.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(u("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(u("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var r=d.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(r+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n");var a=d.getMediaSections(n._remoteDescription.sdp).length;n.transceivers.forEach(function(e,s){if(!(s+1>a)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?r+="m=application 0 DTLS/SCTP 5000\r\n":r+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?r+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(r+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(r+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");if(e.stream){var c;"audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1})}var u=o(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,r+=i(e,u,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(r+="a=rtcp-rsize\r\n")}});var s=new e.RTCSessionDescription({type:"answer",sdp:r});return Promise.resolve(s)},p.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(r,i){if(!n._remoteDescription)return i(u("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var a=e.sdpMLineIndex;if(e.sdpMid)for(var o=0;o0?d.parseCandidate(e.candidate):{};if("tcp"===l.protocol&&(0===l.port||9===l.port))return r();if(l.component&&1!==l.component)return r();if((0===a||a>0&&s.iceTransport!==n.transceivers[0].iceTransport)&&!c(s.iceTransport,l))return i(u("OperationError","Can not add ICE candidate"));var f=e.candidate.trim();0===f.indexOf("a=")&&(f=f.substr(2)),t=d.getMediaSections(n._remoteDescription.sdp),t[a]+="a="+(l.type?f:"end-of-candidates")+"\r\n",n._remoteDescription.sdp=d.getDescription(n._remoteDescription.sdp)+t.join("")}else for(var p=0;p55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var l=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},f=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==typeof e&&"object"==typeof e.audio&&(e=JSON.parse(JSON.stringify(e)),l(e.audio,"autoGainControl","mozAutoGainControl"),l(e.audio,"noiseSuppression","mozNoiseSuppression")),f(e)},a&&a.prototype.getSettings){var p=a.prototype.getSettings;a.prototype.getSettings=function(){var e=p.apply(this,arguments);return l(e,"mozAutoGainControl","autoGainControl"),l(e,"mozNoiseSuppression","noiseSuppression"),e}}if(a&&a.prototype.applyConstraints){var h=a.prototype.applyConstraints;a.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==typeof e&&(e=JSON.parse(JSON.stringify(e)),l(e,"autoGainControl","mozAutoGainControl"),l(e,"noiseSuppression","mozNoiseSuppression")),h.apply(this,[e])}}}n.getUserMedia=function(e,i,a){if(t.version<44)return s(e,i,a);r.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(i,a)}}},function(e,t,n){"use strict";var r=n(3);e.exports={shimLocalStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),"getStreamById"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getStreamById=function(e){var t=null;return this._localStreams&&this._localStreams.forEach(function(n){n.id===e&&(t=n)}),this._remoteStreams&&this._remoteStreams.forEach(function(n){n.id===e&&(t=n)}),t}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),-1===this._localStreams.indexOf(e)&&this._localStreams.push(e);var n=this;e.getTracks().forEach(function(r){t.call(n,r,e)})},e.RTCPeerConnection.prototype.addTrack=function(e,n){return n&&(this._localStreams?-1===this._localStreams.indexOf(n)&&this._localStreams.push(n):this._localStreams=[n]),t.call(this,e,n)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);var t=this._localStreams.indexOf(e);if(-1!==t){this._localStreams.splice(t,1);var n=this,r=e.getTracks();this.getSenders().forEach(function(e){-1!==r.indexOf(e.track)&&n.removeTrack(e)})}})}},shimRemoteStreamsAPI:function(e){"object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),"onaddstream"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=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){if(t._remoteStreams||(t._remoteStreams=[]),!(t._remoteStreams.indexOf(e)>=0)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}})})}}))},shimCallbacksAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,a=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};var s=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){var r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}},shimGetUserMedia:function(e){var t=e&&e.navigator;t.getUserMedia||(t.webkitGetUserMedia?t.getUserMedia=t.webkitGetUserMedia.bind(t):t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t)))},shimRTCIceServerUrls:function(e){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var i=[],a=0;a0?i=parseInt(a[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(i=2147483637),i},c=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;if(e._sctp=null,n(arguments[0])){var t,r=a(arguments[0]),i=o(r),u=s(arguments[0],r);t=0===i&&0===u?Number.POSITIVE_INFINITY:0===i||0===u?Math.max(i,u):Math.min(i,u);var d={};Object.defineProperty(d,"maxMessageSize",{get:function(){return t}}),e._sctp=d}return c.apply(e,arguments)}}},shimSendThrowTypeError:function(e){function t(e,t){var n=e.send;e.send=function(){var r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=this,r=n.apply(e,arguments);return t(r,e),r},i.wrapPeerConnectionEvent(e,"datachannel",function(e){return t(e.channel,e.target),e})}}}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n