/
NIM_Web_WebRTC_v4.1.0_test.js
6 lines (6 loc) · 164 KB
/
NIM_Web_WebRTC_v4.1.0_test.js
1
2
3
4
5
6
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WebRTC=t():e.WebRTC=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}({0:function(e,t,n){"use strict";var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},r=n(92),o=n(151),a=n(168),s=n(67),c=n(160),d=n(161),u=n(162),l=void 0,p=i({},s,{install:function(e,t){r.install(e,t),o.install(e,t),e.parser.mixin({configMap:c,serializeMap:d,unserializeMap:u}),a.install(e,t)},getInstance:function(e){return l||(l=new a(e)),l},destroy:function(){l&&(l.destroy(),l=null)}});e.exports=p},12:function(e,t,n){"use strict";function i(){}function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(){this._events=new i,this._eventsCount=0}var a=Object.prototype.hasOwnProperty,s="~";Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(s=!1)),o.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)a.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e,t){var n=s?s+e:e,i=this._events[n];if(t)return!!i;if(!i)return[];if(i.fn)return[i.fn];for(var r=0,o=i.length,a=new Array(o);r<o;r++)a[r]=i[r].fn;return a},o.prototype.emit=function(e,t,n,i,r,o){var a=s?s+e:e;if(!this._events[a])return!1;var c,d,u=this._events[a],l=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),l){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,r),!0;case 6:return u.fn.call(u.context,t,n,i,r,o),!0}for(d=1,c=new Array(l-1);d<l;d++)c[d-1]=arguments[d];u.fn.apply(u.context,c)}else{var p,h=u.length;for(d=0;d<h;d++)switch(u[d].once&&this.removeListener(e,u[d].fn,void 0,!0),l){case 1:u[d].fn.call(u[d].context);break;case 2:u[d].fn.call(u[d].context,t);break;case 3:u[d].fn.call(u[d].context,t,n);break;case 4:u[d].fn.call(u[d].context,t,n,i);break;default:if(!c)for(p=1,c=new Array(l-1);p<l;p++)c[p-1]=arguments[p];u[d].fn.apply(u[d].context,c)}}return!0},o.prototype.on=function(e,t,n){var i=new r(t,n||this),o=s?s+e:e;return this._events[o]?this._events[o].fn?this._events[o]=[this._events[o],i]:this._events[o].push(i):(this._events[o]=i,this._eventsCount++),this},o.prototype.once=function(e,t,n){var i=new r(t,n||this,!0),o=s?s+e:e;return this._events[o]?this._events[o].fn?this._events[o]=[this._events[o],i]:this._events[o].push(i):(this._events[o]=i,this._eventsCount++),this},o.prototype.removeListener=function(e,t,n,r){var o=s?s+e:e;if(!this._events[o])return this;if(!t)return 0===--this._eventsCount?this._events=new i:delete this._events[o],this;var a=this._events[o];if(a.fn)a.fn!==t||r&&!a.once||n&&a.context!==n||(0===--this._eventsCount?this._events=new i:delete this._events[o]);else{for(var c=0,d=[],u=a.length;c<u;c++)(a[c].fn!==t||r&&!a[c].once||n&&a[c].context!==n)&&d.push(a[c]);d.length?this._events[o]=1===d.length?d[0]:d:0===--this._eventsCount?this._events=new i:delete this._events[o]}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=s?s+e:e,this._events[t]&&(0===--this._eventsCount?this._events=new i:delete this._events[t])):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=s,o.EventEmitter=o,e.exports=o},13:function(e,t,n){var i;(function(e,r){(function(){"use strict";function o(e){return e=String(e),e.charAt(0).toUpperCase()+e.slice(1)}function a(e,t,n){var i={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(i=i[/[\d.]+$/.exec(e)])&&(e="Windows "+i),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),e=c(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}function s(e,t){var n=-1,i=e?e.length:0;if("number"==typeof i&&i>-1&&i<=w)for(;++n<i;)t(e[n],n,e);else d(e,t)}function c(e){return e=f(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:o(e)}function d(e,t){for(var n in e)E.call(e,n)&&t(e[n],n,e)}function u(e){return null==e?o(e):_.call(e).slice(8,-1)}function l(e,t){var n=null!=e?typeof e[t]:"number";return!(/^(?:boolean|number|string|undefined)$/.test(n)||"object"==n&&!e[t])}function p(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function h(e,t){var n=null;return s(e,function(i,r){n=t(n,i,r,e)}),n}function f(e){return String(e).replace(/^ +| +$/g,"")}function m(e){function t(t){return h(t,function(t,n){return t||RegExp("\\b"+(n.pattern||p(n))+"\\b","i").exec(e)&&(n.label||n)})}function n(t){return h(t,function(t,n,i){return t||(n[K]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(K)]||RegExp("\\b"+p(i)+"(?:\\b|\\w*\\d)","i").exec(e))&&i})}function i(t){return h(t,function(t,n){return t||RegExp("\\b"+(n.pattern||p(n))+"\\b","i").exec(e)&&(n.label||n)})}function r(t){return h(t,function(t,n){var i=n.pattern||p(n);return!t&&(t=RegExp("\\b"+i+"(?:/[\\d.]+|[ \\w.]*)","i").exec(e))&&(t=a(t,i,n.label||n)),t})}function o(t){return h(t,function(t,n){var i=n.pattern||p(n);return!t&&(t=RegExp("\\b"+i+" *\\d+[.\\w_]*","i").exec(e)||RegExp("\\b"+i+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(e))&&((t=String(n.label&&!RegExp(i,"i").test(n.label)?n.label:t).split("/"))[1]&&!/[\d.]+/.test(t[0])&&(t[0]+=" "+t[1]),n=n.label||n,t=c(t[0].replace(RegExp(i,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),t})}function s(t){return h(t,function(t,n){return t||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(e)||0)[1]||null})}function v(){return this.description||""}var S=g,b=e&&"object"==typeof e&&"String"!=u(e);b&&(S=e,e=null);var C=S.navigator||{},w=C.userAgent||"";e||(e=w);var A,E,O=b||R==y,k=b?!!C.likeChrome:/\bChrome\b/.test(e)&&!/internal|\n/i.test(_.toString()),I="Object",P=b?I:"ScriptBridgingProxyObject",L=b?I:"Environment",x=b&&S.java?"JavaPackage":u(S.java),M=b?I:"RuntimeObject",D=/\bJava/.test(x)&&S.java,V=D&&u(S.environment)==L,N=D?"a":"α",j=D?"b":"β",U=S.document||{},F=S.operamini||S.opera,B=T.test(B=b&&F?F["[[Class]]"]:u(F))?B:F=null,G=e,H=[],W=null,z=e==w,Y=z&&F&&"function"==typeof F.version&&F.version(),J=t([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),$=i(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"Edge"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt","SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","WebPositive","Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chrome",{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),K=o([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation 3","PlayStation 4","PlayStation Vita","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),Q=n({Apple:{iPad:1,iPhone:1,iPod:1},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{"PlayStation 4":1,"PlayStation 3":1,"PlayStation Vita":1}}),X=r(["Windows Phone","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian","Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);if(J&&(J=[J]),Q&&!K&&(K=o([Q])),(A=/\bGoogle TV\b/.exec(K))&&(K=A[0]),/\bSimulator\b/i.test(e)&&(K=(K?K+" ":"")+"Simulator"),"Opera Mini"==$&&/\bOPiOS\b/.test(e)&&H.push("running in Turbo/Uncompressed mode"),"IE"==$&&/\blike iPhone OS\b/.test(e)?(A=m(e.replace(/like iPhone OS/,"")),Q=A.manufacturer,K=A.product):/^iP/.test(K)?($||($="Safari"),X="iOS"+((A=/ OS ([\d_]+)/i.exec(e))?" "+A[1].replace(/_/g,"."):"")):"Konqueror"!=$||/buntu/i.test(X)?Q&&"Google"!=Q&&(/Chrome/.test($)&&!/\bMobile Safari\b/i.test(e)||/\bVita\b/.test(K))||/\bAndroid\b/.test(X)&&/^Chrome/.test($)&&/\bVersion\//i.test(e)?($="Android Browser",X=/\bAndroid\b/.test(X)?X:"Android"):"Silk"==$?(/\bMobi/i.test(e)||(X="Android",H.unshift("desktop mode")),/Accelerated *= *true/i.test(e)&&H.unshift("accelerated")):"PaleMoon"==$&&(A=/\bFirefox\/([\d.]+)\b/.exec(e))?H.push("identifying as Firefox "+A[1]):"Firefox"==$&&(A=/\b(Mobile|Tablet|TV)\b/i.exec(e))?(X||(X="Firefox OS"),K||(K=A[1])):$&&!(A=!/\bMinefield\b/i.test(e)&&/\b(?:Firefox|Safari)\b/.exec($))||($&&!K&&/[\/,]|^[^(]+?\)/.test(e.slice(e.indexOf(A+"/")+8))&&($=null),(A=K||Q||X)&&(K||Q||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(X))&&($=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(X)?X:A)+" Browser")):X="Kubuntu",Y||(Y=s(["(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|Silk(?!/[\\d.]+$))","Version",p($),"(?:Firefox|Minefield|NetFront)"])),(A="iCab"==J&&parseFloat(Y)>3&&"WebKit"||/\bOpera\b/.test($)&&(/\bOPR\b/.test(e)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(e)&&!/^(?:Trident|EdgeHTML)$/.test(J)&&"WebKit"||!J&&/\bMSIE\b/i.test(e)&&("Mac OS"==X?"Tasman":"Trident")||"WebKit"==J&&/\bPlayStation\b(?! Vita\b)/i.test($)&&"NetFront")&&(J=[A]),"IE"==$&&(A=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e)||0)[1])?($+=" Mobile",X="Windows Phone "+(/\+$/.test(A)?A:A+".x"),H.unshift("desktop mode")):/\bWPDesktop\b/i.test(e)?($="IE Mobile",X="Windows Phone 8.x",H.unshift("desktop mode"),Y||(Y=(/\brv:([\d.]+)/.exec(e)||0)[1])):"IE"!=$&&"Trident"==J&&(A=/\brv:([\d.]+)/.exec(e))&&($&&H.push("identifying as "+$+(Y?" "+Y:"")),$="IE",Y=A[1]),z){if(l(S,"global"))if(D&&(A=D.lang.System,G=A.getProperty("os.arch"),X=X||A.getProperty("os.name")+" "+A.getProperty("os.version")),O&&l(S,"system")&&(A=[S.system])[0]){X||(X=A[0].os||null);try{A[1]=S.require("ringo/engine").version,Y=A[1].join("."),$="RingoJS"}catch(e){A[0].global.system==S.system&&($="Narwhal")}}else"object"==typeof S.process&&!S.process.browser&&(A=S.process)?($="Node.js",G=A.arch,X=A.platform,Y=/[\d.]+/.exec(A.version)[0]):V&&($="Rhino");else u(A=S.runtime)==P?($="Adobe AIR",X=A.flash.system.Capabilities.os):u(A=S.phantom)==M?($="PhantomJS",Y=(A=A.version||null)&&A.major+"."+A.minor+"."+A.patch):"number"==typeof U.documentMode&&(A=/\bTrident\/(\d+)/i.exec(e))&&(Y=[Y,U.documentMode],(A=+A[1]+4)!=Y[1]&&(H.push("IE "+Y[1]+" mode"),J&&(J[1]=""),Y[1]=A),Y="IE"==$?String(Y[1].toFixed(1)):Y[0]);X=X&&c(X)}Y&&(A=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(Y)||/(?:alpha|beta)(?: ?\d)?/i.exec(e+";"+(z&&C.appMinorVersion))||/\bMinefield\b/i.test(e)&&"a")&&(W=/b/i.test(A)?"beta":"alpha",Y=Y.replace(RegExp(A+"\\+?$"),"")+("beta"==W?j:N)+(/\d+\+?/.exec(A)||"")),"Fennec"==$||"Firefox"==$&&/\b(?:Android|Firefox OS)\b/.test(X)?$="Firefox Mobile":"Maxthon"==$&&Y?Y=Y.replace(/\.[\d.]+/,".x"):/\bXbox\b/i.test(K)?(X=null,"Xbox 360"==K&&/\bIEMobile\b/.test(e)&&H.unshift("mobile mode")):!/^(?:Chrome|IE|Opera)$/.test($)&&(!$||K||/Browser|Mobi/.test($))||"Windows CE"!=X&&!/Mobi/i.test(e)?"IE"==$&&z&&null===S.external?H.unshift("platform preview"):(/\bBlackBerry\b/.test(K)||/\bBB10\b/.test(e))&&(A=(RegExp(K.replace(/ +/g," *")+"/([.\\d]+)","i").exec(e)||0)[1]||Y)?(A=[A,/BB10/.test(e)],X=(A[1]?(K=null,Q="BlackBerry"):"Device Software")+" "+A[0],Y=null):this!=d&&"Wii"!=K&&(z&&F||/Opera/.test($)&&/\b(?:MSIE|Firefox)\b/i.test(e)||"Firefox"==$&&/\bOS X (?:\d+\.){2,}/.test(X)||"IE"==$&&(X&&!/^Win/.test(X)&&Y>5.5||/\bWindows XP\b/.test(X)&&Y>8||8==Y&&!/\bTrident\b/.test(e)))&&!T.test(A=m.call(d,e.replace(T,"")+";"))&&A.name&&(A="ing as "+A.name+((A=A.version)?" "+A:""),T.test($)?(/\bIE\b/.test(A)&&"Mac OS"==X&&(X=null),A="identify"+A):(A="mask"+A,$=B?c(B.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(A)&&(X=null),z||(Y=null)),J=["Presto"],H.push(A)):$+=" Mobile",(A=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(e)||0)[1])&&(A=[parseFloat(A.replace(/\.(\d)$/,".0$1")),A],"Safari"==$&&"+"==A[1].slice(-1)?($="WebKit Nightly",W="alpha",Y=A[1].slice(0,-1)):Y!=A[1]&&Y!=(A[2]=(/\bSafari\/([\d.]+\+?)/i.exec(e)||0)[1])||(Y=null),A[1]=(/\bChrome\/([\d.]+)/i.exec(e)||0)[1],537.36==A[0]&&537.36==A[2]&&parseFloat(A[1])>=28&&"WebKit"==J&&(J=["Blink"]),z&&(k||A[1])?(J&&(J[1]="like Chrome"),A=A[1]||(A=A[0],A<530?1:A<532?2:A<532.05?3:A<533?4:A<534.03?5:A<534.07?6:A<534.1?7:A<534.13?8:A<534.16?9:A<534.24?10:A<534.3?11:A<535.01?12:A<535.02?"13+":A<535.07?15:A<535.11?16:A<535.19?17:A<536.05?18:A<536.1?19:A<537.01?20:A<537.11?"21+":A<537.13?23:A<537.18?24:A<537.24?25:A<537.36?26:"Blink"!=J?"27":"28")):(J&&(J[1]="like Safari"),A=A[0],A=A<400?1:A<500?2:A<526?3:A<533?4:A<534?"4+":A<535?5:A<537?6:A<538?7:A<601?8:"8"),J&&(J[1]+=" "+(A+="number"==typeof A?".x":/[.+]/.test(A)?"":"+")),"Safari"==$&&(!Y||parseInt(Y)>45)&&(Y=A)),"Opera"==$&&(A=/\bzbov|zvav$/.exec(X))?($+=" ",H.unshift("desktop mode"),"zvav"==A?($+="Mini",Y=null):$+="Mobile",X=X.replace(RegExp(" *"+A+"$"),"")):"Safari"==$&&/\bChrome\b/.exec(J&&J[1])&&(H.unshift("desktop mode"),$="Chrome Mobile",Y=null,/\bOS X\b/.test(X)?(Q="Apple",X="iOS 4.3+"):X=null),Y&&0==Y.indexOf(A=/[\d.]+$/.exec(X))&&e.indexOf("/"+A+"-")>-1&&(X=f(X.replace(A,""))),J&&!/\b(?:Avant|Nook)\b/.test($)&&(/Browser|Lunascape|Maxthon/.test($)||"Safari"!=$&&/^iOS/.test(X)&&/\bSafari\b/.test(J[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Sleipnir|Web)/.test($)&&J[1])&&(A=J[J.length-1])&&H.push(A),H.length&&(H=["("+H.join("; ")+")"]),Q&&K&&K.indexOf(Q)<0&&H.push("on "+Q),K&&H.push((/^on /.test(H[H.length-1])?"":"on ")+K),X&&(A=/ ([\d.+]+)$/.exec(X),E=A&&"/"==X.charAt(X.length-A[0].length-1),X={architecture:32,family:A&&!E?X.replace(A[0],""):X,version:A?A[1]:null,toString:function(){var e=this.version;return this.family+(e&&!E?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(A=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(G))&&!/\bi686\b/i.test(G)?(X&&(X.architecture=64,X.family=X.family.replace(RegExp(" *"+A),"")),$&&(/\bWOW64\b/i.test(e)||z&&/\w(?:86|32)$/.test(C.cpuClass||C.platform)&&!/\bWin64; x64\b/i.test(e))&&H.unshift("32-bit")):X&&/^OS X/.test(X.family)&&"Chrome"==$&&parseFloat(Y)>=39&&(X.architecture=64),e||(e=null);var q={};return q.description=e,q.layout=J&&J[0],q.manufacturer=Q,q.name=$,q.prerelease=W,q.product=K,q.ua=e,q.version=$&&Y,q.os=X||{architecture:null,family:null,version:null,toString:function(){return"null"}},q.parse=m,q.toString=v,q.version&&H.unshift(Y),q.name&&H.unshift($),X&&$&&(X!=String(X).split(" ")[0]||X!=$.split(" ")[0]&&!K)&&H.push(K?"("+X+")":"on "+X),H.length&&(q.description=H.join(" ")),q}var v={"function":!0,object:!0},g=v[typeof window]&&window||this,y=g,S=v[typeof t]&&t,b=v[typeof e]&&e&&!e.nodeType&&e,C=S&&b&&"object"==typeof r&&r;!C||C.global!==C&&C.window!==C&&C.self!==C||(g=C);var w=Math.pow(2,53)-1,T=/\bOpera/,R=this,A=Object.prototype,E=A.hasOwnProperty,_=A.toString,O=m();g.platform=O,i=function(){return O}.call(t,n,t,e),!(void 0!==i&&(e.exports=i))}).call(this)}).call(t,n(18)(e),function(){return this}())},18:function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}},31:function(e,t){"use strict";var n=!0,i={disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(n=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},log:function(){if("object"==typeof window){if(n)return;"undefined"!=typeof console&&"function"==typeof console.log}},extractVersion:function(e,t,n){var i=e.match(t);return i&&i.length>=n&&parseInt(i[n],10)},detectBrowser:function(){var e={};if(e.browser=null,e.version=null,"undefined"==typeof window||!window.navigator)return e.browser="Not a browser.",e;if(navigator.mozGetUserMedia)e.browser="firefox",e.version=this.extractVersion(navigator.userAgent,/Firefox\/(\d+)\./,1);else if(navigator.webkitGetUserMedia)if(window.webkitRTCPeerConnection)e.browser="chrome",e.version=this.extractVersion(navigator.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!navigator.userAgent.match(/Version\/(\d+).(\d+)/))return e.browser="Unsupported webkit-based browser with GUM support but no WebRTC support.",e;e.browser="safari",e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/(\d+)\./,1)}else if(navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=this.extractVersion(navigator.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!navigator.mediaDevices||!navigator.userAgent.match(/AppleWebKit\/(\d+)\./))return e.browser="Not a supported browser.",e;e.browser="safari",e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/(\d+)\./,1)}return e},shimCreateObjectURL:function(){if("object"==typeof window&&window.HTMLMediaElement&&"srcObject"in window.HTMLMediaElement.prototype){var e=URL.createObjectURL.bind(URL),t=URL.revokeObjectURL.bind(URL),n=new Map,i=0;URL.createObjectURL=function(t){if("getTracks"in t){var r="polyblob:"+ ++i;return n.set(r,t),r}return e(t)},URL.revokeObjectURL=function(e){t(e),n["delete"](e)};var r=Object.getOwnPropertyDescriptor(window.HTMLMediaElement.prototype,"src");Object.defineProperty(window.HTMLMediaElement.prototype,"src",{get:function(){return r.get.apply(this)},set:function(e){return this.srcObject=n.get(e)||null,r.set.apply(this,[e])}});var o=HTMLMediaElement.prototype.setAttribute;HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=n.get(arguments[1])||null),o.apply(this,arguments)}}}};e.exports={log:i.log,disableLog:i.disableLog,browserDetails:i.detectBrowser(),extractVersion:i.extractVersion,shimCreateObjectURL:i.shimCreateObjectURL,detectBrowser:i.detectBrowser.bind(i)}},67:function(e,t){"use strict";t.__esModule=!0;var n,i={NETCALL_TYPE_AUDIO:1,NETCALL_TYPE_VIDEO:2,NETCALL_CONTROL_COMMAND_NOTIFY_AUDIO_ON:1,NETCALL_CONTROL_COMMAND_NOTIFY_AUDIO_OFF:2,NETCALL_CONTROL_COMMAND_NOTIFY_VIDEO_ON:3,NETCALL_CONTROL_COMMAND_NOTIFY_VIDEO_OFF:4,NETCALL_CONTROL_COMMAND_SWITCH_AUDIO_TO_VIDEO:5,NETCALL_CONTROL_COMMAND_SWITCH_AUDIO_TO_VIDEO_AGREE:6,NETCALL_CONTROL_COMMAND_SWITCH_AUDIO_TO_VIDEO_REJECT:7,NETCALL_CONTROL_COMMAND_SWITCH_VIDEO_TO_AUDIO:8,NETCALL_CONTROL_COMMAND_BUSY:9,NETCALL_CONTROL_COMMAND_SELF_CAMERA_INVALID:10,NETCALL_CONTROL_COMMAND_SELF_AUDIO_INVALID:11,NETCALL_CONTROL_COMMAND_SELF_ON_BACKGROUND:12,NETCALL_CONTROL_COMMAND_START_NOTIFY_RECEIVED:13,NETCALL_CONTROL_COMMAND_NOTIFY_RECORD_START:14,NETCALL_CONTROL_COMMAND_NOTIFY_RECORD_STOP:15,DEVICE_TYPE_AUDIO_IN:0,DEVICE_TYPE_AUDIO_OUT_LOCAL:1,DEVICE_TYPE_AUDIO_OUT_CHAT:2,DEVICE_TYPE_VIDEO:3,DEVICE_TYPE_DESKTOP_SCREEN:4,DEVICE_TYPE_DESKTOP_WINDOW:5,CHAT_VIDEO_QUALITY_NORMAL:0,CHAT_VIDEO_QUALITY_LOW:1,CHAT_VIDEO_QUALITY_MEDIUM:2,CHAT_VIDEO_QUALITY_HIGH:3,CHAT_VIDEO_QUALITY_480P:4,CHAT_VIDEO_QUALITY_540P:5,CHAT_VIDEO_QUALITY_720P:6,CHAT_VIDEO_FRAME_RATE_NORMAL:0,CHAT_VIDEO_FRAME_RATE_5:1,CHAT_VIDEO_FRAME_RATE_10:2,CHAT_VIDEO_FRAME_RATE_15:3,CHAT_VIDEO_FRAME_RATE_20:4,CHAT_VIDEO_FRAME_RATE_25:5,LAYOUT_SPLITBOTTOMHORFLOATING:0,LAYOUT_SPLITTOPHORFLOATING:1,LAYOUT_SPLITLATTICETILE:2,LAYOUT_SPLITLATTICECUTTINGTILE:3,LAYOUT_SPLITCUSTOM:4};i.deviceTypeMap=(n={},n[i.DEVICE_TYPE_AUDIO_IN]="audioIn",n[i.DEVICE_TYPE_AUDIO_OUT_CHAT]="audioOut",n[i.DEVICE_TYPE_VIDEO]="video",n),i.getDeviceTypeStr=function(e){return i.deviceTypeMap[e]},t["default"]=i,e.exports=t["default"]},92:function(e,t,n){"use strict";var i=n(114),r={};r.install=function(e){var t=e.fn,n=e.util,r=i({util:n});t.initNetcall=function(e){return n.verifyOptions(e,"type accounts"),e.pushContent="",e.custom="",e.pushConfig||(e.pushConfig={}),e.pushConfig.webrtcEnable=e.webrtcEnable,e.pushConfig=new r(e.pushConfig),this.cbAndSendCmd("initNetcall",e)},t.keepCalling=function(e){return n.verifyOptions(e,"type accounts channelId"),this.cbAndSendCmd("keepCalling",e)},t.calleeAck=function(e){return n.verifyOptions(e,"account channelId type accepted"),this.cbAndSendCmd("calleeAck",e)},t.hangup=function(e){return n.verifyOptions(e,"channelId"),this.cbAndSendCmd("hangup",e)},t.netcallControl=function(e){return n.verifyOptions(e,"channelId type"),this.cbAndSendCmd("netcallControl",e)},t.createChannel=function(e){return this.cbAndSendCmd("createChannel",e)},t.joinChannel=function(e){return n.verifyOptions(e,"channelName"),n.verifyBooleanWithDefault(e,"liveEnable",!1),n.verifyBooleanWithDefault(e,"webrtcEnable",!1),this.cbAndSendCmd("joinChannel",{channelName:e.channelName,liveOption:{liveEnable:e.liveEnable?1:0,webrtcEnable:e.webrtcEnable?1:0}})},t.queryAccountUidMap=function(e,t){return this.cbAndSendCmd("queryAccountUidMap",{channelName:e,uids:t})}},e.exports=r},114:function(e,t){"use strict";function n(e){i(e.enable)&&(this.enable=e.enable?1:0),i(e.needBadge)&&(this.needBadge=e.needBadge?1:0),i(e.needPushNick)&&(this.needPushNick=e.needPushNick?1:0),i(e.pushContent)&&(this.pushContent=""+e.pushContent),i(e.custom)&&(this.custom=""+e.custom),i(e.pushPayload)&&(this.pushPayload=""+e.pushPayload),i(e.sound)&&(this.sound=""+e.sound),i(e.webrtcEnable)&&(this.webrtcEnable=e.webrtcEnable?1:0)}t.__esModule=!0,t["default"]=function(e){var t=e.util;return i=t.notundef,n};var i=void 0;e.exports=t["default"]},151:function(e,t){"use strict";var n={};n.install=function(e){var t=e.Protocol.fn;t.processNetcall=function(e){switch(e.cmd){case"initNetcall":this.onInitNetcall(e);break;case"beCalled":this.onBeCalled(e);break;case"keepCalling":this.onKeepCalling(e);break;case"calleeAck":break;case"notifyCalleeAck":this.onNotifyCalleeAck(e);break;case"hangup":break;case"notifyHangup":this.onNotifyHangup(e);break;case"notifyNetcallControl":this.onNetcallControl(e);break;case"notifyCalleeAckSync":this.onNotifyCalleeAckSync(e);break;case"notifyNetcallRecord":this.onMsg(e);break;case"createChannel":break;case"joinChannel":this.joinChannel(e);break;case"notifyJoin":this.notifyJoin(e)}},t.onInitNetcall=function(e){if(!e.error){var t=e.obj.type;e.obj=e.content,e.obj.type=t,e.obj.accounts=e.obj.keepCallingAccounts,this.setCurrentNetcall(e.obj.channelId),this.keepCalling(e)}},t.setCurrentNetcall=function(e){this.currentNetcallChannelId=e},t.onKeepCalling=function(e){e.error||e.content.accounts.length&&this.keepCalling(e)},t.keepCalling=function(e){var t=this,n=e.obj,i=n.type,r=n.accounts,o=n.channelId;r&&r.length&&setTimeout(function(){t.currentNetcallChannelId&&t.currentNetcallChannelId===o&&t.api.keepCalling({type:i,accounts:r,channelId:o})["catch"](function(){})},3e3)},t.onBeCalled=function(e){e.error||this.emitAPI({type:"beCalled",obj:e.content})},t.onNotifyCalleeAck=function(e){e.error||this.emitAPI({type:"notifyCalleeAck",obj:e.content})},t.onNotifyHangup=function(e){e.error||this.emitAPI({type:"notifyHangup",obj:e.content})},t.onNetcallControl=function(e){e.error||this.emitAPI({type:"netcallControl",obj:e.content})},t.onNotifyCalleeAckSync=function(e){e.error||this.emitAPI({type:"notifyCalleeAckSync",obj:e.content})},t.notifyJoin=function(e){e.error||this.emitAPI({type:"notifyJoin",obj:e.content})},t.joinChannel=function(e){e.obj=e.content}},e.exports=n},160:function(e,t){"use strict";var n=9,i={netcall:{id:n,initNetcall:1,keepCalling:3,calleeAck:4,notifyCalleeAck:5,hangup:6,notifyHangup:7,netcallControl:8,notifyNetcallControl:9,verifyChannelId:10,createChannel:13,joinChannel:14,queryAccountUidMap:16}},r={initNetcall:{sid:n,cid:i.netcall.initNetcall,params:[{type:"byte",name:"type"},{type:"StrArray",name:"accounts"},{type:"String",name:"pushContent"},{type:"String",name:"custom"},{type:"Property",name:"pushConfig"}]},keepCalling:{sid:n,cid:i.netcall.keepCalling,params:[{type:"byte",name:"type"},{type:"StrArray",name:"accounts"},{type:"long",name:"channelId"}]},calleeAck:{sid:n,cid:i.netcall.calleeAck,params:[{type:"string",name:"account"},{type:"long",name:"channelId"},{type:"byte",name:"type"},{type:"bool",name:"accepted"}]},hangup:{sid:n,cid:i.netcall.hangup,params:[{type:"long",name:"channelId"}]},netcallControl:{sid:n,cid:i.netcall.netcallControl,params:[{type:"long",name:"channelId"},{type:"byte",name:"type"}]},verifyChannelId:{sid:n,cid:i.netcall.verifyChannelId,params:[{type:"long",name:"channelId"},{type:"String",name:"account"}]},createChannel:{sid:n,cid:i.netcall.createChannel,params:[{type:"String",name:"channelName"},{type:"String",name:"custom"},{type:"String",name:"webrtcEnable"}]},joinChannel:{sid:n,cid:i.netcall.joinChannel,params:[{type:"String",name:"channelName"},{type:"Property",name:"liveOption"}]},queryAccountUidMap:{sid:n,cid:i.netcall.queryAccountUidMap,params:[{type:"String",name:"channelName"},{type:"LongArray",name:"uids"}]}},o="netcall",a={"9_1":{service:o,cmd:"initNetcall",response:[{type:"Number",name:"timetag"},{type:"Number",name:"uid"},{type:"Number",name:"channelId"},{type:"StrArray",name:"turnServerList"},{type:"StrArray",name:"sturnServerList"},{type:"StrArray",name:"proxyServerList"},{type:"StrArray",name:"keepCallingAccounts"},{type:"StrLongMap",name:"accountUidMap"},{type:"String",name:"clientConfig"},{type:"String",name:"serverMap"}]},"9_2":{service:o,cmd:"beCalled",response:[{type:"Number",name:"timetag"},{type:"Number",name:"type"},{type:"Number",name:"channelId"},{type:"String",name:"account"},{type:"Number",name:"uid"},{type:"StrArray",name:"turnServerList"},{type:"StrArray",name:"sturnServerList"},{type:"StrArray",name:"proxyServerList"},{type:"StrLongMap",name:"accountUidMap"},{type:"String",name:"clientConfig"},{type:"String",name:"custom"},{type:"Property",name:"pushConfig"},{type:"String",name:"serverMap"}]},"9_3":{service:o,cmd:"keepCalling",response:[{type:"StrArr",name:"accounts"}]},"9_4":{service:o,cmd:"calleeAck",response:[]},"9_5":{service:o,cmd:"notifyCalleeAck",response:[{type:"String",name:"account"},{type:"long",name:"channelId"},{type:"byte",name:"type"},{type:"bool",name:"accepted"}]},"9_6":{service:o,cmd:"hangup",response:[]},"9_7":{service:o,cmd:"notifyHangup",response:[{type:"long",name:"channelId"},{type:"String",name:"account"},{type:"long",name:"timetag"}]},"9_8":{service:o,cmd:"netcallControl",response:[]},"9_9":{service:o,cmd:"notifyNetcallControl",response:[{type:"String",name:"account"},{type:"byte",name:"type"},{type:"long",name:"channelId"}]},"9_10":{service:o,cmd:"verifyChannelId",response:[]},"9_11":{service:o,cmd:"notifyNetcallRecord",response:[{type:"Property",name:"msg"}]},"9_12":{service:o,cmd:"notifyCalleeAckSync",response:[{type:"String",name:"timetag"},{type:"long",name:"channelId"},{type:"byte",name:"type"},{type:"bool",name:"accepted"},{type:"byte",name:"fromClientType"}]},"9_13":{service:o,cmd:"createChannel",response:[{type:"long",name:"timetag"}]},"9_14":{service:o,cmd:"joinChannel",response:[{type:"long",name:"timetag"},{type:"long",name:"channelId"},{type:"StrLongMap",name:"accountUidMap"},{type:"String",name:"serverMap"},{type:"String",name:"clientConfig"},{type:"String",name:"custom"}]},"9_15":{service:o,cmd:"notifyJoin",response:[{type:"Long",name:"channelId"},{type:"StrLongMap",name:"accountUidMap"}]},"9_16":{service:o,cmd:"queryAccountUidMap",response:[]}};e.exports={idMap:i,cmdConfig:r,packetConfig:a}},161:function(e,t){"use strict";e.exports={pushConfig:{enable:1,needBadge:2,needPushNick:3,pushContent:4,custom:5,pushPayload:6,sound:7,webrtcEnable:10},liveOption:{liveEnable:1,webrtcEnable:2}}},162:function(e,t){"use strict";e.exports={pushConfig:{1:"enable",2:"needBadge",3:"needPushNick",4:"pushContent",5:"custom",6:"pushPayload",7:"sound",10:"webrtcEnable"},liveOption:{1:"liveEnable",2:"webrtcEnable"}}},163:function(e,t,n){"use strict";!function(){var t=n(31),i=t.log,r=t.browserDetails;e.exports.browserDetails=r,e.exports.extractVersion=t.extractVersion,e.exports.disableLog=t.disableLog;var o=n(194)||null,a=n(196)||null,s=n(199)||null,c=n(201)||null;switch(r.browser){case"chrome":if(!o||!o.shimPeerConnection)return void i("Chrome shim is not included in this adapter release.");i("adapter.js shimming chrome."),e.exports.browserShim=o,o.shimGetUserMedia(),o.shimMediaStream(),t.shimCreateObjectURL(),o.shimSourceObject(),o.shimPeerConnection(),o.shimOnTrack(),o.shimGetSendersWithDtmf();break;case"firefox":if(!s||!s.shimPeerConnection)return void i("Firefox shim is not included in this adapter release.");i("adapter.js shimming firefox."),e.exports.browserShim=s,s.shimGetUserMedia(),t.shimCreateObjectURL(),s.shimSourceObject(),s.shimPeerConnection(),s.shimOnTrack();break;case"edge":if(!a||!a.shimPeerConnection)return void i("MS edge shim is not included in this adapter release.");i("adapter.js shimming edge."),e.exports.browserShim=a,a.shimGetUserMedia(),t.shimCreateObjectURL(),a.shimPeerConnection(),a.shimReplaceTrack();break;case"safari":if(!c)return void i("Safari shim is not included in this adapter release.");i("adapter.js shimming safari."),e.exports.browserShim=c,c.shimOnAddStream(),c.shimGetUserMedia();break;default:i("Unsupported browser!")}}()},167:function(e,t,n){"use strict";function i(e,t,n){this.support=r.WebAudio&&r.MediaStream,this.gain=1,this.stream=e,this.support&&(this.audioIn={},this.uid=t||0,this.isAnalyze=n,this.instant=0,this.slow=0,this.clip=0,this.init())}var r=n(185);i.ac=r.WebAudio&&r.MediaStream?new r.AudioContext:{},i.destination=i.ac.createMediaStreamDestination?i.ac.createMediaStreamDestination():{};var o=i.prototype;o.context=i.ac,o.init=function(){this.validateInput()&&(this.isAnalyze&&this.initMonitor(),this.initWebAudio(),this.initAudioIn())},o.validateInput=function(){var e=this.stream;return/(Array|MediaStream|LocalMediaStream)/.test(e.constructor)},o.initMonitor=function(){var e=this,t=this.script=this.context.createScriptProcessor(0,1,1);t.onaudioprocess=function(t){var n,i=t.inputBuffer.getChannelData(0),r=0,o=0;for(n=0;n<i.length;++n)r+=Math.abs(i[n]),Math.abs(i[n])>.99&&(o+=1);e.instant=Math.sqrt(r/i.length),e.slow=.95*e.slow+.05*e.instant,e.clip=o/i.length}},o.initWebAudio=function(){var e=this.context;this.gainFilter=e.createGain(),this.destination=e.createMediaStreamDestination(),this.gainFilter.gain.value=this.gain,this.gainFilter.connect(this.destination)},o.initAudioIn=function(){function e(e){if(!/(MediaStream|LocalMediaStream)/.test(e.constructor))return null;if(0===e.getAudioTracks().length)return null;var t=r.createMediaStreamSource(e);
return n.isAnalyze&&n.script&&(t.connect(n.script),n.script.connect(n.gainFilter)),t.connect(n.gainFilter),t}var t=this,n=this,i=this.stream,r=this.context,o=void 0;return/(MediaStream|LocalMediaStream)/.test(i.constructor)?(e(i),void(this.outputStream=this.destination.stream)):void(i.constructor===Array&&(i.forEach(function(n){o=e(n),o&&(t.audioIn[n.id]=o)}),this.outputStream=this.destination.stream))},o.addStream=function(e){var t=this.context;if(0!==e.getAudioTracks().length){var n=t.createMediaStreamSource(e);this.isAnalyze&&this.script&&n.connect(this.script),n.connect(this.gainFilter),this.audioIn[e.id]=n,this.outputStream=this.destination.stream}},o.updateStream=function(e){if(this.audioIn)for(var t in this.audioIn)this.audioIn[t]&&this.audioIn[t].disconnect(0),this.audioIn[t]=null;this.audioIn={},this.stream=e,this.initAudioIn()},o.setGain=function(e){this.support&&(this.gainFilter.gain.value=e,this.gain=e)},o.getGain=function(){return this.gain},o.off=function(){return this.setGain(0)},o.on=function(){this.setGain(1)},o.destroy=function(){function e(e){if(e){var t=e.getTracks();!t||0===t.length}}if(this.instant=0,this.slow=0,this.clip=0,this.gainFilter&&this.gainFilter.disconnect(0),this.script&&this.script.disconnect(0),this.audioIn)for(var t in this.audioIn)this.audioIn[t]&&this.audioIn[t].disconnect(0);this.audioIn={};var n=this.stream;/(MediaStream|LocalMediaStream)/.test(n.constructor)||e(n),n.constructor===Array&&n.forEach(function(t){e(t)}),this.stream=null,this.outputStream=null},o.getVolumeData=function(){return this.instant.toFixed(2)},e.exports=i},168:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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)}var a=n(12),s=n(67),c=n(169),d=n(174),u=n(183),l=n(171),p=n(173),h=n(172),f=n(170),m=void 0,v=void 0,g=function(e){function t(n){i(this,t);var o=r(this,e.call(this));return o.setUtil(m),m.merge(o,n),m.rtcLog=o.rtcLog.bind(o),o.init(),o}return o(t,e),t}(a);g.install=function(e){m=e.util,v=v||e.Promise,c.install(e),d.install(e),u.install(e),l.install(e),p.install(e),h.install(e),f.install(e)};var y=g.prototype;y.rtcLog=function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.debug)for(var e=0;e<arguments.length;e++)console&&console.log&&void 0},y.rtcError=function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.debug)for(var e=0;e<arguments.length;e++)console&&console.error&&void 0},y.rtcWarn=function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.debug)for(var e=0;e<arguments.length;e++)console&&console.warn&&void 0},y.init=function(){this.resetStatus(),this.initProtocol(),this.initController(),this.devices={hasAudio:!1,hasVideo:!1}},y.initSignal=function(){return v.resolve()},y.initController=function(){var e=this;window.myContrl=this.controller=new u(this.container,this.remoteContainer,this),this.controller.on("userJoined",this.onUserJoin.bind(this)),this.controller.on("deviceStatus",function(t){e.emit("deviceStatus",t)}),this.controller.on("deviceAdd",function(t){e.emit("deviceAdd",t)}),this.controller.on("deviceRemove",function(t){e.emit("deviceRemove",t)}),this.controller.on("devices",function(t){e.emit("devices",t)}),this.controller.on("statistics",function(t){e.emit("statistics",t)}),this.controller.on("rtcConnectFailed",function(t){e.emit("rtcConnectFailed",t)}),this.controller.on("leaveChannel",function(t){e.emit("leaveChannel",t)}),this.controller.on("audioVolume",function(t){e.emit("audioVolume",t)}),window.addEventListener("beforeunload",this.beforeunload.bind(this))},y.resetStatus=function(){this.signalInited=!1,this.channelId=null,this.type=null,this.target=null,this.sessionConfig=null,this.session_mode=null,this.isCaller=!1,this.callee=null,this.calling=!1,this.callAccepted=!1,this.callerInfo=null,this.beCalledInfo=null,this.nim.protocol.setCurrentNetcall(),this.needQueryAccountMap={}},y.beforeunload=function(){if(this.signalInited){if(this.controller.imInfo&&"meeting"===this.controller.imInfo.session_mode)return void this.leaveChannel();this.hangup()}},y.initProtocol=function(){var e=this.nim;e.on("beCalled",this.onBeCalled.bind(this)),e.on("notifyCalleeAck",this.onCalleeAck.bind(this)),e.on("notifyHangup",this.onHangup.bind(this)),e.on("netcallControl",this.onNetcallControl.bind(this)),e.on("notifyCalleeAckSync",this.onCalleeAckSync.bind(this)),e.on("notifyJoin",this.onNotifyJoin.bind(this))},y.getAccount=function(){return this.nim.account},y.isCurrentChannelId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.channelId&&this.channelId===e.channelId},y.notCurrentChannelId=function(e){return!this.isCurrentChannelId(e)},y.call=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.calling)return v.reject({type:"statusNotMatch"});var t=e.account,n=e.type,i=e.pushConfig,r=e.sessionConfig;return this.calling=!0,this.isCaller=!0,this.callee=this.target=t,r&&(this.setSessionVideoQuality(r.videoQuality),this.setSessionVideoFrameRate(r.videoFrameRate),this.setSessionAudioQuality(r.highAudio)),this.initNetcall({type:n,pushConfig:i})},y.initNetcall=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.type,i=t.pushConfig;return this.type=n,this.nim.initNetcall({type:n,accounts:[this.callee],pushConfig:i,webrtcEnable:!0}).then(function(t){e.rtcLog("initNetcall:",t),e.callerInfo=t,e.channelId=t.channelId},function(t){throw e.resetWhenHangup(),t})},y.onBeCalled=function(e){this.log("beCalling",e),this.emit("beCalling",e)},y.onUserJoin=function(e){if(this.rtcLog("cliet on userJoined",e),e.type=e.type||this.type,e.account=this.getAccountWithUid(e.uid),e.mode=this.session_mode,e.account!==this.getAccount()){if(e.account)return void this.emit("joinChannel",e);this.needQueryAccountMap[e.uid]=e,this.nim.queryAccountUidMap(this.channelName,[e.uid])}},y.response=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.beCalledInfo,i=n.accepted=t.accepted!==!1;return i?(this.type=n.type,this.channelId=n.channelId,this.target=n.account,this.calling=!0):(this.log("rejectNetcall",n),this.packNetcallRecord({type:n.type,channelId:n.channelId,isCaller:!1,target:n.account,recordType:"rejectNetcall"})),this.nim.calleeAck(n).then(function(){if(i)return t.sessionConfig&&e.setSessionConfig(t.sessionConfig),e.beCalledInfo=n,e.initSession({beCalledInfo:n})},function(t){throw e.log(t),t})},y.initSession=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.session_mode="p2p";var n=this.isCaller?this.callerInfo:t.beCalledInfo;this.parseAccountUidMap(n.accountUidMap),!n.account&&n.uid&&(n.account=this.getAccountWithUid(n.uid)),this.callAccepted=!0,this.signalInited=!0,setTimeout(function(){e.emit("callAccepted",{type:n.type,account:n.account})},1)},y.startRtc=function(){var e=this.session_mode=this.session_mode||"p2p",t="meeting"===e?this.meetingInfo:this.isCaller?this.callerInfo:this.beCalledInfo;t.session_mode=e;var n=this.controller.startRtc(t);return n},y.onCalleeAck=function(e){if(!this.notCurrentChannelId(e)){if(e.accepted)return this.callAccepted=!0,this.initSession();this.log("netcallRejected",e),this.packNetcallRecord({type:e.type,channelId:e.channelId,isCaller:!0,target:e.account,recordType:"netcallRejected"});var t=e.account;this.resetWhenHangup(),this.emit("callRejected",{account:t})}},y.onNetcallControl=function(e){this.emit("control",e)},y.netDetect=function(){return this.signalInited?this.signal.netDetect():this.rejectWithNoSignal()},y.rejectWithNoSignal=function(){return this.resetWhenHangup(),v.reject({code:"noConnection"})},y.onCalleeAckSync=function(e){this.emit("callerAckSync",e),this.isCurrentChannelId(e)&&this.resetWhenHangup()},y.onNotifyJoin=function(e){var t=e.accountUidMap,n=this.needQueryAccountMap;this.parseAccountUidMap(t);for(var i in t){var r=i,o=t[i];if(o in n){var a=n[o];a.account=r,delete n[o],this.emit("joinChannel",a)}}},y.onHangup=function(e){this.emit("hangup",e),this.isCurrentChannelId(e)&&this.resetWhenHangup()},y.hangup=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.channelId;!t&&this.calling&&this.channelId&&(t=this.channelId),t&&this.nim.hangup({channelId:t}),t===this.channelId&&(this.isCaller&&!this.callAccepted&&(this.log("cancelNetcallBeforeAccept",{channelId:t}),this.packNetcallRecord({recordType:"cancelNetcallBeforeAccept"})),this.resetWhenHangup())},y.packNetcallRecord=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.recordType,n=m.exist(e.type)?e.type:this.type,i=m.exist(e.channelId)?e.channelId:this.channelId,r=m.exist(e.duration)?e.duration:0,o=m.exist(e.isCaller)?e.isCaller:this.isCaller,a=m.exist(e.target)?e.target:this.target,s=this.getAccount(),c=o?s:a,d=o?a:s,u=+new Date;this.nim.protocol.onMsg({content:{msg:{attach:JSON.stringify({data:{calltype:n,channel:i,duration:r,ids:[s,a],time:u},id:t}),from:c,fromClientType:o?16:0,fromDeviceId:"",fromNick:"",idClient:m.guid(),idServer:m.guid(),scene:0,time:u,to:d,type:5}}})},y.resetWhenHangup=function(){this.resetStatus(),this.controller.hangup()},y.control=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.command,i=t.channelId;if(i||(i=this.channelId),n&&i)return this.nim.netcallControl({channelId:i,type:n})["catch"](function(t){e.log(t)})},y.startRecordMp4=function(e){return this.controller.startRecordMp4(e)},y.stopRecordMp4=function(){return this.controller.stopRecord()},y.startRecordAac=function(){return this.controller.startRecordAac()},y.stopRecordAac=function(){return this.controller.stopRecord()},y.setVideoViewSize=function(e){return this.controller.setVideoViewSize(e)},y.setVideoViewRemoteSize=function(e){return this.controller.setVideoViewRemoteSize(e)},y.startLocalStream=function(e){return this.controller.startLocalStream(e)},y.stopLocalStream=function(){return this.controller.stopLocalStream()},y.startRemoteStream=function(e){return this.controller.startRemoteStream(e)},y.stopRemoteStream=function(e){return this.controller.stopRemoteStream(e)},y.suspendLocalStream=function(){return this.controller.suspendLocalStream()},y.resumeLocalStream=function(){return this.controller.resumeLocalStream()},y.suspendRemoteStream=function(e){return this.controller.suspendRemoteStream(e)},y.resumeRemoteStream=function(e){return this.controller.resumeRemoteStream(e)},y.setAudioStart=function(e){return this.controller.setAudioStart(e)},y.setAudioBlack=function(e){return this.controller.setAudioBlack(e)},y.setVideoBlack=function(e){return this.controller.setVideoBlack(e)},y.setVideoShow=function(e){return this.controller.setVideoShow(e)},y.switchVideoToAudio=function(){var e=this;return this.controller.switchVideoToAudio().then(function(){return e.type=s.NETCALL_TYPE_AUDIO,v.resolve()})["catch"](function(e){return v.resolve(e)})},y.switchAudioToVideo=function(){var e=this;return this.controller.switchAudioToVideo().then(function(){return e.type=s.NETCALL_TYPE_VIDEO,v.resolve()})["catch"](function(e){return v.resolve(e)})},y.stopDevice=function(e){return this.controller.stopDevice(e)},y.startDevice=function(e){return this.devices=m.merge({},this.controller.getDeviceStatus()),this.controller.startDevice(e)},y.getDevicesOfType=function(e){return this.controller.mediaDevices.getDevicesOfType(e).then(function(e){return{devices:e}})},y.setSessionConfig=function(e){this.controller.setSessionConfig(e)},y.setSessionVideoQuality=function(e){this.controller.setSessionVideoQuality(e)},y.setSessionVideoFrameRate=function(e){this.controller.setSessionVideoFrameRate(e)},y.setSessionAudioQuality=function(e){this.controller.setSessionAudioQuality(e)},y.setCaptureVolume=function(e){return e=void 0===e?1:e/255,this.controller.setCaptureVolume(e)},y.setPlayVolume=function(e){return e.constructor===Number&&(e={volume:e}),e.volume=void 0===e.volume?1:e.volume/255,e.volume=e.volume>1?1:e.volume,this.controller.setPlayVolume(e)},y.log=function(){var e=this.nim.logger;e.log.apply(e,arguments)},y.info=function(){var e=this.nim.logger;e.info.apply(e,arguments)},y.parseAccountUidMap=function(e){var t=this;Object.keys(e).forEach(function(n){t.addAccountUidMap({account:n,uid:e[n]})})},y.addAccountUidMap=function(e){var t=e.account,n=e.uid;this.uidAccountMap||(this.uidAccountMap={}),this.uidAccountMap[n]=t,this.accountUidMap||(this.accountUidMap={}),this.accountUidMap[t]=n},y.getAccountWithUid=function(e){if(this.uidAccountMap)return this.uidAccountMap[e]},y.getUidWithAccount=function(e){if(this.accountUidMap)return this.accountUidMap[e]},y.destroy=function(){},e.exports=g,n(182)},169:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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)}n(163);var a=n(12),s=n(67),c=void 0,d=void 0,u=function(e){function t(){i(this,t);var n=r(this,e.call(this));return n.init(),n}return o(t,e),t}(a);u.install=function(e){c=e.Promise,d=e.util};var l=u.prototype;l.init=function(){var e=this;this.getDevices();var t=void 0;navigator.mediaDevices&&navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",function(n){t&&(clearTimeout(t),t=null);var i=d.merge({},e.devicesCache);t=setTimeout(function(){t=null,e.getDevices(!0).then(function(){e.emit("deviceStatus",e.devicesCache),e.filterDeviceChange(e.devicesCache,i)})["catch"](function(){})},500)})},l.filterDeviceChange=function(e,t){function n(e){var t={};return Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[n+e.deviceId]=Object.assign({},e,{type:n})})}),t}var i=this,r=n(e),o=n(t),a=Object.keys(r),s=Object.keys(o);a.length>s.length?!function(){var e=[];a.forEach(function(t){s.indexOf(t)===-1&&e.push(r[t])}),e.length&&i.emit("deviceAdd",e)}():!function(){var e=[];s.forEach(function(t){a.indexOf(t)===-1&&e.push(o[t])}),e.length&&i.emit("deviceRemove",e)}()},l.getDevicesOfType=function(e){var t,n=(t={},t[s.DEVICE_TYPE_AUDIO_IN]="audioIn",t[s.DEVICE_TYPE_AUDIO_OUT_LOCAL]="audioOut",t[s.DEVICE_TYPE_AUDIO_OUT_CHAT]="audioOut",t[s.DEVICE_TYPE_VIDEO]="video",t);return void 0!==n[e]?this.getDevices().then(function(t){return t[n[e]]}):this.getDevices()},l.getDevices=function(e){var t=this;return!e&&this.devicesCache?c.resolve(this.devicesCache):new c(function(e,n){return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?void navigator.mediaDevices.enumerateDevices().then(function(n){var i={video:[],audioIn:[],audioOut:[]};return n.forEach(function(e){"videoinput"===e.kind?i.video.push({deviceId:e.deviceId,label:e.label?e.label:"camera "+(i.video.length+1)}):"audioinput"===e.kind?i.audioIn.push({deviceId:e.deviceId,label:e.label?e.label:"microphone "+(i.audioIn.length+1)}):"audiooutput"===e.kind&&i.audioOut.push({deviceId:e.deviceId,label:e.label?e.label:"speaker "+(i.audioOut.length+1)})}),t.devicesCache=i,e(i)})["catch"](function(e){return n(e)}):n(new Error("your browser not support this feature, see https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices"))})},l.getDeviceStatus=function(){return{hasAudio:this.devicesCache.audioIn.length>0,hasVideo:this.devicesCache.video.length>0}},e.exports=u},170:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=void 0,o=void 0,a=n(167),s=function d(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{type:"video"};if(i(this,d),!t.account)return r.reject("需要录制的帐号缺失");if(!e)return r.reject("获取视频流失败");if(!window.MediaRecorder||!MediaRecorder.isTypeSupported)return r.reject("当前浏览器不支持音视频录制功能");this.recordedChunks=[],this.isRecording=!1,this.stream=e,this.option=t;var n=["video/mp4;codecs=avc1","video/webm","video/webm;codecs=vp8","video/x-matroska;codecs=avc1","video/invalid"];"audio"===t.type&&(n=["audio/wav","audio/ogg","audio/pcm","audio/webm"]);var o=this.mimeType=this.validation(n)[0];return o?this.start():r.reject("当前浏览器不支持对应格式的视频录制")};s.install=function(e){r=e.Promise,o=e.util};var c=s.prototype;c.validation=function(e){return e.filter(function(e){return MediaRecorder.isTypeSupported(e)})},c.format=function(){var e=this,t=this.stream,n=this.option;return new r(function(i,r){if(/(LocalMediaStream|MediaStream)/.test(t.constructor)&&(t=[t]),t.constructor!==Array)return r("音视频录制输入错误");if("audio"===n.type)return e.audioController=new a(t,e.uid),e.opStream=e.audioController.outputStream,i();var o=new MediaStream;return t.forEach(function(e){e&&/(LocalMediaStream|MediaStream)/.test(e.constructor)&&e.getTracks().forEach(function(e){o.addTrack(e)})}),0===o.getTracks().length?r("当前没有任何音视频数据,无法进行录制"):(e.opStream=o,void i())})},c.start=function(){var e=this;if(this.isRecording)return r.reject("音视频正在录制中,请勿重复操作");var t={audioBitsPerSecond:128e3,videoBitsPerSecond:25e5,mimeType:this.mimeType};return this.format().then(function(){var n=e.recorder=new MediaRecorder(e.opStream,t);return n.ondataavailable=e.ondataavailable.bind(e),n.onstop=e.onstop.bind(e),e.recorder.start(),e.startTimer(),r.resolve(e)})["catch"](function(e){return r.reject(e)})},c.stop=function(e){if(o.rtcLog("MediaRecorder: stop event",this.recorder.state),"inactive"===this.recorder.state)return r.reject("音视频录制已结束,请勿重复操作");var t=this.option.account+"--"+Date.now()+"--"+(this.option.type||"video");return this.fileName=e||t,this.recorder?(this.recorder&&this.recorder.stop(),r.resolve()):r.reject("音视频录制已结束,请勿重复操作")},c.ondataavailable=function(e){return o.rtcLog("MediaRecorder: data received"),e.data.size>0?void this.recordedChunks.push(e.data):(this.stop(),r.reject("获取视频流失败"))},c.onstop=function(){o.rtcLog("MediaRecorder: onstop");var e=new Blob(this.recordedChunks,{type:this.mimeType}),t=URL.createObjectURL(e),n=document.createElement("a");document.body.appendChild(n),n.style="display: none",n.href=t,n.download=this.fileName+".webm",n.click(),window.URL.revokeObjectURL(t),this.destroy(),this.clearTimer()},c.pause=function(){this.recorder&&this.recorder.pause()},c.resume=function(){this.recorder&&this.recorder.resume()},c.destroy=function(){this.stream=null,this.recorder=null,this.recordedChunks=[],this.audioController&&this.audioController.destroy(),this.audioController=null},c.startTimer=function(){var e=this;this.timer||(this.timer=setInterval(function(){o.rtcLog("MediaRecorder status:",e.recorder.state)},2e3))},c.clearTimer=function(){this.timer&&clearInterval(this.timer)},t["default"]=s,e.exports=t["default"]},171:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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)}n(163);var a=window.sdpTransform=n(190),s=n(12),c=n(172),d=n(184),u=window.Promise,l=void 0,p=function(e){function t(n){i(this,t);var o=r(this,e.call(this));return o.init(),o.controller=n,o}return o(t,e),t}(s);p.install=function(e){u=u||e.Promise,l=e.util};var h=p.prototype;h.resetStatus=function(){this.isSdpUpdate=!1,this.sdpOffer=null,this.sdpAnswer=null,this.iceOffer=[],this.iceAnswer=[]},h.init=function(){var e=this;this.resetStatus();var t=this.rtcConnection=new RTCPeerConnection;t.onaddstream=this.onRemoteStream.bind(this),t.ontrack=this.onRemoteTrack.bind(this),t.onremovestream=function(e){},t.onicecandidate=function(e){var t=this;if(e.candidate){if(/ tcp /gi.test(e.candidate.candidate))return;this.iceOffer.push(e.candidate)}else setTimeout(function(){if(t.sdpAnswer){var e=t.iceOffer;e.length>0&&!t.iceCompleted&&e.forEach(function(e){t.emit("iceCandidate",e)})}},500),l.rtcLog("onicecandidate end")}.bind(this),t.onnegotiationneeded=function(e){l.rtcLog("onnegotiationneeded"),this.emit("negotiationneeded",e)}.bind(this),t.oniceconnectionstatechange=function(){this.emit("iceconnectionstatechange",t.iceConnectionState)}.bind(this),this.stats=new c(t,1e4);var n=0;this.stats.on("rtcStats",function(t){e.emit("rtcStats",t),n<=3&&l.rtcLog(t),n++})},h.onRemoteStream=function(e){return l.rtcLog("get remote stream",e.stream),!e.stream||e.stream&&"default"===e.stream.id?l.rtcLog("remote stream is default stream, do nothing"):void this.emit("getRemoteStream",e.stream)},h.onRemoteTrack=function(e){},h.getIceConnectionState=function(){if(this.rtcConnection)return this.rtcConnection.iceConnectionState},h.addStream=function(e){if(e){e.stream&&(e=e.stream);var t,n,i,r,o=this.rtcConnection,a=this.stream;i=e.getAudioTracks()[0],r=e.getVideoTracks()[0];var s=o.getLocalStreams();if(s=s.length>0?s[0]:null,l.rtcLog("当前rtc轨道数目",s&&s.id,s&&s.getTracks().length),s&&s.getTracks().forEach(function(e){l.rtcLog("更新前轨道id:",e.kind+":"+e.id)}),!a)return this.addAudioTrack(e),this.addVideoTrack(e),s=o.getLocalStreams(),s=s.length>0?s[0]:null,l.rtcLog("更新后rtc轨道数目",s&&s.id,s&&s.getTracks().length),void(s&&s.getTracks().forEach(function(e){l.rtcLog(" > 轨道id:",e.kind+":"+e.id)}));t=a&&a.getAudioTracks()[0],n=a&&a.getVideoTracks()[0],i=e.getAudioTracks()[0],r=e.getVideoTracks()[0],t||i&&this.addAudioTrack(e),n||r&&this.addVideoTrack(e),t&&(i?i!==t&&this.updateAudioTrack(e):this.removeAudioTrack()),n&&(r?r!==n&&this.updateVideoTrack(e):this.removeVideoTrack()),s=o.getLocalStreams(),s=s.length>0?s[0]:null,l.rtcLog("更新后rtc轨道数目",s&&s.id,s&&s.getTracks().length),s&&s.getTracks().forEach(function(e){l.rtcLog(" > 轨道id:",e.kind+":"+e.id)})}},h.removeVideoTrack=function(){var e=this.rtcConnection,t=this.stream;if(t){var n=t.getVideoTracks()[0],i=!!navigator.mozGetUserMedia;if(!n)return u.reject(new Error("no video track"));if(t.removeTrack(n),i){for(var r=void 0,o=e.getSenders(),a=Array.isArray(o),s=0,o=a?o:o[Symbol.iterator]();;){if(a){if(s>=o.length)break;r=o[s++]}else{if(s=o.next(),s.done)break;r=s.value}if(r.track===n)break}e.removeTrack(r)}}},h.addVideoTrack=function(e){var t=this.rtcConnection,n=this.stream,i=n,r=e.getVideoTracks()[0],o=!!navigator.mozGetUserMedia;if(r)if(n||(n=new MediaStream,this.stream=n),n.addTrack(r),o){var a=t.addTrack(r,n),s=this.controller.getVideoSessionConfig(),c={maxFramerate:s.frameRate,scaleResolutionDownBy:2};a.setParameters({encodings:[c]})}else!i&&t.addStream(n)},h.updateVideoTrack=function(e){var t=this.rtcConnection,n=this.stream;if(n){var i=!!navigator.mozGetUserMedia;if(!i)return this.removeVideoTrack(!0),this.addVideoTrack(e);for(var r=e.getVideoTracks()[0],o=n.getVideoTracks()[0],a=void 0,s=t.getSenders(),c=Array.isArray(s),d=0,s=c?s:s[Symbol.iterator]();;){if(c){if(d>=s.length)break;a=s[d++]}else{if(d=s.next(),d.done)break;a=d.value}if(a.track===o)break}a.replaceTrack(r),n.removeTrack(o),n.addTrack(r)}},h.removeAudioTrack=function(){var e=this.rtcConnection,t=this.stream,n=t.getAudioTracks()[0],i=!!navigator.mozGetUserMedia;if(!n)return u.reject(new Error("no audio track"));if(t.removeTrack(n),i){for(var r=void 0,o=e.getSenders(),a=Array.isArray(o),s=0,o=a?o:o[Symbol.iterator]();;){if(a){if(s>=o.length)break;r=o[s++]}else{if(s=o.next(),s.done)break;r=s.value}if(r.track===n)break}e.removeTrack(r)}},h.addAudioTrack=function(e){var t=this.rtcConnection,n=this.stream,i=n,r=!!navigator.mozGetUserMedia,o=e.getAudioTracks()[0];o&&(n||(n=new MediaStream,this.stream=n),n.addTrack(o),r?t.addTrack(o,n):!i&&t.addStream(n))},h.updateAudioTrack=function(e){var t=this.rtcConnection,n=this.stream,i=!!navigator.mozGetUserMedia;if(n){if(!i)return this.removeAudioTrack(!0),this.addAudioTrack(e);for(var r=e.getAudioTracks()[0],o=n.getAudioTracks()[0],a=void 0,s=t.getSenders(),c=Array.isArray(s),d=0,s=c?s:s[Symbol.iterator]();;){if(c){if(d>=s.length)break;a=s[d++]}else{if(d=s.next(),d.done)break;a=d.value}if(a.track===o)break}a.replaceTrack(r),n.removeTrack(o),n.addTrack(r)}},h.removeStream=function(e){e&&(e.stream&&(e=e.stream),this.rtcConnection.removeStream(e))},h.createAnswer=function(e){return this.rtcConnection.createAnswer().then(function(e){return e.sdp=d.maybePreferVideoReceiveCodec(e.sdp,{videoRecvCodec:"H264"}),e=this.filterLocalDescription(e)}.bind(this))["catch"](function(e){l.rtcLog(e)})},h.createOffer=function(){var e=this,t={offerToReceiveAudio:1,offerToReceiveVideo:1};delete this.rtcConnection.localDescription;var n=new u(function(n,i){e.rtcConnection.createOffer(t).then(function(e){this.resetStatus(),e.sdp=d.maybePreferVideoReceiveCodec(e.sdp,{videoRecvCodec:"H264"}),e=this.filterLocalDescription(e),n(e)}.bind(e))["catch"](function(e){i(e)})});return n},h.checkMediaStatus=function(e,t){var n={audio:!1,video:!1},i=a.parse(t);return i.media.forEach(function(e,t){"audio"===e.type&&(n.audio=!!e.ssrcs),"video"===e.type&&(n.video=!!e.ssrcs)}),n},h.filterLocalDescription=function(e){var t=this,n=this.controller.imInfo.uid,i=this.controller.imInfo.channelId,r=e.sdp,o=a.parse(r),s=this.rtcConnection.getLocalStreams();s=s[0]||new MediaStream;var c=s.getAudioTracks()[0],d=s.getVideoTracks()[0],u=void 0;return o.media&&o.media.forEach(function(r,a){if("audio"===r.type&&(u=r,!c&&delete r.ssrcs&&delete r.ssrcGroups&&delete r.msid),"video"===r.type&&(!d&&delete r.ssrcs&&delete r.ssrcGroups&&delete r.msid,u&&u.msid&&r.msid)){var s=u.msid.split(" "),l=r.msid.split(" ");l[0]=s[0],r.msid=l.join(" ")}navigator.mozGetUserMedia?r.bandwidth=[{type:"TIAS",limit:800}]:r.bandwidth=[{type:"AS",limit:800}],r.iceUfrag&&(r.iceUfrag=i+"/"+n),"audio"===r.type&&(r.ptime=60,r.maxptime=60,r.fmtp&&r.fmtp.length&&!function(){var e=!1,n=t.controller.sessionConfig.highAudio?48e3:16e3;if(r.fmtp.forEach(function(t){t.config&&t.config.indexOf("minptime=")!==-1&&(t.config=t.config.replace(/minptime=\d+/,"minptime=60")),t.config&&t.config.indexOf("sprop-maxcapturerate=")!==-1&&t.config.indexOf("maxplaybackrate")!==-1&&(e=!0,t.config=t.config.replace(/sprop-maxcapturerate=\d+/,"sprop-maxcapturerate="+n),t.config=t.config.replace(/maxplaybackrate=\d+/,"maxplaybackrate="+n))}),!e&&r.rtp&&r.rtp.length){var i=void 0;r.rtp.forEach(function(e){"opus"===e.codec&&(i=e.payload)}),i&&(r.fmtp=r.fmtp||[],r.fmtp.push({payload:i,config:"maxplaybackrate="+n+" sprop-maxcapturerate="+n}))}}()),"offer"===e.type&&!function(){var e=r.mid;r.mid=i+"-"+n+"_"+a,o.groups&&o.groups.forEach(function(t){var n=t.mids.split(" ");n.indexOf(e)!==-1&&(n.splice(n.indexOf(e),1,r.mid),t.mids=n.join(" "))})}()}),e.sdp=a.write(o),e},h.setRemoteDescription=function(e,t){var n=this;"offer"===e.type,l.rtcLog("get remote sdp "+t+" --> "+e.type,e.sdp);var i={sdp:e.sdp,type:e.type};return"offer"!==e.type||this.sdpAnswer?(i.sdp=d.maybePreferVideoSendCodec(i.sdp,{videoRecvCodec:"H264"}),this.rtcConnection.setRemoteDescription(i).then(function(){return"answer"===e.type?(n.sdpAnswer=i,n.iceCompleted&&n.emit("iceCompleted")):n.sdpAnswer=null,u.resolve()})["catch"](function(e){return u.reject()})):u.reject()},h.setLocalDescription=function(e,t){var n=this;return this.isSdpUpdate=t,this.sdpOffer=e,l.rtcLog("set local sdp "+e.type,e.sdp),this.rtcConnection.setLocalDescription(e).then(function(){return"answer"===e.type?(n.sdpAnswer=e,n.iceCompleted&&n.emit("iceCompleted")):n.sdpAnswer=null,u.resolve()})["catch"](function(e){})},h.addRemoteIceCandidate=function(e){var t=this;l.rtcLog("set remote ICE ",e),this.rtcConnection.addIceCandidate(new RTCIceCandidate(e)).then(function(){t.iceAnswer.push(e),t.iceAnswer.length===t.iceOffer.length&&(t.iceCompleted=!0,t.iceAnswer=[],t.iceOffer=[],t.emit("iceCompleted"))})["catch"](function(e){})},h.close=function(){this.rtcConnection&&this.rtcConnection.close(),this.stats&&this.stats.stop()},e.exports=p},172:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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)}t.__esModule=!0;var a=n(12),s=void 0,c=function(e){function t(n){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;i(this,t);var a=r(this,e.call(this));return a.reset(),a.rtcConnection=n,a.statsIntervalTime=o,a.init(),a}return o(t,e),t.prototype.reset=function(){this.intervalId=null,this.rtcConnection=null,this.preStats=null},t.prototype.stop=function(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)},t.prototype.init=function(){var e=this;navigator.webkitGetUserMedia&&(this.intervalId=setInterval(function(){e.rtcConnection.getStats(function(t){var n=[];t.result().forEach(function(e){var t={};e.names().forEach(function(n){t[n]=e.stat(n)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,n.push(t)}),e.dealStats(n)})},this.statsIntervalTime))},t.prototype.dealStats=function(e){var t=this.filterItems(e);this.formatStats(t)},t.prototype.filterItems=function(e){var t={ssrc:{local:{},remote:{}},videoBwe:{},googCandidatePair:{}};return e.forEach(function(e){if("ssrc"===e.type){if(!e.googCodecName)return;var n=e.mediaType,i=e.bytesReceived?"remote":"local",r=t.ssrc,o=r[i]=r[i]||{};o[n]=e,"local"===i&&"video"===n&&("true"===e.googBandwidthLimitedResolution||"true"===e.googCpuLimitedResolution)}else if("VideoBwe"===e.type)t.videoBwe=e;else if("googCandidatePair"===e.type){if("false"===e.googActiveConnection)return;t[e.type]=e}}),t},t.prototype.formatStats=function(e){var t=e.ssrc,n=t.local=t.local||{},i=t.remote=t.remote||{};if(n.total={bytesSent:0,bytesSentRate:0,packetsLost:0,packetsSent:0,packetsLostRate:0,frameHeightSent:0,frameWidthSent:0,frameRateSent:0},i.total={bytesReceived:0,bytesReceivedRate:0,packetsLost:0,packetsReceived:0,packetsLostRate:0,frameHeightReceived:0,frameWidthReceived:0,frameRateReceived:0},(n.video||n.audio)&&(n.total.bytesSent=parseInt(n.audio&&n.audio.bytesSent?n.audio.bytesSent:0)+parseInt(n.video&&n.video.bytesSent?n.video.bytesSent:0),n.total.packetsLost=parseInt(n.audio&&n.audio.packetsLost?n.audio.packetsLost:0)+parseInt(n.video&&n.video.packetsLost?n.video.packetsLost:0),n.total.packetsSent=parseInt(n.audio&&n.audio.packetsSent?n.audio.packetsSent:0)+parseInt(n.video&&n.video.packetsSent?n.video.packetsSent:0),n.video&&(n.total.frameHeightSent=parseInt(n.video.googFrameHeightSent||0),n.total.frameWidthSent=parseInt(n.video.googFrameWidthSent||0),n.total.frameRateSent=parseInt(n.video.googFrameRateSent||0))),(i.video||i.audio)&&(i.total.bytesReceived=parseInt(i.audio&&i.audio.bytesReceived?i.audio.bytesReceived:0)+parseInt(i.video&&i.video.bytesReceived?i.video.bytesReceived:0),i.total.packetsLost=parseInt(i.audio&&i.audio.packetsLost?i.audio.packetsLost:0)+parseInt(i.video&&i.video.packetsLost?i.video.packetsLost:0),
i.total.packetsReceived=parseInt(i.audio&&i.audio.packetsReceived?i.audio.packetsReceived:0)+parseInt(i.video&&i.video.packetsReceived?i.video.packetsReceived:0),i.video&&(i.total.frameHeightReceived=parseInt(i.video.googFrameHeightReceived||0),i.total.frameWidthReceived=parseInt(i.video.googFrameWidthReceived||0),i.total.frameRateReceived=parseInt(i.video.googFrameRateReceived||0))),this.preStats){var r=this.preStats.ssrc.local,o=this.preStats.ssrc.remote,a=n.total.bytesSent-r.total.bytesSent;a&&(n.total.bytesSentRate=parseInt(a/this.statsIntervalTime*1e3));var c=i.total.bytesReceived-o.total.bytesReceived;c&&(i.total.bytesReceivedRate=parseInt(c/this.statsIntervalTime*1e3));var d=n.total.packetsSent-r.total.packetsSent,u=n.total.packetsLost-r.total.packetsLost;d&&(n.total.packetsLostRate=parseFloat((u/d).toFixed(5)));var l=i.total.packetsReceived-o.total.packetsReceived;u=i.total.packetsLost-o.total.packetsLost,l&&(i.total.packetsLostRate=parseFloat((u/l).toFixed(5)))}this.preStats=e,this.emit("rtcStats",s.merge({},e,4))},t}(a);c.install=function(e){s=e.util},t["default"]=c,e.exports=t["default"]},173:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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)}var a=n(12),s=n(13),c=void 0,d=void 0,u=function(e){function t(){return i(this,t),r(this,e.apply(this,arguments))}return o(t,e),t}(a);u.install=function(e){c=e.Promise,d=e.util};var l=u.prototype;l.connect=function(e){var t=this;return e?new c(function(n,i){var r=t.ws=new WebSocket("wss://"+e),o=t;r.onopen=function(e){o.initSignal(),o.signalConnected=!0,o.emit("signalConnected"),n(o)},r.onclose=r.onerror=function(e){o.signalConnected=!1,i(e)}}):c.reject("信令链接地址缺失")},l.initSignal=function(){var e=this,t=this.ws,n=t.send;t.send=function(e){n.call(this,JSON.stringify(e))},t.onmessage=function(t){e.logToConsole("socket receive:",t.data);var n=JSON.parse(t.data||null);n&&(e.emit("message",n),e.isHeartBeating&&"keep_alive_ack"===n.type&&e.onHeartBeat(n))},t.onclose=function(t){e.signalConnected=!1,e.logToConsole("socket Closed"),e.emit("signalClosed",t)},t.onerror=function(t){e.signalConnected=!1,e.logToConsole("socket error",t),e.emit("signalError",t)}},l.send=function(e){var t=this;"keep_alive"!==e.type&&(d.rtcLog("socket send:",e),this.logToConsole("send signal cmd",e)),this.ws&&this.signalConnected?(e&&e.cid&&e.uid&&(e.cid=""+e.cid,e.uid=""+e.uid),e.browser={},e.browser.name=s.name,e.browser.version=s.version,this.ws.send(e)):this.once("signalConnected",function(){t.send(e)})},l.heartbeat=function(e){this.socketData=e||this.socketData,this.logToConsole("socket connect success, start heartbeat"),this.heartBeatList=[],this.bindHearBeat(5)},l.onHeartBeat=function(e){this.logToConsole(e),this.heartBeatList.shift(),this.bindHearBeat(5)},l.heartBeatHandler=function(){var e=this.socketData,t=this.heartBeatList;if(t){if(t.constructor===Array&&0===t.length){var n=Date.now().toString();return t.push(n),this.send({type:"keep_alive",uid:e.uid,cid:e.cid,params:{content:{timestamp:n}}}),void this.bindHearBeat(5)}var i=Date.now()-t[0];if(i>3e4)this.logToConsole("socket error: heartbeat timeout, will reconnect now"),this.emit("signalClosed");else if(i>2e3&&i<3e4){this.logToConsole("socket error: no heartbeat, keep heartbeat");var r=Date.now().toString();t.push(r),this.send({type:"keep_alive",uid:e.uid,cid:e.cid,params:{content:{timestamp:r}}}),this.bindHearBeat(2)}}},l.bindHearBeat=function(e){this.isHeartBeating&&clearTimeout(this.isHeartBeating),this.isHeartBeating=setTimeout(this.heartBeatHandler.bind(this),1e3*e)},l.stopHeartBeat=function(){this.isHeartBeating&&(clearTimeout(this.isHeartBeating),clearInterval(this.heartBeatTimer),this.isHeartBeating=null,this.heartBeatTimer=null,this.heartBeatList=null,this.heartBeatCount=0)},l.logout=function(){var e=this.socketData,t=Date.now().toString();this.send({type:"logout",uid:e.uid,cid:e.cid,params:{content:{timestamp:t}}})},l.destroy=function(){var e="signal close -> signal.js";this.logToConsole(e),this.stopHeartBeat(),this.logout(),this.ws&&(this.ws.onopen=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onclose=null,this.ws.readyState===WebSocket.OPEN&&this.ws.close(),this.ws=null)},l.logToConsole=function(){var e=this.client;e&&e.log.apply(e,arguments)},e.exports=u},174:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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)}n(163);var a=n(167),s=n(12),c=void 0,d=void 0,u=function(e){function t(n){i(this,t);var o=r(this,e.call(this));return o.isRemote=!!n.isRemote,o.constraint=n.constraint||{},o.stream=n.stream,o.container=n.container,o.uid=n.uid||"",o.isAudio="audio"===n.type,o.initNode(),o.videoRatioIntervalId=null,o.startVideoRatioMonitor(),o}return o(t,e),t}(s);u.install=function(e){c=e.Promise,d=e.util};var l=u.prototype;l.initNode=function(){if(!this.node){var e=this.stream.getVideoTracks();0===e.length?(this.isAudio=!0,this.initAudioNode()):this.initVideoNode(),this.isRemote&&!this.isAudio&&this.initVideoEvent()}},l.initAudioNode=function(){this.audioStream=this.stream,this.gainController=new a(this.audioStream,this.uid,!0),this.stream=this.gainController.outputStream,this.node=document.createElement("audio"),this.node.dataset.uid=this.uid},l.initVideoNode=function(){var e=document.createElement("div");e.style.overflow="hidden",e.style.position="relative",e.style.width="100px",e.style.height="100px",e.style.display="none";var t=document.createElement("video");t.dataset.uid=this.uid,t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.transform="translate(-50%,-50%)",e.appendChild(t),this.node=t,this.videoContainer=e,setTimeout(function(){this.videoContainer&&(this.videoContainer.style.display="inline-block")}.bind(this),1e3)},l.initVideoEvent=function(){},l.setMuted=function(e){this.node&&(this.muted=!!e,this.node.muted=!!e,this.setPlayVolume())},l.getMuted=function(){return!!this.muted},l.setPlayVolume=function(e){var t=void 0;e?(e.constructor===Number&&(t=e),e.constructor===Object&&(t=void 0===e.volume?1:e.volume)):t=this.volume,this.volume=t,this.getMuted()||this.node&&(t=void 0===t||t>1?1:t,this.node.volume=t)},l.getPlayVolume=function(){return void 0!==this.volume?this.volume:1},l.setGain=function(e){if(this.stream&&!this.isRemote){if(void 0===e&&(e=1),this.gainOff)return this.gain=e,e;this.gainController.setGain(e),this.gain=e}},l.getGain=function(){return void 0!==this.gain?this.gain:1},l.setGainOff=function(){this.stream&&!this.isRemote&&(this.gainController.setGain(0),this.gainOff=!0)},l.setGainOn=function(){this.stream&&!this.isRemote&&(this.gainController.setGain(void 0!==this.gain?this.gain:1),this.gainOff=!1)},l.show=function(e){if(this.node){if(this.isAudio)return this.node.srcObject=this.audioStream,this.play(),void(this.enable=!0);e=this.container=e||this.container,this.node&&this.videoContainer&&(this.videoContainer&&e&&e.appendChild(this.videoContainer),this.node.srcObject||(this.node.srcObject=this.stream),this.play(),this.enable=!0)}},l.updateStream=function(e){var t=this.stream,n=this.node;if(n&&t){if(t.getTracks().forEach(function(e){e.stop(),t.removeTrack(e)}),t=null,this.isAudio)return d.rtcLog("更新音频流:",e),this.audioStream=e,this.gainController.updateStream(e),void(this.stream=this.gainController.outputStream);this.stream=e,n.srcObject=this.stream,d.rtcLog("更新视频流:",e),d.rtcLog(n)}},l.isShown=function(){return this.node&&this.node.srcObject&&this.enable},l.removeTrack=function(e){var t=this.stream;t&&t.removeTrack(e)},l.updateView=function(){this.node.srcObject&&(this.node.srcObject=this.stream,this.play())},l.hide=function(){var e=this.videoContainer;e&&(this.node.paused||this.node.pause(),e.parentNode&&e.parentNode.removeChild(e),this.enable=!1)},l.resize=function(e){if(this.node&&this.videoContainer&&!this.isAudio&&e&&e.width&&e.height){if(e.cut=void 0===e.cut||e.cut,this.resizeOptions=e,this.videoContainer.style.width=e.width+"px",this.videoContainer.style.height=e.height+"px",!e.cut)return this.node.style.height="100%",void(this.node.style.width="100%");if(this.node.videoWidth&&this.node.videoHeight){var t=this.node.videoWidth,n=this.node.videoHeight,i=t/n,r=e.width/e.height;i>r?(this.node.style.height="100%",this.node.style.width="auto"):(this.node.style.width="100%",this.node.style.height="auto")}else this.node.width=e.width,this.node.height=e.height}},l.startVideoRatioMonitor=function(){var e=this;this.isAudio||null===this.videoRatioIntervalId&&(this.preVideoWidth=this.node.videoWidth,this.preVideoHeight=this.node.videoHeight,this.videoRatioIntervalId=setInterval(function(){e.resizeOptions&&(e.preVideoWidth===e.node.videoWidth&&e.preVideoHeight===e.node.videoHeight||(e.resize(e.resizeOptions),e.preVideoWidth=e.node.videoWidth,e.preVideoHeight=e.node.videoHeight))},1e3))},l.getAudioVolume=function(){return this.gainController.getVolumeData()},l.getMetaWidth=function(e){if(this.node&&!this.isAudio)return this.node.videoWidth},l.getMetaHeight=function(e){if(this.node&&!this.isAudio)return this.node.videoHeight},l.resume=function(){this.play()},l.pause=function(){this.node.pause()},l.play=function(){var e=this.node;4!==e.readyState&&e.load(),0!==e.played.length&&e.pause(),e.play()["catch"](function(e){d.rtcLog(e)}),this.isAudio&&this.setMuted(!1)},l.destroy=function(){function e(e){if(e){var t=e.getTracks();t&&0!==t.length&&t.forEach(function(t){t.stop(),e.removeTrack(t)})}}this.hide(),this.node.srcObject=null,this.node=null,this.videoContainer=null,this.stream&&(e(this.stream),e(this.audioStream),this.stream=null,this.audioStream=null,null!==this.videoRatioIntervalId&&(clearInterval(this.videoRatioIntervalId),this.videoRatioIntervalId=null),this.gainController&&this.gainController.context&&this.gainController.destroy&&this.gainController.destroy())},u.getLocalStream=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!0},t=e.audio?"audio":"";return navigator.mediaDevices.getUserMedia(e).then(function(n){return new u({stream:n,type:t,isRemote:!1,constraint:e})})["catch"](function(e){var t="启动设备失败: "+e.name;return c.reject(t)})},e.exports=u},175:function(e,t){var n=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-\.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%d trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))? (\S*)(?: (\S*))?/,names:["value","direction","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+" %s"+(e.config?" %s":"")}},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_\/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{push:"invalid",names:["value"]}]};Object.keys(n).forEach(function(e){var t=n[e];t.forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})},182:function(e,t,n){"use strict";var i=n(168),r=n(67),o=i.prototype,a=void 0;o.setUtil=function(e){a=e},o.createChannel=function(e){return a.verifyOptions(e,"channelName"),e.custom=e.custom||"",e.webrtcEnable=!0,this.nim.createChannel(e)},o.joinChannel=function(e){var t=this;if(this.signalInited)return Promise.reject("已经加入会议");a.verifyOptions(e,"channelName type");var n=e.sessionConfig;return n&&(a.merge(this,{sessionConfig:n}),this.setSessionConfig(n)),this.nim.joinChannel({channelName:e.channelName,liveEnable:e.liveEnable}).then(function(n){return t.signalInited=!0,t.session_mode=n.session_mode="meeting",t.channelId=n.channelId,t.channelName=e.channelName,t.parseAccountUidMap(n.accountUidMap),n.uid=t.getUidWithAccount(t.nim.account),t.type=n.type=n.type||r.NETCALL_TYPE_VIDEO,n.account=t.nim.account,t.meetingInfo=n,Promise.resolve({uid:n.uid,account:t.nim.account,type:n.type})})["catch"](function(e){return Promise.reject(e)})},o.leaveChannel=function(){return this.signalInited&&this.session_mode?"meeting"!==this.session_mode?Promise.reject({code:"not in a meeting"}):(this.signalInited=!1,this.controller.hangup(),Promise.resolve()):Promise.reject({code:"noConnection"})},o.changeRoleToPlayer=function(){return 0===this.role?Promise.resolve({role:"player"}):(this.role=0,this.controller.rtc&&this.controller.rtc?(this.controller.updateRtcStream(),this.controller.createOffer(!0).then(function(){return Promise.resolve({role:"player"})})):Promise.resolve({role:"player"}))},o.changeRoleToAudience=function(){return 1===this.role?Promise.resolve({role:"audience"}):(this.role=1,this.controller.rtc&&this.controller.rtc?(this.controller.updateRtcStream(),this.controller.createOffer(!0).then(function(){return Promise.resolve({role:"audience"})})):Promise.resolve({role:"audience"}))},o.updateRtmpUrl=function(e){return Promise.resolve()}},183:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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)}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=n(170),c=n(12),d=n(67),u=n(169),l=n(174),p=n(171),h=n(173),f=void 0,m=void 0,v=function(e){function t(n,o,a){i(this,t);var s=r(this,e.call(this));return s.init(),s.sessionConfig={},s.container=n,s.remoteContainer=o,s.resetStatus(),s.client=a,s}return o(t,e),t}(c);v.install=function(e){f=f||e.Promise,m=e.util};var g=v.prototype;g.init=function(){this.mediaDevices=new u,this.mediaDevices.on("deviceStatus",this.onDeviceStatusChange.bind(this)),this.mediaDevices.on("deviceAdd",this.onDeviceAdd.bind(this)),this.mediaDevices.on("deviceRemove",this.onDeviceRemove.bind(this))},g.resetStatus=function(){this.rtc&&this.rtc.close(),this.rtc=null,this.rtcFirstConnected=!1,this.signal&&(this.signal.destroy(),this.signal=null),this.recordRTC&&this.stopRecord(),this.imInfo={},this.stopAudioMonitor(),this.destroyMediaStream({type:"all"}),this.remoteStreamList={},this.remoteUidMsidMap={},this.remoteStreams={},this.deviceVideoStatus=!1,this.deviceAudioStatus=!1,this.monitorRemoteStreamStartTime=null,this.userJoinTimeoutId=null,window.myRtcRemoteStream=this.remoteStreamList},g.destroyMediaStream=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{type:"all"};if("local"!==e.type&&"all"!==e.type||(this.destroyLocalMediaStream(),"local"!==e.type)){if("remote"===e.type)return void this.destroyRemoteMediaStream(e.uid);var t=this.remoteStreamList;if(t){for(var n in t)this.destroyRemoteMediaStream(n);this.remoteStreamList={}}}},g.destroyLocalMediaStream=function(){this.localAudioStream&&(this.localAudioStream.destroy(),this.localAudioStream=null),this.localVideoStream&&(this.localVideoStream.destroy(),this.localVideoStream=null),this.localStream&&(this.localStream.destroy(),this.localStream=null)},g.destroyRemoteMediaStream=function(e){if(e&&this.remoteStreamList&&this.remoteStreamList[e]){var t=this.remoteStreamList[e];t.remoteStream&&t.remoteStream.destroy(),t.remoteVideoStream&&t.remoteVideoStream.destroy(),t.remoteAudioStream&&t.remoteAudioStream.destroy(),t.remoteStream=null,t.remoteVideoStream=null,t.remoteAudioStream=null,this.remoteStreamList[e]=null}},g.getUidByMsid=function(e){var t=this.remoteUidMsidMap;for(var n in t)if(t[n]===e)return n;return null},g.getMsidByUid=function(e){return this.remoteUidMsidMap(e)},g.initSignal=function(){var e=this;if(this.signal)return f.resolve();this.stopSignal();var t=new h;return t.connect(this.imInfo.rtcUrl).then(function(t){e.signal=t,e.initSignalEvent(),e.signal.heartbeat({uid:e.imInfo.uid,cid:e.imInfo.channelId})})},g.initSignalEvent=function(){var e=this;this.signal.on("message",this.onMessage.bind(this)),this.signal.on("signalClosed",function(){e.emit("signalClosed"),e.stopSignal()}),this.signal.on("signalError",function(e){})},g.stopSignal=function(){this.signal&&(this.signal.destroy(),this.signal=null,this.client.signalInited=!1,this.stopRemoteStream())},g.switchVideoToAudio=function(){var e=this;return f.resolve().then(function(){if(!e.rtc)throw new Error("current has no session stared, can't switch video to audio");return e.localVideoStream&&(e.localVideoStream.destroy(),e.localVideoStream=null),f.resolve()})},g.switchAudioToVideo=function(){var e=this;return f.resolve().then(function(){if(!e.rtc)throw new Error("current has no session stared, can't switch audio to video");return e.localVideoStream?(e.updateRtcStream(),e.createOffer(!0)):f.resolve()})},g.updateLocalStream=function(){m.rtcLog("更新本地音视频流,重组合成新的轨道,当前角色:"+(0===this.client.role?"player":"audience"));var e=this.client.getUidWithAccount(this.client.getAccount()),t=void 0;if(t=this.localStream?this.localStream.stream||new MediaStream:new MediaStream,"meeting"===this.client.session_mode&&0!==this.client.role)return t.getTracks().forEach(function(e){t.removeTrack(e)}),t;var n=t&&t.getVideoTracks()[0];if(this.localVideoStream){var i=this.localVideoStream.stream.getVideoTracks()[0];i!==n&&(n&&t.removeTrack(n),t.addTrack(i))}else n&&t.removeTrack(n);var r=t&&t.getAudioTracks()[0];if(this.localAudioStream){var o=this.localAudioStream.stream&&this.localAudioStream.stream.getAudioTracks()[0];o!==r&&(r&&t.removeTrack(r),t.addTrack(o))}else r&&t.removeTrack(r);return this.localStream||(this.localStream=new l({stream:t,uid:e})),t},g.updateRtcStream=function(){var e=window.myLocalStream=this.updateLocalStream();this.rtc&&(m.rtcLog("attach ms length: "+e.getTracks().length),m.rtcLog("本地流附加rtc ---> ",e),this.rtc.addStream(e))},g.startRtc=function(e){var t=this;this.imInfo=e;var n=e.serverMap?JSON.parse(e.serverMap):{};n.webrtc&&(e.rtcUrl=n.webrtc);var i=void 0;return i=this.signal?f.resolve(this.signal):this.initSignal(),i=i.then(function(){return t.rtc||(t.rtc=new p(t),t.initRtcEvent()),t.doRtc(e.session_mode)})},g.hangup=function(){this.client.signalInited&&this.stopSignal(),null!==this.userJoinTimeoutId&&(clearTimeout(this.userJoinTimeoutId),this.userJoinTimeoutId=null),this.resetStatus()},g.logout=function(){this.signal&&this.signal.logout()},g.doRtc=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"p2p";this.updateRtcStream();var n=this.createOffer().then(function(){var n=new f(function(n,i){e.once("userJoined",function(e){m.rtcLog("once userJoined-->",e),n(e)}),e.once("rtcConnectSuccess",function(t){m.rtcLog("rtc connect success"),e.rtcFirstConnected=!0,e.startAudioMonitor(),n(t)}),e.once("rtcConnectError",function(e){i(e)}),"p2p"===t&&(e.userJoinTimeoutId=setTimeout(function(){i("user join timeout")},5e4))});return n});return n},g.createOffer=function(e){var t=this;return this.rtc.sdpAnswer=null,this.createOfferLockTimer&&(m.rtcLog("销毁 createoffer timer"),clearTimeout(this.createOfferLockTimer)),m.rtcLog("新建 createoffer timer"),this.createOfferLockTimer=setTimeout(function(){t.createOfferLockTimer=null,m.rtcLog("------ 执行 createoffer ------"),t._createOffer(e)},1e3),f.resolve()},g._createOffer=function(e){var t=this,n=this.rtc,i=new f(function(i,r){return n?void n.createOffer().then(function(o){n.setLocalDescription(o,e).then(function(){t.sendOffer(o,e),i()})["catch"](function(e){r(e)})}):r("rtc not connected")});return i},g.doSendOffer=function(e){var t=e.offer,n=e.isUpdate,i=e.ice_offer;this.sendOffer(t,n,i)},g.sendOffer=function(e,t){var n=this.imInfo,i=this.getVideoSessionConfig(),r=this.sessionConfig||{},o=t?"sdp_update":"sdp_offer",a=this.mediaDevices.getDeviceStatus();m.rtcLog("send offer",e),this.signal.send({type:o,uid:n.uid,cid:n.channelId,session_mode:n.session_mode||"p2p",bypass_rtmp:{is_host:r.isHost||!1,support_bypass_rtmp:r.bypassRtmp||!1,support_bypass_rtmp_record:r.rtmpRecord||!1,bypass_rtmp_url:r.rtmpUrl||"",participant_mode:"M-"+r.splitMode,layout:r.layout||""},params:{token:n.channelId+"",user_type:2,user_token_type:0,content:e,streamSetting:{video:{width:i.width,height:i.height,frameRate:i.frameRate}}},hasAudio:this.deviceAudioStatus&&a.hasAudio&&!this.client.role,hasVideo:this.deviceVideoStatus&&a.hasVideo&&!this.client.role})},g.getDeviceStatus=function(){return this.mediaDevices.getDeviceStatus()},g.onDeviceStatusChange=function(e){m.rtcLog("onDeviceStatusChange"),this.emit("deviceStatus",e)},g.onDeviceAdd=function(e){m.rtcLog("onDeviceAdd"),this.client.devices.needVideo=this.deviceVideoStatus,this.client.devices.needAudio=this.deviceAudioStatus,this.emit("deviceAdd",e)},g.onDeviceRemove=function(e){var t=this;m.rtcLog("onDeviceRemove"),(this.localVideoStream||this.localAudioStream)&&e.forEach(function(e){t.localVideoStream&&e.deviceId===t.localVideoStream.constraint.video.deviceId&&(t.localVideoStream.destroy(),t.localVideoStream=null,t.client.devices.hasVideo=!1,t.rtcFirstConnected&&(t.updateRtcStream(),t.createOffer(!0))),t.localAudioStream&&e.deviceId===t.localAudioStream.constraint.audio.deviceId&&(t.localAudioStream.destroy(),t.localAudioStream=null,t.client.devices.hasAudio=!1,t.rtcFirstConnected&&(t.updateRtcStream(),t.createOffer(!0)))}),this.emit("deviceRemove",e)},g.initRtcEvent=function(){var e=this;this.rtc.on("sendOffer",this.doSendOffer.bind(this)),this.rtc.on("iceCompleted",this.startSdp_offer.bind(this)),this.rtc.on("getRemoteStream",this.onRemoteStream.bind(this)),this.rtc.on("iceCandidate",this.onLocalIceCandidate.bind(this)),this.rtc.on("negotiationneeded",this.onNegotiationNeeded.bind(this)),this.rtc.on("iceconnectionstatechange",this.onIceConnectionStateChange.bind(this)),this.rtc.on("rtcStats",function(t){e.emit("statistics",t),e.monitorRemoteStream(t)}),this.mediaDevices.getDevices().then(function(t){e.emit("devices",t)})},g.startAudioMonitor=function(){function e(){var e={},t=0;this.localAudioStream&&(t=this.localAudioStream.getAudioVolume()),e.self={status:t};var n=this.remoteStreamList;for(var i in n){var r=this.client.getAccountWithUid(i);r&&(t=n[i]&&n[i].remoteAudioStream?n[i].remoteAudioStream.getAudioVolume():0,e[r]={status:t})}this.emit("audioVolume",e)}var t=this.audioMonitorTimer;t||(t=this.audioMonitorTimer=setInterval(e.bind(this),500))},g.stopAudioMonitor=function(){var e=this.audioMonitorTimer;e&&(clearInterval(e),e=this.audioMonitorTimer=null)},g.monitorRemoteStream=function(e){if(this.remoteVideoStream||this.remoteAudioStream){if(!e.ssrc.remote||!e.ssrc.remote.total)return;var t=e.ssrc.remote.total;if(t.bytesReceivedRate>0||!this.monitorRemoteStreamStartTime)this.monitorRemoteStreamStartTime=Date.now();else{var n=Date.now();n-this.monitorRemoteStreamStartTime>1e4&&(this.emit("remoteStreamNoData"),this.monitorRemoteStreamStartTime=null)}}else this.monitorRemoteStreamStartTime=null},g.onRemoteStream=function(e){m.rtcLog("收到远程流");var t=e.id,n=this.getUidByMsid(t);return n?void this.doRemoteStream(e,n):(this.remoteStreams[t]=e,void(window.myRemoteStreams=this.remoteStreams))},g.checkRemoteTrack=function(e,t){var n=this.remoteStreamList[e],i=window.remoteStream=n.remoteStream&&n.remoteStream.stream;if(i){var r=this.rtc.checkMediaStatus(i,t.sdp);r.video||n.remoteVideoStream.hide()}},g.startDoRemoteStream=function(e,t){this.remoteStreams[t]&&this.doRemoteStream(this.remoteStreams[t],e)},g.doRemoteStream=function(e,t){var n=this;m.rtcLog("响应远程推送过来的流数据,即将进行轨道重组,轨道数目: "+e.getTracks().length,e),e&&e.getTracks().forEach(function(e){m.rtcLog(" > 轨道id:",e.kind+":"+e.id)}),window.myRemoteStreamList=this.remoteStreamList,window.myRtc=this.rtc.rtcConnection;var i=this.remoteStreamList[t];i.remoteStream?i.remoteStream.updateStream(e):i.remoteStream=new l({uid:t,stream:e,isRemote:!0,container:i.container});var r=e.getAudioTracks(),o=e.getVideoTracks();if(r.length){var a=new MediaStream;a.addTrack(r[0]),m.rtcLog("重组音频流:",a),i.remoteAudioStream?i.remoteAudioStream.updateStream(a):i.remoteAudioStream=new l({uid:t,stream:a,type:"audio",isRemote:!0,container:i.container}),i.remoteAudioStream.show()}if(o.length){var s=new MediaStream;s.addTrack(o[0]),m.rtcLog("重组视频流:",s),i.remoteVideoStream?i.remoteVideoStream.updateStream(s):i.remoteVideoStream=new l({uid:t,stream:s,isRemote:!0,container:i.container}),setTimeout(function(){i.isVideoEnable&&(i.remoteVideoStream.show(),i.remoteVideoStream.resize(i.videoSizeOptions||this.videoViewRemoteSizeOptions))}.bind(this),100)}e.onaddtrack=function(r){n.emit("addtrack",r);var o=r.track,a=o.kind;if(m.rtcLog(e.id,"on add track:",a,o),"video"===a){var s=new MediaStream;s.addTrack(o),i.remoteVideoStream?i.remoteVideoStream.updateStream(s):i.remoteVideoStream=new l({uid:t,stream:s,isRemote:!0,container:i.container}),setTimeout(function(){i.isVideoEnable&&(i.remoteVideoStream.show(),i.remoteVideoStream.resize(i.videoSizeOptions||this.videoViewRemoteSizeOptions))}.bind(n),100)}else{var c=new MediaStream;c.addTrack(o),i.remoteAudioStream?i.remoteAudioStream.updateStream(c):i.remoteAudioStream=new l({uid:t,stream:c,type:"audio",isRemote:!0,container:i.container}),i.remoteAudioStream.show()}},e.onremovetrack=function(t){m.rtcLog(e,"on remove track:",t),n.emit("removetrack",t);var r=t.track,o=r.kind;"video"===o?i.remoteVideoStream&&i.remoteVideoStream.hide():i.remoteAudioStream}},g.onLocalIceCandidate=function(e){var t="ice_offer";/\d tcp \d/.test(e.candidate)||this.signal.send({type:t,uid:this.imInfo.uid,cid:this.imInfo.channelId,params:{content:e}})},g.onNegotiationNeeded=function(){this.rtcFirstConnected&&(m.rtcLog("onNegotiationNeeded"),this.createOffer(!0))},g.onIceConnectionStateChange=function(e){m.rtcLog("ice connection state change to:"+e),"connected"===e?this.emit("rtcConnectSuccess"):"failed"===e&&this.emit("rtcConnectFailed")},g.onMessage=function(e){var t={sdp_answer:"onSdp_answer",ice_offer:"onIce_OfferAnswer",ice_answer:"onIce_OfferAnswer",sdp_offer:"onSdp_offer",client_logout:"onClient_logout",logout:"onClient_logout"};if(e&&e.cid&&e.uid&&(e.cid=+e.cid,e.uid=+e.uid),e.cid===this.imInfo.channelId){var n=t[e.type];this[n]&&this[n](e)}},g.onSdp_answer=function(e){m.rtcLog("onSdp_answer-->",e);var t=e.params.auth_res-0;return 200!==t?void this.emit("rtcConnectFailed",{code:t,error:"服务器验证不通过, 断开连接"}):void this.rtc.setRemoteDescription(e.params.content,"answer").then(function(){});
},g.onSdp_offer=function(e){return this.rtc.iceCompleted&&this.rtc.sdpAnswer?this.doSdp_offer(e):(this.remote_SdpOffers=this.remote_SdpOffers||[],void this.remote_SdpOffers.push(e))},g.startSdp_offer=function(){var e=this.remote_SdpOffers,t=this;if(e&&0!==e.length){var n=e.shift();t.doSdp_offer(n),setTimeout(t.startSdp_offer.bind(t),100)}},g.doSdp_offer=function(e){var t=this,n=e.uid,i=e.cid;if(n&&i){var r=JSON.parse(e.params.content.msids);r.forEach(function(n){if(n.uid){n.uid=+n.uid;var i=new Date;i=i.toLocaleString(),m.rtcLog(i+" 有用户状态更新",e),t.remoteUidMsidMap[n.uid]?t.updateRemoteUserStream(n.uid,n.msid):(t.updateRemoteUserStream(n.uid,n.msid),t.emit("userJoined",{uid:n.uid})),t.remoteStreams[n.msid]&&t.startDoRemoteStream(n.uid,n.msid),t.checkRemoteTrack(n.uid,e.params.content)}}),this.rtc.setRemoteDescription(e.params.content,"offer").then(function(){var e=t.getVideoSessionConfig();t.rtc.createAnswer().then(function(n){t.rtc.setLocalDescription(n),t.signal.send({type:"sdp_answer",uid:t.imInfo.uid,cid:t.imInfo.channelId,params:{content:n,streamSetting:{video:{width:e.width,height:e.height,frameRate:e.frameRate}}}})})["catch"](function(e){})})["catch"](function(){})}},g.onIce_OfferAnswer=function(e){var t=e.params.content;"object"!==("undefined"==typeof t?"undefined":a(t))&&(t={candidate:t}),this.rtc.addRemoteIceCandidate(t)},g.onClient_logout=function(e){m.rtcLog("on logout",e);var t=e.uid;if(this.remoteUidMsidMap[t]){var n=this.client.getAccountWithUid(t);this.destroyMediaStream({uid:t,type:"remote"}),this.removeRemoteUserStream(t),this.emit("leaveChannel",{uid:t,account:n})}},g.getVideoSessionConfig=function(){var e,t,n={},i=this.sessionConfig,r=i&&i.videoQuality||d.CHAT_VIDEO_QUALITY_NORMAL,o=i&&i.videoFrameRate||d.CHAT_VIDEO_FRAME_RATE_NORMAL,a=(e={},e[d.CHAT_VIDEO_QUALITY_NORMAL]="480x320",e[d.CHAT_VIDEO_QUALITY_LOW]="176x144",e[d.CHAT_VIDEO_QUALITY_MEDIUM]="352x288",e[d.CHAT_VIDEO_QUALITY_HIGH]="480x320",e[d.CHAT_VIDEO_QUALITY_480P]="640x480",e[d.CHAT_VIDEO_QUALITY_540P]="960x540",e[d.CHAT_VIDEO_QUALITY_720P]="1280x720",e),s=(t={},t[d.CHAT_VIDEO_FRAME_RATE_NORMAL]=15,t[d.CHAT_VIDEO_FRAME_RATE_5]=5,t[d.CHAT_VIDEO_FRAME_RATE_10]=10,t[d.CHAT_VIDEO_FRAME_RATE_15]=15,t[d.CHAT_VIDEO_FRAME_RATE_20]=20,t[d.CHAT_VIDEO_FRAME_RATE_25]=25,t);return n.frameRate=s[o],n.width=parseInt(a[r].split("x")[0]),n.height=parseInt(a[r].split("x")[1]),n},g.stopDevice=function(e){var t=this;return new f(function(n,i){if(e===d.DEVICE_TYPE_VIDEO){if(t.deviceVideoStatus=!1,t.localVideoStream)return t.localVideoStream.destroy(),t.localVideoStream=null,t.rtcFirstConnected&&t.client.type===d.NETCALL_TYPE_VIDEO?(t.updateRtcStream(),t.createOffer(!0).then(n)):n()}else if(e===d.DEVICE_TYPE_AUDIO_IN){if(t.deviceAudioStatus=!1,t.localAudioStream)return t.localAudioStream.destroy(),t.localAudioStream=null,t.rtcFirstConnected?(t.updateRtcStream(),t.createOffer(!0).then(n)):n()}else e===d.DEVICE_TYPE_AUDIO_OUT_LOCAL?t.localAudioStream&&t.localAudioStream.setMuted(!0):e===d.DEVICE_TYPE_AUDIO_OUT_CHAT&&t.setAudioBlack();n()})},g.startDevice=function(e){var t=this;return new f(function(n,i){var r=e.type,o=e.device;if(r===d.DEVICE_TYPE_VIDEO&&(t.deviceVideoStatus=!0),r===d.DEVICE_TYPE_AUDIO_IN&&(t.deviceAudioStatus=!0),r===d.DEVICE_TYPE_AUDIO_OUT_LOCAL)return t.localAudioStream&&(t.localAudioStream.show(),t.localAudioStream.setMuted(!1)),n();if(r===d.DEVICE_TYPE_AUDIO_OUT_CHAT)return t.setAudioStart(),n();var a=f.resolve();r!==d.DEVICE_TYPE_DESKTOP_SCREEN&&r!==d.DEVICE_TYPE_DESKTOP_WINDOW&&(o&&o.deviceId||(a=new f(function(e,n){t.mediaDevices.getDevicesOfType(r).then(function(t){t.length?(o=t[0],e(o)):n("开启设备失败: 没有找到可用设备")})}))),a.then(function(){if(r===d.DEVICE_TYPE_VIDEO&&t.localVideoStream&&t.localVideoStream.constraint&&t.localVideoStream.constraint.video.deviceId===o.deviceId)return void m.rtcLog("摄像头已开启,重复操作");if(r===d.DEVICE_TYPE_AUDIO_IN&&t.localAudioStream&&t.localAudioStream.constraint&&t.localAudioStream.constraint.audio.deviceId===o.deviceId){m.rtcLog("麦克风已开启,设置track为enable");var e=t.localAudioStream.stream&&t.localAudioStream.stream.getAudioTracks()[0];return void(e&&(e.enabled=!0))}return r===d.DEVICE_TYPE_VIDEO?t._getVideoStream(o,n,i):r===d.DEVICE_TYPE_AUDIO_IN?t._getAudioStream(o,n,i):r===d.DEVICE_TYPE_DESKTOP_SCREEN||r===d.DEVICE_TYPE_DESKTOP_WINDOW?t._getScreenStream(r,n,i):void 0}).then(function(){n()})["catch"](function(e){i(e)})})},g._getVideoStream=function(e,t,n){var i=this,r={};this.localVideoStream&&(this.localVideoStream.destroy(),this.localVideoStream=null);var o=r.video={};o.deviceId=e.deviceId;var a=this.getVideoSessionConfig();return m.merge(o,a),l.getLocalStream(r).then(function(e){if(i.localVideoStream=e,i.rtcFirstConnected&&i.client.type===d.NETCALL_TYPE_VIDEO)return i.updateRtcStream(),i.createOffer(!0).then(t)})},g._getAudioStream=function(e,t,n){var i=this,r={};this.localAudioStream&&(this.localAudioStream.destroy(),this.localAudioStream=null);var o=r.audio={};return o.deviceId=e.deviceId,l.getLocalStream(r).then(function(e){if(i.localAudioStream=e,i.rtcFirstConnected)return i.updateRtcStream(),i.createOffer(!0).then(t)})},g._getScreenStream=function(e,t,n){var i=this;this.localVideoStream&&(this.localVideoStream.destroy(),this.localVideoStream=null),e=e===d.DEVICE_TYPE_DESKTOP_SCREEN?"screen":"window";var r={audio:!1,video:{mediaSource:e}};return l.getLocalStream(r).then(function(e){if(i.localVideoStream=e,i.rtcFirstConnected)return i.updateRtcStream(),i.createOffer(!0).then(t)})},g.setSessionConfig=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.sessionConfig=m.merge(this.sessionConfig,e)},g.setSessionVideoQuality=function(e){void 0!==e&&(this.sessionConfig.videoQuality=e)},g.setSessionVideoFrameRate=function(e){void 0!==e&&(this.sessionConfig.videoFrameRate=e)},g.setSessionAudioQuality=function(e){this.sessionConfig.highAudio=!!e},g.setCaptureVolume=function(e){(void 0===e||e>1)&&(e=1),this.localAudioStream&&this.localAudioStream.setGain(e)},g.setPlayVolume=function(e){return e.fn="setPlayVolume",e.option={volume:e.volume},this.localAudioStream&&this.localAudioStream.setPlayVolume(e.volume),this.optionRemoteStream(e)},g.startLocalStream=function(e){var t=this;this.localVideoStream&&(this.localVideoStream.container=e||this.container,this.localVideoStream.resize(this.videoViewSizeOptions),this.localVideoStream.show(),this.localVideoStream.on("resize",function(e){t.emit("streamResize",e)}),this.localVideoStream.on("error",function(e){t.emit("error",e)}),this.localVideoStream.isShown()||this.updateRtcStream())},g.stopLocalStream=function(){this.localVideoStream&&this.localVideoStream.hide()},g.updateRemoteUserStream=function(e,t){this.remoteUidMsidMap[e]=t,this.remoteStreamList[e]||(this.remoteStreamList[e]={isVideoEnable:!0,container:null})},g.removeRemoteUserStream=function(e){delete this.remoteUidMsidMap[e],delete this.remoteStreamList[e]},g.startRecordMp4=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.account,i=void 0,r=void 0;if(n)if(n===this.client.getAccount())i=null;else if(i=this.client.getUidWithAccount(n),!i)return f.reject("账号不在本次会议中,无法进行录制");if(this.recordRTC)return f.reject("当前正在录制中");if(n=n||this.client.getAccount(),r=this.localStream,i&&(r=this.remoteStreamList[i].remoteStream),!r||!r.stream)return f.reject("当前没有音视频数据,无法进行录制");var o=[r.stream];return new s(o,{account:n}).then(function(t){return e.recordRTC=t,f.resolve()})["catch"](function(e){return f.reject(e)})},g.stopRecord=function(){var e=this,t=e.recordRTC;return t?t.stop().then(function(t){return e.recordRTC=null,f.resolve()})["catch"](function(e){return f.reject(e)}):f.reject("请先开启音视频录制")},g.startRecordAac=function(){var e=this,t=this.localAudioStream;if(this.recordRTC)return f.reject("当前正在录制中");var n=this.client.getAccount(),i=[];t&&t.stream&&(i=[t.stream]);var r=this.remoteStreamList;for(var o in r)r[o].remoteStream&&r[o].remoteStream.stream&&i.push(r[o].remoteStream.stream);return new s(i,{account:n,type:"audio"}).then(function(t){return e.recordRTC=t,f.resolve()})["catch"](function(e){return f.reject(e)})},g.startRemoteStream=function(){function e(e){e.container=i&&i.node||e.container,e.isVideoEnable=!0,e.remoteVideoStream&&(e.remoteVideoStream.resize(e.videoSizeOptions),e.remoteVideoStream.show())}var t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("p2p"===this.client.session_mode){if(!this.remoteContainer&&!i.node||!this.client.target)return this.nim.logger.error("不传参数且点对点模式实例化Netcall必须设置remoteContainer与target;传参数必须包含account,node"),f.reject("不传参数且点对点模式实例化Netcall必须设置remoteContainer与target;传参数必须包含account,node");t=this.client.getUidWithAccount(this.client.target),n=this.remoteStreamList[t],i.node=i.node||this.remoteContainer}else{if(!i.uid&&i.account&&(t=this.client.getUidWithAccount(i.account),!t))return f.reject("帐号不在会议中,请检查");t=i.uid||t,n=this.remoteStreamList[t]}if(n)return e(n),f.resolve();var r=this.remoteStreamList;for(var o in r)e(r[o]);return f.resolve()},g.stopRemoteStream=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.constructor===String&&(e={account:e}),e.fn="hide",this.optionRemoteStream(e)},g.suspendLocalStream=function(){return this.localVideoStream?(this.localVideoStream.pause(),f.resolve()):f.reject("本地没有音视频流,无法进行操作")},g.resumeLocalStream=function(){return this.localVideoStream?(this.localVideoStream.resume(),f.resolve()):f.reject("本地没有音视频流,无法进行操作")},g.suspendRemoteStream=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.fn="pause",this.optionRemoteStream(e)},g.resumeRemoteStream=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.fn="resume",this.optionRemoteStream(e)},g.optionRemoteStream=function(){function e(e){return o?void(e.remoteAudioStream&&e.remoteAudioStream[n]&&e.remoteAudioStream[n](a)):("resize"===n&&(e.videoSizeOptions=a||this.videoViewRemoteSizeOptions),e.remoteVideoStream&&e.remoteVideoStream[n]&&e.remoteVideoStream[n](a),void(e.isVideoEnable="hide"!==n))}var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.fn,i=t.uid,r=t.account,o=t.isAudio,a=t.option,s=void 0;if(o=o||/(setPlayVolume|setGain)/.test(n),!i&&r&&(i=this.client.getUidWithAccount(r),!i))return f.reject("操作帐号不在会议中,请检查");if(i)return s=this.remoteStreamList[i],s&&e(s),f.resolve();s=this.remoteStreamList;for(var c in s)s[c]&&e(s[c]);return f.resolve()},g.setVideoViewSize=function(e){this.videoViewSizeOptions=e,this.localVideoStream&&this.localVideoStream.resize(this.videoViewSizeOptions)},g.setVideoViewRemoteSize=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.fn="resize",e.option={width:e.width,height:e.height,cut:e.cut},this.optionRemoteStream(e)},g.setAudioStart=function(e){return this.optionRemoteStream({fn:"setMuted",account:e,isAudio:!0,option:!1})},g.setAudioBlack=function(e){return this.optionRemoteStream({fn:"setMuted",account:e,isAudio:!0,option:!0})},g.setVideoBlack=function(e){return this.optionRemoteStream({fn:"hide",account:e})},g.setVideoShow=function(e){return this.optionRemoteStream({fn:"show",account:e})},e.exports=v},184:function(e,t){"use strict";e.exports={randomSSRC:function(){var e=Math.floor(1e8*Math.random())+1e7;return e>1e8?99999999:e},_createLocalDescription:function(e,t){function n(e,n){var a={};switch(a.type=n,n){case"audio":case"video":a.protocol="RTP/SAVPF",a.port=9,a.direction="sendrecv";break;case"application":a.protocol="DTLS/SCTP",a.port=0,a.payloads="0",a.direction="inactive"}a.connection={ip:"127.0.0.1",version:4},a.mid=e,a.iceUfrag=r.usernameFragment,a.icePwd=r.password,a.candidates=[];for(var l=o,p=Array.isArray(l),h=0,l=p?l:l[Symbol.iterator]();;){var f;if(p){if(h>=l.length)break;f=l[h++]}else{if(h=l.next(),h.done)break;f=h.value}var m=f,v={};v.component=1,v.foundation=m.foundation,v.ip=m.ip,v.port=m.port,v.priority=m.priority,v.transport=m.protocol.toLowerCase(),v.type=m.type,"tcp"===v.transport&&(v.tcptype=m.tcpType),a.candidates.push(v)}if(a.endOfCandidates="end-of-candidates","offer"===t?a.setup="actpass":a.setup="server"===s.role?"active":"passive","audio"===n||"video"===n){a.rtp=[],a.rtcpFb=[],a.fmtp=[];for(var g=[],y=c.codecs,S=Array.isArray(y),b=0,y=S?y:y[Symbol.iterator]();;){var C;if(S){if(b>=y.length)break;C=y[b++]}else{if(b=y.next(),b.done)break;C=b.value}var w=C;if(!w.kind||w.kind===n){g.push(w.preferredPayloadType);var T={codec:w.name,payload:w.preferredPayloadType,rate:w.clockRate};if(w.numChannels>1&&(T.encoding=w.numChannels),a.rtp.push(T),w.parameters){for(var R={config:"",payload:w.preferredPayloadType},A=Object.keys(w.parameters),E=Array.isArray(A),_=0,A=E?A:A[Symbol.iterator]();;){var O;if(E){if(_>=A.length)break;O=A[_++]}else{if(_=A.next(),_.done)break;O=_.value}var k=O;R.config&&(R.config+=";"),R.config+=k+"="+w.parameters[k]}R.config&&a.fmtp.push(R)}for(var I=w.rtcpFeedback||[],P=Array.isArray(I),L=0,I=P?I:I[Symbol.iterator]();;){var x;if(P){if(L>=I.length)break;x=I[L++]}else{if(L=I.next(),L.done)break;x=L.value}var M=x;a.rtcpFb.push({payload:w.preferredPayloadType,subtype:M.parameter||void 0,type:M.type})}}}0===g.length?(a.payloads="9",a.port=0,a.direction="inactive"):a.payloads=g.join(" "),a.ssrcs=[],a.ssrcGroups=[];for(var D=d.values(),V=Array.isArray(D),N=0,D=V?D:D[Symbol.iterator]();;){var j;if(V){if(N>=D.length)break;j=D[N++]}else{if(N=D.next(),N.done)break;j=N.value}var U=j,F=U.rtpSender,B=U.stream.id,G=F.track;if("ended"!==G.readyState&&G.kind===n){U.ssrc||(U.ssrc=this.randomSSRC());var H=u&&"video"===G.kind;H&&!U.rtxSsrc&&(U.rtxSsrc=U.ssrc+1),a.ssrcs.push({attribute:"cname",id:U.ssrc,value:CNAME}),a.ssrcs.push({attribute:"msid",id:U.ssrc,value:B+" "+G.id}),a.ssrcs.push({attribute:"mslabel",id:U.ssrc,value:B}),a.ssrcs.push({attribute:"label",id:U.ssrc,value:G.id}),H&&(a.ssrcs.push({attribute:"cname",id:U.rtxSsrc,value:CNAME}),a.ssrcs.push({attribute:"msid",id:U.rtxSsrc,value:B+" "+G.id}),a.ssrcs.push({attribute:"mslabel",id:U.rtxSsrc,value:B}),a.ssrcs.push({attribute:"label",id:U.rtxSsrc,value:G.id}),a.ssrcGroups.push({semantics:"FID",ssrcs:U.ssrc+" "+U.rtxSsrc}))}}a.ext=[];for(var W=c.headerExtensions,z=Array.isArray(W),Y=0,W=z?W:W[Symbol.iterator]();;){var J;if(z){if(Y>=W.length)break;J=W[Y++]}else{if(Y=W.next(),Y.done)break;J=Y.value}var $=J;$.kind&&$.kind!==n||a.ext.push({value:$.preferredId,uri:$.uri})}a.rtcpMux="rtcp-mux",a.rtcpRsize="rtcp-rsize"}i.media.push(a)}var i={},r=this._iceGatherer.getLocalParameters(),o=this._iceGatherer.getLocalCandidates(),a=this._dtlsTransport.getLocalParameters(),s=this._dtlsTransport.getRemoteParameters(),c=this._localCapabilities,d=this._localTrackInfos;"offer"===t&&this._sdpGlobalFields.version++,i.version=0,i.origin={address:"127.0.0.1",ipVer:4,netType:"IN",sessionId:this._sdpGlobalFields.id,sessionVersion:this._sdpGlobalFields.version,username:"jitsi-ortc-webrtc-shim"},i.name="-",i.timing={start:0,stop:0},i.msidSemantic={semantic:"WMS",token:"*"},i.groups=[{mids:Array.from(this._mids.keys()).join(" "),type:"BUNDLE"}],i.media=[],i.fingerprint={hash:a.fingerprints[0].value,type:a.fingerprints[0].algorithm};for(var u=!1,l=c.codecs,p=Array.isArray(l),h=0,l=p?l:l[Symbol.iterator]();;){var f;if(p){if(h>=l.length)break;f=l[h++]}else{if(h=l.next(),h.done)break;f=h.value}var m=f;if("video"===m.kind&&"rtx"===m.name){u=!0;break}}for(var v=this._mids,g=Array.isArray(v),y=0,v=g?v:v[Symbol.iterator]();;){var S;if(g){if(y>=v.length)break;S=v[y++]}else{if(y=v.next(),y.done)break;S=y.value}var b=S,C=b[0],w=b[1];n.call(this,C,w)}var T=new RTCSessionDescription({type:t,_sdpObject:i});return T},mergeConstraints:function(e,t){if(!e||!t)return e||t;var n=e;for(var i in t)n[i]=t[i];return n},iceCandidateType:function(e){return e.split(" ")[7]},formatTypePreference:function(e){if(/Chrome\/\d+/.test(navigator.userAgent))switch(e){case 0:return"TURN/TLS";case 1:return"TURN/TCP";case 2:return"TURN/UDP"}else if(/Firefox\/\d+/.test(navigator.userAgent))switch(e){case 0:return"TURN/TCP";case 5:return"TURN/UDP"}return""},maybeSetOpusOptions:function(e,t){return"true"===t.opusStereo?e=this.setCodecParam(e,"opus/48000","stereo","1"):"false"===t.opusStereo&&(e=this.removeCodecParam(e,"opus/48000","stereo")),"true"===t.opusFec?e=this.setCodecParam(e,"opus/48000","useinbandfec","1"):"false"===t.opusFec&&(e=this.removeCodecParam(e,"opus/48000","useinbandfec")),"true"===t.opusDtx?e=this.setCodecParam(e,"opus/48000","usedtx","1"):"false"===t.opusDtx&&(e=this.removeCodecParam(e,"opus/48000","usedtx")),t.opusMaxPbr&&(e=this.setCodecParam(e,"opus/48000","maxplaybackrate",t.opusMaxPbr)),e},maybeSetAudioSendBitRate:function(e,t){return t.audioSendBitrate?this.preferBitRate(e,t.audioSendBitrate,"audio"):e},maybeSetAudioReceiveBitRate:function(e,t){return t.audioRecvBitrate?this.preferBitRate(e,t.audioRecvBitrate,"audio"):e},maybeSetVideoSendBitRate:function(e,t){return t.videoSendBitrate?this.preferBitRate(e,t.videoSendBitrate,"video"):e},maybeSetVideoReceiveBitRate:function(e,t){return t.videoRecvBitrate?this.preferBitRate(e,t.videoRecvBitrate,"video"):e},preferBitRate:function(e,t,n){var i=e.split("\r\n"),r=this.findLine(i,"m=",n);if(null===r)return e;var o=this.findLineInRange(i,r+1,-1,"m=");null===o&&(o=i.length);var a=this.findLineInRange(i,r+1,o,"c=");if(null===a)return e;var s=this.findLineInRange(i,a+1,o,"b=AS");s&&i.splice(s,1);var c="b=AS:"+t;return i.splice(a+1,0,c),e=i.join("\r\n")},maybeSetVideoSendInitialBitRate:function(e,t){var n=t.videoSendInitialBitrate;if(!n)return e;var i=n,r=t.videoSendBitrate;r&&(n>r&&(n=r,t.videoSendInitialBitrate=n),i=r);var o=e.split("\r\n"),a=this.findLine(o,"m=","video");if(null===a)return e;var s=t.videoRecvCodec;return e=this.setCodecParam(e,s,"x-google-min-bitrate",t.videoSendInitialBitrate.toString()),e=this.setCodecParam(e,s,"x-google-max-bitrate",i.toString())},removePayloadTypeFromMline: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(" ")},removeCodecByName:function(e,t){var n=this.findLine(e,"a=rtpmap",t);if(null===n)return e;var i=this.getCodecPayloadTypeFromLine(e[n]);e.splice(n,1);var r=this.findLine(e,"m=","video");return null===r?e:(e[r]=this.removePayloadTypeFromMline(e[r],i),e)},removeCodecByPayloadType:function(e,t){var n=this.findLine(e,"a=rtpmap",t.toString());if(null===n)return e;e.splice(n,1);var i=this.findLine(e,"m=","video");return null===i?e:(e[i]=this.removePayloadTypeFromMline(e[i],t),e)},maybeRemoveVideoFec:function(e,t){if("false"!==t.videoFec)return e;var n=e.split("\r\n"),i=this.findLine(n,"a=rtpmap","red");if(null===i)return e;var r=this.getCodecPayloadTypeFromLine(n[i]);if(n=this.removeCodecByPayloadType(n,r),n=this.removeCodecByName(n,"ulpfec"),i=this.findLine(n,"a=fmtp",r.toString()),null===i)return e;var o=this.parseFmtpLine(n[i]),a=o.pt;return null===a?e:(n.splice(i,1),n=this.removeCodecByPayloadType(n,a),n.join("\r\n"))},maybePreferAudioSendCodec:function(e,t){return this.maybePreferCodec(e,"audio","send",t.audioSendCodec)},maybePreferAudioReceiveCodec:function(e,t){return this.maybePreferCodec(e,"audio","receive",t.audioRecvCodec)},maybePreferVideoSendCodec:function(e,t){return this.maybePreferCodec(e,"video","send",t.videoSendCodec)},maybePreferVideoReceiveCodec:function(e,t){return this.maybePreferCodec(e,"video","receive",t.videoRecvCodec)},maybePreferCodec:function(e,t,n,i){if(!i)return e;var r=e.split("\r\n"),o=this.findLine(r,"m=",t);if(null===o)return e;var a=this.getCodecPayloadType(r,i);return a&&(r[o]=this.setDefaultCodec(r[o],a)),e=r.join("\r\n")},setCodecParam:function(e,t,n,i){var r=e.split("\r\n"),o=this.findFmtpLine(r,t),a={};if(null===o){var s=this.findLine(r,"a=rtpmap",t);if(null===s)return e;var c=this.getCodecPayloadTypeFromLine(r[s]);a.pt=c.toString(),a.params={},a.params[n]=i,r.splice(s+1,0,this.writeFmtpLine(a))}else a=this.parseFmtpLine(r[o]),a.params[n]=i,r[o]=this.writeFmtpLine(a);return e=r.join("\r\n")},removeCodecParam:function(e,t,n){var i=e.split("\r\n"),r=this.findFmtpLine(i,t);if(null===r)return e;var o=this.parseFmtpLine(i[r]);delete o.params[n];var a=this.writeFmtpLine(o);return null===a?i.splice(r,1):i[r]=a,e=i.join("\r\n")},parseFmtpLine:function(e){var t={},n=e.indexOf(" "),i=e.substring(n+1).split("; "),r=new RegExp("a=fmtp:(\\d+)"),o=e.match(r);if(!o||2!==o.length)return null;t.pt=o[1];for(var a={},s=0;s<i.length;++s){var c=i[s].split("=");2===c.length&&(a[c[0]]=c[1])}return t.params=a,t},writeFmtpLine:function(e){if(!e.hasOwnProperty("pt")||!e.hasOwnProperty("params"))return null;var t=e.pt,n=e.params,i=[],r=0;for(var o in n)i[r]=o+"="+n[o],++r;return 0===r?null:"a=fmtp:"+t.toString()+" "+i.join("; ")},findFmtpLine:function(e,t){var n=this.getCodecPayloadType(e,t);return n?this.findLine(e,"a=fmtp:"+n.toString()):null},findLine:function(e,t,n){return this.findLineInRange(e,0,-1,t,n)},findLineInRange:function(e,t,n,i,r){for(var o=n!==-1?n:e.length,a=t;a<o;++a)if(0===e[a].indexOf(i)&&(!r||e[a].toLowerCase().indexOf(r.toLowerCase())!==-1))return a;return null},getCodecPayloadType:function(e,t){var n=this.findLine(e,"a=rtpmap",t);return n?this.getCodecPayloadTypeFromLine(e[n]):null},getCodecPayloadTypeFromLine: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},setDefaultCodec:function(e,t){var n=e.split(" "),i=n.slice(0,3);i.push(t);for(var r=3;r<n.length;r++)n[r]!==t&&i.push(n[r]);return i.join(" ")}}},185:function(e,t){"use strict";var n,i,r=navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||(navigator.mediaDevices=navigator.mediaDevices||{},navigator.mediaDevices.getUserMedia=function(e){return new Promise(function(t,n){return navigator.getUserMedia?void navigator.getUserMedia(e,function(e){t(e)},function(e){n(e)}):n("当前浏览器还不支持API: getUserMedia")})});var o=window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext,a=window.RTCPeerConnection=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection,s=window.RTCDataChannel=window.RTCDataChannel||window.DataChannel,c=window.RTCSessionDescription=window.RTCSessionDescription||window.mozRTCSessionDescription,d=window.RTCIceCandidate=window.RTCIceCandidate||window.mozRTCIceCandidate,u=window.MediaStream=window.MediaStream||window.webkitMediaStream;window.mozRTCPeerConnection||navigator.mozGetUserMedia?(n="moz",i=parseInt(navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1],10)):(window.webkitRTCPeerConnection||navigator.webkitGetUserMedia)&&(n="webkit",i=navigator.userAgent.match(/Chrom(e|ium)/)&&parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2],10));var l="https:"===window.location.protocol&&("webkit"===n&&i>=26||"moz"===n&&i>=33),p=document.createElement("video"),h=p&&p.canPlayType&&"probably"===p.canPlayType('video/webm; codecs="vp8", vorbis');e.exports={prefix:n,browserVersion:i,support:!!r||!!a,RTCPeerConnection:!!a,Vp8:h,GetUserMedia:!!r,DataChannel:!!(a&&s&&a.prototype&&a.prototype.createDataChannel),WebAudio:!(!o||!o.prototype.createMediaStreamSource),MediaStream:!!u,ScreenSharing:!!l,AudioContext:o,RTCSessionDescription:c,RTCIceCandidate:d,getUserMedia:r}},190:function(e,t,n){var i=n(191),r=n(192);t.write=r,t.parse=i.parse,t.parseFmtpConfig=i.parseFmtpConfig,t.parseParams=i.parseParams,t.parsePayloads=i.parsePayloads,t.parseRemoteCandidates=i.parseRemoteCandidates,t.parseImageAttributes=i.parseImageAttributes,t.parseSimulcastStreamList=i.parseSimulcastStreamList},191:function(e,t,n){var i=function(e){return String(Number(e))===e?Number(e):e},r=function(e,t,n,r){if(r&&!n)t[r]=i(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(t[n[o]]=i(e[o+1]))},o=function(e,t,n){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var o=e.push?{}:i?t[e.name]:t;r(n.match(e.reg),o,e.names,e.name),e.push&&t[e.push].push(o)},a=n(175),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(e){var t={},n=[],i=t;return e.split(/(\r\n|\r|\n)/).filter(s).forEach(function(e){var t=e[0],r=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),i=n[n.length-1]);for(var s=0;s<(a[t]||[]).length;s+=1){var c=a[t][s];if(c.reg.test(r))return o(c,i,r)}}),t.media=n,t};var c=function(e,t){var n=t.split(/=(.+)/,2);return 2===n.length&&(e[n[0]]=i(n[1])),e};t.parseParams=function(e){return e.split(/\;\s?/).reduce(c,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(i),r=0;r<n.length;r+=3)t.push({component:n[r],ip:n[r+1],port:n[r+2]});return t},t.parseImageAttributes=function(e){return e.split(" ").map(function(e){return e.substring(1,e.length-1).split(",").reduce(c,{})})},t.parseSimulcastStreamList=function(e){return e.split(";").map(function(e){return e.split(",").map(function(e){var t,n=!1;return"~"!==e[0]?t=i(e):(t=i(e.substring(1,e.length)),n=!0),{scid:t,paused:n}})})}},192:function(e,t,n){var i=n(175),r=/%[sdv%]/g,o=function(e){var t=1,n=arguments,i=n.length;return e.replace(r,function(e){if(t>=i)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}})},a=function(e,t,n){var i=t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format,r=[e+"="+i];if(t.names)for(var a=0;a<t.names.length;a+=1){var s=t.names[a];t.name?r.push(n[t.name][s]):r.push(n[t.names[a]])}else r.push(n[t.name]);return o.apply(null,r)},s=["v","o","s","i","u","e","p","c","b","t","r","z","a"],c=["i","c","b","a"];e.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var n=t.outerOrder||s,r=t.innerOrder||c,o=[];return n.forEach(function(t){i[t].forEach(function(n){n.name in e&&null!=e[n.name]?o.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach(function(e){o.push(a(t,n,e))})})}),e.media.forEach(function(e){o.push(a("m",i.m[0],e)),r.forEach(function(t){i[t].forEach(function(n){n.name in e&&null!=e[n.name]?o.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach(function(e){o.push(a(t,n,e))})})})}),o.join("\r\n")+"\r\n"}},193:function(e,t){"use strict";var n={};n.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},n.localCName=n.generateIdentifier(),n.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},n.splitSections=function(e){var t=e.split("\nm=");return t.map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},n.matchPrefix=function(e,t){return n.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},n.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:t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},i=8;i<t.length;i+=2)switch(t[i]){case"raddr":n.relatedAddress=t[i+1];break;case"rport":n.relatedPort=parseInt(t[i+1],10);break;case"tcptype":n.tcpType=t[i+1]}return n},n.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)),"candidate:"+t.join(" ")},n.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.numChannels=3===t.length?parseInt(t[2],10):1,n},n.writeRtpMap=function(e){var t=e.payloadType;return void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType),"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==e.numChannels?"/"+e.numChannels:"")+"\r\n"},n.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),uri:t[1]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,n={},i=e.substr(e.indexOf(" ")+1).split(";"),r=0;r<i.length;r++)t=i[r].trim().split("="),n[t[0].trim()]=t[1];return n},n.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var i=[];Object.keys(e.parameters).forEach(function(t){i.push(t+"="+e.parameters[t])}),t+="a=fmtp:"+n+" "+i.join(";")+"\r\n"}return t},n.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},n.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},n.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},i=e.indexOf(":",t);return i>-1?(n.attribute=e.substr(t+1,i-t-1),n.value=e.substr(i+1)):n.attribute=e.substr(t+1),n},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.getDtlsParameters=function(e,t){var i=n.splitLines(e);i=i.concat(n.splitLines(t));var r=i.filter(function(e){return 0===e.indexOf("a=fingerprint:")})[0].substr(14),o={role:"auto",fingerprints:[{algorithm:r.split(" ")[0].toLowerCase(),value:r.split(" ")[1]}]};return o},n.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},n.getIceParameters=function(e,t){var i=n.splitLines(e);i=i.concat(n.splitLines(t));var r={usernameFragment:i.filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:i.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)};return r},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=n.splitLines(e),r=i[0].split(" "),o=3;o<r.length;o++){var a=r[o],s=n.matchPrefix(e,"a=rtpmap:"+a+" ")[0];if(s){var c=n.parseRtpMap(s),d=n.matchPrefix(e,"a=fmtp:"+a+" ");switch(c.parameters=d.length?n.parseFmtp(d[0]):{},c.rtcpFeedback=n.matchPrefix(e,"a=rtcp-fb:"+a+" ").map(n.parseRtcpFb),t.codecs.push(c),c.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(c.name.toUpperCase())}}}return n.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(n.parseExtmap(e))}),t},n.writeRtpDescription=function(e,t){var i="";i+="m="+e+" ",i+=t.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",i+="c=IN IP4 0.0.0.0\r\n",i+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){i+=n.writeRtpMap(e),i+=n.writeFmtp(e),i+=n.writeRtcpFb(e)});var r=0;return t.codecs.forEach(function(e){e.maxptime>r&&(r=e.maxptime)}),r>0&&(i+="a=maxptime:"+r+"\r\n"),i+="a=rtcp-mux\r\n",t.headerExtensions.forEach(function(e){i+=n.writeExtmap(e)}),i},n.parseRtpEncodingParameters=function(e){var t,i=[],r=n.parseRtpParameters(e),o=r.fecMechanisms.indexOf("RED")!==-1,a=r.fecMechanisms.indexOf("ULPFEC")!==-1,s=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,d=n.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.split(" ");return t.shift(),t.map(function(e){return parseInt(e,10)})});d.length>0&&d[0].length>1&&d[0][0]===c&&(t=d[0][1]),r.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10),rtx:{ssrc:t}};i.push(n),o&&(n=JSON.parse(JSON.stringify(n)),
n.fec={ssrc:t,mechanism:a?"red+ulpfec":"red"},i.push(n))}}),0===i.length&&c&&i.push({ssrc:c});var u=n.matchPrefix(e,"b=");return u.length&&(0===u[0].indexOf("b=TIAS:")?u=parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")&&(u=parseInt(u[0].substr(5),10)),i.forEach(function(e){e.maxBitrate=u})),i},n.parseRtcpParameters=function(e){var t={},i=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];i&&(t.cname=i.value,t.ssrc=i.ssrc);var r=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=r.length>0,t.compound=0===r.length;var o=n.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},n.parseMsid=function(e){var t,i=n.matchPrefix(e,"a=msid:");if(1===i.length)return t=i[0].substr(7).split(" "),{stream:t[0],track:t[1]};var r=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return r.length>0?(t=r[0].value.split(" "),{stream:t[0],track:t[1]}):void 0},n.writeSessionBoilerplate=function(){return"v=0\r\no=thisisadapterortc 8169639915646943137 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,i,r){var o=n.writeRtpDescription(e.kind,t);if(o+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===i?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",o+=e.rtpSender&&e.rtpReceiver?"a=sendrecv\r\n":e.rtpSender?"a=sendonly\r\n":e.rtpReceiver?"a=recvonly\r\n":"a=inactive\r\n",e.rtpSender){var a="msid:"+r.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+a,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),o},n.getDirection=function(e,t){for(var i=n.splitLines(e),r=0;r<i.length;r++)switch(i[r]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[r].substr(2)}return t?n.getDirection(t):"sendrecv"},n.getKind=function(e){var t=n.splitLines(e),i=t[0].split(" ");return i[0].substr(2)},n.isRejected=function(e){return"0"===e.split(" ",2)[1]},e.exports=n},194:function(e,t,n){"use strict";var i=n(31).log,r=n(31).browserDetails,o={shimMediaStream:function(){window.MediaStream=window.MediaStream||window.webkitMediaStream},shimOnTrack:function(){"object"!=typeof window||!window.RTCPeerConnection||"ontrack"in window.RTCPeerConnection.prototype||Object.defineProperty(window.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){var t=this;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.addEventListener("addtrack",function(n){var i=new Event("track");i.track=n.track,i.receiver={track:n.track},i.streams=[e.stream],t.dispatchEvent(i)}),e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}})},shimGetSendersWithDtmf:function(){if("object"==typeof window&&window.RTCPeerConnection&&!("getSenders"in RTCPeerConnection.prototype)&&"createDTMFSender"in RTCPeerConnection.prototype){RTCPeerConnection.prototype.getSenders=function(){return this._senders};var e=RTCPeerConnection.prototype.addStream,t=RTCPeerConnection.prototype.removeStream;RTCPeerConnection.prototype.addStream=function(t){var n=this;n._senders=n._senders||[],e.apply(n,[t]),t.getTracks().forEach(function(e){n._senders.push({track:e,get dtmf(){return void 0===this._dtmf&&("audio"===e.kind?this._dtmf=n.createDTMFSender(e):this._dtmf=null),this._dtmf}})})},RTCPeerConnection.prototype.removeStream=function(e){var n=this;n._senders=n._senders||[],t.apply(n,[e]),e.getTracks().forEach(function(e){var t=n._senders.find(function(t){return t.track===e});t&&n._senders.splice(n._senders.indexOf(t),1)})}}},shimSourceObject:function(){"object"==typeof window&&(!window.HTMLMediaElement||"srcObject"in window.HTMLMediaElement.prototype||Object.defineProperty(window.HTMLMediaElement.prototype,"srcObject",{get:function(){return this._srcObject},set:function(e){var t=this;return this._srcObject=e,this.src&&URL.revokeObjectURL(this.src),e?(this.src=URL.createObjectURL(e),e.addEventListener("addtrack",function(){t.src&&URL.revokeObjectURL(t.src),t.src=URL.createObjectURL(e)}),void e.addEventListener("removetrack",function(){t.src&&URL.revokeObjectURL(t.src),t.src=URL.createObjectURL(e)})):void(this.src="")}}))},shimPeerConnection:function(){if(window.RTCPeerConnection){var e=RTCPeerConnection;window.RTCPeerConnection=function(t,n){if(t&&t.iceServers){for(var i=[],r=0;r<t.iceServers.length;r++){var o=t.iceServers[r];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(o=JSON.parse(JSON.stringify(o)),o.urls=o.url,i.push(o)):i.push(t.iceServers[r])}t.iceServers=i}return new e(t,n)},window.RTCPeerConnection.prototype=e.prototype,Object.defineProperty(window.RTCPeerConnection,"generateCertificate",{get:function(){return e.generateCertificate}})}else window.RTCPeerConnection=function(e,t){return i("PeerConnection"),e&&e.iceTransportPolicy&&(e.iceTransports=e.iceTransportPolicy),new webkitRTCPeerConnection(e,t)},window.RTCPeerConnection.prototype=webkitRTCPeerConnection.prototype,webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(window.RTCPeerConnection,"generateCertificate",{get:function(){return webkitRTCPeerConnection.generateCertificate}});var t=RTCPeerConnection.prototype.getStats;RTCPeerConnection.prototype.getStats=function(e,n,i){var r=this,o=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof arguments[0]))return t.apply(this,[]);var a=function(e){var t={},n=e.result();return n.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){o[1](s(a(e)))};return t.apply(this,[c,arguments[0]])}return new Promise(function(e,n){t.apply(r,[function(t){e(s(a(t)))},n])}).then(n,i)},r.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=RTCPeerConnection.prototype[e];RTCPeerConnection.prototype[e]=function(){var e=arguments,n=this,i=new Promise(function(i,r){t.apply(n,[e[0],i,r])});return e.length<2?i:i.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}}),r.version<52&&["createOffer","createAnswer"].forEach(function(e){var t=RTCPeerConnection.prototype[e];RTCPeerConnection.prototype[e]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var n=1===arguments.length?arguments[0]:void 0;return new Promise(function(i,r){t.apply(e,[i,r,n])})}return t.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=RTCPeerConnection.prototype[e];RTCPeerConnection.prototype[e]=function(){return arguments[0]=new("addIceCandidate"===e?RTCIceCandidate:RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}});var n=RTCPeerConnection.prototype.addIceCandidate;RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}};e.exports={shimMediaStream:o.shimMediaStream,shimOnTrack:o.shimOnTrack,shimGetSendersWithDtmf:o.shimGetSendersWithDtmf,shimSourceObject:o.shimSourceObject,shimPeerConnection:o.shimPeerConnection,shimGetUserMedia:n(195)}},195:function(e,t,n){"use strict";var i=n(31).log,r=n(31).browserDetails;e.exports=function(){var e=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 i="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);var r=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];var o={};"number"==typeof i.ideal?(o[r("min",n)]=i.ideal,t.optional.push(o),o={},o[r("max",n)]=i.ideal,t.optional.push(o)):(o[r("",n)]=i.ideal,t.optional.push(o))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[r("",n)]=i.exact):["min","max"].forEach(function(e){void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[r(e,n)]=i[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},t=function(t,n){if(t=JSON.parse(JSON.stringify(t)),t&&t.audio&&(t.audio=e(t.audio)),t&&"object"==typeof t.video){var o=t.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});var a=r.version<61;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!navigator.mediaDevices.getSupportedConstraints||!navigator.mediaDevices.getSupportedConstraints().facingMode||a)){delete t.video.facingMode;var s;if("environment"===o.exact||"environment"===o.ideal?s=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(s=["front"]),s)return navigator.mediaDevices.enumerateDevices().then(function(r){r=r.filter(function(e){return"videoinput"===e.kind});var a=r.find(function(e){return s.some(function(t){return e.label.toLowerCase().indexOf(t)!==-1})});return!a&&r.length&&s.indexOf("back")!==-1&&(a=r[r.length-1]),a&&(t.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),t.video=e(t.video),i("chrome: "+JSON.stringify(t)),n(t)})}t.video=e(t.video)}return i("chrome: "+JSON.stringify(t)),n(t)},n=function(e){return{name:{PermissionDeniedError:"NotAllowedError",ConstraintNotSatisfiedError:"OverconstrainedError"}[e.name]||e.name,message:e.message,constraint:e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},o=function(e,i,r){t(e,function(e){navigator.webkitGetUserMedia(e,i,function(e){r(n(e))})})};navigator.getUserMedia=o;var a=function(e){return new Promise(function(t,n){navigator.getUserMedia(e,t,n)})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:a,enumerateDevices:function(){return new Promise(function(e){var t={audio:"audioinput",video:"videoinput"};return MediaStreamTrack.getSources(function(n){e(n.map(function(e){return{label:e.label,kind:t[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),navigator.mediaDevices.getUserMedia){var s=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(e){return t(e,function(e){return s(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(n(e))})})}}else navigator.mediaDevices.getUserMedia=function(e){return a(e)};"undefined"==typeof navigator.mediaDevices.addEventListener&&(navigator.mediaDevices.addEventListener=function(){i("Dummy mediaDevices.addEventListener called.")}),"undefined"==typeof navigator.mediaDevices.removeEventListener&&(navigator.mediaDevices.removeEventListener=function(){i("Dummy mediaDevices.removeEventListener called.")})}},196:function(e,t,n){"use strict";var i=n(31).browserDetails,r=n(198);e.exports={shimGetUserMedia:n(197),shimPeerConnection:function(){if(window.RTCIceGatherer&&(window.RTCIceCandidate||(window.RTCIceCandidate=function(e){return e}),window.RTCSessionDescription||(window.RTCSessionDescription=function(e){return e}),i.version<15025)){var e=Object.getOwnPropertyDescriptor(MediaStreamTrack.prototype,"enabled");Object.defineProperty(MediaStreamTrack.prototype,"enabled",{set:function(t){e.set.call(this,t);var n=new Event("enabled");n.enabled=t,this.dispatchEvent(n)}})}window.RTCPeerConnection=r(i.version)},shimReplaceTrack:function(){!window.RTCRtpSender||"replaceTrack"in RTCRtpSender.prototype||(RTCRtpSender.prototype.replaceTrack=RTCRtpSender.prototype.setTrack)}}},197:function(e,t){"use strict";e.exports=function(){var e=function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}},t=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(n){return t(n)["catch"](function(t){return Promise.reject(e(t))})}}},198:function(e,t,n){"use strict";function i(e){var t=e.filter(function(e){return"audio"===e.kind}),n=e.filter(function(e){return"video"===e.kind});for(e=[];t.length||n.length;)t.length&&e.push(t.shift()),n.length&&e.push(n.shift());return e}function r(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;var r="string"==typeof i;return r&&(i=[i]),i=i.filter(function(e){var i=0===e.indexOf("turn:")&&e.indexOf("transport=udp")!==-1&&e.indexOf("turn:[")===-1&&!n;return i?(n=!0,!0):0===e.indexOf("stun:")&&t>=14393}),delete e.url,e.urls=r?i[0]:i,!!i.length}return!1})}var o=n(193);e.exports=function(e){var t=function(t){var n=this,i=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){n[e]=i[e].bind(i)}),this.onicecandidate=null,this.onaddstream=null,this.ontrack=null,this.onremovestream=null,this.onsignalingstatechange=null,this.oniceconnectionstatechange=null,this.onicegatheringstatechange=null,this.onnegotiationneeded=null,this.ondatachannel=null,this.canTrickleIceCandidates=null,this.localStreams=[],this.remoteStreams=[],this.getLocalStreams=function(){return n.localStreams},this.getRemoteStreams=function(){return n.remoteStreams},this.localDescription=new RTCSessionDescription({type:"",sdp:""}),this.remoteDescription=new RTCSessionDescription({type:"",sdp:""}),this.signalingState="stable",this.iceConnectionState="new",this.iceGatheringState="new",this.iceOptions={gatherPolicy:"all",iceServers:[]},t&&t.iceTransportPolicy)switch(t.iceTransportPolicy){case"all":case"relay":this.iceOptions.gatherPolicy=t.iceTransportPolicy}this.usingBundle=t&&"max-bundle"===t.bundlePolicy,t&&t.iceServers&&(this.iceOptions.iceServers=r(t.iceServers,e)),this._config=t||{},this.transceivers=[],this._localIceCandidatesBuffer=[]};return t.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this.dispatchEvent(e),null!==this.onicegatheringstatechange&&this.onicegatheringstatechange(e)},t.prototype._emitBufferedCandidates=function(){var e=this,t=o.splitSections(e.localDescription.sdp);this._localIceCandidatesBuffer.forEach(function(n){var i=!n.candidate||0===Object.keys(n.candidate).length;if(i)for(var r=1;r<t.length;r++)t[r].indexOf("\r\na=end-of-candidates\r\n")===-1&&(t[r]+="a=end-of-candidates\r\n");else t[n.candidate.sdpMLineIndex+1]+="a="+n.candidate.candidate+"\r\n";if(e.localDescription.sdp=t.join(""),e.dispatchEvent(n),null!==e.onicecandidate&&e.onicecandidate(n),!n.candidate&&"complete"!==e.iceGatheringState){var o=e.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});o&&"complete"!==e.iceGatheringStateChange&&(e.iceGatheringState="complete",e._emitGatheringStateChange())}}),this._localIceCandidatesBuffer=[]},t.prototype.getConfiguration=function(){return this._config},t.prototype.addStream=function(t){if(e>=15025)this.localStreams.push(t);else{var n=t.clone();t.getTracks().forEach(function(e,t){var i=n.getTracks()[t];e.addEventListener("enabled",function(e){i.enabled=e.enabled})}),this.localStreams.push(n)}this._maybeFireNegotiationNeeded()},t.prototype.removeStream=function(e){var t=this.localStreams.indexOf(e);t>-1&&(this.localStreams.splice(t,1),this._maybeFireNegotiationNeeded())},t.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},t.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},t.prototype._getCommonCapabilities=function(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},i=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]},r=function(e,t,n,r){var o=i(e.parameters.apt,n),a=i(t.parameters.apt,r);return o&&a&&o.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach(function(i){for(var o=0;o<t.codecs.length;o++){var a=t.codecs[o];if(i.name.toLowerCase()===a.name.toLowerCase()&&i.clockRate===a.clockRate){if("rtx"===i.name.toLowerCase()&&i.parameters&&a.parameters.apt&&!r(i,a,e.codecs,t.codecs))continue;a=JSON.parse(JSON.stringify(a)),a.numChannels=Math.min(i.numChannels,a.numChannels),n.codecs.push(a),a.rtcpFeedback=a.rtcpFeedback.filter(function(e){for(var t=0;t<i.rtcpFeedback.length;t++)if(i.rtcpFeedback[t].type===e.type&&i.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var i=0;i<t.headerExtensions.length;i++){var r=t.headerExtensions[i];if(e.uri===r.uri){n.headerExtensions.push(r);break}}}),n},t.prototype._createIceAndDtlsTransports=function(e,t){var n=this,i=new RTCIceGatherer(n.iceOptions),r=new RTCIceTransport(i);i.onlocalcandidate=function(a){var s=new Event("icecandidate");s.candidate={sdpMid:e,sdpMLineIndex:t};var c=a.candidate,d=!c||0===Object.keys(c).length;d?void 0===i.state&&(i.state="completed"):(c.component="RTCP"===r.component?2:1,s.candidate.candidate=o.writeCandidate(c));var u=o.splitSections(n.localDescription.sdp);d?u[s.candidate.sdpMLineIndex+1]+="a=end-of-candidates\r\n":u[s.candidate.sdpMLineIndex+1]+="a="+s.candidate.candidate+"\r\n",n.localDescription.sdp=u.join("");var l=n._pendingOffer?n._pendingOffer:n.transceivers,p=l.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});switch(n.iceGatheringState){case"new":d||n._localIceCandidatesBuffer.push(s),d&&p&&n._localIceCandidatesBuffer.push(new Event("icecandidate"));break;case"gathering":n._emitBufferedCandidates(),d||(n.dispatchEvent(s),null!==n.onicecandidate&&n.onicecandidate(s)),p&&(n.dispatchEvent(new Event("icecandidate")),null!==n.onicecandidate&&n.onicecandidate(new Event("icecandidate")),n.iceGatheringState="complete",n._emitGatheringStateChange());break;case"complete":}},r.onicestatechange=function(){n._updateConnectionState()};var a=new RTCDtlsTransport(r);return a.ondtlsstatechange=function(){n._updateConnectionState()},a.onerror=function(){a.state="failed",n._updateConnectionState()},{iceGatherer:i,iceTransport:r,dtlsTransport:a}},t.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 i=this.transceivers[e].dtlsTransport;i&&(delete i.ondtlssttatechange,delete i.onerror,delete this.transceivers[e].dtlsTransport)},t.prototype._transceive=function(t,n,i){var r=this._getCommonCapabilities(t.localCapabilities,t.remoteCapabilities);n&&t.rtpSender&&(r.encodings=t.sendEncodingParameters,r.rtcp={cname:o.localCName,compound:t.rtcpParameters.compound},t.recvEncodingParameters.length&&(r.rtcp.ssrc=t.recvEncodingParameters[0].ssrc),t.rtpSender.send(r)),i&&t.rtpReceiver&&("video"===t.kind&&t.recvEncodingParameters&&e<15019&&t.recvEncodingParameters.forEach(function(e){delete e.rtx}),r.encodings=t.recvEncodingParameters,r.rtcp={cname:t.rtcpParameters.cname,compound:t.rtcpParameters.compound},t.sendEncodingParameters.length&&(r.rtcp.ssrc=t.sendEncodingParameters[0].ssrc),t.rtpReceiver.receive(r))},t.prototype.setLocalDescription=function(e){var t,n,i=this;if("offer"===e.type)this._pendingOffer&&(t=o.splitSections(e.sdp),n=t.shift(),t.forEach(function(e,t){var n=o.parseRtpParameters(e);i._pendingOffer[t].localCapabilities=n}),this.transceivers=this._pendingOffer,delete this._pendingOffer);else if("answer"===e.type){t=o.splitSections(i.remoteDescription.sdp),n=t.shift();var r=o.matchPrefix(n,"a=ice-lite").length>0;t.forEach(function(e,t){var a=i.transceivers[t],s=a.iceGatherer,c=a.iceTransport,d=a.dtlsTransport,u=a.localCapabilities,l=a.remoteCapabilities,p=o.isRejected(e);if(!p&&!a.isDatachannel){var h=o.getIceParameters(e,n),f=o.getDtlsParameters(e,n);r&&(f.role="server"),i.usingBundle&&0!==t||(c.start(s,h,r?"controlling":"controlled"),d.start(f));var m=i._getCommonCapabilities(u,l);i._transceive(a,m.codecs.length>0,!1)}})}switch(this.localDescription={type:e.type,sdp:e.sdp},e.type){case"offer":this._updateSignalingState("have-local-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+e.type+'"')}var a=arguments.length>1&&"function"==typeof arguments[1];if(a){var s=arguments[1];window.setTimeout(function(){s(),"new"===i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),i._emitBufferedCandidates()},0)}var c=Promise.resolve();return c.then(function(){a||("new"===i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),window.setTimeout(i._emitBufferedCandidates.bind(i),500))}),c},t.prototype.setRemoteDescription=function(t){var n=this,i={},r=[],a=o.splitSections(t.sdp),s=a.shift(),c=o.matchPrefix(s,"a=ice-lite").length>0,d=o.matchPrefix(s,"a=group:BUNDLE ").length>0,u=o.matchPrefix(s,"a=ice-options:")[0];switch(u?this.canTrickleIceCandidates=u.substr(14).split(" ").indexOf("trickle")>=0:this.canTrickleIceCandidates=!1,a.forEach(function(a,u){var l=o.splitLines(a),p=o.getKind(a),h=o.isRejected(a),f=l[0].substr(2).split(" ")[2],m=o.getDirection(a,s),v=o.parseMsid(a),g=o.getMid(a)||o.generateIdentifier();if("application"===p&&"DTLS/SCTP"===f)return void(n.transceivers[u]={mid:g,isDatachannel:!0});var y,S,b,C,w,T,R,A,E,_,O,k,I=o.parseRtpParameters(a);h||(O=o.getIceParameters(a,s),k=o.getDtlsParameters(a,s),k.role="client"),A=o.parseRtpEncodingParameters(a);var P=o.parseRtcpParameters(a),L=o.matchPrefix(a,"a=end-of-candidates",s).length>0,x=o.matchPrefix(a,"a=candidate:").map(function(e){return o.parseCandidate(e)}).filter(function(e){return"1"===e.component});if("offer"!==t.type||h)"answer"!==t.type||h||(d&&u>0&&(n._disposeIceAndDtlsTransports(u),n.transceivers[u].iceGatherer=n.transceivers[0].iceGatherer,n.transceivers[u].iceTransport=n.transceivers[0].iceTransport,n.transceivers[u].dtlsTransport=n.transceivers[0].dtlsTransport,n.transceivers[u].rtpSender&&n.transceivers[u].rtpSender.setTransport(n.transceivers[0].dtlsTransport),n.transceivers[u].rtpReceiver&&n.transceivers[u].rtpReceiver.setTransport(n.transceivers[0].dtlsTransport)),y=n.transceivers[u],S=y.iceGatherer,b=y.iceTransport,C=y.dtlsTransport,w=y.rtpSender,T=y.rtpReceiver,R=y.sendEncodingParameters,E=y.localCapabilities,n.transceivers[u].recvEncodingParameters=A,n.transceivers[u].remoteCapabilities=I,n.transceivers[u].rtcpParameters=P,(c||L)&&x.length&&b.setRemoteCandidates(x),d&&0!==u||(b.start(S,O,"controlling"),C.start(k)),n._transceive(y,"sendrecv"===m||"recvonly"===m,"sendrecv"===m||"sendonly"===m),!T||"sendrecv"!==m&&"sendonly"!==m?delete y.rtpReceiver:(_=T.track,v?(i[v.stream]||(i[v.stream]=new MediaStream),i[v.stream].addTrack(_),r.push([_,T,i[v.stream]])):(i["default"]||(i["default"]=new MediaStream),i["default"].addTrack(_),r.push([_,T,i["default"]]))));else{var M=d&&u>0?{iceGatherer:n.transceivers[0].iceGatherer,iceTransport:n.transceivers[0].iceTransport,dtlsTransport:n.transceivers[0].dtlsTransport}:n._createIceAndDtlsTransports(g,u);if(!L||d&&0!==u||M.iceTransport.setRemoteCandidates(x),E=RTCRtpReceiver.getCapabilities(p),e<15019&&(E.codecs=E.codecs.filter(function(e){return"rtx"!==e.name})),R=[{ssrc:1001*(2*u+2)}],"sendrecv"!==m&&"sendonly"!==m||(T=new RTCRtpReceiver(M.dtlsTransport,p),_=T.track,v?(i[v.stream]||(i[v.stream]=new MediaStream,Object.defineProperty(i[v.stream],"id",{get:function(){return v.stream}})),Object.defineProperty(_,"id",{get:function(){return v.track}}),i[v.stream].addTrack(_),r.push([_,T,i[v.stream]])):(i["default"]||(i["default"]=new MediaStream),i["default"].addTrack(_),r.push([_,T,i["default"]]))),n.localStreams.length>0&&n.localStreams[0].getTracks().length>=u){var D;"audio"===p?D=n.localStreams[0].getAudioTracks()[0]:"video"===p&&(D=n.localStreams[0].getVideoTracks()[0]),D&&(e>=15019&&"video"===p&&(R[0].rtx={ssrc:1001*(2*u+2)+1}),w=new RTCRtpSender(D,M.dtlsTransport))}n.transceivers[u]={iceGatherer:M.iceGatherer,iceTransport:M.iceTransport,dtlsTransport:M.dtlsTransport,localCapabilities:E,remoteCapabilities:I,rtpSender:w,rtpReceiver:T,kind:p,mid:g,rtcpParameters:P,sendEncodingParameters:R,recvEncodingParameters:A},n._transceive(n.transceivers[u],!1,"sendrecv"===m||"sendonly"===m)}}),this.usingBundle=d,this.remoteDescription={type:t.type,sdp:t.sdp},t.type){case"offer":this._updateSignalingState("have-remote-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+t.type+'"')}return Object.keys(i).forEach(function(e){var t=i[e];if(t.getTracks().length){n.remoteStreams.push(t);var o=new Event("addstream");o.stream=t,n.dispatchEvent(o),null!==n.onaddstream&&window.setTimeout(function(){n.onaddstream(o)},0),r.forEach(function(e){var i=e[0],r=e[1];if(t.id===e[2].id){var o=new Event("track");o.track=i,o.receiver=r,o.streams=[t],n.dispatchEvent(o),null!==n.ontrack&&window.setTimeout(function(){n.ontrack(o)},0)}})}}),arguments.length>1&&"function"==typeof arguments[1]&&window.setTimeout(arguments[1],0),Promise.resolve()},t.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._updateSignalingState("closed")},t.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this.dispatchEvent(t),null!==this.onsignalingstatechange&&this.onsignalingstatechange(t)},t.prototype._maybeFireNegotiationNeeded=function(){var e=new Event("negotiationneeded");this.dispatchEvent(e),null!==this.onnegotiationneeded&&this.onnegotiationneeded(e)},t.prototype._updateConnectionState=function(){var e,t=this,n={"new":0,closed:0,connecting:0,checking:0,connected:0,completed:0,failed:0};if(this.transceivers.forEach(function(e){n[e.iceTransport.state]++,n[e.dtlsTransport.state]++}),n.connected+=n.completed,e="new",n.failed>0?e="failed":n.connecting>0||n.checking>0?e="connecting":n.disconnected>0?e="disconnected":n["new"]>0?e="new":(n.connected>0||n.completed>0)&&(e="connected"),e!==t.iceConnectionState){t.iceConnectionState=e;var i=new Event("iceconnectionstatechange");this.dispatchEvent(i),null!==this.oniceconnectionstatechange&&this.oniceconnectionstatechange(i)}},t.prototype.createOffer=function(){var t=this;if(this._pendingOffer)throw new Error("createOffer called while there is a pending offer.");var n;1===arguments.length&&"function"!=typeof arguments[0]?n=arguments[0]:3===arguments.length&&(n=arguments[2]);var r=[],a=0,s=0;if(this.localStreams.length&&(a=this.localStreams.reduce(function(e,t){return e+t.getAudioTracks().length},0),s=this.localStreams.reduce(function(e,t){return e+t.getVideoTracks().length},0)),n){if(n.mandatory||n.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==n.offerToReceiveAudio&&(a=n.offerToReceiveAudio===!0?1:n.offerToReceiveAudio===!1?0:n.offerToReceiveAudio),void 0!==n.offerToReceiveVideo&&(s=n.offerToReceiveVideo===!0?1:n.offerToReceiveVideo===!1?0:n.offerToReceiveVideo)}for(this.localStreams.forEach(function(e){e.getTracks().forEach(function(t){r.push({kind:t.kind,track:t,stream:e,wantReceive:"audio"===t.kind?a>0:s>0}),"audio"===t.kind?a--:"video"===t.kind&&s--})});a>0||s>0;)a>0&&(r.push({kind:"audio",wantReceive:!0}),a--),s>0&&(r.push({kind:"video",wantReceive:!0}),s--);r=i(r);var c=o.writeSessionBoilerplate(),d=[];r.forEach(function(n,i){var r=n.track,a=n.kind,s=o.generateIdentifier(),c=t.usingBundle&&i>0?{iceGatherer:d[0].iceGatherer,iceTransport:d[0].iceTransport,dtlsTransport:d[0].dtlsTransport}:t._createIceAndDtlsTransports(s,i),u=RTCRtpSender.getCapabilities(a);e<15019&&(u.codecs=u.codecs.filter(function(e){return"rtx"!==e.name})),u.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1")});var l,p,h=[{ssrc:1001*(2*i+1)}];r&&(e>=15019&&"video"===a&&(h[0].rtx={ssrc:1001*(2*i+1)+1}),l=new RTCRtpSender(r,c.dtlsTransport)),n.wantReceive&&(p=new RTCRtpReceiver(c.dtlsTransport,a)),d[i]={iceGatherer:c.iceGatherer,iceTransport:c.iceTransport,dtlsTransport:c.dtlsTransport,localCapabilities:u,remoteCapabilities:null,rtpSender:l,rtpReceiver:p,kind:a,mid:s,sendEncodingParameters:h,recvEncodingParameters:null}}),"max-compat"!==this._config.bundlePolicy&&(c+="a=group:BUNDLE "+d.map(function(e){return e.mid}).join(" ")+"\r\n"),c+="a=ice-options:trickle\r\n",r.forEach(function(e,t){var n=d[t];c+=o.writeMediaSection(n,n.localCapabilities,"offer",e.stream),c+="a=rtcp-rsize\r\n"}),this._pendingOffer=d;var u=new RTCSessionDescription({type:"offer",sdp:c});return arguments.length&&"function"==typeof arguments[0]&&window.setTimeout(arguments[0],0,u),Promise.resolve(u)},t.prototype.createAnswer=function(){var e=this,t=o.writeSessionBoilerplate();this.usingBundle&&(t+="a=group:BUNDLE "+this.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),this.transceivers.forEach(function(n){if(n.isDatachannel)return void(t+="m=application 0 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=mid:"+n.mid+"\r\n");var i=e._getCommonCapabilities(n.localCapabilities,n.remoteCapabilities),r=i.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length;!r&&n.sendEncodingParameters[0].rtx&&delete n.sendEncodingParameters[0].rtx,t+=o.writeMediaSection(n,i,"answer",e.localStreams[0]),n.rtcpParameters&&n.rtcpParameters.reducedSize&&(t+="a=rtcp-rsize\r\n")});var n=new RTCSessionDescription({type:"answer",sdp:t});return arguments.length&&"function"==typeof arguments[0]&&window.setTimeout(arguments[0],0,n),Promise.resolve(n)},t.prototype.addIceCandidate=function(e){if(e){var t=e.sdpMLineIndex;if(e.sdpMid)for(var n=0;n<this.transceivers.length;n++)if(this.transceivers[n].mid===e.sdpMid){t=n;break}var i=this.transceivers[t];if(i){var r=Object.keys(e.candidate).length>0?o.parseCandidate(e.candidate):{};if("tcp"===r.protocol&&(0===r.port||9===r.port))return Promise.resolve();if("1"!==r.component)return Promise.resolve();i.iceTransport.addRemoteCandidate(r);var a=o.splitSections(this.remoteDescription.sdp);a[t+1]+=(r.type?e.candidate.trim():"a=end-of-candidates")+"\r\n",this.remoteDescription.sdp=a.join("")}}else for(var s=0;s<this.transceivers.length;s++)if(this.transceivers[s].iceTransport.addRemoteCandidate({}),this.usingBundle)return Promise.resolve();return arguments.length>1&&"function"==typeof arguments[1]&&window.setTimeout(arguments[1],0),Promise.resolve()},t.prototype.getStats=function(){var e=[];this.transceivers.forEach(function(t){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(n){t[n]&&e.push(t[n].getStats())})});var t=arguments.length>1&&"function"==typeof arguments[1]&&arguments[1],n=function(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",
localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};return new Promise(function(i){var r=new Map;Promise.all(e).then(function(e){e.forEach(function(e){Object.keys(e).forEach(function(t){e[t].type=n(e[t]),r.set(t,e[t])})}),t&&window.setTimeout(t,0,r),i(r)})})},t}},199:function(e,t,n){"use strict";var i=n(31).browserDetails,r={shimOnTrack:function(){"object"!=typeof window||!window.RTCPeerConnection||"ontrack"in window.RTCPeerConnection.prototype||Object.defineProperty(window.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.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}})},shimSourceObject:function(){"object"==typeof window&&(!window.HTMLMediaElement||"srcObject"in window.HTMLMediaElement.prototype||Object.defineProperty(window.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(){if("object"==typeof window&&(window.RTCPeerConnection||window.mozRTCPeerConnection)){window.RTCPeerConnection||(window.RTCPeerConnection=function(e,t){if(i.version<38&&e&&e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++){var o=e.iceServers[r];if(o.hasOwnProperty("urls"))for(var a=0;a<o.urls.length;a++){var s={url:o.urls[a]};0===o.urls[a].indexOf("turn")&&(s.username=o.username,s.credential=o.credential),n.push(s)}else n.push(e.iceServers[r])}e.iceServers=n}return new mozRTCPeerConnection(e,t)},window.RTCPeerConnection.prototype=mozRTCPeerConnection.prototype,mozRTCPeerConnection.generateCertificate&&Object.defineProperty(window.RTCPeerConnection,"generateCertificate",{get:function(){return mozRTCPeerConnection.generateCertificate}}),window.RTCSessionDescription=mozRTCSessionDescription,window.RTCIceCandidate=mozRTCIceCandidate),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=RTCPeerConnection.prototype[e];RTCPeerConnection.prototype[e]=function(){return arguments[0]=new("addIceCandidate"===e?RTCIceCandidate:RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}});var e=RTCPeerConnection.prototype.addIceCandidate;RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?e.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())};var t=function(e){var t=new Map;return Object.keys(e).forEach(function(n){t.set(n,e[n]),t[n]=e[n]}),t},n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=RTCPeerConnection.prototype.getStats;RTCPeerConnection.prototype.getStats=function(e,o,a){return r.apply(this,[e||null]).then(function(e){if(i.version<48&&(e=t(e)),i.version<53&&!o)try{e.forEach(function(e){e.type=n[e.type]||e.type})}catch(e){if("TypeError"!==e.name)throw e;e.forEach(function(t,i){e.set(i,Object.assign({},t,{type:n[t.type]||t.type}))})}return e}).then(o,a)}}}};e.exports={shimOnTrack:r.shimOnTrack,shimSourceObject:r.shimSourceObject,shimPeerConnection:r.shimPeerConnection,shimGetUserMedia:n(200)}},200:function(e,t,n){"use strict";var i=n(31).log,r=n(31).browserDetails;e.exports=function(){var e=function(e){return{name:{NotSupportedError:"TypeError",SecurityError:"NotAllowedError",PermissionDeniedError:"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}}},t=function(t,n,o){var a=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 i=e[n]="object"==typeof e[n]?e[n]:{ideal:e[n]};if(void 0===i.min&&void 0===i.max&&void 0===i.exact||t.push(n),void 0!==i.exact&&("number"==typeof i.exact?i.min=i.max=i.exact:e[n]=i.exact,delete i.exact),void 0!==i.ideal){e.advanced=e.advanced||[];var r={};"number"==typeof i.ideal?r[n]={min:i.ideal,max:i.ideal}:r[n]=i.ideal,e.advanced.push(r),delete i.ideal,Object.keys(i).length||delete e[n]}}}),t.length&&(e.require=t),e};return t=JSON.parse(JSON.stringify(t)),r.version<38&&(i("spec: "+JSON.stringify(t)),t.audio&&(t.audio=a(t.audio)),t.video&&(t.video=a(t.video)),i("ff37: "+JSON.stringify(t))),navigator.mozGetUserMedia(t,n,function(t){o(e(t))})},n=function(e){return new Promise(function(n,i){t(e,n,i)})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:n,addEventListener:function(){},removeEventListener:function(){}}),navigator.mediaDevices.enumerateDevices=navigator.mediaDevices.enumerateDevices||function(){return new Promise(function(e){var t=[{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}];e(t)})},r.version<41){var o=navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices);navigator.mediaDevices.enumerateDevices=function(){return o().then(void 0,function(e){if("NotFoundError"===e.name)return[];throw e})}}if(r.version<49){var a=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(t){return a(t).then(function(e){if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(function(e){e.stop()}),new DOMException("The object can not be found here.","NotFoundError");return e},function(t){return Promise.reject(e(t))})}}navigator.getUserMedia=function(e,n,i){return r.version<44?t(e,n,i):void navigator.mediaDevices.getUserMedia(e).then(n,i)}}},201:function(e,t){"use strict";var n={shimOnAddStream:function(){"object"!=typeof window||!window.RTCPeerConnection||"onaddstream"in window.RTCPeerConnection.prototype||Object.defineProperty(window.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){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){var t=e.streams[0];if(this._streams||(this._streams=[]),!(this._streams.indexOf(t)>=0)){this._streams.push(t);var n=new Event("addstream");n.stream=e.streams[0],this.dispatchEvent(n)}}.bind(this))}})},shimGetUserMedia:function(){navigator.getUserMedia||(navigator.webkitGetUserMedia?navigator.getUserMedia=navigator.webkitGetUserMedia.bind(navigator):navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&(navigator.getUserMedia=function(e,t,n){navigator.mediaDevices.getUserMedia(e).then(t,n)}.bind(navigator)))}};e.exports={shimOnAddStream:n.shimOnAddStream,shimGetUserMedia:n.shimGetUserMedia}}})});