gh-camp-video-portal/public/lib/aliyun-webrtc-sdk-1.9.1.min.js

2 lines
226 KiB
JavaScript

/*! 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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,null,[{key:"_getSystemInfo",value:function(){if(!e._systemName||!e._systemVersion)if(navigator&&navigator.userAgent){var t=navigator.userAgent.toLowerCase();t.indexOf("ipad")>-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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,null,[{key:"_getBrowserInfo",value:function(){if(!e._browserName||!e._browserVersion)if(navigator&&navigator.userAgent){var t=navigator.userAgent.toLowerCase(),n={},r=void 0;(r=t.match(/firefox\/([\d.]+)/))?n.firefox=r[1]:(r=t.match(/chrome\/([\d.]+)/))?n.chrome=r[1]:(r=t.match(/version\/([\d.]+).*safari/))&&(n.safari=r[1]),n.safari?(e._browserName="Safari",e._browserVersion=n.safari):n.firefox?(e._browserName="Firefox",e._browserVersion=n.firefox):n.chrome?(e._browserName="Chrome",e._browserVersion=n.chrome):(e._browserName="unknown",e._browserVersion="0.0")}else e._browserName="unknown",e._browserVersion="0.0"}},{key:"isBrowser",get:function(){return"undefined"!=typeof document}},{key:"domain",get:function(){return window.location.protocol+window.location.host}},{key:"isHttps",get:function(){return!(!this.isBrowser||!document.location||"https:"!=document.location.protocol)}},{key:"isChrome",get:function(){return"Chrome"===e.browserName}},{key:"isSafari",get:function(){return"Safari"===e.browserName}},{key:"isFirefox",get:function(){return"Firefox"===e.browserName}},{key:"browserName",get:function(){return e._getBrowserInfo(),e._browserName}},{key:"browserVersion",get:function(){return e._getBrowserInfo(),e._browserVersion}},{key:"browserMainVersion",get:function(){return e._getBrowserInfo(),e._browserVersion?parseInt(e._browserVersion.split(".")[0]):0}}]),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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(0),s=r(o),c=n(1),u=r(c),d=n(12),l=r(d),f=n(14),p=r(f),h=function(){function e(){i(this,e)}return a(e,null,[{key:"init",value:function(t){e._initParam(),e._param.apid=t.appid,e._param.usrid=t.userId,e._param.sessionId=t.sessionId,e._param.channelid=t.channel,e._param.usrn=t.userName}},{key:"reportJoinRoom",value:function(t,n,r,i,a){e._log({evetid:10010,args:JSON.stringify({joitm:t,rslt:n,tid:r,gslbtm:i,gslbrst:JSON.stringify(a)})})}},{key:"reportLeaveRoom",value:function(t,n,r){e._log({evetid:10020,args:JSON.stringify({lvetm:t,rslt:n,tid:r})})}},{key:"reportPublish",value:function(t,n,r,i,a,o,s,c,u){e._log({evetid:10030,args:JSON.stringify({calid:t,isvl:n,isvss:r,isaudio:i,hgt:o,wdth:a,rslt:s,tid:c,pubtm:u})})}},{key:"reportPublishStart",value:function(t,n,r){e._log({evetid:10031,args:JSON.stringify({callid:calid,fpst:n,tckid:r})})}},{key:"reportRepublish",value:function(t,n,r,i,a,o,s,c,u){e._log({evetid:10032,args:JSON.stringify({calid:t,isvl:n,isvss:r,isaudio:i,hgt:o,wdth:a,rslt:s,tid:c,pubtm:u})})}},{key:"reportUnpublish",value:function(t,n,r,i){e._log({evetid:10040,args:JSON.stringify({calid:t,unpubtm:n,rslt:r,tid:i})})}},{key:"reportSubscribe",value:function(t,n,r,i,a,o,s,c,u){e._log({evetid:10050,args:JSON.stringify({calid:t,rmtid:n,isvl:r,isvs:i,isvss:a,isaudio:o,rslt:s,tid:c,subtm:u})})}},{key:"reportResubscribe",value:function(t,n,r,i,a,o,s,c,u){e._log({evetid:10053,args:JSON.stringify({calid:t,rmtid:n,isvl:r,isvs:i,isvss:a,isaudio:o,rslt:s,tid:c,resubtm:u})})}},{key:"reportUnsubscribe",value:function(t,n,r,i,a){e._log({evetid:10060,args:JSON.stringify({calid:t,rmtid:n,unsubtm:r,rslt:i,tid:a})})}},{key:"reportPublishStatus",value:function(t,n,r,i,a,o,s,c,u,d,l,f,p,h,v,m,_){e._log({evetid:10070,args:JSON.stringify({rtt:t,calid:n,raddr:r,vlsrc:i,asrc:a,isaudio:o,isvl:s,vlsfps:c,asb:u,teb:d,vlrn:l,vcodc:f,acodc:p,vlsw:h,vlsh:v,vlps:m,aps:_})})}},{key:"reportSubscribeStatus",value:function(t,n,r,i,a,o,s,c,u,d,l,f,p,h,v,m,_,g,y,b,S,k,C){e._log({evetid:10080,args:JSON.stringify({rtt:t,calid:n,raddr:r,vsrc:i,vsssrc:a,asrc:o,isaudio:s,isv:c,isvss:u,vrplr:d,vssrplr:l,arlr:f,vofps:p,vssofps:h,vdcode:v,adcode:m,arb:_,vns:g,vssns:y,vps:b,vssps:S,vpr:k,vsspr:C})})}},{key:"reportMonitor",value:function(t){e._log({evetid:10090,args:JSON.stringify(t)})}},{key:"reportStartPreview",value:function(t,n,r){e._log({evetid:20010,dt:t,rslt:n,descb:r})}},{key:"reportStopPreview",value:function(t){e._log({evetid:20020,rslt:t})}},{key:"reportSupportInfo",value:function(t){e._log({evetid:20030,rslt:t?JSON.stringify(t):t})}},{key:"reportSetDisplayRemoteVideo",value:function(t,n,r){e._log({evetid:20040,rslt:n,descb:r})}},{key:"reportGetDevice",value:function(t){e._log({evetid:20050,rslt:t?JSON.stringify(t):t})}},{key:"reportMuteLocalCamera",value:function(t){e._log({evetid:20060,mt:t})}},{key:"reportMuteLocalMic",value:function(t){e._log({evetid:20070,mt:t})}},{key:"_log",value:function(t){e._initParam();var n={};for(var r in e._param)n[r]=e._param[r];for(var i in t)n[i]=t[i];n.tm=(new Date).getTime();var a=[];for(var o in n)a.push(o+"="+n[o]);var s=a.join("&");new Image(0,0).src="https://ali-rtc-sz.cn-shenzhen.log.aliyuncs.com/logstores/client-test/track?"+s}},{key:"_initParam",value:function(){e._param||(e._param={statsvrs:"0.1.0",APIVersion:"0.6.0",osn:s.default.systemName,osv:s.default.systemVersion,udid:l.default.uuid,sdkv:p.default.version,dm:u.default.domain,bt:u.default.browserName})}}]),e}();t.default=h},function(e,t,n){"use strict";function r(e,t,n){var r=e.match(t);return r&&r.length>=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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,null,[{key:"postBody",value:function(t,n,r){t=e._getUrl(t,n);var i={};i.headers||(i.headers={}),i.headers.Accept="application/json",i.headers["Content-Type"]="application/json";var a="";return new Promise(function(n,i){e.requestBody("POST",t,r).then(function(e){return a=e,e.ok?e.json():e.text()}).then(function(t){a.ok?t.code?(t=e._intercept(t),i(t)):n(t.data):i(e._httpErrorMessage(a,t))}).catch(function(t){t=e._httpErrorMessage(t),i(t)})})}},{key:"get",value:function(t,n){var r=arguments.length>2&&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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a={Login:"/app/v1/login",Gslb:"/gslb/v1/allocate",STSRefresh:"/gslb/v1/stsupdate",Auth:"/auth/v1/token",Create:"/signaling/v1/create",Join:"/signaling/v1/join",Leave:"/signaling/v1/leave",Publish:"/signaling/v1/publish",Republish:"/signaling/v1/republish",UnPublish:"/signaling/v1/unpublish",ICECandidate:"/signaling/v1/icecandidate",Subscribe:"/signaling/v1/subscribe",ReSubscribe:"/signaling/v1/resubscribe",UnSubscribe:"/signaling/v1/unsubscribe",Answer:"/signaling/v1/answer",Polling:"/signaling/v1/polling",PollingResponse:"/signaling/v1/response"},o=function(){function e(){r(this,e)}return i(e,null,[{key:"Init",value:function(t,n){t&&t.length?e._availableSlb=t[0]:e._availableSlb="",n&&n.length?e._availableServer=n[0]:e._availableServer=""}},{key:"GslbUrl",value:function(e){return e&&e.length?e[0]+a.Gslb:""}},{key:"serverUrl",get:function(){return e._availableServer}},{key:"AnswerUrl",get:function(){return e._availableSlb+a.Answer}},{key:"UnSubscribeUrl",get:function(){return e._availableSlb+a.UnSubscribe}},{key:"ReSubscribeUrl",get:function(){return e._availableSlb+a.ReSubscribe}},{key:"SubscribeUrl",get:function(){return e._availableSlb+a.Subscribe}},{key:"UnPublishUrl",get:function(){return e._availableSlb+a.UnPublish}},{key:"PublishUrl",get:function(){return e._availableSlb+a.Publish}},{key:"RepublishUrl",get:function(){return e._availableSlb+a.Republish}},{key:"ICECandidateUrl",get:function(){return e._availableSlb+a.ICECandidate}},{key:"PollingResponseUrl",get:function(){return e._availableSlb+a.PollingResponse}},{key:"PollingUrl",get:function(){return e._availableSlb+a.Polling}},{key:"LeaveUrl",get:function(){return e._availableSlb+a.Leave}},{key:"JoinUrl",get:function(){return e._availableSlb+a.Join}},{key:"AuthUrl",get:function(){return e._availableSlb+a.Auth}}]),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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(0),o=(function(e){e&&e.__esModule}(a),function(){function e(){r(this,e)}return i(e,null,[{key:"mergeConstraints",value:function(e,t){if(!e||!t)return e||t;var n=e;for(var r in t)n[r]=t[r];return n}},{key:"iceCandidateType",value:function(e){return e.split(" ")[7]}},{key:"matchSDP",value:function(t,n){var r=[];return e._matchSdp(r,t,!0),e._matchSdp(r,n,!1),r}},{key:"_matchSdp",value:function(t,n,r){var i=n.split("\r\n"),a=e.findLine(i,"m=","video");if(null!==a)for(;a>0&&a<i.length;)a=e._getVideoName(i,a,t,r)}},{key:"_getVideoName",value:function(t,n,r,i){var a=e.findLineInRange(t,n+1,-1,"m=video");null===a&&(a=t.length);var o=e.findLineInRange(t,n,a,"a=mid:");if(null!==o){var s=t[o].replace("a=mid:","");for(o=e.findLineInRange(t,n,a,"a=ssrc");o>0&&o<t.length&&t[o].indexOf("a=ssrc")>=0;){var c=t[o].indexOf("label:");if(c>0){for(var u=!1,d=0;d<r.length;++d)if(r[d].key===s){i?r[d].label=t[o].substring(c+6,t[o].length):r[d].cname=t[o].substring(c+6,t[o].length),u=!0;break}u||(i?r.push({key:s,label:t[o].substring(c+6,t[o].length)}):r.push({key:s,cname:t[o].substring(c+6,t[o].length)}));break}if(!i&&(c=t[o].indexOf("cname:"))>0){for(var l=!1,f=0;f<r.length;++f)if(r[f].key===s){i?r[f].label=t[o].substring(c+6,t[o].length):r[f].cname=t[o].substring(c+6,t[o].length),l=!0;break}l||(i?r.push({key:s,label:t[o].substring(c+6,t[o].length)}):r.push({key:s,cname:t[o].substring(c+6,t[o].length)}));break}++o}}return a+1}},{key:"completionSDPSSRC",value:function(t){var n=t.split("\r\n"),r=e.findLine(n,"m=","audio");if(null===r)return t;var i=e.findLineInRange(n,r+1,-1,"m=");return null===i&&(i=n.length),i+=e._completionSSRC(n,r,i),r=i,i=e.findLineInRange(n,r+1,-1,"m="),null===i&&(i=n.length),e._completionSSRC(n,r,i),n.join("\r\n")}},{key:"_completionSSRC",value:function(t,n,r){var i="",a=e.findLineInRange(t,n+1,r,"a=msid");if(!a)return 0;i=t[a].substring(2,t[a].length);var o=!1,s=!1,c=!1,u="",d=0;if((a=e.findLineInRange(t,n+1,r,"a=ssrc"))>-1){u=t[a].split(" ")[0]+" ";for(var l=a;l<r&&t[l].indexOf("a=ssrc")>-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;n<e.length;++n)e[n]===t.toString()&&e.splice(n,1);return e.join(" ")}},{key:"removeCodecByName",value:function(t,n){var r=e.findLine(t,"a=rtpmap",n);if(null===r)return t;var i=e.getCodecPayloadTypeFromLine(t[r]);t.splice(r,1);var a=e.findLine(t,"m=","video");return null===a?t:(t[a]=e.removePayloadTypeFromMline(t[a],i),t)}},{key:"removeCodecByPayloadType",value:function(t,n){var r=e.findLine(t,"a=rtpmap",n.toString());if(null===r)return t;t.splice(r,1);var i=e.findLine(t,"m=","video");return null===i?t:(t[i]=e.removePayloadTypeFromMline(t[i],n),t)}},{key:"maybeRemoveVideoFec",value:function(t,n){if("false"!==n.videoFec)return t;var r=t.split("\r\n"),i=e.findLine(r,"a=rtpmap","red");if(null===i)return t;var a=e.getCodecPayloadTypeFromLine(r[i]);if(r=e.removeCodecByPayloadType(r,a),r=e.removeCodecByName(r,"ulpfec"),null===(i=e.findLine(r,"a=fmtp",a.toString())))return t;var o=e.parseFmtpLine(r[i]),s=o.pt;return null===s?t:(r.splice(i,1),r=e.removeCodecByPayloadType(r,s),r.join("\r\n"))}},{key:"maybePreferAudioSendCodec",value:function(t,n){return e.maybePreferCodec(t,"audio","send",n.audioSendCodec)}},{key:"maybePreferAudioReceiveCodec",value:function(t,n){return e.maybePreferCodec(t,"audio","receive",n.audioRecvCodec)}},{key:"maybePreferVideoSendCodec",value:function(t,n){return e.maybePreferCodec(t,"video","send",n.videoSendCodec)}},{key:"maybePreferVideoReceiveCodec",value:function(t,n){return e.maybePreferCodec(t,"video","receive",n.videoRecvCodec)}},{key:"maybePreferCodec",value:function(t,n,r,i){if(!i)return t;var a=t.split("\r\n"),o=e.findLine(a,"m=",n);if(null===o)return t;var s=e.getCodecPayloadType(a,i);return s&&(a[o]=e.setDefaultCodec(a[o],s)),t=a.join("\r\n")}},{key:"setCodecParam",value:function(t,n,r,i){var a=t.split("\r\n"),o=e.findFmtpLine(a,n),s={};if(null===o){var c=e.findLine(a,"a=rtpmap",n);if(null===c)return t;var u=e.getCodecPayloadTypeFromLine(a[c]);s.pt=u.toString(),s.params={},s.params[r]=i,a.splice(c+1,0,e.writeFmtpLine(s))}else s=e.parseFmtpLine(a[o]),s.params[r]=i,a[o]=e.writeFmtpLine(s);return t=a.join("\r\n")}},{key:"removeCodecParam",value:function(t,n,r){var i=t.split("\r\n"),a=e.findFmtpLine(i,n);if(null===a)return t;var o=e.parseFmtpLine(i[a]);delete o.params[r];var s=e.writeFmtpLine(o);return null===s?i.splice(a,1):i[a]=s,t=i.join("\r\n")}},{key:"parseFmtpLine",value:function(e){var t={},n=e.indexOf(" "),r=e.substring(n+1).split(";"),i=new RegExp("a=fmtp:(\\d+)"),a=e.match(i);if(!a||2!==a.length)return null;t.pt=a[1];for(var o={},s=0;s<r.length;++s){var c=r[s].split("=");2===c.length&&(o[c[0]]=c[1])}return t.params=o,t}},{key:"writeFmtpLine",value:function(e){if(!e.hasOwnProperty("pt")||!e.hasOwnProperty("params"))return null;var t=e.pt,n=e.params,r=[],i=0;for(var a in n)r[i]=a+"="+n[a],++i;return 0===i?null:"a=fmtp:"+t.toString()+" "+r.join(";")}},{key:"findFmtpLine",value:function(t,n){var r=e.getCodecPayloadType(t,n);return r?e.findLine(t,"a=fmtp:"+r.toString()):null}},{key:"findLine",value:function(t,n,r){return e.findLineInRange(t,0,-1,n,r)}},{key:"findLineInRange",value:function(e,t,n,r,i){for(var a=-1!==n?n:e.length,o=t;o<a;++o)if(0===e[o].indexOf(r)&&(!i||-1!==e[o].toLowerCase().indexOf(i.toLowerCase())))return o;return null}},{key:"getCodecPayloadType",value:function(t,n){var r=e.findLine(t,"a=rtpmap",n);return r?e.getCodecPayloadTypeFromLine(t[r]):null}},{key:"getCodecPayloadTypeFromLine",value:function(e){var t=new RegExp("a=rtpmap:(\\d+) [a-zA-Z0-9-]+\\/\\d+"),n=e.match(t);return n&&2===n.length?n[1]:null}},{key:"setDefaultCodec",value:function(e,t){var n=e.split(" "),r=n.slice(0,3);r.push(t);for(var i=3;i<n.length;i++)n[i]!==t&&r.push(n[i]);return r.join(" ")}},{key:"hasH264",value:function(e){return-1==e.indexOf("mid:video")||(e.indexOf("H264")>0||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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(1),o=function(e){return e&&e.__esModule?e:{default:e}}(a),s=function(){function e(){r(this,e)}return i(e,null,[{key:"random",value:function(e){for(var t="";t.length<e;)t+=Math.random().toString(36).replace(/[^a-zA-Z0-9]+/g,"").substr(0,e);return t.substr(0,e)}},{key:"getUrlVars",value:function(){for(var e=[],t=void 0,n=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),r=0;r<n.length;r++)t=n[r].split("="),e.push(t[0]),e[t[0]]=t[1];return e}},{key:"getUrlVar",value:function(t){return e.getUrlVars()[t]}},{key:"trace",value:function(e){if("\n"===e[e.length-1]&&(e=e.substring(0,e.length-1)),window.performance){(window.performance.now()/1e3).toFixed(3)}}}]),e}();s.prefixAPI=function(e){if(!o.default.isBrowser)return e;var t=[];for(var n in e){var r=e[n];if(r&&void 0!==r.indexOf){var i=document.createElement("a");i.href=window.location.href,i.search=i.hash="",-1==r.indexOf(":")?i.host=i.hostname+":"+r:-1==r.indexOf("://")?i.host=r:i.href=r;var a=i.protocol+"//"+i.host;t.push(a)}}return t},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")}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=n(18),s=function(e){return e&&e.__esModule?e:{default:e}}(o),c=function(e){function t(){r(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._resolutionArr=[{width:1280,height:720},{width:960,height:540},{width:640,height:480},{width:320,height:240}],e}return a(t,e),t}(s.default);t.default=c},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=n(19),s=function(e){return e&&e.__esModule?e:{default:e}}(o),c=function(e){function t(e,n,a){r(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o._signaling=a,o._authInfo=e,o._channelInfo=n,o}return a(t,e),t}(s.default);t.default=c},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(7),s=r(o),c=n(1),u=r(c),d=function(){function e(t,n,r,a,o){i(this,e),this._userId=t,this._streamConfig=[],this._authInfo=r,this._displayName=n,this._dispatcher=a,this._signalingListener=o,this._pcMonitor=null,this._params=null,this._conn=null}return a(e,[{key:"getUserInfo",value:function(){var e={userId:this._userId,displayName:this._displayName,streamConfigs:[]};return Object.assign(e.streamConfigs,this._streamConfig),e}},{key:"getMonitorData",value:function(){return this._pcMonitor&&this._pcMonitor.getMonitorData(),null}},{key:"clear",value:function(){this._conn&&(this._conn.onremovestream=function(){},this._conn.oniceconnectionstatechange=function(){},this._conn.onsignalingstatechange=function(){},this._conn.onicegatheringstatechange=function(){}),this._conn&&(this._conn.close(),this._conn=null),this._pcMonitor&&this._pcMonitor.releaseMonitor()}},{key:"_createPeerConnection",value:function(e){this._params={peerConnectionConfig:{iceServers:[{urls:e.iceServers,username:e.username,credential:e.credential}],iceTransportPolicy:"relay",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceCandidatePoolSize:0}};var t=this._params.peerConnectionConfig,n=void 0;try{if(u.default.isFirefox){n={sdpSemantics:"unified-plan",iceTransportPolicy:"relay",iceServers:[]};for(var r=t.iceServers[0].urls,i=0;i<r.length;++i)n.iceServers.push({username:t.iceServers[0].username,credential:t.iceServers[0].credential,urls:r[i]})}else n={iceServers:t.iceServers,iceTransportPolicy:"relay"};this._conn=new RTCPeerConnection(n)}catch(e){}}},{key:"_filterIceCandidate",value:function(e){var t=e.candidate;return-1===t.indexOf("tcp")&&("relay"!==this._params.peerConnectionConfig.iceTransports||"relay"===s.default.iceCandidateType(t))}},{key:"_setRemoteDescription",value:function(e){return e.sdp=s.default.replace42e01fTo42001f(e.sdp),e.sdp=s.default.maybeSetOpusOptions(e.sdp,this._params),e.sdp=s.default.maybePreferAudioSendCodec(e.sdp,this._params),e.sdp=s.default.maybePreferVideoSendCodec(e.sdp,this._params),e.sdp=s.default.maybeSetAudioSendBitRate(e.sdp,this._params),e.sdp=s.default.maybeSetVideoSendBitRate(e.sdp,this._params),e.sdp=s.default.maybeSetVideoSendInitialBitRate(e.sdp,this._params),e.sdp=s.default.maybeRemoveVideoFec(e.sdp,this._params),this._conn.setRemoteDescription(new RTCSessionDescription(e))}},{key:"_setLocalDescription",value:function(e){var t=this;return e.sdp=s.default.replace42e01fTo42001f(e.sdp),e.sdp=s.default.maybePreferAudioReceiveCodec(e.sdp,this._params),e.sdp=s.default.maybePreferVideoReceiveCodec(e.sdp,this._params),e.sdp=s.default.maybeSetAudioReceiveBitRate(e.sdp,this._params),e.sdp=s.default.maybeSetVideoReceiveBitRate(e.sdp,this._params),e.sdp=s.default.maybeRemoveVideoFec(e.sdp,this._params),new Promise(function(n,r){s.default.hasH264(e.sdp)||r({message:"Does not support webrtc, because device can not support h264"}),t._conn.setLocalDescription(e).then(function(){n()}).catch(function(e){r(e)})})}},{key:"userId",get:function(){return this._userId}},{key:"displayName",get:function(){return this._displayName}},{key:"conn",get:function(){return this._conn}},{key:"streamConfig",get:function(){return this._streamConfig},set:function(e){this._streamConfig=e}},{key:"isConnecting",get:function(){return null!=this._conn}}]),e}();t.default=d},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(13),o=function(e){return e&&e.__esModule?e:{default:e}}(a),s=function(){function e(){r(this,e)}return i(e,null,[{key:"get",value:function(e){for(var t=e+"",n=document.cookie.split(";"),r=0;r<n.length;r++){var i=n[r].trim();if(0==i.indexOf(t))return unescape(i.substring(t.length+1,i.length))}return""}},{key:"set",value:function(e,t,n){var r=new Date;r.setTime(r.getTime()+24*n*60*60*1e3);var i="expires="+r.toGMTString();document.cookie=e+"="+escape(t)+"; "+i}},{key:"uuid",get:function(){var t=e.get("rtc_uuid");return t||(t=o.default.create(32),e.set("rtc_uuid",t,365)),t}}]),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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,null,[{key:"create",value:function(e,t){var n,r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[];if(t=t||r.length,e)for(n=0;n<e;n++)i[n]=r[0|Math.random()*t];else{var a;for(i[8]=i[13]=i[18]=i[23]="-",i[14]="4",n=0;n<36;n++)i[n]||(a=0|16*Math.random(),i[n]=r[19==n?3&a|8:a])}return i.join("")}}]),e}();t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={evn:"prod",version:"1.9.0"};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")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(1),s=(r(o),n(0)),c=(r(s),function(){function e(t){i(this,e),this._peerConnection=t,this._timerId=0,this._interval=1e3}return a(e,[{key:"getMonitorData",value:function(){return null}},{key:"startMonitor",value:function(){var e=arguments.length>0&&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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(18),u=r(c),d=n(2),l=(r(d),function(e){function t(){i(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._resolutionArr=[{width:1080,height:720},{width:720,height:480},{width:640,height:480},{width:640,height:360},{width:320,height:240}],e._videoProfile={width:640,height:480},e}return o(t,e),s(t,[{key:"_setVideoElementAttribute",value:function(e){this._localVideoElement&&(this._localVideoElement.setAttribute("playsinline",""),this._localVideoElement.setAttribute("autoplay",""),this._localVideoElement.srcObject=e)}}]),t}(u.default));t.default=l},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(2),o=function(e){return e&&e.__esModule?e:{default:e}}(a),s=function(){function e(){r(this,e),this._resoluting=!1,this._defaultAudio=!0,this._localVideoElement=null,this._publishStream=null,this._preViewStream=null,this._resolutionArr=[{width:1280,height:720},{width:640,height:480},{width:320,height:240}],this._cameraInfo={video:!0},this._audioInfo={audio:!0},this._configLocalCameraPublish=!0,this._configLocalScreenPublish=!1,this._configLocalAudioPublish=!0,this._videoProfile={width:640,height:480,frameRate:15},this._audioProfile={}}return i(e,[{key:"getPreViewStream",value:function(e){var t=this;return new Promise(function(n,r){if(t._preViewStream)return t._localVideoElement=e,t._setVideoElementAttribute(t._preViewStream),void n();t.releasePreviewStream(),t._localVideoElement=e,t._setVideoElementAttribute(null),t._getMediaStream(!0).then(function(e){t._preViewStream=e,t._localVideoElement&&(t._localVideoElement.srcObject=e),n()}).catch(function(e){t._handleError(e),r(e)})})}},{key:"getPublishStream",value:function(e){var t=this;return new Promise(function(e,n){t._publishStream?e(t._publishStream):t._getMediaStream(!1).then(function(n){n.getAudioTracks()[0].enabled=t._configLocalAudioPublish,n.getVideoTracks()[0].enabled=t._configLocalCameraPublish,t._publishStream=n,e(n)}).catch(function(e){n(e)})})}},{key:"releasePreviewStream",value:function(){this._releaseLocalVideoElement(),this._releasePreviewStream()}},{key:"releasePublishStream",value:function(){this._publishStream&&this._publishStream.getTracks().forEach(function(e){e.stop()}),this._publishStream=null}},{key:"muteLocalMic",value:function(e){if(this._publishStream){var t=this._publishStream.getAudioTracks();if(t.length){for(var n=0;n<t.length;++n)t[n].enabled=!e;return!0}}return!1}},{key:"muteLocalCamera",value:function(e){if(this._publishStream){var t=this._publishStream.getVideoTracks();if(t.length){for(var n=0;n<t.length;++n)t[n].enabled=!e;return!0}}return!1}},{key:"getDevices",value:function(){return new Promise(function(e,t){navigator.mediaDevices.enumerateDevices().then(function(t){var n=[],r=[];t.forEach(function(e){"audioinput"==e.kind?r.push(e):"videoinput"==e.kind&&n.push(e)});var i={videoDevices:n,audioDevices:r};o.default.reportGetDevice(i),e(i)}).catch(function(e){o.default.reportGetDevice(e),t(e)})})}},{key:"getAvailableResolutions",value:function(e){var t=this;return new Promise(function(n,r){if(t._resoluting)return void r({message:"请不要频繁操作"});t._resoluting=!0;var i="";"user"===e||"environment"===e?(i=e,e="",t._getResolution(e,i).then(function(e){t._resoluting=!1,n(e)}).catch(function(e){t._resoluting=!1,r(e)})):e?t.getDevices().then(function(a){for(var o=a.videoDevices,s=!1,c=0;c<o.length;++c)if(o[c].deviceId==e){s=!0;break}s?t._getResolution(e,i).then(function(e){t._resoluting=!1,n(e)}).catch(function(e){t._resoluting=!1,r(e)}):r({message:"请重新打开页面或刷新页面"})}).catch(function(e){r(e)}):t._getResolution(e,i).then(function(e){t._resoluting=!1,n(e)}).catch(function(e){t._resoluting=!1,r(e)})})}},{key:"getUserMedia",value:function(e){var t=this;arguments.length>1&&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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e),this._eventListener={}}return i(e,[{key:"has",value:function(e){return!!this._eventListener[e]}},{key:"hasEventListener",value:function(e,t,n){return!(!this._checkFunction(t)||void 0===this._eventListener[e]||-1===this._eventListener[e].indexOf(t))}},{key:"addEventListener",value:function(e,t,n){var r=arguments.length>3&&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<i.length;++a)if(i[a].func===t&&i[a].context===n)return!1;return this._eventListener[e].push({func:t,context:n,once:r}),!0}return!1}},{key:"removeEventListener",value:function(e,t,n){if(this._checkFunction(t)&&void 0!==this._eventListener[e])for(var r=this._eventListener[e],i=0;i<r.length;++i)if(r[i].func===t&&n===r[i].context)return void r.splice(i,1)}},{key:"dispatchEvent",value:function(){var e=Array.prototype.slice.call(arguments),t=e.shift();if(t&&void 0!==this._eventListener[t]&&this._eventListener[t].length)for(var n=this._eventListener[t],r=n.length-1;r>=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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(2),s=r(o),c=n(54),u=r(c),d=function(){function e(){i(this,e)}return a(e,null,[{key:"isSupported",value:function(){return new Promise(function(t,n){return e.supportInfo.isChecking?void n(e.supportInfo.checkresult):e.supportInfo.isComplete?void t(e.supportInfo.checkresult):void e.supportInfo.checkStart().then(function(e){s.default.reportSupportInfo(e),t(e)}).catch(function(e){s.default.reportSupportInfo(e),n(e)})})}}]),e}();t.default=d,d.supportInfo=new u.default},function(e,t,n){"use strict";(function(t){var r=n(58);e.exports=r({window:t.window})}).call(t,n(57))},function(e,t,n){"use strict";var r={};r.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.getDescription=function(e){var t=r.splitSections(e);return t&&t[0]},r.getMediaSections=function(e){var t=r.splitSections(e);return t.shift(),t},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){var t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");for(var n={foundation:t[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},r.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.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&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(" ")},r.parseIceOptions=function(e){return e.substr(14).split(" ")},r.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},r.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},r.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?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<r.length;i++)t=r[i].trim().split("="),n[t[0].trim()]=t[1];return n},r.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)}),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},r.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},r.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},r.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-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;a<i.length;a++){var o=i[a],s=r.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(s){var c=r.parseRtpMap(s),u=r.matchPrefix(e,"a=fmtp:"+o+" ");switch(c.parameters=u.length?r.parseFmtp(u[0]):{},c.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(r.parseRtcpFb),t.codecs.push(c),c.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(c.name.toUpperCase())}}}return r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))}),t},r.writeRtpDescription=function(e,t){var n="";n+="m="+e+" ",n+=t.codecs.length>0?"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;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return t?r.getDirection(t):"sendrecv"},r.getKind=function(e){return r.splitLines(e)[0].split(" ")[0].substr(2)},r.isRejected=function(e){return"0"===e.split(" ",2)[1]},r.parseMLine=function(e){var t=r.splitLines(e),n=t[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},r.parseOLine=function(e){var t=r.matchPrefix(e,"o=")[0],n=t.substr(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},e.exports=r},function(e,t,n){e.exports=n(24)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var i,a;Object.defineProperty(t,"__esModule",{value:!0});var o=("function"==typeof Symbol&&Symbol.iterator,n(25)),s=r(o),c=n(69),u=r(c);n(21),s.default.Polyfill=u.default,window&&(window.AliRtcEngine=s.default),i=[],void 0!==(a=function(){return s.default}.apply(t,i))&&(e.exports=a),t.default=s.default},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"==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},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(26),d=r(u),l=n(27),f=r(l),p=n(4),h=r(p),v=n(43),m=r(v),_=n(44),g=r(_),y=n(51),b=r(y),S=n(20),k=r(S),C=n(55),P=r(C),w=n(2),T=r(w),R=n(19),I=r(R),O=n(0),E=r(O);n(21);var D=function(e){function t(e,n,r){i(this,t);var o=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o._turn={},o._authInfo=new d.default,o._signalingServer=new m.default,o._channelInfo=new f.default(o._turn,o._ws),o._option=e||{},o._hasJoinedChannel=!1,o._isPreviwing=!1,o._rtcMediaDevice=new g.default,o._service=b.default.create(o._authInfo,o._channelInfo,o._signalingServer,o._turn),o._signalingListener=new P.default(o._authInfo,o._channelInfo,o._signalingServer),o._channelInfo.dispatcher=o,o._channelInfo.signalingListener=o._signalingListener,k.default.isSupported().then(function(e){n&&n(o,e)}).catch(function(e){r&&r(e)}),o}return o(t,e),c(t,[{key:"configRemoteCameraTrack",value:function(e,t,n){var r=this._channelInfo.getUser(e);r&&r.configRemoteCameraTrack(t,n)}},{key:"configRemoteScreenTrack",value:function(e,t){var n=this._channelInfo.getUser(e);n&&n.configRemoteScreenTrack(t)}},{key:"configRemoteAudio",value:function(e,t){var n=this._channelInfo.getUser(e);n&&n.configRemoteAudio(t)}},{key:"getUserList",value:function(){return this._channelInfo.getUserList()}},{key:"getUserInfo",value:function(e){var t=this._channelInfo.getUser(e);return t?t.getUserInfo():null}},{key:"joinChannel",value:function(e,t){var n=this;return new Promise(function(r,i){var a=n._validateAuthInfo(e);if(a)return n.dispatchEvent(h.default.OnError,a),void i({message:a});n._service.gslb.updateAuthInfo(e),t||(t=n._authInfo.userId),n._authInfo.userName=t;var o=(new Date).getTime();n._service.gslb.getGslb().then(function(e){var t=(new Date).getTime();n._service.channel.join(n._signalingListener).then(function(i){T.default.reportJoinRoom((new Date).getTime()-t,0,i.tid,t-o,e),n._hasJoinedChannel=!0,n._channelInfo.onJoinSuccess(n._authInfo),r()}).catch(function(e){T.default.reportJoinRoom((new Date).getTime()-t,e.code,e.tid,t-o,e),i(e)})}).catch(function(e){i(e)})})}},{key:"leaveChannel",value:function(){var e=this;return new Promise(function(t,n){e._channelInfo&&e._channelInfo.clear();var r=(new Date).getTime();e._service.channel.leave().then(function(n){T.default.reportLeaveRoom((new Date).getTime()-r,0,n.tid),e._signalingListener.cancel(),e._hasJoinedChannel=!1,t(e._channelInfo)}).catch(function(e){T.default.reportLeaveRoom((new Date).getTime()-r,e.code,e.tid),t(e)})})}},{key:"startPreview",value:function(e){var t=this;return new Promise(function(n,r){if(t._checkHtmlElement(e))t._rtcMediaDevice.getPreViewStream(e).then(function(){t._isPreviwing=!0,T.default.reportStartPreview(e.nodeName,0,""),n()}).catch(function(t){T.default.reportStartPreview(e.nodeName,-1,t.message),r(t)});else{var i="",a="";e?dom instanceof HTMLElement?(i=e.nodeName,a="wrong htmlelement"):(i=void 0===i?"undefined":s(i),a="video is not htmlelement"):(i="null",a="video is null"),T.default.reportStartPreview(i,-1,a),r({message:"video对象错误"})}})}},{key:"stopPreview",value:function(){var e=this;return new Promise(function(t,n){try{e._rtcMediaDevice.releasePreviewStream(),e._isPreviwing=!1,T.default.reportStopPreview(0),t()}catch(e){T.default.reportStopPreview(1),n(e)}})}},{key:"publish",value:function(){var e=this;return new Promise(function(t,n){if(!e._channelInfo.self.canPublish(e._rtcMediaDevice.streamConfig))return void n({message:"没有推流"});e._rtcMediaDevice.getPublishStream(e).then(function(r){e._channelInfo.self.publish(r,e._turn,e._rtcMediaDevice.streamConfig).then(function(n){n.publishCallId=e._authInfo.publishCallId,t(n)}).catch(function(e){n(e)})}).catch(function(e){n(e)})})}},{key:"unPublish",value:function(){var e=this;return new Promise(function(t,n){e._channelInfo.self.unPublish().then(function(n){e._rtcMediaDevice.releasePublishStream(),e._channelInfo.self.clear(),t(n)}).catch(function(t){e._rtcMediaDevice.releasePublishStream(),n(t)})})}},{key:"subscribe",value:function(e){var t=this;return new Promise(function(n,r){var i=t._channelInfo.getUser(e);i?i.subscribe().then(function(t){n(e)}).catch(function(e){r(e)}):r({message:"订阅用户不存在"})})}},{key:"unSubscribe",value:function(e){var t=this;return new Promise(function(n,r){var i=t._channelInfo.getUser(e);i?i.unSubscribe().then(function(){n()}).catch(function(e){r(e)}):r({message:"取消订阅的用户不存在"})})}},{key:"setDisplayRemoteVideo",value:function(e,t,n){var r=this._checkHtmlElement(t);if(r&&e&&e.userId){var i=this._channelInfo.getUser(e.userId);return!!i&&(i.setDisplayRemoteVideo(t,n),T.default.reportSetDisplayRemoteVideo(t.nodeName,0,""),!0)}var a="",o="";return r?(a=t.nodeName,o=e?"can not found "+e.publisherId:"subscriber is null"):t?dom instanceof HTMLElement?(a=t.nodeName,o="wrong htmlelement"):(a=void 0===a?"undefined":s(a),o="video is not htmlelement"):(a="null",o="video is null"),T.default.reportSetDisplayRemoteVideo(a,-1,o),!1}},{key:"getDevices",value:function(){return this._rtcMediaDevice.getDevices()}},{key:"muteLocalCamera",value:function(e){return!E.default.isIos&&(T.default.reportMuteLocalCamera(e),this._rtcMediaDevice.muteLocalCamera(e),!1)}},{key:"muteLocalMic",value:function(e){return T.default.reportMuteLocalMic(e),this._rtcMediaDevice.muteLocalMic(e)}},{key:"on",value:function(e,t,n){this.addEventListener(e,t,n)}},{key:"off",value:function(e,t,n){this.removeEventListener(e,t,n)}},{key:"getAvailableResolutions",value:function(e){return this._rtcMediaDevice.getAvailableResolutions(e)}},{key:"dispose",value:function(){if(this._signalingListener.cancel(),this._hasJoinedChannel){this._hasJoinedChannel=!1,this._service.channel.leaveSync();!function(e){for(var t=(new Date).getTime(),n=t;n<t+e;)n=(new Date).getTime()}(1e3)}}},{key:"_publish",value:function(){return new Promise(function(e,t){})}},{key:"_validateAuthInfo",value:function(e){var t="频道鉴权令牌参数#不能为空",n="";return e.appid?e.channel?e.nonce?e.userid?e.timestamp?e.token?e.gslb||(n="gslb"):n="token":n="timestamp":n="userid":n="nonce":n="channel":n="appid",n?t=t.replace("#",n):/[^\d^\w^\-]+/.test(e.userid)?"用户名(userid)只能为字母或数字":""}},{key:"_checkHtmlElement",value:function(e){return!(!(e&&e instanceof HTMLElement)||"VIDEO"!==e.nodeName&&"AUDIO"!==e.nodeName)}},{key:"configLocalCameraPublish",set:function(e){this._rtcMediaDevice.configLocalCameraPublish=e},get:function(){return this._rtcMediaDevice.configLocalCameraPublish}},{key:"configLocalScreenPublish",set:function(e){this._rtcMediaDevice.configLocalScreenPublish=e},get:function(){return this._rtcMediaDevice.configLocalScreenPublish}},{key:"configLocalAudioPublish",set:function(e){this._rtcMediaDevice.configLocalAudioPublish=e},get:function(){return this._rtcMediaDevice.configLocalAudioPublish}},{key:"currentCamera",set:function(e){this._rtcMediaDevice.currentCamera=e}},{key:"currentAudioCapture",set:function(e){this._rtcMediaDevice.currentAudioCapture=e}},{key:"videoProfile",set:function(e){this._rtcMediaDevice.videoProfile=e}},{key:"audioProfile",set:function(e){this._rtcMediaDevice.audioProfile=e}}],[{key:"isSupport",value:function(){return k.default.isSupported()}}]),t}(I.default);t.default=D},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,[{key:"userName",get:function(){return this._userName},set:function(e){this._userName=e}},{key:"userId",get:function(){return this._userId},set:function(e){this._userId=e}},{key:"channel",get:function(){return this._channel},set:function(e){this._channel=e}},{key:"appid",get:function(){return this._appid},set:function(e){this._appid=e}},{key:"nonce",get:function(){return this._nonce},set:function(e){this._nonce=e}},{key:"timestamp",get:function(){return this._timestamp},set:function(e){this._timestamp=e}},{key:"gslb",get:function(){return this._gslb},set:function(e){this._gslb=e}},{key:"token",get:function(){return this._token},set:function(e){this._token=e}},{key:"publishCallId",get:function(){return this._publishCallid},set:function(e){this._publishCallid=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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(4),s=r(o),c=n(28),u=r(c),d=n(36),l=r(d),f=n(2),p=r(f),h=function(){function e(t,n){i(this,e),this._users={},this._turn=t}return a(e,[{key:"getUser",value:function(e){return e?this._users[e]:null}},{key:"getUserList",value:function(){var e=[];for(var t in this._users)e.push({userId:this._users[t].userId,displayName:this._users[t].displayName});return e}},{key:"onJoinSuccess",value:function(e){var t=this;this._authInfo=e,this._self=new u.default(this._authInfo.userId,this._authInfo.userName,this._authInfo,this._dispatcher,this._signalingListener),this._timerId||(this._timerId=setInterval(function(){t._onMonitorTimer()},2e3))}},{key:"onJoin",value:function(e){if(e.peers&&e.peers.length)for(var t=0;t<e.peers.length;++t){var n=e.peers[t];n&&n.userid&&(this._users[n.userid]||(this._users[n.userid]=new l.default(n.userid,n.displayname,this._authInfo,this._dispatcher,this._signalingListener)),this._dispatcher&&this._dispatcher.dispatchEvent(s.default.OnJoin,this._users[n.userid].getUserInfo()))}}},{key:"onPublisher",value:function(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n],i=this._users[r.userid];i||(i=new l.default(r.userid,r.displayName,this._authInfo,this._dispatcher,this._signalingListener),this._users[r.userid]=i),i.callId=r.callid,i.updateStreams(r.streams),this._dispatcher.dispatchEvent(s.default.OnPublisher,i.getUserInfo())}}},{key:"onLeave",value:function(e){if(e&&e.userid){var t=this._users[e.userid];if(t){var n=t.getUserInfo();t.clear(),delete this._users[e.userid],this._dispatcher.dispatchEvent(s.default.OnLeave,n)}}}},{key:"onUnpublish",value:function(e){if(e&&e.userid){var t=this._users[e.userid];t&&(t.onUnpublish(),this._dispatcher.dispatchEvent(s.default.OnUnPublisher,t.getUserInfo()))}}},{key:"onOffer",value:function(e){for(var t in this._users)if(this._users[t].subscribeId===e.callid){this._users[t].recvOffer(e.jsep,this._turn);break}}},{key:"onSignalError",value:function(e){this._dispatcher&&this._dispatcher.dispatchEvent(s.default.OnError,e)}},{key:"clear",value:function(){this._timerId&&(clearInterval(this._timerId),this._timerId=0),this._self.unPublish().then(function(){}).catch(function(e){}),this._self.clear(),this._unSubscribeAll(),this._users={}}},{key:"_unSubscribeAll",value:function(){for(var e in this._users)this._users[e].unSubscribe().then(function(){}).catch(function(e){}),this._users[e].clear(),delete this._users[e]}},{key:"_onMonitorTimer",value:function(){var e={publisher:this._self.getMonitorData(),subscribers:[]};for(var t in this._users){var n=this._users[t].getMonitorData();n&&e.subscribers.push(n)}p.default.reportMonitor(e)}},{key:"self",get:function(){return this._self}},{key:"dispatcher",set:function(e){this._dispatcher=e}},{key:"signalingListener",set:function(e){this._signalingListener=e}}]),e}();t.default=h},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,r)}if("value"in i)return i.value;var o=i.get;if(void 0!==o)return o.call(r)},u=n(11),d=r(u),l=n(29),f=r(l),p=n(4),h=r(p),v=n(2),m=r(v),_=n(8),g=r(_),y=n(5),b=r(y),S=n(1),k=r(S),C=n(7),P=r(C),w=n(6),T=r(w),R=n(30),I=r(R),O=n(35),E=r(O),D=function(e){function t(e,n,r,o,s){i(this,t);var c=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r,o,s));return c._status=E.default.Init,c._isPublishAudio=!1,c._isPublishCamera=!1,c._isPublishScreen=!1,c}return o(t,e),s(t,[{key:"canPublish",value:function(e){return!!(e.audio||e.camera||e.screen||this._conn)}},{key:"publish",value:function(e,t,n){var r=this;return new Promise(function(i,a){n.audio||n.camera||n.screen?r._conn?r._republish(e,n).then(function(e){i(e)}).catch(function(e){a(e)}):r._publish(e,t,n).then(function(e){i(e)}).catch(function(e){a(e)}):r._conn?r.unPublish().then(function(e){i(e)}).catch(function(e){a(e)}):a({message:"没有推流"})})}},{key:"getMonitorData",value:function(){return this._pcMonitor?this._pcMonitor.getMonitorData():null}},{key:"unPublish",value:function(){var e=this;return new Promise(function(t,n){if(!e._conn)return void n({message:"没有推流"});e._status=E.default.UnPublishing;var r=(new Date).getTime();e._releaseMonitor(),b.default.post(T.default.UnPublishUrl,{appid:e._authInfo.appid,session:e._authInfo.sessionId,callid:e._authInfo.publishCallId,tid:g.default.random(32),server:T.default.serverUrl,token:e._authInfo.token}).then(function(n){e.clear(),e._status=E.default.Init,m.default.reportUnpublish(e._authInfo.publishCallId,(new Date).getTime()-r,0,n.tid),t(n)}).catch(function(t){t.code&&m.default.reportUnpublish(e._authInfo.publishCallId,(new Date).getTime()-r,t.code,t.tid),e._status=E.default.Init,n(t)})})}},{key:"clear",value:function(){c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"clear",this).call(this),this._streamConfig=[]}},{key:"_publish",value:function(e,t,n){var r=this;return new Promise(function(i,a){r._status=E.default.Publishing;var o=(new Date).getTime();r._startConnect(e,t).then(function(e){k.default.isFirefox&&(e.sdp=P.default.completionSDPSSRC(e.sdp));var t=[];return r._updateStreamConfig(n),new Promise(function(n,i){r._allocate(t).then(function(){}).catch(function(e){i(e)});var a=r._getStreamData();r._startPublish(e,t).then(function(t){m.default.reportPublish(r._authInfo.publishCallId,a.isLargeVideo,!1,a.isAudio,a.width,a.height,0,t.tid,(new Date).getTime()-o),n({offer:e,answer:t.jsep})}).catch(function(e){i(e)})})}).catch(function(e){a(e)}).then(function(e){r._status=E.default.Published,i(e)}).catch(function(e){r._status=E.default.Init;var t=r._getStreamData();m.default.reportPublish(r._authInfo.publishCallId,t.isLargeVideo,!1,t.isAudio,t.width,t.height,err.code,e.tid,(new Date).getTime()-o),a(e)})})}},{key:"_republish",value:function(e,t){var n=this;return new Promise(function(e,r){var i=(new Date).getTime(),a=n.conn.getLocalStreams();if(!a||!a.length)return m.default.reportRepublish(n._authInfo.publishCallId,!1,!1,!1,0,0,-1,"",(new Date).getTime()-i),void r({message:"mediastream错误"});var o=a[0];if(n._isPublishAudio!=t.audio){var s=o.getAudioTracks()[0];n._isPublishAudio?(n._isPublishAudio=!1,s.enabled=!1):(n._isPublishAudio=!0,s.enabled=!0)}var c=!1;if(n._isPublishScreen!=t.screen?n._isPublishScreen?(n._isPublishScreen=!1,c=!0):(n._isPublishScreen=!0,c=!0):n._isPublishScreen||n._isPublishCamera==t.camera||(n._isPublishCamera?(n._isPublishCamera=!1,c=!0):(n._isPublishCamera=!0,c=!0)),c){var u=n.conn.getLocalStreams();if(u&&u.length){var d=u[0].getTracks();if(d&&d.length)for(var l=0;l<d.length;++l)"video"===d[l].kind&&(d[l].enabled=!d[l].enabled)}}n._updateStreamConfig(t);var f=JSON.stringify({streams:n._streamConfig}),p=n._getStreamData(),h=g.default.random(32);n._signalingListener&&n._signalingListener.addEventListener(h,function(t){m.default.reportRepublish(n._authInfo.publishCallId,p.isLargeVideo,!1,p.isAudio,p.width,p.height,t.code,t.tid,(new Date).getTime()-i),e(t)},n,!0),b.default.ajaxPost(T.default.RepublishUrl,{appid:n._authInfo.appid,session:n._authInfo.sessionId,callid:n._authInfo.publishCallId,tid:h,server:T.default.serverUrl,token:n._authInfo.token},f).then(function(e){}).catch(function(e){m.default.reportRepublish(n._authInfo.publishCallId,p.isLargeVideo,!1,p.isAudio,p.width,p.height,e.code,e.tid,(new Date).getTime()-i),r(e)})})}},{key:"_createOffer",value:function(e){var t=this;return new Promise(function(n,r){var i=P.default.mergeConstraints(P.default.DEFAULT_SDP_OFFER_OPTIONS,e);t.conn.createOffer(i).then(function(e){e.sdp=P.default.replace42e01fTo42001f(e.sdp),n(e)}).catch(function(e){r(e)})})}},{key:"_getStreamData",value:function(){return new f.default(this._streamConfig)}},{key:"_startConnect",value:function(e,t){return this._createPeerConnection(t),this.conn.addStream(e),this._pcMonitor=new I.default(this.conn,this._authInfo.publishCallId),this._pcMonitor.startMonitor(),this._createOffer({})}},{key:"_updateStreamConfig",value:function(e){var t=this;this.conn&&(this._streamConfig=[],this.conn.getLocalStreams().forEach(function(n){n.getTracks().forEach(function(r){if("video"===r.kind){e.screen?t._isPublishScreen=!0:e.camera&&(t._isPublishCamera=!0);var i=void 0,a=r.getSettings();i=a?"UD_"+(a.width?a.width:640)+"_"+(a.height?a.height:480)+"_"+(a.frameRate?a.frameRate:15):"UD_640_480P_15",t._streamConfig.push({mslabel:n.id,label:r.id,type:r.kind,temporalLayers:1,substreams:1,videoprofile:i,state:r.enabled?"active":"inactive"})}else"audio"===r.kind&&(e.audio?(t._isPublishAudio=!0,t._streamConfig.push({mslabel:n.id,label:r.id,type:r.kind,temporalLayers:0,substreams:0,state:"active",videoprofile:""})):(t._isPublishAudio=!1,t._streamConfig.push({mslabel:n.id,label:r.id,type:r.kind,temporalLayers:0,substreams:0,state:"inactive",videoprofile:""})))})}))}},{key:"_allocate",value:function(e){var t=this;return this._dispatcher&&this._dispatcher.dispatchEvent(h.default.OnConnecting,{displayName:this.displayName,publishId:this.publishId,type:"publish"}),new Promise(function(n,r){t.conn.onicecandidate=function(n){n.candidate&&t._filterIceCandidate(n.candidate)&&(t._iceCandidateByOffer(!1,n.candidate).then(function(e){}).catch(function(e){r(e)}),e.push(n.candidate))},t.conn.onicegatheringstatechange=function(n){"complete"==t.conn.iceGatheringState&&(0==e.length?r({message:"connection failed, no candidate"}):t._iceCandidateByOffer(!0).then(function(e){t._dispatcher&&t._dispatcher.dispatchEvent(h.default.OnConnected,{displayName:t.displayName,publishId:t.publishId,type:"publish"})}).catch(function(e){r(e)}))},t.conn.oniceconnectionstatechange=function(e){var n=t.conn.iceConnectionState;switch(n){case"closed":case"failed":case"disconnected":!t._dispatcher||t._status!==E.default.Published&&t._status!==E.default.Publishing||(t._dispatcher.dispatchEvent(h.default.OnError,{message:"ICE connection "+n+",please check network or try to stop publish, then publish again",type:"publish"}),"disconnected"===n&&t._releaseMonitor())}}})}},{key:"_startPublish",value:function(e,t){var n=this,r=g.default.random(32);return new Promise(function(i,a){var o=JSON.stringify({jsep:{type:e.type,sdp:e.sdp},streams:n._streamConfig});n._signalingListener&&n._signalingListener.addEventListener(r,function(e){if(!e.jsep||!e.jsep.sdp)return void a({message:"no answer"});n._setRemoteDescription(e.jsep).then(function(){n._setEncodParams()}).catch(function(e){});!function n(){t&&t.length>0?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<e.length;++t)if(e[t].track)if("video"===e[t].track.kind){var n=e[t],r=n.getParameters();if(r&&r.encodings.length)for(var i=0;i<r.encodings.length;++i)r.encodings[i].maxBitrate=5e5;n.setParameters(r).then(function(e){}).catch(function(e){})}else if("audio"===e[t].track.kind){var a=e[t],o=a.getParameters();if(o&&o.encodings.length)for(var s=0;s<o.encodings.length;++s)o.encodings[s].maxBitrate=24e3;a.setParameters(o).then(function(e){}).catch(function(e){})}}}]),t}(d.default);t.default=D},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(t){r(this,e),this._isLargeVideo=!1,this._isAudio=!1,this._w=0,this._h=0;for(var n=0;n<t.length;++n)"audio"===t[n].type?this._isAudio=!0:"video"===t[n].type&&(this._isLargeVideo=!0,this._w=640,this._h=480)}return i(e,[{key:"isAudio",get:function(){return this._isAudio?1:0}},{key:"isLargeVideo",get:function(){return this._isLargeVideo?1:0}},{key:"width",get:function(){return this._w}},{key:"height",get:function(){return this._h}}]),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")}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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(15),u=r(c),d=n(31),l=r(d),f=n(0),p=r(f),h=function(e){function t(e,n){i(this,t);var r=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r._senderMonitorData=new l.default(n),r}return o(t,e),s(t,[{key:"getMonitorData",value:function(){return this._senderMonitorData.getMonitorData()}},{key:"_onMonitorTimer",value:function(){var e=this;if(this._peerConnection)if(p.default.isIos||p.default.isAndroid){var t=this._peerConnection.getLocalStreams();if(t&&t.length){var n=t[0].getAudioTracks()[0];this._peerConnection.getStats(n).then(function(t){e._getAudioInfo(t,n)}).catch(function(e){});var r=t[0].getVideoTracks();r.length&&this._peerConnection.getStats(r[0]).then(function(t){e._getVideoInfo(t,r[0])}).catch(function(e){})}}else!function(){for(var t=e._peerConnection.getSenders(),n=0;n<t.length;++n)!function(n){t[n].track&&void 0!=t[n].getStats&&t[n].getStats().then(function(r){"audio"===t[n].track.kind?e._getAudioInfo(r,t[n].track,t[n].getParameters()):"video"===t[n].track.kind&&e._getVideoInfo(r,t[n].track,t[n].getParameters())}).catch(function(e){})}(n)}()}},{key:"_getAudioInfo",value:function(e,t,n){var r=this;e.forEach(function(e){if(e)switch(e.type){case"candidate-pair":r._onAudioCandidatePair(e);break;case"codec":r._onAudioCodec(e);break;case"local-candidate":r._onAudioLocalCandidate(e);break;case"outbound-rtp":r._onAudioOutBoundRtp(e,t,n);break;case"receiver":case"stream":break;case"track":r._onAudioTrack(e)}})}},{key:"_getVideoInfo",value:function(e,t,n){var r=this;e.forEach(function(e){if(e)switch(e.type){case"candidate-pair":r._onVideoCandidatePair(e);break;case"codec":r._onVideoCodec(e);break;case"csrc":case"data-channel":case"inbound-rtp":case"local-candidate":break;case"outbound-rtp":r._onVideoOutBoundRtp(e,t,n)}})}},{key:"_onAudioCodec",value:function(e){this._senderMonitorData.updateAudioCodec(e)}},{key:"_onAudioCandidatePair",value:function(e){this._senderMonitorData.updateCommonInfo(e.timestamp,e.currentRoundTripTime)}},{key:"_onAudioLocalCandidate",value:function(e){this._senderMonitorData.updateNetworkInfo(e.timestamp,e.ip,e.port,e.protocol,e.networkType)}},{key:"_onAudioOutBoundRtp",value:function(e,t){this._senderMonitorData.updateAudioDataSent(e.timestamp,e.bytesSent,e.packetsSent,e.ssrc,t)}},{key:"_onAudioTrack",value:function(e){this._senderMonitorData.updateAudioInfo(e.timestamp,e.audioLevel,e.totalAudioEnergy,e.totalSamplesDuration)}},{key:"_onVideoCandidatePair",value:function(e){this._senderMonitorData.updateVideoCandidatePair(e.availableBandwidth||e.availableOutgoingBitrate)}},{key:"_onVideoCodec",value:function(e){this._senderMonitorData.updateVideoCodec(e)}},{key:"_onVideoOutBoundRtp",value:function(e,t,n){this._senderMonitorData.updateVideoDataSent(e.timestamp,e.bytesSent,e.packetsSent,e.ssrc,e.nackCount,t,n)}}]),t}(u.default);t.default=h},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(32),s=r(o),c=n(33),u=r(c),d=n(34),l=r(d),f=function(){function e(t){i(this,e),this._reportData=new l.default(t),this._callId=t,this._senderAudioData=new s.default,this._senderVideoData=new u.default,this._rtt=0,this._ip="",this._port="",this._protocol="",this._networkType="",this._isAudio=!1,this._isVideo=!1}return a(e,[{key:"getMonitorData",value:function(){return this._reportData.rtt=this._rtt,this._reportData.raddr=this._ip+":"+this._port,this._reportData.asb=this._senderVideoData.availableBandwidth,this._reportData.video.vlsrc=this._senderVideoData.ssrc,this._reportData.video.isv=this._isVideo,this._reportData.video.vfps=this._senderVideoData.frameRate,this._reportData.video.teb=this._senderVideoData.bitrate,this._reportData.video.vrn=this._senderVideoData.nackCount,this._reportData.video.codec=this._senderVideoData.codec,this._reportData.video.w=this._senderVideoData.width,this._reportData.video.h=this._senderVideoData.height,this._reportData.video.bsps=this._senderVideoData.bytesSentPerSecond,this._reportData.audio.asrc=this._senderAudioData.ssrc,this._reportData.audio.isa=this._isAudio,this._reportData.audio.codec=this._senderAudioData.codec,this._reportData.audio.bsps=this._senderAudioData.bytesSentPerSecond,this._reportData}},{key:"updateAudioDataSent",value:function(e,t,n,r,i){this._isAudio=i.enabled,this._senderAudioData.updateDataSent(e,t,n,r)}},{key:"updateVideoDataSent",value:function(e,t,n,r,i,a,o){this._isVideo=a.enabled,this._senderVideoData.updateDataSent(e,t,n,r,i,a,o)}},{key:"updateAudioInfo",value:function(e,t,n,r){this._senderAudioData.updateAudioInfo(e,t,n,r)}},{key:"updateCommonInfo",value:function(e,t){this._rtt=t}},{key:"updateNetworkInfo",value:function(e,t,n,r,i){this._ip=t,this._port=n,this._protocol=r,this._networkType=i}},{key:"updateAudioCodec",value:function(e){this._senderAudioData.updateParameters(e)}},{key:"updateVideoCodec",value:function(e){this._senderVideoData.updateParameters(e)}},{key:"updateVideoCandidatePair",value:function(e){this._senderVideoData.updateVideoCandidatePair(e)}}]),e}();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")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e),this._lastDataSentTimeStamp=0,this._bytesSent=0,this._packetsSent=0,this._bytesSentPerSecond=0,this._packetsSentPerSecond=0,this._ssrc="",this._audioLevel=0,this._clockRate=0,this._mimeType=""}return i(e,[{key:"updateDataSent",value:function(e,t,n,r){if(this._ssrc=r,this._lastDataSentTimeStamp&&this._bytesSent&&this._packetsSent){var i=(e-this._lastDataSentTimeStamp)/1e3;this._bytesSentPerSecond=(t-this._bytesSent)/i,this._packetsSentPerSecond=(n-this._packetsSent)/i}this._lastDataSentTimeStamp=e,this._bytesSent=t,this._packetsSent=n}},{key:"updateAudioInfo",value:function(e,t,n,r){this._audioLevel=t}},{key:"updateParameters",value:function(e){this._mimeType=e.mimeType?e.mimeType.replace("audio/",""):"",this._clockRate=e.clockRate?e.clockRate:0}},{key:"ssrc",get:function(){return this._ssrc}},{key:"codec",get:function(){return this._mimeType}},{key:"packetsSent",get:function(){return this._packetsSent}},{key:"bytesSentPerSecond",get:function(){return this._bytesSentPerSecond}}]),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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e),this._lastDataSentTimeStamp=0,this._bytesSent=0,this._packetsSent=0,this._bytesSentPerSecond=0,this._packetsSentPerSecond=0,this._nackCount=0,this._ssrc="",this._frameRate=0,this._width=0,this._height=0,this._clockRate=0,this._mimeType="",this._availableBandwidth=3e3,this._bitrate=0}return i(e,[{key:"updateDataSent",value:function(e,t,n,r,i,a,o){if(a){var s=a.getSettings();s?(this._frameRate=s.frameRate,this._width=s.width?s.width:0,this._height=s.height?s.height:0):this._frameRate=0}if(o&&o.encodings&&o.encodings.length?this._bitrate=o.encodings[0].maxBitrate:this._bitrate=0,this._nackCount=i,this._ssrc=r,this._lastDataSentTimeStamp&&this._bytesSent&&this._packetsSent){var c=(e-this._lastDataSentTimeStamp)/1e3;this._bytesSentPerSecond=(t-this._bytesSent)/c,this._packetsSentPerSecond=(n-this._packetsSent)/c}this._lastDataSentTimeStamp=e,this._bytesSent=t,this._packetsSent=n}},{key:"updateParameters",value:function(e){this._mimeType=e.mimeType?e.mimeType.replace("video/",""):"",this._clockRate=e.clockRate?e.clockRate:0}},{key:"updateVideoCandidatePair",value:function(e){this._availableBandwidth=e}},{key:"ssrc",get:function(){return this._ssrc}},{key:"nackCount",get:function(){return this._nackCount}},{key:"frameRate",get:function(){return this._frameRate}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"codec",get:function(){return this._mimeType}},{key:"packetsSent",get:function(){return this._packetsSent}},{key:"availableBandwidth",get:function(){return this._availableBandwidth/1024}},{key:"bitrate",get:function(){return this._bitrate}},{key:"bytesSentPerSecond",get:function(){return this._bytesSentPerSecond}}]),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 e(t){r(this,e),this.calid=t,this.rtt=-1,this.raddr="",this.asb=1e3,this.video={src:"",isv:!1,vfps:0,teb:0,vrn:0,codec:"",w:0,h:0,vps:0},this.audio={src:"",isa:!1,codec:"",aps:0}};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={Init:0,Publishing:1,Published:2,UnPublishing:3}},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,r)}if("value"in i)return i.value;var o=i.get;if(void 0!==o)return o.call(r)},u=n(11),d=r(u),l=n(16),f=r(l),p=n(8),h=r(p),v=n(4),m=r(v),_=n(5),g=r(_),y=n(2),b=r(y),S=n(1),k=r(S),C=n(7),P=r(C),w=n(6),T=r(w),R=n(37),I=r(R),O=n(0),E=r(O),D=function(e){function t(e,n,r,o,s){i(this,t);var c=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r,o,s));return c._subscribeStreams=[],c._mediastream=null,c._firefoxStreamInfo=[],c._configRemoteCameraTrack=!0,c._preferMaster=!0,c._configRemoteScreenTrack=!1,c._configRemoteAudio=!0,c._callId="",c._subscribeId="",c._cameraVideo=null,c._screenVideo=null,c}return o(t,e),s(t,[{key:"getMonitorData",value:function(){return this._pcMonitor?this._pcMonitor.getMonitorData(this._streamConfig):null}},{key:"configRemoteCameraTrack",value:function(e,t){this._configRemoteCameraTrack=t,this._preferMaster=e}},{key:"configRemoteScreenTrack",value:function(e){this._configRemoteScreenTrack=e}},{key:"configRemoteAudio",value:function(e){this._configRemoteAudio=e}},{key:"clear",value:function(){c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"clear",this).call(this),this._cameraVideo&&(this._cameraVideo.srcObject=null),this._cameraVideo=null,this._screenVideo&&(this._screenVideo.srcObject=null),this._mediastream=null;for(var e=0;e<this._streamConfig.length;++e)this._streamConfig[e].subscribed=!1}},{key:"setDisplayRemoteVideo",value:function(e,t){if(t){if(e.srcObject=t,e.setAttribute("autoplay",""),(E.default.isIos||E.default.isAndroid)&&(e.setAttribute("playsinline",""),E.default.isIos)){var n=!0,r=e.muted;e.muted=!0,e.addEventListener("play",function(){n&&(n=!1,setTimeout(function(){e.muted=r},100))})}var i=t.getVideoTracks();i&&i.length&&(i[0].label===f.default.ScreenShareVideo?this._screenVideo=e:this._cameraVideo=e)}}},{key:"subscribe",value:function(){var e=this;return new Promise(function(t,n){e._configRemoteCameraTrack||e._configRemoteScreenTrack||e._configRemoteAudio?e.conn?e._reSubscribe().then(function(e){t(e)}).catch(function(e){n(e)}):e._subscribe().then(function(e){t(e)}).catch(function(e){n(e)}):e.unSubscribe().then(function(e){t(e)}).catch(function(e){n(e)})})}},{key:"unSubscribe",value:function(){var e=this;return new Promise(function(t,n){if(e.conn){var r=h.default.random(32),i=(new Date).getTime();e._signalingListener.addEventListener(r,function(n){b.default.reportUnsubscribe(e._subscribeId,e._callId,(new Date).getTime()-i,0,n.tid),e.clear(),t(e.getUserInfo())},e,!0),e._releaseMonitor(),g.default.post(T.default.UnSubscribeUrl,{appid:e._authInfo.appid,session:e._authInfo.sessionId,callid:e._subscribeId,tid:r,server:T.default.serverUrl,token:e._authInfo.token}).then(function(e){}).catch(function(t){b.default.reportUnsubscribe(e._subscribeId,e._callId,(new Date).getTime()-i,t.code,r),n(t)})}else n({message:"没有订阅"})})}},{key:"updateStreams",value:function(e){if(this._streamConfig.length)for(var t=0;t<e.length;++t){for(var n=!1,r=0;r<this._streamConfig.length;++r)if(this._streamConfig[r].label===e[t].label){n=!0,this._streamConfig[r].subscribed!=e[t].subscribed&&(e[t].subscribed=this._streamConfig[r].subscribed,this._streamConfig[r]=e[t],this._isStreamSubscribed(this._streamConfig[r].label)&&(f.default.ScreenShareVideo===this._streamConfig[r].label?!0:f.default.Audio===this._streamConfig[r].label?!0:f.default.SmallVideo===this._streamConfig[r].label?!0:f.default.SuperVideo!=this._streamConfig[r].label&&!0));break}n||(e[t].subscribed=!1,this._streamConfig.push(e[t]))}else{Object.assign(this._streamConfig,e);for(var i=0;i<this._streamConfig.length;++i)this._streamConfig[i].subscribed=!1}}},{key:"recvOffer",value:function(e,t){var n=this;this.conn||(this._dispatcher.dispatchEvent(m.default.OnConnecting,{displayName:this._displayName,userId:this._userId,type:"subscribe"}),this._offerByRemote(e,t).then(function(e){n._dispatcher.dispatchEvent(m.default.OnConnected,{displayName:n._displayName,publishId:n._publishId,subscribeId:n._publishId,onlyAudio:!1,type:"subscribe"})}).catch(function(e){n._dispatcher.dispatchEvent(m.default.OnError,e)}))}},{key:"onUnpublish",value:function(){var e=this;this._conn&&this.unSubscribe().then(function(){e.clear()}).catch(function(t){e.clear()}),this._streamConfig=[]}},{key:"_subscribe",value:function(){var e=this;return new Promise(function(t,n){var r=e._createSubscribeStreams();if(!e._subscribeStreams.length)return void n({message:"没有订阅"});var i=(new Date).getTime(),a=h.default.random(32);e._subscribeId=h.default.random(32);var o=JSON.stringify({streams:e._subscribeStreams});e._signalingListener.addEventListener(a,function(o){33620257===o.code?(b.default.reportSubscribe(e._subscribeId,e._callId,r.isLargeVideo,r.isSmallVideo,r.isScreenShare,r.isAudio,o.code,a,(new Date).getTime()-i),n(o)):(e._updateStreamsSubscribeState(r),b.default.reportSubscribe(e._subscribeId,e._callId,r.isLargeVideo,r.isSmallVideo,r.isScreenShare,r.isAudio,0,a,(new Date).getTime()-i),t(o))},e,!0),g.default.ajaxPost(T.default.SubscribeUrl,{appid:e._authInfo.appid,session:e._authInfo.sessionId,callid:e._subscribeId,callee:e._callId,tid:a,server:T.default.serverUrl,token:e._authInfo.token},o).then(function(e){}).catch(function(t){b.default.reportSubscribe(e._subscribeId,e._callId,r.isLargeVideo,r.isSmallVideo,r.isScreenShare,r.isAudio,t.code,a,(new Date).getTime()-i),n(t)})})}},{key:"_reSubscribe",value:function(){var e=this;return new Promise(function(t,n){var r=(new Date).getTime(),i=e._createSubscribeStreams(),a=JSON.stringify({streams:e._subscribeStreams}),o=h.default.random(32);e._signalingListener.addEventListener(o,function(n){e._mediastream&&e._onRecvRemoteStream(e._mediastream),e._updateStreamsSubscribeState(i),b.default.reportResubscribe(e._subscribeId,e._publishId,i.isLargeVideo,i.isSmallVideo,i.isScreenShare,i.isAudio,0,o,(new Date).getTime()-r),t({subscribeCallId:e._subscribeId})},e,!0),g.default.ajaxPost(T.default.ReSubscribeUrl,{appid:e._authInfo.appid,session:e._authInfo.sessionId,callid:e._subscribeId,callee:e._callId,tid:o,server:T.default.serverUrl,token:e._authInfo.token},a).then(function(e){}).catch(function(t){b.default.reportResubscribe(e._subscribeId,e._publishId,i.isLargeVideo,i.isSmallVideo,i.isScreenShare,i.isAudio,t.code,o,(new Date).getTime()-r),n(t)})})}},{key:"_offerByRemote",value:function(e,t){var n=this;return new Promise(function(r,i){n._createAnswer(e,t).then(function(e){n._answer(e).then(function(e){r(e)}).catch(function(e){i(e)});var t=function(){"complete"==n.conn.iceGatheringState&&(n._iceGatheringStateCompleteHandle=!0,n._iceCandidateByAnswer(!0).then(function(e){n._iceGatheringStateCompleteHandle=!1}).catch(function(e){}))};n.conn.onicecandidate=function(e){if(e.candidate&&n._filterIceCandidate(e.candidate)){var r=e.candidate;if(n._iceCandidateByAnswer(!1,r).then(function(e){}).catch(function(e){}),void 0===n.conn.onicegatheringstatechange){!function e(){"complete"==n.conn.iceGatheringState?1!=n._iceGatheringStateCompleteHandle&&t():setTimeout(e)}()}}},void 0!==n.conn.onicegatheringstatechange&&(n.conn.onicegatheringstatechange=function(e){t()}),n.conn.oniceconnectionstatechange=function(e){var t=n.conn.iceConnectionState;switch(t){case"closed":case"failed":case"disconnected":n._dispatcher.dispatchEvent(m.default.OnError,{message:"ICE connection "+t+",please check network or try to cancel subscribe, then subscribe again",userId:n._userId,state:t,type:"subscribe"}),"disconnected"===t&&n._releaseMonitor()}},n.conn.onconnectionstatechange=function(e){switch(n.conn.connectionState){case"connected":break;case"disconnected":n._releaseMonitor();break;case"failed":n._displayName;break;case"closed":n._displayName}},n._setLocalDescription(e).then(function(){}).catch(function(e){i(e)})}).catch(function(e){i(e)})})}},{key:"_createAnswer",value:function(e,t){var n=this;return new Promise(function(r,i){n._createPeerConnection(t),n._pcMonitor=new I.default(n.conn,n._callId),n._pcMonitor.startMonitor(),k.default.isFirefox?n.conn.ontrack=function(e){e.streams&&e.streams.length&&(n._mediastream=e.streams[0])}:n.conn.onaddstream=function(e){n._onRecvRemoteStream(e.stream)},n._setRemoteDescription(e).then(function(){k.default.isFirefox&&n._createPeerConnectionAnswer().then(function(t){n._firefoxStreamInfo=P.default.matchSDP(e.sdp,t.sdp),n._onRecvRemoteStream(n._mediastream),r(t)}).catch(function(e){i(e)})}).catch(function(e){i(e)}),k.default.isFirefox||n._createPeerConnectionAnswer().then(function(e){r(e)}).catch(function(e){i(e)})})}},{key:"_answer",value:function(e){var t=this,n=h.default.random(32),r=JSON.stringify({jsep:{type:e.type,sdp:e.sdp}});return new Promise(function(e,i){t._signalingListener.addEventListener(n,function(t){e(t)}),g.default.ajaxPost(T.default.AnswerUrl,{appid:t._authInfo.appid,session:t._authInfo.sessionId,callid:t._subscribeId,callee:t._callId,tid:n,server:T.default.serverUrl,token:t._authInfo.token},r).then(function(e){}).catch(function(e){i(e)})})}},{key:"_createPeerConnectionAnswer",value:function(){var e=this;return new Promise(function(t,n){e.conn.createAnswer().then(function(e){e.sdp=P.default.replace42e01fTo42001f(e.sdp),t(e)}).catch(function(e){n(e)})})}},{key:"_iceCandidateByAnswer",value:function(e,t){var n=this,r=h.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.addEventListener(r,function(t){e()},n,!0),g.default.ajaxPost(T.default.ICECandidateUrl,{appid:n._authInfo.appid,session:n._authInfo.sessionId,callid:n._subscribeId,callee:n._callId,tid:r,server:T.default.serverUrl,token:n._authInfo.token},JSON.stringify(i)).then(function(e){}).catch(function(e){t(e)})})}},{key:"_createSubscribeStreams",value:function(){this._subscribeStreams=[];var e={isLargeVideo:!1,isSmallVideo:!1,isScreenShare:!1,isAudio:!1};if(this._configRemoteAudio&&(e.isAudio=this._addAudioToSubscribeStreams()),this._configRemoteScreenTrack&&(e.isScreenShare=this._addScreenToSubscribeStreams()),this._configRemoteCameraTrack){var t=this._addCameraToSubscribeStreams();t===f.default.LargeVideo?e.isLargeVideo=!0:t===f.default.SmallVideo&&(e.isSmallVideo=!0)}return e}},{key:"_addAudioToSubscribeStreams",value:function(){for(var e=0;e<this._streamConfig.length;++e)if("audio"===this._streamConfig[e].type&&"active"===this._streamConfig[e].state)return this._subscribeStreams.push({mslabel:this._streamConfig[e].mslabel,label:this._streamConfig[e].label,type:this._streamConfig[e].type,temporalLayer:0,substream:0}),!0;return!1}},{key:"_addScreenToSubscribeStreams",value:function(){for(var e=0;e<this._streamConfig.length;++e)if("video"===this._streamConfig[e].type&&this._streamConfig[e].label===f.default.ScreenShareVideo&&"active"===this._streamConfig[e].state)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}),!0;return!1}},{key:"_addCameraToSubscribeStreams",value:function(){for(var e=-1,t=-1,n=0;n<this._streamConfig.length;++n)this._streamConfig[n].label===f.default.LargeVideo&&"active"===this._streamConfig[n].state?e=n:this._streamConfig[n].label===f.default.SmallVideo&&"active"===this._streamConfig[n].state&&(t=n);if(e>-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;r<this._streamConfig.length;++r)if("video"===this._streamConfig[r].type&&"active"===this._streamConfig[r].state)return this._subscribeStreams.push({mslabel:this._streamConfig[r].mslabel,label:this._streamConfig[r].label,type:this._streamConfig[r].type,temporalLayer:this._streamConfig[r].temporalLayers-1,substream:this._streamConfig[r].substreams-1}),f.default.LargeVideo;return""}},{key:"_isStreamSubscribed",value:function(e){for(var t=0;t<this._streamConfig.length;++t)if(this._streamConfig[t].label===e&&this._streamConfig[t].subscribed)return!0;return!1}},{key:"_onRecvRemoteStream",value:function(e){var t=this;this._mediastream=e;var n=!1;if(this._subscribeStreams.length){var r=this._mediastream.getVideoTracks();if(!r||0===r.length){n=!0;var i=setInterval(function(){var e=t._mediastream.getVideoTracks();if(e&&e.length)return clearInterval(i),t._subscribeStreams=[],void t._dispatcher.dispatchEvent(m.default.OnMediaStream,t.getUserInfo(),t._mediastream)},10)}n||(this._subscribeStreams=[],this._dispatcher.dispatchEvent(m.default.OnMediaStream,this.getUserInfo(),this._mediastream))}}},{key:"_releaseMonitor",value:function(){this._pcMonitor&&(this._pcMonitor.stopMonitor(),this._pcMonitor=null)}},{key:"_updateStreamsSubscribeState",value:function(e){for(var t=0;t<this._streamConfig.length;++t)"audio"===this._streamConfig[t].type?this._streamConfig[t].subscribed=e.isAudio:this._streamConfig[t].label===f.default.SmallVideo?this._streamConfig[t].subscribed=e.isSmallVideo:this._streamConfig[t].label===f.default.ScreenShareVideo?this._streamConfig[t].subscribed=e.isScreenShare:this._streamConfig[t].label!=f.default.SuperVideo&&(this._streamConfig[t].subscribed=e.isLargeVideo)}},{key:"callId",set:function(e){this._callId=e}},{key:"subscribeId",get:function(){return this._subscribeId}}]),t}(d.default);t.default=D},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(15),u=r(c),d=n(38),l=r(d),f=n(0),p=r(f),h=function(e){function t(e,n){i(this,t);var r=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r._receiverMonitorData=new l.default(n),r}return o(t,e),s(t,[{key:"getMonitorData",value:function(e){return this._receiverMonitorData.getMonitorData(e)}},{key:"_onMonitorTimer",value:function(){var e=this;if(this._peerConnection)if(p.default.isIos||p.default.isAndroid){var t=this._peerConnection.getRemoteStreams();if(t&&t.length){var n=t[0].getAudioTracks()[0];this._peerConnection.getStats(n).then(function(t){e._getAudioInfo(t,n)}).catch(function(e){});var r=t[0].getVideoTracks();if(r)for(var i=0;i<r.length;++i)!function(t){var n=r[t];e._peerConnection.getStats(n).then(function(t){e._getVideoInfo(t,n.id,n)}).catch(function(e){})}(i)}}else!function(){for(var t=e._peerConnection.getReceivers(),n=0;n<t.length;++n)!function(n){t[n].track&&void 0!=t[n].getStats&&t[n].getStats().then(function(r){"audio"===t[n].track.kind?e._getAudioInfo(r,t[n].track):"video"===t[n].track.kind&&e._getVideoInfo(r,t[n].track.id,t[n].track,t[n].getParameters())}).catch(function(e){})}(n)}()}},{key:"_getAudioInfo",value:function(e,t){var n=this;e.forEach(function(e){if(e)switch(e.type){case"certificate":break;case"candidate-pair":n._onAudioCandidatePair(e);break;case"codec":n._onAudioCodec(e);break;case"csrc":case"data-channel":break;case"inbound-rtp":n._onAudioInBoundRtp(e,t);break;case"local-candidate":case"outbound-rtp":case"peer-connection":case"receiver":break;case"remote-candidate":n._onAudioRemoteCandidate(e)}})}},{key:"_getVideoInfo",value:function(e,t,n,r){var i=this;e.forEach(function(e){if(e)switch(e.type){case"candidate-pair":i._onVideoCandidatePair(e,t);break;case"codec":i._onVideoCodec(e,t);break;case"csrc":case"data-channel":break;case"inbound-rtp":i._onVideoInboundRtp(e,n,r,t);break;case"local-candidate":case"outbound-rtp":case"peer-connection":case"receiver":break;case"remote-candidate":i._onAudioRemoteCandidate(e);break;case"remote-inbound-rtp":case"remote-outbound-rtp":case"sender":case"stream":break;case"track":i._onVideoTrack(e,t)}})}},{key:"_onAudioCandidatePair",value:function(e){this._receiverMonitorData.updateCommonInfo(e.timestamp,e.currentRoundTripTime)}},{key:"_onAudioCodec",value:function(e){this._receiverMonitorData.updateAudioCodec(e.clockRate,e.mimeType)}},{key:"_onAudioInBoundRtp",value:function(e,t){this._receiverMonitorData.updateAudioDataReceived(e.timestamp,e.bytesReceived,e.packetsReceived,e.ssrc,e.packetsLost,t)}},{key:"_onAudioRemoteCandidate",value:function(e){this._receiverMonitorData.updateNetworkInfo(e.timestamp,e.ip,e.port,e.protocol,e.networkType)}},{key:"_onVideoCodec",value:function(e,t){this._receiverMonitorData.updateVideoCodec(e.clockRate,e.mimeType,t)}},{key:"_onVideoInboundRtp",value:function(e,t,n,r){this._receiverMonitorData.updateVideoDataReceived(e.timestamp,e.bytesReceived,e.packetsReceived,e.ssrc,e.packetsLost,e.nackCount,e.pliCount,e.firCount,t,n,r)}},{key:"_onVideoTrack",value:function(e,t){this._receiverMonitorData.onVideoTrack(e.timestamp,e.framesReceived,e.frameWidth,e.frameHeight,e.framesDecoded,e.framesDropped,t)}},{key:"_onVideoCandidatePair",value:function(e,t){this._receiverMonitorData.onVideoCandidatePair(e.availableBandwidth,t)}}]),t}(u.default);t.default=h},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(39),s=r(o),c=n(40),u=r(c),d=n(16),l=r(d),f=n(42),p=r(f),h=function(){function e(t){i(this,e),this._callId=t,this._reportData=new p.default(t),this._receiverAudioData=new s.default,this._receiverVideoSmallData=new u.default,this._receiverVideoLargeData=new u.default,this._receiverVideoScreenShareData=new u.default,this._rtt=0,this._ip="",this._port="",this._isAudio=!1}return a(e,[{key:"getMonitorData",value:function(e){this._reportData.rtt=this._rtt,this._reportData.raddr=this._ip+":"+this._port,this._reportData.video=[];for(var t=void 0,n=0;n<e.length;++n)e[n].subscribed&&("audio"===e[n].type?(this._reportData.audio.asrc=this._receiverAudioData.ssrc,this._reportData.audio.isa=this._isAudio,this._reportData.audio.codec=this._receiverAudioData.mimeType,this._reportData.audio.bsps=this._receiverAudioData.bytesReceivedPerSecond):e[n].label===l.default.SmallVideo?(t=this._receiverVideoSmallData.getMonitorData(),t.trackid=l.default.SmallVideo,this._reportData.video.push(t)):e[n].label===l.default.ScreenShareVideo?(t=this._receiverVideoScreenShareData.getMonitorData(),t.trackid=l.default.ScreenShareVideo,this._reportData.video.push(t)):e[n].label!=l.default.SuperVideo&&(t=this._receiverVideoLargeData.getMonitorData(),t.trackid=e[n].label,this._reportData.video.push(t)));return this._reportData}},{key:"updateCommonInfo",value:function(e,t){this._rtt=t}},{key:"updateNetworkInfo",value:function(e,t,n,r,i){this._ip=t,this._port=n,this._protocol=r,this._networkType=i}},{key:"updateAudioCodec",value:function(e,t){this._receiverAudioData.updateAudioCodec(e,t)}},{key:"updateAudioDataReceived",value:function(e,t,n,r,i,a){this._isAudio=a.enabled,this._receiverAudioData.updateDataReceived(e,t,n,r,i)}},{key:"updateVideoCodec",value:function(e,t,n){l.default.SmallVideo===n?this._receiverVideoSmallData.updateVideoCodec(e,t):l.default.ScreenShareVideo===n?this._receiverVideoScreenShareData.updateVideoCodec(e,t):l.default.SuperVideo!==n&&this._receiverVideoLargeData.updateVideoCodec(e,t)}},{key:"updateVideoDataReceived",value:function(e,t,n,r,i,a,o,s,c,u,d){l.default.SmallVideo===d?this._receiverVideoSmallData.updateDataReceived(e,t,n,r,i,a,o,s,c,u):l.default.ScreenShareVideo===d?this._receiverVideoScreenShareData.updateDataReceived(e,t,n,r,i,a,o,s,c,u):l.default.SuperVideo!==d&&this._receiverVideoLargeData.updateDataReceived(e,t,n,r,i,a,o,s,c,u)}},{key:"onVideoTrack",value:function(e,t,n,r,i,a,o){l.default.SmallVideo===o?this._receiverVideoSmallData.onVideoTrack(e,t,n,r,i,a):l.default.ScreenShareVideo===o?this._receiverVideoScreenShareData.onVideoTrack(e,t,n,r,i,a):l.default.SuperVideo!==o&&this._receiverVideoLargeData.onVideoTrack(e,t,n,r,i,a)}},{key:"onVideoCandidatePair",value:function(e,t){l.default.SmallVideo===t?this._receiverVideoSmallData.onVideoCandidatePair(e):l.default.ScreenShareVideo===t?this._receiverVideoScreenShareData.onVideoCandidatePair(e):l.default.SuperVideo!==t&&this._receiverVideoLargeData.onVideoCandidatePair(e)}},{key:"videoSsrc",get:function(){return this._receiverVideoLargeData.isVideo?this._receiverVideoLargeData.ssrc:this._receiverVideoSmallData.isVideo?this._receiverVideoSmallData.ssrc:""}},{key:"isVideo",get:function(){return this._receiverVideoSmallData.isVideo||this._receiverVideoLargeData.isVideo}},{key:"isVideoScreenShare",get:function(){return this._receiverVideoScreenShareData.isVideo}},{key:"videoPacketsLostRate",get:function(){return this._receiverVideoLargeData.isVideo?this._receiverVideoLargeData.packetsLostRate:this._receiverVideoSmallData.isVideo?this._receiverVideoSmallData.packetsLostRate:0}},{key:"videoFrameRate",get:function(){return this._receiverVideoLargeData.isVideo?this._receiverVideoLargeData.frameRate:this._receiverVideoSmallData.isVideo?this._receiverVideoSmallData.frameRate:0}},{key:"videoCodec",get:function(){return this._receiverVideoLargeData.isVideo?this._receiverVideoLargeData.mimeType:this._receiverVideoSmallData.isVideo?this._receiverVideoSmallData.mimeType:this._receiverVideoScreenShareData.mimeType}},{key:"videoNackCount",get:function(){return this._receiverVideoLargeData.isVideo?this._receiverVideoLargeData.nackCount:this._receiverVideoSmallData.isVideo?this._receiverVideoSmallData.nackCount:0}},{key:"videoPliCount",get:function(){return this._receiverVideoLargeData.isVideo?this._receiverVideoLargeData.pliCount:this._receiverVideoSmallData.isVideo?this._receiverVideoSmallData.pliCount:0}},{key:"videoFirCount",get:function(){return this._receiverVideoLargeData.isVideo?this._receiverVideoLargeData.firCount:this._receiverVideoSmallData.isVideo?this._receiverVideoSmallData.firCount:0}},{key:"videoBytesReceivedPerSecond",get:function(){return this._receiverVideoLargeData.isVideo?this._receiverVideoLargeData.bytesReceivedPerSecond:this._receiverVideoSmallData.isVideo?this._receiverVideoSmallData.bytesReceivedPerSecond:0}},{key:"availableBandwidth",get:function(){return this._receiverVideoLargeData.isVideo?this._receiverVideoLargeData.availableBandwidth:this._receiverVideoSmallData.isVideo?this._receiverVideoSmallData.availableBandwidth:this._receiverVideoScreenShareData.isVideo?this._receiverVideoScreenShareData.availableBandwidth:0}}]),e}();t.default=h},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e),this._lastDataReceivedTimeStamp=0,this._bytesReceived=0,this._packetsReceived=0,this._bytesReceivedPerSecond=0,this._packetsReceivedPerSecond=0,this._packetsLost=0,this._packetsLostRate=0,this._ssrc="",this._audioLevel=0,this._clockRate=0,this._mimeType=""}return i(e,[{key:"updateAudioCodec",value:function(e,t){this._mimeType=t?t.replace("audio/",""):"",this._clockRate=e||0}},{key:"updateDataReceived",value:function(e,t,n,r,i){if(this._ssrc=r,this._lastDataReceivedTimeStamp&&this._bytesReceived&&this._packetsReceived){var a=(e-this._lastDataReceivedTimeStamp)/1e3;this._bytesReceivedPerSecond=(t-this._bytesReceived)/a,this._packetsReceivedPerSecond=(n-this._packetsReceived)/a,i>this._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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(41),o=function(e){return e&&e.__esModule?e:{default:e}}(a),s=function(){function e(){r(this,e),this._monitorData=new o.default,this._lastDataReceivedTimeStamp=0,this._bytesReceived=0,this._packetsReceived=0,this._bytesReceivedPerSecond=0,this._packetsReceivedPerSecond=0,this._ssrc="",this._frameRate=0,this._width=0,this._height=0,this._clockRate=0,this._mimeType="",this._isVideo=!1,this._nackCount=0,this._firCount=0,this._pliCount=0,this._frameReceived=0,this._packetsLost=0,this._packetsLostRate=0,this._lastFrameReceivedTimeStamp=0,this._framesReceived=0,this._framesDecoded=0,this._framesDropped=0,this._framesReceivedPerSecond=0,this._framesDecodedPerSecond=0,this._availableBandwidth=0}return i(e,[{key:"getMonitorData",value:function(){return this._monitorData.src=this._ssrc,this._monitorData.fps=this._frameRate,this._monitorData.vrn=this._nackCount,this._monitorData.codec=this._mimeType,this._monitorData.w=this._width,this._monitorData.h=this._height,this._monitorData.vps=this._bytesReceivedPerSecond,this._monitorData}},{key:"updateVideoCodec",value:function(e,t){this._mimeType=t?t.replace("video/",""):"",this._clockRate=e||0}},{key:"updateDataReceived",value:function(e,t,n,r,i,a,o,s,c,u){if(c){var d=c.getSettings();d?(this._frameRate=d.frameRate,this._width=d.width?d.width:0,this._height=d.height?d.height:0):this._frameRate=0}if(this._nackCount=a,this._firCount=s,this._pliCount=o,this._ssrc=r,this._lastDataReceivedTimeStamp&&this._bytesReceived&&this._packetsReceived){var l=(e-this._lastDataReceivedTimeStamp)/1e3;this._bytesReceivedPerSecond=(t-this._bytesReceived)/l,this._packetsReceivedPerSecond=(n-this._packetsReceived)/l,i>this._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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,[{key:"auth",get:function(){return this._auth},set:function(e){this._auth=e}},{key:"availableAuth",get:function(){return!this._availableAuth&&this.auth&&this.auth.length>0&&(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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(0),s=r(o),c=n(1),u=r(c),d=n(45),l=r(d),f=n(46),p=r(f),h=n(47),v=r(h),m=n(9),_=r(m),g=n(48),y=r(g),b=n(49),S=r(b),k=function(){function e(){i(this,e),this._isSupportRTC=!0,this._createDeviceManager(),this._checkRTCSupport()}return a(e,[{key:"checkRTCSupport",value:function(){return this._checkRTCSupport()}},{key:"getPreViewStream",value:function(e){var t=this;return new Promise(function(n,r){t._isSupportRTC?t._deviceManager.getPreViewStream(e).then(function(){n()}).catch(function(e){r(e)}):r({message:"Not support webrtc on this platform"})})}},{key:"getPublishStream",value:function(e){var t=this;return new Promise(function(n,r){t._isSupportRTC?t._deviceManager.getPublishStream(e).then(function(e){n(e)}).catch(function(e){r(e)}):r({message:"Not support webrtc on this platform"})})}},{key:"releasePreviewStream",value:function(){this._deviceManager.releasePreviewStream()}},{key:"releasePublishStream",value:function(){this._deviceManager.releasePublishStream()}},{key:"muteLocalMic",value:function(e){this._deviceManager.muteLocalMic(e)}},{key:"muteLocalCamera",value:function(e){this._deviceManager.muteLocalCamera(e)}},{key:"getDevices",value:function(){return this._deviceManager.getDevices()}},{key:"getAvailableResolutions",value:function(e){return this._deviceManager.getAvailableResolutions(e)}},{key:"_checkRTCSupport",value:function(){var e=this;return new Promise(function(t,n){if(e._isSupportRTC)return void t({message:"支持webrtc"});navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?e._deviceManager.getUserMedia(null,!1).then(function(n){n.getTracks().forEach(function(e){e.stop()}),e._isSupportRTC=!0,t({message:"支持webrtc"})}).catch(function(t){e._isSupportRTC=!1,n({message:"音频或视频设备不可用"})}):(e._isSupportRTC=!1,n({message:"浏览器不支持webrtc"}))})}},{key:"_createDeviceManager",value:function(){s.default.isIos?this._deviceManager=new l.default:s.default.isAndroid?this._deviceManager=new p.default:u.default.isFirefox?this._deviceManager=new v.default:u.default.isSafari?this._deviceManager=new y.default:u.default.isChrome?this._deviceManager=new S.default:this._deviceManager=new _.default}},{key:"configLocalCameraPublish",set:function(e){this._deviceManager.configLocalCameraPublish=e},get:function(){return this._deviceManager.configLocalCameraPublish}},{key:"configLocalScreenPublish",set:function(e){this._deviceManager.configLocalScreenPublish=e},get:function(){return this._deviceManager.configLocalScreenPublish}},{key:"configLocalAudioPublish",set:function(e){this._deviceManager.configLocalAudioPublish=e},get:function(){return this._deviceManager.configLocalAudioPublish}},{key:"currentCamera",set:function(e){this._deviceManager.currentCamera=e}},{key:"currentAudioCapture",set:function(e){this._deviceManager.currentAudioCapture=e}},{key:"videoProfile",set:function(e){this._deviceManager.videoProfile=e}},{key:"audioProfile",set:function(e){this._deviceManager.audioProfile=e}},{key:"streamConfig",get:function(){return{camera:this._deviceManager.configLocalCameraPublish,screen:this._deviceManager.configLocalScreenPublish,audio:this._deviceManager.configLocalAudioPublish}}}]),e}();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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,r)}if("value"in i)return i.value;var o=i.get;if(void 0!==o)return o.call(r)},u=n(17),d=r(u),l=n(2),f=r(l),p=function(e){function t(){i(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._mediaStream=null,e}return o(t,e),s(t,[{key:"getDevices",value:function(){return new Promise(function(e,t){navigator.mediaDevices.enumerateDevices().then(function(t){var n=[],r=[];t.forEach(function(e){"audioinput"==e.kind&&r.push(e)}),n.push({kind:"videoinput",facingMode:"user",label:"前置摄像头"}),n.push({kind:"videoinput",facingMode:"environment",label:"后置摄像头"});var i={videoDevices:n,audioDevices:r};f.default.reportGetDevice(i),e(i)}).catch(function(e){f.default.reportGetDevice(e),t(e)})})}},{key:"getPreViewStream",value:function(e){var t=this;return new Promise(function(n,r){return t._preViewStream?(t._localVideoElement=e,t._setVideoElementAttribute(t._preViewStream),void n()):t._mediaStream?(t._getPreViewStream(),t._localVideoElement=e,t._setVideoElementAttribute(t._preViewStream),void n()):void t._getMediaStream().then(function(r){t._localVideoElement=e,t._mediaStream=r,t._getPreViewStream(),t._setVideoElementAttribute(t._preViewStream),n()}).catch(function(e){t._handleError(e),r(e)})})}},{key:"getPublishStream",value:function(e){var t=this;return new Promise(function(e,n){return t._publishStream?void e(t._publishStream):t._mediaStream?(t._getPublishStream(),void e(t._publishStream)):void t._getMediaStream().then(function(n){t._mediaStream=n,t._getPublishStream(),e(t._publishStream)}).catch(function(e){t._handleError(e),n(e)})})}},{key:"releasePublishStream",value:function(){this._publishStream&&!this._preViewStream&&(this._publishStream.getTracks().forEach(function(e){e.stop()}),this._releaseMediaStream()),this._publishStream=null}},{key:"_checkResolution",value:function(e,t,n,r){var i={video:{width:n,height:r}};t?i.video.facingMode={exact:t}:e&&(i.video.deviceId={exact:e});navigator.mediaDevices.getSupportedConstraints();return 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:"_releasePreviewStream",value:function(){this._preViewStream&&!this._publishStream&&(this._preViewStream.getTracks().forEach(function(e){e.stop()}),this._releaseMediaStream()),this._preViewStream=null}},{key:"_getMediaStream",value:function(e){return navigator.mediaDevices.getUserMedia(this._getConstraints())}},{key:"_getConstraints",value:function(){var e={};return this._cameraInfo.facingMode||this._cameraInfo.deviceId?(e.video={},this._cameraInfo.facingMode?e.video.facingMode={exact:this._cameraInfo.facingMode}:this._cameraInfo.deviceId&&(e.video.deviceId={exact:this._cameraInfo.deviceId}),e.video.width=parseInt(this._videoProfile.width),e.video.height=parseInt(this._videoProfile.height)):(e.video={},e.video.width=parseInt(this._videoProfile.width),e.video.height=parseInt(this._videoProfile.height)),this._audioInfo.deviceId?(e.audio={},Object.assign(e.audio,this._audioInfo)):e.audio=!0,e}},{key:"_getPreViewStream",value:function(){this._preViewStream=this._mediaStream}},{key:"_getPublishStream",value:function(){this._publishStream=new MediaStream;var e=this._mediaStream.getVideoTracks()[0];e.enabled=this._configLocalCameraPublish,this._publishStream.addTrack(e);var t=this._mediaStream.getAudioTracks()[0];t.enabled=this._configLocalAudioPublish,this._publishStream.addTrack(t)}},{key:"_releaseMediaStream",value:function(){this._mediaStream&&this._mediaStream.getTracks().forEach(function(e){e.stop()}),this._mediaStream=null}},{key:"_setVideoElementAttribute",value:function(e){c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_setVideoElementAttribute",this).call(this,e),this._localVideoElement&&(this._localVideoElement.muted=!0)}}]),t}(d.default);t.default=p},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(17),u=r(c),d=n(2),l=r(d),f=function(e){function t(){i(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._videoDeviceMap={},e}return o(t,e),s(t,[{key:"getDevices",value:function(){var e=this;return new Promise(function(t,n){navigator.mediaDevices.enumerateDevices().then(function(n){var r=[],i=[];n.forEach(function(t){"audioinput"==t.kind?i.push(t):"videoinput"===t.kind&&t.label&&(t.label.indexOf("front")>-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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(9),c=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this))}return a(t,e),o(t,[{key:"_checkResolution",value:function(e,t,n,r){var i={audio:!1,video:{width:{exact:n}}};return i.video={width:n,height:r},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)})})}}]),t}(c.default);t.default=u},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(9),c=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this))}return a(t,e),o(t,[{key:"_getPreviewConstraints",value:function(){var e={};return this._cameraInfo.deviceId?e.video={deviceId:{exact:this._cameraInfo.deviceId},width:{ideal:this._videoProfile.width},frameRate:{ideal:this._videoProfile.frameRate}}:e.video={width:{ideal:this._videoProfile.width},frameRate:{ideal:this._videoProfile.frameRate}},e}},{key:"_getPublishConstraints",value:function(){var e={};return this._configLocalCameraPublish?this._cameraInfo.deviceId?e.video={deviceId:{exact:this._cameraInfo.deviceId},width:{ideal:this._videoProfile.width},frameRate:{ideal:this._videoProfile.frameRate}}:e.video={width:{ideal:this._videoProfile.width},frameRate:{ideal:this._videoProfile.frameRate}}:e.video=this._videoProfile,this._audioInfo.deviceId?(e.audio={},Object.assign(e.audio,this._audioInfo)):e.audio=!0,e}},{key:"_checkResolution",value:function(e,t,n,r){var i={audio:!1,video:{width:{ideal:n}}};return e&&(i.video.deviceId={exact:e}),new Promise(function(e,t){navigator.mediaDevices.getUserMedia(i).then(function(t){var i=n,a=r;t.getTracks().forEach(function(e){if("video"===e.kind){var t=e.getSettings();t&&(i=t.width,a=t.height)}e.stop()}),e({width:i,height:a})}).catch(function(e){t(e)})})}}]),t}(c.default);t.default=u},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,r)}if("value"in i)return i.value;var o=i.get;if(void 0!==o)return o.call(r)},u=n(9),d=r(u),l=n(4),f=r(l),p=n(50),h=r(p),v=function(e){function t(){i(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._isScreenSharing=!1,e}return o(t,e),s(t,[{key:"getPublishStream",value:function(e){var n=this;return this._configLocalScreenPublish?new Promise(function(t,r){if(n._publishStream)t(n._publishStream);else{n._publishStream=new MediaStream;var i=!1,a=!1;navigator.mediaDevices.getDisplayMedia({video:{width:1080,height:720,frameRate:10}}).then(function(r){var o=r.getVideoTracks()[0];if(o.onended=function(){e&&e.dispatchEvent(f.default.OnError,h.default.getError(103))},n._publishStream.addTrack(o),a=!0,i)return void t(n._publishStream)}).catch(function(e){n.releasePublishStream(),r(e)}),n._getAudioTrack().then(function(e){if(n._publishStream.addTrack(e),i=!0,a)return void t(n._publishStream)}).catch(function(e){r(e)})}}):(this._isScreenSharing=!1,c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"getPublishStream",this).call(this))}},{key:"releasePublishStream",value:function(){this._configLocalScreenPublish?(this._publishStream&&this._publishStream.getTracks().forEach(function(e){e.stop()}),this._publishStream=null):c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"releasePublishStream",this).call(this)}},{key:"_getMediaStream",value:function(e){return this._configLocalScreenPublish&&!e?this._configLocalAudioPublish?new Promise(function(e,t){var n=new MediaStream,r=!1,i=!1;navigator.mediaDevices.getDisplayMedia({video:{width:1080,height:720,frameRate:5}}).then(function(t){i=!0,n.addTrack(t.getVideoTracks()[0]),r&&e(n)}).catch(function(e){t(e)}),navigator.mediaDevices.getUserMedia({audio:!0}).then(function(t){r=!0,n.addTrack(t.getAudioTracks()[0]),i&&e(n)}).catch(function(e){t(e)})}):navigator.mediaDevices.getDisplayMedia({video:{width:1080,height:720,frameRate:15}}):c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_getMediaStream",this).call(this,e)}},{key:"_getAudioTrack",value:function(){var e=this;return new Promise(function(t,n){navigator.mediaDevices.getUserMedia({audio:!0}).then(function(n){var r=n.getAudioTracks()[0];e._configLocalAudioPublish?r.enabled=!0:r.enabled=!1,t(r)}).catch(function(e){n(e)})})}}]),t}(d.default);t.default=v},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,null,[{key:"getError",value:function(e){var t={code:e};switch(e){case 101:case 102:break;case 103:t.message="screen share error",t.name="device error";break;default:t.message=""}return t}}]),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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(52),s=r(o),c=n(53),u=r(c),d=function(){function e(){i(this,e)}return a(e,null,[{key:"create",value:function(e,t,n,r){return{channel:new u.default(e,t,n),gslb:new s.default(e,t,n,r)}}}]),e}();t.default=d},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(5),u=r(c),d=n(10),l=r(d),f=n(13),p=r(f),h=n(8),v=r(h),m=n(2),_=r(m),g=n(1),y=r(g),b=n(6),S=r(b),k=function(e){function t(e,n,r,o){i(this,t);var s=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r));return s._turn=o,s}return o(t,e),s(t,[{key:"getGslb",value:function(){var e=this;return new Promise(function(t,n){u.default.post(S.default.GslbUrl(e._authInfo.gslb),{appid:e._authInfo.appid,room:e._authInfo.channel,session:e._authInfo.sessionId,userid:e._authInfo.userId,nonce:e._authInfo.nonce,timestamp:e._authInfo.timestamp,token:e._authInfo.token,tokensid:!1}).then(function(n){_.default.init(e._authInfo),S.default.Init(n.slbs,n.servers),e._turn.iceServers=e._changeport(n.routers),t(n)}).catch(function(e){n(e)})})}},{key:"updateAuthInfo",value:function(e){if(e){var t=p.default.create(32);this._authInfo.userId=e.userid,this._authInfo.channel=e.channel,this._authInfo.sessionId=t,this._authInfo.appid=e.appid,this._authInfo.nonce=e.nonce,this._authInfo.timestamp=e.timestamp,this._authInfo.gslb=v.default.prefixAPI(e.gslb),this._authInfo.token=e.token,this._authInfo.publishCallId=v.default.random(32);var n=this._getTurnCredential();this._turn.username=n.username,this._turn.credential=n.credential}}},{key:"_changeport",value:function(e){if(e)for(var t=e.length-1;t>=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+"&timestamp="+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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(8),u=r(c),d=n(5),l=r(d),f=n(10),p=r(f),h=n(1),v=r(h),m=n(14),_=r(m),g=n(12),y=r(g),b=n(6),S=r(b),k=n(0),C=r(k),P=n(20),w=r(P),T=function(e){function t(e,n,r){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r))}return o(t,e),s(t,[{key:"join",value:function(e){var t=this;return new Promise(function(n,r){var i=u.default.random(32);e&&e.addEventListener(i,function(e){n(e)},t,!0),l.default.postBody(S.default.JoinUrl,{appid:t._authInfo.appid,"display-name":t._authInfo.userName,room:t._authInfo.channel,userid:t._authInfo.userId,session:t._authInfo.sessionId,nonce:t._authInfo.nonce,timestamp:t._authInfo.timestamp,token:t._authInfo.token,tid:i,tokensid:!1,server:S.default.serverUrl},t._isNeedSDPUnified()).then(function(t){e&&e.start(0)}).catch(function(e){r(e)})})}},{key:"leave",value:function(){var e=this;return new Promise(function(t,n){var r=u.default.random(32);l.default.post(S.default.LeaveUrl,{appid:e._authInfo.appid,room:e._authInfo.channel,userid:e._authInfo.userId,session:e._authInfo.sessionId,token:e._authInfo.token,tid:r,server:S.default.serverUrl}).then(function(e){t(e)}).catch(function(e){n(e)})})}},{key:"leaveSync",value:function(){try{var e=u.default.random(32);l.default.post(S.default.LeaveUrl,{appid:this._authInfo.appid,room:this._authInfo.channel,userid:this._authInfo.userId,session:this._authInfo.sessionId,token:this._authInfo.token,tid:e,server:S.default.serverUrl}).then(function(e){}).catch(function(e){})}catch(e){}}},{key:"_isNeedSDPUnified",value:function(){var e={sdkagent:"SDK/"+_.default.version+" "+C.default.systemName+"/"+C.default.systemVersion+" UDID/"+y.default.uuid,configure:{WebSDK:v.default.browserName+"-"+v.default.browserVersion,NeedSDPUnified:w.default.supportInfo.needSDPUnified}};return JSON.stringify(e)}}]),t}(p.default);t.default=T},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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(1),s=r(o),c=n(0),u=r(c),d=n(7),l=r(d),f=function(){function e(){i(this,e),this._isSupport=!1,this._checkingstatus=0,this._message="",this._hasAudioDevice=!1,this._hasVideoDevice=!1,this._supportScreenShare=!1,this._supportH264=!1,this._needSDPUnified=!1}return a(e,[{key:"checkStart",value:function(){var e=this;return new Promise(function(t,n){if(e._checkingstatus=1,e._isSupport=!1,e._message="检测中",e._checkSystemInfo(),!(e._isSupport&&e._checkProtocol()&&e._checkApi()))return e._checkingstatus=2,void n(e.checkresult);e._checkDevice().then(function(){e._checkingstatus=2,e._hasAudioDevice&&e._hasVideoDevice?(e._isSupport=!0,e._message="",t(e.checkresult)):(e._isSupport=!1,e._message="缺少摄像头或者麦克风",n(e.checkresult))}).catch(function(t){e._checkingstatus=2,e._isSupport=!1,e._message=t.message,n(e.checkresult)})})}},{key:"_checkProtocol",value:function(){return!!s.default.isHttps||(this._message="必须使用https",this._isSupport=!1,!1)}},{key:"_checkApi",value:function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)||(this._isSupport=!1,this._message="不支持webrtc",!1)}},{key:"_checkDevice",value:function(){var e=this;return new Promise(function(t,n){navigator.mediaDevices.getUserMedia({audio:!0,video:!0}).then(function(r){e._hasAudioDevice=!1,e._hasVideoDevice=!1,r.getTracks().forEach(function(t){"audio"===t.kind?e._hasAudioDevice=!0:"video"===t.kind&&(e._hasVideoDevice=!0)}),e._hasAudioDevice?e._checkSDP(r).then(function(n){e._releaseMediaStream(r),t()}).catch(function(t){e._releaseMediaStream(r),n(t)}):n({message:"没有音频设备"})}).catch(function(e){n(e)})})}},{key:"_releaseMediaStream",value:function(e){e.getTracks().forEach(function(e){e.stop()})}},{key:"_checkSDP",value:function(e){var t=this;return new Promise(function(n,r){var i=new RTCPeerConnection({iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceCandidatePoolSize:0});i.addStream(e),i.createOffer().then(function(e){l.default.supportH264(e.sdp)?(t._supportH264=!0,t._needSDPUnified=l.default.needUnifiedSDPPlan(e.sdp),n()):(t._supportH264=!1,r({message:"不支持H264"}))}).catch(function(e){r(e)})})}},{key:"_checkSystemInfo",value:function(){u.default.isIos?s.default.isSafari?s.default.browserMainVersion<11?(this._isSupport=!1,this._message="iOS上请使用Safari11以上浏览器"):this._isSupport=!0:(this._isSupport=!1,this._message="iOS上支持Safari浏览器"):u.default.isAndroid?s.default.isChrome?s.default.browserMainVersion<63?(this._isSupport=!1,this._message="Android支持Chrome63以上浏览器"):this._isSupport=!0:(this._isSupport=!1,this._message="Android仅支持Chrome浏览器"):u.default.isMacOS?s.default.isSafari?s.default.browserMainVersion<11?(this._isSupport=!1,this._message="MocOS支持Safari11以上的浏览器"):this._isSupport=!0:s.default.isChrome?s.default.browserMainVersion<60?(this._isSupport=!1,this._message="MacOS支持Chrome60以上浏览器"):(this._isSupport=!0,s.default.browserMainVersion>=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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(5),u=r(c),d=n(10),l=r(d),f=n(56),p=r(f),h=n(6),v=r(h),m=function(e){function t(e,n,r){i(this,t);var o=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r));return o._disposed=!1,o._canceled=!1,o._longPollingHandle=null,o._seq=0,o._nosessionIndex=0,o}return o(t,e),s(t,[{key:"cancel",value:function(){this._canceled=!0,this._longPollingHandle&&(clearTimeout(this._longPollingHandle),this._longPollingHandle=null,this._nosessionIndex=0)}},{key:"start",value:function(){var e=this,t=arguments.length>0&&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;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(a.deprecated("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,r.push(o)):r.push(e.iceServers[i])}e.iceServers=r}return new n(e,t)},e.RTCPeerConnection.prototype=n.prototype,Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return n.generateCertificate}})}var r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(e,t,n){var i=this,a=arguments;if(arguments.length>0&&"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;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var a=r(e.parameters.apt,n),o=r(t.parameters.apt,i);return a&&o&&a.name.toLowerCase()===o.name.toLowerCase()};return e.codecs.forEach(function(r){for(var a=0;a<t.codecs.length;a++){var o=t.codecs[a];if(r.name.toLowerCase()===o.name.toLowerCase()&&r.clockRate===o.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&o.parameters.apt&&!i(r,o,e.codecs,t.codecs))continue;o=JSON.parse(JSON.stringify(o)),o.numChannels=Math.min(r.numChannels,o.numChannels),n.codecs.push(o),o.rtcpFeedback=o.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}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}}),n}function s(e,t,n){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(n)}function c(e,t){var n=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 n||e.addRemoteCandidate(t),!n}function u(e,t){var n=new Error(t);return n.name=e,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],n}var d=n(22);e.exports=function(e,t){function n(t,n){n.addTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function l(t,n){n.removeTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}function f(t,n,r,i){var a=new Event("track");a.track=n,a.receiver=r,a.transceiver={receiver:r},a.streams=i,e.setTimeout(function(){t._dispatchEvent("track",a)})}var p=function(n){var r=this,i=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){r[e]=i[e].bind(i)}),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",n=JSON.parse(JSON.stringify(n||{})),this.usingBundle="max-bundle"===n.bundlePolicy,"negotiate"===n.rtcpMuxPolicy)throw u("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(n.rtcpMuxPolicy||(n.rtcpMuxPolicy="require"),n.iceTransportPolicy){case"all":case"relay":break;default:n.iceTransportPolicy="all"}switch(n.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:n.bundlePolicy="balanced"}if(n.iceServers=a(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var o=n.iceCandidatePoolSize;o>0;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<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(n)&&this.localStreams.push(n),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},p.prototype.addStream=function(e){var n=this;if(t>=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;o<n.transceivers.length;o++)if(n.transceivers[o].mid===e.sdpMid){a=o;break}var s=n.transceivers[a];if(!s)return i(u("OperationError","Can not add ICE candidate"));if(s.rejected)return r();var l=Object.keys(e.candidate).length>0?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;p<n.transceivers.length&&(n.transceivers[p].rejected||(n.transceivers[p].iceTransport.addRemoteCandidate({}),t=d.getMediaSections(n._remoteDescription.sdp),t[p]+="a=end-of-candidates\r\n",n._remoteDescription.sdp=d.getDescription(n._remoteDescription.sdp)+t.join(""),!n.usingBundle));p++);r()})},p.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var n=null;if(this.transceivers.forEach(function(e){e.rtpSender&&e.rtpSender.track===t?n=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(n=e.rtpReceiver)}),!n)throw u("InvalidAccessError","Invalid selector.");return n.getStats()}var r=[];return this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){e[t]&&r.push(e[t].getStats())})}),Promise.all(r).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(t){var n=e[t];if(n&&n.prototype&&n.prototype.getStats){var i=n.prototype.getStats;n.prototype.getStats=function(){return i.apply(this).then(function(e){var t=new Map;return Object.keys(e).forEach(function(n){e[n].type=r(e[n]),t.set(n,e[n])}),t})}}});var h=["createOffer","createAnswer"];return h.forEach(function(e){var t=p.prototype[e];p.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then(function(t){"function"==typeof e[0]&&e[0].apply(null,[t])},function(t){"function"==typeof e[1]&&e[1].apply(null,[t])}):t.apply(this,arguments)}}),h=["setLocalDescription","setRemoteDescription","addIceCandidate"],h.forEach(function(e){var t=p.prototype[e];p.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)},function(t){"function"==typeof e[2]&&e[2].apply(null,[t])}):t.apply(this,arguments)}}),["getStats"].forEach(function(e){var t=p.prototype[e];p.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)}}),p}},function(e,t,n){"use strict";e.exports=function(e){var t=e&&e.navigator,n=function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}},r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch(function(e){return Promise.reject(n(e))})}}},function(e,t,n){"use strict";var r=n(3);e.exports={shimGetUserMedia:n(66),shimOnTrack:function(e){"object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.transceiver={receiver:n.receiver},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}}),"object"==typeof 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}}})},shimSourceObject:function(e){"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(e){var t=r.detectBrowser(e);if("object"==typeof e&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){e.RTCPeerConnection||(e.RTCPeerConnection=function(n,r){if(t.version<38&&n&&n.iceServers){for(var i=[],a=0;a<n.iceServers.length;a++){var o=n.iceServers[a];if(o.hasOwnProperty("urls"))for(var s=0;s<o.urls.length;s++){var c={url:o.urls[s]};0===o.urls[s].indexOf("turn")&&(c.username=o.username,c.credential=o.credential),i.push(c)}else i.push(n.iceServers[a])}n.iceServers=i}return new e.mozRTCPeerConnection(n,r)},e.RTCPeerConnection.prototype=e.mozRTCPeerConnection.prototype,e.mozRTCPeerConnection.generateCertificate&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return e.mozRTCPeerConnection.generateCertificate}}),e.RTCSessionDescription=e.mozRTCSessionDescription,e.RTCIceCandidate=e.mozRTCIceCandidate),["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 n=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())};var i=function(e){var t=new Map;return Object.keys(e).forEach(function(n){t.set(n,e[n]),t[n]=e[n]}),t},a={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},o=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(e,n,r){return o.apply(this,[e||null]).then(function(e){if(t.version<48&&(e=i(e)),t.version<53&&!n)try{e.forEach(function(e){e.type=a[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach(function(t,n){e.set(n,Object.assign({},t,{type:a[t.type]||t.type}))})}return e}).then(n,r)}}},shimSenderGetStats:function(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&!(e.RTCRtpSender&&"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(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}},shimReceiverGetStats:function(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&!(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,n=t.apply(e,[]);return n.forEach(function(t){t._pc=e}),n}),r.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}},shimRemoveStream:function(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;r.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(n){n.track&&-1!==e.getTracks().indexOf(n.track)&&t.removeTrack(n)})})},shimRTCDataChannel:function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}}},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=e&&e.MediaStreamTrack,o=function(e){return{name:{InternalError:"NotReadableError",NotSupportedError:"TypeError",PermissionDeniedError:"NotAllowedError",SecurityError:"NotAllowedError"}[e.name]||e.name,message:{"The operation is insecure.":"The request is not allowed by the user agent or the platform in the current context."}[e.message]||e.message,constraint:e.constraint,toString:function(){return this.name+(this.message&&": ")+this.message}}},s=function(e,r,a){var s=function(e){if("object"!=typeof e||e.require)return e;var t=[];return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r=e[n]="object"==typeof e[n]?e[n]:{ideal:e[n]};if(void 0===r.min&&void 0===r.max&&void 0===r.exact||t.push(n),void 0!==r.exact&&("number"==typeof r.exact?r.min=r.max=r.exact:e[n]=r.exact,delete r.exact),void 0!==r.ideal){e.advanced=e.advanced||[];var i={};"number"==typeof r.ideal?i[n]={min:r.ideal,max:r.ideal}:i[n]=r.ideal,e.advanced.push(i),delete r.ideal,Object.keys(r).length||delete e[n]}}}),t.length&&(e.require=t),e};return e=JSON.parse(JSON.stringify(e)),t.version<38&&(i("spec: "+JSON.stringify(e)),e.audio&&(e.audio=s(e.audio)),e.video&&(e.video=s(e.video)),i("ff37: "+JSON.stringify(e))),n.mozGetUserMedia(e,r,function(e){a(o(e))})},c=function(e){return new Promise(function(t,n){s(e,t,n)})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:c,addEventListener:function(){},removeEventListener:function(){}}),n.mediaDevices.enumerateDevices=n.mediaDevices.enumerateDevices||function(){return new Promise(function(e){e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})},t.version<41){var u=n.mediaDevices.enumerateDevices.bind(n.mediaDevices);n.mediaDevices.enumerateDevices=function(){return u().then(void 0,function(e){if("NotFoundError"===e.name)return[];throw e})}}if(t.version<49){var d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=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("The object can not be found here.","NotFoundError");return t},function(e){return Promise.reject(o(e))})}}if(!(t.version>55&&"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;a<e.iceServers.length;a++){var o=e.iceServers[a];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(r.deprecated("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,i.push(o)):i.push(e.iceServers[a])}e.iceServers=i}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in e.RTCPeerConnection&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})},shimTrackEventTransceiver:function(e){"object"==typeof e&&e.RTCPeerConnection&&"receiver"in e.RTCTrackEvent.prototype&&!e.RTCTransceiver&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimCreateOfferLegacy:function(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){var n=this;if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var r=n.getTransceivers().find(function(e){return e.sender.track&&"audio"===e.sender.track.kind});!1===e.offerToReceiveAudio&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveAudio||r||n.addTransceiver("audio"),void 0!==e.offerToReceiveAudio&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var i=n.getTransceivers().find(function(e){return e.sender.track&&"video"===e.sender.track.kind});!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection("sendonly"):"recvonly"===i.direction&&i.setDirection("inactive"):!0!==e.offerToReceiveVideo||i||n.addTransceiver("video")}return t.apply(n,arguments)}}}},function(e,t,n){"use strict";var r=n(22),i=n(3);e.exports={shimRTCIceCandidate:function(e){if(e.RTCIceCandidate&&!(e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&(e=JSON.parse(JSON.stringify(e)),e.candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=r.parseCandidate(e.candidate),a=Object.assign(n,i);return a.toJSON=function(){return{candidate:a.candidate,sdpMid:a.sdpMid,sdpMLineIndex:a.sdpMLineIndex,usernameFragment:a.usernameFragment}},a}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,i.wrapPeerConnectionEvent(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})}},shimCreateObjectURL:function(e){var t=e&&e.URL;if("object"==typeof e&&e.HTMLMediaElement&&"srcObject"in e.HTMLMediaElement.prototype&&t.createObjectURL&&t.revokeObjectURL){var n=t.createObjectURL.bind(t),r=t.revokeObjectURL.bind(t),a=new Map,o=0;t.createObjectURL=function(e){if("getTracks"in e){var t="polyblob:"+ ++o;return a.set(t,e),i.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream"),t}return n(e)},t.revokeObjectURL=function(e){r(e),a.delete(e)};var s=Object.getOwnPropertyDescriptor(e.HTMLMediaElement.prototype,"src");Object.defineProperty(e.HTMLMediaElement.prototype,"src",{get:function(){return s.get.apply(this)},set:function(e){return this.srcObject=a.get(e)||null,s.set.apply(this,[e])}});var c=e.HTMLMediaElement.prototype.setAttribute;e.HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=a.get(arguments[1])||null),c.apply(this,arguments)}}},shimMaxMessageSize:function(e){if(!e.RTCSctpTransport&&e.RTCPeerConnection){var t=i.detectBrowser(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var n=function(e){var t=r.splitSections(e.sdp);return t.shift(),t.some(function(e){var t=r.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})},a=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var n=parseInt(t[1],10);return n!==n?-1:n},o=function(e){var n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n},s=function(e,n){var i=65536;"firefox"===t.browser&&57===t.version&&(i=65535);var a=r.matchPrefix(e.sdp,"a=max-message-size:");return a.length>0?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<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,null,[{key:"install",value:function(e){"function"==typeof e&&e()}}]),e}();t.default=a}]);