>0]=e.charCodeAt(n);k[t>>0]=0},Ko=(e,t)=>{var n=0;return We().forEach((a,s)=>{var u=t+n;A[e+s*4>>2]=u,Zo(a,u),n+=a.length+1}),0},ei=(e,t)=>{var n=We();A[e>>2]=n.length;var a=0;return n.forEach(s=>a+=s.length+1),A[t>>2]=a,0},ti=e=>e,it=e=>e%4===0&&(e%100!==0||e%400===0),ri=(e,t)=>{for(var n=0,a=0;a<=t;n+=e[a++]);return n},qr=[31,29,31,30,31,30,31,31,30,31,30,31],Nr=[31,28,31,30,31,30,31,31,30,31,30,31],ni=(e,t)=>{for(var n=new Date(e.getTime());t>0;){var a=it(n.getFullYear()),s=n.getMonth(),u=(a?qr:Nr)[s];if(t>u-n.getDate())t-=u-n.getDate()+1,n.setDate(1),s<11?n.setMonth(s+1):(n.setMonth(0),n.setFullYear(n.getFullYear()+1));else return n.setDate(n.getDate()+t),n}return n};function ai(e,t,n){var a=Lr(e)+1,s=new Array(a);return jr(e,s,0,s.length),s}var oi=(e,t)=>{k.set(e,t)},ii=(e,t,n,a)=>{var s=A[a+40>>2],u={tm_sec:D[a>>2],tm_min:D[a+4>>2],tm_hour:D[a+8>>2],tm_mday:D[a+12>>2],tm_mon:D[a+16>>2],tm_year:D[a+20>>2],tm_wday:D[a+24>>2],tm_yday:D[a+28>>2],tm_isdst:D[a+32>>2],tm_gmtoff:D[a+36>>2],tm_zone:s?kt(s):""},d=kt(n),f={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var m in f)d=d.replace(new RegExp(m,"g"),f[m]);var w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],_=["January","February","March","April","May","June","July","August","September","October","November","December"];function T(y,P,z){for(var Y=typeof y=="number"?y.toString():y||"";Y.length0?1:0}var Y;return(Y=z(y.getFullYear()-P.getFullYear()))===0&&(Y=z(y.getMonth()-P.getMonth()))===0&&(Y=z(y.getDate()-P.getDate())),Y}function H(y){switch(y.getDay()){case 0:return new Date(y.getFullYear()-1,11,29);case 1:return y;case 2:return new Date(y.getFullYear(),0,3);case 3:return new Date(y.getFullYear(),0,2);case 4:return new Date(y.getFullYear(),0,1);case 5:return new Date(y.getFullYear()-1,11,31);case 6:return new Date(y.getFullYear()-1,11,30)}}function N(y){var P=ni(new Date(y.tm_year+1900,0,1),y.tm_yday),z=new Date(P.getFullYear(),0,4),Y=new Date(P.getFullYear()+1,0,4),Oe=H(z),ct=H(Y);return M(Oe,P)<=0?M(ct,P)<=0?P.getFullYear()+1:P.getFullYear():P.getFullYear()-1}var F={"%a":y=>w[y.tm_wday].substring(0,3),"%A":y=>w[y.tm_wday],"%b":y=>_[y.tm_mon].substring(0,3),"%B":y=>_[y.tm_mon],"%C":y=>{var P=y.tm_year+1900;return E(P/100|0,2)},"%d":y=>E(y.tm_mday,2),"%e":y=>T(y.tm_mday,2," "),"%g":y=>N(y).toString().substring(2),"%G":y=>N(y),"%H":y=>E(y.tm_hour,2),"%I":y=>{var P=y.tm_hour;return P==0?P=12:P>12&&(P-=12),E(P,2)},"%j":y=>E(y.tm_mday+ri(it(y.tm_year+1900)?qr:Nr,y.tm_mon-1),3),"%m":y=>E(y.tm_mon+1,2),"%M":y=>E(y.tm_min,2),"%n":()=>`
+`,"%p":y=>y.tm_hour>=0&&y.tm_hour<12?"AM":"PM","%S":y=>E(y.tm_sec,2),"%t":()=>" ","%u":y=>y.tm_wday||7,"%U":y=>{var P=y.tm_yday+7-y.tm_wday;return E(Math.floor(P/7),2)},"%V":y=>{var P=Math.floor((y.tm_yday+7-(y.tm_wday+6)%7)/7);if((y.tm_wday+371-y.tm_yday-2)%7<=2&&P++,P){if(P==53){var z=(y.tm_wday+371-y.tm_yday)%7;z!=4&&(z!=3||!it(y.tm_year))&&(P=1)}}else{P=52;var Y=(y.tm_wday+7-y.tm_yday-1)%7;(Y==4||Y==5&&it(y.tm_year%400-1))&&P++}return E(P,2)},"%w":y=>y.tm_wday,"%W":y=>{var P=y.tm_yday+7-(y.tm_wday+6)%7;return E(Math.floor(P/7),2)},"%y":y=>(y.tm_year+1900).toString().substring(2),"%Y":y=>y.tm_year+1900,"%z":y=>{var P=y.tm_gmtoff,z=P>=0;return P=Math.abs(P)/60,P=P/60*100+P%60,(z?"+":"-")+("0000"+P).slice(-4)},"%Z":y=>y.tm_zone,"%%":()=>"%"};d=d.replace(/%%/g,"\0\0");for(var m in F)d.includes(m)&&(d=d.replace(new RegExp(m,"g"),F[m](u)));d=d.replace(/\0\0/g,"%");var Q=ai(d);return Q.length>t?0:(oi(Q,e),Q.length-1)},si=(e,t,n,a,s)=>ii(e,t,n,a);Pr=i.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},Ra(),Ee=i.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},qa(),La(),Za(),Ir=i.UnboundTypeError=ro(Error,"UnboundTypeError"),so(),uo();var ci={s:Ca,u:$a,b:Sa,g:Pa,q:Ta,J:Ea,f:Oa,V:Ma,d:_a,da:Da,Q:Aa,_:ka,ca:no,ba:oo,w:io,Y:lo,x:ho,h:po,L:vo,M:yo,t:wo,o:bo,K:_o,C:Do,A:Ao,ea:Ro,$:xo,R:ko,ha:At,fa:Uo,Z:Bo,N:Vo,O:qo,aa:No,B:zo,X:Go,W:Qo,T:Ko,U:ei,E:Si,D:hi,F:_i,n:Pi,a:ui,e:mi,m:fi,k:yi,H:Ci,v:wi,G:$i,z:Ei,P:Mi,l:vi,j:pi,c:di,p:li,I:bi,r:Ti,i:gi,y:Oi,ga:ti,S:si},G=ba(),de=i._free=e=>(de=i._free=G.ka)(e),Ut=i._malloc=e=>(Ut=i._malloc=G.la)(e),zr=e=>(zr=G.na)(e),L=(e,t)=>(L=G.oa)(e,t),je=e=>(je=G.pa)(e),V=()=>(V=G.qa)(),q=e=>(q=G.ra)(e),Gr=e=>(Gr=G.sa)(e),Yr=e=>(Yr=G.ta)(e),Jr=(e,t,n)=>(Jr=G.ua)(e,t,n),Qr=e=>(Qr=G.va)(e);i.dynCall_viijii=(e,t,n,a,s,u,d)=>(i.dynCall_viijii=G.wa)(e,t,n,a,s,u,d);var Xr=i.dynCall_jiiii=(e,t,n,a,s)=>(Xr=i.dynCall_jiiii=G.xa)(e,t,n,a,s);i.dynCall_iiiiij=(e,t,n,a,s,u,d)=>(i.dynCall_iiiiij=G.ya)(e,t,n,a,s,u,d),i.dynCall_iiiiijj=(e,t,n,a,s,u,d,f,m)=>(i.dynCall_iiiiijj=G.za)(e,t,n,a,s,u,d,f,m),i.dynCall_iiiiiijj=(e,t,n,a,s,u,d,f,m,w)=>(i.dynCall_iiiiiijj=G.Aa)(e,t,n,a,s,u,d,f,m,w);function ui(e,t){var n=V();try{return B(e)(t)}catch(a){if(q(n),a!==a+0)throw a;L(1,0)}}function li(e,t,n,a){var s=V();try{B(e)(t,n,a)}catch(u){if(q(s),u!==u+0)throw u;L(1,0)}}function di(e,t,n){var a=V();try{B(e)(t,n)}catch(s){if(q(a),s!==s+0)throw s;L(1,0)}}function fi(e,t,n,a){var s=V();try{return B(e)(t,n,a)}catch(u){if(q(s),u!==u+0)throw u;L(1,0)}}function hi(e,t,n,a,s){var u=V();try{return B(e)(t,n,a,s)}catch(d){if(q(u),d!==d+0)throw d;L(1,0)}}function pi(e,t){var n=V();try{B(e)(t)}catch(a){if(q(n),a!==a+0)throw a;L(1,0)}}function mi(e,t,n){var a=V();try{return B(e)(t,n)}catch(s){if(q(a),s!==s+0)throw s;L(1,0)}}function vi(e){var t=V();try{B(e)()}catch(n){if(q(t),n!==n+0)throw n;L(1,0)}}function yi(e,t,n,a,s){var u=V();try{return B(e)(t,n,a,s)}catch(d){if(q(u),d!==d+0)throw d;L(1,0)}}function gi(e,t,n,a,s,u,d,f,m,w,_){var T=V();try{B(e)(t,n,a,s,u,d,f,m,w,_)}catch(E){if(q(T),E!==E+0)throw E;L(1,0)}}function wi(e,t,n,a,s,u,d){var f=V();try{return B(e)(t,n,a,s,u,d)}catch(m){if(q(f),m!==m+0)throw m;L(1,0)}}function bi(e,t,n,a,s){var u=V();try{B(e)(t,n,a,s)}catch(d){if(q(u),d!==d+0)throw d;L(1,0)}}function Ci(e,t,n,a,s,u){var d=V();try{return B(e)(t,n,a,s,u)}catch(f){if(q(d),f!==f+0)throw f;L(1,0)}}function $i(e,t,n,a,s,u,d,f){var m=V();try{return B(e)(t,n,a,s,u,d,f)}catch(w){if(q(m),w!==w+0)throw w;L(1,0)}}function _i(e,t,n,a){var s=V();try{return B(e)(t,n,a)}catch(u){if(q(s),u!==u+0)throw u;L(1,0)}}function Si(e,t,n,a){var s=V();try{return B(e)(t,n,a)}catch(u){if(q(s),u!==u+0)throw u;L(1,0)}}function Pi(e){var t=V();try{return B(e)()}catch(n){if(q(t),n!==n+0)throw n;L(1,0)}}function Ti(e,t,n,a,s,u,d,f){var m=V();try{B(e)(t,n,a,s,u,d,f)}catch(w){if(q(m),w!==w+0)throw w;L(1,0)}}function Ei(e,t,n,a,s,u,d,f,m,w,_,T){var E=V();try{return B(e)(t,n,a,s,u,d,f,m,w,_,T)}catch(M){if(q(E),M!==M+0)throw M;L(1,0)}}function Oi(e,t,n,a,s,u,d,f,m,w,_,T,E,M,H,N){var F=V();try{B(e)(t,n,a,s,u,d,f,m,w,_,T,E,M,H,N)}catch(Q){if(q(F),Q!==Q+0)throw Q;L(1,0)}}function Mi(e,t,n,a,s){var u=V();try{return Xr(e,t,n,a,s)}catch(d){if(q(u),d!==d+0)throw d;L(1,0)}}var st;ge=function e(){st||Zr(),st||(ge=e)};function Zr(){if(ae>0||(ze(),ae>0))return;function e(){st||(st=!0,i.calledRun=!0,!j&&(ft(),c(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),ht()))}i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),e()},1)):e()}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return Zr(),o.ready}})();function Mn(r){return lt(He,r)}function Dn(r){return Tn(He,r)}async function An(r,o){return En(He,r,o)}async function Rn(r,o){return On(He,r,o)}var Me;class Be extends EventTarget{constructor(o={}){var i;super(),tn(this,Me,void 0);try{const c=(i=o==null?void 0:o.formats)==null?void 0:i.filter(l=>l!=="unknown");if((c==null?void 0:c.length)===0)throw new TypeError("Hint option provided, but is empty.");c==null||c.forEach(l=>{if(!Le.has(l))throw new TypeError(`Failed to read the 'formats' property from 'BarcodeDetectorOptions': The provided value '${l}' is not a valid enum value of type BarcodeFormat.`)}),rn(this,Me,c!=null?c:[]),Mn().then(l=>{this.dispatchEvent(new CustomEvent("load",{detail:l}))}).catch(l=>{this.dispatchEvent(new CustomEvent("error",{detail:l}))})}catch(c){throw Qt(c,"Failed to construct 'BarcodeDetector'")}}static async getSupportedFormats(){return nn.filter(o=>o!=="unknown")}async detect(o){try{const i=await dn(o);if(i===null)return[];let c;try{Yt(i)?c=await An(i,{tryHarder:!0,formats:jt(this,Me).map(l=>Le.get(l))}):c=await Rn(i,{tryHarder:!0,formats:jt(this,Me).map(l=>Le.get(l))})}catch(l){throw console.error(l),new DOMException("Barcode detection service unavailable.","NotSupportedError")}return c.map(l=>{const{topLeft:{x:h,y:v},topRight:{x:g,y:b},bottomLeft:{x:p,y:C},bottomRight:{x:S,y:$}}=l.position,U=Math.min(h,g,p,S),W=Math.min(v,b,C,$),j=Math.max(h,g,p,S),k=Math.max(v,b,C,$);return{boundingBox:new DOMRectReadOnly(U,W,j-U,k-W),rawValue:l.text,format:an(l.format),cornerPoints:[{x:h,y:v},{x:g,y:b},{x:S,y:$},{x:p,y:C}]}})}catch(i){throw Qt(i,"Failed to execute 'detect' on 'BarcodeDetector'")}}}Me=new WeakMap;const dt=(r,o,i="error")=>{let c,l;const h=new Promise((v,g)=>{c=v,l=g,r.addEventListener(o,c),r.addEventListener(i,l)});return h.finally(()=>{r.removeEventListener(o,c),r.removeEventListener(i,l)}),h},tr=r=>new Promise(o=>setTimeout(o,r));class xn extends Error{constructor(){super("can't process cross-origin image"),this.name="DropImageFetchError"}}class rr extends Error{constructor(){super("this browser has no Stream API support"),this.name="StreamApiNotSupportedError"}}class kn extends Error{constructor(){super("camera access is only permitted in secure context. Use HTTPS or localhost rather than HTTP."),this.name="InsecureContextError"}}class In extends Error{constructor(){super("Loading camera stream timed out after 6 seconds. If you are on iOS in PWA mode, this is a known issue (see https://github.com/gruhn/vue-qrcode-reader/issues/298)"),this.name="StreamLoadTimeoutError"}}let nr;async function Fn(r){if(window.BarcodeDetector===void 0)return console.debug("[vue-qrcode-reader] Native BarcodeDetector not supported. Will use polyfill."),new Be({formats:r});const o=await window.BarcodeDetector.getSupportedFormats(),i=r.filter(c=>!o.includes(c));return i.length>0?(console.debug(`[vue-qrcode-reader] Native BarcodeDetector does not support formats ${JSON.stringify(i)}. Will use polyfill.`),new Be({formats:r})):(console.debug("[vue-qrcode-reader] Will use native BarcodeDetector."),new window.BarcodeDetector({formats:r}))}async function ar(r){nr=await Fn(r)}const Un=async(r,{detectHandler:o,locateHandler:i,minDelay:c,formats:l})=>{console.debug("[vue-qrcode-reader] start scanning"),await ar(l);const h=v=>async g=>{if(r.readyState===0)console.debug("[vue-qrcode-reader] stop scanning: video element readyState is 0");else{const{lastScanned:b,contentBefore:p,lastScanHadContent:C}=v;if(g-b!p.includes(j.rawValue));$&&o(S);const U=S.length>0;U&&i(S),!U&&C&&i(S);const W={lastScanned:g,lastScanHadContent:U,contentBefore:$?S.map(j=>j.rawValue):p};window.requestAnimationFrame(h(W))}}};h({lastScanned:performance.now(),contentBefore:[],lastScanHadContent:!1})(performance.now())},Wn=async r=>{if(r.startsWith("http")&&r.includes(location.host)===!1)throw new xn;const o=document.createElement("img");return o.src=r,await dt(o,"load"),o},or=async(r,o=["qr_code"])=>await new Be({formats:o}).detect(r),jn=async(r,o=["qr_code"])=>{const i=new Be({formats:o}),c=await Wn(r);return await i.detect(c)};var ir={},X={};Object.defineProperty(X,"__esModule",{value:!0}),X.compactObject=lr,X.deprecated=Yn;var Ln=X.detectBrowser=Jn;X.disableLog=Nn,X.disableWarnings=zn,X.extractVersion=Ve,X.filterStats=Qn,X.log=Gn,X.walkStats=qe,X.wrapPeerConnectionEvent=qn;function Hn(r,o,i){return o=Bn(o),o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i,r}function Bn(r){var o=Vn(r,"string");return fe(o)==="symbol"?o:String(o)}function Vn(r,o){if(fe(r)!=="object"||r===null)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var c=i.call(r,o||"default");if(fe(c)!=="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(r)}function fe(r){"@babel/helpers - typeof";return fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},fe(r)}var sr=!0,cr=!0;function Ve(r,o,i){var c=r.match(o);return c&&c.length>=i&&parseInt(c[i],10)}function qn(r,o,i){if(r.RTCPeerConnection){var c=r.RTCPeerConnection.prototype,l=c.addEventListener;c.addEventListener=function(v,g){if(v!==o)return l.apply(this,arguments);var b=function(C){var S=i(C);S&&(g.handleEvent?g.handleEvent(S):g(S))};return this._eventMap=this._eventMap||{},this._eventMap[o]||(this._eventMap[o]=new Map),this._eventMap[o].set(g,b),l.apply(this,[v,b])};var h=c.removeEventListener;c.removeEventListener=function(v,g){if(v!==o||!this._eventMap||!this._eventMap[o])return h.apply(this,arguments);if(!this._eventMap[o].has(g))return h.apply(this,arguments);var b=this._eventMap[o].get(g);return this._eventMap[o].delete(g),this._eventMap[o].size===0&&delete this._eventMap[o],Object.keys(this._eventMap).length===0&&delete this._eventMap,h.apply(this,[v,b])},Object.defineProperty(c,"on"+o,{get:function(){return this["_on"+o]},set:function(g){this["_on"+o]&&(this.removeEventListener(o,this["_on"+o]),delete this["_on"+o]),g&&this.addEventListener(o,this["_on"+o]=g)},enumerable:!0,configurable:!0})}}function Nn(r){return typeof r!="boolean"?new Error("Argument type: "+fe(r)+". Please use a boolean."):(sr=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function zn(r){return typeof r!="boolean"?new Error("Argument type: "+fe(r)+". Please use a boolean."):(cr=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function Gn(){if((typeof window>"u"?"undefined":fe(window))==="object"){if(sr)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Yn(r,o){cr&&console.warn(r+" is deprecated, please use "+o+" instead.")}function Jn(r){var o={browser:null,version:null};if(typeof r>"u"||!r.navigator||!r.navigator.userAgent)return o.browser="Not a browser.",o;var i=r.navigator;if(i.mozGetUserMedia)o.browser="firefox",o.version=Ve(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection)o.browser="chrome",o.version=Ve(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(r.RTCPeerConnection&&i.userAgent.match(/AppleWebKit\/(\d+)\./))o.browser="safari",o.version=Ve(i.userAgent,/AppleWebKit\/(\d+)\./,1),o.supportsUnifiedPlan=r.RTCRtpTransceiver&&"currentDirection"in r.RTCRtpTransceiver.prototype;else return o.browser="Not a supported browser.",o;return o}function ur(r){return Object.prototype.toString.call(r)==="[object Object]"}function lr(r){return ur(r)?Object.keys(r).reduce(function(o,i){var c=ur(r[i]),l=c?lr(r[i]):r[i],h=c&&!Object.keys(l).length;return l===void 0||h?o:Object.assign(o,Hn({},i,l))},{}):r}function qe(r,o,i){!o||i.has(o.id)||(i.set(o.id,o),Object.keys(o).forEach(function(c){c.endsWith("Id")?qe(r,r.get(o[c]),i):c.endsWith("Ids")&&o[c].forEach(function(l){qe(r,r.get(l),i)})}))}function Qn(r,o,i){var c=i?"outbound-rtp":"inbound-rtp",l=new Map;if(o===null)return l;var h=[];return r.forEach(function(v){v.type==="track"&&v.trackIdentifier===o.id&&h.push(v)}),h.forEach(function(v){r.forEach(function(g){g.type===c&&g.trackId===v.id&&qe(r,g,l)})}),l}Object.defineProperty(ir,"__esModule",{value:!0});var Xn=ir.shimGetUserMedia=ea,Zn=Kn(X);function dr(r){if(typeof WeakMap!="function")return null;var o=new WeakMap,i=new WeakMap;return(dr=function(l){return l?i:o})(r)}function Kn(r,o){if(r&&r.__esModule)return r;if(r===null||he(r)!=="object"&&typeof r!="function")return{default:r};var i=dr(o);if(i&&i.has(r))return i.get(r);var c={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var h in r)if(h!=="default"&&Object.prototype.hasOwnProperty.call(r,h)){var v=l?Object.getOwnPropertyDescriptor(r,h):null;v&&(v.get||v.set)?Object.defineProperty(c,h,v):c[h]=r[h]}return c.default=r,i&&i.set(r,c),c}function he(r){"@babel/helpers - typeof";return he=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},he(r)}var fr=Zn.log;function ea(r,o){var i=r&&r.navigator;if(i.mediaDevices){var c=function(p){if(he(p)!=="object"||p.mandatory||p.optional)return p;var C={};return Object.keys(p).forEach(function(S){if(!(S==="require"||S==="advanced"||S==="mediaSource")){var $=he(p[S])==="object"?p[S]:{ideal:p[S]};$.exact!==void 0&&typeof $.exact=="number"&&($.min=$.max=$.exact);var U=function(k,R){return k?k+R.charAt(0).toUpperCase()+R.slice(1):R==="deviceId"?"sourceId":R};if($.ideal!==void 0){C.optional=C.optional||[];var W={};typeof $.ideal=="number"?(W[U("min",S)]=$.ideal,C.optional.push(W),W={},W[U("max",S)]=$.ideal,C.optional.push(W)):(W[U("",S)]=$.ideal,C.optional.push(W))}$.exact!==void 0&&typeof $.exact!="number"?(C.mandatory=C.mandatory||{},C.mandatory[U("",S)]=$.exact):["min","max"].forEach(function(j){$[j]!==void 0&&(C.mandatory=C.mandatory||{},C.mandatory[U(j,S)]=$[j])})}}),p.advanced&&(C.optional=(C.optional||[]).concat(p.advanced)),C},l=function(p,C){if(o.version>=61)return C(p);if(p=JSON.parse(JSON.stringify(p)),p&&he(p.audio)==="object"){var S=function(k,R,Z){R in k&&!(Z in k)&&(k[Z]=k[R],delete k[R])};p=JSON.parse(JSON.stringify(p)),S(p.audio,"autoGainControl","googAutoGainControl"),S(p.audio,"noiseSuppression","googNoiseSuppression"),p.audio=c(p.audio)}if(p&&he(p.video)==="object"){var $=p.video.facingMode;$=$&&(he($)==="object"?$:{ideal:$});var U=o.version<66;if($&&($.exact==="user"||$.exact==="environment"||$.ideal==="user"||$.ideal==="environment")&&!(i.mediaDevices.getSupportedConstraints&&i.mediaDevices.getSupportedConstraints().facingMode&&!U)){delete p.video.facingMode;var W;if($.exact==="environment"||$.ideal==="environment"?W=["back","rear"]:($.exact==="user"||$.ideal==="user")&&(W=["front"]),W)return i.mediaDevices.enumerateDevices().then(function(j){j=j.filter(function(R){return R.kind==="videoinput"});var k=j.find(function(R){return W.some(function(Z){return R.label.toLowerCase().includes(Z)})});return!k&&j.length&&W.includes("back")&&(k=j[j.length-1]),k&&(p.video.deviceId=$.exact?{exact:k.deviceId}:{ideal:k.deviceId}),p.video=c(p.video),fr("chrome: "+JSON.stringify(p)),C(p)})}p.video=c(p.video)}return fr("chrome: "+JSON.stringify(p)),C(p)},h=function(p){return o.version>=64?p:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[p.name]||p.name,message:p.message,constraint:p.constraint||p.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},v=function(p,C,S){l(p,function($){i.webkitGetUserMedia($,C,function(U){S&&S(h(U))})})};if(i.getUserMedia=v.bind(i),i.mediaDevices.getUserMedia){var g=i.mediaDevices.getUserMedia.bind(i.mediaDevices);i.mediaDevices.getUserMedia=function(b){return l(b,function(p){return g(p).then(function(C){if(p.audio&&!C.getAudioTracks().length||p.video&&!C.getVideoTracks().length)throw C.getTracks().forEach(function(S){S.stop()}),new DOMException("","NotFoundError");return C},function(C){return Promise.reject(h(C))})})}}}}var hr={};Object.defineProperty(hr,"__esModule",{value:!0});var ta=hr.shimGetUserMedia=aa,ra=na(X);function pr(r){if(typeof WeakMap!="function")return null;var o=new WeakMap,i=new WeakMap;return(pr=function(l){return l?i:o})(r)}function na(r,o){if(r&&r.__esModule)return r;if(r===null||$e(r)!=="object"&&typeof r!="function")return{default:r};var i=pr(o);if(i&&i.has(r))return i.get(r);var c={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var h in r)if(h!=="default"&&Object.prototype.hasOwnProperty.call(r,h)){var v=l?Object.getOwnPropertyDescriptor(r,h):null;v&&(v.get||v.set)?Object.defineProperty(c,h,v):c[h]=r[h]}return c.default=r,i&&i.set(r,c),c}function $e(r){"@babel/helpers - typeof";return $e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},$e(r)}function aa(r,o){var i=r&&r.navigator,c=r&&r.MediaStreamTrack;if(i.getUserMedia=function(b,p,C){ra.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(b).then(p,C)},!(o.version>55&&"autoGainControl"in i.mediaDevices.getSupportedConstraints())){var l=function(p,C,S){C in p&&!(S in p)&&(p[S]=p[C],delete p[C])},h=i.mediaDevices.getUserMedia.bind(i.mediaDevices);if(i.mediaDevices.getUserMedia=function(b){return $e(b)==="object"&&$e(b.audio)==="object"&&(b=JSON.parse(JSON.stringify(b)),l(b.audio,"autoGainControl","mozAutoGainControl"),l(b.audio,"noiseSuppression","mozNoiseSuppression")),h(b)},c&&c.prototype.getSettings){var v=c.prototype.getSettings;c.prototype.getSettings=function(){var b=v.apply(this,arguments);return l(b,"mozAutoGainControl","autoGainControl"),l(b,"mozNoiseSuppression","noiseSuppression"),b}}if(c&&c.prototype.applyConstraints){var g=c.prototype.applyConstraints;c.prototype.applyConstraints=function(b){return this.kind==="audio"&&$e(b)==="object"&&(b=JSON.parse(JSON.stringify(b)),l(b,"autoGainControl","mozAutoGainControl"),l(b,"noiseSuppression","mozNoiseSuppression")),g.apply(this,[b])}}}}var ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.shimAudioContext=pa,ne.shimCallbacksAPI=ua,ne.shimConstraints=yr,ne.shimCreateOfferLegacy=ha;var oa=ne.shimGetUserMedia=la;ne.shimLocalStreamsAPI=sa,ne.shimRTCIceServerUrls=da,ne.shimRemoteStreamsAPI=ca,ne.shimTrackEventTransceiver=fa;var mr=ia(X);function vr(r){if(typeof WeakMap!="function")return null;var o=new WeakMap,i=new WeakMap;return(vr=function(l){return l?i:o})(r)}function ia(r,o){if(r&&r.__esModule)return r;if(r===null||pe(r)!=="object"&&typeof r!="function")return{default:r};var i=vr(o);if(i&&i.has(r))return i.get(r);var c={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var h in r)if(h!=="default"&&Object.prototype.hasOwnProperty.call(r,h)){var v=l?Object.getOwnPropertyDescriptor(r,h):null;v&&(v.get||v.set)?Object.defineProperty(c,h,v):c[h]=r[h]}return c.default=r,i&&i.set(r,c),c}function pe(r){"@babel/helpers - typeof";return pe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},pe(r)}function sa(r){if(!(pe(r)!=="object"||!r.RTCPeerConnection)){if("getLocalStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in r.RTCPeerConnection.prototype)){var o=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addStream=function(c){var l=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(c)||this._localStreams.push(c),c.getAudioTracks().forEach(function(h){return o.call(l,h,c)}),c.getVideoTracks().forEach(function(h){return o.call(l,h,c)})},r.RTCPeerConnection.prototype.addTrack=function(c){for(var l=this,h=arguments.length,v=new Array(h>1?h-1:0),g=1;g=0)){c._remoteStreams.push(h);var v=new Event("addstream");v.stream=h,c.dispatchEvent(v)}})}),o.apply(c,arguments)}}}function ua(r){if(!(pe(r)!=="object"||!r.RTCPeerConnection)){var o=r.RTCPeerConnection.prototype,i=o.createOffer,c=o.createAnswer,l=o.setLocalDescription,h=o.setRemoteDescription,v=o.addIceCandidate;o.createOffer=function(p,C){var S=arguments.length>=2?arguments[2]:arguments[0],$=i.apply(this,[S]);return C?($.then(p,C),Promise.resolve()):$},o.createAnswer=function(p,C){var S=arguments.length>=2?arguments[2]:arguments[0],$=c.apply(this,[S]);return C?($.then(p,C),Promise.resolve()):$};var g=function(p,C,S){var $=l.apply(this,[p]);return S?($.then(C,S),Promise.resolve()):$};o.setLocalDescription=g,g=function(p,C,S){var $=h.apply(this,[p]);return S?($.then(C,S),Promise.resolve()):$},o.setRemoteDescription=g,g=function(p,C,S){var $=v.apply(this,[p]);return S?($.then(C,S),Promise.resolve()):$},o.addIceCandidate=g}}function la(r){var o=r&&r.navigator;if(o.mediaDevices&&o.mediaDevices.getUserMedia){var i=o.mediaDevices,c=i.getUserMedia.bind(i);o.mediaDevices.getUserMedia=function(l){return c(yr(l))}}!o.getUserMedia&&o.mediaDevices&&o.mediaDevices.getUserMedia&&(o.getUserMedia=(function(h,v,g){o.mediaDevices.getUserMedia(h).then(v,g)}).bind(o))}function yr(r){return r&&r.video!==void 0?Object.assign({},r,{video:mr.compactObject(r.video)}):r}function da(r){if(r.RTCPeerConnection){var o=r.RTCPeerConnection;r.RTCPeerConnection=function(c,l){if(c&&c.iceServers){for(var h=[],v=0;v{let o=!1,i;return(...c)=>(o||(i=r(c),o=!0),i)};function se(r,o){if(r===!1)throw new Error(o!=null?o:"assertion failure")}function gr(r){throw new Error("this code should be unreachable")}const va=ma(()=>{const r=Ln(window);switch(r.browser){case"chrome":Xn(window,r);break;case"firefox":ta(window,r);break;case"safari":oa(window,r);break;default:throw new rr}});let _e=Promise.resolve({type:"stop",data:{}});async function wr(r,o,i){var g,b,p;if(console.debug("[vue-qrcode-reader] starting camera with constraints: ",JSON.stringify(o)),window.isSecureContext!==!0)throw new kn;if(((g=navigator==null?void 0:navigator.mediaDevices)==null?void 0:g.getUserMedia)===void 0)throw new rr;va(),console.debug("[vue-qrcode-reader] calling getUserMedia");const c=await navigator.mediaDevices.getUserMedia({audio:!1,video:o});r.srcObject!==void 0?r.srcObject=c:r.mozSrcObject!==void 0?r.mozSrcObject=c:window.URL.createObjectURL?r.src=window.URL.createObjectURL(c):window.webkitURL?r.src=window.webkitURL.createObjectURL(c):r.src=c.id,r.play(),console.debug("[vue-qrcode-reader] waiting for video element to load"),await Promise.race([dt(r,"loadeddata"),tr(6e3).then(()=>{throw new In})]),console.debug("[vue-qrcode-reader] video element loaded"),await tr(500);const[l]=c.getVideoTracks(),h=(p=(b=l==null?void 0:l.getCapabilities)==null?void 0:b.call(l))!=null?p:{};let v=!1;return i&&h.torch&&(await l.applyConstraints({advanced:[{torch:!0}]}),v=!0),console.debug("[vue-qrcode-reader] camera ready"),{type:"start",data:{videoEl:r,stream:c,capabilities:h,constraints:o,isTorchOn:v}}}async function ya(r,{constraints:o,torch:i,restart:c=!1}){_e=_e.then(h=>{if(h.type==="start"){const{data:{videoEl:v,stream:g,constraints:b,isTorchOn:p}}=h;return!c&&r===v&&o===b&&i===p?h:br(v,g,p).then(()=>wr(r,o,i))}else if(h.type==="stop"||h.type==="failed")return wr(r,o,i);gr()}).catch(h=>(console.debug(`[vue-qrcode-reader] starting camera failed with "${h}"`),{type:"failed",error:h}));const l=await _e;if(l.type==="stop")throw new Error("Something went wrong with the camera task queue (start task).");if(l.type==="failed")throw l.error;if(l.type==="start")return l.data.capabilities;gr()}async function br(r,o,i){console.debug("[vue-qrcode-reader] stopping camera"),r.src="",r.srcObject=null,r.load(),await dt(r,"error");for(const c of o.getTracks())i!=null||await c.applyConstraints({advanced:[{torch:!1}]}),o.removeTrack(c),c.stop();return{type:"stop",data:{}}}async function Ne(){if(_e=_e.then(o=>{if(o.type==="stop"||o.type==="failed")return o;const{data:{videoEl:i,stream:c,isTorchOn:l}}=o;return br(i,c,l)}),(await _e).type==="start")throw new Error("Something went wrong with the camera task queue (stop task).")}const Cr=O.defineComponent({__name:"QrcodeStream",props:{constraints:{type:Object,default(){return{facingMode:"environment"}}},formats:{type:Array,default:()=>["qr_code"]},paused:{type:Boolean,default:!1},torch:{type:Boolean,default:!1},track:{type:Function}},emits:["detect","camera-on","camera-off","error"],setup(r,{emit:o}){const i=r,c=o,l=O.ref(i.constraints),h=O.ref(i.formats);O.watch(()=>i.constraints,(I,D)=>{JSON.stringify(I)!==JSON.stringify(D)&&(l.value=I)},{deep:!0}),O.watch(()=>i.formats,(I,D)=>{JSON.stringify(I)!==JSON.stringify(D)&&(h.value=I)},{deep:!0});const v=O.ref(),g=O.ref(),b=O.ref(),p=O.ref(!1),C=O.ref(!1);O.onMounted(()=>{C.value=!0}),O.onUnmounted(()=>{Ne()});const S=O.computed(()=>({torch:i.torch,constraints:l.value,shouldStream:C.value&&!i.paused}));O.watch(S,async I=>{const D=b.value;se(D!==void 0,"cameraSettings watcher should never be triggered when component is not mounted. Thus video element should always be defined.");const A=v.value;se(A!==void 0,"cameraSettings watcher should never be triggered when component is not mounted. Thus canvas should always be defined.");const me=A.getContext("2d");if(se(me!==null,"if cavnas is defined, canvas 2d context should also be non-null"),I.shouldStream){Ne(),p.value=!1;try{const ce=await ya(D,I);C.value?(p.value=!0,c("camera-on",ce)):await Ne()}catch(ce){c("error",ce)}}else A.width=D.videoWidth,A.height=D.videoHeight,me.drawImage(D,0,0,D.videoWidth,D.videoHeight),Ne(),p.value=!1,c("camera-off")},{deep:!0}),O.watch(h,async I=>{C.value&&await ar(I)});const $=O.computed(()=>S.value.shouldStream&&p.value);O.watch($,I=>{if(I){se(v.value!==void 0,"shouldScan watcher should only be triggered when component is mounted. Thus pause frame canvas is defined"),U(v.value),se(g.value!==void 0,"shouldScan watcher should only be triggered when component is mounted. Thus tracking canvas is defined"),U(g.value);const D=()=>i.track===void 0?500:40;se(b.value!==void 0,"shouldScan watcher should only be triggered when component is mounted. Thus video element is defined"),Un(b.value,{detectHandler:A=>c("detect",A),formats:h.value,locateHandler:W,minDelay:D()})}});const U=I=>{const D=I.getContext("2d");se(D!==null,"canvas 2d context should always be non-null"),D.clearRect(0,0,I.width,I.height)},W=I=>{const D=g.value;se(D!==void 0,"onLocate handler should only be called when component is mounted. Thus tracking canvas is always defined.");const A=b.value;if(se(A!==void 0,"onLocate handler should only be called when component is mounted. Thus video element is always defined."),I.length===0||i.track===void 0)U(D);else{const me=A.offsetWidth,ce=A.offsetHeight,Se=A.videoWidth,Pe=A.videoHeight,De=Math.max(me/Se,ce/Pe),Ae=Se*De,ze=Pe*De,ft=Ae/Se,ht=ze/Pe,pt=(me-Ae)/2,mt=(ce-ze)/2,Re=({x:ve,y:K})=>({x:Math.floor(ve*ft),y:Math.floor(K*ht)}),ae=({x:ve,y:K})=>({x:Math.floor(ve+pt),y:Math.floor(K+mt)}),ge=I.map(ve=>{const{boundingBox:K,cornerPoints:yt}=ve,{x:Ge,y:ye}=ae(Re({x:K.x,y:K.y})),{x:Ye,y:gt}=Re({x:K.width,y:K.height});return{...ve,cornerPoints:yt.map(Je=>ae(Re(Je))),boundingBox:DOMRectReadOnly.fromRect({x:Ge,y:ye,width:Ye,height:gt})}});D.width=A.offsetWidth,D.height=A.offsetHeight;const vt=D.getContext("2d");i.track(ge,vt)}},j={width:"100%",height:"100%",position:"relative","z-index":"0"},k={width:"100%",height:"100%",position:"absolute",top:"0",left:"0"},R={width:"100%",height:"100%","object-fit":"cover"},Z=O.computed(()=>$.value?R:{...R,visibility:"hidden",position:"absolute"});return(I,D)=>(O.openBlock(),O.createElementBlock("div",{style:j},[O.createElementVNode("video",{ref_key:"videoRef",ref:b,style:O.normalizeStyle(Z.value),autoplay:"",muted:"",playsinline:""},null,4),O.withDirectives(O.createElementVNode("canvas",{id:"qrcode-stream-pause-frame",ref_key:"pauseFrameRef",ref:v,style:R},null,512),[[O.vShow,!$.value]]),O.createElementVNode("canvas",{id:"qrcode-stream-tracking-layer",ref_key:"trackingLayerRef",ref:g,style:k},null,512),O.createElementVNode("div",{style:k},[O.renderSlot(I.$slots,"default")])]))}}),$r=O.defineComponent({__name:"QrcodeCapture",props:{formats:{type:Array,default:()=>["qr_code"]}},emits:["detect"],setup(r,{emit:o}){const i=r,c=o,l=h=>{if(!(!(h.target instanceof HTMLInputElement)||!h.target.files))for(const v of Array.from(h.target.files))or(v,i.formats).then(g=>{c("detect",g)})};return(h,v)=>(O.openBlock(),O.createElementBlock("input",{onChange:l,type:"file",name:"image",accept:"image/*",capture:"environment",multiple:""},null,32))}}),_r=O.defineComponent({__name:"QrcodeDropZone",props:{formats:{type:Array,default:()=>["qr_code"]}},emits:["detect","dragover","error"],setup(r,{emit:o}){const i=r,c=o,l=async g=>{try{const b=await g;c("detect",b)}catch(b){c("error",b)}},h=g=>{c("dragover",g)},v=({dataTransfer:g})=>{if(!g)return;h(!1);const b=[...Array.from(g.files)],p=g.getData("text/uri-list");b.forEach(C=>{l(or(C,i.formats))}),p!==""&&l(jn(p,i.formats))};return(g,b)=>(O.openBlock(),O.createElementBlock("div",{onDrop:O.withModifiers(v,["prevent","stop"]),onDragenter:b[0]||(b[0]=O.withModifiers(p=>h(!0),["prevent","stop"])),onDragleave:b[1]||(b[1]=O.withModifiers(p=>h(!1),["prevent","stop"])),onDragover:b[2]||(b[2]=O.withModifiers(()=>{},["prevent","stop"]))},[O.renderSlot(g.$slots,"default")],32))}});function Sr(r){r.component("qrcode-stream",Cr),r.component("qrcode-capture",$r),r.component("qrcode-drop-zone",_r)}const ga={install:Sr};ee.QrcodeCapture=$r,ee.QrcodeDropZone=_r,ee.QrcodeStream=Cr,ee.VueQrcodeReader=ga,ee.install=Sr,ee.setZXingModuleOverrides=Dn,Object.defineProperty(ee,Symbol.toStringTag,{value:"Module"})});
diff --git a/node_modules/vue-qrcode-reader/package.json b/node_modules/vue-qrcode-reader/package.json
new file mode 100644
index 0000000..e8b5ea6
--- /dev/null
+++ b/node_modules/vue-qrcode-reader/package.json
@@ -0,0 +1,77 @@
+{
+ "name": "vue-qrcode-reader",
+ "version": "5.6.0",
+ "description": "A set of Vue.js components for detecting and decoding QR codes.",
+ "author": {
+ "name": "Niklas Gruhn",
+ "email": "niklas@gruhn.me"
+ },
+ "engines": {
+ "node": ">=18.0.0"
+ },
+ "packageManager": "pnpm@8.3.1",
+ "type": "module",
+ "scripts": {
+ "build": "vite build",
+ "docs:dev": "vitepress dev docs",
+ "docs:build": "vitepress build docs",
+ "docs:preview": "vitepress preview docs",
+ "format": "prettier **/*.{vue,ts,json,md} --write --ignore-path .gitignore --ignore-path docs/.gitignore",
+ "type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
+ "prepack": "pnpm run build"
+ },
+ "main": "./dist/vue-qrcode-reader.js",
+ "module": "./dist/vue-qrcode-reader.js",
+ "unpkg": "./dist/vue-qrcode-reader.umd.js",
+ "exports": {
+ ".": {
+ "import": "./dist/vue-qrcode-reader.js",
+ "require": "./dist/vue-qrcode-reader.umd.js",
+ "types": "./dist/index.d.ts"
+ }
+ },
+ "types": "./dist/index.d.ts",
+ "files": [
+ "dist"
+ ],
+ "dependencies": {
+ "barcode-detector": "2.2.2",
+ "webrtc-adapter": "8.2.3"
+ },
+ "devDependencies": {
+ "@tsconfig/node20": "20.1.2",
+ "@types/node": "20.10.5",
+ "@types/w3c-image-capture": "1.0.10",
+ "@vite-pwa/vitepress": "0.3.1",
+ "@vitejs/plugin-vue": "4.5.2",
+ "@vue/compiler-sfc": "3.3.13",
+ "@vue/eslint-config-prettier": "8.0.0",
+ "@vue/eslint-config-typescript": "12.0.0",
+ "@vue/tsconfig": "0.5.1",
+ "eslint": "8.56.0",
+ "eslint-plugin-prettier": "5.1.0",
+ "eslint-plugin-vue": "9.19.2",
+ "prettier": "3.1.1",
+ "semantic-release": "22.0.12",
+ "typescript": "5.5.3",
+ "vite": "5.0.10",
+ "vite-plugin-dts": "3.6.4",
+ "vitepress": "1.0.0-rc.32",
+ "vue": "3.3.13",
+ "vue-tsc": "1.8.25",
+ "workbox-window": "7.0.0"
+ },
+ "bugs": "https://github.com/gruhn/vue-qrcode-reader/issues",
+ "homepage": "https://gruhn.github.io/vue-qrcode-reader/",
+ "keywords": [
+ "vue",
+ "vuejs",
+ "vue-component",
+ "qrcode",
+ "qrcode-reader",
+ "qrcode-scanner",
+ "webrtc"
+ ],
+ "license": "MIT",
+ "repository": "github:gruhn/vue-qrcode-reader"
+}
diff --git a/node_modules/webrtc-adapter/.eslintrc b/node_modules/webrtc-adapter/.eslintrc
new file mode 100644
index 0000000..fd82de2
--- /dev/null
+++ b/node_modules/webrtc-adapter/.eslintrc
@@ -0,0 +1,70 @@
+{
+ "rules": {
+ "array-bracket-spacing": 2,
+ "block-spacing": [2, "never"],
+ "brace-style": [2, "1tbs", {"allowSingleLine": false}],
+ "camelcase": [2, {"properties": "always"}],
+ "curly": 2,
+ "default-case": 2,
+ "dot-notation": 2,
+ "eqeqeq": 2,
+ "id-match": ["error", "^[\x00-\x7F]+$", {
+ "properties": true,
+ "onlyDeclarations": false,
+ "ignoreDestructuring": false
+ }],
+ "indent": [
+ 2,
+ 2,
+ {"SwitchCase": 1}
+ ],
+ "key-spacing": [2, {"beforeColon": false, "afterColon": true}],
+ "keyword-spacing": 2,
+ "max-len": [2, 80, 2, {"ignoreUrls": true}],
+ "new-cap": [2, {"newIsCapExceptions": [
+ "webkitRTCPeerConnection",
+ "mozRTCPeerConnection"
+ ]}],
+ "no-console": 0,
+ "no-else-return": 2,
+ "no-eval": 2,
+ "no-multi-spaces": 2,
+ "no-multiple-empty-lines": [2, {"max": 2}],
+ "no-shadow": 2,
+ "no-trailing-spaces": 2,
+ "no-unused-expressions": 2,
+ "no-unused-vars": [2, {"args": "none"}],
+ "object-curly-spacing": [2, "never"],
+ "padded-blocks": [2, "never"],
+ "quotes": [
+ 2,
+ "single"
+ ],
+ "semi": [
+ 2,
+ "always"
+ ],
+ "space-before-blocks": 2,
+ "space-before-function-paren": [2, "never"],
+ "space-unary-ops": 2,
+ "space-infix-ops": 2,
+ "spaced-comment": 2,
+ "valid-typeof": 2
+ },
+ "env": {
+ "browser": true,
+ "es6": true,
+ "node": true
+ },
+ "extends": ["eslint:recommended"],
+ "parserOptions": {
+ "sourceType": "module"
+ },
+ "globals": {
+ "module": true,
+ "require": true,
+ "process": true,
+ "Promise": true,
+ "Map": true
+ }
+}
diff --git a/node_modules/webrtc-adapter/.travis.yml b/node_modules/webrtc-adapter/.travis.yml
new file mode 100644
index 0000000..7b57cb7
--- /dev/null
+++ b/node_modules/webrtc-adapter/.travis.yml
@@ -0,0 +1,65 @@
+sudo: false
+language: node_js
+dist: trusty
+node_js:
+- "7"
+
+env:
+ - CXX=g++-4.8
+matrix:
+ include:
+ - os: linux
+ sudo: false
+ env: BROWSER=chrome BVER=stable
+ - os: linux
+ sudo: false
+ env: BROWSER=chrome BVER=beta
+ - os: linux
+ sudo: false
+ env: BROWSER=chrome BVER=unstable
+ - os: linux
+ sudo: false
+ env: BROWSER=firefox BVER=stable
+ - os: linux
+ sudo: false
+ env: BROWSER=firefox BVER=beta
+ - os: linux
+ sudo: false
+ env: BROWSER=firefox BVER=unstable
+ - os: osx
+ sudo: required
+ osx_image: xcode9.4
+ env: BROWSER=safari BVER=stable
+ - os: osx
+ sudo: required
+ osx_image: xcode11.2
+ env: BROWSER=safari BVER=unstable
+
+ fast_finish: true
+
+ allow_failures:
+ - os: linux
+ sudo: false
+ env: BROWSER=chrome BVER=unstable
+ - os: linux
+ sudo: false
+ env: BROWSER=firefox BVER=unstable
+
+before_script:
+ - ./node_modules/travis-multirunner/setup.sh
+ - export DISPLAY=:99.0
+ - if [ -f /etc/init.d/xvfb ]; then sh -e /etc/init.d/xvfb start; fi
+
+after_failure:
+ - for file in *.log; do echo $file; echo "======================"; cat $file; done || true
+
+notifications:
+ email:
+ -
+
+addons:
+ apt:
+ sources:
+ - ubuntu-toolchain-r-test
+ packages:
+ - g++-4.8
diff --git a/node_modules/webrtc-adapter/CONTRIBUTING.md b/node_modules/webrtc-adapter/CONTRIBUTING.md
new file mode 100644
index 0000000..c86d36e
--- /dev/null
+++ b/node_modules/webrtc-adapter/CONTRIBUTING.md
@@ -0,0 +1,15 @@
+WebRTC welcomes patches/pulls for features and bug fixes.
+
+For contributors external to Google, follow the instructions given in the [Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual).
+
+In all cases, contributors must sign a contributor license agreement before a contribution can be accepted. Please complete the agreement for an [individual](https://developers.google.com/open-source/cla/individual) or a [corporation](https://developers.google.com/open-source/cla/corporate) as appropriate.
+
+If you plan to add a significant component or large chunk of code, we recommend you bring this up on the [webrtc-discuss group](https://groups.google.com/forum/#!forum/discuss-webrtc) for a design discussion before writing code.
+
+If appropriate, write a unit test which demonstrates that your code functions as expected. Tests are the best way to ensure that future contributors do not break your code accidentally.
+
+To request a change or addition, you must [submit a pull request](https://help.github.com/categories/collaborating/).
+
+WebRTC developers monitor outstanding pull requests. They may request changes to the pull request before accepting. They will also verify that a CLA has been signed.
+
+The [Developer's Guide](https://bit.ly/webrtcdevguide) for this repo has more detailed information about code style, structure and validation.
diff --git a/node_modules/webrtc-adapter/Gruntfile.js b/node_modules/webrtc-adapter/Gruntfile.js
new file mode 100644
index 0000000..e39392b
--- /dev/null
+++ b/node_modules/webrtc-adapter/Gruntfile.js
@@ -0,0 +1,71 @@
+'use strict';
+
+module.exports = function(grunt) {
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+ babel: {
+ options: {
+ presets: ['@babel/preset-env']
+ },
+ dist: {
+ files: [{
+ expand: 'true',
+ cwd: 'src/js',
+ src: ['*.js', '**/*.js'],
+ dest: 'dist/'
+ }]
+ }
+ },
+ browserify: {
+ adapterGlobalObject: {
+ src: ['./dist/adapter_core5.js'],
+ dest: './out/adapter.js',
+ options: {
+ browserifyOptions: {
+ // Exposes shim methods in a global object to the browser.
+ // The tests require this.
+ standalone: 'adapter'
+ }
+ }
+ },
+ // Use this if you do not want adapter to expose anything to the global
+ // scope.
+ adapterAndNoGlobalObject: {
+ src: ['./dist/adapter_core5.js'],
+ dest: './out/adapter_no_global.js'
+ }
+ },
+ eslint: {
+ options: {
+ overrideConfigFile: '.eslintrc'
+ },
+ target: ['src/**/*.js', 'test/*.js', 'test/unit/*.js', 'test/e2e/*.js']
+ },
+ copy: {
+ build: {
+ dest: 'release/',
+ cwd: 'out',
+ src: '**',
+ nonull: true,
+ expand: true
+ }
+ },
+ shell: {
+ downloadBrowser : {
+ command: 'BROWSER=${BROWSER-chrome} BVER=${BVER-stable} ./node_modules/travis-multirunner/setup.sh'
+ },
+ },
+ });
+
+ grunt.loadNpmTasks('grunt-eslint');
+ grunt.loadNpmTasks('grunt-browserify');
+ grunt.loadNpmTasks('grunt-babel');
+ grunt.loadNpmTasks('grunt-contrib-copy');
+ grunt.loadNpmTasks('grunt-shell');
+
+ grunt.registerTask('default', ['eslint', 'build']);
+ grunt.registerTask('lint', ['eslint']);
+ grunt.registerTask('build', ['babel', 'browserify']);
+ grunt.registerTask('copyForPublish', ['copy']);
+ grunt.registerTask('downloadBrowser', ['shell:downloadBrowser'])
+};
diff --git a/node_modules/webrtc-adapter/LICENSE.md b/node_modules/webrtc-adapter/LICENSE.md
new file mode 100644
index 0000000..30f27f9
--- /dev/null
+++ b/node_modules/webrtc-adapter/LICENSE.md
@@ -0,0 +1,30 @@
+Copyright (c) 2014, The WebRTC project authors. All rights reserved.
+Copyright (c) 2018, The adapter.js project authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ * Neither the name of Google nor the names of its contributors may
+ be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/node_modules/webrtc-adapter/README.md b/node_modules/webrtc-adapter/README.md
new file mode 100644
index 0000000..367d995
--- /dev/null
+++ b/node_modules/webrtc-adapter/README.md
@@ -0,0 +1,79 @@
+# WebRTC adapter #
+adapter.js is a shim to insulate apps from spec changes and prefix differences in WebRTC. The prefix differences are mostly gone these days but differences in behaviour between browsers remain.
+
+This repository used to be part of the WebRTC organisation on github but moved. We aim to keep the old repository updated with new releases.
+
+## Install ##
+
+#### NPM
+```bash
+npm install webrtc-adapter
+```
+
+#### Bower
+```bash
+bower install webrtc-adapter
+```
+
+## Usage ##
+##### Javascript
+Just import adapter:
+```
+import adapter from 'webrtc-adapter';
+```
+No further action is required. You might want to use adapters browser detection
+which detects which webrtc quirks are required. You can look at
+```
+adapter.browserDetails.browser
+```
+for webrtc engine detection (which will for example detect Opera or the Chromium based Edge as 'chrome') and
+```
+adapter.browserDetails.version
+```
+for the version according to the user-agent string.
+
+##### NPM
+Copy to desired location in your src tree or use a minify/vulcanize tool (node_modules is usually not published with the code).
+See [webrtc/samples repo](https://github.com/webrtc/samples) as an example on how you can do this.
+
+#### Prebuilt releases
+##### Web
+In the [gh-pages branch](https://github.com/webrtcHacks/adapter/tree/gh-pages) prebuilt ready to use files can be downloaded/linked directly.
+Latest version can be found at https://webrtc.github.io/adapter/adapter-latest.js.
+Specific versions can be found at https://webrtc.github.io/adapter/adapter-N.N.N.js, e.g. https://webrtc.github.io/adapter/adapter-1.0.2.js.
+
+##### Bower
+You will find `adapter.js` in `bower_components/webrtc-adapter/`.
+
+##### NPM
+In node_modules/webrtc-adapter/out/ folder you will find 4 files:
+* `adapter.js` - includes all the shims and is visible in the browser under the global `adapter` object (window.adapter).
+* `adapter_no_global.js` - same as `adapter.js` but is not exposed/visible in the browser (you cannot call/interact with the shims in the browser).
+
+Include the file that suits your need in your project.
+
+## Development ##
+Head over to [test/README.md](https://github.com/webrtcHacks/adapter/blob/master/test/README.md) and get started developing.
+
+## Publish a new version ##
+* Go to the adapter repository root directory
+* Make sure your repository is clean, i.e. no untracked files etc. Also check that you are on the master branch and have pulled the latest changes.
+* Depending on the impact of the release, either use `patch`, `minor` or `major` in place of ``. Run `npm version -m 'bump to %s'` and type in your password lots of times (setting up credential caching is probably a good idea).
+* Create and merge the PR if green in the GitHub web ui
+* Go to the releases tab in the GitHub web ui and edit the tag.
+* Add a summary of the recent commits in the tag summary and a link to the diff between the previous and current version in the description, [example](https://github.com/webrtcHacks/adapter/releases/tag/v3.4.1).
+* Go back to your checkout and run `git pull`
+* Run `npm publish` (you need access to the [webrtc-adapter npmjs package](https://www.npmjs.com/package/webrtc-adapter)). For big changes, consider using a [tag version](https://docs.npmjs.com/adding-dist-tags-to-packages) such as `next` and then [change the dist-tag after testing](https://docs.npmjs.com/cli/dist-tag).
+* Done! There should now be a new release published to NPM and the gh-pages branch.
+
+Note: Currently only tested on Linux, not sure about Mac but will definitely not work on Windows.
+
+### Publish a hotfix patch versions
+In some cases it may be necessary to do a patch version while there are significant changes changes on the master branch.
+To make a patch release,
+* checkout the latest git tag using `git checkout tags/vMajor.minor.patch`.
+* checkout a new branch, using a name such as patchrelease-major-minor-patch.
+* cherry-pick the fixes using `git cherry-pick some-commit-hash`.
+* run `npm version patch`. This will create a new patch version and publish it on github.
+* check out `origin/bumpVersion` branch and publish the new version using `npm publish`.
+* the branch can now safely be deleted. It is not necessary to merge it into the main branch since it only contains cherry-picked commits.
diff --git a/node_modules/webrtc-adapter/bower.json b/node_modules/webrtc-adapter/bower.json
new file mode 100644
index 0000000..cc5ac95
--- /dev/null
+++ b/node_modules/webrtc-adapter/bower.json
@@ -0,0 +1,25 @@
+{
+ "name": "webrtc-adapter",
+ "description": "A shim to insulate apps from WebRTC spec changes and browser prefix differences",
+ "license": "BSD-3-Clause",
+ "main": "./release/adapter.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/webrtchacks/adapter.git"
+ },
+ "authors": [
+ "The WebRTC project authors (https://www.webrtc.org/)",
+ "The adapter.js project authors (https://github.com/webrtchacks/adapter/)"
+ ],
+ "moduleType": [
+ "node"
+ ],
+ "ignore": [
+ "test/*"
+ ],
+ "keywords": [
+ "WebRTC",
+ "RTCPeerConnection",
+ "getUserMedia"
+ ]
+}
diff --git a/node_modules/webrtc-adapter/dist/adapter_core.js b/node_modules/webrtc-adapter/dist/adapter_core.js
new file mode 100644
index 0000000..6eb013a
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/adapter_core.js
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports["default"] = void 0;
+var _adapter_factory = require("./adapter_factory.js");
+var adapter = (0, _adapter_factory.adapterFactory)({
+ window: typeof window === 'undefined' ? undefined : window
+});
+var _default = adapter;
+exports["default"] = _default;
diff --git a/node_modules/webrtc-adapter/dist/adapter_core5.js b/node_modules/webrtc-adapter/dist/adapter_core5.js
new file mode 100644
index 0000000..d96b1d0
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/adapter_core5.js
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+
+'use strict';
+
+var _adapter_factory = require("./adapter_factory.js");
+var adapter = (0, _adapter_factory.adapterFactory)({
+ window: typeof window === 'undefined' ? undefined : window
+});
+module.exports = adapter; // this is the difference from adapter_core.
diff --git a/node_modules/webrtc-adapter/dist/adapter_factory.js b/node_modules/webrtc-adapter/dist/adapter_factory.js
new file mode 100644
index 0000000..0cd97fa
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/adapter_factory.js
@@ -0,0 +1,141 @@
+"use strict";
+
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.adapterFactory = adapterFactory;
+var utils = _interopRequireWildcard(require("./utils"));
+var chromeShim = _interopRequireWildcard(require("./chrome/chrome_shim"));
+var firefoxShim = _interopRequireWildcard(require("./firefox/firefox_shim"));
+var safariShim = _interopRequireWildcard(require("./safari/safari_shim"));
+var commonShim = _interopRequireWildcard(require("./common_shim"));
+var sdp = _interopRequireWildcard(require("sdp"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+
+// Browser shims.
+
+// Shimming starts here.
+function adapterFactory() {
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
+ window = _ref.window;
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
+ shimChrome: true,
+ shimFirefox: true,
+ shimSafari: true
+ };
+ // Utils.
+ var logging = utils.log;
+ var browserDetails = utils.detectBrowser(window);
+ var adapter = {
+ browserDetails: browserDetails,
+ commonShim: commonShim,
+ extractVersion: utils.extractVersion,
+ disableLog: utils.disableLog,
+ disableWarnings: utils.disableWarnings,
+ // Expose sdp as a convenience. For production apps include directly.
+ sdp: sdp
+ };
+
+ // Shim browser if found.
+ switch (browserDetails.browser) {
+ case 'chrome':
+ if (!chromeShim || !chromeShim.shimPeerConnection || !options.shimChrome) {
+ logging('Chrome shim is not included in this adapter release.');
+ return adapter;
+ }
+ if (browserDetails.version === null) {
+ logging('Chrome shim can not determine version, not shimming.');
+ return adapter;
+ }
+ logging('adapter.js shimming chrome.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = chromeShim;
+
+ // Must be called before shimPeerConnection.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+ chromeShim.shimGetUserMedia(window, browserDetails);
+ chromeShim.shimMediaStream(window, browserDetails);
+ chromeShim.shimPeerConnection(window, browserDetails);
+ chromeShim.shimOnTrack(window, browserDetails);
+ chromeShim.shimAddTrackRemoveTrack(window, browserDetails);
+ chromeShim.shimGetSendersWithDtmf(window, browserDetails);
+ chromeShim.shimGetStats(window, browserDetails);
+ chromeShim.shimSenderReceiverGetStats(window, browserDetails);
+ chromeShim.fixNegotiationNeeded(window, browserDetails);
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
+ commonShim.shimConnectionState(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ commonShim.removeExtmapAllowMixed(window, browserDetails);
+ break;
+ case 'firefox':
+ if (!firefoxShim || !firefoxShim.shimPeerConnection || !options.shimFirefox) {
+ logging('Firefox shim is not included in this adapter release.');
+ return adapter;
+ }
+ logging('adapter.js shimming firefox.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = firefoxShim;
+
+ // Must be called before shimPeerConnection.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+ firefoxShim.shimGetUserMedia(window, browserDetails);
+ firefoxShim.shimPeerConnection(window, browserDetails);
+ firefoxShim.shimOnTrack(window, browserDetails);
+ firefoxShim.shimRemoveStream(window, browserDetails);
+ firefoxShim.shimSenderGetStats(window, browserDetails);
+ firefoxShim.shimReceiverGetStats(window, browserDetails);
+ firefoxShim.shimRTCDataChannel(window, browserDetails);
+ firefoxShim.shimAddTransceiver(window, browserDetails);
+ firefoxShim.shimGetParameters(window, browserDetails);
+ firefoxShim.shimCreateOffer(window, browserDetails);
+ firefoxShim.shimCreateAnswer(window, browserDetails);
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimConnectionState(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ break;
+ case 'safari':
+ if (!safariShim || !options.shimSafari) {
+ logging('Safari shim is not included in this adapter release.');
+ return adapter;
+ }
+ logging('adapter.js shimming safari.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = safariShim;
+
+ // Must be called before shimCallbackAPI.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+ safariShim.shimRTCIceServerUrls(window, browserDetails);
+ safariShim.shimCreateOfferLegacy(window, browserDetails);
+ safariShim.shimCallbacksAPI(window, browserDetails);
+ safariShim.shimLocalStreamsAPI(window, browserDetails);
+ safariShim.shimRemoteStreamsAPI(window, browserDetails);
+ safariShim.shimTrackEventTransceiver(window, browserDetails);
+ safariShim.shimGetUserMedia(window, browserDetails);
+ safariShim.shimAudioContext(window, browserDetails);
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ commonShim.removeExtmapAllowMixed(window, browserDetails);
+ break;
+ default:
+ logging('Unsupported browser!');
+ break;
+ }
+ return adapter;
+}
diff --git a/node_modules/webrtc-adapter/dist/chrome/chrome_shim.js b/node_modules/webrtc-adapter/dist/chrome/chrome_shim.js
new file mode 100644
index 0000000..8d1d984
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/chrome/chrome_shim.js
@@ -0,0 +1,698 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.fixNegotiationNeeded = fixNegotiationNeeded;
+exports.shimAddTrackRemoveTrack = shimAddTrackRemoveTrack;
+exports.shimAddTrackRemoveTrackWithNative = shimAddTrackRemoveTrackWithNative;
+Object.defineProperty(exports, "shimGetDisplayMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getdisplaymedia.shimGetDisplayMedia;
+ }
+});
+exports.shimGetSendersWithDtmf = shimGetSendersWithDtmf;
+exports.shimGetStats = shimGetStats;
+Object.defineProperty(exports, "shimGetUserMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getusermedia.shimGetUserMedia;
+ }
+});
+exports.shimMediaStream = shimMediaStream;
+exports.shimOnTrack = shimOnTrack;
+exports.shimPeerConnection = shimPeerConnection;
+exports.shimSenderReceiverGetStats = shimSenderReceiverGetStats;
+var utils = _interopRequireWildcard(require("../utils.js"));
+var _getusermedia = require("./getusermedia");
+var _getdisplaymedia = require("./getdisplaymedia");
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimMediaStream(window) {
+ window.MediaStream = window.MediaStream || window.webkitMediaStream;
+}
+function shimOnTrack(window) {
+ if (_typeof(window) === 'object' && window.RTCPeerConnection && !('ontrack' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'ontrack', {
+ get: function get() {
+ return this._ontrack;
+ },
+ set: function set(f) {
+ if (this._ontrack) {
+ this.removeEventListener('track', this._ontrack);
+ }
+ this.addEventListener('track', this._ontrack = f);
+ },
+ enumerable: true,
+ configurable: true
+ });
+ var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
+ var _this = this;
+ if (!this._ontrackpoly) {
+ this._ontrackpoly = function (e) {
+ // onaddstream does not fire when a track is added to an existing
+ // stream. But stream.onaddtrack is implemented so we use that.
+ e.stream.addEventListener('addtrack', function (te) {
+ var receiver;
+ if (window.RTCPeerConnection.prototype.getReceivers) {
+ receiver = _this.getReceivers().find(function (r) {
+ return r.track && r.track.id === te.track.id;
+ });
+ } else {
+ receiver = {
+ track: te.track
+ };
+ }
+ var event = new Event('track');
+ event.track = te.track;
+ event.receiver = receiver;
+ event.transceiver = {
+ receiver: receiver
+ };
+ event.streams = [e.stream];
+ _this.dispatchEvent(event);
+ });
+ e.stream.getTracks().forEach(function (track) {
+ var receiver;
+ if (window.RTCPeerConnection.prototype.getReceivers) {
+ receiver = _this.getReceivers().find(function (r) {
+ return r.track && r.track.id === track.id;
+ });
+ } else {
+ receiver = {
+ track: track
+ };
+ }
+ var event = new Event('track');
+ event.track = track;
+ event.receiver = receiver;
+ event.transceiver = {
+ receiver: receiver
+ };
+ event.streams = [e.stream];
+ _this.dispatchEvent(event);
+ });
+ };
+ this.addEventListener('addstream', this._ontrackpoly);
+ }
+ return origSetRemoteDescription.apply(this, arguments);
+ };
+ } else {
+ // even if RTCRtpTransceiver is in window, it is only used and
+ // emitted in unified-plan. Unfortunately this means we need
+ // to unconditionally wrap the event.
+ utils.wrapPeerConnectionEvent(window, 'track', function (e) {
+ if (!e.transceiver) {
+ Object.defineProperty(e, 'transceiver', {
+ value: {
+ receiver: e.receiver
+ }
+ });
+ }
+ return e;
+ });
+ }
+}
+function shimGetSendersWithDtmf(window) {
+ // Overrides addTrack/removeTrack, depends on shimAddTrackRemoveTrack.
+ if (_typeof(window) === 'object' && window.RTCPeerConnection && !('getSenders' in window.RTCPeerConnection.prototype) && 'createDTMFSender' in window.RTCPeerConnection.prototype) {
+ var shimSenderWithDtmf = function shimSenderWithDtmf(pc, track) {
+ return {
+ track: track,
+ get dtmf() {
+ if (this._dtmf === undefined) {
+ if (track.kind === 'audio') {
+ this._dtmf = pc.createDTMFSender(track);
+ } else {
+ this._dtmf = null;
+ }
+ }
+ return this._dtmf;
+ },
+ _pc: pc
+ };
+ };
+
+ // augment addTrack when getSenders is not available.
+ if (!window.RTCPeerConnection.prototype.getSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ this._senders = this._senders || [];
+ return this._senders.slice(); // return a copy of the internal state.
+ };
+
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
+ var sender = origAddTrack.apply(this, arguments);
+ if (!sender) {
+ sender = shimSenderWithDtmf(this, track);
+ this._senders.push(sender);
+ }
+ return sender;
+ };
+ var origRemoveTrack = window.RTCPeerConnection.prototype.removeTrack;
+ window.RTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
+ origRemoveTrack.apply(this, arguments);
+ var idx = this._senders.indexOf(sender);
+ if (idx !== -1) {
+ this._senders.splice(idx, 1);
+ }
+ };
+ }
+ var origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this2 = this;
+ this._senders = this._senders || [];
+ origAddStream.apply(this, [stream]);
+ stream.getTracks().forEach(function (track) {
+ _this2._senders.push(shimSenderWithDtmf(_this2, track));
+ });
+ };
+ var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ var _this3 = this;
+ this._senders = this._senders || [];
+ origRemoveStream.apply(this, [stream]);
+ stream.getTracks().forEach(function (track) {
+ var sender = _this3._senders.find(function (s) {
+ return s.track === track;
+ });
+ if (sender) {
+ // remove sender
+ _this3._senders.splice(_this3._senders.indexOf(sender), 1);
+ }
+ });
+ };
+ } else if (_typeof(window) === 'object' && window.RTCPeerConnection && 'getSenders' in window.RTCPeerConnection.prototype && 'createDTMFSender' in window.RTCPeerConnection.prototype && window.RTCRtpSender && !('dtmf' in window.RTCRtpSender.prototype)) {
+ var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ var _this4 = this;
+ var senders = origGetSenders.apply(this, []);
+ senders.forEach(function (sender) {
+ return sender._pc = _this4;
+ });
+ return senders;
+ };
+ Object.defineProperty(window.RTCRtpSender.prototype, 'dtmf', {
+ get: function get() {
+ if (this._dtmf === undefined) {
+ if (this.track.kind === 'audio') {
+ this._dtmf = this._pc.createDTMFSender(this.track);
+ } else {
+ this._dtmf = null;
+ }
+ }
+ return this._dtmf;
+ }
+ });
+ }
+}
+function shimGetStats(window) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ var origGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ var _this5 = this;
+ var _arguments = Array.prototype.slice.call(arguments),
+ selector = _arguments[0],
+ onSucc = _arguments[1],
+ onErr = _arguments[2];
+
+ // If selector is a function then we are in the old style stats so just
+ // pass back the original getStats format to avoid breaking old users.
+ if (arguments.length > 0 && typeof selector === 'function') {
+ return origGetStats.apply(this, arguments);
+ }
+
+ // When spec-style getStats is supported, return those when called with
+ // either no arguments or the selector argument is null.
+ if (origGetStats.length === 0 && (arguments.length === 0 || typeof selector !== 'function')) {
+ return origGetStats.apply(this, []);
+ }
+ var fixChromeStats_ = function fixChromeStats_(response) {
+ var standardReport = {};
+ var reports = response.result();
+ reports.forEach(function (report) {
+ var standardStats = {
+ id: report.id,
+ timestamp: report.timestamp,
+ type: {
+ localcandidate: 'local-candidate',
+ remotecandidate: 'remote-candidate'
+ }[report.type] || report.type
+ };
+ report.names().forEach(function (name) {
+ standardStats[name] = report.stat(name);
+ });
+ standardReport[standardStats.id] = standardStats;
+ });
+ return standardReport;
+ };
+
+ // shim getStats with maplike support
+ var makeMapStats = function makeMapStats(stats) {
+ return new Map(Object.keys(stats).map(function (key) {
+ return [key, stats[key]];
+ }));
+ };
+ if (arguments.length >= 2) {
+ var successCallbackWrapper_ = function successCallbackWrapper_(response) {
+ onSucc(makeMapStats(fixChromeStats_(response)));
+ };
+ return origGetStats.apply(this, [successCallbackWrapper_, selector]);
+ }
+
+ // promise-support
+ return new Promise(function (resolve, reject) {
+ origGetStats.apply(_this5, [function (response) {
+ resolve(makeMapStats(fixChromeStats_(response)));
+ }, reject]);
+ }).then(onSucc, onErr);
+ };
+}
+function shimSenderReceiverGetStats(window) {
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection && window.RTCRtpSender && window.RTCRtpReceiver)) {
+ return;
+ }
+
+ // shim sender stats.
+ if (!('getStats' in window.RTCRtpSender.prototype)) {
+ var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ if (origGetSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ var _this6 = this;
+ var senders = origGetSenders.apply(this, []);
+ senders.forEach(function (sender) {
+ return sender._pc = _this6;
+ });
+ return senders;
+ };
+ }
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ if (origAddTrack) {
+ window.RTCPeerConnection.prototype.addTrack = function addTrack() {
+ var sender = origAddTrack.apply(this, arguments);
+ sender._pc = this;
+ return sender;
+ };
+ }
+ window.RTCRtpSender.prototype.getStats = function getStats() {
+ var sender = this;
+ return this._pc.getStats().then(function (result) {
+ return (
+ /* Note: this will include stats of all senders that
+ * send a track with the same id as sender.track as
+ * it is not possible to identify the RTCRtpSender.
+ */
+ utils.filterStats(result, sender.track, true)
+ );
+ });
+ };
+ }
+
+ // shim receiver stats.
+ if (!('getStats' in window.RTCRtpReceiver.prototype)) {
+ var origGetReceivers = window.RTCPeerConnection.prototype.getReceivers;
+ if (origGetReceivers) {
+ window.RTCPeerConnection.prototype.getReceivers = function getReceivers() {
+ var _this7 = this;
+ var receivers = origGetReceivers.apply(this, []);
+ receivers.forEach(function (receiver) {
+ return receiver._pc = _this7;
+ });
+ return receivers;
+ };
+ }
+ utils.wrapPeerConnectionEvent(window, 'track', function (e) {
+ e.receiver._pc = e.srcElement;
+ return e;
+ });
+ window.RTCRtpReceiver.prototype.getStats = function getStats() {
+ var receiver = this;
+ return this._pc.getStats().then(function (result) {
+ return utils.filterStats(result, receiver.track, false);
+ });
+ };
+ }
+ if (!('getStats' in window.RTCRtpSender.prototype && 'getStats' in window.RTCRtpReceiver.prototype)) {
+ return;
+ }
+
+ // shim RTCPeerConnection.getStats(track).
+ var origGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ if (arguments.length > 0 && arguments[0] instanceof window.MediaStreamTrack) {
+ var track = arguments[0];
+ var sender;
+ var receiver;
+ var err;
+ this.getSenders().forEach(function (s) {
+ if (s.track === track) {
+ if (sender) {
+ err = true;
+ } else {
+ sender = s;
+ }
+ }
+ });
+ this.getReceivers().forEach(function (r) {
+ if (r.track === track) {
+ if (receiver) {
+ err = true;
+ } else {
+ receiver = r;
+ }
+ }
+ return r.track === track;
+ });
+ if (err || sender && receiver) {
+ return Promise.reject(new DOMException('There are more than one sender or receiver for the track.', 'InvalidAccessError'));
+ } else if (sender) {
+ return sender.getStats();
+ } else if (receiver) {
+ return receiver.getStats();
+ }
+ return Promise.reject(new DOMException('There is no sender or receiver for the track.', 'InvalidAccessError'));
+ }
+ return origGetStats.apply(this, arguments);
+ };
+}
+function shimAddTrackRemoveTrackWithNative(window) {
+ // shim addTrack/removeTrack with native variants in order to make
+ // the interactions with legacy getLocalStreams behave as in other browsers.
+ // Keeps a mapping stream.id => [stream, rtpsenders...]
+ window.RTCPeerConnection.prototype.getLocalStreams = function getLocalStreams() {
+ var _this8 = this;
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ return Object.keys(this._shimmedLocalStreams).map(function (streamId) {
+ return _this8._shimmedLocalStreams[streamId][0];
+ });
+ };
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
+ if (!stream) {
+ return origAddTrack.apply(this, arguments);
+ }
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ var sender = origAddTrack.apply(this, arguments);
+ if (!this._shimmedLocalStreams[stream.id]) {
+ this._shimmedLocalStreams[stream.id] = [stream, sender];
+ } else if (this._shimmedLocalStreams[stream.id].indexOf(sender) === -1) {
+ this._shimmedLocalStreams[stream.id].push(sender);
+ }
+ return sender;
+ };
+ var origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this9 = this;
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ stream.getTracks().forEach(function (track) {
+ var alreadyExists = _this9.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.', 'InvalidAccessError');
+ }
+ });
+ var existingSenders = this.getSenders();
+ origAddStream.apply(this, arguments);
+ var newSenders = this.getSenders().filter(function (newSender) {
+ return existingSenders.indexOf(newSender) === -1;
+ });
+ this._shimmedLocalStreams[stream.id] = [stream].concat(newSenders);
+ };
+ var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ delete this._shimmedLocalStreams[stream.id];
+ return origRemoveStream.apply(this, arguments);
+ };
+ var origRemoveTrack = window.RTCPeerConnection.prototype.removeTrack;
+ window.RTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
+ var _this10 = this;
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ if (sender) {
+ Object.keys(this._shimmedLocalStreams).forEach(function (streamId) {
+ var idx = _this10._shimmedLocalStreams[streamId].indexOf(sender);
+ if (idx !== -1) {
+ _this10._shimmedLocalStreams[streamId].splice(idx, 1);
+ }
+ if (_this10._shimmedLocalStreams[streamId].length === 1) {
+ delete _this10._shimmedLocalStreams[streamId];
+ }
+ });
+ }
+ return origRemoveTrack.apply(this, arguments);
+ };
+}
+function shimAddTrackRemoveTrack(window, browserDetails) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ // shim addTrack and removeTrack.
+ if (window.RTCPeerConnection.prototype.addTrack && browserDetails.version >= 65) {
+ return shimAddTrackRemoveTrackWithNative(window);
+ }
+
+ // also shim pc.getLocalStreams when addTrack is shimmed
+ // to return the original streams.
+ var origGetLocalStreams = window.RTCPeerConnection.prototype.getLocalStreams;
+ window.RTCPeerConnection.prototype.getLocalStreams = function getLocalStreams() {
+ var _this11 = this;
+ var nativeStreams = origGetLocalStreams.apply(this);
+ this._reverseStreams = this._reverseStreams || {};
+ return nativeStreams.map(function (stream) {
+ return _this11._reverseStreams[stream.id];
+ });
+ };
+ var origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this12 = this;
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ stream.getTracks().forEach(function (track) {
+ var alreadyExists = _this12.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.', 'InvalidAccessError');
+ }
+ });
+ // Add identity mapping for consistency with addTrack.
+ // Unless this is being used with a stream from addTrack.
+ if (!this._reverseStreams[stream.id]) {
+ var newStream = new window.MediaStream(stream.getTracks());
+ this._streams[stream.id] = newStream;
+ this._reverseStreams[newStream.id] = stream;
+ stream = newStream;
+ }
+ origAddStream.apply(this, [stream]);
+ };
+ var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ origRemoveStream.apply(this, [this._streams[stream.id] || stream]);
+ delete this._reverseStreams[this._streams[stream.id] ? this._streams[stream.id].id : stream.id];
+ delete this._streams[stream.id];
+ };
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
+ var _this13 = this;
+ if (this.signalingState === 'closed') {
+ throw new DOMException('The RTCPeerConnection\'s signalingState is \'closed\'.', 'InvalidStateError');
+ }
+ var streams = [].slice.call(arguments, 1);
+ if (streams.length !== 1 || !streams[0].getTracks().find(function (t) {
+ return t === track;
+ })) {
+ // this is not fully correct but all we can manage without
+ // [[associated MediaStreams]] internal slot.
+ throw new DOMException('The adapter.js addTrack polyfill only supports a single ' + ' stream which is associated with the specified track.', 'NotSupportedError');
+ }
+ var alreadyExists = this.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.', 'InvalidAccessError');
+ }
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ var oldStream = this._streams[stream.id];
+ if (oldStream) {
+ // this is using odd Chrome behaviour, use with caution:
+ // https://bugs.chromium.org/p/webrtc/issues/detail?id=7815
+ // Note: we rely on the high-level addTrack/dtmf shim to
+ // create the sender with a dtmf sender.
+ oldStream.addTrack(track);
+
+ // Trigger ONN async.
+ Promise.resolve().then(function () {
+ _this13.dispatchEvent(new Event('negotiationneeded'));
+ });
+ } else {
+ var newStream = new window.MediaStream([track]);
+ this._streams[stream.id] = newStream;
+ this._reverseStreams[newStream.id] = stream;
+ this.addStream(newStream);
+ }
+ return this.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ };
+
+ // replace the internal stream id with the external one and
+ // vice versa.
+ function replaceInternalStreamId(pc, description) {
+ var sdp = description.sdp;
+ Object.keys(pc._reverseStreams || []).forEach(function (internalId) {
+ var externalStream = pc._reverseStreams[internalId];
+ var internalStream = pc._streams[externalStream.id];
+ sdp = sdp.replace(new RegExp(internalStream.id, 'g'), externalStream.id);
+ });
+ return new RTCSessionDescription({
+ type: description.type,
+ sdp: sdp
+ });
+ }
+ function replaceExternalStreamId(pc, description) {
+ var sdp = description.sdp;
+ Object.keys(pc._reverseStreams || []).forEach(function (internalId) {
+ var externalStream = pc._reverseStreams[internalId];
+ var internalStream = pc._streams[externalStream.id];
+ sdp = sdp.replace(new RegExp(externalStream.id, 'g'), internalStream.id);
+ });
+ return new RTCSessionDescription({
+ type: description.type,
+ sdp: sdp
+ });
+ }
+ ['createOffer', 'createAnswer'].forEach(function (method) {
+ var nativeMethod = window.RTCPeerConnection.prototype[method];
+ var methodObj = _defineProperty({}, method, function () {
+ var _this14 = this;
+ var args = arguments;
+ var isLegacyCall = arguments.length && typeof arguments[0] === 'function';
+ if (isLegacyCall) {
+ return nativeMethod.apply(this, [function (description) {
+ var desc = replaceInternalStreamId(_this14, description);
+ args[0].apply(null, [desc]);
+ }, function (err) {
+ if (args[1]) {
+ args[1].apply(null, err);
+ }
+ }, arguments[2]]);
+ }
+ return nativeMethod.apply(this, arguments).then(function (description) {
+ return replaceInternalStreamId(_this14, description);
+ });
+ });
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ var origSetLocalDescription = window.RTCPeerConnection.prototype.setLocalDescription;
+ window.RTCPeerConnection.prototype.setLocalDescription = function setLocalDescription() {
+ if (!arguments.length || !arguments[0].type) {
+ return origSetLocalDescription.apply(this, arguments);
+ }
+ arguments[0] = replaceExternalStreamId(this, arguments[0]);
+ return origSetLocalDescription.apply(this, arguments);
+ };
+
+ // TODO: mangle getStats: https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamstats-streamidentifier
+
+ var origLocalDescription = Object.getOwnPropertyDescriptor(window.RTCPeerConnection.prototype, 'localDescription');
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'localDescription', {
+ get: function get() {
+ var description = origLocalDescription.get.apply(this);
+ if (description.type === '') {
+ return description;
+ }
+ return replaceInternalStreamId(this, description);
+ }
+ });
+ window.RTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
+ var _this15 = this;
+ if (this.signalingState === 'closed') {
+ throw new DOMException('The RTCPeerConnection\'s signalingState is \'closed\'.', 'InvalidStateError');
+ }
+ // We can not yet check for sender instanceof RTCRtpSender
+ // since we shim RTPSender. So we check if sender._pc is set.
+ if (!sender._pc) {
+ throw new DOMException('Argument 1 of RTCPeerConnection.removeTrack ' + 'does not implement interface RTCRtpSender.', 'TypeError');
+ }
+ var isLocal = sender._pc === this;
+ if (!isLocal) {
+ throw new DOMException('Sender was not created by this connection.', 'InvalidAccessError');
+ }
+
+ // Search for the native stream the senders track belongs to.
+ this._streams = this._streams || {};
+ var stream;
+ Object.keys(this._streams).forEach(function (streamid) {
+ var hasTrack = _this15._streams[streamid].getTracks().find(function (track) {
+ return sender.track === track;
+ });
+ if (hasTrack) {
+ stream = _this15._streams[streamid];
+ }
+ });
+ if (stream) {
+ if (stream.getTracks().length === 1) {
+ // if this is the last track of the stream, remove the stream. This
+ // takes care of any shimmed _senders.
+ this.removeStream(this._reverseStreams[stream.id]);
+ } else {
+ // relying on the same odd chrome behaviour as above.
+ stream.removeTrack(sender.track);
+ }
+ this.dispatchEvent(new Event('negotiationneeded'));
+ }
+ };
+}
+function shimPeerConnection(window, browserDetails) {
+ if (!window.RTCPeerConnection && window.webkitRTCPeerConnection) {
+ // very basic support for old versions.
+ window.RTCPeerConnection = window.webkitRTCPeerConnection;
+ }
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+
+ // shim implicit creation of RTCSessionDescription/RTCIceCandidate
+ if (browserDetails.version < 53) {
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
+ var nativeMethod = window.RTCPeerConnection.prototype[method];
+ var methodObj = _defineProperty({}, method, function () {
+ arguments[0] = new (method === 'addIceCandidate' ? window.RTCIceCandidate : window.RTCSessionDescription)(arguments[0]);
+ return nativeMethod.apply(this, arguments);
+ });
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ }
+}
+
+// Attempt to fix ONN in plan-b mode.
+function fixNegotiationNeeded(window, browserDetails) {
+ utils.wrapPeerConnectionEvent(window, 'negotiationneeded', function (e) {
+ var pc = e.target;
+ if (browserDetails.version < 72 || pc.getConfiguration && pc.getConfiguration().sdpSemantics === 'plan-b') {
+ if (pc.signalingState !== 'stable') {
+ return;
+ }
+ }
+ return e;
+ });
+}
diff --git a/node_modules/webrtc-adapter/dist/chrome/getdisplaymedia.js b/node_modules/webrtc-adapter/dist/chrome/getdisplaymedia.js
new file mode 100644
index 0000000..6ee7586
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/chrome/getdisplaymedia.js
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetDisplayMedia = shimGetDisplayMedia;
+function shimGetDisplayMedia(window, getSourceId) {
+ if (window.navigator.mediaDevices && 'getDisplayMedia' in window.navigator.mediaDevices) {
+ return;
+ }
+ if (!window.navigator.mediaDevices) {
+ return;
+ }
+ // getSourceId is a function that returns a promise resolving with
+ // the sourceId of the screen/window/tab to be shared.
+ if (typeof getSourceId !== 'function') {
+ console.error('shimGetDisplayMedia: getSourceId argument is not ' + 'a function');
+ return;
+ }
+ window.navigator.mediaDevices.getDisplayMedia = function getDisplayMedia(constraints) {
+ return getSourceId(constraints).then(function (sourceId) {
+ var widthSpecified = constraints.video && constraints.video.width;
+ var heightSpecified = constraints.video && constraints.video.height;
+ var frameRateSpecified = constraints.video && constraints.video.frameRate;
+ constraints.video = {
+ mandatory: {
+ chromeMediaSource: 'desktop',
+ chromeMediaSourceId: sourceId,
+ maxFrameRate: frameRateSpecified || 3
+ }
+ };
+ if (widthSpecified) {
+ constraints.video.mandatory.maxWidth = widthSpecified;
+ }
+ if (heightSpecified) {
+ constraints.video.mandatory.maxHeight = heightSpecified;
+ }
+ return window.navigator.mediaDevices.getUserMedia(constraints);
+ });
+ };
+}
diff --git a/node_modules/webrtc-adapter/dist/chrome/getusermedia.js b/node_modules/webrtc-adapter/dist/chrome/getusermedia.js
new file mode 100644
index 0000000..80e2547
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/chrome/getusermedia.js
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetUserMedia = shimGetUserMedia;
+var utils = _interopRequireWildcard(require("../utils.js"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+var logging = utils.log;
+function shimGetUserMedia(window, browserDetails) {
+ var navigator = window && window.navigator;
+ if (!navigator.mediaDevices) {
+ return;
+ }
+ var constraintsToChrome_ = function constraintsToChrome_(c) {
+ if (_typeof(c) !== 'object' || c.mandatory || c.optional) {
+ return c;
+ }
+ var cc = {};
+ Object.keys(c).forEach(function (key) {
+ if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
+ return;
+ }
+ var r = _typeof(c[key]) === 'object' ? c[key] : {
+ ideal: c[key]
+ };
+ if (r.exact !== undefined && typeof r.exact === 'number') {
+ r.min = r.max = r.exact;
+ }
+ var oldname_ = function oldname_(prefix, name) {
+ if (prefix) {
+ return prefix + name.charAt(0).toUpperCase() + name.slice(1);
+ }
+ return name === 'deviceId' ? 'sourceId' : name;
+ };
+ if (r.ideal !== undefined) {
+ cc.optional = cc.optional || [];
+ var oc = {};
+ if (typeof r.ideal === 'number') {
+ oc[oldname_('min', key)] = r.ideal;
+ cc.optional.push(oc);
+ oc = {};
+ oc[oldname_('max', key)] = r.ideal;
+ cc.optional.push(oc);
+ } else {
+ oc[oldname_('', key)] = r.ideal;
+ cc.optional.push(oc);
+ }
+ }
+ if (r.exact !== undefined && typeof r.exact !== 'number') {
+ cc.mandatory = cc.mandatory || {};
+ cc.mandatory[oldname_('', key)] = r.exact;
+ } else {
+ ['min', 'max'].forEach(function (mix) {
+ if (r[mix] !== undefined) {
+ cc.mandatory = cc.mandatory || {};
+ cc.mandatory[oldname_(mix, key)] = r[mix];
+ }
+ });
+ }
+ });
+ if (c.advanced) {
+ cc.optional = (cc.optional || []).concat(c.advanced);
+ }
+ return cc;
+ };
+ var shimConstraints_ = function shimConstraints_(constraints, func) {
+ if (browserDetails.version >= 61) {
+ return func(constraints);
+ }
+ constraints = JSON.parse(JSON.stringify(constraints));
+ if (constraints && _typeof(constraints.audio) === 'object') {
+ var remap = function remap(obj, a, b) {
+ if (a in obj && !(b in obj)) {
+ obj[b] = obj[a];
+ delete obj[a];
+ }
+ };
+ constraints = JSON.parse(JSON.stringify(constraints));
+ remap(constraints.audio, 'autoGainControl', 'googAutoGainControl');
+ remap(constraints.audio, 'noiseSuppression', 'googNoiseSuppression');
+ constraints.audio = constraintsToChrome_(constraints.audio);
+ }
+ if (constraints && _typeof(constraints.video) === 'object') {
+ // Shim facingMode for mobile & surface pro.
+ var face = constraints.video.facingMode;
+ face = face && (_typeof(face) === 'object' ? face : {
+ ideal: face
+ });
+ var getSupportedFacingModeLies = browserDetails.version < 66;
+ if (face && (face.exact === 'user' || face.exact === 'environment' || face.ideal === 'user' || face.ideal === 'environment') && !(navigator.mediaDevices.getSupportedConstraints && navigator.mediaDevices.getSupportedConstraints().facingMode && !getSupportedFacingModeLies)) {
+ delete constraints.video.facingMode;
+ var matches;
+ if (face.exact === 'environment' || face.ideal === 'environment') {
+ matches = ['back', 'rear'];
+ } else if (face.exact === 'user' || face.ideal === 'user') {
+ matches = ['front'];
+ }
+ if (matches) {
+ // Look for matches in label, or use last cam for back (typical).
+ return navigator.mediaDevices.enumerateDevices().then(function (devices) {
+ devices = devices.filter(function (d) {
+ return d.kind === 'videoinput';
+ });
+ var dev = devices.find(function (d) {
+ return matches.some(function (match) {
+ return d.label.toLowerCase().includes(match);
+ });
+ });
+ if (!dev && devices.length && matches.includes('back')) {
+ dev = devices[devices.length - 1]; // more likely the back cam
+ }
+
+ if (dev) {
+ constraints.video.deviceId = face.exact ? {
+ exact: dev.deviceId
+ } : {
+ ideal: dev.deviceId
+ };
+ }
+ constraints.video = constraintsToChrome_(constraints.video);
+ logging('chrome: ' + JSON.stringify(constraints));
+ return func(constraints);
+ });
+ }
+ }
+ constraints.video = constraintsToChrome_(constraints.video);
+ }
+ logging('chrome: ' + JSON.stringify(constraints));
+ return func(constraints);
+ };
+ var shimError_ = function shimError_(e) {
+ if (browserDetails.version >= 64) {
+ return e;
+ }
+ return {
+ name: {
+ PermissionDeniedError: 'NotAllowedError',
+ PermissionDismissedError: 'NotAllowedError',
+ InvalidStateError: 'NotAllowedError',
+ DevicesNotFoundError: 'NotFoundError',
+ ConstraintNotSatisfiedError: 'OverconstrainedError',
+ TrackStartError: 'NotReadableError',
+ MediaDeviceFailedDueToShutdown: 'NotAllowedError',
+ MediaDeviceKillSwitchOn: 'NotAllowedError',
+ TabCaptureError: 'AbortError',
+ ScreenCaptureError: 'AbortError',
+ DeviceCaptureError: 'AbortError'
+ }[e.name] || e.name,
+ message: e.message,
+ constraint: e.constraint || e.constraintName,
+ toString: function toString() {
+ return this.name + (this.message && ': ') + this.message;
+ }
+ };
+ };
+ var getUserMedia_ = function getUserMedia_(constraints, onSuccess, onError) {
+ shimConstraints_(constraints, function (c) {
+ navigator.webkitGetUserMedia(c, onSuccess, function (e) {
+ if (onError) {
+ onError(shimError_(e));
+ }
+ });
+ });
+ };
+ navigator.getUserMedia = getUserMedia_.bind(navigator);
+
+ // Even though Chrome 45 has navigator.mediaDevices and a getUserMedia
+ // function which returns a Promise, it does not accept spec-style
+ // constraints.
+ if (navigator.mediaDevices.getUserMedia) {
+ var origGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
+ navigator.mediaDevices.getUserMedia = function (cs) {
+ return shimConstraints_(cs, function (c) {
+ return origGetUserMedia(c).then(function (stream) {
+ if (c.audio && !stream.getAudioTracks().length || c.video && !stream.getVideoTracks().length) {
+ stream.getTracks().forEach(function (track) {
+ track.stop();
+ });
+ throw new DOMException('', 'NotFoundError');
+ }
+ return stream;
+ }, function (e) {
+ return Promise.reject(shimError_(e));
+ });
+ });
+ };
+ }
+}
diff --git a/node_modules/webrtc-adapter/dist/chrome/selectaudiooutput.js b/node_modules/webrtc-adapter/dist/chrome/selectaudiooutput.js
new file mode 100644
index 0000000..9e577e4
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/chrome/selectaudiooutput.js
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2022 The adapter.js project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimSelectAudioOutput = shimSelectAudioOutput;
+function shimSelectAudioOutput(window) {
+ // Polyfillying only makes sense when setSinkId is available
+ // and the function is not already there.
+ if (!('HTMLMediaElement' in window)) {
+ return;
+ }
+ if (!('setSinkId' in window.HTMLMediaElement.prototype)) {
+ return;
+ }
+ if (!(window.navigator && window.navigator.mediaDevices)) {
+ return;
+ }
+ if (!window.navigator.mediaDevices.enumerateDevices) {
+ return;
+ }
+ if (window.navigator.mediaDevices.selectAudioOutput) {
+ return;
+ }
+ window.navigator.mediaDevices.selectAudioOutput = function () {
+ return window.navigator.mediaDevices.enumerateDevices().then(function (devices) {
+ return devices.filter(function (d) {
+ return d.kind === 'audiooutput';
+ });
+ });
+ };
+}
diff --git a/node_modules/webrtc-adapter/dist/common_shim.js b/node_modules/webrtc-adapter/dist/common_shim.js
new file mode 100644
index 0000000..1214fa0
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/common_shim.js
@@ -0,0 +1,436 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.removeExtmapAllowMixed = removeExtmapAllowMixed;
+exports.shimAddIceCandidateNullOrEmpty = shimAddIceCandidateNullOrEmpty;
+exports.shimConnectionState = shimConnectionState;
+exports.shimMaxMessageSize = shimMaxMessageSize;
+exports.shimParameterlessSetLocalDescription = shimParameterlessSetLocalDescription;
+exports.shimRTCIceCandidate = shimRTCIceCandidate;
+exports.shimRTCIceCandidateRelayProtocol = shimRTCIceCandidateRelayProtocol;
+exports.shimSendThrowTypeError = shimSendThrowTypeError;
+var _sdp = _interopRequireDefault(require("sdp"));
+var utils = _interopRequireWildcard(require("./utils"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimRTCIceCandidate(window) {
+ // foundation is arbitrarily chosen as an indicator for full support for
+ // https://w3c.github.io/webrtc-pc/#rtcicecandidate-interface
+ if (!window.RTCIceCandidate || window.RTCIceCandidate && 'foundation' in window.RTCIceCandidate.prototype) {
+ return;
+ }
+ var NativeRTCIceCandidate = window.RTCIceCandidate;
+ window.RTCIceCandidate = function RTCIceCandidate(args) {
+ // Remove the a= which shouldn't be part of the candidate string.
+ if (_typeof(args) === 'object' && args.candidate && args.candidate.indexOf('a=') === 0) {
+ args = JSON.parse(JSON.stringify(args));
+ args.candidate = args.candidate.substring(2);
+ }
+ if (args.candidate && args.candidate.length) {
+ // Augment the native candidate with the parsed fields.
+ var nativeCandidate = new NativeRTCIceCandidate(args);
+ var parsedCandidate = _sdp["default"].parseCandidate(args.candidate);
+ for (var key in parsedCandidate) {
+ if (!(key in nativeCandidate)) {
+ Object.defineProperty(nativeCandidate, key, {
+ value: parsedCandidate[key]
+ });
+ }
+ }
+
+ // Override serializer to not serialize the extra attributes.
+ nativeCandidate.toJSON = function toJSON() {
+ return {
+ candidate: nativeCandidate.candidate,
+ sdpMid: nativeCandidate.sdpMid,
+ sdpMLineIndex: nativeCandidate.sdpMLineIndex,
+ usernameFragment: nativeCandidate.usernameFragment
+ };
+ };
+ return nativeCandidate;
+ }
+ return new NativeRTCIceCandidate(args);
+ };
+ window.RTCIceCandidate.prototype = NativeRTCIceCandidate.prototype;
+
+ // Hook up the augmented candidate in onicecandidate and
+ // addEventListener('icecandidate', ...)
+ utils.wrapPeerConnectionEvent(window, 'icecandidate', function (e) {
+ if (e.candidate) {
+ Object.defineProperty(e, 'candidate', {
+ value: new window.RTCIceCandidate(e.candidate),
+ writable: 'false'
+ });
+ }
+ return e;
+ });
+}
+function shimRTCIceCandidateRelayProtocol(window) {
+ if (!window.RTCIceCandidate || window.RTCIceCandidate && 'relayProtocol' in window.RTCIceCandidate.prototype) {
+ return;
+ }
+
+ // Hook up the augmented candidate in onicecandidate and
+ // addEventListener('icecandidate', ...)
+ utils.wrapPeerConnectionEvent(window, 'icecandidate', function (e) {
+ if (e.candidate) {
+ var parsedCandidate = _sdp["default"].parseCandidate(e.candidate.candidate);
+ if (parsedCandidate.type === 'relay') {
+ // This is a libwebrtc-specific mapping of local type preference
+ // to relayProtocol.
+ e.candidate.relayProtocol = {
+ 0: 'tls',
+ 1: 'tcp',
+ 2: 'udp'
+ }[parsedCandidate.priority >> 24];
+ }
+ }
+ return e;
+ });
+}
+function shimMaxMessageSize(window, browserDetails) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ if (!('sctp' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'sctp', {
+ get: function get() {
+ return typeof this._sctp === 'undefined' ? null : this._sctp;
+ }
+ });
+ }
+ var sctpInDescription = function sctpInDescription(description) {
+ if (!description || !description.sdp) {
+ return false;
+ }
+ var sections = _sdp["default"].splitSections(description.sdp);
+ sections.shift();
+ return sections.some(function (mediaSection) {
+ var mLine = _sdp["default"].parseMLine(mediaSection);
+ return mLine && mLine.kind === 'application' && mLine.protocol.indexOf('SCTP') !== -1;
+ });
+ };
+ var getRemoteFirefoxVersion = function getRemoteFirefoxVersion(description) {
+ // TODO: Is there a better solution for detecting Firefox?
+ var match = description.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);
+ if (match === null || match.length < 2) {
+ return -1;
+ }
+ var version = parseInt(match[1], 10);
+ // Test for NaN (yes, this is ugly)
+ return version !== version ? -1 : version;
+ };
+ var getCanSendMaxMessageSize = function getCanSendMaxMessageSize(remoteIsFirefox) {
+ // Every implementation we know can send at least 64 KiB.
+ // Note: Although Chrome is technically able to send up to 256 KiB, the
+ // data does not reach the other peer reliably.
+ // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=8419
+ var canSendMaxMessageSize = 65536;
+ if (browserDetails.browser === 'firefox') {
+ if (browserDetails.version < 57) {
+ if (remoteIsFirefox === -1) {
+ // FF < 57 will send in 16 KiB chunks using the deprecated PPID
+ // fragmentation.
+ canSendMaxMessageSize = 16384;
+ } else {
+ // However, other FF (and RAWRTC) can reassemble PPID-fragmented
+ // messages. Thus, supporting ~2 GiB when sending.
+ canSendMaxMessageSize = 2147483637;
+ }
+ } else if (browserDetails.version < 60) {
+ // Currently, all FF >= 57 will reset the remote maximum message size
+ // to the default value when a data channel is created at a later
+ // stage. :(
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
+ canSendMaxMessageSize = browserDetails.version === 57 ? 65535 : 65536;
+ } else {
+ // FF >= 60 supports sending ~2 GiB
+ canSendMaxMessageSize = 2147483637;
+ }
+ }
+ return canSendMaxMessageSize;
+ };
+ var getMaxMessageSize = function getMaxMessageSize(description, remoteIsFirefox) {
+ // Note: 65536 bytes is the default value from the SDP spec. Also,
+ // every implementation we know supports receiving 65536 bytes.
+ var maxMessageSize = 65536;
+
+ // FF 57 has a slightly incorrect default remote max message size, so
+ // we need to adjust it here to avoid a failure when sending.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1425697
+ if (browserDetails.browser === 'firefox' && browserDetails.version === 57) {
+ maxMessageSize = 65535;
+ }
+ var match = _sdp["default"].matchPrefix(description.sdp, 'a=max-message-size:');
+ if (match.length > 0) {
+ maxMessageSize = parseInt(match[0].substring(19), 10);
+ } else if (browserDetails.browser === 'firefox' && remoteIsFirefox !== -1) {
+ // If the maximum message size is not present in the remote SDP and
+ // both local and remote are Firefox, the remote peer can receive
+ // ~2 GiB.
+ maxMessageSize = 2147483637;
+ }
+ return maxMessageSize;
+ };
+ var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
+ this._sctp = null;
+ // Chrome decided to not expose .sctp in plan-b mode.
+ // As usual, adapter.js has to do an 'ugly worakaround'
+ // to cover up the mess.
+ if (browserDetails.browser === 'chrome' && browserDetails.version >= 76) {
+ var _this$getConfiguratio = this.getConfiguration(),
+ sdpSemantics = _this$getConfiguratio.sdpSemantics;
+ if (sdpSemantics === 'plan-b') {
+ Object.defineProperty(this, 'sctp', {
+ get: function get() {
+ return typeof this._sctp === 'undefined' ? null : this._sctp;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ }
+ }
+ if (sctpInDescription(arguments[0])) {
+ // Check if the remote is FF.
+ var isFirefox = getRemoteFirefoxVersion(arguments[0]);
+
+ // Get the maximum message size the local peer is capable of sending
+ var canSendMMS = getCanSendMaxMessageSize(isFirefox);
+
+ // Get the maximum message size of the remote peer.
+ var remoteMMS = getMaxMessageSize(arguments[0], isFirefox);
+
+ // Determine final maximum message size
+ var maxMessageSize;
+ if (canSendMMS === 0 && remoteMMS === 0) {
+ maxMessageSize = Number.POSITIVE_INFINITY;
+ } else if (canSendMMS === 0 || remoteMMS === 0) {
+ maxMessageSize = Math.max(canSendMMS, remoteMMS);
+ } else {
+ maxMessageSize = Math.min(canSendMMS, remoteMMS);
+ }
+
+ // Create a dummy RTCSctpTransport object and the 'maxMessageSize'
+ // attribute.
+ var sctp = {};
+ Object.defineProperty(sctp, 'maxMessageSize', {
+ get: function get() {
+ return maxMessageSize;
+ }
+ });
+ this._sctp = sctp;
+ }
+ return origSetRemoteDescription.apply(this, arguments);
+ };
+}
+function shimSendThrowTypeError(window) {
+ if (!(window.RTCPeerConnection && 'createDataChannel' in window.RTCPeerConnection.prototype)) {
+ return;
+ }
+
+ // Note: Although Firefox >= 57 has a native implementation, the maximum
+ // message size can be reset for all data channels at a later stage.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
+
+ function wrapDcSend(dc, pc) {
+ var origDataChannelSend = dc.send;
+ dc.send = function send() {
+ var data = arguments[0];
+ var length = data.length || data.size || data.byteLength;
+ if (dc.readyState === 'open' && pc.sctp && length > pc.sctp.maxMessageSize) {
+ throw new TypeError('Message too large (can send a maximum of ' + pc.sctp.maxMessageSize + ' bytes)');
+ }
+ return origDataChannelSend.apply(dc, arguments);
+ };
+ }
+ var origCreateDataChannel = window.RTCPeerConnection.prototype.createDataChannel;
+ window.RTCPeerConnection.prototype.createDataChannel = function createDataChannel() {
+ var dataChannel = origCreateDataChannel.apply(this, arguments);
+ wrapDcSend(dataChannel, this);
+ return dataChannel;
+ };
+ utils.wrapPeerConnectionEvent(window, 'datachannel', function (e) {
+ wrapDcSend(e.channel, e.target);
+ return e;
+ });
+}
+
+/* shims RTCConnectionState by pretending it is the same as iceConnectionState.
+ * See https://bugs.chromium.org/p/webrtc/issues/detail?id=6145#c12
+ * for why this is a valid hack in Chrome. In Firefox it is slightly incorrect
+ * since DTLS failures would be hidden. See
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=1265827
+ * for the Firefox tracking bug.
+ */
+function shimConnectionState(window) {
+ if (!window.RTCPeerConnection || 'connectionState' in window.RTCPeerConnection.prototype) {
+ return;
+ }
+ var proto = window.RTCPeerConnection.prototype;
+ Object.defineProperty(proto, 'connectionState', {
+ get: function get() {
+ return {
+ completed: 'connected',
+ checking: 'connecting'
+ }[this.iceConnectionState] || this.iceConnectionState;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(proto, 'onconnectionstatechange', {
+ get: function get() {
+ return this._onconnectionstatechange || null;
+ },
+ set: function set(cb) {
+ if (this._onconnectionstatechange) {
+ this.removeEventListener('connectionstatechange', this._onconnectionstatechange);
+ delete this._onconnectionstatechange;
+ }
+ if (cb) {
+ this.addEventListener('connectionstatechange', this._onconnectionstatechange = cb);
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+ ['setLocalDescription', 'setRemoteDescription'].forEach(function (method) {
+ var origMethod = proto[method];
+ proto[method] = function () {
+ if (!this._connectionstatechangepoly) {
+ this._connectionstatechangepoly = function (e) {
+ var pc = e.target;
+ if (pc._lastConnectionState !== pc.connectionState) {
+ pc._lastConnectionState = pc.connectionState;
+ var newEvent = new Event('connectionstatechange', e);
+ pc.dispatchEvent(newEvent);
+ }
+ return e;
+ };
+ this.addEventListener('iceconnectionstatechange', this._connectionstatechangepoly);
+ }
+ return origMethod.apply(this, arguments);
+ };
+ });
+}
+function removeExtmapAllowMixed(window, browserDetails) {
+ /* remove a=extmap-allow-mixed for webrtc.org < M71 */
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ if (browserDetails.browser === 'chrome' && browserDetails.version >= 71) {
+ return;
+ }
+ if (browserDetails.browser === 'safari' && browserDetails.version >= 605) {
+ return;
+ }
+ var nativeSRD = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription(desc) {
+ if (desc && desc.sdp && desc.sdp.indexOf('\na=extmap-allow-mixed') !== -1) {
+ var sdp = desc.sdp.split('\n').filter(function (line) {
+ return line.trim() !== 'a=extmap-allow-mixed';
+ }).join('\n');
+ // Safari enforces read-only-ness of RTCSessionDescription fields.
+ if (window.RTCSessionDescription && desc instanceof window.RTCSessionDescription) {
+ arguments[0] = new window.RTCSessionDescription({
+ type: desc.type,
+ sdp: sdp
+ });
+ } else {
+ desc.sdp = sdp;
+ }
+ }
+ return nativeSRD.apply(this, arguments);
+ };
+}
+function shimAddIceCandidateNullOrEmpty(window, browserDetails) {
+ // Support for addIceCandidate(null or undefined)
+ // as well as addIceCandidate({candidate: "", ...})
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=978582
+ // Note: must be called before other polyfills which change the signature.
+ if (!(window.RTCPeerConnection && window.RTCPeerConnection.prototype)) {
+ return;
+ }
+ var nativeAddIceCandidate = window.RTCPeerConnection.prototype.addIceCandidate;
+ if (!nativeAddIceCandidate || nativeAddIceCandidate.length === 0) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.addIceCandidate = function addIceCandidate() {
+ if (!arguments[0]) {
+ if (arguments[1]) {
+ arguments[1].apply(null);
+ }
+ return Promise.resolve();
+ }
+ // Firefox 68+ emits and processes {candidate: "", ...}, ignore
+ // in older versions.
+ // Native support for ignoring exists for Chrome M77+.
+ // Safari ignores as well, exact version unknown but works in the same
+ // version that also ignores addIceCandidate(null).
+ if ((browserDetails.browser === 'chrome' && browserDetails.version < 78 || browserDetails.browser === 'firefox' && browserDetails.version < 68 || browserDetails.browser === 'safari') && arguments[0] && arguments[0].candidate === '') {
+ return Promise.resolve();
+ }
+ return nativeAddIceCandidate.apply(this, arguments);
+ };
+}
+
+// Note: Make sure to call this ahead of APIs that modify
+// setLocalDescription.length
+function shimParameterlessSetLocalDescription(window, browserDetails) {
+ if (!(window.RTCPeerConnection && window.RTCPeerConnection.prototype)) {
+ return;
+ }
+ var nativeSetLocalDescription = window.RTCPeerConnection.prototype.setLocalDescription;
+ if (!nativeSetLocalDescription || nativeSetLocalDescription.length === 0) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.setLocalDescription = function setLocalDescription() {
+ var _this = this;
+ var desc = arguments[0] || {};
+ if (_typeof(desc) !== 'object' || desc.type && desc.sdp) {
+ return nativeSetLocalDescription.apply(this, arguments);
+ }
+ // The remaining steps should technically happen when SLD comes off the
+ // RTCPeerConnection's operations chain (not ahead of going on it), but
+ // this is too difficult to shim. Instead, this shim only covers the
+ // common case where the operations chain is empty. This is imperfect, but
+ // should cover many cases. Rationale: Even if we can't reduce the glare
+ // window to zero on imperfect implementations, there's value in tapping
+ // into the perfect negotiation pattern that several browsers support.
+ desc = {
+ type: desc.type,
+ sdp: desc.sdp
+ };
+ if (!desc.type) {
+ switch (this.signalingState) {
+ case 'stable':
+ case 'have-local-offer':
+ case 'have-remote-pranswer':
+ desc.type = 'offer';
+ break;
+ default:
+ desc.type = 'answer';
+ break;
+ }
+ }
+ if (desc.sdp || desc.type !== 'offer' && desc.type !== 'answer') {
+ return nativeSetLocalDescription.apply(this, [desc]);
+ }
+ var func = desc.type === 'offer' ? this.createOffer : this.createAnswer;
+ return func.apply(this).then(function (d) {
+ return nativeSetLocalDescription.apply(_this, [d]);
+ });
+ };
+}
diff --git a/node_modules/webrtc-adapter/dist/firefox/firefox_shim.js b/node_modules/webrtc-adapter/dist/firefox/firefox_shim.js
new file mode 100644
index 0000000..44c4c38
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/firefox/firefox_shim.js
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimAddTransceiver = shimAddTransceiver;
+exports.shimCreateAnswer = shimCreateAnswer;
+exports.shimCreateOffer = shimCreateOffer;
+Object.defineProperty(exports, "shimGetDisplayMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getdisplaymedia.shimGetDisplayMedia;
+ }
+});
+exports.shimGetParameters = shimGetParameters;
+Object.defineProperty(exports, "shimGetUserMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getusermedia.shimGetUserMedia;
+ }
+});
+exports.shimOnTrack = shimOnTrack;
+exports.shimPeerConnection = shimPeerConnection;
+exports.shimRTCDataChannel = shimRTCDataChannel;
+exports.shimReceiverGetStats = shimReceiverGetStats;
+exports.shimRemoveStream = shimRemoveStream;
+exports.shimSenderGetStats = shimSenderGetStats;
+var utils = _interopRequireWildcard(require("../utils"));
+var _getusermedia = require("./getusermedia");
+var _getdisplaymedia = require("./getdisplaymedia");
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
+function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
+function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimOnTrack(window) {
+ if (_typeof(window) === 'object' && window.RTCTrackEvent && 'receiver' in window.RTCTrackEvent.prototype && !('transceiver' in window.RTCTrackEvent.prototype)) {
+ Object.defineProperty(window.RTCTrackEvent.prototype, 'transceiver', {
+ get: function get() {
+ return {
+ receiver: this.receiver
+ };
+ }
+ });
+ }
+}
+function shimPeerConnection(window, browserDetails) {
+ if (_typeof(window) !== 'object' || !(window.RTCPeerConnection || window.mozRTCPeerConnection)) {
+ return; // probably media.peerconnection.enabled=false in about:config
+ }
+
+ if (!window.RTCPeerConnection && window.mozRTCPeerConnection) {
+ // very basic support for old versions.
+ window.RTCPeerConnection = window.mozRTCPeerConnection;
+ }
+ if (browserDetails.version < 53) {
+ // shim away need for obsolete RTCIceCandidate/RTCSessionDescription.
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
+ var nativeMethod = window.RTCPeerConnection.prototype[method];
+ var methodObj = _defineProperty({}, method, function () {
+ arguments[0] = new (method === 'addIceCandidate' ? window.RTCIceCandidate : window.RTCSessionDescription)(arguments[0]);
+ return nativeMethod.apply(this, arguments);
+ });
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ }
+ var modernStatsTypes = {
+ inboundrtp: 'inbound-rtp',
+ outboundrtp: 'outbound-rtp',
+ candidatepair: 'candidate-pair',
+ localcandidate: 'local-candidate',
+ remotecandidate: 'remote-candidate'
+ };
+ var nativeGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ var _arguments = Array.prototype.slice.call(arguments),
+ selector = _arguments[0],
+ onSucc = _arguments[1],
+ onErr = _arguments[2];
+ return nativeGetStats.apply(this, [selector || null]).then(function (stats) {
+ if (browserDetails.version < 53 && !onSucc) {
+ // Shim only promise getStats with spec-hyphens in type names
+ // Leave callback version alone; misc old uses of forEach before Map
+ try {
+ stats.forEach(function (stat) {
+ stat.type = modernStatsTypes[stat.type] || stat.type;
+ });
+ } catch (e) {
+ if (e.name !== 'TypeError') {
+ throw e;
+ }
+ // Avoid TypeError: "type" is read-only, in old versions. 34-43ish
+ stats.forEach(function (stat, i) {
+ stats.set(i, Object.assign({}, stat, {
+ type: modernStatsTypes[stat.type] || stat.type
+ }));
+ });
+ }
+ }
+ return stats;
+ }).then(onSucc, onErr);
+ };
+}
+function shimSenderGetStats(window) {
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection && window.RTCRtpSender)) {
+ return;
+ }
+ if (window.RTCRtpSender && 'getStats' in window.RTCRtpSender.prototype) {
+ return;
+ }
+ var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ if (origGetSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ var _this = this;
+ var senders = origGetSenders.apply(this, []);
+ senders.forEach(function (sender) {
+ return sender._pc = _this;
+ });
+ return senders;
+ };
+ }
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ if (origAddTrack) {
+ window.RTCPeerConnection.prototype.addTrack = function addTrack() {
+ var sender = origAddTrack.apply(this, arguments);
+ sender._pc = this;
+ return sender;
+ };
+ }
+ window.RTCRtpSender.prototype.getStats = function getStats() {
+ return this.track ? this._pc.getStats(this.track) : Promise.resolve(new Map());
+ };
+}
+function shimReceiverGetStats(window) {
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection && window.RTCRtpSender)) {
+ return;
+ }
+ if (window.RTCRtpSender && 'getStats' in window.RTCRtpReceiver.prototype) {
+ return;
+ }
+ var origGetReceivers = window.RTCPeerConnection.prototype.getReceivers;
+ if (origGetReceivers) {
+ window.RTCPeerConnection.prototype.getReceivers = function getReceivers() {
+ var _this2 = this;
+ var receivers = origGetReceivers.apply(this, []);
+ receivers.forEach(function (receiver) {
+ return receiver._pc = _this2;
+ });
+ return receivers;
+ };
+ }
+ utils.wrapPeerConnectionEvent(window, 'track', function (e) {
+ e.receiver._pc = e.srcElement;
+ return e;
+ });
+ window.RTCRtpReceiver.prototype.getStats = function getStats() {
+ return this._pc.getStats(this.track);
+ };
+}
+function shimRemoveStream(window) {
+ if (!window.RTCPeerConnection || 'removeStream' in window.RTCPeerConnection.prototype) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ var _this3 = this;
+ utils.deprecated('removeStream', 'removeTrack');
+ this.getSenders().forEach(function (sender) {
+ if (sender.track && stream.getTracks().includes(sender.track)) {
+ _this3.removeTrack(sender);
+ }
+ });
+ };
+}
+function shimRTCDataChannel(window) {
+ // rename DataChannel to RTCDataChannel (native fix in FF60):
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1173851
+ if (window.DataChannel && !window.RTCDataChannel) {
+ window.RTCDataChannel = window.DataChannel;
+ }
+}
+function shimAddTransceiver(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ var origAddTransceiver = window.RTCPeerConnection.prototype.addTransceiver;
+ if (origAddTransceiver) {
+ window.RTCPeerConnection.prototype.addTransceiver = function addTransceiver() {
+ this.setParametersPromises = [];
+ // WebIDL input coercion and validation
+ var sendEncodings = arguments[1] && arguments[1].sendEncodings;
+ if (sendEncodings === undefined) {
+ sendEncodings = [];
+ }
+ sendEncodings = _toConsumableArray(sendEncodings);
+ var shouldPerformCheck = sendEncodings.length > 0;
+ if (shouldPerformCheck) {
+ // If sendEncodings params are provided, validate grammar
+ sendEncodings.forEach(function (encodingParam) {
+ if ('rid' in encodingParam) {
+ var ridRegex = /^[a-z0-9]{0,16}$/i;
+ if (!ridRegex.test(encodingParam.rid)) {
+ throw new TypeError('Invalid RID value provided.');
+ }
+ }
+ if ('scaleResolutionDownBy' in encodingParam) {
+ if (!(parseFloat(encodingParam.scaleResolutionDownBy) >= 1.0)) {
+ throw new RangeError('scale_resolution_down_by must be >= 1.0');
+ }
+ }
+ if ('maxFramerate' in encodingParam) {
+ if (!(parseFloat(encodingParam.maxFramerate) >= 0)) {
+ throw new RangeError('max_framerate must be >= 0.0');
+ }
+ }
+ });
+ }
+ var transceiver = origAddTransceiver.apply(this, arguments);
+ if (shouldPerformCheck) {
+ // Check if the init options were applied. If not we do this in an
+ // asynchronous way and save the promise reference in a global object.
+ // This is an ugly hack, but at the same time is way more robust than
+ // checking the sender parameters before and after the createOffer
+ // Also note that after the createoffer we are not 100% sure that
+ // the params were asynchronously applied so we might miss the
+ // opportunity to recreate offer.
+ var sender = transceiver.sender;
+ var params = sender.getParameters();
+ if (!('encodings' in params) ||
+ // Avoid being fooled by patched getParameters() below.
+ params.encodings.length === 1 && Object.keys(params.encodings[0]).length === 0) {
+ params.encodings = sendEncodings;
+ sender.sendEncodings = sendEncodings;
+ this.setParametersPromises.push(sender.setParameters(params).then(function () {
+ delete sender.sendEncodings;
+ })["catch"](function () {
+ delete sender.sendEncodings;
+ }));
+ }
+ }
+ return transceiver;
+ };
+ }
+}
+function shimGetParameters(window) {
+ if (!(_typeof(window) === 'object' && window.RTCRtpSender)) {
+ return;
+ }
+ var origGetParameters = window.RTCRtpSender.prototype.getParameters;
+ if (origGetParameters) {
+ window.RTCRtpSender.prototype.getParameters = function getParameters() {
+ var params = origGetParameters.apply(this, arguments);
+ if (!('encodings' in params)) {
+ params.encodings = [].concat(this.sendEncodings || [{}]);
+ }
+ return params;
+ };
+ }
+}
+function shimCreateOffer(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ var origCreateOffer = window.RTCPeerConnection.prototype.createOffer;
+ window.RTCPeerConnection.prototype.createOffer = function createOffer() {
+ var _arguments2 = arguments,
+ _this4 = this;
+ if (this.setParametersPromises && this.setParametersPromises.length) {
+ return Promise.all(this.setParametersPromises).then(function () {
+ return origCreateOffer.apply(_this4, _arguments2);
+ })["finally"](function () {
+ _this4.setParametersPromises = [];
+ });
+ }
+ return origCreateOffer.apply(this, arguments);
+ };
+}
+function shimCreateAnswer(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ var origCreateAnswer = window.RTCPeerConnection.prototype.createAnswer;
+ window.RTCPeerConnection.prototype.createAnswer = function createAnswer() {
+ var _arguments3 = arguments,
+ _this5 = this;
+ if (this.setParametersPromises && this.setParametersPromises.length) {
+ return Promise.all(this.setParametersPromises).then(function () {
+ return origCreateAnswer.apply(_this5, _arguments3);
+ })["finally"](function () {
+ _this5.setParametersPromises = [];
+ });
+ }
+ return origCreateAnswer.apply(this, arguments);
+ };
+}
diff --git a/node_modules/webrtc-adapter/dist/firefox/getdisplaymedia.js b/node_modules/webrtc-adapter/dist/firefox/getdisplaymedia.js
new file mode 100644
index 0000000..bd2caaa
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/firefox/getdisplaymedia.js
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetDisplayMedia = shimGetDisplayMedia;
+function shimGetDisplayMedia(window, preferredMediaSource) {
+ if (window.navigator.mediaDevices && 'getDisplayMedia' in window.navigator.mediaDevices) {
+ return;
+ }
+ if (!window.navigator.mediaDevices) {
+ return;
+ }
+ window.navigator.mediaDevices.getDisplayMedia = function getDisplayMedia(constraints) {
+ if (!(constraints && constraints.video)) {
+ var err = new DOMException('getDisplayMedia without video ' + 'constraints is undefined');
+ err.name = 'NotFoundError';
+ // from https://heycam.github.io/webidl/#idl-DOMException-error-names
+ err.code = 8;
+ return Promise.reject(err);
+ }
+ if (constraints.video === true) {
+ constraints.video = {
+ mediaSource: preferredMediaSource
+ };
+ } else {
+ constraints.video.mediaSource = preferredMediaSource;
+ }
+ return window.navigator.mediaDevices.getUserMedia(constraints);
+ };
+}
diff --git a/node_modules/webrtc-adapter/dist/firefox/getusermedia.js b/node_modules/webrtc-adapter/dist/firefox/getusermedia.js
new file mode 100644
index 0000000..eac0dc4
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/firefox/getusermedia.js
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetUserMedia = shimGetUserMedia;
+var utils = _interopRequireWildcard(require("../utils"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimGetUserMedia(window, browserDetails) {
+ var navigator = window && window.navigator;
+ var MediaStreamTrack = window && window.MediaStreamTrack;
+ navigator.getUserMedia = function (constraints, onSuccess, onError) {
+ // Replace Firefox 44+'s deprecation warning with unprefixed version.
+ utils.deprecated('navigator.getUserMedia', 'navigator.mediaDevices.getUserMedia');
+ navigator.mediaDevices.getUserMedia(constraints).then(onSuccess, onError);
+ };
+ if (!(browserDetails.version > 55 && 'autoGainControl' in navigator.mediaDevices.getSupportedConstraints())) {
+ var remap = function remap(obj, a, b) {
+ if (a in obj && !(b in obj)) {
+ obj[b] = obj[a];
+ delete obj[a];
+ }
+ };
+ var nativeGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
+ navigator.mediaDevices.getUserMedia = function (c) {
+ if (_typeof(c) === 'object' && _typeof(c.audio) === 'object') {
+ c = JSON.parse(JSON.stringify(c));
+ remap(c.audio, 'autoGainControl', 'mozAutoGainControl');
+ remap(c.audio, 'noiseSuppression', 'mozNoiseSuppression');
+ }
+ return nativeGetUserMedia(c);
+ };
+ if (MediaStreamTrack && MediaStreamTrack.prototype.getSettings) {
+ var nativeGetSettings = MediaStreamTrack.prototype.getSettings;
+ MediaStreamTrack.prototype.getSettings = function () {
+ var obj = nativeGetSettings.apply(this, arguments);
+ remap(obj, 'mozAutoGainControl', 'autoGainControl');
+ remap(obj, 'mozNoiseSuppression', 'noiseSuppression');
+ return obj;
+ };
+ }
+ if (MediaStreamTrack && MediaStreamTrack.prototype.applyConstraints) {
+ var nativeApplyConstraints = MediaStreamTrack.prototype.applyConstraints;
+ MediaStreamTrack.prototype.applyConstraints = function (c) {
+ if (this.kind === 'audio' && _typeof(c) === 'object') {
+ c = JSON.parse(JSON.stringify(c));
+ remap(c, 'autoGainControl', 'mozAutoGainControl');
+ remap(c, 'noiseSuppression', 'mozNoiseSuppression');
+ }
+ return nativeApplyConstraints.apply(this, [c]);
+ };
+ }
+ }
+}
diff --git a/node_modules/webrtc-adapter/dist/safari/safari_shim.js b/node_modules/webrtc-adapter/dist/safari/safari_shim.js
new file mode 100644
index 0000000..9d841ee
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/safari/safari_shim.js
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimAudioContext = shimAudioContext;
+exports.shimCallbacksAPI = shimCallbacksAPI;
+exports.shimConstraints = shimConstraints;
+exports.shimCreateOfferLegacy = shimCreateOfferLegacy;
+exports.shimGetUserMedia = shimGetUserMedia;
+exports.shimLocalStreamsAPI = shimLocalStreamsAPI;
+exports.shimRTCIceServerUrls = shimRTCIceServerUrls;
+exports.shimRemoteStreamsAPI = shimRemoteStreamsAPI;
+exports.shimTrackEventTransceiver = shimTrackEventTransceiver;
+var utils = _interopRequireWildcard(require("../utils"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimLocalStreamsAPI(window) {
+ if (_typeof(window) !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ if (!('getLocalStreams' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.getLocalStreams = function getLocalStreams() {
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ return this._localStreams;
+ };
+ }
+ if (!('addStream' in window.RTCPeerConnection.prototype)) {
+ var _addTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this = this;
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ if (!this._localStreams.includes(stream)) {
+ this._localStreams.push(stream);
+ }
+ // Try to emulate Chrome's behaviour of adding in audio-video order.
+ // Safari orders by track id.
+ stream.getAudioTracks().forEach(function (track) {
+ return _addTrack.call(_this, track, stream);
+ });
+ stream.getVideoTracks().forEach(function (track) {
+ return _addTrack.call(_this, track, stream);
+ });
+ };
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track) {
+ var _this2 = this;
+ for (var _len = arguments.length, streams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ streams[_key - 1] = arguments[_key];
+ }
+ if (streams) {
+ streams.forEach(function (stream) {
+ if (!_this2._localStreams) {
+ _this2._localStreams = [stream];
+ } else if (!_this2._localStreams.includes(stream)) {
+ _this2._localStreams.push(stream);
+ }
+ });
+ }
+ return _addTrack.apply(this, arguments);
+ };
+ }
+ if (!('removeStream' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ var _this3 = this;
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ var index = this._localStreams.indexOf(stream);
+ if (index === -1) {
+ return;
+ }
+ this._localStreams.splice(index, 1);
+ var tracks = stream.getTracks();
+ this.getSenders().forEach(function (sender) {
+ if (tracks.includes(sender.track)) {
+ _this3.removeTrack(sender);
+ }
+ });
+ };
+ }
+}
+function shimRemoteStreamsAPI(window) {
+ if (_typeof(window) !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ if (!('getRemoteStreams' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.getRemoteStreams = function getRemoteStreams() {
+ return this._remoteStreams ? this._remoteStreams : [];
+ };
+ }
+ if (!('onaddstream' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'onaddstream', {
+ get: function get() {
+ return this._onaddstream;
+ },
+ set: function set(f) {
+ var _this4 = this;
+ if (this._onaddstream) {
+ this.removeEventListener('addstream', this._onaddstream);
+ this.removeEventListener('track', this._onaddstreampoly);
+ }
+ this.addEventListener('addstream', this._onaddstream = f);
+ this.addEventListener('track', this._onaddstreampoly = function (e) {
+ e.streams.forEach(function (stream) {
+ if (!_this4._remoteStreams) {
+ _this4._remoteStreams = [];
+ }
+ if (_this4._remoteStreams.includes(stream)) {
+ return;
+ }
+ _this4._remoteStreams.push(stream);
+ var event = new Event('addstream');
+ event.stream = stream;
+ _this4.dispatchEvent(event);
+ });
+ });
+ }
+ });
+ var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
+ var pc = this;
+ if (!this._onaddstreampoly) {
+ this.addEventListener('track', this._onaddstreampoly = function (e) {
+ e.streams.forEach(function (stream) {
+ if (!pc._remoteStreams) {
+ pc._remoteStreams = [];
+ }
+ if (pc._remoteStreams.indexOf(stream) >= 0) {
+ return;
+ }
+ pc._remoteStreams.push(stream);
+ var event = new Event('addstream');
+ event.stream = stream;
+ pc.dispatchEvent(event);
+ });
+ });
+ }
+ return origSetRemoteDescription.apply(pc, arguments);
+ };
+ }
+}
+function shimCallbacksAPI(window) {
+ if (_typeof(window) !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ var prototype = window.RTCPeerConnection.prototype;
+ var origCreateOffer = prototype.createOffer;
+ var origCreateAnswer = prototype.createAnswer;
+ var setLocalDescription = prototype.setLocalDescription;
+ var setRemoteDescription = prototype.setRemoteDescription;
+ var addIceCandidate = prototype.addIceCandidate;
+ prototype.createOffer = function createOffer(successCallback, failureCallback) {
+ var options = arguments.length >= 2 ? arguments[2] : arguments[0];
+ var promise = origCreateOffer.apply(this, [options]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.createAnswer = function createAnswer(successCallback, failureCallback) {
+ var options = arguments.length >= 2 ? arguments[2] : arguments[0];
+ var promise = origCreateAnswer.apply(this, [options]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ var withCallback = function withCallback(description, successCallback, failureCallback) {
+ var promise = setLocalDescription.apply(this, [description]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.setLocalDescription = withCallback;
+ withCallback = function withCallback(description, successCallback, failureCallback) {
+ var promise = setRemoteDescription.apply(this, [description]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.setRemoteDescription = withCallback;
+ withCallback = function withCallback(candidate, successCallback, failureCallback) {
+ var promise = addIceCandidate.apply(this, [candidate]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.addIceCandidate = withCallback;
+}
+function shimGetUserMedia(window) {
+ var navigator = window && window.navigator;
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
+ // shim not needed in Safari 12.1
+ var mediaDevices = navigator.mediaDevices;
+ var _getUserMedia = mediaDevices.getUserMedia.bind(mediaDevices);
+ navigator.mediaDevices.getUserMedia = function (constraints) {
+ return _getUserMedia(shimConstraints(constraints));
+ };
+ }
+ if (!navigator.getUserMedia && navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
+ navigator.getUserMedia = function getUserMedia(constraints, cb, errcb) {
+ navigator.mediaDevices.getUserMedia(constraints).then(cb, errcb);
+ }.bind(navigator);
+ }
+}
+function shimConstraints(constraints) {
+ if (constraints && constraints.video !== undefined) {
+ return Object.assign({}, constraints, {
+ video: utils.compactObject(constraints.video)
+ });
+ }
+ return constraints;
+}
+function shimRTCIceServerUrls(window) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ // migrate from non-spec RTCIceServer.url to RTCIceServer.urls
+ var OrigPeerConnection = window.RTCPeerConnection;
+ window.RTCPeerConnection = function RTCPeerConnection(pcConfig, pcConstraints) {
+ if (pcConfig && pcConfig.iceServers) {
+ var newIceServers = [];
+ for (var i = 0; i < pcConfig.iceServers.length; i++) {
+ var server = pcConfig.iceServers[i];
+ if (server.urls === undefined && server.url) {
+ utils.deprecated('RTCIceServer.url', 'RTCIceServer.urls');
+ server = JSON.parse(JSON.stringify(server));
+ server.urls = server.url;
+ delete server.url;
+ newIceServers.push(server);
+ } else {
+ newIceServers.push(pcConfig.iceServers[i]);
+ }
+ }
+ pcConfig.iceServers = newIceServers;
+ }
+ return new OrigPeerConnection(pcConfig, pcConstraints);
+ };
+ window.RTCPeerConnection.prototype = OrigPeerConnection.prototype;
+ // wrap static methods. Currently just generateCertificate.
+ if ('generateCertificate' in OrigPeerConnection) {
+ Object.defineProperty(window.RTCPeerConnection, 'generateCertificate', {
+ get: function get() {
+ return OrigPeerConnection.generateCertificate;
+ }
+ });
+ }
+}
+function shimTrackEventTransceiver(window) {
+ // Add event.transceiver member over deprecated event.receiver
+ if (_typeof(window) === 'object' && window.RTCTrackEvent && 'receiver' in window.RTCTrackEvent.prototype && !('transceiver' in window.RTCTrackEvent.prototype)) {
+ Object.defineProperty(window.RTCTrackEvent.prototype, 'transceiver', {
+ get: function get() {
+ return {
+ receiver: this.receiver
+ };
+ }
+ });
+ }
+}
+function shimCreateOfferLegacy(window) {
+ var origCreateOffer = window.RTCPeerConnection.prototype.createOffer;
+ window.RTCPeerConnection.prototype.createOffer = function createOffer(offerOptions) {
+ if (offerOptions) {
+ if (typeof offerOptions.offerToReceiveAudio !== 'undefined') {
+ // support bit values
+ offerOptions.offerToReceiveAudio = !!offerOptions.offerToReceiveAudio;
+ }
+ var audioTransceiver = this.getTransceivers().find(function (transceiver) {
+ return transceiver.receiver.track.kind === 'audio';
+ });
+ if (offerOptions.offerToReceiveAudio === false && audioTransceiver) {
+ if (audioTransceiver.direction === 'sendrecv') {
+ if (audioTransceiver.setDirection) {
+ audioTransceiver.setDirection('sendonly');
+ } else {
+ audioTransceiver.direction = 'sendonly';
+ }
+ } else if (audioTransceiver.direction === 'recvonly') {
+ if (audioTransceiver.setDirection) {
+ audioTransceiver.setDirection('inactive');
+ } else {
+ audioTransceiver.direction = 'inactive';
+ }
+ }
+ } else if (offerOptions.offerToReceiveAudio === true && !audioTransceiver) {
+ this.addTransceiver('audio', {
+ direction: 'recvonly'
+ });
+ }
+ if (typeof offerOptions.offerToReceiveVideo !== 'undefined') {
+ // support bit values
+ offerOptions.offerToReceiveVideo = !!offerOptions.offerToReceiveVideo;
+ }
+ var videoTransceiver = this.getTransceivers().find(function (transceiver) {
+ return transceiver.receiver.track.kind === 'video';
+ });
+ if (offerOptions.offerToReceiveVideo === false && videoTransceiver) {
+ if (videoTransceiver.direction === 'sendrecv') {
+ if (videoTransceiver.setDirection) {
+ videoTransceiver.setDirection('sendonly');
+ } else {
+ videoTransceiver.direction = 'sendonly';
+ }
+ } else if (videoTransceiver.direction === 'recvonly') {
+ if (videoTransceiver.setDirection) {
+ videoTransceiver.setDirection('inactive');
+ } else {
+ videoTransceiver.direction = 'inactive';
+ }
+ }
+ } else if (offerOptions.offerToReceiveVideo === true && !videoTransceiver) {
+ this.addTransceiver('video', {
+ direction: 'recvonly'
+ });
+ }
+ }
+ return origCreateOffer.apply(this, arguments);
+ };
+}
+function shimAudioContext(window) {
+ if (_typeof(window) !== 'object' || window.AudioContext) {
+ return;
+ }
+ window.AudioContext = window.webkitAudioContext;
+}
diff --git a/node_modules/webrtc-adapter/dist/utils.js b/node_modules/webrtc-adapter/dist/utils.js
new file mode 100644
index 0000000..578a34d
--- /dev/null
+++ b/node_modules/webrtc-adapter/dist/utils.js
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.compactObject = compactObject;
+exports.deprecated = deprecated;
+exports.detectBrowser = detectBrowser;
+exports.disableLog = disableLog;
+exports.disableWarnings = disableWarnings;
+exports.extractVersion = extractVersion;
+exports.filterStats = filterStats;
+exports.log = log;
+exports.walkStats = walkStats;
+exports.wrapPeerConnectionEvent = wrapPeerConnectionEvent;
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+var logDisabled_ = true;
+var deprecationWarnings_ = true;
+
+/**
+ * Extract browser version out of the provided user agent string.
+ *
+ * @param {!string} uastring userAgent string.
+ * @param {!string} expr Regular expression used as match criteria.
+ * @param {!number} pos position in the version string to be returned.
+ * @return {!number} browser version.
+ */
+function extractVersion(uastring, expr, pos) {
+ var match = uastring.match(expr);
+ return match && match.length >= pos && parseInt(match[pos], 10);
+}
+
+// Wraps the peerconnection event eventNameToWrap in a function
+// which returns the modified event object (or false to prevent
+// the event).
+function wrapPeerConnectionEvent(window, eventNameToWrap, wrapper) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ var proto = window.RTCPeerConnection.prototype;
+ var nativeAddEventListener = proto.addEventListener;
+ proto.addEventListener = function (nativeEventName, cb) {
+ if (nativeEventName !== eventNameToWrap) {
+ return nativeAddEventListener.apply(this, arguments);
+ }
+ var wrappedCallback = function wrappedCallback(e) {
+ var modifiedEvent = wrapper(e);
+ if (modifiedEvent) {
+ if (cb.handleEvent) {
+ cb.handleEvent(modifiedEvent);
+ } else {
+ cb(modifiedEvent);
+ }
+ }
+ };
+ this._eventMap = this._eventMap || {};
+ if (!this._eventMap[eventNameToWrap]) {
+ this._eventMap[eventNameToWrap] = new Map();
+ }
+ this._eventMap[eventNameToWrap].set(cb, wrappedCallback);
+ return nativeAddEventListener.apply(this, [nativeEventName, wrappedCallback]);
+ };
+ var nativeRemoveEventListener = proto.removeEventListener;
+ proto.removeEventListener = function (nativeEventName, cb) {
+ if (nativeEventName !== eventNameToWrap || !this._eventMap || !this._eventMap[eventNameToWrap]) {
+ return nativeRemoveEventListener.apply(this, arguments);
+ }
+ if (!this._eventMap[eventNameToWrap].has(cb)) {
+ return nativeRemoveEventListener.apply(this, arguments);
+ }
+ var unwrappedCb = this._eventMap[eventNameToWrap].get(cb);
+ this._eventMap[eventNameToWrap]["delete"](cb);
+ if (this._eventMap[eventNameToWrap].size === 0) {
+ delete this._eventMap[eventNameToWrap];
+ }
+ if (Object.keys(this._eventMap).length === 0) {
+ delete this._eventMap;
+ }
+ return nativeRemoveEventListener.apply(this, [nativeEventName, unwrappedCb]);
+ };
+ Object.defineProperty(proto, 'on' + eventNameToWrap, {
+ get: function get() {
+ return this['_on' + eventNameToWrap];
+ },
+ set: function set(cb) {
+ if (this['_on' + eventNameToWrap]) {
+ this.removeEventListener(eventNameToWrap, this['_on' + eventNameToWrap]);
+ delete this['_on' + eventNameToWrap];
+ }
+ if (cb) {
+ this.addEventListener(eventNameToWrap, this['_on' + eventNameToWrap] = cb);
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+}
+function disableLog(bool) {
+ if (typeof bool !== 'boolean') {
+ return new Error('Argument type: ' + _typeof(bool) + '. Please use a boolean.');
+ }
+ logDisabled_ = bool;
+ return bool ? 'adapter.js logging disabled' : 'adapter.js logging enabled';
+}
+
+/**
+ * Disable or enable deprecation warnings
+ * @param {!boolean} bool set to true to disable warnings.
+ */
+function disableWarnings(bool) {
+ if (typeof bool !== 'boolean') {
+ return new Error('Argument type: ' + _typeof(bool) + '. Please use a boolean.');
+ }
+ deprecationWarnings_ = !bool;
+ return 'adapter.js deprecation warnings ' + (bool ? 'disabled' : 'enabled');
+}
+function log() {
+ if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object') {
+ if (logDisabled_) {
+ return;
+ }
+ if (typeof console !== 'undefined' && typeof console.log === 'function') {
+ console.log.apply(console, arguments);
+ }
+ }
+}
+
+/**
+ * Shows a deprecation warning suggesting the modern and spec-compatible API.
+ */
+function deprecated(oldMethod, newMethod) {
+ if (!deprecationWarnings_) {
+ return;
+ }
+ console.warn(oldMethod + ' is deprecated, please use ' + newMethod + ' instead.');
+}
+
+/**
+ * Browser detector.
+ *
+ * @return {object} result containing browser and version
+ * properties.
+ */
+function detectBrowser(window) {
+ // Returned result object.
+ var result = {
+ browser: null,
+ version: null
+ };
+
+ // Fail early if it's not a browser
+ if (typeof window === 'undefined' || !window.navigator || !window.navigator.userAgent) {
+ result.browser = 'Not a browser.';
+ return result;
+ }
+ var navigator = window.navigator;
+ if (navigator.mozGetUserMedia) {
+ // Firefox.
+ result.browser = 'firefox';
+ result.version = extractVersion(navigator.userAgent, /Firefox\/(\d+)\./, 1);
+ } else if (navigator.webkitGetUserMedia || window.isSecureContext === false && window.webkitRTCPeerConnection) {
+ // Chrome, Chromium, Webview, Opera.
+ // Version matches Chrome/WebRTC version.
+ // Chrome 74 removed webkitGetUserMedia on http as well so we need the
+ // more complicated fallback to webkitRTCPeerConnection.
+ result.browser = 'chrome';
+ result.version = extractVersion(navigator.userAgent, /Chrom(e|ium)\/(\d+)\./, 2);
+ } else if (window.RTCPeerConnection && navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) {
+ // Safari.
+ result.browser = 'safari';
+ result.version = extractVersion(navigator.userAgent, /AppleWebKit\/(\d+)\./, 1);
+ result.supportsUnifiedPlan = window.RTCRtpTransceiver && 'currentDirection' in window.RTCRtpTransceiver.prototype;
+ } else {
+ // Default fallthrough: not supported.
+ result.browser = 'Not a supported browser.';
+ return result;
+ }
+ return result;
+}
+
+/**
+ * Checks if something is an object.
+ *
+ * @param {*} val The something you want to check.
+ * @return true if val is an object, false otherwise.
+ */
+function isObject(val) {
+ return Object.prototype.toString.call(val) === '[object Object]';
+}
+
+/**
+ * Remove all empty objects and undefined values
+ * from a nested object -- an enhanced and vanilla version
+ * of Lodash's `compact`.
+ */
+function compactObject(data) {
+ if (!isObject(data)) {
+ return data;
+ }
+ return Object.keys(data).reduce(function (accumulator, key) {
+ var isObj = isObject(data[key]);
+ var value = isObj ? compactObject(data[key]) : data[key];
+ var isEmptyObject = isObj && !Object.keys(value).length;
+ if (value === undefined || isEmptyObject) {
+ return accumulator;
+ }
+ return Object.assign(accumulator, _defineProperty({}, key, value));
+ }, {});
+}
+
+/* iterates the stats graph recursively. */
+function walkStats(stats, base, resultSet) {
+ if (!base || resultSet.has(base.id)) {
+ return;
+ }
+ resultSet.set(base.id, base);
+ Object.keys(base).forEach(function (name) {
+ if (name.endsWith('Id')) {
+ walkStats(stats, stats.get(base[name]), resultSet);
+ } else if (name.endsWith('Ids')) {
+ base[name].forEach(function (id) {
+ walkStats(stats, stats.get(id), resultSet);
+ });
+ }
+ });
+}
+
+/* filter getStats for a sender/receiver track. */
+function filterStats(result, track, outbound) {
+ var streamStatsType = outbound ? 'outbound-rtp' : 'inbound-rtp';
+ var filteredResult = new Map();
+ if (track === null) {
+ return filteredResult;
+ }
+ var trackStats = [];
+ result.forEach(function (value) {
+ if (value.type === 'track' && value.trackIdentifier === track.id) {
+ trackStats.push(value);
+ }
+ });
+ trackStats.forEach(function (trackStat) {
+ result.forEach(function (stats) {
+ if (stats.type === streamStatsType && stats.trackId === trackStat.id) {
+ walkStats(result, stats, filteredResult);
+ }
+ });
+ });
+ return filteredResult;
+}
diff --git a/node_modules/webrtc-adapter/index.d.ts b/node_modules/webrtc-adapter/index.d.ts
new file mode 100644
index 0000000..0fd704f
--- /dev/null
+++ b/node_modules/webrtc-adapter/index.d.ts
@@ -0,0 +1,59 @@
+declare module "webrtc-adapter" {
+ interface IBrowserDetails {
+ browser: string;
+ version?: number;
+ supportsUnifiedPlan?: boolean;
+ }
+
+ interface ICommonShim {
+ shimRTCIceCandidate(window: Window): void;
+ shimMaxMessageSize(window: Window): void;
+ shimSendThrowTypeError(window: Window): void;
+ shimConnectionState(window: Window): void;
+ removeAllowExtmapMixed(window: Window): void;
+ }
+
+ interface IChromeShim {
+ shimMediaStream(window: Window): void;
+ shimOnTrack(window: Window): void;
+ shimGetSendersWithDtmf(window: Window): void;
+ shimGetStats(window: Window): void;
+ shimSenderReceiverGetStats(window: Window): void;
+ shimAddTrackRemoveTrackWithNative(window: Window): void;
+ shimAddTrackRemoveTrack(window: Window): void;
+ shimPeerConnection(window: Window): void;
+ fixNegotiationNeeded(window: Window): void;
+ }
+
+ interface IFirefoxShim {
+ shimOnTrack(window: Window): void;
+ shimPeerConnection(window: Window): void;
+ shimSenderGetStats(window: Window): void;
+ shimReceiverGetStats(window: Window): void;
+ shimRemoveStream(window: Window): void;
+ shimRTCDataChannel(window: Window): void;
+ }
+
+ interface ISafariShim {
+ shimLocalStreamsAPI(window: Window): void;
+ shimRemoteStreamsAPI(window: Window): void;
+ shimCallbacksAPI(window: Window): void;
+ shimGetUserMedia(window: Window): void;
+ shimConstraints(constraints: MediaStreamConstraints): void;
+ shimRTCIceServerUrls(window: Window): void;
+ shimTrackEventTransceiver(window: Window): void;
+ shimCreateOfferLegacy(window: Window): void;
+ }
+
+ export interface IAdapter {
+ browserDetails: IBrowserDetails;
+ commonShim: ICommonShim;
+ browserShim: IChromeShim | IFirefoxShim | ISafariShim | undefined;
+ extractVersion(uastring: string, expr: string, pos: number): number;
+ disableLog(disable: boolean): void;
+ disableWarnings(disable: boolean): void;
+ }
+
+ const adapter: IAdapter;
+ export default adapter;
+}
diff --git a/node_modules/webrtc-adapter/out/adapter.js b/node_modules/webrtc-adapter/out/adapter.js
new file mode 100644
index 0000000..ce2d6a8
--- /dev/null
+++ b/node_modules/webrtc-adapter/out/adapter.js
@@ -0,0 +1,3364 @@
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.adapter = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0 && arguments[0] !== undefined ? arguments[0] : {},
+ window = _ref.window;
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
+ shimChrome: true,
+ shimFirefox: true,
+ shimSafari: true
+ };
+ // Utils.
+ var logging = utils.log;
+ var browserDetails = utils.detectBrowser(window);
+ var adapter = {
+ browserDetails: browserDetails,
+ commonShim: commonShim,
+ extractVersion: utils.extractVersion,
+ disableLog: utils.disableLog,
+ disableWarnings: utils.disableWarnings,
+ // Expose sdp as a convenience. For production apps include directly.
+ sdp: sdp
+ };
+
+ // Shim browser if found.
+ switch (browserDetails.browser) {
+ case 'chrome':
+ if (!chromeShim || !chromeShim.shimPeerConnection || !options.shimChrome) {
+ logging('Chrome shim is not included in this adapter release.');
+ return adapter;
+ }
+ if (browserDetails.version === null) {
+ logging('Chrome shim can not determine version, not shimming.');
+ return adapter;
+ }
+ logging('adapter.js shimming chrome.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = chromeShim;
+
+ // Must be called before shimPeerConnection.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+ chromeShim.shimGetUserMedia(window, browserDetails);
+ chromeShim.shimMediaStream(window, browserDetails);
+ chromeShim.shimPeerConnection(window, browserDetails);
+ chromeShim.shimOnTrack(window, browserDetails);
+ chromeShim.shimAddTrackRemoveTrack(window, browserDetails);
+ chromeShim.shimGetSendersWithDtmf(window, browserDetails);
+ chromeShim.shimGetStats(window, browserDetails);
+ chromeShim.shimSenderReceiverGetStats(window, browserDetails);
+ chromeShim.fixNegotiationNeeded(window, browserDetails);
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
+ commonShim.shimConnectionState(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ commonShim.removeExtmapAllowMixed(window, browserDetails);
+ break;
+ case 'firefox':
+ if (!firefoxShim || !firefoxShim.shimPeerConnection || !options.shimFirefox) {
+ logging('Firefox shim is not included in this adapter release.');
+ return adapter;
+ }
+ logging('adapter.js shimming firefox.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = firefoxShim;
+
+ // Must be called before shimPeerConnection.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+ firefoxShim.shimGetUserMedia(window, browserDetails);
+ firefoxShim.shimPeerConnection(window, browserDetails);
+ firefoxShim.shimOnTrack(window, browserDetails);
+ firefoxShim.shimRemoveStream(window, browserDetails);
+ firefoxShim.shimSenderGetStats(window, browserDetails);
+ firefoxShim.shimReceiverGetStats(window, browserDetails);
+ firefoxShim.shimRTCDataChannel(window, browserDetails);
+ firefoxShim.shimAddTransceiver(window, browserDetails);
+ firefoxShim.shimGetParameters(window, browserDetails);
+ firefoxShim.shimCreateOffer(window, browserDetails);
+ firefoxShim.shimCreateAnswer(window, browserDetails);
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimConnectionState(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ break;
+ case 'safari':
+ if (!safariShim || !options.shimSafari) {
+ logging('Safari shim is not included in this adapter release.');
+ return adapter;
+ }
+ logging('adapter.js shimming safari.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = safariShim;
+
+ // Must be called before shimCallbackAPI.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+ safariShim.shimRTCIceServerUrls(window, browserDetails);
+ safariShim.shimCreateOfferLegacy(window, browserDetails);
+ safariShim.shimCallbacksAPI(window, browserDetails);
+ safariShim.shimLocalStreamsAPI(window, browserDetails);
+ safariShim.shimRemoteStreamsAPI(window, browserDetails);
+ safariShim.shimTrackEventTransceiver(window, browserDetails);
+ safariShim.shimGetUserMedia(window, browserDetails);
+ safariShim.shimAudioContext(window, browserDetails);
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ commonShim.removeExtmapAllowMixed(window, browserDetails);
+ break;
+ default:
+ logging('Unsupported browser!');
+ break;
+ }
+ return adapter;
+}
+
+},{"./chrome/chrome_shim":3,"./common_shim":6,"./firefox/firefox_shim":7,"./safari/safari_shim":10,"./utils":11,"sdp":12}],3:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.fixNegotiationNeeded = fixNegotiationNeeded;
+exports.shimAddTrackRemoveTrack = shimAddTrackRemoveTrack;
+exports.shimAddTrackRemoveTrackWithNative = shimAddTrackRemoveTrackWithNative;
+Object.defineProperty(exports, "shimGetDisplayMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getdisplaymedia.shimGetDisplayMedia;
+ }
+});
+exports.shimGetSendersWithDtmf = shimGetSendersWithDtmf;
+exports.shimGetStats = shimGetStats;
+Object.defineProperty(exports, "shimGetUserMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getusermedia.shimGetUserMedia;
+ }
+});
+exports.shimMediaStream = shimMediaStream;
+exports.shimOnTrack = shimOnTrack;
+exports.shimPeerConnection = shimPeerConnection;
+exports.shimSenderReceiverGetStats = shimSenderReceiverGetStats;
+var utils = _interopRequireWildcard(require("../utils.js"));
+var _getusermedia = require("./getusermedia");
+var _getdisplaymedia = require("./getdisplaymedia");
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimMediaStream(window) {
+ window.MediaStream = window.MediaStream || window.webkitMediaStream;
+}
+function shimOnTrack(window) {
+ if (_typeof(window) === 'object' && window.RTCPeerConnection && !('ontrack' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'ontrack', {
+ get: function get() {
+ return this._ontrack;
+ },
+ set: function set(f) {
+ if (this._ontrack) {
+ this.removeEventListener('track', this._ontrack);
+ }
+ this.addEventListener('track', this._ontrack = f);
+ },
+ enumerable: true,
+ configurable: true
+ });
+ var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
+ var _this = this;
+ if (!this._ontrackpoly) {
+ this._ontrackpoly = function (e) {
+ // onaddstream does not fire when a track is added to an existing
+ // stream. But stream.onaddtrack is implemented so we use that.
+ e.stream.addEventListener('addtrack', function (te) {
+ var receiver;
+ if (window.RTCPeerConnection.prototype.getReceivers) {
+ receiver = _this.getReceivers().find(function (r) {
+ return r.track && r.track.id === te.track.id;
+ });
+ } else {
+ receiver = {
+ track: te.track
+ };
+ }
+ var event = new Event('track');
+ event.track = te.track;
+ event.receiver = receiver;
+ event.transceiver = {
+ receiver: receiver
+ };
+ event.streams = [e.stream];
+ _this.dispatchEvent(event);
+ });
+ e.stream.getTracks().forEach(function (track) {
+ var receiver;
+ if (window.RTCPeerConnection.prototype.getReceivers) {
+ receiver = _this.getReceivers().find(function (r) {
+ return r.track && r.track.id === track.id;
+ });
+ } else {
+ receiver = {
+ track: track
+ };
+ }
+ var event = new Event('track');
+ event.track = track;
+ event.receiver = receiver;
+ event.transceiver = {
+ receiver: receiver
+ };
+ event.streams = [e.stream];
+ _this.dispatchEvent(event);
+ });
+ };
+ this.addEventListener('addstream', this._ontrackpoly);
+ }
+ return origSetRemoteDescription.apply(this, arguments);
+ };
+ } else {
+ // even if RTCRtpTransceiver is in window, it is only used and
+ // emitted in unified-plan. Unfortunately this means we need
+ // to unconditionally wrap the event.
+ utils.wrapPeerConnectionEvent(window, 'track', function (e) {
+ if (!e.transceiver) {
+ Object.defineProperty(e, 'transceiver', {
+ value: {
+ receiver: e.receiver
+ }
+ });
+ }
+ return e;
+ });
+ }
+}
+function shimGetSendersWithDtmf(window) {
+ // Overrides addTrack/removeTrack, depends on shimAddTrackRemoveTrack.
+ if (_typeof(window) === 'object' && window.RTCPeerConnection && !('getSenders' in window.RTCPeerConnection.prototype) && 'createDTMFSender' in window.RTCPeerConnection.prototype) {
+ var shimSenderWithDtmf = function shimSenderWithDtmf(pc, track) {
+ return {
+ track: track,
+ get dtmf() {
+ if (this._dtmf === undefined) {
+ if (track.kind === 'audio') {
+ this._dtmf = pc.createDTMFSender(track);
+ } else {
+ this._dtmf = null;
+ }
+ }
+ return this._dtmf;
+ },
+ _pc: pc
+ };
+ };
+
+ // augment addTrack when getSenders is not available.
+ if (!window.RTCPeerConnection.prototype.getSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ this._senders = this._senders || [];
+ return this._senders.slice(); // return a copy of the internal state.
+ };
+
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
+ var sender = origAddTrack.apply(this, arguments);
+ if (!sender) {
+ sender = shimSenderWithDtmf(this, track);
+ this._senders.push(sender);
+ }
+ return sender;
+ };
+ var origRemoveTrack = window.RTCPeerConnection.prototype.removeTrack;
+ window.RTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
+ origRemoveTrack.apply(this, arguments);
+ var idx = this._senders.indexOf(sender);
+ if (idx !== -1) {
+ this._senders.splice(idx, 1);
+ }
+ };
+ }
+ var origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this2 = this;
+ this._senders = this._senders || [];
+ origAddStream.apply(this, [stream]);
+ stream.getTracks().forEach(function (track) {
+ _this2._senders.push(shimSenderWithDtmf(_this2, track));
+ });
+ };
+ var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ var _this3 = this;
+ this._senders = this._senders || [];
+ origRemoveStream.apply(this, [stream]);
+ stream.getTracks().forEach(function (track) {
+ var sender = _this3._senders.find(function (s) {
+ return s.track === track;
+ });
+ if (sender) {
+ // remove sender
+ _this3._senders.splice(_this3._senders.indexOf(sender), 1);
+ }
+ });
+ };
+ } else if (_typeof(window) === 'object' && window.RTCPeerConnection && 'getSenders' in window.RTCPeerConnection.prototype && 'createDTMFSender' in window.RTCPeerConnection.prototype && window.RTCRtpSender && !('dtmf' in window.RTCRtpSender.prototype)) {
+ var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ var _this4 = this;
+ var senders = origGetSenders.apply(this, []);
+ senders.forEach(function (sender) {
+ return sender._pc = _this4;
+ });
+ return senders;
+ };
+ Object.defineProperty(window.RTCRtpSender.prototype, 'dtmf', {
+ get: function get() {
+ if (this._dtmf === undefined) {
+ if (this.track.kind === 'audio') {
+ this._dtmf = this._pc.createDTMFSender(this.track);
+ } else {
+ this._dtmf = null;
+ }
+ }
+ return this._dtmf;
+ }
+ });
+ }
+}
+function shimGetStats(window) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ var origGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ var _this5 = this;
+ var _arguments = Array.prototype.slice.call(arguments),
+ selector = _arguments[0],
+ onSucc = _arguments[1],
+ onErr = _arguments[2];
+
+ // If selector is a function then we are in the old style stats so just
+ // pass back the original getStats format to avoid breaking old users.
+ if (arguments.length > 0 && typeof selector === 'function') {
+ return origGetStats.apply(this, arguments);
+ }
+
+ // When spec-style getStats is supported, return those when called with
+ // either no arguments or the selector argument is null.
+ if (origGetStats.length === 0 && (arguments.length === 0 || typeof selector !== 'function')) {
+ return origGetStats.apply(this, []);
+ }
+ var fixChromeStats_ = function fixChromeStats_(response) {
+ var standardReport = {};
+ var reports = response.result();
+ reports.forEach(function (report) {
+ var standardStats = {
+ id: report.id,
+ timestamp: report.timestamp,
+ type: {
+ localcandidate: 'local-candidate',
+ remotecandidate: 'remote-candidate'
+ }[report.type] || report.type
+ };
+ report.names().forEach(function (name) {
+ standardStats[name] = report.stat(name);
+ });
+ standardReport[standardStats.id] = standardStats;
+ });
+ return standardReport;
+ };
+
+ // shim getStats with maplike support
+ var makeMapStats = function makeMapStats(stats) {
+ return new Map(Object.keys(stats).map(function (key) {
+ return [key, stats[key]];
+ }));
+ };
+ if (arguments.length >= 2) {
+ var successCallbackWrapper_ = function successCallbackWrapper_(response) {
+ onSucc(makeMapStats(fixChromeStats_(response)));
+ };
+ return origGetStats.apply(this, [successCallbackWrapper_, selector]);
+ }
+
+ // promise-support
+ return new Promise(function (resolve, reject) {
+ origGetStats.apply(_this5, [function (response) {
+ resolve(makeMapStats(fixChromeStats_(response)));
+ }, reject]);
+ }).then(onSucc, onErr);
+ };
+}
+function shimSenderReceiverGetStats(window) {
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection && window.RTCRtpSender && window.RTCRtpReceiver)) {
+ return;
+ }
+
+ // shim sender stats.
+ if (!('getStats' in window.RTCRtpSender.prototype)) {
+ var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ if (origGetSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ var _this6 = this;
+ var senders = origGetSenders.apply(this, []);
+ senders.forEach(function (sender) {
+ return sender._pc = _this6;
+ });
+ return senders;
+ };
+ }
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ if (origAddTrack) {
+ window.RTCPeerConnection.prototype.addTrack = function addTrack() {
+ var sender = origAddTrack.apply(this, arguments);
+ sender._pc = this;
+ return sender;
+ };
+ }
+ window.RTCRtpSender.prototype.getStats = function getStats() {
+ var sender = this;
+ return this._pc.getStats().then(function (result) {
+ return (
+ /* Note: this will include stats of all senders that
+ * send a track with the same id as sender.track as
+ * it is not possible to identify the RTCRtpSender.
+ */
+ utils.filterStats(result, sender.track, true)
+ );
+ });
+ };
+ }
+
+ // shim receiver stats.
+ if (!('getStats' in window.RTCRtpReceiver.prototype)) {
+ var origGetReceivers = window.RTCPeerConnection.prototype.getReceivers;
+ if (origGetReceivers) {
+ window.RTCPeerConnection.prototype.getReceivers = function getReceivers() {
+ var _this7 = this;
+ var receivers = origGetReceivers.apply(this, []);
+ receivers.forEach(function (receiver) {
+ return receiver._pc = _this7;
+ });
+ return receivers;
+ };
+ }
+ utils.wrapPeerConnectionEvent(window, 'track', function (e) {
+ e.receiver._pc = e.srcElement;
+ return e;
+ });
+ window.RTCRtpReceiver.prototype.getStats = function getStats() {
+ var receiver = this;
+ return this._pc.getStats().then(function (result) {
+ return utils.filterStats(result, receiver.track, false);
+ });
+ };
+ }
+ if (!('getStats' in window.RTCRtpSender.prototype && 'getStats' in window.RTCRtpReceiver.prototype)) {
+ return;
+ }
+
+ // shim RTCPeerConnection.getStats(track).
+ var origGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ if (arguments.length > 0 && arguments[0] instanceof window.MediaStreamTrack) {
+ var track = arguments[0];
+ var sender;
+ var receiver;
+ var err;
+ this.getSenders().forEach(function (s) {
+ if (s.track === track) {
+ if (sender) {
+ err = true;
+ } else {
+ sender = s;
+ }
+ }
+ });
+ this.getReceivers().forEach(function (r) {
+ if (r.track === track) {
+ if (receiver) {
+ err = true;
+ } else {
+ receiver = r;
+ }
+ }
+ return r.track === track;
+ });
+ if (err || sender && receiver) {
+ return Promise.reject(new DOMException('There are more than one sender or receiver for the track.', 'InvalidAccessError'));
+ } else if (sender) {
+ return sender.getStats();
+ } else if (receiver) {
+ return receiver.getStats();
+ }
+ return Promise.reject(new DOMException('There is no sender or receiver for the track.', 'InvalidAccessError'));
+ }
+ return origGetStats.apply(this, arguments);
+ };
+}
+function shimAddTrackRemoveTrackWithNative(window) {
+ // shim addTrack/removeTrack with native variants in order to make
+ // the interactions with legacy getLocalStreams behave as in other browsers.
+ // Keeps a mapping stream.id => [stream, rtpsenders...]
+ window.RTCPeerConnection.prototype.getLocalStreams = function getLocalStreams() {
+ var _this8 = this;
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ return Object.keys(this._shimmedLocalStreams).map(function (streamId) {
+ return _this8._shimmedLocalStreams[streamId][0];
+ });
+ };
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
+ if (!stream) {
+ return origAddTrack.apply(this, arguments);
+ }
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ var sender = origAddTrack.apply(this, arguments);
+ if (!this._shimmedLocalStreams[stream.id]) {
+ this._shimmedLocalStreams[stream.id] = [stream, sender];
+ } else if (this._shimmedLocalStreams[stream.id].indexOf(sender) === -1) {
+ this._shimmedLocalStreams[stream.id].push(sender);
+ }
+ return sender;
+ };
+ var origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this9 = this;
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ stream.getTracks().forEach(function (track) {
+ var alreadyExists = _this9.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.', 'InvalidAccessError');
+ }
+ });
+ var existingSenders = this.getSenders();
+ origAddStream.apply(this, arguments);
+ var newSenders = this.getSenders().filter(function (newSender) {
+ return existingSenders.indexOf(newSender) === -1;
+ });
+ this._shimmedLocalStreams[stream.id] = [stream].concat(newSenders);
+ };
+ var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ delete this._shimmedLocalStreams[stream.id];
+ return origRemoveStream.apply(this, arguments);
+ };
+ var origRemoveTrack = window.RTCPeerConnection.prototype.removeTrack;
+ window.RTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
+ var _this10 = this;
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ if (sender) {
+ Object.keys(this._shimmedLocalStreams).forEach(function (streamId) {
+ var idx = _this10._shimmedLocalStreams[streamId].indexOf(sender);
+ if (idx !== -1) {
+ _this10._shimmedLocalStreams[streamId].splice(idx, 1);
+ }
+ if (_this10._shimmedLocalStreams[streamId].length === 1) {
+ delete _this10._shimmedLocalStreams[streamId];
+ }
+ });
+ }
+ return origRemoveTrack.apply(this, arguments);
+ };
+}
+function shimAddTrackRemoveTrack(window, browserDetails) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ // shim addTrack and removeTrack.
+ if (window.RTCPeerConnection.prototype.addTrack && browserDetails.version >= 65) {
+ return shimAddTrackRemoveTrackWithNative(window);
+ }
+
+ // also shim pc.getLocalStreams when addTrack is shimmed
+ // to return the original streams.
+ var origGetLocalStreams = window.RTCPeerConnection.prototype.getLocalStreams;
+ window.RTCPeerConnection.prototype.getLocalStreams = function getLocalStreams() {
+ var _this11 = this;
+ var nativeStreams = origGetLocalStreams.apply(this);
+ this._reverseStreams = this._reverseStreams || {};
+ return nativeStreams.map(function (stream) {
+ return _this11._reverseStreams[stream.id];
+ });
+ };
+ var origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this12 = this;
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ stream.getTracks().forEach(function (track) {
+ var alreadyExists = _this12.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.', 'InvalidAccessError');
+ }
+ });
+ // Add identity mapping for consistency with addTrack.
+ // Unless this is being used with a stream from addTrack.
+ if (!this._reverseStreams[stream.id]) {
+ var newStream = new window.MediaStream(stream.getTracks());
+ this._streams[stream.id] = newStream;
+ this._reverseStreams[newStream.id] = stream;
+ stream = newStream;
+ }
+ origAddStream.apply(this, [stream]);
+ };
+ var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ origRemoveStream.apply(this, [this._streams[stream.id] || stream]);
+ delete this._reverseStreams[this._streams[stream.id] ? this._streams[stream.id].id : stream.id];
+ delete this._streams[stream.id];
+ };
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
+ var _this13 = this;
+ if (this.signalingState === 'closed') {
+ throw new DOMException('The RTCPeerConnection\'s signalingState is \'closed\'.', 'InvalidStateError');
+ }
+ var streams = [].slice.call(arguments, 1);
+ if (streams.length !== 1 || !streams[0].getTracks().find(function (t) {
+ return t === track;
+ })) {
+ // this is not fully correct but all we can manage without
+ // [[associated MediaStreams]] internal slot.
+ throw new DOMException('The adapter.js addTrack polyfill only supports a single ' + ' stream which is associated with the specified track.', 'NotSupportedError');
+ }
+ var alreadyExists = this.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.', 'InvalidAccessError');
+ }
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ var oldStream = this._streams[stream.id];
+ if (oldStream) {
+ // this is using odd Chrome behaviour, use with caution:
+ // https://bugs.chromium.org/p/webrtc/issues/detail?id=7815
+ // Note: we rely on the high-level addTrack/dtmf shim to
+ // create the sender with a dtmf sender.
+ oldStream.addTrack(track);
+
+ // Trigger ONN async.
+ Promise.resolve().then(function () {
+ _this13.dispatchEvent(new Event('negotiationneeded'));
+ });
+ } else {
+ var newStream = new window.MediaStream([track]);
+ this._streams[stream.id] = newStream;
+ this._reverseStreams[newStream.id] = stream;
+ this.addStream(newStream);
+ }
+ return this.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ };
+
+ // replace the internal stream id with the external one and
+ // vice versa.
+ function replaceInternalStreamId(pc, description) {
+ var sdp = description.sdp;
+ Object.keys(pc._reverseStreams || []).forEach(function (internalId) {
+ var externalStream = pc._reverseStreams[internalId];
+ var internalStream = pc._streams[externalStream.id];
+ sdp = sdp.replace(new RegExp(internalStream.id, 'g'), externalStream.id);
+ });
+ return new RTCSessionDescription({
+ type: description.type,
+ sdp: sdp
+ });
+ }
+ function replaceExternalStreamId(pc, description) {
+ var sdp = description.sdp;
+ Object.keys(pc._reverseStreams || []).forEach(function (internalId) {
+ var externalStream = pc._reverseStreams[internalId];
+ var internalStream = pc._streams[externalStream.id];
+ sdp = sdp.replace(new RegExp(externalStream.id, 'g'), internalStream.id);
+ });
+ return new RTCSessionDescription({
+ type: description.type,
+ sdp: sdp
+ });
+ }
+ ['createOffer', 'createAnswer'].forEach(function (method) {
+ var nativeMethod = window.RTCPeerConnection.prototype[method];
+ var methodObj = _defineProperty({}, method, function () {
+ var _this14 = this;
+ var args = arguments;
+ var isLegacyCall = arguments.length && typeof arguments[0] === 'function';
+ if (isLegacyCall) {
+ return nativeMethod.apply(this, [function (description) {
+ var desc = replaceInternalStreamId(_this14, description);
+ args[0].apply(null, [desc]);
+ }, function (err) {
+ if (args[1]) {
+ args[1].apply(null, err);
+ }
+ }, arguments[2]]);
+ }
+ return nativeMethod.apply(this, arguments).then(function (description) {
+ return replaceInternalStreamId(_this14, description);
+ });
+ });
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ var origSetLocalDescription = window.RTCPeerConnection.prototype.setLocalDescription;
+ window.RTCPeerConnection.prototype.setLocalDescription = function setLocalDescription() {
+ if (!arguments.length || !arguments[0].type) {
+ return origSetLocalDescription.apply(this, arguments);
+ }
+ arguments[0] = replaceExternalStreamId(this, arguments[0]);
+ return origSetLocalDescription.apply(this, arguments);
+ };
+
+ // TODO: mangle getStats: https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamstats-streamidentifier
+
+ var origLocalDescription = Object.getOwnPropertyDescriptor(window.RTCPeerConnection.prototype, 'localDescription');
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'localDescription', {
+ get: function get() {
+ var description = origLocalDescription.get.apply(this);
+ if (description.type === '') {
+ return description;
+ }
+ return replaceInternalStreamId(this, description);
+ }
+ });
+ window.RTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
+ var _this15 = this;
+ if (this.signalingState === 'closed') {
+ throw new DOMException('The RTCPeerConnection\'s signalingState is \'closed\'.', 'InvalidStateError');
+ }
+ // We can not yet check for sender instanceof RTCRtpSender
+ // since we shim RTPSender. So we check if sender._pc is set.
+ if (!sender._pc) {
+ throw new DOMException('Argument 1 of RTCPeerConnection.removeTrack ' + 'does not implement interface RTCRtpSender.', 'TypeError');
+ }
+ var isLocal = sender._pc === this;
+ if (!isLocal) {
+ throw new DOMException('Sender was not created by this connection.', 'InvalidAccessError');
+ }
+
+ // Search for the native stream the senders track belongs to.
+ this._streams = this._streams || {};
+ var stream;
+ Object.keys(this._streams).forEach(function (streamid) {
+ var hasTrack = _this15._streams[streamid].getTracks().find(function (track) {
+ return sender.track === track;
+ });
+ if (hasTrack) {
+ stream = _this15._streams[streamid];
+ }
+ });
+ if (stream) {
+ if (stream.getTracks().length === 1) {
+ // if this is the last track of the stream, remove the stream. This
+ // takes care of any shimmed _senders.
+ this.removeStream(this._reverseStreams[stream.id]);
+ } else {
+ // relying on the same odd chrome behaviour as above.
+ stream.removeTrack(sender.track);
+ }
+ this.dispatchEvent(new Event('negotiationneeded'));
+ }
+ };
+}
+function shimPeerConnection(window, browserDetails) {
+ if (!window.RTCPeerConnection && window.webkitRTCPeerConnection) {
+ // very basic support for old versions.
+ window.RTCPeerConnection = window.webkitRTCPeerConnection;
+ }
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+
+ // shim implicit creation of RTCSessionDescription/RTCIceCandidate
+ if (browserDetails.version < 53) {
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
+ var nativeMethod = window.RTCPeerConnection.prototype[method];
+ var methodObj = _defineProperty({}, method, function () {
+ arguments[0] = new (method === 'addIceCandidate' ? window.RTCIceCandidate : window.RTCSessionDescription)(arguments[0]);
+ return nativeMethod.apply(this, arguments);
+ });
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ }
+}
+
+// Attempt to fix ONN in plan-b mode.
+function fixNegotiationNeeded(window, browserDetails) {
+ utils.wrapPeerConnectionEvent(window, 'negotiationneeded', function (e) {
+ var pc = e.target;
+ if (browserDetails.version < 72 || pc.getConfiguration && pc.getConfiguration().sdpSemantics === 'plan-b') {
+ if (pc.signalingState !== 'stable') {
+ return;
+ }
+ }
+ return e;
+ });
+}
+
+},{"../utils.js":11,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(require,module,exports){
+/*
+ * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetDisplayMedia = shimGetDisplayMedia;
+function shimGetDisplayMedia(window, getSourceId) {
+ if (window.navigator.mediaDevices && 'getDisplayMedia' in window.navigator.mediaDevices) {
+ return;
+ }
+ if (!window.navigator.mediaDevices) {
+ return;
+ }
+ // getSourceId is a function that returns a promise resolving with
+ // the sourceId of the screen/window/tab to be shared.
+ if (typeof getSourceId !== 'function') {
+ console.error('shimGetDisplayMedia: getSourceId argument is not ' + 'a function');
+ return;
+ }
+ window.navigator.mediaDevices.getDisplayMedia = function getDisplayMedia(constraints) {
+ return getSourceId(constraints).then(function (sourceId) {
+ var widthSpecified = constraints.video && constraints.video.width;
+ var heightSpecified = constraints.video && constraints.video.height;
+ var frameRateSpecified = constraints.video && constraints.video.frameRate;
+ constraints.video = {
+ mandatory: {
+ chromeMediaSource: 'desktop',
+ chromeMediaSourceId: sourceId,
+ maxFrameRate: frameRateSpecified || 3
+ }
+ };
+ if (widthSpecified) {
+ constraints.video.mandatory.maxWidth = widthSpecified;
+ }
+ if (heightSpecified) {
+ constraints.video.mandatory.maxHeight = heightSpecified;
+ }
+ return window.navigator.mediaDevices.getUserMedia(constraints);
+ });
+ };
+}
+
+},{}],5:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetUserMedia = shimGetUserMedia;
+var utils = _interopRequireWildcard(require("../utils.js"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+var logging = utils.log;
+function shimGetUserMedia(window, browserDetails) {
+ var navigator = window && window.navigator;
+ if (!navigator.mediaDevices) {
+ return;
+ }
+ var constraintsToChrome_ = function constraintsToChrome_(c) {
+ if (_typeof(c) !== 'object' || c.mandatory || c.optional) {
+ return c;
+ }
+ var cc = {};
+ Object.keys(c).forEach(function (key) {
+ if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
+ return;
+ }
+ var r = _typeof(c[key]) === 'object' ? c[key] : {
+ ideal: c[key]
+ };
+ if (r.exact !== undefined && typeof r.exact === 'number') {
+ r.min = r.max = r.exact;
+ }
+ var oldname_ = function oldname_(prefix, name) {
+ if (prefix) {
+ return prefix + name.charAt(0).toUpperCase() + name.slice(1);
+ }
+ return name === 'deviceId' ? 'sourceId' : name;
+ };
+ if (r.ideal !== undefined) {
+ cc.optional = cc.optional || [];
+ var oc = {};
+ if (typeof r.ideal === 'number') {
+ oc[oldname_('min', key)] = r.ideal;
+ cc.optional.push(oc);
+ oc = {};
+ oc[oldname_('max', key)] = r.ideal;
+ cc.optional.push(oc);
+ } else {
+ oc[oldname_('', key)] = r.ideal;
+ cc.optional.push(oc);
+ }
+ }
+ if (r.exact !== undefined && typeof r.exact !== 'number') {
+ cc.mandatory = cc.mandatory || {};
+ cc.mandatory[oldname_('', key)] = r.exact;
+ } else {
+ ['min', 'max'].forEach(function (mix) {
+ if (r[mix] !== undefined) {
+ cc.mandatory = cc.mandatory || {};
+ cc.mandatory[oldname_(mix, key)] = r[mix];
+ }
+ });
+ }
+ });
+ if (c.advanced) {
+ cc.optional = (cc.optional || []).concat(c.advanced);
+ }
+ return cc;
+ };
+ var shimConstraints_ = function shimConstraints_(constraints, func) {
+ if (browserDetails.version >= 61) {
+ return func(constraints);
+ }
+ constraints = JSON.parse(JSON.stringify(constraints));
+ if (constraints && _typeof(constraints.audio) === 'object') {
+ var remap = function remap(obj, a, b) {
+ if (a in obj && !(b in obj)) {
+ obj[b] = obj[a];
+ delete obj[a];
+ }
+ };
+ constraints = JSON.parse(JSON.stringify(constraints));
+ remap(constraints.audio, 'autoGainControl', 'googAutoGainControl');
+ remap(constraints.audio, 'noiseSuppression', 'googNoiseSuppression');
+ constraints.audio = constraintsToChrome_(constraints.audio);
+ }
+ if (constraints && _typeof(constraints.video) === 'object') {
+ // Shim facingMode for mobile & surface pro.
+ var face = constraints.video.facingMode;
+ face = face && (_typeof(face) === 'object' ? face : {
+ ideal: face
+ });
+ var getSupportedFacingModeLies = browserDetails.version < 66;
+ if (face && (face.exact === 'user' || face.exact === 'environment' || face.ideal === 'user' || face.ideal === 'environment') && !(navigator.mediaDevices.getSupportedConstraints && navigator.mediaDevices.getSupportedConstraints().facingMode && !getSupportedFacingModeLies)) {
+ delete constraints.video.facingMode;
+ var matches;
+ if (face.exact === 'environment' || face.ideal === 'environment') {
+ matches = ['back', 'rear'];
+ } else if (face.exact === 'user' || face.ideal === 'user') {
+ matches = ['front'];
+ }
+ if (matches) {
+ // Look for matches in label, or use last cam for back (typical).
+ return navigator.mediaDevices.enumerateDevices().then(function (devices) {
+ devices = devices.filter(function (d) {
+ return d.kind === 'videoinput';
+ });
+ var dev = devices.find(function (d) {
+ return matches.some(function (match) {
+ return d.label.toLowerCase().includes(match);
+ });
+ });
+ if (!dev && devices.length && matches.includes('back')) {
+ dev = devices[devices.length - 1]; // more likely the back cam
+ }
+
+ if (dev) {
+ constraints.video.deviceId = face.exact ? {
+ exact: dev.deviceId
+ } : {
+ ideal: dev.deviceId
+ };
+ }
+ constraints.video = constraintsToChrome_(constraints.video);
+ logging('chrome: ' + JSON.stringify(constraints));
+ return func(constraints);
+ });
+ }
+ }
+ constraints.video = constraintsToChrome_(constraints.video);
+ }
+ logging('chrome: ' + JSON.stringify(constraints));
+ return func(constraints);
+ };
+ var shimError_ = function shimError_(e) {
+ if (browserDetails.version >= 64) {
+ return e;
+ }
+ return {
+ name: {
+ PermissionDeniedError: 'NotAllowedError',
+ PermissionDismissedError: 'NotAllowedError',
+ InvalidStateError: 'NotAllowedError',
+ DevicesNotFoundError: 'NotFoundError',
+ ConstraintNotSatisfiedError: 'OverconstrainedError',
+ TrackStartError: 'NotReadableError',
+ MediaDeviceFailedDueToShutdown: 'NotAllowedError',
+ MediaDeviceKillSwitchOn: 'NotAllowedError',
+ TabCaptureError: 'AbortError',
+ ScreenCaptureError: 'AbortError',
+ DeviceCaptureError: 'AbortError'
+ }[e.name] || e.name,
+ message: e.message,
+ constraint: e.constraint || e.constraintName,
+ toString: function toString() {
+ return this.name + (this.message && ': ') + this.message;
+ }
+ };
+ };
+ var getUserMedia_ = function getUserMedia_(constraints, onSuccess, onError) {
+ shimConstraints_(constraints, function (c) {
+ navigator.webkitGetUserMedia(c, onSuccess, function (e) {
+ if (onError) {
+ onError(shimError_(e));
+ }
+ });
+ });
+ };
+ navigator.getUserMedia = getUserMedia_.bind(navigator);
+
+ // Even though Chrome 45 has navigator.mediaDevices and a getUserMedia
+ // function which returns a Promise, it does not accept spec-style
+ // constraints.
+ if (navigator.mediaDevices.getUserMedia) {
+ var origGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
+ navigator.mediaDevices.getUserMedia = function (cs) {
+ return shimConstraints_(cs, function (c) {
+ return origGetUserMedia(c).then(function (stream) {
+ if (c.audio && !stream.getAudioTracks().length || c.video && !stream.getVideoTracks().length) {
+ stream.getTracks().forEach(function (track) {
+ track.stop();
+ });
+ throw new DOMException('', 'NotFoundError');
+ }
+ return stream;
+ }, function (e) {
+ return Promise.reject(shimError_(e));
+ });
+ });
+ };
+ }
+}
+
+},{"../utils.js":11}],6:[function(require,module,exports){
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.removeExtmapAllowMixed = removeExtmapAllowMixed;
+exports.shimAddIceCandidateNullOrEmpty = shimAddIceCandidateNullOrEmpty;
+exports.shimConnectionState = shimConnectionState;
+exports.shimMaxMessageSize = shimMaxMessageSize;
+exports.shimParameterlessSetLocalDescription = shimParameterlessSetLocalDescription;
+exports.shimRTCIceCandidate = shimRTCIceCandidate;
+exports.shimRTCIceCandidateRelayProtocol = shimRTCIceCandidateRelayProtocol;
+exports.shimSendThrowTypeError = shimSendThrowTypeError;
+var _sdp = _interopRequireDefault(require("sdp"));
+var utils = _interopRequireWildcard(require("./utils"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimRTCIceCandidate(window) {
+ // foundation is arbitrarily chosen as an indicator for full support for
+ // https://w3c.github.io/webrtc-pc/#rtcicecandidate-interface
+ if (!window.RTCIceCandidate || window.RTCIceCandidate && 'foundation' in window.RTCIceCandidate.prototype) {
+ return;
+ }
+ var NativeRTCIceCandidate = window.RTCIceCandidate;
+ window.RTCIceCandidate = function RTCIceCandidate(args) {
+ // Remove the a= which shouldn't be part of the candidate string.
+ if (_typeof(args) === 'object' && args.candidate && args.candidate.indexOf('a=') === 0) {
+ args = JSON.parse(JSON.stringify(args));
+ args.candidate = args.candidate.substring(2);
+ }
+ if (args.candidate && args.candidate.length) {
+ // Augment the native candidate with the parsed fields.
+ var nativeCandidate = new NativeRTCIceCandidate(args);
+ var parsedCandidate = _sdp["default"].parseCandidate(args.candidate);
+ for (var key in parsedCandidate) {
+ if (!(key in nativeCandidate)) {
+ Object.defineProperty(nativeCandidate, key, {
+ value: parsedCandidate[key]
+ });
+ }
+ }
+
+ // Override serializer to not serialize the extra attributes.
+ nativeCandidate.toJSON = function toJSON() {
+ return {
+ candidate: nativeCandidate.candidate,
+ sdpMid: nativeCandidate.sdpMid,
+ sdpMLineIndex: nativeCandidate.sdpMLineIndex,
+ usernameFragment: nativeCandidate.usernameFragment
+ };
+ };
+ return nativeCandidate;
+ }
+ return new NativeRTCIceCandidate(args);
+ };
+ window.RTCIceCandidate.prototype = NativeRTCIceCandidate.prototype;
+
+ // Hook up the augmented candidate in onicecandidate and
+ // addEventListener('icecandidate', ...)
+ utils.wrapPeerConnectionEvent(window, 'icecandidate', function (e) {
+ if (e.candidate) {
+ Object.defineProperty(e, 'candidate', {
+ value: new window.RTCIceCandidate(e.candidate),
+ writable: 'false'
+ });
+ }
+ return e;
+ });
+}
+function shimRTCIceCandidateRelayProtocol(window) {
+ if (!window.RTCIceCandidate || window.RTCIceCandidate && 'relayProtocol' in window.RTCIceCandidate.prototype) {
+ return;
+ }
+
+ // Hook up the augmented candidate in onicecandidate and
+ // addEventListener('icecandidate', ...)
+ utils.wrapPeerConnectionEvent(window, 'icecandidate', function (e) {
+ if (e.candidate) {
+ var parsedCandidate = _sdp["default"].parseCandidate(e.candidate.candidate);
+ if (parsedCandidate.type === 'relay') {
+ // This is a libwebrtc-specific mapping of local type preference
+ // to relayProtocol.
+ e.candidate.relayProtocol = {
+ 0: 'tls',
+ 1: 'tcp',
+ 2: 'udp'
+ }[parsedCandidate.priority >> 24];
+ }
+ }
+ return e;
+ });
+}
+function shimMaxMessageSize(window, browserDetails) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ if (!('sctp' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'sctp', {
+ get: function get() {
+ return typeof this._sctp === 'undefined' ? null : this._sctp;
+ }
+ });
+ }
+ var sctpInDescription = function sctpInDescription(description) {
+ if (!description || !description.sdp) {
+ return false;
+ }
+ var sections = _sdp["default"].splitSections(description.sdp);
+ sections.shift();
+ return sections.some(function (mediaSection) {
+ var mLine = _sdp["default"].parseMLine(mediaSection);
+ return mLine && mLine.kind === 'application' && mLine.protocol.indexOf('SCTP') !== -1;
+ });
+ };
+ var getRemoteFirefoxVersion = function getRemoteFirefoxVersion(description) {
+ // TODO: Is there a better solution for detecting Firefox?
+ var match = description.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);
+ if (match === null || match.length < 2) {
+ return -1;
+ }
+ var version = parseInt(match[1], 10);
+ // Test for NaN (yes, this is ugly)
+ return version !== version ? -1 : version;
+ };
+ var getCanSendMaxMessageSize = function getCanSendMaxMessageSize(remoteIsFirefox) {
+ // Every implementation we know can send at least 64 KiB.
+ // Note: Although Chrome is technically able to send up to 256 KiB, the
+ // data does not reach the other peer reliably.
+ // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=8419
+ var canSendMaxMessageSize = 65536;
+ if (browserDetails.browser === 'firefox') {
+ if (browserDetails.version < 57) {
+ if (remoteIsFirefox === -1) {
+ // FF < 57 will send in 16 KiB chunks using the deprecated PPID
+ // fragmentation.
+ canSendMaxMessageSize = 16384;
+ } else {
+ // However, other FF (and RAWRTC) can reassemble PPID-fragmented
+ // messages. Thus, supporting ~2 GiB when sending.
+ canSendMaxMessageSize = 2147483637;
+ }
+ } else if (browserDetails.version < 60) {
+ // Currently, all FF >= 57 will reset the remote maximum message size
+ // to the default value when a data channel is created at a later
+ // stage. :(
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
+ canSendMaxMessageSize = browserDetails.version === 57 ? 65535 : 65536;
+ } else {
+ // FF >= 60 supports sending ~2 GiB
+ canSendMaxMessageSize = 2147483637;
+ }
+ }
+ return canSendMaxMessageSize;
+ };
+ var getMaxMessageSize = function getMaxMessageSize(description, remoteIsFirefox) {
+ // Note: 65536 bytes is the default value from the SDP spec. Also,
+ // every implementation we know supports receiving 65536 bytes.
+ var maxMessageSize = 65536;
+
+ // FF 57 has a slightly incorrect default remote max message size, so
+ // we need to adjust it here to avoid a failure when sending.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1425697
+ if (browserDetails.browser === 'firefox' && browserDetails.version === 57) {
+ maxMessageSize = 65535;
+ }
+ var match = _sdp["default"].matchPrefix(description.sdp, 'a=max-message-size:');
+ if (match.length > 0) {
+ maxMessageSize = parseInt(match[0].substring(19), 10);
+ } else if (browserDetails.browser === 'firefox' && remoteIsFirefox !== -1) {
+ // If the maximum message size is not present in the remote SDP and
+ // both local and remote are Firefox, the remote peer can receive
+ // ~2 GiB.
+ maxMessageSize = 2147483637;
+ }
+ return maxMessageSize;
+ };
+ var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
+ this._sctp = null;
+ // Chrome decided to not expose .sctp in plan-b mode.
+ // As usual, adapter.js has to do an 'ugly worakaround'
+ // to cover up the mess.
+ if (browserDetails.browser === 'chrome' && browserDetails.version >= 76) {
+ var _this$getConfiguratio = this.getConfiguration(),
+ sdpSemantics = _this$getConfiguratio.sdpSemantics;
+ if (sdpSemantics === 'plan-b') {
+ Object.defineProperty(this, 'sctp', {
+ get: function get() {
+ return typeof this._sctp === 'undefined' ? null : this._sctp;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ }
+ }
+ if (sctpInDescription(arguments[0])) {
+ // Check if the remote is FF.
+ var isFirefox = getRemoteFirefoxVersion(arguments[0]);
+
+ // Get the maximum message size the local peer is capable of sending
+ var canSendMMS = getCanSendMaxMessageSize(isFirefox);
+
+ // Get the maximum message size of the remote peer.
+ var remoteMMS = getMaxMessageSize(arguments[0], isFirefox);
+
+ // Determine final maximum message size
+ var maxMessageSize;
+ if (canSendMMS === 0 && remoteMMS === 0) {
+ maxMessageSize = Number.POSITIVE_INFINITY;
+ } else if (canSendMMS === 0 || remoteMMS === 0) {
+ maxMessageSize = Math.max(canSendMMS, remoteMMS);
+ } else {
+ maxMessageSize = Math.min(canSendMMS, remoteMMS);
+ }
+
+ // Create a dummy RTCSctpTransport object and the 'maxMessageSize'
+ // attribute.
+ var sctp = {};
+ Object.defineProperty(sctp, 'maxMessageSize', {
+ get: function get() {
+ return maxMessageSize;
+ }
+ });
+ this._sctp = sctp;
+ }
+ return origSetRemoteDescription.apply(this, arguments);
+ };
+}
+function shimSendThrowTypeError(window) {
+ if (!(window.RTCPeerConnection && 'createDataChannel' in window.RTCPeerConnection.prototype)) {
+ return;
+ }
+
+ // Note: Although Firefox >= 57 has a native implementation, the maximum
+ // message size can be reset for all data channels at a later stage.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
+
+ function wrapDcSend(dc, pc) {
+ var origDataChannelSend = dc.send;
+ dc.send = function send() {
+ var data = arguments[0];
+ var length = data.length || data.size || data.byteLength;
+ if (dc.readyState === 'open' && pc.sctp && length > pc.sctp.maxMessageSize) {
+ throw new TypeError('Message too large (can send a maximum of ' + pc.sctp.maxMessageSize + ' bytes)');
+ }
+ return origDataChannelSend.apply(dc, arguments);
+ };
+ }
+ var origCreateDataChannel = window.RTCPeerConnection.prototype.createDataChannel;
+ window.RTCPeerConnection.prototype.createDataChannel = function createDataChannel() {
+ var dataChannel = origCreateDataChannel.apply(this, arguments);
+ wrapDcSend(dataChannel, this);
+ return dataChannel;
+ };
+ utils.wrapPeerConnectionEvent(window, 'datachannel', function (e) {
+ wrapDcSend(e.channel, e.target);
+ return e;
+ });
+}
+
+/* shims RTCConnectionState by pretending it is the same as iceConnectionState.
+ * See https://bugs.chromium.org/p/webrtc/issues/detail?id=6145#c12
+ * for why this is a valid hack in Chrome. In Firefox it is slightly incorrect
+ * since DTLS failures would be hidden. See
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=1265827
+ * for the Firefox tracking bug.
+ */
+function shimConnectionState(window) {
+ if (!window.RTCPeerConnection || 'connectionState' in window.RTCPeerConnection.prototype) {
+ return;
+ }
+ var proto = window.RTCPeerConnection.prototype;
+ Object.defineProperty(proto, 'connectionState', {
+ get: function get() {
+ return {
+ completed: 'connected',
+ checking: 'connecting'
+ }[this.iceConnectionState] || this.iceConnectionState;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(proto, 'onconnectionstatechange', {
+ get: function get() {
+ return this._onconnectionstatechange || null;
+ },
+ set: function set(cb) {
+ if (this._onconnectionstatechange) {
+ this.removeEventListener('connectionstatechange', this._onconnectionstatechange);
+ delete this._onconnectionstatechange;
+ }
+ if (cb) {
+ this.addEventListener('connectionstatechange', this._onconnectionstatechange = cb);
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+ ['setLocalDescription', 'setRemoteDescription'].forEach(function (method) {
+ var origMethod = proto[method];
+ proto[method] = function () {
+ if (!this._connectionstatechangepoly) {
+ this._connectionstatechangepoly = function (e) {
+ var pc = e.target;
+ if (pc._lastConnectionState !== pc.connectionState) {
+ pc._lastConnectionState = pc.connectionState;
+ var newEvent = new Event('connectionstatechange', e);
+ pc.dispatchEvent(newEvent);
+ }
+ return e;
+ };
+ this.addEventListener('iceconnectionstatechange', this._connectionstatechangepoly);
+ }
+ return origMethod.apply(this, arguments);
+ };
+ });
+}
+function removeExtmapAllowMixed(window, browserDetails) {
+ /* remove a=extmap-allow-mixed for webrtc.org < M71 */
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ if (browserDetails.browser === 'chrome' && browserDetails.version >= 71) {
+ return;
+ }
+ if (browserDetails.browser === 'safari' && browserDetails.version >= 605) {
+ return;
+ }
+ var nativeSRD = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription(desc) {
+ if (desc && desc.sdp && desc.sdp.indexOf('\na=extmap-allow-mixed') !== -1) {
+ var sdp = desc.sdp.split('\n').filter(function (line) {
+ return line.trim() !== 'a=extmap-allow-mixed';
+ }).join('\n');
+ // Safari enforces read-only-ness of RTCSessionDescription fields.
+ if (window.RTCSessionDescription && desc instanceof window.RTCSessionDescription) {
+ arguments[0] = new window.RTCSessionDescription({
+ type: desc.type,
+ sdp: sdp
+ });
+ } else {
+ desc.sdp = sdp;
+ }
+ }
+ return nativeSRD.apply(this, arguments);
+ };
+}
+function shimAddIceCandidateNullOrEmpty(window, browserDetails) {
+ // Support for addIceCandidate(null or undefined)
+ // as well as addIceCandidate({candidate: "", ...})
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=978582
+ // Note: must be called before other polyfills which change the signature.
+ if (!(window.RTCPeerConnection && window.RTCPeerConnection.prototype)) {
+ return;
+ }
+ var nativeAddIceCandidate = window.RTCPeerConnection.prototype.addIceCandidate;
+ if (!nativeAddIceCandidate || nativeAddIceCandidate.length === 0) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.addIceCandidate = function addIceCandidate() {
+ if (!arguments[0]) {
+ if (arguments[1]) {
+ arguments[1].apply(null);
+ }
+ return Promise.resolve();
+ }
+ // Firefox 68+ emits and processes {candidate: "", ...}, ignore
+ // in older versions.
+ // Native support for ignoring exists for Chrome M77+.
+ // Safari ignores as well, exact version unknown but works in the same
+ // version that also ignores addIceCandidate(null).
+ if ((browserDetails.browser === 'chrome' && browserDetails.version < 78 || browserDetails.browser === 'firefox' && browserDetails.version < 68 || browserDetails.browser === 'safari') && arguments[0] && arguments[0].candidate === '') {
+ return Promise.resolve();
+ }
+ return nativeAddIceCandidate.apply(this, arguments);
+ };
+}
+
+// Note: Make sure to call this ahead of APIs that modify
+// setLocalDescription.length
+function shimParameterlessSetLocalDescription(window, browserDetails) {
+ if (!(window.RTCPeerConnection && window.RTCPeerConnection.prototype)) {
+ return;
+ }
+ var nativeSetLocalDescription = window.RTCPeerConnection.prototype.setLocalDescription;
+ if (!nativeSetLocalDescription || nativeSetLocalDescription.length === 0) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.setLocalDescription = function setLocalDescription() {
+ var _this = this;
+ var desc = arguments[0] || {};
+ if (_typeof(desc) !== 'object' || desc.type && desc.sdp) {
+ return nativeSetLocalDescription.apply(this, arguments);
+ }
+ // The remaining steps should technically happen when SLD comes off the
+ // RTCPeerConnection's operations chain (not ahead of going on it), but
+ // this is too difficult to shim. Instead, this shim only covers the
+ // common case where the operations chain is empty. This is imperfect, but
+ // should cover many cases. Rationale: Even if we can't reduce the glare
+ // window to zero on imperfect implementations, there's value in tapping
+ // into the perfect negotiation pattern that several browsers support.
+ desc = {
+ type: desc.type,
+ sdp: desc.sdp
+ };
+ if (!desc.type) {
+ switch (this.signalingState) {
+ case 'stable':
+ case 'have-local-offer':
+ case 'have-remote-pranswer':
+ desc.type = 'offer';
+ break;
+ default:
+ desc.type = 'answer';
+ break;
+ }
+ }
+ if (desc.sdp || desc.type !== 'offer' && desc.type !== 'answer') {
+ return nativeSetLocalDescription.apply(this, [desc]);
+ }
+ var func = desc.type === 'offer' ? this.createOffer : this.createAnswer;
+ return func.apply(this).then(function (d) {
+ return nativeSetLocalDescription.apply(_this, [d]);
+ });
+ };
+}
+
+},{"./utils":11,"sdp":12}],7:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimAddTransceiver = shimAddTransceiver;
+exports.shimCreateAnswer = shimCreateAnswer;
+exports.shimCreateOffer = shimCreateOffer;
+Object.defineProperty(exports, "shimGetDisplayMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getdisplaymedia.shimGetDisplayMedia;
+ }
+});
+exports.shimGetParameters = shimGetParameters;
+Object.defineProperty(exports, "shimGetUserMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getusermedia.shimGetUserMedia;
+ }
+});
+exports.shimOnTrack = shimOnTrack;
+exports.shimPeerConnection = shimPeerConnection;
+exports.shimRTCDataChannel = shimRTCDataChannel;
+exports.shimReceiverGetStats = shimReceiverGetStats;
+exports.shimRemoveStream = shimRemoveStream;
+exports.shimSenderGetStats = shimSenderGetStats;
+var utils = _interopRequireWildcard(require("../utils"));
+var _getusermedia = require("./getusermedia");
+var _getdisplaymedia = require("./getdisplaymedia");
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
+function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
+function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimOnTrack(window) {
+ if (_typeof(window) === 'object' && window.RTCTrackEvent && 'receiver' in window.RTCTrackEvent.prototype && !('transceiver' in window.RTCTrackEvent.prototype)) {
+ Object.defineProperty(window.RTCTrackEvent.prototype, 'transceiver', {
+ get: function get() {
+ return {
+ receiver: this.receiver
+ };
+ }
+ });
+ }
+}
+function shimPeerConnection(window, browserDetails) {
+ if (_typeof(window) !== 'object' || !(window.RTCPeerConnection || window.mozRTCPeerConnection)) {
+ return; // probably media.peerconnection.enabled=false in about:config
+ }
+
+ if (!window.RTCPeerConnection && window.mozRTCPeerConnection) {
+ // very basic support for old versions.
+ window.RTCPeerConnection = window.mozRTCPeerConnection;
+ }
+ if (browserDetails.version < 53) {
+ // shim away need for obsolete RTCIceCandidate/RTCSessionDescription.
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
+ var nativeMethod = window.RTCPeerConnection.prototype[method];
+ var methodObj = _defineProperty({}, method, function () {
+ arguments[0] = new (method === 'addIceCandidate' ? window.RTCIceCandidate : window.RTCSessionDescription)(arguments[0]);
+ return nativeMethod.apply(this, arguments);
+ });
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ }
+ var modernStatsTypes = {
+ inboundrtp: 'inbound-rtp',
+ outboundrtp: 'outbound-rtp',
+ candidatepair: 'candidate-pair',
+ localcandidate: 'local-candidate',
+ remotecandidate: 'remote-candidate'
+ };
+ var nativeGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ var _arguments = Array.prototype.slice.call(arguments),
+ selector = _arguments[0],
+ onSucc = _arguments[1],
+ onErr = _arguments[2];
+ return nativeGetStats.apply(this, [selector || null]).then(function (stats) {
+ if (browserDetails.version < 53 && !onSucc) {
+ // Shim only promise getStats with spec-hyphens in type names
+ // Leave callback version alone; misc old uses of forEach before Map
+ try {
+ stats.forEach(function (stat) {
+ stat.type = modernStatsTypes[stat.type] || stat.type;
+ });
+ } catch (e) {
+ if (e.name !== 'TypeError') {
+ throw e;
+ }
+ // Avoid TypeError: "type" is read-only, in old versions. 34-43ish
+ stats.forEach(function (stat, i) {
+ stats.set(i, Object.assign({}, stat, {
+ type: modernStatsTypes[stat.type] || stat.type
+ }));
+ });
+ }
+ }
+ return stats;
+ }).then(onSucc, onErr);
+ };
+}
+function shimSenderGetStats(window) {
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection && window.RTCRtpSender)) {
+ return;
+ }
+ if (window.RTCRtpSender && 'getStats' in window.RTCRtpSender.prototype) {
+ return;
+ }
+ var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ if (origGetSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ var _this = this;
+ var senders = origGetSenders.apply(this, []);
+ senders.forEach(function (sender) {
+ return sender._pc = _this;
+ });
+ return senders;
+ };
+ }
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ if (origAddTrack) {
+ window.RTCPeerConnection.prototype.addTrack = function addTrack() {
+ var sender = origAddTrack.apply(this, arguments);
+ sender._pc = this;
+ return sender;
+ };
+ }
+ window.RTCRtpSender.prototype.getStats = function getStats() {
+ return this.track ? this._pc.getStats(this.track) : Promise.resolve(new Map());
+ };
+}
+function shimReceiverGetStats(window) {
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection && window.RTCRtpSender)) {
+ return;
+ }
+ if (window.RTCRtpSender && 'getStats' in window.RTCRtpReceiver.prototype) {
+ return;
+ }
+ var origGetReceivers = window.RTCPeerConnection.prototype.getReceivers;
+ if (origGetReceivers) {
+ window.RTCPeerConnection.prototype.getReceivers = function getReceivers() {
+ var _this2 = this;
+ var receivers = origGetReceivers.apply(this, []);
+ receivers.forEach(function (receiver) {
+ return receiver._pc = _this2;
+ });
+ return receivers;
+ };
+ }
+ utils.wrapPeerConnectionEvent(window, 'track', function (e) {
+ e.receiver._pc = e.srcElement;
+ return e;
+ });
+ window.RTCRtpReceiver.prototype.getStats = function getStats() {
+ return this._pc.getStats(this.track);
+ };
+}
+function shimRemoveStream(window) {
+ if (!window.RTCPeerConnection || 'removeStream' in window.RTCPeerConnection.prototype) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ var _this3 = this;
+ utils.deprecated('removeStream', 'removeTrack');
+ this.getSenders().forEach(function (sender) {
+ if (sender.track && stream.getTracks().includes(sender.track)) {
+ _this3.removeTrack(sender);
+ }
+ });
+ };
+}
+function shimRTCDataChannel(window) {
+ // rename DataChannel to RTCDataChannel (native fix in FF60):
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1173851
+ if (window.DataChannel && !window.RTCDataChannel) {
+ window.RTCDataChannel = window.DataChannel;
+ }
+}
+function shimAddTransceiver(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ var origAddTransceiver = window.RTCPeerConnection.prototype.addTransceiver;
+ if (origAddTransceiver) {
+ window.RTCPeerConnection.prototype.addTransceiver = function addTransceiver() {
+ this.setParametersPromises = [];
+ // WebIDL input coercion and validation
+ var sendEncodings = arguments[1] && arguments[1].sendEncodings;
+ if (sendEncodings === undefined) {
+ sendEncodings = [];
+ }
+ sendEncodings = _toConsumableArray(sendEncodings);
+ var shouldPerformCheck = sendEncodings.length > 0;
+ if (shouldPerformCheck) {
+ // If sendEncodings params are provided, validate grammar
+ sendEncodings.forEach(function (encodingParam) {
+ if ('rid' in encodingParam) {
+ var ridRegex = /^[a-z0-9]{0,16}$/i;
+ if (!ridRegex.test(encodingParam.rid)) {
+ throw new TypeError('Invalid RID value provided.');
+ }
+ }
+ if ('scaleResolutionDownBy' in encodingParam) {
+ if (!(parseFloat(encodingParam.scaleResolutionDownBy) >= 1.0)) {
+ throw new RangeError('scale_resolution_down_by must be >= 1.0');
+ }
+ }
+ if ('maxFramerate' in encodingParam) {
+ if (!(parseFloat(encodingParam.maxFramerate) >= 0)) {
+ throw new RangeError('max_framerate must be >= 0.0');
+ }
+ }
+ });
+ }
+ var transceiver = origAddTransceiver.apply(this, arguments);
+ if (shouldPerformCheck) {
+ // Check if the init options were applied. If not we do this in an
+ // asynchronous way and save the promise reference in a global object.
+ // This is an ugly hack, but at the same time is way more robust than
+ // checking the sender parameters before and after the createOffer
+ // Also note that after the createoffer we are not 100% sure that
+ // the params were asynchronously applied so we might miss the
+ // opportunity to recreate offer.
+ var sender = transceiver.sender;
+ var params = sender.getParameters();
+ if (!('encodings' in params) ||
+ // Avoid being fooled by patched getParameters() below.
+ params.encodings.length === 1 && Object.keys(params.encodings[0]).length === 0) {
+ params.encodings = sendEncodings;
+ sender.sendEncodings = sendEncodings;
+ this.setParametersPromises.push(sender.setParameters(params).then(function () {
+ delete sender.sendEncodings;
+ })["catch"](function () {
+ delete sender.sendEncodings;
+ }));
+ }
+ }
+ return transceiver;
+ };
+ }
+}
+function shimGetParameters(window) {
+ if (!(_typeof(window) === 'object' && window.RTCRtpSender)) {
+ return;
+ }
+ var origGetParameters = window.RTCRtpSender.prototype.getParameters;
+ if (origGetParameters) {
+ window.RTCRtpSender.prototype.getParameters = function getParameters() {
+ var params = origGetParameters.apply(this, arguments);
+ if (!('encodings' in params)) {
+ params.encodings = [].concat(this.sendEncodings || [{}]);
+ }
+ return params;
+ };
+ }
+}
+function shimCreateOffer(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ var origCreateOffer = window.RTCPeerConnection.prototype.createOffer;
+ window.RTCPeerConnection.prototype.createOffer = function createOffer() {
+ var _arguments2 = arguments,
+ _this4 = this;
+ if (this.setParametersPromises && this.setParametersPromises.length) {
+ return Promise.all(this.setParametersPromises).then(function () {
+ return origCreateOffer.apply(_this4, _arguments2);
+ })["finally"](function () {
+ _this4.setParametersPromises = [];
+ });
+ }
+ return origCreateOffer.apply(this, arguments);
+ };
+}
+function shimCreateAnswer(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ var origCreateAnswer = window.RTCPeerConnection.prototype.createAnswer;
+ window.RTCPeerConnection.prototype.createAnswer = function createAnswer() {
+ var _arguments3 = arguments,
+ _this5 = this;
+ if (this.setParametersPromises && this.setParametersPromises.length) {
+ return Promise.all(this.setParametersPromises).then(function () {
+ return origCreateAnswer.apply(_this5, _arguments3);
+ })["finally"](function () {
+ _this5.setParametersPromises = [];
+ });
+ }
+ return origCreateAnswer.apply(this, arguments);
+ };
+}
+
+},{"../utils":11,"./getdisplaymedia":8,"./getusermedia":9}],8:[function(require,module,exports){
+/*
+ * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetDisplayMedia = shimGetDisplayMedia;
+function shimGetDisplayMedia(window, preferredMediaSource) {
+ if (window.navigator.mediaDevices && 'getDisplayMedia' in window.navigator.mediaDevices) {
+ return;
+ }
+ if (!window.navigator.mediaDevices) {
+ return;
+ }
+ window.navigator.mediaDevices.getDisplayMedia = function getDisplayMedia(constraints) {
+ if (!(constraints && constraints.video)) {
+ var err = new DOMException('getDisplayMedia without video ' + 'constraints is undefined');
+ err.name = 'NotFoundError';
+ // from https://heycam.github.io/webidl/#idl-DOMException-error-names
+ err.code = 8;
+ return Promise.reject(err);
+ }
+ if (constraints.video === true) {
+ constraints.video = {
+ mediaSource: preferredMediaSource
+ };
+ } else {
+ constraints.video.mediaSource = preferredMediaSource;
+ }
+ return window.navigator.mediaDevices.getUserMedia(constraints);
+ };
+}
+
+},{}],9:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetUserMedia = shimGetUserMedia;
+var utils = _interopRequireWildcard(require("../utils"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimGetUserMedia(window, browserDetails) {
+ var navigator = window && window.navigator;
+ var MediaStreamTrack = window && window.MediaStreamTrack;
+ navigator.getUserMedia = function (constraints, onSuccess, onError) {
+ // Replace Firefox 44+'s deprecation warning with unprefixed version.
+ utils.deprecated('navigator.getUserMedia', 'navigator.mediaDevices.getUserMedia');
+ navigator.mediaDevices.getUserMedia(constraints).then(onSuccess, onError);
+ };
+ if (!(browserDetails.version > 55 && 'autoGainControl' in navigator.mediaDevices.getSupportedConstraints())) {
+ var remap = function remap(obj, a, b) {
+ if (a in obj && !(b in obj)) {
+ obj[b] = obj[a];
+ delete obj[a];
+ }
+ };
+ var nativeGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
+ navigator.mediaDevices.getUserMedia = function (c) {
+ if (_typeof(c) === 'object' && _typeof(c.audio) === 'object') {
+ c = JSON.parse(JSON.stringify(c));
+ remap(c.audio, 'autoGainControl', 'mozAutoGainControl');
+ remap(c.audio, 'noiseSuppression', 'mozNoiseSuppression');
+ }
+ return nativeGetUserMedia(c);
+ };
+ if (MediaStreamTrack && MediaStreamTrack.prototype.getSettings) {
+ var nativeGetSettings = MediaStreamTrack.prototype.getSettings;
+ MediaStreamTrack.prototype.getSettings = function () {
+ var obj = nativeGetSettings.apply(this, arguments);
+ remap(obj, 'mozAutoGainControl', 'autoGainControl');
+ remap(obj, 'mozNoiseSuppression', 'noiseSuppression');
+ return obj;
+ };
+ }
+ if (MediaStreamTrack && MediaStreamTrack.prototype.applyConstraints) {
+ var nativeApplyConstraints = MediaStreamTrack.prototype.applyConstraints;
+ MediaStreamTrack.prototype.applyConstraints = function (c) {
+ if (this.kind === 'audio' && _typeof(c) === 'object') {
+ c = JSON.parse(JSON.stringify(c));
+ remap(c, 'autoGainControl', 'mozAutoGainControl');
+ remap(c, 'noiseSuppression', 'mozNoiseSuppression');
+ }
+ return nativeApplyConstraints.apply(this, [c]);
+ };
+ }
+ }
+}
+
+},{"../utils":11}],10:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimAudioContext = shimAudioContext;
+exports.shimCallbacksAPI = shimCallbacksAPI;
+exports.shimConstraints = shimConstraints;
+exports.shimCreateOfferLegacy = shimCreateOfferLegacy;
+exports.shimGetUserMedia = shimGetUserMedia;
+exports.shimLocalStreamsAPI = shimLocalStreamsAPI;
+exports.shimRTCIceServerUrls = shimRTCIceServerUrls;
+exports.shimRemoteStreamsAPI = shimRemoteStreamsAPI;
+exports.shimTrackEventTransceiver = shimTrackEventTransceiver;
+var utils = _interopRequireWildcard(require("../utils"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimLocalStreamsAPI(window) {
+ if (_typeof(window) !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ if (!('getLocalStreams' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.getLocalStreams = function getLocalStreams() {
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ return this._localStreams;
+ };
+ }
+ if (!('addStream' in window.RTCPeerConnection.prototype)) {
+ var _addTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this = this;
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ if (!this._localStreams.includes(stream)) {
+ this._localStreams.push(stream);
+ }
+ // Try to emulate Chrome's behaviour of adding in audio-video order.
+ // Safari orders by track id.
+ stream.getAudioTracks().forEach(function (track) {
+ return _addTrack.call(_this, track, stream);
+ });
+ stream.getVideoTracks().forEach(function (track) {
+ return _addTrack.call(_this, track, stream);
+ });
+ };
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track) {
+ var _this2 = this;
+ for (var _len = arguments.length, streams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ streams[_key - 1] = arguments[_key];
+ }
+ if (streams) {
+ streams.forEach(function (stream) {
+ if (!_this2._localStreams) {
+ _this2._localStreams = [stream];
+ } else if (!_this2._localStreams.includes(stream)) {
+ _this2._localStreams.push(stream);
+ }
+ });
+ }
+ return _addTrack.apply(this, arguments);
+ };
+ }
+ if (!('removeStream' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ var _this3 = this;
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ var index = this._localStreams.indexOf(stream);
+ if (index === -1) {
+ return;
+ }
+ this._localStreams.splice(index, 1);
+ var tracks = stream.getTracks();
+ this.getSenders().forEach(function (sender) {
+ if (tracks.includes(sender.track)) {
+ _this3.removeTrack(sender);
+ }
+ });
+ };
+ }
+}
+function shimRemoteStreamsAPI(window) {
+ if (_typeof(window) !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ if (!('getRemoteStreams' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.getRemoteStreams = function getRemoteStreams() {
+ return this._remoteStreams ? this._remoteStreams : [];
+ };
+ }
+ if (!('onaddstream' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'onaddstream', {
+ get: function get() {
+ return this._onaddstream;
+ },
+ set: function set(f) {
+ var _this4 = this;
+ if (this._onaddstream) {
+ this.removeEventListener('addstream', this._onaddstream);
+ this.removeEventListener('track', this._onaddstreampoly);
+ }
+ this.addEventListener('addstream', this._onaddstream = f);
+ this.addEventListener('track', this._onaddstreampoly = function (e) {
+ e.streams.forEach(function (stream) {
+ if (!_this4._remoteStreams) {
+ _this4._remoteStreams = [];
+ }
+ if (_this4._remoteStreams.includes(stream)) {
+ return;
+ }
+ _this4._remoteStreams.push(stream);
+ var event = new Event('addstream');
+ event.stream = stream;
+ _this4.dispatchEvent(event);
+ });
+ });
+ }
+ });
+ var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
+ var pc = this;
+ if (!this._onaddstreampoly) {
+ this.addEventListener('track', this._onaddstreampoly = function (e) {
+ e.streams.forEach(function (stream) {
+ if (!pc._remoteStreams) {
+ pc._remoteStreams = [];
+ }
+ if (pc._remoteStreams.indexOf(stream) >= 0) {
+ return;
+ }
+ pc._remoteStreams.push(stream);
+ var event = new Event('addstream');
+ event.stream = stream;
+ pc.dispatchEvent(event);
+ });
+ });
+ }
+ return origSetRemoteDescription.apply(pc, arguments);
+ };
+ }
+}
+function shimCallbacksAPI(window) {
+ if (_typeof(window) !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ var prototype = window.RTCPeerConnection.prototype;
+ var origCreateOffer = prototype.createOffer;
+ var origCreateAnswer = prototype.createAnswer;
+ var setLocalDescription = prototype.setLocalDescription;
+ var setRemoteDescription = prototype.setRemoteDescription;
+ var addIceCandidate = prototype.addIceCandidate;
+ prototype.createOffer = function createOffer(successCallback, failureCallback) {
+ var options = arguments.length >= 2 ? arguments[2] : arguments[0];
+ var promise = origCreateOffer.apply(this, [options]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.createAnswer = function createAnswer(successCallback, failureCallback) {
+ var options = arguments.length >= 2 ? arguments[2] : arguments[0];
+ var promise = origCreateAnswer.apply(this, [options]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ var withCallback = function withCallback(description, successCallback, failureCallback) {
+ var promise = setLocalDescription.apply(this, [description]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.setLocalDescription = withCallback;
+ withCallback = function withCallback(description, successCallback, failureCallback) {
+ var promise = setRemoteDescription.apply(this, [description]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.setRemoteDescription = withCallback;
+ withCallback = function withCallback(candidate, successCallback, failureCallback) {
+ var promise = addIceCandidate.apply(this, [candidate]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.addIceCandidate = withCallback;
+}
+function shimGetUserMedia(window) {
+ var navigator = window && window.navigator;
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
+ // shim not needed in Safari 12.1
+ var mediaDevices = navigator.mediaDevices;
+ var _getUserMedia = mediaDevices.getUserMedia.bind(mediaDevices);
+ navigator.mediaDevices.getUserMedia = function (constraints) {
+ return _getUserMedia(shimConstraints(constraints));
+ };
+ }
+ if (!navigator.getUserMedia && navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
+ navigator.getUserMedia = function getUserMedia(constraints, cb, errcb) {
+ navigator.mediaDevices.getUserMedia(constraints).then(cb, errcb);
+ }.bind(navigator);
+ }
+}
+function shimConstraints(constraints) {
+ if (constraints && constraints.video !== undefined) {
+ return Object.assign({}, constraints, {
+ video: utils.compactObject(constraints.video)
+ });
+ }
+ return constraints;
+}
+function shimRTCIceServerUrls(window) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ // migrate from non-spec RTCIceServer.url to RTCIceServer.urls
+ var OrigPeerConnection = window.RTCPeerConnection;
+ window.RTCPeerConnection = function RTCPeerConnection(pcConfig, pcConstraints) {
+ if (pcConfig && pcConfig.iceServers) {
+ var newIceServers = [];
+ for (var i = 0; i < pcConfig.iceServers.length; i++) {
+ var server = pcConfig.iceServers[i];
+ if (server.urls === undefined && server.url) {
+ utils.deprecated('RTCIceServer.url', 'RTCIceServer.urls');
+ server = JSON.parse(JSON.stringify(server));
+ server.urls = server.url;
+ delete server.url;
+ newIceServers.push(server);
+ } else {
+ newIceServers.push(pcConfig.iceServers[i]);
+ }
+ }
+ pcConfig.iceServers = newIceServers;
+ }
+ return new OrigPeerConnection(pcConfig, pcConstraints);
+ };
+ window.RTCPeerConnection.prototype = OrigPeerConnection.prototype;
+ // wrap static methods. Currently just generateCertificate.
+ if ('generateCertificate' in OrigPeerConnection) {
+ Object.defineProperty(window.RTCPeerConnection, 'generateCertificate', {
+ get: function get() {
+ return OrigPeerConnection.generateCertificate;
+ }
+ });
+ }
+}
+function shimTrackEventTransceiver(window) {
+ // Add event.transceiver member over deprecated event.receiver
+ if (_typeof(window) === 'object' && window.RTCTrackEvent && 'receiver' in window.RTCTrackEvent.prototype && !('transceiver' in window.RTCTrackEvent.prototype)) {
+ Object.defineProperty(window.RTCTrackEvent.prototype, 'transceiver', {
+ get: function get() {
+ return {
+ receiver: this.receiver
+ };
+ }
+ });
+ }
+}
+function shimCreateOfferLegacy(window) {
+ var origCreateOffer = window.RTCPeerConnection.prototype.createOffer;
+ window.RTCPeerConnection.prototype.createOffer = function createOffer(offerOptions) {
+ if (offerOptions) {
+ if (typeof offerOptions.offerToReceiveAudio !== 'undefined') {
+ // support bit values
+ offerOptions.offerToReceiveAudio = !!offerOptions.offerToReceiveAudio;
+ }
+ var audioTransceiver = this.getTransceivers().find(function (transceiver) {
+ return transceiver.receiver.track.kind === 'audio';
+ });
+ if (offerOptions.offerToReceiveAudio === false && audioTransceiver) {
+ if (audioTransceiver.direction === 'sendrecv') {
+ if (audioTransceiver.setDirection) {
+ audioTransceiver.setDirection('sendonly');
+ } else {
+ audioTransceiver.direction = 'sendonly';
+ }
+ } else if (audioTransceiver.direction === 'recvonly') {
+ if (audioTransceiver.setDirection) {
+ audioTransceiver.setDirection('inactive');
+ } else {
+ audioTransceiver.direction = 'inactive';
+ }
+ }
+ } else if (offerOptions.offerToReceiveAudio === true && !audioTransceiver) {
+ this.addTransceiver('audio', {
+ direction: 'recvonly'
+ });
+ }
+ if (typeof offerOptions.offerToReceiveVideo !== 'undefined') {
+ // support bit values
+ offerOptions.offerToReceiveVideo = !!offerOptions.offerToReceiveVideo;
+ }
+ var videoTransceiver = this.getTransceivers().find(function (transceiver) {
+ return transceiver.receiver.track.kind === 'video';
+ });
+ if (offerOptions.offerToReceiveVideo === false && videoTransceiver) {
+ if (videoTransceiver.direction === 'sendrecv') {
+ if (videoTransceiver.setDirection) {
+ videoTransceiver.setDirection('sendonly');
+ } else {
+ videoTransceiver.direction = 'sendonly';
+ }
+ } else if (videoTransceiver.direction === 'recvonly') {
+ if (videoTransceiver.setDirection) {
+ videoTransceiver.setDirection('inactive');
+ } else {
+ videoTransceiver.direction = 'inactive';
+ }
+ }
+ } else if (offerOptions.offerToReceiveVideo === true && !videoTransceiver) {
+ this.addTransceiver('video', {
+ direction: 'recvonly'
+ });
+ }
+ }
+ return origCreateOffer.apply(this, arguments);
+ };
+}
+function shimAudioContext(window) {
+ if (_typeof(window) !== 'object' || window.AudioContext) {
+ return;
+ }
+ window.AudioContext = window.webkitAudioContext;
+}
+
+},{"../utils":11}],11:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.compactObject = compactObject;
+exports.deprecated = deprecated;
+exports.detectBrowser = detectBrowser;
+exports.disableLog = disableLog;
+exports.disableWarnings = disableWarnings;
+exports.extractVersion = extractVersion;
+exports.filterStats = filterStats;
+exports.log = log;
+exports.walkStats = walkStats;
+exports.wrapPeerConnectionEvent = wrapPeerConnectionEvent;
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+var logDisabled_ = true;
+var deprecationWarnings_ = true;
+
+/**
+ * Extract browser version out of the provided user agent string.
+ *
+ * @param {!string} uastring userAgent string.
+ * @param {!string} expr Regular expression used as match criteria.
+ * @param {!number} pos position in the version string to be returned.
+ * @return {!number} browser version.
+ */
+function extractVersion(uastring, expr, pos) {
+ var match = uastring.match(expr);
+ return match && match.length >= pos && parseInt(match[pos], 10);
+}
+
+// Wraps the peerconnection event eventNameToWrap in a function
+// which returns the modified event object (or false to prevent
+// the event).
+function wrapPeerConnectionEvent(window, eventNameToWrap, wrapper) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ var proto = window.RTCPeerConnection.prototype;
+ var nativeAddEventListener = proto.addEventListener;
+ proto.addEventListener = function (nativeEventName, cb) {
+ if (nativeEventName !== eventNameToWrap) {
+ return nativeAddEventListener.apply(this, arguments);
+ }
+ var wrappedCallback = function wrappedCallback(e) {
+ var modifiedEvent = wrapper(e);
+ if (modifiedEvent) {
+ if (cb.handleEvent) {
+ cb.handleEvent(modifiedEvent);
+ } else {
+ cb(modifiedEvent);
+ }
+ }
+ };
+ this._eventMap = this._eventMap || {};
+ if (!this._eventMap[eventNameToWrap]) {
+ this._eventMap[eventNameToWrap] = new Map();
+ }
+ this._eventMap[eventNameToWrap].set(cb, wrappedCallback);
+ return nativeAddEventListener.apply(this, [nativeEventName, wrappedCallback]);
+ };
+ var nativeRemoveEventListener = proto.removeEventListener;
+ proto.removeEventListener = function (nativeEventName, cb) {
+ if (nativeEventName !== eventNameToWrap || !this._eventMap || !this._eventMap[eventNameToWrap]) {
+ return nativeRemoveEventListener.apply(this, arguments);
+ }
+ if (!this._eventMap[eventNameToWrap].has(cb)) {
+ return nativeRemoveEventListener.apply(this, arguments);
+ }
+ var unwrappedCb = this._eventMap[eventNameToWrap].get(cb);
+ this._eventMap[eventNameToWrap]["delete"](cb);
+ if (this._eventMap[eventNameToWrap].size === 0) {
+ delete this._eventMap[eventNameToWrap];
+ }
+ if (Object.keys(this._eventMap).length === 0) {
+ delete this._eventMap;
+ }
+ return nativeRemoveEventListener.apply(this, [nativeEventName, unwrappedCb]);
+ };
+ Object.defineProperty(proto, 'on' + eventNameToWrap, {
+ get: function get() {
+ return this['_on' + eventNameToWrap];
+ },
+ set: function set(cb) {
+ if (this['_on' + eventNameToWrap]) {
+ this.removeEventListener(eventNameToWrap, this['_on' + eventNameToWrap]);
+ delete this['_on' + eventNameToWrap];
+ }
+ if (cb) {
+ this.addEventListener(eventNameToWrap, this['_on' + eventNameToWrap] = cb);
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+}
+function disableLog(bool) {
+ if (typeof bool !== 'boolean') {
+ return new Error('Argument type: ' + _typeof(bool) + '. Please use a boolean.');
+ }
+ logDisabled_ = bool;
+ return bool ? 'adapter.js logging disabled' : 'adapter.js logging enabled';
+}
+
+/**
+ * Disable or enable deprecation warnings
+ * @param {!boolean} bool set to true to disable warnings.
+ */
+function disableWarnings(bool) {
+ if (typeof bool !== 'boolean') {
+ return new Error('Argument type: ' + _typeof(bool) + '. Please use a boolean.');
+ }
+ deprecationWarnings_ = !bool;
+ return 'adapter.js deprecation warnings ' + (bool ? 'disabled' : 'enabled');
+}
+function log() {
+ if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object') {
+ if (logDisabled_) {
+ return;
+ }
+ if (typeof console !== 'undefined' && typeof console.log === 'function') {
+ console.log.apply(console, arguments);
+ }
+ }
+}
+
+/**
+ * Shows a deprecation warning suggesting the modern and spec-compatible API.
+ */
+function deprecated(oldMethod, newMethod) {
+ if (!deprecationWarnings_) {
+ return;
+ }
+ console.warn(oldMethod + ' is deprecated, please use ' + newMethod + ' instead.');
+}
+
+/**
+ * Browser detector.
+ *
+ * @return {object} result containing browser and version
+ * properties.
+ */
+function detectBrowser(window) {
+ // Returned result object.
+ var result = {
+ browser: null,
+ version: null
+ };
+
+ // Fail early if it's not a browser
+ if (typeof window === 'undefined' || !window.navigator || !window.navigator.userAgent) {
+ result.browser = 'Not a browser.';
+ return result;
+ }
+ var navigator = window.navigator;
+ if (navigator.mozGetUserMedia) {
+ // Firefox.
+ result.browser = 'firefox';
+ result.version = extractVersion(navigator.userAgent, /Firefox\/(\d+)\./, 1);
+ } else if (navigator.webkitGetUserMedia || window.isSecureContext === false && window.webkitRTCPeerConnection) {
+ // Chrome, Chromium, Webview, Opera.
+ // Version matches Chrome/WebRTC version.
+ // Chrome 74 removed webkitGetUserMedia on http as well so we need the
+ // more complicated fallback to webkitRTCPeerConnection.
+ result.browser = 'chrome';
+ result.version = extractVersion(navigator.userAgent, /Chrom(e|ium)\/(\d+)\./, 2);
+ } else if (window.RTCPeerConnection && navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) {
+ // Safari.
+ result.browser = 'safari';
+ result.version = extractVersion(navigator.userAgent, /AppleWebKit\/(\d+)\./, 1);
+ result.supportsUnifiedPlan = window.RTCRtpTransceiver && 'currentDirection' in window.RTCRtpTransceiver.prototype;
+ } else {
+ // Default fallthrough: not supported.
+ result.browser = 'Not a supported browser.';
+ return result;
+ }
+ return result;
+}
+
+/**
+ * Checks if something is an object.
+ *
+ * @param {*} val The something you want to check.
+ * @return true if val is an object, false otherwise.
+ */
+function isObject(val) {
+ return Object.prototype.toString.call(val) === '[object Object]';
+}
+
+/**
+ * Remove all empty objects and undefined values
+ * from a nested object -- an enhanced and vanilla version
+ * of Lodash's `compact`.
+ */
+function compactObject(data) {
+ if (!isObject(data)) {
+ return data;
+ }
+ return Object.keys(data).reduce(function (accumulator, key) {
+ var isObj = isObject(data[key]);
+ var value = isObj ? compactObject(data[key]) : data[key];
+ var isEmptyObject = isObj && !Object.keys(value).length;
+ if (value === undefined || isEmptyObject) {
+ return accumulator;
+ }
+ return Object.assign(accumulator, _defineProperty({}, key, value));
+ }, {});
+}
+
+/* iterates the stats graph recursively. */
+function walkStats(stats, base, resultSet) {
+ if (!base || resultSet.has(base.id)) {
+ return;
+ }
+ resultSet.set(base.id, base);
+ Object.keys(base).forEach(function (name) {
+ if (name.endsWith('Id')) {
+ walkStats(stats, stats.get(base[name]), resultSet);
+ } else if (name.endsWith('Ids')) {
+ base[name].forEach(function (id) {
+ walkStats(stats, stats.get(id), resultSet);
+ });
+ }
+ });
+}
+
+/* filter getStats for a sender/receiver track. */
+function filterStats(result, track, outbound) {
+ var streamStatsType = outbound ? 'outbound-rtp' : 'inbound-rtp';
+ var filteredResult = new Map();
+ if (track === null) {
+ return filteredResult;
+ }
+ var trackStats = [];
+ result.forEach(function (value) {
+ if (value.type === 'track' && value.trackIdentifier === track.id) {
+ trackStats.push(value);
+ }
+ });
+ trackStats.forEach(function (trackStat) {
+ result.forEach(function (stats) {
+ if (stats.type === streamStatsType && stats.trackId === trackStat.id) {
+ walkStats(result, stats, filteredResult);
+ }
+ });
+ });
+ return filteredResult;
+}
+
+},{}],12:[function(require,module,exports){
+/* eslint-env node */
+'use strict';
+
+// SDP helpers.
+
+var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
+
+var SDPUtils = {};
+
+// Generate an alphanumeric identifier for cname or mids.
+// TODO: use UUIDs instead? https://gist.github.com/jed/982883
+SDPUtils.generateIdentifier = function () {
+ return Math.random().toString(36).substring(2, 12);
+};
+
+// The RTCP CNAME used by all peerconnections from the same JS.
+SDPUtils.localCName = SDPUtils.generateIdentifier();
+
+// Splits SDP into lines, dealing with both CRLF and LF.
+SDPUtils.splitLines = function (blob) {
+ return blob.trim().split('\n').map(function (line) {
+ return line.trim();
+ });
+};
+// Splits SDP into sessionpart and mediasections. Ensures CRLF.
+SDPUtils.splitSections = function (blob) {
+ var parts = blob.split('\nm=');
+ return parts.map(function (part, index) {
+ return (index > 0 ? 'm=' + part : part).trim() + '\r\n';
+ });
+};
+
+// Returns the session description.
+SDPUtils.getDescription = function (blob) {
+ var sections = SDPUtils.splitSections(blob);
+ return sections && sections[0];
+};
+
+// Returns the individual media sections.
+SDPUtils.getMediaSections = function (blob) {
+ var sections = SDPUtils.splitSections(blob);
+ sections.shift();
+ return sections;
+};
+
+// Returns lines that start with a certain prefix.
+SDPUtils.matchPrefix = function (blob, prefix) {
+ return SDPUtils.splitLines(blob).filter(function (line) {
+ return line.indexOf(prefix) === 0;
+ });
+};
+
+// Parses an ICE candidate line. Sample input:
+// candidate:702786350 2 udp 41819902 8.8.8.8 60769 typ relay raddr 8.8.8.8
+// rport 55996"
+// Input can be prefixed with a=.
+SDPUtils.parseCandidate = function (line) {
+ var parts = void 0;
+ // Parse both variants.
+ if (line.indexOf('a=candidate:') === 0) {
+ parts = line.substring(12).split(' ');
+ } else {
+ parts = line.substring(10).split(' ');
+ }
+
+ var candidate = {
+ foundation: parts[0],
+ component: { 1: 'rtp', 2: 'rtcp' }[parts[1]] || parts[1],
+ protocol: parts[2].toLowerCase(),
+ priority: parseInt(parts[3], 10),
+ ip: parts[4],
+ address: parts[4], // address is an alias for ip.
+ port: parseInt(parts[5], 10),
+ // skip parts[6] == 'typ'
+ type: parts[7]
+ };
+
+ for (var i = 8; i < parts.length; i += 2) {
+ switch (parts[i]) {
+ case 'raddr':
+ candidate.relatedAddress = parts[i + 1];
+ break;
+ case 'rport':
+ candidate.relatedPort = parseInt(parts[i + 1], 10);
+ break;
+ case 'tcptype':
+ candidate.tcpType = parts[i + 1];
+ break;
+ case 'ufrag':
+ candidate.ufrag = parts[i + 1]; // for backward compatibility.
+ candidate.usernameFragment = parts[i + 1];
+ break;
+ default:
+ // extension handling, in particular ufrag. Don't overwrite.
+ if (candidate[parts[i]] === undefined) {
+ candidate[parts[i]] = parts[i + 1];
+ }
+ break;
+ }
+ }
+ return candidate;
+};
+
+// Translates a candidate object into SDP candidate attribute.
+// This does not include the a= prefix!
+SDPUtils.writeCandidate = function (candidate) {
+ var sdp = [];
+ sdp.push(candidate.foundation);
+
+ var component = candidate.component;
+ if (component === 'rtp') {
+ sdp.push(1);
+ } else if (component === 'rtcp') {
+ sdp.push(2);
+ } else {
+ sdp.push(component);
+ }
+ sdp.push(candidate.protocol.toUpperCase());
+ sdp.push(candidate.priority);
+ sdp.push(candidate.address || candidate.ip);
+ sdp.push(candidate.port);
+
+ var type = candidate.type;
+ sdp.push('typ');
+ sdp.push(type);
+ if (type !== 'host' && candidate.relatedAddress && candidate.relatedPort) {
+ sdp.push('raddr');
+ sdp.push(candidate.relatedAddress);
+ sdp.push('rport');
+ sdp.push(candidate.relatedPort);
+ }
+ if (candidate.tcpType && candidate.protocol.toLowerCase() === 'tcp') {
+ sdp.push('tcptype');
+ sdp.push(candidate.tcpType);
+ }
+ if (candidate.usernameFragment || candidate.ufrag) {
+ sdp.push('ufrag');
+ sdp.push(candidate.usernameFragment || candidate.ufrag);
+ }
+ return 'candidate:' + sdp.join(' ');
+};
+
+// Parses an ice-options line, returns an array of option tags.
+// Sample input:
+// a=ice-options:foo bar
+SDPUtils.parseIceOptions = function (line) {
+ return line.substring(14).split(' ');
+};
+
+// Parses a rtpmap line, returns RTCRtpCoddecParameters. Sample input:
+// a=rtpmap:111 opus/48000/2
+SDPUtils.parseRtpMap = function (line) {
+ var parts = line.substring(9).split(' ');
+ var parsed = {
+ payloadType: parseInt(parts.shift(), 10) // was: id
+ };
+
+ parts = parts[0].split('/');
+
+ parsed.name = parts[0];
+ parsed.clockRate = parseInt(parts[1], 10); // was: clockrate
+ parsed.channels = parts.length === 3 ? parseInt(parts[2], 10) : 1;
+ // legacy alias, got renamed back to channels in ORTC.
+ parsed.numChannels = parsed.channels;
+ return parsed;
+};
+
+// Generates a rtpmap line from RTCRtpCodecCapability or
+// RTCRtpCodecParameters.
+SDPUtils.writeRtpMap = function (codec) {
+ var pt = codec.payloadType;
+ if (codec.preferredPayloadType !== undefined) {
+ pt = codec.preferredPayloadType;
+ }
+ var channels = codec.channels || codec.numChannels || 1;
+ return 'a=rtpmap:' + pt + ' ' + codec.name + '/' + codec.clockRate + (channels !== 1 ? '/' + channels : '') + '\r\n';
+};
+
+// Parses a extmap line (headerextension from RFC 5285). Sample input:
+// a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
+// a=extmap:2/sendonly urn:ietf:params:rtp-hdrext:toffset
+SDPUtils.parseExtmap = function (line) {
+ var parts = line.substring(9).split(' ');
+ return {
+ id: parseInt(parts[0], 10),
+ direction: parts[0].indexOf('/') > 0 ? parts[0].split('/')[1] : 'sendrecv',
+ uri: parts[1],
+ attributes: parts.slice(2).join(' ')
+ };
+};
+
+// Generates an extmap line from RTCRtpHeaderExtensionParameters or
+// RTCRtpHeaderExtension.
+SDPUtils.writeExtmap = function (headerExtension) {
+ return 'a=extmap:' + (headerExtension.id || headerExtension.preferredId) + (headerExtension.direction && headerExtension.direction !== 'sendrecv' ? '/' + headerExtension.direction : '') + ' ' + headerExtension.uri + (headerExtension.attributes ? ' ' + headerExtension.attributes : '') + '\r\n';
+};
+
+// Parses a fmtp line, returns dictionary. Sample input:
+// a=fmtp:96 vbr=on;cng=on
+// Also deals with vbr=on; cng=on
+SDPUtils.parseFmtp = function (line) {
+ var parsed = {};
+ var kv = void 0;
+ var parts = line.substring(line.indexOf(' ') + 1).split(';');
+ for (var j = 0; j < parts.length; j++) {
+ kv = parts[j].trim().split('=');
+ parsed[kv[0].trim()] = kv[1];
+ }
+ return parsed;
+};
+
+// Generates a fmtp line from RTCRtpCodecCapability or RTCRtpCodecParameters.
+SDPUtils.writeFmtp = function (codec) {
+ var line = '';
+ var pt = codec.payloadType;
+ if (codec.preferredPayloadType !== undefined) {
+ pt = codec.preferredPayloadType;
+ }
+ if (codec.parameters && Object.keys(codec.parameters).length) {
+ var params = [];
+ Object.keys(codec.parameters).forEach(function (param) {
+ if (codec.parameters[param] !== undefined) {
+ params.push(param + '=' + codec.parameters[param]);
+ } else {
+ params.push(param);
+ }
+ });
+ line += 'a=fmtp:' + pt + ' ' + params.join(';') + '\r\n';
+ }
+ return line;
+};
+
+// Parses a rtcp-fb line, returns RTCPRtcpFeedback object. Sample input:
+// a=rtcp-fb:98 nack rpsi
+SDPUtils.parseRtcpFb = function (line) {
+ var parts = line.substring(line.indexOf(' ') + 1).split(' ');
+ return {
+ type: parts.shift(),
+ parameter: parts.join(' ')
+ };
+};
+
+// Generate a=rtcp-fb lines from RTCRtpCodecCapability or RTCRtpCodecParameters.
+SDPUtils.writeRtcpFb = function (codec) {
+ var lines = '';
+ var pt = codec.payloadType;
+ if (codec.preferredPayloadType !== undefined) {
+ pt = codec.preferredPayloadType;
+ }
+ if (codec.rtcpFeedback && codec.rtcpFeedback.length) {
+ // FIXME: special handling for trr-int?
+ codec.rtcpFeedback.forEach(function (fb) {
+ lines += 'a=rtcp-fb:' + pt + ' ' + fb.type + (fb.parameter && fb.parameter.length ? ' ' + fb.parameter : '') + '\r\n';
+ });
+ }
+ return lines;
+};
+
+// Parses a RFC 5576 ssrc media attribute. Sample input:
+// a=ssrc:3735928559 cname:something
+SDPUtils.parseSsrcMedia = function (line) {
+ var sp = line.indexOf(' ');
+ var parts = {
+ ssrc: parseInt(line.substring(7, sp), 10)
+ };
+ var colon = line.indexOf(':', sp);
+ if (colon > -1) {
+ parts.attribute = line.substring(sp + 1, colon);
+ parts.value = line.substring(colon + 1);
+ } else {
+ parts.attribute = line.substring(sp + 1);
+ }
+ return parts;
+};
+
+// Parse a ssrc-group line (see RFC 5576). Sample input:
+// a=ssrc-group:semantics 12 34
+SDPUtils.parseSsrcGroup = function (line) {
+ var parts = line.substring(13).split(' ');
+ return {
+ semantics: parts.shift(),
+ ssrcs: parts.map(function (ssrc) {
+ return parseInt(ssrc, 10);
+ })
+ };
+};
+
+// Extracts the MID (RFC 5888) from a media section.
+// Returns the MID or undefined if no mid line was found.
+SDPUtils.getMid = function (mediaSection) {
+ var mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:')[0];
+ if (mid) {
+ return mid.substring(6);
+ }
+};
+
+// Parses a fingerprint line for DTLS-SRTP.
+SDPUtils.parseFingerprint = function (line) {
+ var parts = line.substring(14).split(' ');
+ return {
+ algorithm: parts[0].toLowerCase(), // algorithm is case-sensitive in Edge.
+ value: parts[1].toUpperCase() // the definition is upper-case in RFC 4572.
+ };
+};
+
+// Extracts DTLS parameters from SDP media section or sessionpart.
+// FIXME: for consistency with other functions this should only
+// get the fingerprint line as input. See also getIceParameters.
+SDPUtils.getDtlsParameters = function (mediaSection, sessionpart) {
+ var lines = SDPUtils.matchPrefix(mediaSection + sessionpart, 'a=fingerprint:');
+ // Note: a=setup line is ignored since we use the 'auto' role in Edge.
+ return {
+ role: 'auto',
+ fingerprints: lines.map(SDPUtils.parseFingerprint)
+ };
+};
+
+// Serializes DTLS parameters to SDP.
+SDPUtils.writeDtlsParameters = function (params, setupType) {
+ var sdp = 'a=setup:' + setupType + '\r\n';
+ params.fingerprints.forEach(function (fp) {
+ sdp += 'a=fingerprint:' + fp.algorithm + ' ' + fp.value + '\r\n';
+ });
+ return sdp;
+};
+
+// Parses a=crypto lines into
+// https://rawgit.com/aboba/edgertc/master/msortc-rs4.html#dictionary-rtcsrtpsdesparameters-members
+SDPUtils.parseCryptoLine = function (line) {
+ var parts = line.substring(9).split(' ');
+ return {
+ tag: parseInt(parts[0], 10),
+ cryptoSuite: parts[1],
+ keyParams: parts[2],
+ sessionParams: parts.slice(3)
+ };
+};
+
+SDPUtils.writeCryptoLine = function (parameters) {
+ return 'a=crypto:' + parameters.tag + ' ' + parameters.cryptoSuite + ' ' + (_typeof(parameters.keyParams) === 'object' ? SDPUtils.writeCryptoKeyParams(parameters.keyParams) : parameters.keyParams) + (parameters.sessionParams ? ' ' + parameters.sessionParams.join(' ') : '') + '\r\n';
+};
+
+// Parses the crypto key parameters into
+// https://rawgit.com/aboba/edgertc/master/msortc-rs4.html#rtcsrtpkeyparam*
+SDPUtils.parseCryptoKeyParams = function (keyParams) {
+ if (keyParams.indexOf('inline:') !== 0) {
+ return null;
+ }
+ var parts = keyParams.substring(7).split('|');
+ return {
+ keyMethod: 'inline',
+ keySalt: parts[0],
+ lifeTime: parts[1],
+ mkiValue: parts[2] ? parts[2].split(':')[0] : undefined,
+ mkiLength: parts[2] ? parts[2].split(':')[1] : undefined
+ };
+};
+
+SDPUtils.writeCryptoKeyParams = function (keyParams) {
+ return keyParams.keyMethod + ':' + keyParams.keySalt + (keyParams.lifeTime ? '|' + keyParams.lifeTime : '') + (keyParams.mkiValue && keyParams.mkiLength ? '|' + keyParams.mkiValue + ':' + keyParams.mkiLength : '');
+};
+
+// Extracts all SDES parameters.
+SDPUtils.getCryptoParameters = function (mediaSection, sessionpart) {
+ var lines = SDPUtils.matchPrefix(mediaSection + sessionpart, 'a=crypto:');
+ return lines.map(SDPUtils.parseCryptoLine);
+};
+
+// Parses ICE information from SDP media section or sessionpart.
+// FIXME: for consistency with other functions this should only
+// get the ice-ufrag and ice-pwd lines as input.
+SDPUtils.getIceParameters = function (mediaSection, sessionpart) {
+ var ufrag = SDPUtils.matchPrefix(mediaSection + sessionpart, 'a=ice-ufrag:')[0];
+ var pwd = SDPUtils.matchPrefix(mediaSection + sessionpart, 'a=ice-pwd:')[0];
+ if (!(ufrag && pwd)) {
+ return null;
+ }
+ return {
+ usernameFragment: ufrag.substring(12),
+ password: pwd.substring(10)
+ };
+};
+
+// Serializes ICE parameters to SDP.
+SDPUtils.writeIceParameters = function (params) {
+ var sdp = 'a=ice-ufrag:' + params.usernameFragment + '\r\n' + 'a=ice-pwd:' + params.password + '\r\n';
+ if (params.iceLite) {
+ sdp += 'a=ice-lite\r\n';
+ }
+ return sdp;
+};
+
+// Parses the SDP media section and returns RTCRtpParameters.
+SDPUtils.parseRtpParameters = function (mediaSection) {
+ var description = {
+ codecs: [],
+ headerExtensions: [],
+ fecMechanisms: [],
+ rtcp: []
+ };
+ var lines = SDPUtils.splitLines(mediaSection);
+ var mline = lines[0].split(' ');
+ description.profile = mline[2];
+ for (var i = 3; i < mline.length; i++) {
+ // find all codecs from mline[3..]
+ var pt = mline[i];
+ var rtpmapline = SDPUtils.matchPrefix(mediaSection, 'a=rtpmap:' + pt + ' ')[0];
+ if (rtpmapline) {
+ var codec = SDPUtils.parseRtpMap(rtpmapline);
+ var fmtps = SDPUtils.matchPrefix(mediaSection, 'a=fmtp:' + pt + ' ');
+ // Only the first a=fmtp: is considered.
+ codec.parameters = fmtps.length ? SDPUtils.parseFmtp(fmtps[0]) : {};
+ codec.rtcpFeedback = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-fb:' + pt + ' ').map(SDPUtils.parseRtcpFb);
+ description.codecs.push(codec);
+ // parse FEC mechanisms from rtpmap lines.
+ switch (codec.name.toUpperCase()) {
+ case 'RED':
+ case 'ULPFEC':
+ description.fecMechanisms.push(codec.name.toUpperCase());
+ break;
+ default:
+ // only RED and ULPFEC are recognized as FEC mechanisms.
+ break;
+ }
+ }
+ }
+ SDPUtils.matchPrefix(mediaSection, 'a=extmap:').forEach(function (line) {
+ description.headerExtensions.push(SDPUtils.parseExtmap(line));
+ });
+ var wildcardRtcpFb = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-fb:* ').map(SDPUtils.parseRtcpFb);
+ description.codecs.forEach(function (codec) {
+ wildcardRtcpFb.forEach(function (fb) {
+ var duplicate = codec.rtcpFeedback.find(function (existingFeedback) {
+ return existingFeedback.type === fb.type && existingFeedback.parameter === fb.parameter;
+ });
+ if (!duplicate) {
+ codec.rtcpFeedback.push(fb);
+ }
+ });
+ });
+ // FIXME: parse rtcp.
+ return description;
+};
+
+// Generates parts of the SDP media section describing the capabilities /
+// parameters.
+SDPUtils.writeRtpDescription = function (kind, caps) {
+ var sdp = '';
+
+ // Build the mline.
+ sdp += 'm=' + kind + ' ';
+ sdp += caps.codecs.length > 0 ? '9' : '0'; // reject if no codecs.
+ sdp += ' ' + (caps.profile || 'UDP/TLS/RTP/SAVPF') + ' ';
+ sdp += caps.codecs.map(function (codec) {
+ if (codec.preferredPayloadType !== undefined) {
+ return codec.preferredPayloadType;
+ }
+ return codec.payloadType;
+ }).join(' ') + '\r\n';
+
+ sdp += 'c=IN IP4 0.0.0.0\r\n';
+ sdp += 'a=rtcp:9 IN IP4 0.0.0.0\r\n';
+
+ // Add a=rtpmap lines for each codec. Also fmtp and rtcp-fb.
+ caps.codecs.forEach(function (codec) {
+ sdp += SDPUtils.writeRtpMap(codec);
+ sdp += SDPUtils.writeFmtp(codec);
+ sdp += SDPUtils.writeRtcpFb(codec);
+ });
+ var maxptime = 0;
+ caps.codecs.forEach(function (codec) {
+ if (codec.maxptime > maxptime) {
+ maxptime = codec.maxptime;
+ }
+ });
+ if (maxptime > 0) {
+ sdp += 'a=maxptime:' + maxptime + '\r\n';
+ }
+
+ if (caps.headerExtensions) {
+ caps.headerExtensions.forEach(function (extension) {
+ sdp += SDPUtils.writeExtmap(extension);
+ });
+ }
+ // FIXME: write fecMechanisms.
+ return sdp;
+};
+
+// Parses the SDP media section and returns an array of
+// RTCRtpEncodingParameters.
+SDPUtils.parseRtpEncodingParameters = function (mediaSection) {
+ var encodingParameters = [];
+ var description = SDPUtils.parseRtpParameters(mediaSection);
+ var hasRed = description.fecMechanisms.indexOf('RED') !== -1;
+ var hasUlpfec = description.fecMechanisms.indexOf('ULPFEC') !== -1;
+
+ // filter a=ssrc:... cname:, ignore PlanB-msid
+ var ssrcs = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:').map(function (line) {
+ return SDPUtils.parseSsrcMedia(line);
+ }).filter(function (parts) {
+ return parts.attribute === 'cname';
+ });
+ var primarySsrc = ssrcs.length > 0 && ssrcs[0].ssrc;
+ var secondarySsrc = void 0;
+
+ var flows = SDPUtils.matchPrefix(mediaSection, 'a=ssrc-group:FID').map(function (line) {
+ var parts = line.substring(17).split(' ');
+ return parts.map(function (part) {
+ return parseInt(part, 10);
+ });
+ });
+ if (flows.length > 0 && flows[0].length > 1 && flows[0][0] === primarySsrc) {
+ secondarySsrc = flows[0][1];
+ }
+
+ description.codecs.forEach(function (codec) {
+ if (codec.name.toUpperCase() === 'RTX' && codec.parameters.apt) {
+ var encParam = {
+ ssrc: primarySsrc,
+ codecPayloadType: parseInt(codec.parameters.apt, 10)
+ };
+ if (primarySsrc && secondarySsrc) {
+ encParam.rtx = { ssrc: secondarySsrc };
+ }
+ encodingParameters.push(encParam);
+ if (hasRed) {
+ encParam = JSON.parse(JSON.stringify(encParam));
+ encParam.fec = {
+ ssrc: primarySsrc,
+ mechanism: hasUlpfec ? 'red+ulpfec' : 'red'
+ };
+ encodingParameters.push(encParam);
+ }
+ }
+ });
+ if (encodingParameters.length === 0 && primarySsrc) {
+ encodingParameters.push({
+ ssrc: primarySsrc
+ });
+ }
+
+ // we support both b=AS and b=TIAS but interpret AS as TIAS.
+ var bandwidth = SDPUtils.matchPrefix(mediaSection, 'b=');
+ if (bandwidth.length) {
+ if (bandwidth[0].indexOf('b=TIAS:') === 0) {
+ bandwidth = parseInt(bandwidth[0].substring(7), 10);
+ } else if (bandwidth[0].indexOf('b=AS:') === 0) {
+ // use formula from JSEP to convert b=AS to TIAS value.
+ bandwidth = parseInt(bandwidth[0].substring(5), 10) * 1000 * 0.95 - 50 * 40 * 8;
+ } else {
+ bandwidth = undefined;
+ }
+ encodingParameters.forEach(function (params) {
+ params.maxBitrate = bandwidth;
+ });
+ }
+ return encodingParameters;
+};
+
+// parses http://draft.ortc.org/#rtcrtcpparameters*
+SDPUtils.parseRtcpParameters = function (mediaSection) {
+ var rtcpParameters = {};
+
+ // Gets the first SSRC. Note that with RTX there might be multiple
+ // SSRCs.
+ var remoteSsrc = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:').map(function (line) {
+ return SDPUtils.parseSsrcMedia(line);
+ }).filter(function (obj) {
+ return obj.attribute === 'cname';
+ })[0];
+ if (remoteSsrc) {
+ rtcpParameters.cname = remoteSsrc.value;
+ rtcpParameters.ssrc = remoteSsrc.ssrc;
+ }
+
+ // Edge uses the compound attribute instead of reducedSize
+ // compound is !reducedSize
+ var rsize = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-rsize');
+ rtcpParameters.reducedSize = rsize.length > 0;
+ rtcpParameters.compound = rsize.length === 0;
+
+ // parses the rtcp-mux attrіbute.
+ // Note that Edge does not support unmuxed RTCP.
+ var mux = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-mux');
+ rtcpParameters.mux = mux.length > 0;
+
+ return rtcpParameters;
+};
+
+SDPUtils.writeRtcpParameters = function (rtcpParameters) {
+ var sdp = '';
+ if (rtcpParameters.reducedSize) {
+ sdp += 'a=rtcp-rsize\r\n';
+ }
+ if (rtcpParameters.mux) {
+ sdp += 'a=rtcp-mux\r\n';
+ }
+ if (rtcpParameters.ssrc !== undefined && rtcpParameters.cname) {
+ sdp += 'a=ssrc:' + rtcpParameters.ssrc + ' cname:' + rtcpParameters.cname + '\r\n';
+ }
+ return sdp;
+};
+
+// parses either a=msid: or a=ssrc:... msid lines and returns
+// the id of the MediaStream and MediaStreamTrack.
+SDPUtils.parseMsid = function (mediaSection) {
+ var parts = void 0;
+ var spec = SDPUtils.matchPrefix(mediaSection, 'a=msid:');
+ if (spec.length === 1) {
+ parts = spec[0].substring(7).split(' ');
+ return { stream: parts[0], track: parts[1] };
+ }
+ var planB = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:').map(function (line) {
+ return SDPUtils.parseSsrcMedia(line);
+ }).filter(function (msidParts) {
+ return msidParts.attribute === 'msid';
+ });
+ if (planB.length > 0) {
+ parts = planB[0].value.split(' ');
+ return { stream: parts[0], track: parts[1] };
+ }
+};
+
+// SCTP
+// parses draft-ietf-mmusic-sctp-sdp-26 first and falls back
+// to draft-ietf-mmusic-sctp-sdp-05
+SDPUtils.parseSctpDescription = function (mediaSection) {
+ var mline = SDPUtils.parseMLine(mediaSection);
+ var maxSizeLine = SDPUtils.matchPrefix(mediaSection, 'a=max-message-size:');
+ var maxMessageSize = void 0;
+ if (maxSizeLine.length > 0) {
+ maxMessageSize = parseInt(maxSizeLine[0].substring(19), 10);
+ }
+ if (isNaN(maxMessageSize)) {
+ maxMessageSize = 65536;
+ }
+ var sctpPort = SDPUtils.matchPrefix(mediaSection, 'a=sctp-port:');
+ if (sctpPort.length > 0) {
+ return {
+ port: parseInt(sctpPort[0].substring(12), 10),
+ protocol: mline.fmt,
+ maxMessageSize: maxMessageSize
+ };
+ }
+ var sctpMapLines = SDPUtils.matchPrefix(mediaSection, 'a=sctpmap:');
+ if (sctpMapLines.length > 0) {
+ var parts = sctpMapLines[0].substring(10).split(' ');
+ return {
+ port: parseInt(parts[0], 10),
+ protocol: parts[1],
+ maxMessageSize: maxMessageSize
+ };
+ }
+};
+
+// SCTP
+// outputs the draft-ietf-mmusic-sctp-sdp-26 version that all browsers
+// support by now receiving in this format, unless we originally parsed
+// as the draft-ietf-mmusic-sctp-sdp-05 format (indicated by the m-line
+// protocol of DTLS/SCTP -- without UDP/ or TCP/)
+SDPUtils.writeSctpDescription = function (media, sctp) {
+ var output = [];
+ if (media.protocol !== 'DTLS/SCTP') {
+ output = ['m=' + media.kind + ' 9 ' + media.protocol + ' ' + sctp.protocol + '\r\n', 'c=IN IP4 0.0.0.0\r\n', 'a=sctp-port:' + sctp.port + '\r\n'];
+ } else {
+ output = ['m=' + media.kind + ' 9 ' + media.protocol + ' ' + sctp.port + '\r\n', 'c=IN IP4 0.0.0.0\r\n', 'a=sctpmap:' + sctp.port + ' ' + sctp.protocol + ' 65535\r\n'];
+ }
+ if (sctp.maxMessageSize !== undefined) {
+ output.push('a=max-message-size:' + sctp.maxMessageSize + '\r\n');
+ }
+ return output.join('');
+};
+
+// Generate a session ID for SDP.
+// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-20#section-5.2.1
+// recommends using a cryptographically random +ve 64-bit value
+// but right now this should be acceptable and within the right range
+SDPUtils.generateSessionId = function () {
+ return Math.random().toString().substr(2, 22);
+};
+
+// Write boiler plate for start of SDP
+// sessId argument is optional - if not supplied it will
+// be generated randomly
+// sessVersion is optional and defaults to 2
+// sessUser is optional and defaults to 'thisisadapterortc'
+SDPUtils.writeSessionBoilerplate = function (sessId, sessVer, sessUser) {
+ var sessionId = void 0;
+ var version = sessVer !== undefined ? sessVer : 2;
+ if (sessId) {
+ sessionId = sessId;
+ } else {
+ sessionId = SDPUtils.generateSessionId();
+ }
+ var user = sessUser || 'thisisadapterortc';
+ // FIXME: sess-id should be an NTP timestamp.
+ return 'v=0\r\n' + 'o=' + user + ' ' + sessionId + ' ' + version + ' IN IP4 127.0.0.1\r\n' + 's=-\r\n' + 't=0 0\r\n';
+};
+
+// Gets the direction from the mediaSection or the sessionpart.
+SDPUtils.getDirection = function (mediaSection, sessionpart) {
+ // Look for sendrecv, sendonly, recvonly, inactive, default to sendrecv.
+ var lines = SDPUtils.splitLines(mediaSection);
+ for (var i = 0; i < lines.length; i++) {
+ switch (lines[i]) {
+ case 'a=sendrecv':
+ case 'a=sendonly':
+ case 'a=recvonly':
+ case 'a=inactive':
+ return lines[i].substring(2);
+ default:
+ // FIXME: What should happen here?
+ }
+ }
+ if (sessionpart) {
+ return SDPUtils.getDirection(sessionpart);
+ }
+ return 'sendrecv';
+};
+
+SDPUtils.getKind = function (mediaSection) {
+ var lines = SDPUtils.splitLines(mediaSection);
+ var mline = lines[0].split(' ');
+ return mline[0].substring(2);
+};
+
+SDPUtils.isRejected = function (mediaSection) {
+ return mediaSection.split(' ', 2)[1] === '0';
+};
+
+SDPUtils.parseMLine = function (mediaSection) {
+ var lines = SDPUtils.splitLines(mediaSection);
+ var parts = lines[0].substring(2).split(' ');
+ return {
+ kind: parts[0],
+ port: parseInt(parts[1], 10),
+ protocol: parts[2],
+ fmt: parts.slice(3).join(' ')
+ };
+};
+
+SDPUtils.parseOLine = function (mediaSection) {
+ var line = SDPUtils.matchPrefix(mediaSection, 'o=')[0];
+ var parts = line.substring(2).split(' ');
+ return {
+ username: parts[0],
+ sessionId: parts[1],
+ sessionVersion: parseInt(parts[2], 10),
+ netType: parts[3],
+ addressType: parts[4],
+ address: parts[5]
+ };
+};
+
+// a very naive interpretation of a valid SDP.
+SDPUtils.isValidSDP = function (blob) {
+ if (typeof blob !== 'string' || blob.length === 0) {
+ return false;
+ }
+ var lines = SDPUtils.splitLines(blob);
+ for (var i = 0; i < lines.length; i++) {
+ if (lines[i].length < 2 || lines[i].charAt(1) !== '=') {
+ return false;
+ }
+ // TODO: check the modifier a bit more.
+ }
+ return true;
+};
+
+// Expose public methods.
+if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object') {
+ module.exports = SDPUtils;
+}
+},{}]},{},[1])(1)
+});
diff --git a/node_modules/webrtc-adapter/out/adapter_no_global.js b/node_modules/webrtc-adapter/out/adapter_no_global.js
new file mode 100644
index 0000000..dd390fb
--- /dev/null
+++ b/node_modules/webrtc-adapter/out/adapter_no_global.js
@@ -0,0 +1,3363 @@
+(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0 && arguments[0] !== undefined ? arguments[0] : {},
+ window = _ref.window;
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
+ shimChrome: true,
+ shimFirefox: true,
+ shimSafari: true
+ };
+ // Utils.
+ var logging = utils.log;
+ var browserDetails = utils.detectBrowser(window);
+ var adapter = {
+ browserDetails: browserDetails,
+ commonShim: commonShim,
+ extractVersion: utils.extractVersion,
+ disableLog: utils.disableLog,
+ disableWarnings: utils.disableWarnings,
+ // Expose sdp as a convenience. For production apps include directly.
+ sdp: sdp
+ };
+
+ // Shim browser if found.
+ switch (browserDetails.browser) {
+ case 'chrome':
+ if (!chromeShim || !chromeShim.shimPeerConnection || !options.shimChrome) {
+ logging('Chrome shim is not included in this adapter release.');
+ return adapter;
+ }
+ if (browserDetails.version === null) {
+ logging('Chrome shim can not determine version, not shimming.');
+ return adapter;
+ }
+ logging('adapter.js shimming chrome.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = chromeShim;
+
+ // Must be called before shimPeerConnection.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+ chromeShim.shimGetUserMedia(window, browserDetails);
+ chromeShim.shimMediaStream(window, browserDetails);
+ chromeShim.shimPeerConnection(window, browserDetails);
+ chromeShim.shimOnTrack(window, browserDetails);
+ chromeShim.shimAddTrackRemoveTrack(window, browserDetails);
+ chromeShim.shimGetSendersWithDtmf(window, browserDetails);
+ chromeShim.shimGetStats(window, browserDetails);
+ chromeShim.shimSenderReceiverGetStats(window, browserDetails);
+ chromeShim.fixNegotiationNeeded(window, browserDetails);
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
+ commonShim.shimConnectionState(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ commonShim.removeExtmapAllowMixed(window, browserDetails);
+ break;
+ case 'firefox':
+ if (!firefoxShim || !firefoxShim.shimPeerConnection || !options.shimFirefox) {
+ logging('Firefox shim is not included in this adapter release.');
+ return adapter;
+ }
+ logging('adapter.js shimming firefox.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = firefoxShim;
+
+ // Must be called before shimPeerConnection.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+ firefoxShim.shimGetUserMedia(window, browserDetails);
+ firefoxShim.shimPeerConnection(window, browserDetails);
+ firefoxShim.shimOnTrack(window, browserDetails);
+ firefoxShim.shimRemoveStream(window, browserDetails);
+ firefoxShim.shimSenderGetStats(window, browserDetails);
+ firefoxShim.shimReceiverGetStats(window, browserDetails);
+ firefoxShim.shimRTCDataChannel(window, browserDetails);
+ firefoxShim.shimAddTransceiver(window, browserDetails);
+ firefoxShim.shimGetParameters(window, browserDetails);
+ firefoxShim.shimCreateOffer(window, browserDetails);
+ firefoxShim.shimCreateAnswer(window, browserDetails);
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimConnectionState(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ break;
+ case 'safari':
+ if (!safariShim || !options.shimSafari) {
+ logging('Safari shim is not included in this adapter release.');
+ return adapter;
+ }
+ logging('adapter.js shimming safari.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = safariShim;
+
+ // Must be called before shimCallbackAPI.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+ safariShim.shimRTCIceServerUrls(window, browserDetails);
+ safariShim.shimCreateOfferLegacy(window, browserDetails);
+ safariShim.shimCallbacksAPI(window, browserDetails);
+ safariShim.shimLocalStreamsAPI(window, browserDetails);
+ safariShim.shimRemoteStreamsAPI(window, browserDetails);
+ safariShim.shimTrackEventTransceiver(window, browserDetails);
+ safariShim.shimGetUserMedia(window, browserDetails);
+ safariShim.shimAudioContext(window, browserDetails);
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ commonShim.removeExtmapAllowMixed(window, browserDetails);
+ break;
+ default:
+ logging('Unsupported browser!');
+ break;
+ }
+ return adapter;
+}
+
+},{"./chrome/chrome_shim":3,"./common_shim":6,"./firefox/firefox_shim":7,"./safari/safari_shim":10,"./utils":11,"sdp":12}],3:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.fixNegotiationNeeded = fixNegotiationNeeded;
+exports.shimAddTrackRemoveTrack = shimAddTrackRemoveTrack;
+exports.shimAddTrackRemoveTrackWithNative = shimAddTrackRemoveTrackWithNative;
+Object.defineProperty(exports, "shimGetDisplayMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getdisplaymedia.shimGetDisplayMedia;
+ }
+});
+exports.shimGetSendersWithDtmf = shimGetSendersWithDtmf;
+exports.shimGetStats = shimGetStats;
+Object.defineProperty(exports, "shimGetUserMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getusermedia.shimGetUserMedia;
+ }
+});
+exports.shimMediaStream = shimMediaStream;
+exports.shimOnTrack = shimOnTrack;
+exports.shimPeerConnection = shimPeerConnection;
+exports.shimSenderReceiverGetStats = shimSenderReceiverGetStats;
+var utils = _interopRequireWildcard(require("../utils.js"));
+var _getusermedia = require("./getusermedia");
+var _getdisplaymedia = require("./getdisplaymedia");
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimMediaStream(window) {
+ window.MediaStream = window.MediaStream || window.webkitMediaStream;
+}
+function shimOnTrack(window) {
+ if (_typeof(window) === 'object' && window.RTCPeerConnection && !('ontrack' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'ontrack', {
+ get: function get() {
+ return this._ontrack;
+ },
+ set: function set(f) {
+ if (this._ontrack) {
+ this.removeEventListener('track', this._ontrack);
+ }
+ this.addEventListener('track', this._ontrack = f);
+ },
+ enumerable: true,
+ configurable: true
+ });
+ var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
+ var _this = this;
+ if (!this._ontrackpoly) {
+ this._ontrackpoly = function (e) {
+ // onaddstream does not fire when a track is added to an existing
+ // stream. But stream.onaddtrack is implemented so we use that.
+ e.stream.addEventListener('addtrack', function (te) {
+ var receiver;
+ if (window.RTCPeerConnection.prototype.getReceivers) {
+ receiver = _this.getReceivers().find(function (r) {
+ return r.track && r.track.id === te.track.id;
+ });
+ } else {
+ receiver = {
+ track: te.track
+ };
+ }
+ var event = new Event('track');
+ event.track = te.track;
+ event.receiver = receiver;
+ event.transceiver = {
+ receiver: receiver
+ };
+ event.streams = [e.stream];
+ _this.dispatchEvent(event);
+ });
+ e.stream.getTracks().forEach(function (track) {
+ var receiver;
+ if (window.RTCPeerConnection.prototype.getReceivers) {
+ receiver = _this.getReceivers().find(function (r) {
+ return r.track && r.track.id === track.id;
+ });
+ } else {
+ receiver = {
+ track: track
+ };
+ }
+ var event = new Event('track');
+ event.track = track;
+ event.receiver = receiver;
+ event.transceiver = {
+ receiver: receiver
+ };
+ event.streams = [e.stream];
+ _this.dispatchEvent(event);
+ });
+ };
+ this.addEventListener('addstream', this._ontrackpoly);
+ }
+ return origSetRemoteDescription.apply(this, arguments);
+ };
+ } else {
+ // even if RTCRtpTransceiver is in window, it is only used and
+ // emitted in unified-plan. Unfortunately this means we need
+ // to unconditionally wrap the event.
+ utils.wrapPeerConnectionEvent(window, 'track', function (e) {
+ if (!e.transceiver) {
+ Object.defineProperty(e, 'transceiver', {
+ value: {
+ receiver: e.receiver
+ }
+ });
+ }
+ return e;
+ });
+ }
+}
+function shimGetSendersWithDtmf(window) {
+ // Overrides addTrack/removeTrack, depends on shimAddTrackRemoveTrack.
+ if (_typeof(window) === 'object' && window.RTCPeerConnection && !('getSenders' in window.RTCPeerConnection.prototype) && 'createDTMFSender' in window.RTCPeerConnection.prototype) {
+ var shimSenderWithDtmf = function shimSenderWithDtmf(pc, track) {
+ return {
+ track: track,
+ get dtmf() {
+ if (this._dtmf === undefined) {
+ if (track.kind === 'audio') {
+ this._dtmf = pc.createDTMFSender(track);
+ } else {
+ this._dtmf = null;
+ }
+ }
+ return this._dtmf;
+ },
+ _pc: pc
+ };
+ };
+
+ // augment addTrack when getSenders is not available.
+ if (!window.RTCPeerConnection.prototype.getSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ this._senders = this._senders || [];
+ return this._senders.slice(); // return a copy of the internal state.
+ };
+
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
+ var sender = origAddTrack.apply(this, arguments);
+ if (!sender) {
+ sender = shimSenderWithDtmf(this, track);
+ this._senders.push(sender);
+ }
+ return sender;
+ };
+ var origRemoveTrack = window.RTCPeerConnection.prototype.removeTrack;
+ window.RTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
+ origRemoveTrack.apply(this, arguments);
+ var idx = this._senders.indexOf(sender);
+ if (idx !== -1) {
+ this._senders.splice(idx, 1);
+ }
+ };
+ }
+ var origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this2 = this;
+ this._senders = this._senders || [];
+ origAddStream.apply(this, [stream]);
+ stream.getTracks().forEach(function (track) {
+ _this2._senders.push(shimSenderWithDtmf(_this2, track));
+ });
+ };
+ var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ var _this3 = this;
+ this._senders = this._senders || [];
+ origRemoveStream.apply(this, [stream]);
+ stream.getTracks().forEach(function (track) {
+ var sender = _this3._senders.find(function (s) {
+ return s.track === track;
+ });
+ if (sender) {
+ // remove sender
+ _this3._senders.splice(_this3._senders.indexOf(sender), 1);
+ }
+ });
+ };
+ } else if (_typeof(window) === 'object' && window.RTCPeerConnection && 'getSenders' in window.RTCPeerConnection.prototype && 'createDTMFSender' in window.RTCPeerConnection.prototype && window.RTCRtpSender && !('dtmf' in window.RTCRtpSender.prototype)) {
+ var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ var _this4 = this;
+ var senders = origGetSenders.apply(this, []);
+ senders.forEach(function (sender) {
+ return sender._pc = _this4;
+ });
+ return senders;
+ };
+ Object.defineProperty(window.RTCRtpSender.prototype, 'dtmf', {
+ get: function get() {
+ if (this._dtmf === undefined) {
+ if (this.track.kind === 'audio') {
+ this._dtmf = this._pc.createDTMFSender(this.track);
+ } else {
+ this._dtmf = null;
+ }
+ }
+ return this._dtmf;
+ }
+ });
+ }
+}
+function shimGetStats(window) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ var origGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ var _this5 = this;
+ var _arguments = Array.prototype.slice.call(arguments),
+ selector = _arguments[0],
+ onSucc = _arguments[1],
+ onErr = _arguments[2];
+
+ // If selector is a function then we are in the old style stats so just
+ // pass back the original getStats format to avoid breaking old users.
+ if (arguments.length > 0 && typeof selector === 'function') {
+ return origGetStats.apply(this, arguments);
+ }
+
+ // When spec-style getStats is supported, return those when called with
+ // either no arguments or the selector argument is null.
+ if (origGetStats.length === 0 && (arguments.length === 0 || typeof selector !== 'function')) {
+ return origGetStats.apply(this, []);
+ }
+ var fixChromeStats_ = function fixChromeStats_(response) {
+ var standardReport = {};
+ var reports = response.result();
+ reports.forEach(function (report) {
+ var standardStats = {
+ id: report.id,
+ timestamp: report.timestamp,
+ type: {
+ localcandidate: 'local-candidate',
+ remotecandidate: 'remote-candidate'
+ }[report.type] || report.type
+ };
+ report.names().forEach(function (name) {
+ standardStats[name] = report.stat(name);
+ });
+ standardReport[standardStats.id] = standardStats;
+ });
+ return standardReport;
+ };
+
+ // shim getStats with maplike support
+ var makeMapStats = function makeMapStats(stats) {
+ return new Map(Object.keys(stats).map(function (key) {
+ return [key, stats[key]];
+ }));
+ };
+ if (arguments.length >= 2) {
+ var successCallbackWrapper_ = function successCallbackWrapper_(response) {
+ onSucc(makeMapStats(fixChromeStats_(response)));
+ };
+ return origGetStats.apply(this, [successCallbackWrapper_, selector]);
+ }
+
+ // promise-support
+ return new Promise(function (resolve, reject) {
+ origGetStats.apply(_this5, [function (response) {
+ resolve(makeMapStats(fixChromeStats_(response)));
+ }, reject]);
+ }).then(onSucc, onErr);
+ };
+}
+function shimSenderReceiverGetStats(window) {
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection && window.RTCRtpSender && window.RTCRtpReceiver)) {
+ return;
+ }
+
+ // shim sender stats.
+ if (!('getStats' in window.RTCRtpSender.prototype)) {
+ var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ if (origGetSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ var _this6 = this;
+ var senders = origGetSenders.apply(this, []);
+ senders.forEach(function (sender) {
+ return sender._pc = _this6;
+ });
+ return senders;
+ };
+ }
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ if (origAddTrack) {
+ window.RTCPeerConnection.prototype.addTrack = function addTrack() {
+ var sender = origAddTrack.apply(this, arguments);
+ sender._pc = this;
+ return sender;
+ };
+ }
+ window.RTCRtpSender.prototype.getStats = function getStats() {
+ var sender = this;
+ return this._pc.getStats().then(function (result) {
+ return (
+ /* Note: this will include stats of all senders that
+ * send a track with the same id as sender.track as
+ * it is not possible to identify the RTCRtpSender.
+ */
+ utils.filterStats(result, sender.track, true)
+ );
+ });
+ };
+ }
+
+ // shim receiver stats.
+ if (!('getStats' in window.RTCRtpReceiver.prototype)) {
+ var origGetReceivers = window.RTCPeerConnection.prototype.getReceivers;
+ if (origGetReceivers) {
+ window.RTCPeerConnection.prototype.getReceivers = function getReceivers() {
+ var _this7 = this;
+ var receivers = origGetReceivers.apply(this, []);
+ receivers.forEach(function (receiver) {
+ return receiver._pc = _this7;
+ });
+ return receivers;
+ };
+ }
+ utils.wrapPeerConnectionEvent(window, 'track', function (e) {
+ e.receiver._pc = e.srcElement;
+ return e;
+ });
+ window.RTCRtpReceiver.prototype.getStats = function getStats() {
+ var receiver = this;
+ return this._pc.getStats().then(function (result) {
+ return utils.filterStats(result, receiver.track, false);
+ });
+ };
+ }
+ if (!('getStats' in window.RTCRtpSender.prototype && 'getStats' in window.RTCRtpReceiver.prototype)) {
+ return;
+ }
+
+ // shim RTCPeerConnection.getStats(track).
+ var origGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ if (arguments.length > 0 && arguments[0] instanceof window.MediaStreamTrack) {
+ var track = arguments[0];
+ var sender;
+ var receiver;
+ var err;
+ this.getSenders().forEach(function (s) {
+ if (s.track === track) {
+ if (sender) {
+ err = true;
+ } else {
+ sender = s;
+ }
+ }
+ });
+ this.getReceivers().forEach(function (r) {
+ if (r.track === track) {
+ if (receiver) {
+ err = true;
+ } else {
+ receiver = r;
+ }
+ }
+ return r.track === track;
+ });
+ if (err || sender && receiver) {
+ return Promise.reject(new DOMException('There are more than one sender or receiver for the track.', 'InvalidAccessError'));
+ } else if (sender) {
+ return sender.getStats();
+ } else if (receiver) {
+ return receiver.getStats();
+ }
+ return Promise.reject(new DOMException('There is no sender or receiver for the track.', 'InvalidAccessError'));
+ }
+ return origGetStats.apply(this, arguments);
+ };
+}
+function shimAddTrackRemoveTrackWithNative(window) {
+ // shim addTrack/removeTrack with native variants in order to make
+ // the interactions with legacy getLocalStreams behave as in other browsers.
+ // Keeps a mapping stream.id => [stream, rtpsenders...]
+ window.RTCPeerConnection.prototype.getLocalStreams = function getLocalStreams() {
+ var _this8 = this;
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ return Object.keys(this._shimmedLocalStreams).map(function (streamId) {
+ return _this8._shimmedLocalStreams[streamId][0];
+ });
+ };
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
+ if (!stream) {
+ return origAddTrack.apply(this, arguments);
+ }
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ var sender = origAddTrack.apply(this, arguments);
+ if (!this._shimmedLocalStreams[stream.id]) {
+ this._shimmedLocalStreams[stream.id] = [stream, sender];
+ } else if (this._shimmedLocalStreams[stream.id].indexOf(sender) === -1) {
+ this._shimmedLocalStreams[stream.id].push(sender);
+ }
+ return sender;
+ };
+ var origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this9 = this;
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ stream.getTracks().forEach(function (track) {
+ var alreadyExists = _this9.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.', 'InvalidAccessError');
+ }
+ });
+ var existingSenders = this.getSenders();
+ origAddStream.apply(this, arguments);
+ var newSenders = this.getSenders().filter(function (newSender) {
+ return existingSenders.indexOf(newSender) === -1;
+ });
+ this._shimmedLocalStreams[stream.id] = [stream].concat(newSenders);
+ };
+ var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ delete this._shimmedLocalStreams[stream.id];
+ return origRemoveStream.apply(this, arguments);
+ };
+ var origRemoveTrack = window.RTCPeerConnection.prototype.removeTrack;
+ window.RTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
+ var _this10 = this;
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ if (sender) {
+ Object.keys(this._shimmedLocalStreams).forEach(function (streamId) {
+ var idx = _this10._shimmedLocalStreams[streamId].indexOf(sender);
+ if (idx !== -1) {
+ _this10._shimmedLocalStreams[streamId].splice(idx, 1);
+ }
+ if (_this10._shimmedLocalStreams[streamId].length === 1) {
+ delete _this10._shimmedLocalStreams[streamId];
+ }
+ });
+ }
+ return origRemoveTrack.apply(this, arguments);
+ };
+}
+function shimAddTrackRemoveTrack(window, browserDetails) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ // shim addTrack and removeTrack.
+ if (window.RTCPeerConnection.prototype.addTrack && browserDetails.version >= 65) {
+ return shimAddTrackRemoveTrackWithNative(window);
+ }
+
+ // also shim pc.getLocalStreams when addTrack is shimmed
+ // to return the original streams.
+ var origGetLocalStreams = window.RTCPeerConnection.prototype.getLocalStreams;
+ window.RTCPeerConnection.prototype.getLocalStreams = function getLocalStreams() {
+ var _this11 = this;
+ var nativeStreams = origGetLocalStreams.apply(this);
+ this._reverseStreams = this._reverseStreams || {};
+ return nativeStreams.map(function (stream) {
+ return _this11._reverseStreams[stream.id];
+ });
+ };
+ var origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this12 = this;
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ stream.getTracks().forEach(function (track) {
+ var alreadyExists = _this12.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.', 'InvalidAccessError');
+ }
+ });
+ // Add identity mapping for consistency with addTrack.
+ // Unless this is being used with a stream from addTrack.
+ if (!this._reverseStreams[stream.id]) {
+ var newStream = new window.MediaStream(stream.getTracks());
+ this._streams[stream.id] = newStream;
+ this._reverseStreams[newStream.id] = stream;
+ stream = newStream;
+ }
+ origAddStream.apply(this, [stream]);
+ };
+ var origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ origRemoveStream.apply(this, [this._streams[stream.id] || stream]);
+ delete this._reverseStreams[this._streams[stream.id] ? this._streams[stream.id].id : stream.id];
+ delete this._streams[stream.id];
+ };
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
+ var _this13 = this;
+ if (this.signalingState === 'closed') {
+ throw new DOMException('The RTCPeerConnection\'s signalingState is \'closed\'.', 'InvalidStateError');
+ }
+ var streams = [].slice.call(arguments, 1);
+ if (streams.length !== 1 || !streams[0].getTracks().find(function (t) {
+ return t === track;
+ })) {
+ // this is not fully correct but all we can manage without
+ // [[associated MediaStreams]] internal slot.
+ throw new DOMException('The adapter.js addTrack polyfill only supports a single ' + ' stream which is associated with the specified track.', 'NotSupportedError');
+ }
+ var alreadyExists = this.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.', 'InvalidAccessError');
+ }
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ var oldStream = this._streams[stream.id];
+ if (oldStream) {
+ // this is using odd Chrome behaviour, use with caution:
+ // https://bugs.chromium.org/p/webrtc/issues/detail?id=7815
+ // Note: we rely on the high-level addTrack/dtmf shim to
+ // create the sender with a dtmf sender.
+ oldStream.addTrack(track);
+
+ // Trigger ONN async.
+ Promise.resolve().then(function () {
+ _this13.dispatchEvent(new Event('negotiationneeded'));
+ });
+ } else {
+ var newStream = new window.MediaStream([track]);
+ this._streams[stream.id] = newStream;
+ this._reverseStreams[newStream.id] = stream;
+ this.addStream(newStream);
+ }
+ return this.getSenders().find(function (s) {
+ return s.track === track;
+ });
+ };
+
+ // replace the internal stream id with the external one and
+ // vice versa.
+ function replaceInternalStreamId(pc, description) {
+ var sdp = description.sdp;
+ Object.keys(pc._reverseStreams || []).forEach(function (internalId) {
+ var externalStream = pc._reverseStreams[internalId];
+ var internalStream = pc._streams[externalStream.id];
+ sdp = sdp.replace(new RegExp(internalStream.id, 'g'), externalStream.id);
+ });
+ return new RTCSessionDescription({
+ type: description.type,
+ sdp: sdp
+ });
+ }
+ function replaceExternalStreamId(pc, description) {
+ var sdp = description.sdp;
+ Object.keys(pc._reverseStreams || []).forEach(function (internalId) {
+ var externalStream = pc._reverseStreams[internalId];
+ var internalStream = pc._streams[externalStream.id];
+ sdp = sdp.replace(new RegExp(externalStream.id, 'g'), internalStream.id);
+ });
+ return new RTCSessionDescription({
+ type: description.type,
+ sdp: sdp
+ });
+ }
+ ['createOffer', 'createAnswer'].forEach(function (method) {
+ var nativeMethod = window.RTCPeerConnection.prototype[method];
+ var methodObj = _defineProperty({}, method, function () {
+ var _this14 = this;
+ var args = arguments;
+ var isLegacyCall = arguments.length && typeof arguments[0] === 'function';
+ if (isLegacyCall) {
+ return nativeMethod.apply(this, [function (description) {
+ var desc = replaceInternalStreamId(_this14, description);
+ args[0].apply(null, [desc]);
+ }, function (err) {
+ if (args[1]) {
+ args[1].apply(null, err);
+ }
+ }, arguments[2]]);
+ }
+ return nativeMethod.apply(this, arguments).then(function (description) {
+ return replaceInternalStreamId(_this14, description);
+ });
+ });
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ var origSetLocalDescription = window.RTCPeerConnection.prototype.setLocalDescription;
+ window.RTCPeerConnection.prototype.setLocalDescription = function setLocalDescription() {
+ if (!arguments.length || !arguments[0].type) {
+ return origSetLocalDescription.apply(this, arguments);
+ }
+ arguments[0] = replaceExternalStreamId(this, arguments[0]);
+ return origSetLocalDescription.apply(this, arguments);
+ };
+
+ // TODO: mangle getStats: https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamstats-streamidentifier
+
+ var origLocalDescription = Object.getOwnPropertyDescriptor(window.RTCPeerConnection.prototype, 'localDescription');
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'localDescription', {
+ get: function get() {
+ var description = origLocalDescription.get.apply(this);
+ if (description.type === '') {
+ return description;
+ }
+ return replaceInternalStreamId(this, description);
+ }
+ });
+ window.RTCPeerConnection.prototype.removeTrack = function removeTrack(sender) {
+ var _this15 = this;
+ if (this.signalingState === 'closed') {
+ throw new DOMException('The RTCPeerConnection\'s signalingState is \'closed\'.', 'InvalidStateError');
+ }
+ // We can not yet check for sender instanceof RTCRtpSender
+ // since we shim RTPSender. So we check if sender._pc is set.
+ if (!sender._pc) {
+ throw new DOMException('Argument 1 of RTCPeerConnection.removeTrack ' + 'does not implement interface RTCRtpSender.', 'TypeError');
+ }
+ var isLocal = sender._pc === this;
+ if (!isLocal) {
+ throw new DOMException('Sender was not created by this connection.', 'InvalidAccessError');
+ }
+
+ // Search for the native stream the senders track belongs to.
+ this._streams = this._streams || {};
+ var stream;
+ Object.keys(this._streams).forEach(function (streamid) {
+ var hasTrack = _this15._streams[streamid].getTracks().find(function (track) {
+ return sender.track === track;
+ });
+ if (hasTrack) {
+ stream = _this15._streams[streamid];
+ }
+ });
+ if (stream) {
+ if (stream.getTracks().length === 1) {
+ // if this is the last track of the stream, remove the stream. This
+ // takes care of any shimmed _senders.
+ this.removeStream(this._reverseStreams[stream.id]);
+ } else {
+ // relying on the same odd chrome behaviour as above.
+ stream.removeTrack(sender.track);
+ }
+ this.dispatchEvent(new Event('negotiationneeded'));
+ }
+ };
+}
+function shimPeerConnection(window, browserDetails) {
+ if (!window.RTCPeerConnection && window.webkitRTCPeerConnection) {
+ // very basic support for old versions.
+ window.RTCPeerConnection = window.webkitRTCPeerConnection;
+ }
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+
+ // shim implicit creation of RTCSessionDescription/RTCIceCandidate
+ if (browserDetails.version < 53) {
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
+ var nativeMethod = window.RTCPeerConnection.prototype[method];
+ var methodObj = _defineProperty({}, method, function () {
+ arguments[0] = new (method === 'addIceCandidate' ? window.RTCIceCandidate : window.RTCSessionDescription)(arguments[0]);
+ return nativeMethod.apply(this, arguments);
+ });
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ }
+}
+
+// Attempt to fix ONN in plan-b mode.
+function fixNegotiationNeeded(window, browserDetails) {
+ utils.wrapPeerConnectionEvent(window, 'negotiationneeded', function (e) {
+ var pc = e.target;
+ if (browserDetails.version < 72 || pc.getConfiguration && pc.getConfiguration().sdpSemantics === 'plan-b') {
+ if (pc.signalingState !== 'stable') {
+ return;
+ }
+ }
+ return e;
+ });
+}
+
+},{"../utils.js":11,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(require,module,exports){
+/*
+ * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetDisplayMedia = shimGetDisplayMedia;
+function shimGetDisplayMedia(window, getSourceId) {
+ if (window.navigator.mediaDevices && 'getDisplayMedia' in window.navigator.mediaDevices) {
+ return;
+ }
+ if (!window.navigator.mediaDevices) {
+ return;
+ }
+ // getSourceId is a function that returns a promise resolving with
+ // the sourceId of the screen/window/tab to be shared.
+ if (typeof getSourceId !== 'function') {
+ console.error('shimGetDisplayMedia: getSourceId argument is not ' + 'a function');
+ return;
+ }
+ window.navigator.mediaDevices.getDisplayMedia = function getDisplayMedia(constraints) {
+ return getSourceId(constraints).then(function (sourceId) {
+ var widthSpecified = constraints.video && constraints.video.width;
+ var heightSpecified = constraints.video && constraints.video.height;
+ var frameRateSpecified = constraints.video && constraints.video.frameRate;
+ constraints.video = {
+ mandatory: {
+ chromeMediaSource: 'desktop',
+ chromeMediaSourceId: sourceId,
+ maxFrameRate: frameRateSpecified || 3
+ }
+ };
+ if (widthSpecified) {
+ constraints.video.mandatory.maxWidth = widthSpecified;
+ }
+ if (heightSpecified) {
+ constraints.video.mandatory.maxHeight = heightSpecified;
+ }
+ return window.navigator.mediaDevices.getUserMedia(constraints);
+ });
+ };
+}
+
+},{}],5:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetUserMedia = shimGetUserMedia;
+var utils = _interopRequireWildcard(require("../utils.js"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+var logging = utils.log;
+function shimGetUserMedia(window, browserDetails) {
+ var navigator = window && window.navigator;
+ if (!navigator.mediaDevices) {
+ return;
+ }
+ var constraintsToChrome_ = function constraintsToChrome_(c) {
+ if (_typeof(c) !== 'object' || c.mandatory || c.optional) {
+ return c;
+ }
+ var cc = {};
+ Object.keys(c).forEach(function (key) {
+ if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
+ return;
+ }
+ var r = _typeof(c[key]) === 'object' ? c[key] : {
+ ideal: c[key]
+ };
+ if (r.exact !== undefined && typeof r.exact === 'number') {
+ r.min = r.max = r.exact;
+ }
+ var oldname_ = function oldname_(prefix, name) {
+ if (prefix) {
+ return prefix + name.charAt(0).toUpperCase() + name.slice(1);
+ }
+ return name === 'deviceId' ? 'sourceId' : name;
+ };
+ if (r.ideal !== undefined) {
+ cc.optional = cc.optional || [];
+ var oc = {};
+ if (typeof r.ideal === 'number') {
+ oc[oldname_('min', key)] = r.ideal;
+ cc.optional.push(oc);
+ oc = {};
+ oc[oldname_('max', key)] = r.ideal;
+ cc.optional.push(oc);
+ } else {
+ oc[oldname_('', key)] = r.ideal;
+ cc.optional.push(oc);
+ }
+ }
+ if (r.exact !== undefined && typeof r.exact !== 'number') {
+ cc.mandatory = cc.mandatory || {};
+ cc.mandatory[oldname_('', key)] = r.exact;
+ } else {
+ ['min', 'max'].forEach(function (mix) {
+ if (r[mix] !== undefined) {
+ cc.mandatory = cc.mandatory || {};
+ cc.mandatory[oldname_(mix, key)] = r[mix];
+ }
+ });
+ }
+ });
+ if (c.advanced) {
+ cc.optional = (cc.optional || []).concat(c.advanced);
+ }
+ return cc;
+ };
+ var shimConstraints_ = function shimConstraints_(constraints, func) {
+ if (browserDetails.version >= 61) {
+ return func(constraints);
+ }
+ constraints = JSON.parse(JSON.stringify(constraints));
+ if (constraints && _typeof(constraints.audio) === 'object') {
+ var remap = function remap(obj, a, b) {
+ if (a in obj && !(b in obj)) {
+ obj[b] = obj[a];
+ delete obj[a];
+ }
+ };
+ constraints = JSON.parse(JSON.stringify(constraints));
+ remap(constraints.audio, 'autoGainControl', 'googAutoGainControl');
+ remap(constraints.audio, 'noiseSuppression', 'googNoiseSuppression');
+ constraints.audio = constraintsToChrome_(constraints.audio);
+ }
+ if (constraints && _typeof(constraints.video) === 'object') {
+ // Shim facingMode for mobile & surface pro.
+ var face = constraints.video.facingMode;
+ face = face && (_typeof(face) === 'object' ? face : {
+ ideal: face
+ });
+ var getSupportedFacingModeLies = browserDetails.version < 66;
+ if (face && (face.exact === 'user' || face.exact === 'environment' || face.ideal === 'user' || face.ideal === 'environment') && !(navigator.mediaDevices.getSupportedConstraints && navigator.mediaDevices.getSupportedConstraints().facingMode && !getSupportedFacingModeLies)) {
+ delete constraints.video.facingMode;
+ var matches;
+ if (face.exact === 'environment' || face.ideal === 'environment') {
+ matches = ['back', 'rear'];
+ } else if (face.exact === 'user' || face.ideal === 'user') {
+ matches = ['front'];
+ }
+ if (matches) {
+ // Look for matches in label, or use last cam for back (typical).
+ return navigator.mediaDevices.enumerateDevices().then(function (devices) {
+ devices = devices.filter(function (d) {
+ return d.kind === 'videoinput';
+ });
+ var dev = devices.find(function (d) {
+ return matches.some(function (match) {
+ return d.label.toLowerCase().includes(match);
+ });
+ });
+ if (!dev && devices.length && matches.includes('back')) {
+ dev = devices[devices.length - 1]; // more likely the back cam
+ }
+
+ if (dev) {
+ constraints.video.deviceId = face.exact ? {
+ exact: dev.deviceId
+ } : {
+ ideal: dev.deviceId
+ };
+ }
+ constraints.video = constraintsToChrome_(constraints.video);
+ logging('chrome: ' + JSON.stringify(constraints));
+ return func(constraints);
+ });
+ }
+ }
+ constraints.video = constraintsToChrome_(constraints.video);
+ }
+ logging('chrome: ' + JSON.stringify(constraints));
+ return func(constraints);
+ };
+ var shimError_ = function shimError_(e) {
+ if (browserDetails.version >= 64) {
+ return e;
+ }
+ return {
+ name: {
+ PermissionDeniedError: 'NotAllowedError',
+ PermissionDismissedError: 'NotAllowedError',
+ InvalidStateError: 'NotAllowedError',
+ DevicesNotFoundError: 'NotFoundError',
+ ConstraintNotSatisfiedError: 'OverconstrainedError',
+ TrackStartError: 'NotReadableError',
+ MediaDeviceFailedDueToShutdown: 'NotAllowedError',
+ MediaDeviceKillSwitchOn: 'NotAllowedError',
+ TabCaptureError: 'AbortError',
+ ScreenCaptureError: 'AbortError',
+ DeviceCaptureError: 'AbortError'
+ }[e.name] || e.name,
+ message: e.message,
+ constraint: e.constraint || e.constraintName,
+ toString: function toString() {
+ return this.name + (this.message && ': ') + this.message;
+ }
+ };
+ };
+ var getUserMedia_ = function getUserMedia_(constraints, onSuccess, onError) {
+ shimConstraints_(constraints, function (c) {
+ navigator.webkitGetUserMedia(c, onSuccess, function (e) {
+ if (onError) {
+ onError(shimError_(e));
+ }
+ });
+ });
+ };
+ navigator.getUserMedia = getUserMedia_.bind(navigator);
+
+ // Even though Chrome 45 has navigator.mediaDevices and a getUserMedia
+ // function which returns a Promise, it does not accept spec-style
+ // constraints.
+ if (navigator.mediaDevices.getUserMedia) {
+ var origGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
+ navigator.mediaDevices.getUserMedia = function (cs) {
+ return shimConstraints_(cs, function (c) {
+ return origGetUserMedia(c).then(function (stream) {
+ if (c.audio && !stream.getAudioTracks().length || c.video && !stream.getVideoTracks().length) {
+ stream.getTracks().forEach(function (track) {
+ track.stop();
+ });
+ throw new DOMException('', 'NotFoundError');
+ }
+ return stream;
+ }, function (e) {
+ return Promise.reject(shimError_(e));
+ });
+ });
+ };
+ }
+}
+
+},{"../utils.js":11}],6:[function(require,module,exports){
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.removeExtmapAllowMixed = removeExtmapAllowMixed;
+exports.shimAddIceCandidateNullOrEmpty = shimAddIceCandidateNullOrEmpty;
+exports.shimConnectionState = shimConnectionState;
+exports.shimMaxMessageSize = shimMaxMessageSize;
+exports.shimParameterlessSetLocalDescription = shimParameterlessSetLocalDescription;
+exports.shimRTCIceCandidate = shimRTCIceCandidate;
+exports.shimRTCIceCandidateRelayProtocol = shimRTCIceCandidateRelayProtocol;
+exports.shimSendThrowTypeError = shimSendThrowTypeError;
+var _sdp = _interopRequireDefault(require("sdp"));
+var utils = _interopRequireWildcard(require("./utils"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimRTCIceCandidate(window) {
+ // foundation is arbitrarily chosen as an indicator for full support for
+ // https://w3c.github.io/webrtc-pc/#rtcicecandidate-interface
+ if (!window.RTCIceCandidate || window.RTCIceCandidate && 'foundation' in window.RTCIceCandidate.prototype) {
+ return;
+ }
+ var NativeRTCIceCandidate = window.RTCIceCandidate;
+ window.RTCIceCandidate = function RTCIceCandidate(args) {
+ // Remove the a= which shouldn't be part of the candidate string.
+ if (_typeof(args) === 'object' && args.candidate && args.candidate.indexOf('a=') === 0) {
+ args = JSON.parse(JSON.stringify(args));
+ args.candidate = args.candidate.substring(2);
+ }
+ if (args.candidate && args.candidate.length) {
+ // Augment the native candidate with the parsed fields.
+ var nativeCandidate = new NativeRTCIceCandidate(args);
+ var parsedCandidate = _sdp["default"].parseCandidate(args.candidate);
+ for (var key in parsedCandidate) {
+ if (!(key in nativeCandidate)) {
+ Object.defineProperty(nativeCandidate, key, {
+ value: parsedCandidate[key]
+ });
+ }
+ }
+
+ // Override serializer to not serialize the extra attributes.
+ nativeCandidate.toJSON = function toJSON() {
+ return {
+ candidate: nativeCandidate.candidate,
+ sdpMid: nativeCandidate.sdpMid,
+ sdpMLineIndex: nativeCandidate.sdpMLineIndex,
+ usernameFragment: nativeCandidate.usernameFragment
+ };
+ };
+ return nativeCandidate;
+ }
+ return new NativeRTCIceCandidate(args);
+ };
+ window.RTCIceCandidate.prototype = NativeRTCIceCandidate.prototype;
+
+ // Hook up the augmented candidate in onicecandidate and
+ // addEventListener('icecandidate', ...)
+ utils.wrapPeerConnectionEvent(window, 'icecandidate', function (e) {
+ if (e.candidate) {
+ Object.defineProperty(e, 'candidate', {
+ value: new window.RTCIceCandidate(e.candidate),
+ writable: 'false'
+ });
+ }
+ return e;
+ });
+}
+function shimRTCIceCandidateRelayProtocol(window) {
+ if (!window.RTCIceCandidate || window.RTCIceCandidate && 'relayProtocol' in window.RTCIceCandidate.prototype) {
+ return;
+ }
+
+ // Hook up the augmented candidate in onicecandidate and
+ // addEventListener('icecandidate', ...)
+ utils.wrapPeerConnectionEvent(window, 'icecandidate', function (e) {
+ if (e.candidate) {
+ var parsedCandidate = _sdp["default"].parseCandidate(e.candidate.candidate);
+ if (parsedCandidate.type === 'relay') {
+ // This is a libwebrtc-specific mapping of local type preference
+ // to relayProtocol.
+ e.candidate.relayProtocol = {
+ 0: 'tls',
+ 1: 'tcp',
+ 2: 'udp'
+ }[parsedCandidate.priority >> 24];
+ }
+ }
+ return e;
+ });
+}
+function shimMaxMessageSize(window, browserDetails) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ if (!('sctp' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'sctp', {
+ get: function get() {
+ return typeof this._sctp === 'undefined' ? null : this._sctp;
+ }
+ });
+ }
+ var sctpInDescription = function sctpInDescription(description) {
+ if (!description || !description.sdp) {
+ return false;
+ }
+ var sections = _sdp["default"].splitSections(description.sdp);
+ sections.shift();
+ return sections.some(function (mediaSection) {
+ var mLine = _sdp["default"].parseMLine(mediaSection);
+ return mLine && mLine.kind === 'application' && mLine.protocol.indexOf('SCTP') !== -1;
+ });
+ };
+ var getRemoteFirefoxVersion = function getRemoteFirefoxVersion(description) {
+ // TODO: Is there a better solution for detecting Firefox?
+ var match = description.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);
+ if (match === null || match.length < 2) {
+ return -1;
+ }
+ var version = parseInt(match[1], 10);
+ // Test for NaN (yes, this is ugly)
+ return version !== version ? -1 : version;
+ };
+ var getCanSendMaxMessageSize = function getCanSendMaxMessageSize(remoteIsFirefox) {
+ // Every implementation we know can send at least 64 KiB.
+ // Note: Although Chrome is technically able to send up to 256 KiB, the
+ // data does not reach the other peer reliably.
+ // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=8419
+ var canSendMaxMessageSize = 65536;
+ if (browserDetails.browser === 'firefox') {
+ if (browserDetails.version < 57) {
+ if (remoteIsFirefox === -1) {
+ // FF < 57 will send in 16 KiB chunks using the deprecated PPID
+ // fragmentation.
+ canSendMaxMessageSize = 16384;
+ } else {
+ // However, other FF (and RAWRTC) can reassemble PPID-fragmented
+ // messages. Thus, supporting ~2 GiB when sending.
+ canSendMaxMessageSize = 2147483637;
+ }
+ } else if (browserDetails.version < 60) {
+ // Currently, all FF >= 57 will reset the remote maximum message size
+ // to the default value when a data channel is created at a later
+ // stage. :(
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
+ canSendMaxMessageSize = browserDetails.version === 57 ? 65535 : 65536;
+ } else {
+ // FF >= 60 supports sending ~2 GiB
+ canSendMaxMessageSize = 2147483637;
+ }
+ }
+ return canSendMaxMessageSize;
+ };
+ var getMaxMessageSize = function getMaxMessageSize(description, remoteIsFirefox) {
+ // Note: 65536 bytes is the default value from the SDP spec. Also,
+ // every implementation we know supports receiving 65536 bytes.
+ var maxMessageSize = 65536;
+
+ // FF 57 has a slightly incorrect default remote max message size, so
+ // we need to adjust it here to avoid a failure when sending.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1425697
+ if (browserDetails.browser === 'firefox' && browserDetails.version === 57) {
+ maxMessageSize = 65535;
+ }
+ var match = _sdp["default"].matchPrefix(description.sdp, 'a=max-message-size:');
+ if (match.length > 0) {
+ maxMessageSize = parseInt(match[0].substring(19), 10);
+ } else if (browserDetails.browser === 'firefox' && remoteIsFirefox !== -1) {
+ // If the maximum message size is not present in the remote SDP and
+ // both local and remote are Firefox, the remote peer can receive
+ // ~2 GiB.
+ maxMessageSize = 2147483637;
+ }
+ return maxMessageSize;
+ };
+ var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
+ this._sctp = null;
+ // Chrome decided to not expose .sctp in plan-b mode.
+ // As usual, adapter.js has to do an 'ugly worakaround'
+ // to cover up the mess.
+ if (browserDetails.browser === 'chrome' && browserDetails.version >= 76) {
+ var _this$getConfiguratio = this.getConfiguration(),
+ sdpSemantics = _this$getConfiguratio.sdpSemantics;
+ if (sdpSemantics === 'plan-b') {
+ Object.defineProperty(this, 'sctp', {
+ get: function get() {
+ return typeof this._sctp === 'undefined' ? null : this._sctp;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ }
+ }
+ if (sctpInDescription(arguments[0])) {
+ // Check if the remote is FF.
+ var isFirefox = getRemoteFirefoxVersion(arguments[0]);
+
+ // Get the maximum message size the local peer is capable of sending
+ var canSendMMS = getCanSendMaxMessageSize(isFirefox);
+
+ // Get the maximum message size of the remote peer.
+ var remoteMMS = getMaxMessageSize(arguments[0], isFirefox);
+
+ // Determine final maximum message size
+ var maxMessageSize;
+ if (canSendMMS === 0 && remoteMMS === 0) {
+ maxMessageSize = Number.POSITIVE_INFINITY;
+ } else if (canSendMMS === 0 || remoteMMS === 0) {
+ maxMessageSize = Math.max(canSendMMS, remoteMMS);
+ } else {
+ maxMessageSize = Math.min(canSendMMS, remoteMMS);
+ }
+
+ // Create a dummy RTCSctpTransport object and the 'maxMessageSize'
+ // attribute.
+ var sctp = {};
+ Object.defineProperty(sctp, 'maxMessageSize', {
+ get: function get() {
+ return maxMessageSize;
+ }
+ });
+ this._sctp = sctp;
+ }
+ return origSetRemoteDescription.apply(this, arguments);
+ };
+}
+function shimSendThrowTypeError(window) {
+ if (!(window.RTCPeerConnection && 'createDataChannel' in window.RTCPeerConnection.prototype)) {
+ return;
+ }
+
+ // Note: Although Firefox >= 57 has a native implementation, the maximum
+ // message size can be reset for all data channels at a later stage.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
+
+ function wrapDcSend(dc, pc) {
+ var origDataChannelSend = dc.send;
+ dc.send = function send() {
+ var data = arguments[0];
+ var length = data.length || data.size || data.byteLength;
+ if (dc.readyState === 'open' && pc.sctp && length > pc.sctp.maxMessageSize) {
+ throw new TypeError('Message too large (can send a maximum of ' + pc.sctp.maxMessageSize + ' bytes)');
+ }
+ return origDataChannelSend.apply(dc, arguments);
+ };
+ }
+ var origCreateDataChannel = window.RTCPeerConnection.prototype.createDataChannel;
+ window.RTCPeerConnection.prototype.createDataChannel = function createDataChannel() {
+ var dataChannel = origCreateDataChannel.apply(this, arguments);
+ wrapDcSend(dataChannel, this);
+ return dataChannel;
+ };
+ utils.wrapPeerConnectionEvent(window, 'datachannel', function (e) {
+ wrapDcSend(e.channel, e.target);
+ return e;
+ });
+}
+
+/* shims RTCConnectionState by pretending it is the same as iceConnectionState.
+ * See https://bugs.chromium.org/p/webrtc/issues/detail?id=6145#c12
+ * for why this is a valid hack in Chrome. In Firefox it is slightly incorrect
+ * since DTLS failures would be hidden. See
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=1265827
+ * for the Firefox tracking bug.
+ */
+function shimConnectionState(window) {
+ if (!window.RTCPeerConnection || 'connectionState' in window.RTCPeerConnection.prototype) {
+ return;
+ }
+ var proto = window.RTCPeerConnection.prototype;
+ Object.defineProperty(proto, 'connectionState', {
+ get: function get() {
+ return {
+ completed: 'connected',
+ checking: 'connecting'
+ }[this.iceConnectionState] || this.iceConnectionState;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(proto, 'onconnectionstatechange', {
+ get: function get() {
+ return this._onconnectionstatechange || null;
+ },
+ set: function set(cb) {
+ if (this._onconnectionstatechange) {
+ this.removeEventListener('connectionstatechange', this._onconnectionstatechange);
+ delete this._onconnectionstatechange;
+ }
+ if (cb) {
+ this.addEventListener('connectionstatechange', this._onconnectionstatechange = cb);
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+ ['setLocalDescription', 'setRemoteDescription'].forEach(function (method) {
+ var origMethod = proto[method];
+ proto[method] = function () {
+ if (!this._connectionstatechangepoly) {
+ this._connectionstatechangepoly = function (e) {
+ var pc = e.target;
+ if (pc._lastConnectionState !== pc.connectionState) {
+ pc._lastConnectionState = pc.connectionState;
+ var newEvent = new Event('connectionstatechange', e);
+ pc.dispatchEvent(newEvent);
+ }
+ return e;
+ };
+ this.addEventListener('iceconnectionstatechange', this._connectionstatechangepoly);
+ }
+ return origMethod.apply(this, arguments);
+ };
+ });
+}
+function removeExtmapAllowMixed(window, browserDetails) {
+ /* remove a=extmap-allow-mixed for webrtc.org < M71 */
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ if (browserDetails.browser === 'chrome' && browserDetails.version >= 71) {
+ return;
+ }
+ if (browserDetails.browser === 'safari' && browserDetails.version >= 605) {
+ return;
+ }
+ var nativeSRD = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription(desc) {
+ if (desc && desc.sdp && desc.sdp.indexOf('\na=extmap-allow-mixed') !== -1) {
+ var sdp = desc.sdp.split('\n').filter(function (line) {
+ return line.trim() !== 'a=extmap-allow-mixed';
+ }).join('\n');
+ // Safari enforces read-only-ness of RTCSessionDescription fields.
+ if (window.RTCSessionDescription && desc instanceof window.RTCSessionDescription) {
+ arguments[0] = new window.RTCSessionDescription({
+ type: desc.type,
+ sdp: sdp
+ });
+ } else {
+ desc.sdp = sdp;
+ }
+ }
+ return nativeSRD.apply(this, arguments);
+ };
+}
+function shimAddIceCandidateNullOrEmpty(window, browserDetails) {
+ // Support for addIceCandidate(null or undefined)
+ // as well as addIceCandidate({candidate: "", ...})
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=978582
+ // Note: must be called before other polyfills which change the signature.
+ if (!(window.RTCPeerConnection && window.RTCPeerConnection.prototype)) {
+ return;
+ }
+ var nativeAddIceCandidate = window.RTCPeerConnection.prototype.addIceCandidate;
+ if (!nativeAddIceCandidate || nativeAddIceCandidate.length === 0) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.addIceCandidate = function addIceCandidate() {
+ if (!arguments[0]) {
+ if (arguments[1]) {
+ arguments[1].apply(null);
+ }
+ return Promise.resolve();
+ }
+ // Firefox 68+ emits and processes {candidate: "", ...}, ignore
+ // in older versions.
+ // Native support for ignoring exists for Chrome M77+.
+ // Safari ignores as well, exact version unknown but works in the same
+ // version that also ignores addIceCandidate(null).
+ if ((browserDetails.browser === 'chrome' && browserDetails.version < 78 || browserDetails.browser === 'firefox' && browserDetails.version < 68 || browserDetails.browser === 'safari') && arguments[0] && arguments[0].candidate === '') {
+ return Promise.resolve();
+ }
+ return nativeAddIceCandidate.apply(this, arguments);
+ };
+}
+
+// Note: Make sure to call this ahead of APIs that modify
+// setLocalDescription.length
+function shimParameterlessSetLocalDescription(window, browserDetails) {
+ if (!(window.RTCPeerConnection && window.RTCPeerConnection.prototype)) {
+ return;
+ }
+ var nativeSetLocalDescription = window.RTCPeerConnection.prototype.setLocalDescription;
+ if (!nativeSetLocalDescription || nativeSetLocalDescription.length === 0) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.setLocalDescription = function setLocalDescription() {
+ var _this = this;
+ var desc = arguments[0] || {};
+ if (_typeof(desc) !== 'object' || desc.type && desc.sdp) {
+ return nativeSetLocalDescription.apply(this, arguments);
+ }
+ // The remaining steps should technically happen when SLD comes off the
+ // RTCPeerConnection's operations chain (not ahead of going on it), but
+ // this is too difficult to shim. Instead, this shim only covers the
+ // common case where the operations chain is empty. This is imperfect, but
+ // should cover many cases. Rationale: Even if we can't reduce the glare
+ // window to zero on imperfect implementations, there's value in tapping
+ // into the perfect negotiation pattern that several browsers support.
+ desc = {
+ type: desc.type,
+ sdp: desc.sdp
+ };
+ if (!desc.type) {
+ switch (this.signalingState) {
+ case 'stable':
+ case 'have-local-offer':
+ case 'have-remote-pranswer':
+ desc.type = 'offer';
+ break;
+ default:
+ desc.type = 'answer';
+ break;
+ }
+ }
+ if (desc.sdp || desc.type !== 'offer' && desc.type !== 'answer') {
+ return nativeSetLocalDescription.apply(this, [desc]);
+ }
+ var func = desc.type === 'offer' ? this.createOffer : this.createAnswer;
+ return func.apply(this).then(function (d) {
+ return nativeSetLocalDescription.apply(_this, [d]);
+ });
+ };
+}
+
+},{"./utils":11,"sdp":12}],7:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimAddTransceiver = shimAddTransceiver;
+exports.shimCreateAnswer = shimCreateAnswer;
+exports.shimCreateOffer = shimCreateOffer;
+Object.defineProperty(exports, "shimGetDisplayMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getdisplaymedia.shimGetDisplayMedia;
+ }
+});
+exports.shimGetParameters = shimGetParameters;
+Object.defineProperty(exports, "shimGetUserMedia", {
+ enumerable: true,
+ get: function get() {
+ return _getusermedia.shimGetUserMedia;
+ }
+});
+exports.shimOnTrack = shimOnTrack;
+exports.shimPeerConnection = shimPeerConnection;
+exports.shimRTCDataChannel = shimRTCDataChannel;
+exports.shimReceiverGetStats = shimReceiverGetStats;
+exports.shimRemoveStream = shimRemoveStream;
+exports.shimSenderGetStats = shimSenderGetStats;
+var utils = _interopRequireWildcard(require("../utils"));
+var _getusermedia = require("./getusermedia");
+var _getdisplaymedia = require("./getdisplaymedia");
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
+function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
+function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimOnTrack(window) {
+ if (_typeof(window) === 'object' && window.RTCTrackEvent && 'receiver' in window.RTCTrackEvent.prototype && !('transceiver' in window.RTCTrackEvent.prototype)) {
+ Object.defineProperty(window.RTCTrackEvent.prototype, 'transceiver', {
+ get: function get() {
+ return {
+ receiver: this.receiver
+ };
+ }
+ });
+ }
+}
+function shimPeerConnection(window, browserDetails) {
+ if (_typeof(window) !== 'object' || !(window.RTCPeerConnection || window.mozRTCPeerConnection)) {
+ return; // probably media.peerconnection.enabled=false in about:config
+ }
+
+ if (!window.RTCPeerConnection && window.mozRTCPeerConnection) {
+ // very basic support for old versions.
+ window.RTCPeerConnection = window.mozRTCPeerConnection;
+ }
+ if (browserDetails.version < 53) {
+ // shim away need for obsolete RTCIceCandidate/RTCSessionDescription.
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
+ var nativeMethod = window.RTCPeerConnection.prototype[method];
+ var methodObj = _defineProperty({}, method, function () {
+ arguments[0] = new (method === 'addIceCandidate' ? window.RTCIceCandidate : window.RTCSessionDescription)(arguments[0]);
+ return nativeMethod.apply(this, arguments);
+ });
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ }
+ var modernStatsTypes = {
+ inboundrtp: 'inbound-rtp',
+ outboundrtp: 'outbound-rtp',
+ candidatepair: 'candidate-pair',
+ localcandidate: 'local-candidate',
+ remotecandidate: 'remote-candidate'
+ };
+ var nativeGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ var _arguments = Array.prototype.slice.call(arguments),
+ selector = _arguments[0],
+ onSucc = _arguments[1],
+ onErr = _arguments[2];
+ return nativeGetStats.apply(this, [selector || null]).then(function (stats) {
+ if (browserDetails.version < 53 && !onSucc) {
+ // Shim only promise getStats with spec-hyphens in type names
+ // Leave callback version alone; misc old uses of forEach before Map
+ try {
+ stats.forEach(function (stat) {
+ stat.type = modernStatsTypes[stat.type] || stat.type;
+ });
+ } catch (e) {
+ if (e.name !== 'TypeError') {
+ throw e;
+ }
+ // Avoid TypeError: "type" is read-only, in old versions. 34-43ish
+ stats.forEach(function (stat, i) {
+ stats.set(i, Object.assign({}, stat, {
+ type: modernStatsTypes[stat.type] || stat.type
+ }));
+ });
+ }
+ }
+ return stats;
+ }).then(onSucc, onErr);
+ };
+}
+function shimSenderGetStats(window) {
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection && window.RTCRtpSender)) {
+ return;
+ }
+ if (window.RTCRtpSender && 'getStats' in window.RTCRtpSender.prototype) {
+ return;
+ }
+ var origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ if (origGetSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ var _this = this;
+ var senders = origGetSenders.apply(this, []);
+ senders.forEach(function (sender) {
+ return sender._pc = _this;
+ });
+ return senders;
+ };
+ }
+ var origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ if (origAddTrack) {
+ window.RTCPeerConnection.prototype.addTrack = function addTrack() {
+ var sender = origAddTrack.apply(this, arguments);
+ sender._pc = this;
+ return sender;
+ };
+ }
+ window.RTCRtpSender.prototype.getStats = function getStats() {
+ return this.track ? this._pc.getStats(this.track) : Promise.resolve(new Map());
+ };
+}
+function shimReceiverGetStats(window) {
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection && window.RTCRtpSender)) {
+ return;
+ }
+ if (window.RTCRtpSender && 'getStats' in window.RTCRtpReceiver.prototype) {
+ return;
+ }
+ var origGetReceivers = window.RTCPeerConnection.prototype.getReceivers;
+ if (origGetReceivers) {
+ window.RTCPeerConnection.prototype.getReceivers = function getReceivers() {
+ var _this2 = this;
+ var receivers = origGetReceivers.apply(this, []);
+ receivers.forEach(function (receiver) {
+ return receiver._pc = _this2;
+ });
+ return receivers;
+ };
+ }
+ utils.wrapPeerConnectionEvent(window, 'track', function (e) {
+ e.receiver._pc = e.srcElement;
+ return e;
+ });
+ window.RTCRtpReceiver.prototype.getStats = function getStats() {
+ return this._pc.getStats(this.track);
+ };
+}
+function shimRemoveStream(window) {
+ if (!window.RTCPeerConnection || 'removeStream' in window.RTCPeerConnection.prototype) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ var _this3 = this;
+ utils.deprecated('removeStream', 'removeTrack');
+ this.getSenders().forEach(function (sender) {
+ if (sender.track && stream.getTracks().includes(sender.track)) {
+ _this3.removeTrack(sender);
+ }
+ });
+ };
+}
+function shimRTCDataChannel(window) {
+ // rename DataChannel to RTCDataChannel (native fix in FF60):
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1173851
+ if (window.DataChannel && !window.RTCDataChannel) {
+ window.RTCDataChannel = window.DataChannel;
+ }
+}
+function shimAddTransceiver(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ var origAddTransceiver = window.RTCPeerConnection.prototype.addTransceiver;
+ if (origAddTransceiver) {
+ window.RTCPeerConnection.prototype.addTransceiver = function addTransceiver() {
+ this.setParametersPromises = [];
+ // WebIDL input coercion and validation
+ var sendEncodings = arguments[1] && arguments[1].sendEncodings;
+ if (sendEncodings === undefined) {
+ sendEncodings = [];
+ }
+ sendEncodings = _toConsumableArray(sendEncodings);
+ var shouldPerformCheck = sendEncodings.length > 0;
+ if (shouldPerformCheck) {
+ // If sendEncodings params are provided, validate grammar
+ sendEncodings.forEach(function (encodingParam) {
+ if ('rid' in encodingParam) {
+ var ridRegex = /^[a-z0-9]{0,16}$/i;
+ if (!ridRegex.test(encodingParam.rid)) {
+ throw new TypeError('Invalid RID value provided.');
+ }
+ }
+ if ('scaleResolutionDownBy' in encodingParam) {
+ if (!(parseFloat(encodingParam.scaleResolutionDownBy) >= 1.0)) {
+ throw new RangeError('scale_resolution_down_by must be >= 1.0');
+ }
+ }
+ if ('maxFramerate' in encodingParam) {
+ if (!(parseFloat(encodingParam.maxFramerate) >= 0)) {
+ throw new RangeError('max_framerate must be >= 0.0');
+ }
+ }
+ });
+ }
+ var transceiver = origAddTransceiver.apply(this, arguments);
+ if (shouldPerformCheck) {
+ // Check if the init options were applied. If not we do this in an
+ // asynchronous way and save the promise reference in a global object.
+ // This is an ugly hack, but at the same time is way more robust than
+ // checking the sender parameters before and after the createOffer
+ // Also note that after the createoffer we are not 100% sure that
+ // the params were asynchronously applied so we might miss the
+ // opportunity to recreate offer.
+ var sender = transceiver.sender;
+ var params = sender.getParameters();
+ if (!('encodings' in params) ||
+ // Avoid being fooled by patched getParameters() below.
+ params.encodings.length === 1 && Object.keys(params.encodings[0]).length === 0) {
+ params.encodings = sendEncodings;
+ sender.sendEncodings = sendEncodings;
+ this.setParametersPromises.push(sender.setParameters(params).then(function () {
+ delete sender.sendEncodings;
+ })["catch"](function () {
+ delete sender.sendEncodings;
+ }));
+ }
+ }
+ return transceiver;
+ };
+ }
+}
+function shimGetParameters(window) {
+ if (!(_typeof(window) === 'object' && window.RTCRtpSender)) {
+ return;
+ }
+ var origGetParameters = window.RTCRtpSender.prototype.getParameters;
+ if (origGetParameters) {
+ window.RTCRtpSender.prototype.getParameters = function getParameters() {
+ var params = origGetParameters.apply(this, arguments);
+ if (!('encodings' in params)) {
+ params.encodings = [].concat(this.sendEncodings || [{}]);
+ }
+ return params;
+ };
+ }
+}
+function shimCreateOffer(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ var origCreateOffer = window.RTCPeerConnection.prototype.createOffer;
+ window.RTCPeerConnection.prototype.createOffer = function createOffer() {
+ var _arguments2 = arguments,
+ _this4 = this;
+ if (this.setParametersPromises && this.setParametersPromises.length) {
+ return Promise.all(this.setParametersPromises).then(function () {
+ return origCreateOffer.apply(_this4, _arguments2);
+ })["finally"](function () {
+ _this4.setParametersPromises = [];
+ });
+ }
+ return origCreateOffer.apply(this, arguments);
+ };
+}
+function shimCreateAnswer(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(_typeof(window) === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ var origCreateAnswer = window.RTCPeerConnection.prototype.createAnswer;
+ window.RTCPeerConnection.prototype.createAnswer = function createAnswer() {
+ var _arguments3 = arguments,
+ _this5 = this;
+ if (this.setParametersPromises && this.setParametersPromises.length) {
+ return Promise.all(this.setParametersPromises).then(function () {
+ return origCreateAnswer.apply(_this5, _arguments3);
+ })["finally"](function () {
+ _this5.setParametersPromises = [];
+ });
+ }
+ return origCreateAnswer.apply(this, arguments);
+ };
+}
+
+},{"../utils":11,"./getdisplaymedia":8,"./getusermedia":9}],8:[function(require,module,exports){
+/*
+ * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetDisplayMedia = shimGetDisplayMedia;
+function shimGetDisplayMedia(window, preferredMediaSource) {
+ if (window.navigator.mediaDevices && 'getDisplayMedia' in window.navigator.mediaDevices) {
+ return;
+ }
+ if (!window.navigator.mediaDevices) {
+ return;
+ }
+ window.navigator.mediaDevices.getDisplayMedia = function getDisplayMedia(constraints) {
+ if (!(constraints && constraints.video)) {
+ var err = new DOMException('getDisplayMedia without video ' + 'constraints is undefined');
+ err.name = 'NotFoundError';
+ // from https://heycam.github.io/webidl/#idl-DOMException-error-names
+ err.code = 8;
+ return Promise.reject(err);
+ }
+ if (constraints.video === true) {
+ constraints.video = {
+ mediaSource: preferredMediaSource
+ };
+ } else {
+ constraints.video.mediaSource = preferredMediaSource;
+ }
+ return window.navigator.mediaDevices.getUserMedia(constraints);
+ };
+}
+
+},{}],9:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimGetUserMedia = shimGetUserMedia;
+var utils = _interopRequireWildcard(require("../utils"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimGetUserMedia(window, browserDetails) {
+ var navigator = window && window.navigator;
+ var MediaStreamTrack = window && window.MediaStreamTrack;
+ navigator.getUserMedia = function (constraints, onSuccess, onError) {
+ // Replace Firefox 44+'s deprecation warning with unprefixed version.
+ utils.deprecated('navigator.getUserMedia', 'navigator.mediaDevices.getUserMedia');
+ navigator.mediaDevices.getUserMedia(constraints).then(onSuccess, onError);
+ };
+ if (!(browserDetails.version > 55 && 'autoGainControl' in navigator.mediaDevices.getSupportedConstraints())) {
+ var remap = function remap(obj, a, b) {
+ if (a in obj && !(b in obj)) {
+ obj[b] = obj[a];
+ delete obj[a];
+ }
+ };
+ var nativeGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
+ navigator.mediaDevices.getUserMedia = function (c) {
+ if (_typeof(c) === 'object' && _typeof(c.audio) === 'object') {
+ c = JSON.parse(JSON.stringify(c));
+ remap(c.audio, 'autoGainControl', 'mozAutoGainControl');
+ remap(c.audio, 'noiseSuppression', 'mozNoiseSuppression');
+ }
+ return nativeGetUserMedia(c);
+ };
+ if (MediaStreamTrack && MediaStreamTrack.prototype.getSettings) {
+ var nativeGetSettings = MediaStreamTrack.prototype.getSettings;
+ MediaStreamTrack.prototype.getSettings = function () {
+ var obj = nativeGetSettings.apply(this, arguments);
+ remap(obj, 'mozAutoGainControl', 'autoGainControl');
+ remap(obj, 'mozNoiseSuppression', 'noiseSuppression');
+ return obj;
+ };
+ }
+ if (MediaStreamTrack && MediaStreamTrack.prototype.applyConstraints) {
+ var nativeApplyConstraints = MediaStreamTrack.prototype.applyConstraints;
+ MediaStreamTrack.prototype.applyConstraints = function (c) {
+ if (this.kind === 'audio' && _typeof(c) === 'object') {
+ c = JSON.parse(JSON.stringify(c));
+ remap(c, 'autoGainControl', 'mozAutoGainControl');
+ remap(c, 'noiseSuppression', 'mozNoiseSuppression');
+ }
+ return nativeApplyConstraints.apply(this, [c]);
+ };
+ }
+ }
+}
+
+},{"../utils":11}],10:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shimAudioContext = shimAudioContext;
+exports.shimCallbacksAPI = shimCallbacksAPI;
+exports.shimConstraints = shimConstraints;
+exports.shimCreateOfferLegacy = shimCreateOfferLegacy;
+exports.shimGetUserMedia = shimGetUserMedia;
+exports.shimLocalStreamsAPI = shimLocalStreamsAPI;
+exports.shimRTCIceServerUrls = shimRTCIceServerUrls;
+exports.shimRemoteStreamsAPI = shimRemoteStreamsAPI;
+exports.shimTrackEventTransceiver = shimTrackEventTransceiver;
+var utils = _interopRequireWildcard(require("../utils"));
+function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
+function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+function shimLocalStreamsAPI(window) {
+ if (_typeof(window) !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ if (!('getLocalStreams' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.getLocalStreams = function getLocalStreams() {
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ return this._localStreams;
+ };
+ }
+ if (!('addStream' in window.RTCPeerConnection.prototype)) {
+ var _addTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ var _this = this;
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ if (!this._localStreams.includes(stream)) {
+ this._localStreams.push(stream);
+ }
+ // Try to emulate Chrome's behaviour of adding in audio-video order.
+ // Safari orders by track id.
+ stream.getAudioTracks().forEach(function (track) {
+ return _addTrack.call(_this, track, stream);
+ });
+ stream.getVideoTracks().forEach(function (track) {
+ return _addTrack.call(_this, track, stream);
+ });
+ };
+ window.RTCPeerConnection.prototype.addTrack = function addTrack(track) {
+ var _this2 = this;
+ for (var _len = arguments.length, streams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ streams[_key - 1] = arguments[_key];
+ }
+ if (streams) {
+ streams.forEach(function (stream) {
+ if (!_this2._localStreams) {
+ _this2._localStreams = [stream];
+ } else if (!_this2._localStreams.includes(stream)) {
+ _this2._localStreams.push(stream);
+ }
+ });
+ }
+ return _addTrack.apply(this, arguments);
+ };
+ }
+ if (!('removeStream' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.removeStream = function removeStream(stream) {
+ var _this3 = this;
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ var index = this._localStreams.indexOf(stream);
+ if (index === -1) {
+ return;
+ }
+ this._localStreams.splice(index, 1);
+ var tracks = stream.getTracks();
+ this.getSenders().forEach(function (sender) {
+ if (tracks.includes(sender.track)) {
+ _this3.removeTrack(sender);
+ }
+ });
+ };
+ }
+}
+function shimRemoteStreamsAPI(window) {
+ if (_typeof(window) !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ if (!('getRemoteStreams' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.getRemoteStreams = function getRemoteStreams() {
+ return this._remoteStreams ? this._remoteStreams : [];
+ };
+ }
+ if (!('onaddstream' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'onaddstream', {
+ get: function get() {
+ return this._onaddstream;
+ },
+ set: function set(f) {
+ var _this4 = this;
+ if (this._onaddstream) {
+ this.removeEventListener('addstream', this._onaddstream);
+ this.removeEventListener('track', this._onaddstreampoly);
+ }
+ this.addEventListener('addstream', this._onaddstream = f);
+ this.addEventListener('track', this._onaddstreampoly = function (e) {
+ e.streams.forEach(function (stream) {
+ if (!_this4._remoteStreams) {
+ _this4._remoteStreams = [];
+ }
+ if (_this4._remoteStreams.includes(stream)) {
+ return;
+ }
+ _this4._remoteStreams.push(stream);
+ var event = new Event('addstream');
+ event.stream = stream;
+ _this4.dispatchEvent(event);
+ });
+ });
+ }
+ });
+ var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() {
+ var pc = this;
+ if (!this._onaddstreampoly) {
+ this.addEventListener('track', this._onaddstreampoly = function (e) {
+ e.streams.forEach(function (stream) {
+ if (!pc._remoteStreams) {
+ pc._remoteStreams = [];
+ }
+ if (pc._remoteStreams.indexOf(stream) >= 0) {
+ return;
+ }
+ pc._remoteStreams.push(stream);
+ var event = new Event('addstream');
+ event.stream = stream;
+ pc.dispatchEvent(event);
+ });
+ });
+ }
+ return origSetRemoteDescription.apply(pc, arguments);
+ };
+ }
+}
+function shimCallbacksAPI(window) {
+ if (_typeof(window) !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ var prototype = window.RTCPeerConnection.prototype;
+ var origCreateOffer = prototype.createOffer;
+ var origCreateAnswer = prototype.createAnswer;
+ var setLocalDescription = prototype.setLocalDescription;
+ var setRemoteDescription = prototype.setRemoteDescription;
+ var addIceCandidate = prototype.addIceCandidate;
+ prototype.createOffer = function createOffer(successCallback, failureCallback) {
+ var options = arguments.length >= 2 ? arguments[2] : arguments[0];
+ var promise = origCreateOffer.apply(this, [options]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.createAnswer = function createAnswer(successCallback, failureCallback) {
+ var options = arguments.length >= 2 ? arguments[2] : arguments[0];
+ var promise = origCreateAnswer.apply(this, [options]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ var withCallback = function withCallback(description, successCallback, failureCallback) {
+ var promise = setLocalDescription.apply(this, [description]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.setLocalDescription = withCallback;
+ withCallback = function withCallback(description, successCallback, failureCallback) {
+ var promise = setRemoteDescription.apply(this, [description]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.setRemoteDescription = withCallback;
+ withCallback = function withCallback(candidate, successCallback, failureCallback) {
+ var promise = addIceCandidate.apply(this, [candidate]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.addIceCandidate = withCallback;
+}
+function shimGetUserMedia(window) {
+ var navigator = window && window.navigator;
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
+ // shim not needed in Safari 12.1
+ var mediaDevices = navigator.mediaDevices;
+ var _getUserMedia = mediaDevices.getUserMedia.bind(mediaDevices);
+ navigator.mediaDevices.getUserMedia = function (constraints) {
+ return _getUserMedia(shimConstraints(constraints));
+ };
+ }
+ if (!navigator.getUserMedia && navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
+ navigator.getUserMedia = function getUserMedia(constraints, cb, errcb) {
+ navigator.mediaDevices.getUserMedia(constraints).then(cb, errcb);
+ }.bind(navigator);
+ }
+}
+function shimConstraints(constraints) {
+ if (constraints && constraints.video !== undefined) {
+ return Object.assign({}, constraints, {
+ video: utils.compactObject(constraints.video)
+ });
+ }
+ return constraints;
+}
+function shimRTCIceServerUrls(window) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ // migrate from non-spec RTCIceServer.url to RTCIceServer.urls
+ var OrigPeerConnection = window.RTCPeerConnection;
+ window.RTCPeerConnection = function RTCPeerConnection(pcConfig, pcConstraints) {
+ if (pcConfig && pcConfig.iceServers) {
+ var newIceServers = [];
+ for (var i = 0; i < pcConfig.iceServers.length; i++) {
+ var server = pcConfig.iceServers[i];
+ if (server.urls === undefined && server.url) {
+ utils.deprecated('RTCIceServer.url', 'RTCIceServer.urls');
+ server = JSON.parse(JSON.stringify(server));
+ server.urls = server.url;
+ delete server.url;
+ newIceServers.push(server);
+ } else {
+ newIceServers.push(pcConfig.iceServers[i]);
+ }
+ }
+ pcConfig.iceServers = newIceServers;
+ }
+ return new OrigPeerConnection(pcConfig, pcConstraints);
+ };
+ window.RTCPeerConnection.prototype = OrigPeerConnection.prototype;
+ // wrap static methods. Currently just generateCertificate.
+ if ('generateCertificate' in OrigPeerConnection) {
+ Object.defineProperty(window.RTCPeerConnection, 'generateCertificate', {
+ get: function get() {
+ return OrigPeerConnection.generateCertificate;
+ }
+ });
+ }
+}
+function shimTrackEventTransceiver(window) {
+ // Add event.transceiver member over deprecated event.receiver
+ if (_typeof(window) === 'object' && window.RTCTrackEvent && 'receiver' in window.RTCTrackEvent.prototype && !('transceiver' in window.RTCTrackEvent.prototype)) {
+ Object.defineProperty(window.RTCTrackEvent.prototype, 'transceiver', {
+ get: function get() {
+ return {
+ receiver: this.receiver
+ };
+ }
+ });
+ }
+}
+function shimCreateOfferLegacy(window) {
+ var origCreateOffer = window.RTCPeerConnection.prototype.createOffer;
+ window.RTCPeerConnection.prototype.createOffer = function createOffer(offerOptions) {
+ if (offerOptions) {
+ if (typeof offerOptions.offerToReceiveAudio !== 'undefined') {
+ // support bit values
+ offerOptions.offerToReceiveAudio = !!offerOptions.offerToReceiveAudio;
+ }
+ var audioTransceiver = this.getTransceivers().find(function (transceiver) {
+ return transceiver.receiver.track.kind === 'audio';
+ });
+ if (offerOptions.offerToReceiveAudio === false && audioTransceiver) {
+ if (audioTransceiver.direction === 'sendrecv') {
+ if (audioTransceiver.setDirection) {
+ audioTransceiver.setDirection('sendonly');
+ } else {
+ audioTransceiver.direction = 'sendonly';
+ }
+ } else if (audioTransceiver.direction === 'recvonly') {
+ if (audioTransceiver.setDirection) {
+ audioTransceiver.setDirection('inactive');
+ } else {
+ audioTransceiver.direction = 'inactive';
+ }
+ }
+ } else if (offerOptions.offerToReceiveAudio === true && !audioTransceiver) {
+ this.addTransceiver('audio', {
+ direction: 'recvonly'
+ });
+ }
+ if (typeof offerOptions.offerToReceiveVideo !== 'undefined') {
+ // support bit values
+ offerOptions.offerToReceiveVideo = !!offerOptions.offerToReceiveVideo;
+ }
+ var videoTransceiver = this.getTransceivers().find(function (transceiver) {
+ return transceiver.receiver.track.kind === 'video';
+ });
+ if (offerOptions.offerToReceiveVideo === false && videoTransceiver) {
+ if (videoTransceiver.direction === 'sendrecv') {
+ if (videoTransceiver.setDirection) {
+ videoTransceiver.setDirection('sendonly');
+ } else {
+ videoTransceiver.direction = 'sendonly';
+ }
+ } else if (videoTransceiver.direction === 'recvonly') {
+ if (videoTransceiver.setDirection) {
+ videoTransceiver.setDirection('inactive');
+ } else {
+ videoTransceiver.direction = 'inactive';
+ }
+ }
+ } else if (offerOptions.offerToReceiveVideo === true && !videoTransceiver) {
+ this.addTransceiver('video', {
+ direction: 'recvonly'
+ });
+ }
+ }
+ return origCreateOffer.apply(this, arguments);
+ };
+}
+function shimAudioContext(window) {
+ if (_typeof(window) !== 'object' || window.AudioContext) {
+ return;
+ }
+ window.AudioContext = window.webkitAudioContext;
+}
+
+},{"../utils":11}],11:[function(require,module,exports){
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.compactObject = compactObject;
+exports.deprecated = deprecated;
+exports.detectBrowser = detectBrowser;
+exports.disableLog = disableLog;
+exports.disableWarnings = disableWarnings;
+exports.extractVersion = extractVersion;
+exports.filterStats = filterStats;
+exports.log = log;
+exports.walkStats = walkStats;
+exports.wrapPeerConnectionEvent = wrapPeerConnectionEvent;
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
+var logDisabled_ = true;
+var deprecationWarnings_ = true;
+
+/**
+ * Extract browser version out of the provided user agent string.
+ *
+ * @param {!string} uastring userAgent string.
+ * @param {!string} expr Regular expression used as match criteria.
+ * @param {!number} pos position in the version string to be returned.
+ * @return {!number} browser version.
+ */
+function extractVersion(uastring, expr, pos) {
+ var match = uastring.match(expr);
+ return match && match.length >= pos && parseInt(match[pos], 10);
+}
+
+// Wraps the peerconnection event eventNameToWrap in a function
+// which returns the modified event object (or false to prevent
+// the event).
+function wrapPeerConnectionEvent(window, eventNameToWrap, wrapper) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ var proto = window.RTCPeerConnection.prototype;
+ var nativeAddEventListener = proto.addEventListener;
+ proto.addEventListener = function (nativeEventName, cb) {
+ if (nativeEventName !== eventNameToWrap) {
+ return nativeAddEventListener.apply(this, arguments);
+ }
+ var wrappedCallback = function wrappedCallback(e) {
+ var modifiedEvent = wrapper(e);
+ if (modifiedEvent) {
+ if (cb.handleEvent) {
+ cb.handleEvent(modifiedEvent);
+ } else {
+ cb(modifiedEvent);
+ }
+ }
+ };
+ this._eventMap = this._eventMap || {};
+ if (!this._eventMap[eventNameToWrap]) {
+ this._eventMap[eventNameToWrap] = new Map();
+ }
+ this._eventMap[eventNameToWrap].set(cb, wrappedCallback);
+ return nativeAddEventListener.apply(this, [nativeEventName, wrappedCallback]);
+ };
+ var nativeRemoveEventListener = proto.removeEventListener;
+ proto.removeEventListener = function (nativeEventName, cb) {
+ if (nativeEventName !== eventNameToWrap || !this._eventMap || !this._eventMap[eventNameToWrap]) {
+ return nativeRemoveEventListener.apply(this, arguments);
+ }
+ if (!this._eventMap[eventNameToWrap].has(cb)) {
+ return nativeRemoveEventListener.apply(this, arguments);
+ }
+ var unwrappedCb = this._eventMap[eventNameToWrap].get(cb);
+ this._eventMap[eventNameToWrap]["delete"](cb);
+ if (this._eventMap[eventNameToWrap].size === 0) {
+ delete this._eventMap[eventNameToWrap];
+ }
+ if (Object.keys(this._eventMap).length === 0) {
+ delete this._eventMap;
+ }
+ return nativeRemoveEventListener.apply(this, [nativeEventName, unwrappedCb]);
+ };
+ Object.defineProperty(proto, 'on' + eventNameToWrap, {
+ get: function get() {
+ return this['_on' + eventNameToWrap];
+ },
+ set: function set(cb) {
+ if (this['_on' + eventNameToWrap]) {
+ this.removeEventListener(eventNameToWrap, this['_on' + eventNameToWrap]);
+ delete this['_on' + eventNameToWrap];
+ }
+ if (cb) {
+ this.addEventListener(eventNameToWrap, this['_on' + eventNameToWrap] = cb);
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+}
+function disableLog(bool) {
+ if (typeof bool !== 'boolean') {
+ return new Error('Argument type: ' + _typeof(bool) + '. Please use a boolean.');
+ }
+ logDisabled_ = bool;
+ return bool ? 'adapter.js logging disabled' : 'adapter.js logging enabled';
+}
+
+/**
+ * Disable or enable deprecation warnings
+ * @param {!boolean} bool set to true to disable warnings.
+ */
+function disableWarnings(bool) {
+ if (typeof bool !== 'boolean') {
+ return new Error('Argument type: ' + _typeof(bool) + '. Please use a boolean.');
+ }
+ deprecationWarnings_ = !bool;
+ return 'adapter.js deprecation warnings ' + (bool ? 'disabled' : 'enabled');
+}
+function log() {
+ if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object') {
+ if (logDisabled_) {
+ return;
+ }
+ if (typeof console !== 'undefined' && typeof console.log === 'function') {
+ console.log.apply(console, arguments);
+ }
+ }
+}
+
+/**
+ * Shows a deprecation warning suggesting the modern and spec-compatible API.
+ */
+function deprecated(oldMethod, newMethod) {
+ if (!deprecationWarnings_) {
+ return;
+ }
+ console.warn(oldMethod + ' is deprecated, please use ' + newMethod + ' instead.');
+}
+
+/**
+ * Browser detector.
+ *
+ * @return {object} result containing browser and version
+ * properties.
+ */
+function detectBrowser(window) {
+ // Returned result object.
+ var result = {
+ browser: null,
+ version: null
+ };
+
+ // Fail early if it's not a browser
+ if (typeof window === 'undefined' || !window.navigator || !window.navigator.userAgent) {
+ result.browser = 'Not a browser.';
+ return result;
+ }
+ var navigator = window.navigator;
+ if (navigator.mozGetUserMedia) {
+ // Firefox.
+ result.browser = 'firefox';
+ result.version = extractVersion(navigator.userAgent, /Firefox\/(\d+)\./, 1);
+ } else if (navigator.webkitGetUserMedia || window.isSecureContext === false && window.webkitRTCPeerConnection) {
+ // Chrome, Chromium, Webview, Opera.
+ // Version matches Chrome/WebRTC version.
+ // Chrome 74 removed webkitGetUserMedia on http as well so we need the
+ // more complicated fallback to webkitRTCPeerConnection.
+ result.browser = 'chrome';
+ result.version = extractVersion(navigator.userAgent, /Chrom(e|ium)\/(\d+)\./, 2);
+ } else if (window.RTCPeerConnection && navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) {
+ // Safari.
+ result.browser = 'safari';
+ result.version = extractVersion(navigator.userAgent, /AppleWebKit\/(\d+)\./, 1);
+ result.supportsUnifiedPlan = window.RTCRtpTransceiver && 'currentDirection' in window.RTCRtpTransceiver.prototype;
+ } else {
+ // Default fallthrough: not supported.
+ result.browser = 'Not a supported browser.';
+ return result;
+ }
+ return result;
+}
+
+/**
+ * Checks if something is an object.
+ *
+ * @param {*} val The something you want to check.
+ * @return true if val is an object, false otherwise.
+ */
+function isObject(val) {
+ return Object.prototype.toString.call(val) === '[object Object]';
+}
+
+/**
+ * Remove all empty objects and undefined values
+ * from a nested object -- an enhanced and vanilla version
+ * of Lodash's `compact`.
+ */
+function compactObject(data) {
+ if (!isObject(data)) {
+ return data;
+ }
+ return Object.keys(data).reduce(function (accumulator, key) {
+ var isObj = isObject(data[key]);
+ var value = isObj ? compactObject(data[key]) : data[key];
+ var isEmptyObject = isObj && !Object.keys(value).length;
+ if (value === undefined || isEmptyObject) {
+ return accumulator;
+ }
+ return Object.assign(accumulator, _defineProperty({}, key, value));
+ }, {});
+}
+
+/* iterates the stats graph recursively. */
+function walkStats(stats, base, resultSet) {
+ if (!base || resultSet.has(base.id)) {
+ return;
+ }
+ resultSet.set(base.id, base);
+ Object.keys(base).forEach(function (name) {
+ if (name.endsWith('Id')) {
+ walkStats(stats, stats.get(base[name]), resultSet);
+ } else if (name.endsWith('Ids')) {
+ base[name].forEach(function (id) {
+ walkStats(stats, stats.get(id), resultSet);
+ });
+ }
+ });
+}
+
+/* filter getStats for a sender/receiver track. */
+function filterStats(result, track, outbound) {
+ var streamStatsType = outbound ? 'outbound-rtp' : 'inbound-rtp';
+ var filteredResult = new Map();
+ if (track === null) {
+ return filteredResult;
+ }
+ var trackStats = [];
+ result.forEach(function (value) {
+ if (value.type === 'track' && value.trackIdentifier === track.id) {
+ trackStats.push(value);
+ }
+ });
+ trackStats.forEach(function (trackStat) {
+ result.forEach(function (stats) {
+ if (stats.type === streamStatsType && stats.trackId === trackStat.id) {
+ walkStats(result, stats, filteredResult);
+ }
+ });
+ });
+ return filteredResult;
+}
+
+},{}],12:[function(require,module,exports){
+/* eslint-env node */
+'use strict';
+
+// SDP helpers.
+
+var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
+
+var SDPUtils = {};
+
+// Generate an alphanumeric identifier for cname or mids.
+// TODO: use UUIDs instead? https://gist.github.com/jed/982883
+SDPUtils.generateIdentifier = function () {
+ return Math.random().toString(36).substring(2, 12);
+};
+
+// The RTCP CNAME used by all peerconnections from the same JS.
+SDPUtils.localCName = SDPUtils.generateIdentifier();
+
+// Splits SDP into lines, dealing with both CRLF and LF.
+SDPUtils.splitLines = function (blob) {
+ return blob.trim().split('\n').map(function (line) {
+ return line.trim();
+ });
+};
+// Splits SDP into sessionpart and mediasections. Ensures CRLF.
+SDPUtils.splitSections = function (blob) {
+ var parts = blob.split('\nm=');
+ return parts.map(function (part, index) {
+ return (index > 0 ? 'm=' + part : part).trim() + '\r\n';
+ });
+};
+
+// Returns the session description.
+SDPUtils.getDescription = function (blob) {
+ var sections = SDPUtils.splitSections(blob);
+ return sections && sections[0];
+};
+
+// Returns the individual media sections.
+SDPUtils.getMediaSections = function (blob) {
+ var sections = SDPUtils.splitSections(blob);
+ sections.shift();
+ return sections;
+};
+
+// Returns lines that start with a certain prefix.
+SDPUtils.matchPrefix = function (blob, prefix) {
+ return SDPUtils.splitLines(blob).filter(function (line) {
+ return line.indexOf(prefix) === 0;
+ });
+};
+
+// Parses an ICE candidate line. Sample input:
+// candidate:702786350 2 udp 41819902 8.8.8.8 60769 typ relay raddr 8.8.8.8
+// rport 55996"
+// Input can be prefixed with a=.
+SDPUtils.parseCandidate = function (line) {
+ var parts = void 0;
+ // Parse both variants.
+ if (line.indexOf('a=candidate:') === 0) {
+ parts = line.substring(12).split(' ');
+ } else {
+ parts = line.substring(10).split(' ');
+ }
+
+ var candidate = {
+ foundation: parts[0],
+ component: { 1: 'rtp', 2: 'rtcp' }[parts[1]] || parts[1],
+ protocol: parts[2].toLowerCase(),
+ priority: parseInt(parts[3], 10),
+ ip: parts[4],
+ address: parts[4], // address is an alias for ip.
+ port: parseInt(parts[5], 10),
+ // skip parts[6] == 'typ'
+ type: parts[7]
+ };
+
+ for (var i = 8; i < parts.length; i += 2) {
+ switch (parts[i]) {
+ case 'raddr':
+ candidate.relatedAddress = parts[i + 1];
+ break;
+ case 'rport':
+ candidate.relatedPort = parseInt(parts[i + 1], 10);
+ break;
+ case 'tcptype':
+ candidate.tcpType = parts[i + 1];
+ break;
+ case 'ufrag':
+ candidate.ufrag = parts[i + 1]; // for backward compatibility.
+ candidate.usernameFragment = parts[i + 1];
+ break;
+ default:
+ // extension handling, in particular ufrag. Don't overwrite.
+ if (candidate[parts[i]] === undefined) {
+ candidate[parts[i]] = parts[i + 1];
+ }
+ break;
+ }
+ }
+ return candidate;
+};
+
+// Translates a candidate object into SDP candidate attribute.
+// This does not include the a= prefix!
+SDPUtils.writeCandidate = function (candidate) {
+ var sdp = [];
+ sdp.push(candidate.foundation);
+
+ var component = candidate.component;
+ if (component === 'rtp') {
+ sdp.push(1);
+ } else if (component === 'rtcp') {
+ sdp.push(2);
+ } else {
+ sdp.push(component);
+ }
+ sdp.push(candidate.protocol.toUpperCase());
+ sdp.push(candidate.priority);
+ sdp.push(candidate.address || candidate.ip);
+ sdp.push(candidate.port);
+
+ var type = candidate.type;
+ sdp.push('typ');
+ sdp.push(type);
+ if (type !== 'host' && candidate.relatedAddress && candidate.relatedPort) {
+ sdp.push('raddr');
+ sdp.push(candidate.relatedAddress);
+ sdp.push('rport');
+ sdp.push(candidate.relatedPort);
+ }
+ if (candidate.tcpType && candidate.protocol.toLowerCase() === 'tcp') {
+ sdp.push('tcptype');
+ sdp.push(candidate.tcpType);
+ }
+ if (candidate.usernameFragment || candidate.ufrag) {
+ sdp.push('ufrag');
+ sdp.push(candidate.usernameFragment || candidate.ufrag);
+ }
+ return 'candidate:' + sdp.join(' ');
+};
+
+// Parses an ice-options line, returns an array of option tags.
+// Sample input:
+// a=ice-options:foo bar
+SDPUtils.parseIceOptions = function (line) {
+ return line.substring(14).split(' ');
+};
+
+// Parses a rtpmap line, returns RTCRtpCoddecParameters. Sample input:
+// a=rtpmap:111 opus/48000/2
+SDPUtils.parseRtpMap = function (line) {
+ var parts = line.substring(9).split(' ');
+ var parsed = {
+ payloadType: parseInt(parts.shift(), 10) // was: id
+ };
+
+ parts = parts[0].split('/');
+
+ parsed.name = parts[0];
+ parsed.clockRate = parseInt(parts[1], 10); // was: clockrate
+ parsed.channels = parts.length === 3 ? parseInt(parts[2], 10) : 1;
+ // legacy alias, got renamed back to channels in ORTC.
+ parsed.numChannels = parsed.channels;
+ return parsed;
+};
+
+// Generates a rtpmap line from RTCRtpCodecCapability or
+// RTCRtpCodecParameters.
+SDPUtils.writeRtpMap = function (codec) {
+ var pt = codec.payloadType;
+ if (codec.preferredPayloadType !== undefined) {
+ pt = codec.preferredPayloadType;
+ }
+ var channels = codec.channels || codec.numChannels || 1;
+ return 'a=rtpmap:' + pt + ' ' + codec.name + '/' + codec.clockRate + (channels !== 1 ? '/' + channels : '') + '\r\n';
+};
+
+// Parses a extmap line (headerextension from RFC 5285). Sample input:
+// a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
+// a=extmap:2/sendonly urn:ietf:params:rtp-hdrext:toffset
+SDPUtils.parseExtmap = function (line) {
+ var parts = line.substring(9).split(' ');
+ return {
+ id: parseInt(parts[0], 10),
+ direction: parts[0].indexOf('/') > 0 ? parts[0].split('/')[1] : 'sendrecv',
+ uri: parts[1],
+ attributes: parts.slice(2).join(' ')
+ };
+};
+
+// Generates an extmap line from RTCRtpHeaderExtensionParameters or
+// RTCRtpHeaderExtension.
+SDPUtils.writeExtmap = function (headerExtension) {
+ return 'a=extmap:' + (headerExtension.id || headerExtension.preferredId) + (headerExtension.direction && headerExtension.direction !== 'sendrecv' ? '/' + headerExtension.direction : '') + ' ' + headerExtension.uri + (headerExtension.attributes ? ' ' + headerExtension.attributes : '') + '\r\n';
+};
+
+// Parses a fmtp line, returns dictionary. Sample input:
+// a=fmtp:96 vbr=on;cng=on
+// Also deals with vbr=on; cng=on
+SDPUtils.parseFmtp = function (line) {
+ var parsed = {};
+ var kv = void 0;
+ var parts = line.substring(line.indexOf(' ') + 1).split(';');
+ for (var j = 0; j < parts.length; j++) {
+ kv = parts[j].trim().split('=');
+ parsed[kv[0].trim()] = kv[1];
+ }
+ return parsed;
+};
+
+// Generates a fmtp line from RTCRtpCodecCapability or RTCRtpCodecParameters.
+SDPUtils.writeFmtp = function (codec) {
+ var line = '';
+ var pt = codec.payloadType;
+ if (codec.preferredPayloadType !== undefined) {
+ pt = codec.preferredPayloadType;
+ }
+ if (codec.parameters && Object.keys(codec.parameters).length) {
+ var params = [];
+ Object.keys(codec.parameters).forEach(function (param) {
+ if (codec.parameters[param] !== undefined) {
+ params.push(param + '=' + codec.parameters[param]);
+ } else {
+ params.push(param);
+ }
+ });
+ line += 'a=fmtp:' + pt + ' ' + params.join(';') + '\r\n';
+ }
+ return line;
+};
+
+// Parses a rtcp-fb line, returns RTCPRtcpFeedback object. Sample input:
+// a=rtcp-fb:98 nack rpsi
+SDPUtils.parseRtcpFb = function (line) {
+ var parts = line.substring(line.indexOf(' ') + 1).split(' ');
+ return {
+ type: parts.shift(),
+ parameter: parts.join(' ')
+ };
+};
+
+// Generate a=rtcp-fb lines from RTCRtpCodecCapability or RTCRtpCodecParameters.
+SDPUtils.writeRtcpFb = function (codec) {
+ var lines = '';
+ var pt = codec.payloadType;
+ if (codec.preferredPayloadType !== undefined) {
+ pt = codec.preferredPayloadType;
+ }
+ if (codec.rtcpFeedback && codec.rtcpFeedback.length) {
+ // FIXME: special handling for trr-int?
+ codec.rtcpFeedback.forEach(function (fb) {
+ lines += 'a=rtcp-fb:' + pt + ' ' + fb.type + (fb.parameter && fb.parameter.length ? ' ' + fb.parameter : '') + '\r\n';
+ });
+ }
+ return lines;
+};
+
+// Parses a RFC 5576 ssrc media attribute. Sample input:
+// a=ssrc:3735928559 cname:something
+SDPUtils.parseSsrcMedia = function (line) {
+ var sp = line.indexOf(' ');
+ var parts = {
+ ssrc: parseInt(line.substring(7, sp), 10)
+ };
+ var colon = line.indexOf(':', sp);
+ if (colon > -1) {
+ parts.attribute = line.substring(sp + 1, colon);
+ parts.value = line.substring(colon + 1);
+ } else {
+ parts.attribute = line.substring(sp + 1);
+ }
+ return parts;
+};
+
+// Parse a ssrc-group line (see RFC 5576). Sample input:
+// a=ssrc-group:semantics 12 34
+SDPUtils.parseSsrcGroup = function (line) {
+ var parts = line.substring(13).split(' ');
+ return {
+ semantics: parts.shift(),
+ ssrcs: parts.map(function (ssrc) {
+ return parseInt(ssrc, 10);
+ })
+ };
+};
+
+// Extracts the MID (RFC 5888) from a media section.
+// Returns the MID or undefined if no mid line was found.
+SDPUtils.getMid = function (mediaSection) {
+ var mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:')[0];
+ if (mid) {
+ return mid.substring(6);
+ }
+};
+
+// Parses a fingerprint line for DTLS-SRTP.
+SDPUtils.parseFingerprint = function (line) {
+ var parts = line.substring(14).split(' ');
+ return {
+ algorithm: parts[0].toLowerCase(), // algorithm is case-sensitive in Edge.
+ value: parts[1].toUpperCase() // the definition is upper-case in RFC 4572.
+ };
+};
+
+// Extracts DTLS parameters from SDP media section or sessionpart.
+// FIXME: for consistency with other functions this should only
+// get the fingerprint line as input. See also getIceParameters.
+SDPUtils.getDtlsParameters = function (mediaSection, sessionpart) {
+ var lines = SDPUtils.matchPrefix(mediaSection + sessionpart, 'a=fingerprint:');
+ // Note: a=setup line is ignored since we use the 'auto' role in Edge.
+ return {
+ role: 'auto',
+ fingerprints: lines.map(SDPUtils.parseFingerprint)
+ };
+};
+
+// Serializes DTLS parameters to SDP.
+SDPUtils.writeDtlsParameters = function (params, setupType) {
+ var sdp = 'a=setup:' + setupType + '\r\n';
+ params.fingerprints.forEach(function (fp) {
+ sdp += 'a=fingerprint:' + fp.algorithm + ' ' + fp.value + '\r\n';
+ });
+ return sdp;
+};
+
+// Parses a=crypto lines into
+// https://rawgit.com/aboba/edgertc/master/msortc-rs4.html#dictionary-rtcsrtpsdesparameters-members
+SDPUtils.parseCryptoLine = function (line) {
+ var parts = line.substring(9).split(' ');
+ return {
+ tag: parseInt(parts[0], 10),
+ cryptoSuite: parts[1],
+ keyParams: parts[2],
+ sessionParams: parts.slice(3)
+ };
+};
+
+SDPUtils.writeCryptoLine = function (parameters) {
+ return 'a=crypto:' + parameters.tag + ' ' + parameters.cryptoSuite + ' ' + (_typeof(parameters.keyParams) === 'object' ? SDPUtils.writeCryptoKeyParams(parameters.keyParams) : parameters.keyParams) + (parameters.sessionParams ? ' ' + parameters.sessionParams.join(' ') : '') + '\r\n';
+};
+
+// Parses the crypto key parameters into
+// https://rawgit.com/aboba/edgertc/master/msortc-rs4.html#rtcsrtpkeyparam*
+SDPUtils.parseCryptoKeyParams = function (keyParams) {
+ if (keyParams.indexOf('inline:') !== 0) {
+ return null;
+ }
+ var parts = keyParams.substring(7).split('|');
+ return {
+ keyMethod: 'inline',
+ keySalt: parts[0],
+ lifeTime: parts[1],
+ mkiValue: parts[2] ? parts[2].split(':')[0] : undefined,
+ mkiLength: parts[2] ? parts[2].split(':')[1] : undefined
+ };
+};
+
+SDPUtils.writeCryptoKeyParams = function (keyParams) {
+ return keyParams.keyMethod + ':' + keyParams.keySalt + (keyParams.lifeTime ? '|' + keyParams.lifeTime : '') + (keyParams.mkiValue && keyParams.mkiLength ? '|' + keyParams.mkiValue + ':' + keyParams.mkiLength : '');
+};
+
+// Extracts all SDES parameters.
+SDPUtils.getCryptoParameters = function (mediaSection, sessionpart) {
+ var lines = SDPUtils.matchPrefix(mediaSection + sessionpart, 'a=crypto:');
+ return lines.map(SDPUtils.parseCryptoLine);
+};
+
+// Parses ICE information from SDP media section or sessionpart.
+// FIXME: for consistency with other functions this should only
+// get the ice-ufrag and ice-pwd lines as input.
+SDPUtils.getIceParameters = function (mediaSection, sessionpart) {
+ var ufrag = SDPUtils.matchPrefix(mediaSection + sessionpart, 'a=ice-ufrag:')[0];
+ var pwd = SDPUtils.matchPrefix(mediaSection + sessionpart, 'a=ice-pwd:')[0];
+ if (!(ufrag && pwd)) {
+ return null;
+ }
+ return {
+ usernameFragment: ufrag.substring(12),
+ password: pwd.substring(10)
+ };
+};
+
+// Serializes ICE parameters to SDP.
+SDPUtils.writeIceParameters = function (params) {
+ var sdp = 'a=ice-ufrag:' + params.usernameFragment + '\r\n' + 'a=ice-pwd:' + params.password + '\r\n';
+ if (params.iceLite) {
+ sdp += 'a=ice-lite\r\n';
+ }
+ return sdp;
+};
+
+// Parses the SDP media section and returns RTCRtpParameters.
+SDPUtils.parseRtpParameters = function (mediaSection) {
+ var description = {
+ codecs: [],
+ headerExtensions: [],
+ fecMechanisms: [],
+ rtcp: []
+ };
+ var lines = SDPUtils.splitLines(mediaSection);
+ var mline = lines[0].split(' ');
+ description.profile = mline[2];
+ for (var i = 3; i < mline.length; i++) {
+ // find all codecs from mline[3..]
+ var pt = mline[i];
+ var rtpmapline = SDPUtils.matchPrefix(mediaSection, 'a=rtpmap:' + pt + ' ')[0];
+ if (rtpmapline) {
+ var codec = SDPUtils.parseRtpMap(rtpmapline);
+ var fmtps = SDPUtils.matchPrefix(mediaSection, 'a=fmtp:' + pt + ' ');
+ // Only the first a=fmtp: is considered.
+ codec.parameters = fmtps.length ? SDPUtils.parseFmtp(fmtps[0]) : {};
+ codec.rtcpFeedback = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-fb:' + pt + ' ').map(SDPUtils.parseRtcpFb);
+ description.codecs.push(codec);
+ // parse FEC mechanisms from rtpmap lines.
+ switch (codec.name.toUpperCase()) {
+ case 'RED':
+ case 'ULPFEC':
+ description.fecMechanisms.push(codec.name.toUpperCase());
+ break;
+ default:
+ // only RED and ULPFEC are recognized as FEC mechanisms.
+ break;
+ }
+ }
+ }
+ SDPUtils.matchPrefix(mediaSection, 'a=extmap:').forEach(function (line) {
+ description.headerExtensions.push(SDPUtils.parseExtmap(line));
+ });
+ var wildcardRtcpFb = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-fb:* ').map(SDPUtils.parseRtcpFb);
+ description.codecs.forEach(function (codec) {
+ wildcardRtcpFb.forEach(function (fb) {
+ var duplicate = codec.rtcpFeedback.find(function (existingFeedback) {
+ return existingFeedback.type === fb.type && existingFeedback.parameter === fb.parameter;
+ });
+ if (!duplicate) {
+ codec.rtcpFeedback.push(fb);
+ }
+ });
+ });
+ // FIXME: parse rtcp.
+ return description;
+};
+
+// Generates parts of the SDP media section describing the capabilities /
+// parameters.
+SDPUtils.writeRtpDescription = function (kind, caps) {
+ var sdp = '';
+
+ // Build the mline.
+ sdp += 'm=' + kind + ' ';
+ sdp += caps.codecs.length > 0 ? '9' : '0'; // reject if no codecs.
+ sdp += ' ' + (caps.profile || 'UDP/TLS/RTP/SAVPF') + ' ';
+ sdp += caps.codecs.map(function (codec) {
+ if (codec.preferredPayloadType !== undefined) {
+ return codec.preferredPayloadType;
+ }
+ return codec.payloadType;
+ }).join(' ') + '\r\n';
+
+ sdp += 'c=IN IP4 0.0.0.0\r\n';
+ sdp += 'a=rtcp:9 IN IP4 0.0.0.0\r\n';
+
+ // Add a=rtpmap lines for each codec. Also fmtp and rtcp-fb.
+ caps.codecs.forEach(function (codec) {
+ sdp += SDPUtils.writeRtpMap(codec);
+ sdp += SDPUtils.writeFmtp(codec);
+ sdp += SDPUtils.writeRtcpFb(codec);
+ });
+ var maxptime = 0;
+ caps.codecs.forEach(function (codec) {
+ if (codec.maxptime > maxptime) {
+ maxptime = codec.maxptime;
+ }
+ });
+ if (maxptime > 0) {
+ sdp += 'a=maxptime:' + maxptime + '\r\n';
+ }
+
+ if (caps.headerExtensions) {
+ caps.headerExtensions.forEach(function (extension) {
+ sdp += SDPUtils.writeExtmap(extension);
+ });
+ }
+ // FIXME: write fecMechanisms.
+ return sdp;
+};
+
+// Parses the SDP media section and returns an array of
+// RTCRtpEncodingParameters.
+SDPUtils.parseRtpEncodingParameters = function (mediaSection) {
+ var encodingParameters = [];
+ var description = SDPUtils.parseRtpParameters(mediaSection);
+ var hasRed = description.fecMechanisms.indexOf('RED') !== -1;
+ var hasUlpfec = description.fecMechanisms.indexOf('ULPFEC') !== -1;
+
+ // filter a=ssrc:... cname:, ignore PlanB-msid
+ var ssrcs = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:').map(function (line) {
+ return SDPUtils.parseSsrcMedia(line);
+ }).filter(function (parts) {
+ return parts.attribute === 'cname';
+ });
+ var primarySsrc = ssrcs.length > 0 && ssrcs[0].ssrc;
+ var secondarySsrc = void 0;
+
+ var flows = SDPUtils.matchPrefix(mediaSection, 'a=ssrc-group:FID').map(function (line) {
+ var parts = line.substring(17).split(' ');
+ return parts.map(function (part) {
+ return parseInt(part, 10);
+ });
+ });
+ if (flows.length > 0 && flows[0].length > 1 && flows[0][0] === primarySsrc) {
+ secondarySsrc = flows[0][1];
+ }
+
+ description.codecs.forEach(function (codec) {
+ if (codec.name.toUpperCase() === 'RTX' && codec.parameters.apt) {
+ var encParam = {
+ ssrc: primarySsrc,
+ codecPayloadType: parseInt(codec.parameters.apt, 10)
+ };
+ if (primarySsrc && secondarySsrc) {
+ encParam.rtx = { ssrc: secondarySsrc };
+ }
+ encodingParameters.push(encParam);
+ if (hasRed) {
+ encParam = JSON.parse(JSON.stringify(encParam));
+ encParam.fec = {
+ ssrc: primarySsrc,
+ mechanism: hasUlpfec ? 'red+ulpfec' : 'red'
+ };
+ encodingParameters.push(encParam);
+ }
+ }
+ });
+ if (encodingParameters.length === 0 && primarySsrc) {
+ encodingParameters.push({
+ ssrc: primarySsrc
+ });
+ }
+
+ // we support both b=AS and b=TIAS but interpret AS as TIAS.
+ var bandwidth = SDPUtils.matchPrefix(mediaSection, 'b=');
+ if (bandwidth.length) {
+ if (bandwidth[0].indexOf('b=TIAS:') === 0) {
+ bandwidth = parseInt(bandwidth[0].substring(7), 10);
+ } else if (bandwidth[0].indexOf('b=AS:') === 0) {
+ // use formula from JSEP to convert b=AS to TIAS value.
+ bandwidth = parseInt(bandwidth[0].substring(5), 10) * 1000 * 0.95 - 50 * 40 * 8;
+ } else {
+ bandwidth = undefined;
+ }
+ encodingParameters.forEach(function (params) {
+ params.maxBitrate = bandwidth;
+ });
+ }
+ return encodingParameters;
+};
+
+// parses http://draft.ortc.org/#rtcrtcpparameters*
+SDPUtils.parseRtcpParameters = function (mediaSection) {
+ var rtcpParameters = {};
+
+ // Gets the first SSRC. Note that with RTX there might be multiple
+ // SSRCs.
+ var remoteSsrc = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:').map(function (line) {
+ return SDPUtils.parseSsrcMedia(line);
+ }).filter(function (obj) {
+ return obj.attribute === 'cname';
+ })[0];
+ if (remoteSsrc) {
+ rtcpParameters.cname = remoteSsrc.value;
+ rtcpParameters.ssrc = remoteSsrc.ssrc;
+ }
+
+ // Edge uses the compound attribute instead of reducedSize
+ // compound is !reducedSize
+ var rsize = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-rsize');
+ rtcpParameters.reducedSize = rsize.length > 0;
+ rtcpParameters.compound = rsize.length === 0;
+
+ // parses the rtcp-mux attrіbute.
+ // Note that Edge does not support unmuxed RTCP.
+ var mux = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-mux');
+ rtcpParameters.mux = mux.length > 0;
+
+ return rtcpParameters;
+};
+
+SDPUtils.writeRtcpParameters = function (rtcpParameters) {
+ var sdp = '';
+ if (rtcpParameters.reducedSize) {
+ sdp += 'a=rtcp-rsize\r\n';
+ }
+ if (rtcpParameters.mux) {
+ sdp += 'a=rtcp-mux\r\n';
+ }
+ if (rtcpParameters.ssrc !== undefined && rtcpParameters.cname) {
+ sdp += 'a=ssrc:' + rtcpParameters.ssrc + ' cname:' + rtcpParameters.cname + '\r\n';
+ }
+ return sdp;
+};
+
+// parses either a=msid: or a=ssrc:... msid lines and returns
+// the id of the MediaStream and MediaStreamTrack.
+SDPUtils.parseMsid = function (mediaSection) {
+ var parts = void 0;
+ var spec = SDPUtils.matchPrefix(mediaSection, 'a=msid:');
+ if (spec.length === 1) {
+ parts = spec[0].substring(7).split(' ');
+ return { stream: parts[0], track: parts[1] };
+ }
+ var planB = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:').map(function (line) {
+ return SDPUtils.parseSsrcMedia(line);
+ }).filter(function (msidParts) {
+ return msidParts.attribute === 'msid';
+ });
+ if (planB.length > 0) {
+ parts = planB[0].value.split(' ');
+ return { stream: parts[0], track: parts[1] };
+ }
+};
+
+// SCTP
+// parses draft-ietf-mmusic-sctp-sdp-26 first and falls back
+// to draft-ietf-mmusic-sctp-sdp-05
+SDPUtils.parseSctpDescription = function (mediaSection) {
+ var mline = SDPUtils.parseMLine(mediaSection);
+ var maxSizeLine = SDPUtils.matchPrefix(mediaSection, 'a=max-message-size:');
+ var maxMessageSize = void 0;
+ if (maxSizeLine.length > 0) {
+ maxMessageSize = parseInt(maxSizeLine[0].substring(19), 10);
+ }
+ if (isNaN(maxMessageSize)) {
+ maxMessageSize = 65536;
+ }
+ var sctpPort = SDPUtils.matchPrefix(mediaSection, 'a=sctp-port:');
+ if (sctpPort.length > 0) {
+ return {
+ port: parseInt(sctpPort[0].substring(12), 10),
+ protocol: mline.fmt,
+ maxMessageSize: maxMessageSize
+ };
+ }
+ var sctpMapLines = SDPUtils.matchPrefix(mediaSection, 'a=sctpmap:');
+ if (sctpMapLines.length > 0) {
+ var parts = sctpMapLines[0].substring(10).split(' ');
+ return {
+ port: parseInt(parts[0], 10),
+ protocol: parts[1],
+ maxMessageSize: maxMessageSize
+ };
+ }
+};
+
+// SCTP
+// outputs the draft-ietf-mmusic-sctp-sdp-26 version that all browsers
+// support by now receiving in this format, unless we originally parsed
+// as the draft-ietf-mmusic-sctp-sdp-05 format (indicated by the m-line
+// protocol of DTLS/SCTP -- without UDP/ or TCP/)
+SDPUtils.writeSctpDescription = function (media, sctp) {
+ var output = [];
+ if (media.protocol !== 'DTLS/SCTP') {
+ output = ['m=' + media.kind + ' 9 ' + media.protocol + ' ' + sctp.protocol + '\r\n', 'c=IN IP4 0.0.0.0\r\n', 'a=sctp-port:' + sctp.port + '\r\n'];
+ } else {
+ output = ['m=' + media.kind + ' 9 ' + media.protocol + ' ' + sctp.port + '\r\n', 'c=IN IP4 0.0.0.0\r\n', 'a=sctpmap:' + sctp.port + ' ' + sctp.protocol + ' 65535\r\n'];
+ }
+ if (sctp.maxMessageSize !== undefined) {
+ output.push('a=max-message-size:' + sctp.maxMessageSize + '\r\n');
+ }
+ return output.join('');
+};
+
+// Generate a session ID for SDP.
+// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-20#section-5.2.1
+// recommends using a cryptographically random +ve 64-bit value
+// but right now this should be acceptable and within the right range
+SDPUtils.generateSessionId = function () {
+ return Math.random().toString().substr(2, 22);
+};
+
+// Write boiler plate for start of SDP
+// sessId argument is optional - if not supplied it will
+// be generated randomly
+// sessVersion is optional and defaults to 2
+// sessUser is optional and defaults to 'thisisadapterortc'
+SDPUtils.writeSessionBoilerplate = function (sessId, sessVer, sessUser) {
+ var sessionId = void 0;
+ var version = sessVer !== undefined ? sessVer : 2;
+ if (sessId) {
+ sessionId = sessId;
+ } else {
+ sessionId = SDPUtils.generateSessionId();
+ }
+ var user = sessUser || 'thisisadapterortc';
+ // FIXME: sess-id should be an NTP timestamp.
+ return 'v=0\r\n' + 'o=' + user + ' ' + sessionId + ' ' + version + ' IN IP4 127.0.0.1\r\n' + 's=-\r\n' + 't=0 0\r\n';
+};
+
+// Gets the direction from the mediaSection or the sessionpart.
+SDPUtils.getDirection = function (mediaSection, sessionpart) {
+ // Look for sendrecv, sendonly, recvonly, inactive, default to sendrecv.
+ var lines = SDPUtils.splitLines(mediaSection);
+ for (var i = 0; i < lines.length; i++) {
+ switch (lines[i]) {
+ case 'a=sendrecv':
+ case 'a=sendonly':
+ case 'a=recvonly':
+ case 'a=inactive':
+ return lines[i].substring(2);
+ default:
+ // FIXME: What should happen here?
+ }
+ }
+ if (sessionpart) {
+ return SDPUtils.getDirection(sessionpart);
+ }
+ return 'sendrecv';
+};
+
+SDPUtils.getKind = function (mediaSection) {
+ var lines = SDPUtils.splitLines(mediaSection);
+ var mline = lines[0].split(' ');
+ return mline[0].substring(2);
+};
+
+SDPUtils.isRejected = function (mediaSection) {
+ return mediaSection.split(' ', 2)[1] === '0';
+};
+
+SDPUtils.parseMLine = function (mediaSection) {
+ var lines = SDPUtils.splitLines(mediaSection);
+ var parts = lines[0].substring(2).split(' ');
+ return {
+ kind: parts[0],
+ port: parseInt(parts[1], 10),
+ protocol: parts[2],
+ fmt: parts.slice(3).join(' ')
+ };
+};
+
+SDPUtils.parseOLine = function (mediaSection) {
+ var line = SDPUtils.matchPrefix(mediaSection, 'o=')[0];
+ var parts = line.substring(2).split(' ');
+ return {
+ username: parts[0],
+ sessionId: parts[1],
+ sessionVersion: parseInt(parts[2], 10),
+ netType: parts[3],
+ addressType: parts[4],
+ address: parts[5]
+ };
+};
+
+// a very naive interpretation of a valid SDP.
+SDPUtils.isValidSDP = function (blob) {
+ if (typeof blob !== 'string' || blob.length === 0) {
+ return false;
+ }
+ var lines = SDPUtils.splitLines(blob);
+ for (var i = 0; i < lines.length; i++) {
+ if (lines[i].length < 2 || lines[i].charAt(1) !== '=') {
+ return false;
+ }
+ // TODO: check the modifier a bit more.
+ }
+ return true;
+};
+
+// Expose public methods.
+if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object') {
+ module.exports = SDPUtils;
+}
+},{}]},{},[1]);
diff --git a/node_modules/webrtc-adapter/out/esbuild.js b/node_modules/webrtc-adapter/out/esbuild.js
new file mode 100644
index 0000000..0f8320a
--- /dev/null
+++ b/node_modules/webrtc-adapter/out/esbuild.js
@@ -0,0 +1,35 @@
+"use strict";(()=>{var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var x=P(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});var J=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};E.extractVersion=F;E.wrapPeerConnectionEvent=Te;E.disableLog=Pe;E.disableWarnings=_e;E.log=Ee;E.deprecated=Me;E.detectBrowser=be;E.compactObject=ee;E.walkStats=N;E.filterStats=ke;function Re(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Z=!0,w=!0;function F(e,t,r){var n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function Te(e,t,r){if(!!e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(u,c){if(u!==t)return i.apply(this,arguments);var p=function(o){var d=r(o);d&&(c.handleEvent?c.handleEvent(d):c(d))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(c,p),i.apply(this,[u,p])};var a=n.removeEventListener;n.removeEventListener=function(u,c){if(u!==t||!this._eventMap||!this._eventMap[t])return a.apply(this,arguments);if(!this._eventMap[t].has(c))return a.apply(this,arguments);var p=this._eventMap[t].get(c);return this._eventMap[t].delete(c),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,a.apply(this,[u,p])},Object.defineProperty(n,"on"+t,{get:function(){return this["_on"+t]},set:function(c){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),c&&this.addEventListener(t,this["_on"+t]=c)},enumerable:!0,configurable:!0})}}function Pe(e){return typeof e!="boolean"?new Error("Argument type: "+(typeof e>"u"?"undefined":J(e))+". Please use a boolean."):(Z=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function _e(e){return typeof e!="boolean"?new Error("Argument type: "+(typeof e>"u"?"undefined":J(e))+". Please use a boolean."):(w=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Ee(){if((typeof window>"u"?"undefined":J(window))==="object"){if(Z)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Me(e,t){!w||console.warn(e+" is deprecated, please use "+t+" instead.")}function be(e){var t={browser:null,version:null};if(typeof e>"u"||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=F(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||e.isSecureContext===!1&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=F(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.RTCPeerConnection&&r.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser="safari",t.version=F(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype;else return t.browser="Not a supported browser.",t;return t}function Q(e){return Object.prototype.toString.call(e)==="[object Object]"}function ee(e){return Q(e)?Object.keys(e).reduce(function(t,r){var n=Q(e[r]),i=n?ee(e[r]):e[r],a=n&&!Object.keys(i).length;return i===void 0||a?t:Object.assign(t,Re({},r,i))},{}):e}function N(e,t,r){!t||r.has(t.id)||(r.set(t.id,t),Object.keys(t).forEach(function(n){n.endsWith("Id")?N(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach(function(i){N(e,e.get(i),r)})}))}function ke(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(t===null)return i;var a=[];return e.forEach(function(u){u.type==="track"&&u.trackIdentifier===t.id&&a.push(u)}),a.forEach(function(u){e.forEach(function(c){c.type===n&&c.trackId===u.id&&N(e,c,i)})}),i}});var re=P(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});var I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};j.shimGetUserMedia=Ie;var xe=x(),De=Oe(xe);function Oe(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}var te=De.log;function Ie(e,t){var r=e&&e.navigator;if(!!r.mediaDevices){var n=function(s){if((typeof s>"u"?"undefined":I(s))!=="object"||s.mandatory||s.optional)return s;var o={};return Object.keys(s).forEach(function(d){if(!(d==="require"||d==="advanced"||d==="mediaSource")){var m=I(s[d])==="object"?s[d]:{ideal:s[d]};m.exact!==void 0&&typeof m.exact=="number"&&(m.min=m.max=m.exact);var l=function(y,g){return y?y+g.charAt(0).toUpperCase()+g.slice(1):g==="deviceId"?"sourceId":g};if(m.ideal!==void 0){o.optional=o.optional||[];var v={};typeof m.ideal=="number"?(v[l("min",d)]=m.ideal,o.optional.push(v),v={},v[l("max",d)]=m.ideal,o.optional.push(v)):(v[l("",d)]=m.ideal,o.optional.push(v))}m.exact!==void 0&&typeof m.exact!="number"?(o.mandatory=o.mandatory||{},o.mandatory[l("",d)]=m.exact):["min","max"].forEach(function(h){m[h]!==void 0&&(o.mandatory=o.mandatory||{},o.mandatory[l(h,d)]=m[h])})}}),s.advanced&&(o.optional=(o.optional||[]).concat(s.advanced)),o},i=function(s,o){if(t.version>=61)return o(s);if(s=JSON.parse(JSON.stringify(s)),s&&I(s.audio)==="object"){var d=function(y,g,U){g in y&&!(U in y)&&(y[U]=y[g],delete y[g])};s=JSON.parse(JSON.stringify(s)),d(s.audio,"autoGainControl","googAutoGainControl"),d(s.audio,"noiseSuppression","googNoiseSuppression"),s.audio=n(s.audio)}if(s&&I(s.video)==="object"){var m=s.video.facingMode;m=m&&((typeof m>"u"?"undefined":I(m))==="object"?m:{ideal:m});var l=t.version<66;if(m&&(m.exact==="user"||m.exact==="environment"||m.ideal==="user"||m.ideal==="environment")&&!(r.mediaDevices.getSupportedConstraints&&r.mediaDevices.getSupportedConstraints().facingMode&&!l)){delete s.video.facingMode;var v=void 0;if(m.exact==="environment"||m.ideal==="environment"?v=["back","rear"]:(m.exact==="user"||m.ideal==="user")&&(v=["front"]),v)return r.mediaDevices.enumerateDevices().then(function(h){h=h.filter(function(g){return g.kind==="videoinput"});var y=h.find(function(g){return v.some(function(U){return g.label.toLowerCase().includes(U)})});return!y&&h.length&&v.includes("back")&&(y=h[h.length-1]),y&&(s.video.deviceId=m.exact?{exact:y.deviceId}:{ideal:y.deviceId}),s.video=n(s.video),te("chrome: "+JSON.stringify(s)),o(s)})}s.video=n(s.video)}return te("chrome: "+JSON.stringify(s)),o(s)},a=function(s){return t.version>=64?s:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[s.name]||s.name,message:s.message,constraint:s.constraint||s.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},u=function(s,o,d){i(s,function(m){r.webkitGetUserMedia(m,o,function(l){d&&d(a(l))})})};if(r.getUserMedia=u.bind(r),r.mediaDevices.getUserMedia){var c=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(p){return i(p,function(s){return c(s).then(function(o){if(s.audio&&!o.getAudioTracks().length||s.video&&!o.getVideoTracks().length)throw o.getTracks().forEach(function(d){d.stop()}),new DOMException("","NotFoundError");return o},function(o){return Promise.reject(a(o))})})}}}}});var ne=P(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.shimGetDisplayMedia=Le;function Le(e,t){if(!(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)&&!!e.navigator.mediaDevices){if(typeof t!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then(function(i){var a=n.video&&n.video.width,u=n.video&&n.video.height,c=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:i,maxFrameRate:c||3}},a&&(n.video.mandatory.maxWidth=a),u&&(n.video.mandatory.maxHeight=u),e.navigator.mediaDevices.getUserMedia(n)})}}}});var ie=P(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.shimSelectAudioOutput=Ae;function Ae(e){"HTMLMediaElement"in e&&"setSinkId"in e.HTMLMediaElement.prototype&&(!(e.navigator&&e.navigator.mediaDevices)||!e.navigator.mediaDevices.enumerateDevices||e.navigator.mediaDevices.selectAudioOutput||(e.navigator.mediaDevices.selectAudioOutput=function(){return e.navigator.mediaDevices.enumerateDevices().then(function(t){return t.filter(function(r){return r.kind==="audiooutput"})})}))}});var oe=P(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.shimSelectAudioOutput=S.shimGetDisplayMedia=S.shimGetUserMedia=void 0;var z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ge=re();Object.defineProperty(S,"shimGetUserMedia",{enumerable:!0,get:function(){return Ge.shimGetUserMedia}});var Ue=ne();Object.defineProperty(S,"shimGetDisplayMedia",{enumerable:!0,get:function(){return Ue.shimGetDisplayMedia}});var Fe=ie();Object.defineProperty(S,"shimSelectAudioOutput",{enumerable:!0,get:function(){return Fe.shimSelectAudioOutput}});S.shimMediaStream=qe;S.shimOnTrack=Ve;S.shimGetSendersWithDtmf=Je;S.shimGetStats=je;S.shimSenderReceiverGetStats=Be;S.shimAddTrackRemoveTrackWithNative=se;S.shimAddTrackRemoveTrack=Ke;S.shimPeerConnection=We;S.fixNegotiationNeeded=He;var Ne=x(),L=ze(Ne);function ze(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function ae(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qe(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Ve(e){if((typeof e>"u"?"undefined":z(e))==="object"&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return this._ontrackpoly||(this._ontrackpoly=function(i){i.stream.addEventListener("addtrack",function(a){var u=void 0;e.RTCPeerConnection.prototype.getReceivers?u=n.getReceivers().find(function(p){return p.track&&p.track.id===a.track.id}):u={track:a.track};var c=new Event("track");c.track=a.track,c.receiver=u,c.transceiver={receiver:u},c.streams=[i.stream],n.dispatchEvent(c)}),i.stream.getTracks().forEach(function(a){var u=void 0;e.RTCPeerConnection.prototype.getReceivers?u=n.getReceivers().find(function(p){return p.track&&p.track.id===a.id}):u={track:a};var c=new Event("track");c.track=a,c.receiver=u,c.transceiver={receiver:u},c.streams=[i.stream],n.dispatchEvent(c)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else L.wrapPeerConnectionEvent(e,"track",function(r){return r.transceiver||Object.defineProperty(r,"transceiver",{value:{receiver:r.receiver}}),r})}function Je(e){if((typeof e>"u"?"undefined":z(e))==="object"&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(p,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=p.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:p}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(p,s){var o=r.apply(this,arguments);return o||(o=t(this,p),this._senders.push(o)),o};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(p){n.apply(this,arguments);var s=this._senders.indexOf(p);s!==-1&&this._senders.splice(s,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(p){var s=this;this._senders=this._senders||[],i.apply(this,[p]),p.getTracks().forEach(function(o){s._senders.push(t(s,o))})};var a=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(p){var s=this;this._senders=this._senders||[],a.apply(this,[p]),p.getTracks().forEach(function(o){var d=s._senders.find(function(m){return m.track===o});d&&s._senders.splice(s._senders.indexOf(d),1)})}}else if((typeof e>"u"?"undefined":z(e))==="object"&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var u=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var p=this,s=u.apply(this,[]);return s.forEach(function(o){return o._pc=p}),s},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function je(e){if(!!e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var n=this,i=Array.prototype.slice.call(arguments),a=i[0],u=i[1],c=i[2];if(arguments.length>0&&typeof a=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof a!="function"))return t.apply(this,[]);var p=function(m){var l={},v=m.result();return v.forEach(function(h){var y={id:h.id,timestamp:h.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[h.type]||h.type};h.names().forEach(function(g){y[g]=h.stat(g)}),l[y.id]=y}),l},s=function(m){return new Map(Object.keys(m).map(function(l){return[l,m[l]]}))};if(arguments.length>=2){var o=function(m){u(s(p(m)))};return t.apply(this,[o,a])}return new Promise(function(d,m){t.apply(n,[function(l){d(s(p(l)))},m])}).then(u,c)}}}function Be(e){if(!!((typeof e>"u"?"undefined":z(e))==="object"&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver)){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var u=this,c=t.apply(this,[]);return c.forEach(function(p){return p._pc=u}),c});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var u=r.apply(this,arguments);return u._pc=this,u}),e.RTCRtpSender.prototype.getStats=function(){var u=this;return this._pc.getStats().then(function(c){return L.filterStats(c,u.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var u=this,c=n.apply(this,[]);return c.forEach(function(p){return p._pc=u}),c}),L.wrapPeerConnectionEvent(e,"track",function(a){return a.receiver._pc=a.srcElement,a}),e.RTCRtpReceiver.prototype.getStats=function(){var u=this;return this._pc.getStats().then(function(c){return L.filterStats(c,u.track,!1)})}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var u=arguments[0],c=void 0,p=void 0,s=void 0;return this.getSenders().forEach(function(o){o.track===u&&(c?s=!0:c=o)}),this.getReceivers().forEach(function(o){return o.track===u&&(p?s=!0:p=o),o.track===u}),s||c&&p?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):c?c.getStats():p?p.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function se(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var u=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(c){return u._shimmedLocalStreams[c][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(u,c){if(!c)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var p=t.apply(this,arguments);return this._shimmedLocalStreams[c.id]?this._shimmedLocalStreams[c.id].indexOf(p)===-1&&this._shimmedLocalStreams[c.id].push(p):this._shimmedLocalStreams[c.id]=[c,p],p};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(u){var c=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},u.getTracks().forEach(function(o){var d=c.getSenders().find(function(m){return m.track===o});if(d)throw new DOMException("Track already exists.","InvalidAccessError")});var p=this.getSenders();r.apply(this,arguments);var s=this.getSenders().filter(function(o){return p.indexOf(o)===-1});this._shimmedLocalStreams[u.id]=[u].concat(s)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(u){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[u.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(u){var c=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},u&&Object.keys(this._shimmedLocalStreams).forEach(function(p){var s=c._shimmedLocalStreams[p].indexOf(u);s!==-1&&c._shimmedLocalStreams[p].splice(s,1),c._shimmedLocalStreams[p].length===1&&delete c._shimmedLocalStreams[p]}),i.apply(this,arguments)}}function Ke(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return se(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var o=this,d=r.apply(this);return this._reverseStreams=this._reverseStreams||{},d.map(function(m){return o._reverseStreams[m.id]})};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(o){var d=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},o.getTracks().forEach(function(l){var v=d.getSenders().find(function(h){return h.track===l});if(v)throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[o.id]){var m=new e.MediaStream(o.getTracks());this._streams[o.id]=m,this._reverseStreams[m.id]=o,o=m}n.apply(this,[o])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(o){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[o.id]||o]),delete this._reverseStreams[this._streams[o.id]?this._streams[o.id].id:o.id],delete this._streams[o.id]},e.RTCPeerConnection.prototype.addTrack=function(o,d){var m=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var l=[].slice.call(arguments,1);if(l.length!==1||!l[0].getTracks().find(function(g){return g===o}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var v=this.getSenders().find(function(g){return g.track===o});if(v)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var h=this._streams[d.id];if(h)h.addTrack(o),Promise.resolve().then(function(){m.dispatchEvent(new Event("negotiationneeded"))});else{var y=new e.MediaStream([o]);this._streams[d.id]=y,this._reverseStreams[y.id]=d,this.addStream(y)}return this.getSenders().find(function(g){return g.track===o})};function a(s,o){var d=o.sdp;return Object.keys(s._reverseStreams||[]).forEach(function(m){var l=s._reverseStreams[m],v=s._streams[l.id];d=d.replace(new RegExp(v.id,"g"),l.id)}),new RTCSessionDescription({type:o.type,sdp:d})}function u(s,o){var d=o.sdp;return Object.keys(s._reverseStreams||[]).forEach(function(m){var l=s._reverseStreams[m],v=s._streams[l.id];d=d.replace(new RegExp(l.id,"g"),v.id)}),new RTCSessionDescription({type:o.type,sdp:d})}["createOffer","createAnswer"].forEach(function(s){var o=e.RTCPeerConnection.prototype[s],d=ae({},s,function(){var m=this,l=arguments,v=arguments.length&&typeof arguments[0]=="function";return v?o.apply(this,[function(h){var y=a(m,h);l[0].apply(null,[y])},function(h){l[1]&&l[1].apply(null,h)},arguments[2]]):o.apply(this,arguments).then(function(h){return a(m,h)})});e.RTCPeerConnection.prototype[s]=d[s]});var c=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?c.apply(this,arguments):(arguments[0]=u(this,arguments[0]),c.apply(this,arguments))};var p=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var o=p.get.apply(this);return o.type===""?o:a(this,o)}}),e.RTCPeerConnection.prototype.removeTrack=function(o){var d=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!o._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");var m=o._pc===this;if(!m)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var l=void 0;Object.keys(this._streams).forEach(function(v){var h=d._streams[v].getTracks().find(function(y){return o.track===y});h&&(l=d._streams[v])}),l&&(l.getTracks().length===1?this.removeStream(this._reverseStreams[l.id]):l.removeTrack(o.track),this.dispatchEvent(new Event("negotiationneeded")))}}function We(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),!!e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(r){var n=e.RTCPeerConnection.prototype[r],i=ae({},r,function(){return arguments[0]=new(r==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)});e.RTCPeerConnection.prototype[r]=i[r]})}function He(e,t){L.wrapPeerConnectionEvent(e,"negotiationneeded",function(r){var n=r.target;if(!((t.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return r})}});var ce=P(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});var W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};H.shimGetUserMedia=Qe;var Xe=x(),Ye=$e(Xe);function $e(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function Qe(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(p,s,o){Ye.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(p).then(s,o)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(s,o,d){o in s&&!(d in s)&&(s[d]=s[o],delete s[o])},a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(p){return(typeof p>"u"?"undefined":W(p))==="object"&&W(p.audio)==="object"&&(p=JSON.parse(JSON.stringify(p)),i(p.audio,"autoGainControl","mozAutoGainControl"),i(p.audio,"noiseSuppression","mozNoiseSuppression")),a(p)},n&&n.prototype.getSettings){var u=n.prototype.getSettings;n.prototype.getSettings=function(){var p=u.apply(this,arguments);return i(p,"mozAutoGainControl","autoGainControl"),i(p,"mozNoiseSuppression","noiseSuppression"),p}}if(n&&n.prototype.applyConstraints){var c=n.prototype.applyConstraints;n.prototype.applyConstraints=function(p){return this.kind==="audio"&&(typeof p>"u"?"undefined":W(p))==="object"&&(p=JSON.parse(JSON.stringify(p)),i(p,"autoGainControl","mozAutoGainControl"),i(p,"noiseSuppression","mozNoiseSuppression")),c.apply(this,[p])}}}}});var ue=P(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.shimGetDisplayMedia=Ze;function Ze(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||!e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){var i=new DOMException("getDisplayMedia without video constraints is undefined");return i.name="NotFoundError",i.code=8,Promise.reject(i)}return n.video===!0?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}});var fe=P(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.shimGetDisplayMedia=R.shimGetUserMedia=void 0;var D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},we=ce();Object.defineProperty(R,"shimGetUserMedia",{enumerable:!0,get:function(){return we.shimGetUserMedia}});var et=ue();Object.defineProperty(R,"shimGetDisplayMedia",{enumerable:!0,get:function(){return et.shimGetDisplayMedia}});R.shimOnTrack=it;R.shimPeerConnection=at;R.shimSenderGetStats=st;R.shimReceiverGetStats=ot;R.shimRemoveStream=ct;R.shimRTCDataChannel=ut;R.shimAddTransceiver=pt;R.shimGetParameters=ft;R.shimCreateOffer=dt;R.shimCreateAnswer=mt;var tt=x(),pe=rt(tt);function rt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function nt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function it(e){(typeof e>"u"?"undefined":D(e))==="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function at(e,t){if(!((typeof e>"u"?"undefined":D(e))!=="object"||!(e.RTCPeerConnection||e.mozRTCPeerConnection))){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){var a=e.RTCPeerConnection.prototype[i],u=nt({},i,function(){return arguments[0]=new(i==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),a.apply(this,arguments)});e.RTCPeerConnection.prototype[i]=u[i]});var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var a=Array.prototype.slice.call(arguments),u=a[0],c=a[1],p=a[2];return n.apply(this,[u||null]).then(function(s){if(t.version<53&&!c)try{s.forEach(function(o){o.type=r[o.type]||o.type})}catch(o){if(o.name!=="TypeError")throw o;s.forEach(function(d,m){s.set(m,Object.assign({},d,{type:r[d.type]||d.type}))})}return s}).then(c,p)}}}function st(e){if(!!((typeof e>"u"?"undefined":D(e))==="object"&&e.RTCPeerConnection&&e.RTCRtpSender)&&!(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var i=this,a=t.apply(this,[]);return a.forEach(function(u){return u._pc=i}),a});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var i=r.apply(this,arguments);return i._pc=this,i}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function ot(e){if(!!((typeof e>"u"?"undefined":D(e))==="object"&&e.RTCPeerConnection&&e.RTCRtpSender)&&!(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var n=this,i=t.apply(this,[]);return i.forEach(function(a){return a._pc=n}),i}),pe.wrapPeerConnectionEvent(e,"track",function(r){return r.receiver._pc=r.srcElement,r}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function ct(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(r){var n=this;pe.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(i){i.track&&r.getTracks().includes(i.track)&&n.removeTrack(i)})})}function ut(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function pt(e){if(!!((typeof e>"u"?"undefined":D(e))==="object"&&e.RTCPeerConnection)){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var n=arguments[1],i=n&&"sendEncodings"in n;i&&n.sendEncodings.forEach(function(p){if("rid"in p){var s=/^[a-z0-9]{0,16}$/i;if(!s.test(p.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in p&&!(parseFloat(p.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in p&&!(parseFloat(p.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var a=t.apply(this,arguments);if(i){var u=a.sender,c=u.getParameters();(!("encodings"in c)||c.encodings.length===1&&Object.keys(c.encodings[0]).length===0)&&(c.encodings=n.sendEncodings,u.sendEncodings=n.sendEncodings,this.setParametersPromises.push(u.setParameters(c).then(function(){delete u.sendEncodings}).catch(function(){delete u.sendEncodings})))}return a})}}function ft(e){if(!!((typeof e>"u"?"undefined":D(e))==="object"&&e.RTCRtpSender)){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var n=t.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}}function dt(e){if(!!((typeof e>"u"?"undefined":D(e))==="object"&&e.RTCPeerConnection)){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var n=this,i=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(n,i)}).finally(function(){n.setParametersPromises=[]}):t.apply(this,arguments)}}}function mt(e){if(!!((typeof e>"u"?"undefined":D(e))==="object"&&e.RTCPeerConnection)){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var n=this,i=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(n,i)}).finally(function(){n.setParametersPromises=[]}):t.apply(this,arguments)}}}});var le=P(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});var A=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};M.shimLocalStreamsAPI=vt;M.shimRemoteStreamsAPI=yt;M.shimCallbacksAPI=gt;M.shimGetUserMedia=Ct;M.shimConstraints=me;M.shimRTCIceServerUrls=St;M.shimTrackEventTransceiver=Rt;M.shimCreateOfferLegacy=Tt;M.shimAudioContext=Pt;var lt=x(),de=ht(lt);function ht(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function vt(e){if(!((typeof e>"u"?"undefined":A(e))!=="object"||!e.RTCPeerConnection)){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(n){var i=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(function(a){return t.call(i,a,n)}),n.getVideoTracks().forEach(function(a){return t.call(i,a,n)})},e.RTCPeerConnection.prototype.addTrack=function(n){for(var i=this,a=arguments.length,u=Array(a>1?a-1:0),c=1;c"u"?"undefined":A(e))!=="object"||!e.RTCPeerConnection)&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(n){var i=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=n),this.addEventListener("track",this._onaddstreampoly=function(a){a.streams.forEach(function(u){if(i._remoteStreams||(i._remoteStreams=[]),!i._remoteStreams.includes(u)){i._remoteStreams.push(u);var c=new Event("addstream");c.stream=u,i.dispatchEvent(c)}})})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(i){i.streams.forEach(function(a){if(n._remoteStreams||(n._remoteStreams=[]),!(n._remoteStreams.indexOf(a)>=0)){n._remoteStreams.push(a);var u=new Event("addstream");u.stream=a,n.dispatchEvent(u)}})}),t.apply(n,arguments)}}}function gt(e){if(!((typeof e>"u"?"undefined":A(e))!=="object"||!e.RTCPeerConnection)){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,a=t.setRemoteDescription,u=t.addIceCandidate;t.createOffer=function(s,o){var d=arguments.length>=2?arguments[2]:arguments[0],m=r.apply(this,[d]);return o?(m.then(s,o),Promise.resolve()):m},t.createAnswer=function(s,o){var d=arguments.length>=2?arguments[2]:arguments[0],m=n.apply(this,[d]);return o?(m.then(s,o),Promise.resolve()):m};var c=function(s,o,d){var m=i.apply(this,[s]);return d?(m.then(o,d),Promise.resolve()):m};t.setLocalDescription=c,c=function(s,o,d){var m=a.apply(this,[s]);return d?(m.then(o,d),Promise.resolve()):m},t.setRemoteDescription=c,c=function(s,o,d){var m=u.apply(this,[s]);return d?(m.then(o,d),Promise.resolve()):m},t.addIceCandidate=c}}function Ct(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(i){return n(me(i))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(a,u,c){t.mediaDevices.getUserMedia(a).then(u,c)}.bind(t))}function me(e){return e&&e.video!==void 0?Object.assign({},e,{video:de.compactObject(e.video)}):e}function St(e){if(!!e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(n,i){if(n&&n.iceServers){for(var a=[],u=0;u"u"?"undefined":A(e))==="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function Tt(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(n){if(n){typeof n.offerToReceiveAudio<"u"&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);var i=this.getTransceivers().find(function(u){return u.receiver.track.kind==="audio"});n.offerToReceiveAudio===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveAudio===!0&&!i&&this.addTransceiver("audio",{direction:"recvonly"}),typeof n.offerToReceiveVideo<"u"&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);var a=this.getTransceivers().find(function(u){return u.receiver.track.kind==="video"});n.offerToReceiveVideo===!1&&a?a.direction==="sendrecv"?a.setDirection?a.setDirection("sendonly"):a.direction="sendonly":a.direction==="recvonly"&&(a.setDirection?a.setDirection("inactive"):a.direction="inactive"):n.offerToReceiveVideo===!0&&!a&&this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Pt(e){(typeof e>"u"?"undefined":A(e))!=="object"||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}});var Y=P((rr,q)=>{"use strict";var he=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f={};f.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)};f.localCName=f.generateIdentifier();f.splitLines=function(e){return e.trim().split(`
+`).map(function(t){return t.trim()})};f.splitSections=function(e){var t=e.split(`
+m=`);return t.map(function(r,n){return(n>0?"m="+r:r).trim()+`\r
+`})};f.getDescription=function(e){var t=f.splitSections(e);return t&&t[0]};f.getMediaSections=function(e){var t=f.splitSections(e);return t.shift(),t};f.matchPrefix=function(e,t){return f.splitLines(e).filter(function(r){return r.indexOf(t)===0})};f.parseCandidate=function(e){var t=void 0;e.indexOf("a=candidate:")===0?t=e.substring(12).split(" "):t=e.substring(10).split(" ");for(var r={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n0?t[0].split("/")[1]:"sendrecv",uri:t[1]}};f.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&e.direction!=="sendrecv"?"/"+e.direction:"")+" "+e.uri+`\r
+`};f.parseFmtp=function(e){for(var t={},r=void 0,n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r};f.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(r){return parseInt(r,10)})}};f.getMid=function(e){var t=f.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)};f.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}};f.getDtlsParameters=function(e,t){var r=f.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:r.map(f.parseFingerprint)}};f.writeDtlsParameters=function(e,t){var r="a=setup:"+t+`\r
+`;return e.fingerprints.forEach(function(n){r+="a=fingerprint:"+n.algorithm+" "+n.value+`\r
+`}),r};f.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}};f.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+(he(e.keyParams)==="object"?f.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+`\r
+`};f.parseCryptoKeyParams=function(e){if(e.indexOf("inline:")!==0)return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}};f.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")};f.getCryptoParameters=function(e,t){var r=f.matchPrefix(e+t,"a=crypto:");return r.map(f.parseCryptoLine)};f.getIceParameters=function(e,t){var r=f.matchPrefix(e+t,"a=ice-ufrag:")[0],n=f.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null};f.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+`\r
+a=ice-pwd:`+e.password+`\r
+`;return e.iceLite&&(t+=`a=ice-lite\r
+`),t};f.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=f.splitLines(e),n=r[0].split(" "),i=3;i0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map(function(i){return i.preferredPayloadType!==void 0?i.preferredPayloadType:i.payloadType}).join(" ")+`\r
+`,r+=`c=IN IP4 0.0.0.0\r
+`,r+=`a=rtcp:9 IN IP4 0.0.0.0\r
+`,t.codecs.forEach(function(i){r+=f.writeRtpMap(i),r+=f.writeFmtp(i),r+=f.writeRtcpFb(i)});var n=0;return t.codecs.forEach(function(i){i.maxptime>n&&(n=i.maxptime)}),n>0&&(r+="a=maxptime:"+n+`\r
+`),t.headerExtensions&&t.headerExtensions.forEach(function(i){r+=f.writeExtmap(i)}),r};f.parseRtpEncodingParameters=function(e){var t=[],r=f.parseRtpParameters(e),n=r.fecMechanisms.indexOf("RED")!==-1,i=r.fecMechanisms.indexOf("ULPFEC")!==-1,a=f.matchPrefix(e,"a=ssrc:").map(function(o){return f.parseSsrcMedia(o)}).filter(function(o){return o.attribute==="cname"}),u=a.length>0&&a[0].ssrc,c=void 0,p=f.matchPrefix(e,"a=ssrc-group:FID").map(function(o){var d=o.substr(17).split(" ");return d.map(function(m){return parseInt(m,10)})});p.length>0&&p[0].length>1&&p[0][0]===u&&(c=p[0][1]),r.codecs.forEach(function(o){if(o.name.toUpperCase()==="RTX"&&o.parameters.apt){var d={ssrc:u,codecPayloadType:parseInt(o.parameters.apt,10)};u&&c&&(d.rtx={ssrc:c}),t.push(d),n&&(d=JSON.parse(JSON.stringify(d)),d.fec={ssrc:u,mechanism:i?"red+ulpfec":"red"},t.push(d))}}),t.length===0&&u&&t.push({ssrc:u});var s=f.matchPrefix(e,"b=");return s.length&&(s[0].indexOf("b=TIAS:")===0?s=parseInt(s[0].substr(7),10):s[0].indexOf("b=AS:")===0?s=parseInt(s[0].substr(5),10)*1e3*.95-50*40*8:s=void 0,t.forEach(function(o){o.maxBitrate=s})),t};f.parseRtcpParameters=function(e){var t={},r=f.matchPrefix(e,"a=ssrc:").map(function(a){return f.parseSsrcMedia(a)}).filter(function(a){return a.attribute==="cname"})[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var n=f.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=n.length>0,t.compound=n.length===0;var i=f.matchPrefix(e,"a=rtcp-mux");return t.mux=i.length>0,t};f.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+=`a=rtcp-rsize\r
+`),e.mux&&(t+=`a=rtcp-mux\r
+`),e.ssrc!==void 0&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+`\r
+`),t};f.parseMsid=function(e){var t=void 0,r=f.matchPrefix(e,"a=msid:");if(r.length===1)return t=r[0].substr(7).split(" "),{stream:t[0],track:t[1]};var n=f.matchPrefix(e,"a=ssrc:").map(function(i){return f.parseSsrcMedia(i)}).filter(function(i){return i.attribute==="msid"});if(n.length>0)return t=n[0].value.split(" "),{stream:t[0],track:t[1]}};f.parseSctpDescription=function(e){var t=f.parseMLine(e),r=f.matchPrefix(e,"a=max-message-size:"),n=void 0;r.length>0&&(n=parseInt(r[0].substr(19),10)),isNaN(n)&&(n=65536);var i=f.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:parseInt(i[0].substr(12),10),protocol:t.fmt,maxMessageSize:n};var a=f.matchPrefix(e,"a=sctpmap:");if(a.length>0){var u=a[0].substr(10).split(" ");return{port:parseInt(u[0],10),protocol:u[1],maxMessageSize:n}}};f.writeSctpDescription=function(e,t){var r=[];return e.protocol!=="DTLS/SCTP"?r=["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+`\r
+`,`c=IN IP4 0.0.0.0\r
+`,"a=sctp-port:"+t.port+`\r
+`]:r=["m="+e.kind+" 9 "+e.protocol+" "+t.port+`\r
+`,`c=IN IP4 0.0.0.0\r
+`,"a=sctpmap:"+t.port+" "+t.protocol+` 65535\r
+`],t.maxMessageSize!==void 0&&r.push("a=max-message-size:"+t.maxMessageSize+`\r
+`),r.join("")};f.generateSessionId=function(){return Math.random().toString().substr(2,21)};f.writeSessionBoilerplate=function(e,t,r){var n=void 0,i=t!==void 0?t:2;e?n=e:n=f.generateSessionId();var a=r||"thisisadapterortc";return`v=0\r
+o=`+a+" "+n+" "+i+` IN IP4 127.0.0.1\r
+s=-\r
+t=0 0\r
+`};f.getDirection=function(e,t){for(var r=f.splitLines(e),n=0;n"u"?"undefined":he(q))==="object"&&(q.exports=f)});var ge=P(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});var ve=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};k.shimRTCIceCandidate=kt;k.shimMaxMessageSize=xt;k.shimSendThrowTypeError=Dt;k.shimConnectionState=Ot;k.removeExtmapAllowMixed=It;k.shimAddIceCandidateNullOrEmpty=Lt;k.shimParameterlessSetLocalDescription=At;var _t=Y(),V=bt(_t),Et=x(),ye=Mt(Et);function Mt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function bt(e){return e&&e.__esModule?e:{default:e}}function kt(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(n){if((typeof n>"u"?"undefined":ve(n))==="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&(n=JSON.parse(JSON.stringify(n)),n.candidate=n.candidate.substr(2)),n.candidate&&n.candidate.length){var i=new t(n),a=V.default.parseCandidate(n.candidate),u=Object.assign(i,a);return u.toJSON=function(){return{candidate:u.candidate,sdpMid:u.sdpMid,sdpMLineIndex:u.sdpMLineIndex,usernameFragment:u.usernameFragment}},u}return new t(n)},e.RTCIceCandidate.prototype=t.prototype,ye.wrapPeerConnectionEvent(e,"icecandidate",function(r){return r.candidate&&Object.defineProperty(r,"candidate",{value:new e.RTCIceCandidate(r.candidate),writable:"false"}),r})}}function xt(e,t){if(!!e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return typeof this._sctp>"u"?null:this._sctp}});var r=function(p){if(!p||!p.sdp)return!1;var s=V.default.splitSections(p.sdp);return s.shift(),s.some(function(o){var d=V.default.parseMLine(o);return d&&d.kind==="application"&&d.protocol.indexOf("SCTP")!==-1})},n=function(p){var s=p.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(s===null||s.length<2)return-1;var o=parseInt(s[1],10);return o!==o?-1:o},i=function(p){var s=65536;return t.browser==="firefox"&&(t.version<57?p===-1?s=16384:s=2147483637:t.version<60?s=t.version===57?65535:65536:s=2147483637),s},a=function(p,s){var o=65536;t.browser==="firefox"&&t.version===57&&(o=65535);var d=V.default.matchPrefix(p.sdp,"a=max-message-size:");return d.length>0?o=parseInt(d[0].substr(19),10):t.browser==="firefox"&&s!==-1&&(o=2147483637),o},u=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,t.browser==="chrome"&&t.version>=76){var p=this.getConfiguration(),s=p.sdpSemantics;s==="plan-b"&&Object.defineProperty(this,"sctp",{get:function(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var o=n(arguments[0]),d=i(o),m=a(arguments[0],o),l=void 0;d===0&&m===0?l=Number.POSITIVE_INFINITY:d===0||m===0?l=Math.max(d,m):l=Math.min(d,m);var v={};Object.defineProperty(v,"maxMessageSize",{get:function(){return l}}),this._sctp=v}return u.apply(this,arguments)}}}function Dt(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(n,i){var a=n.send;n.send=function(){var c=arguments[0],p=c.length||c.size||c.byteLength;if(n.readyState==="open"&&i.sctp&&p>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return a.apply(n,arguments)}}var r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var i=r.apply(this,arguments);return t(i,this),i},ye.wrapPeerConnectionEvent(e,"datachannel",function(n){return t(n.channel,n.target),n})}function Ot(e){if(!(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(n){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),n&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=n)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(function(r){var n=t[r];t[r]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(i){var a=i.target;if(a._lastConnectionState!==a.connectionState){a._lastConnectionState=a.connectionState;var u=new Event("connectionstatechange",i);a.dispatchEvent(u)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}}function It(e,t){if(!!e.RTCPeerConnection&&!(t.browser==="chrome"&&t.version>=71)&&!(t.browser==="safari"&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(i){if(i&&i.sdp&&i.sdp.indexOf(`
+a=extmap-allow-mixed`)!==-1){var a=i.sdp.split(`
+`).filter(function(u){return u.trim()!=="a=extmap-allow-mixed"}).join(`
+`);e.RTCSessionDescription&&i instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:i.type,sdp:a}):i.sdp=a}return r.apply(this,arguments)}}}function Lt(e,t){if(!!(e.RTCPeerConnection&&e.RTCPeerConnection.prototype)){var r=e.RTCPeerConnection.prototype.addIceCandidate;!r||r.length===0||(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(t.browser==="chrome"&&t.version<78||t.browser==="firefox"&&t.version<68||t.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function At(e,t){if(!!(e.RTCPeerConnection&&e.RTCPeerConnection.prototype)){var r=e.RTCPeerConnection.prototype.setLocalDescription;!r||r.length===0||(e.RTCPeerConnection.prototype.setLocalDescription=function(){var i=this,a=arguments[0]||{};if((typeof a>"u"?"undefined":ve(a))!=="object"||a.type&&a.sdp)return r.apply(this,arguments);if(a={type:a.type,sdp:a.sdp},!a.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":a.type="offer";break;default:a.type="answer";break}if(a.sdp||a.type!=="offer"&&a.type!=="answer")return r.apply(this,[a]);var u=a.type==="offer"?this.createOffer:this.createAnswer;return u.apply(this).then(function(c){return r.apply(i,[c])})})}}});var Ce=P($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.adapterFactory=Jt;var Gt=x(),G=O(Gt),Ut=oe(),_=O(Ut),Ft=fe(),T=O(Ft),Nt=le(),b=O(Nt),zt=ge(),C=O(zt),qt=Y(),Vt=O(qt);function O(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function Jt(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.window,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=G.log,i=G.detectBrowser(t),a={browserDetails:i,commonShim:C,extractVersion:G.extractVersion,disableLog:G.disableLog,disableWarnings:G.disableWarnings,sdp:Vt};switch(i.browser){case"chrome":if(!_||!_.shimPeerConnection||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),a;if(i.version===null)return n("Chrome shim can not determine version, not shimming."),a;n("adapter.js shimming chrome."),a.browserShim=_,C.shimAddIceCandidateNullOrEmpty(t,i),C.shimParameterlessSetLocalDescription(t,i),_.shimGetUserMedia(t,i),_.shimMediaStream(t,i),_.shimPeerConnection(t,i),_.shimOnTrack(t,i),_.shimAddTrackRemoveTrack(t,i),_.shimGetSendersWithDtmf(t,i),_.shimGetStats(t,i),_.shimSenderReceiverGetStats(t,i),_.fixNegotiationNeeded(t,i),_.shimSelectAudioOutput(t,i),C.shimRTCIceCandidate(t,i),C.shimConnectionState(t,i),C.shimMaxMessageSize(t,i),C.shimSendThrowTypeError(t,i),C.removeExtmapAllowMixed(t,i);break;case"firefox":if(!T||!T.shimPeerConnection||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),a;n("adapter.js shimming firefox."),a.browserShim=T,C.shimAddIceCandidateNullOrEmpty(t,i),C.shimParameterlessSetLocalDescription(t,i),T.shimGetUserMedia(t,i),T.shimPeerConnection(t,i),T.shimOnTrack(t,i),T.shimRemoveStream(t,i),T.shimSenderGetStats(t,i),T.shimReceiverGetStats(t,i),T.shimRTCDataChannel(t,i),T.shimAddTransceiver(t,i),T.shimGetParameters(t,i),T.shimCreateOffer(t,i),T.shimCreateAnswer(t,i),C.shimRTCIceCandidate(t,i),C.shimConnectionState(t,i),C.shimMaxMessageSize(t,i),C.shimSendThrowTypeError(t,i);break;case"safari":if(!b||!r.shimSafari)return n("Safari shim is not included in this adapter release."),a;n("adapter.js shimming safari."),a.browserShim=b,C.shimAddIceCandidateNullOrEmpty(t,i),C.shimParameterlessSetLocalDescription(t,i),b.shimRTCIceServerUrls(t,i),b.shimCreateOfferLegacy(t,i),b.shimCallbacksAPI(t,i),b.shimLocalStreamsAPI(t,i),b.shimRemoteStreamsAPI(t,i),b.shimTrackEventTransceiver(t,i),b.shimGetUserMedia(t,i),b.shimAudioContext(t,i),C.shimRTCIceCandidate(t,i),C.shimMaxMessageSize(t,i),C.shimSendThrowTypeError(t,i),C.removeExtmapAllowMixed(t,i);break;default:n("Unsupported browser!");break}return a}});var Kt=P((ar,Se)=>{var jt=Ce(),Bt=(0,jt.adapterFactory)({window:typeof window>"u"?void 0:window});Se.exports=Bt});"use strict";Kt();})();
diff --git a/node_modules/webrtc-adapter/package.json b/node_modules/webrtc-adapter/package.json
new file mode 100644
index 0000000..4215dbc
--- /dev/null
+++ b/node_modules/webrtc-adapter/package.json
@@ -0,0 +1,62 @@
+{
+ "name": "webrtc-adapter",
+ "version": "8.2.3",
+ "description": "A shim to insulate apps from WebRTC spec changes and browser prefix differences",
+ "license": "BSD-3-Clause",
+ "main": "./dist/adapter_core.js",
+ "types": "./index.d.ts",
+ "module": "./src/js/adapter_core.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/webrtchacks/adapter.git"
+ },
+ "authors": [
+ "The WebRTC project authors (https://www.webrtc.org/)",
+ "The adapter.js project authors (https://github.com/webrtchacks/adapter/)"
+ ],
+ "scripts": {
+ "preversion": "git stash && npm install && npm update && BROWSER=chrome BVER=stable CI=true npm test && git checkout -B bumpVersion && grunt build && grunt copyForPublish && git add package.json release/* && git commit -m 'Add adapter artifacts' --allow-empty",
+ "version": "",
+ "postversion": "export GITTAG=\"echo $(git describe --abbrev=0 --tags | sed 's/^v//')\" && git push --force --set-upstream origin bumpVersion --follow-tags && git checkout gh-pages && git pull && cp out/adapter.js adapter.js && cp adapter.js adapter-`$GITTAG`.js && rm adapter-latest.js && ln -s adapter-`$GITTAG`.js adapter-latest.js && mkdir -p adapter-`$GITTAG`-variants && cp out/adapter.js adapter-`$GITTAG`-variants/ && cp out/adapter_*.js adapter-`$GITTAG`-variants/ && git add adapter.js adapter-latest.js adapter-`$GITTAG`.js adapter-`$GITTAG`-variants && git commit -m `$GITTAG` && git push --set-upstream origin gh-pages && git checkout main",
+ "prepare": "grunt build",
+ "prepublishonly": "npm test",
+ "test": "grunt && mocha test/unit && grunt downloadBrowser && karma start test/karma.conf.js",
+ "lint-and-unit-tests": "grunt && mocha test/unit",
+ "e2e-tests": "grunt && grunt downloadBrowser && karma start test/karma.conf.js"
+ },
+ "dependencies": {
+ "sdp": "^3.2.0"
+ },
+ "engines": {
+ "npm": ">=3.10.0",
+ "node": ">=6.0.0"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.21.0",
+ "@babel/preset-env": "^7.20.2",
+ "babel-preset-env": "^1.7.0",
+ "brfs": "^1.5.0",
+ "chai": "^3.5.0",
+ "grunt": "^1.1.0",
+ "grunt-babel": "^8.0.0",
+ "grunt-browserify": "^6.0.0",
+ "grunt-cli": "^1.3.1",
+ "grunt-contrib-clean": "^1.1.0",
+ "grunt-contrib-copy": "^1.0.0",
+ "grunt-eslint": "^24.0.0",
+ "grunt-shell": "^2.1.0",
+ "karma": "^6.4.1",
+ "karma-browserify": "^8.1.0",
+ "karma-chai": "^0.1.0",
+ "karma-chrome-launcher": "^2.2.0",
+ "karma-firefox-launcher": "^1.3.0",
+ "karma-mocha": "^2.0.1",
+ "karma-mocha-reporter": "^2.2.3",
+ "karma-safari-launcher": "^1.0.0",
+ "karma-stability-reporter": "^3.0.1",
+ "mocha": "^10.1.0",
+ "sinon": "^2.2.0",
+ "sinon-chai": "^2.14.0",
+ "travis-multirunner": "^5.0.1"
+ }
+}
diff --git a/node_modules/webrtc-adapter/src/js/adapter_core.js b/node_modules/webrtc-adapter/src/js/adapter_core.js
new file mode 100644
index 0000000..e24468f
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/adapter_core.js
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+
+'use strict';
+
+import {adapterFactory} from './adapter_factory.js';
+
+const adapter =
+ adapterFactory({window: typeof window === 'undefined' ? undefined : window});
+export default adapter;
diff --git a/node_modules/webrtc-adapter/src/js/adapter_core5.js b/node_modules/webrtc-adapter/src/js/adapter_core5.js
new file mode 100644
index 0000000..941e1a3
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/adapter_core5.js
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+
+'use strict';
+
+import {adapterFactory} from './adapter_factory.js';
+
+const adapter =
+ adapterFactory({window: typeof window === 'undefined' ? undefined : window});
+module.exports = adapter; // this is the difference from adapter_core.
diff --git a/node_modules/webrtc-adapter/src/js/adapter_factory.js b/node_modules/webrtc-adapter/src/js/adapter_factory.js
new file mode 100644
index 0000000..54bdda2
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/adapter_factory.js
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+import * as utils from './utils';
+
+// Browser shims.
+import * as chromeShim from './chrome/chrome_shim';
+import * as firefoxShim from './firefox/firefox_shim';
+import * as safariShim from './safari/safari_shim';
+import * as commonShim from './common_shim';
+import * as sdp from 'sdp';
+
+// Shimming starts here.
+export function adapterFactory({window} = {}, options = {
+ shimChrome: true,
+ shimFirefox: true,
+ shimSafari: true,
+}) {
+ // Utils.
+ const logging = utils.log;
+ const browserDetails = utils.detectBrowser(window);
+
+ const adapter = {
+ browserDetails,
+ commonShim,
+ extractVersion: utils.extractVersion,
+ disableLog: utils.disableLog,
+ disableWarnings: utils.disableWarnings,
+ // Expose sdp as a convenience. For production apps include directly.
+ sdp,
+ };
+
+ // Shim browser if found.
+ switch (browserDetails.browser) {
+ case 'chrome':
+ if (!chromeShim || !chromeShim.shimPeerConnection ||
+ !options.shimChrome) {
+ logging('Chrome shim is not included in this adapter release.');
+ return adapter;
+ }
+ if (browserDetails.version === null) {
+ logging('Chrome shim can not determine version, not shimming.');
+ return adapter;
+ }
+ logging('adapter.js shimming chrome.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = chromeShim;
+
+ // Must be called before shimPeerConnection.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+
+ chromeShim.shimGetUserMedia(window, browserDetails);
+ chromeShim.shimMediaStream(window, browserDetails);
+ chromeShim.shimPeerConnection(window, browserDetails);
+ chromeShim.shimOnTrack(window, browserDetails);
+ chromeShim.shimAddTrackRemoveTrack(window, browserDetails);
+ chromeShim.shimGetSendersWithDtmf(window, browserDetails);
+ chromeShim.shimGetStats(window, browserDetails);
+ chromeShim.shimSenderReceiverGetStats(window, browserDetails);
+ chromeShim.fixNegotiationNeeded(window, browserDetails);
+
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
+ commonShim.shimConnectionState(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ commonShim.removeExtmapAllowMixed(window, browserDetails);
+ break;
+ case 'firefox':
+ if (!firefoxShim || !firefoxShim.shimPeerConnection ||
+ !options.shimFirefox) {
+ logging('Firefox shim is not included in this adapter release.');
+ return adapter;
+ }
+ logging('adapter.js shimming firefox.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = firefoxShim;
+
+ // Must be called before shimPeerConnection.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+
+ firefoxShim.shimGetUserMedia(window, browserDetails);
+ firefoxShim.shimPeerConnection(window, browserDetails);
+ firefoxShim.shimOnTrack(window, browserDetails);
+ firefoxShim.shimRemoveStream(window, browserDetails);
+ firefoxShim.shimSenderGetStats(window, browserDetails);
+ firefoxShim.shimReceiverGetStats(window, browserDetails);
+ firefoxShim.shimRTCDataChannel(window, browserDetails);
+ firefoxShim.shimAddTransceiver(window, browserDetails);
+ firefoxShim.shimGetParameters(window, browserDetails);
+ firefoxShim.shimCreateOffer(window, browserDetails);
+ firefoxShim.shimCreateAnswer(window, browserDetails);
+
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimConnectionState(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ break;
+ case 'safari':
+ if (!safariShim || !options.shimSafari) {
+ logging('Safari shim is not included in this adapter release.');
+ return adapter;
+ }
+ logging('adapter.js shimming safari.');
+ // Export to the adapter global object visible in the browser.
+ adapter.browserShim = safariShim;
+
+ // Must be called before shimCallbackAPI.
+ commonShim.shimAddIceCandidateNullOrEmpty(window, browserDetails);
+ commonShim.shimParameterlessSetLocalDescription(window, browserDetails);
+
+ safariShim.shimRTCIceServerUrls(window, browserDetails);
+ safariShim.shimCreateOfferLegacy(window, browserDetails);
+ safariShim.shimCallbacksAPI(window, browserDetails);
+ safariShim.shimLocalStreamsAPI(window, browserDetails);
+ safariShim.shimRemoteStreamsAPI(window, browserDetails);
+ safariShim.shimTrackEventTransceiver(window, browserDetails);
+ safariShim.shimGetUserMedia(window, browserDetails);
+ safariShim.shimAudioContext(window, browserDetails);
+
+ commonShim.shimRTCIceCandidate(window, browserDetails);
+ commonShim.shimRTCIceCandidateRelayProtocol(window, browserDetails);
+ commonShim.shimMaxMessageSize(window, browserDetails);
+ commonShim.shimSendThrowTypeError(window, browserDetails);
+ commonShim.removeExtmapAllowMixed(window, browserDetails);
+ break;
+ default:
+ logging('Unsupported browser!');
+ break;
+ }
+
+ return adapter;
+}
diff --git a/node_modules/webrtc-adapter/src/js/chrome/chrome_shim.js b/node_modules/webrtc-adapter/src/js/chrome/chrome_shim.js
new file mode 100644
index 0000000..46aee7e
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/chrome/chrome_shim.js
@@ -0,0 +1,702 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+import * as utils from '../utils.js';
+
+export {shimGetUserMedia} from './getusermedia';
+export {shimGetDisplayMedia} from './getdisplaymedia';
+
+export function shimMediaStream(window) {
+ window.MediaStream = window.MediaStream || window.webkitMediaStream;
+}
+
+export function shimOnTrack(window) {
+ if (typeof window === 'object' && window.RTCPeerConnection && !('ontrack' in
+ window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'ontrack', {
+ get() {
+ return this._ontrack;
+ },
+ set(f) {
+ if (this._ontrack) {
+ this.removeEventListener('track', this._ontrack);
+ }
+ this.addEventListener('track', this._ontrack = f);
+ },
+ enumerable: true,
+ configurable: true
+ });
+ const origSetRemoteDescription =
+ window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription =
+ function setRemoteDescription() {
+ if (!this._ontrackpoly) {
+ this._ontrackpoly = (e) => {
+ // onaddstream does not fire when a track is added to an existing
+ // stream. But stream.onaddtrack is implemented so we use that.
+ e.stream.addEventListener('addtrack', te => {
+ let receiver;
+ if (window.RTCPeerConnection.prototype.getReceivers) {
+ receiver = this.getReceivers()
+ .find(r => r.track && r.track.id === te.track.id);
+ } else {
+ receiver = {track: te.track};
+ }
+
+ const event = new Event('track');
+ event.track = te.track;
+ event.receiver = receiver;
+ event.transceiver = {receiver};
+ event.streams = [e.stream];
+ this.dispatchEvent(event);
+ });
+ e.stream.getTracks().forEach(track => {
+ let receiver;
+ if (window.RTCPeerConnection.prototype.getReceivers) {
+ receiver = this.getReceivers()
+ .find(r => r.track && r.track.id === track.id);
+ } else {
+ receiver = {track};
+ }
+ const event = new Event('track');
+ event.track = track;
+ event.receiver = receiver;
+ event.transceiver = {receiver};
+ event.streams = [e.stream];
+ this.dispatchEvent(event);
+ });
+ };
+ this.addEventListener('addstream', this._ontrackpoly);
+ }
+ return origSetRemoteDescription.apply(this, arguments);
+ };
+ } else {
+ // even if RTCRtpTransceiver is in window, it is only used and
+ // emitted in unified-plan. Unfortunately this means we need
+ // to unconditionally wrap the event.
+ utils.wrapPeerConnectionEvent(window, 'track', e => {
+ if (!e.transceiver) {
+ Object.defineProperty(e, 'transceiver',
+ {value: {receiver: e.receiver}});
+ }
+ return e;
+ });
+ }
+}
+
+export function shimGetSendersWithDtmf(window) {
+ // Overrides addTrack/removeTrack, depends on shimAddTrackRemoveTrack.
+ if (typeof window === 'object' && window.RTCPeerConnection &&
+ !('getSenders' in window.RTCPeerConnection.prototype) &&
+ 'createDTMFSender' in window.RTCPeerConnection.prototype) {
+ const shimSenderWithDtmf = function(pc, track) {
+ return {
+ track,
+ get dtmf() {
+ if (this._dtmf === undefined) {
+ if (track.kind === 'audio') {
+ this._dtmf = pc.createDTMFSender(track);
+ } else {
+ this._dtmf = null;
+ }
+ }
+ return this._dtmf;
+ },
+ _pc: pc
+ };
+ };
+
+ // augment addTrack when getSenders is not available.
+ if (!window.RTCPeerConnection.prototype.getSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ this._senders = this._senders || [];
+ return this._senders.slice(); // return a copy of the internal state.
+ };
+ const origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addTrack =
+ function addTrack(track, stream) {
+ let sender = origAddTrack.apply(this, arguments);
+ if (!sender) {
+ sender = shimSenderWithDtmf(this, track);
+ this._senders.push(sender);
+ }
+ return sender;
+ };
+
+ const origRemoveTrack = window.RTCPeerConnection.prototype.removeTrack;
+ window.RTCPeerConnection.prototype.removeTrack =
+ function removeTrack(sender) {
+ origRemoveTrack.apply(this, arguments);
+ const idx = this._senders.indexOf(sender);
+ if (idx !== -1) {
+ this._senders.splice(idx, 1);
+ }
+ };
+ }
+ const origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ this._senders = this._senders || [];
+ origAddStream.apply(this, [stream]);
+ stream.getTracks().forEach(track => {
+ this._senders.push(shimSenderWithDtmf(this, track));
+ });
+ };
+
+ const origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream =
+ function removeStream(stream) {
+ this._senders = this._senders || [];
+ origRemoveStream.apply(this, [stream]);
+
+ stream.getTracks().forEach(track => {
+ const sender = this._senders.find(s => s.track === track);
+ if (sender) { // remove sender
+ this._senders.splice(this._senders.indexOf(sender), 1);
+ }
+ });
+ };
+ } else if (typeof window === 'object' && window.RTCPeerConnection &&
+ 'getSenders' in window.RTCPeerConnection.prototype &&
+ 'createDTMFSender' in window.RTCPeerConnection.prototype &&
+ window.RTCRtpSender &&
+ !('dtmf' in window.RTCRtpSender.prototype)) {
+ const origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ const senders = origGetSenders.apply(this, []);
+ senders.forEach(sender => sender._pc = this);
+ return senders;
+ };
+
+ Object.defineProperty(window.RTCRtpSender.prototype, 'dtmf', {
+ get() {
+ if (this._dtmf === undefined) {
+ if (this.track.kind === 'audio') {
+ this._dtmf = this._pc.createDTMFSender(this.track);
+ } else {
+ this._dtmf = null;
+ }
+ }
+ return this._dtmf;
+ }
+ });
+ }
+}
+
+export function shimGetStats(window) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+
+ const origGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ const [selector, onSucc, onErr] = arguments;
+
+ // If selector is a function then we are in the old style stats so just
+ // pass back the original getStats format to avoid breaking old users.
+ if (arguments.length > 0 && typeof selector === 'function') {
+ return origGetStats.apply(this, arguments);
+ }
+
+ // When spec-style getStats is supported, return those when called with
+ // either no arguments or the selector argument is null.
+ if (origGetStats.length === 0 && (arguments.length === 0 ||
+ typeof selector !== 'function')) {
+ return origGetStats.apply(this, []);
+ }
+
+ const fixChromeStats_ = function(response) {
+ const standardReport = {};
+ const reports = response.result();
+ reports.forEach(report => {
+ const standardStats = {
+ id: report.id,
+ timestamp: report.timestamp,
+ type: {
+ localcandidate: 'local-candidate',
+ remotecandidate: 'remote-candidate'
+ }[report.type] || report.type
+ };
+ report.names().forEach(name => {
+ standardStats[name] = report.stat(name);
+ });
+ standardReport[standardStats.id] = standardStats;
+ });
+
+ return standardReport;
+ };
+
+ // shim getStats with maplike support
+ const makeMapStats = function(stats) {
+ return new Map(Object.keys(stats).map(key => [key, stats[key]]));
+ };
+
+ if (arguments.length >= 2) {
+ const successCallbackWrapper_ = function(response) {
+ onSucc(makeMapStats(fixChromeStats_(response)));
+ };
+
+ return origGetStats.apply(this, [successCallbackWrapper_,
+ selector]);
+ }
+
+ // promise-support
+ return new Promise((resolve, reject) => {
+ origGetStats.apply(this, [
+ function(response) {
+ resolve(makeMapStats(fixChromeStats_(response)));
+ }, reject]);
+ }).then(onSucc, onErr);
+ };
+}
+
+export function shimSenderReceiverGetStats(window) {
+ if (!(typeof window === 'object' && window.RTCPeerConnection &&
+ window.RTCRtpSender && window.RTCRtpReceiver)) {
+ return;
+ }
+
+ // shim sender stats.
+ if (!('getStats' in window.RTCRtpSender.prototype)) {
+ const origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ if (origGetSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ const senders = origGetSenders.apply(this, []);
+ senders.forEach(sender => sender._pc = this);
+ return senders;
+ };
+ }
+
+ const origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ if (origAddTrack) {
+ window.RTCPeerConnection.prototype.addTrack = function addTrack() {
+ const sender = origAddTrack.apply(this, arguments);
+ sender._pc = this;
+ return sender;
+ };
+ }
+ window.RTCRtpSender.prototype.getStats = function getStats() {
+ const sender = this;
+ return this._pc.getStats().then(result =>
+ /* Note: this will include stats of all senders that
+ * send a track with the same id as sender.track as
+ * it is not possible to identify the RTCRtpSender.
+ */
+ utils.filterStats(result, sender.track, true));
+ };
+ }
+
+ // shim receiver stats.
+ if (!('getStats' in window.RTCRtpReceiver.prototype)) {
+ const origGetReceivers = window.RTCPeerConnection.prototype.getReceivers;
+ if (origGetReceivers) {
+ window.RTCPeerConnection.prototype.getReceivers =
+ function getReceivers() {
+ const receivers = origGetReceivers.apply(this, []);
+ receivers.forEach(receiver => receiver._pc = this);
+ return receivers;
+ };
+ }
+ utils.wrapPeerConnectionEvent(window, 'track', e => {
+ e.receiver._pc = e.srcElement;
+ return e;
+ });
+ window.RTCRtpReceiver.prototype.getStats = function getStats() {
+ const receiver = this;
+ return this._pc.getStats().then(result =>
+ utils.filterStats(result, receiver.track, false));
+ };
+ }
+
+ if (!('getStats' in window.RTCRtpSender.prototype &&
+ 'getStats' in window.RTCRtpReceiver.prototype)) {
+ return;
+ }
+
+ // shim RTCPeerConnection.getStats(track).
+ const origGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ if (arguments.length > 0 &&
+ arguments[0] instanceof window.MediaStreamTrack) {
+ const track = arguments[0];
+ let sender;
+ let receiver;
+ let err;
+ this.getSenders().forEach(s => {
+ if (s.track === track) {
+ if (sender) {
+ err = true;
+ } else {
+ sender = s;
+ }
+ }
+ });
+ this.getReceivers().forEach(r => {
+ if (r.track === track) {
+ if (receiver) {
+ err = true;
+ } else {
+ receiver = r;
+ }
+ }
+ return r.track === track;
+ });
+ if (err || (sender && receiver)) {
+ return Promise.reject(new DOMException(
+ 'There are more than one sender or receiver for the track.',
+ 'InvalidAccessError'));
+ } else if (sender) {
+ return sender.getStats();
+ } else if (receiver) {
+ return receiver.getStats();
+ }
+ return Promise.reject(new DOMException(
+ 'There is no sender or receiver for the track.',
+ 'InvalidAccessError'));
+ }
+ return origGetStats.apply(this, arguments);
+ };
+}
+
+export function shimAddTrackRemoveTrackWithNative(window) {
+ // shim addTrack/removeTrack with native variants in order to make
+ // the interactions with legacy getLocalStreams behave as in other browsers.
+ // Keeps a mapping stream.id => [stream, rtpsenders...]
+ window.RTCPeerConnection.prototype.getLocalStreams =
+ function getLocalStreams() {
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ return Object.keys(this._shimmedLocalStreams)
+ .map(streamId => this._shimmedLocalStreams[streamId][0]);
+ };
+
+ const origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addTrack =
+ function addTrack(track, stream) {
+ if (!stream) {
+ return origAddTrack.apply(this, arguments);
+ }
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+
+ const sender = origAddTrack.apply(this, arguments);
+ if (!this._shimmedLocalStreams[stream.id]) {
+ this._shimmedLocalStreams[stream.id] = [stream, sender];
+ } else if (this._shimmedLocalStreams[stream.id].indexOf(sender) === -1) {
+ this._shimmedLocalStreams[stream.id].push(sender);
+ }
+ return sender;
+ };
+
+ const origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+
+ stream.getTracks().forEach(track => {
+ const alreadyExists = this.getSenders().find(s => s.track === track);
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.',
+ 'InvalidAccessError');
+ }
+ });
+ const existingSenders = this.getSenders();
+ origAddStream.apply(this, arguments);
+ const newSenders = this.getSenders()
+ .filter(newSender => existingSenders.indexOf(newSender) === -1);
+ this._shimmedLocalStreams[stream.id] = [stream].concat(newSenders);
+ };
+
+ const origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream =
+ function removeStream(stream) {
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ delete this._shimmedLocalStreams[stream.id];
+ return origRemoveStream.apply(this, arguments);
+ };
+
+ const origRemoveTrack = window.RTCPeerConnection.prototype.removeTrack;
+ window.RTCPeerConnection.prototype.removeTrack =
+ function removeTrack(sender) {
+ this._shimmedLocalStreams = this._shimmedLocalStreams || {};
+ if (sender) {
+ Object.keys(this._shimmedLocalStreams).forEach(streamId => {
+ const idx = this._shimmedLocalStreams[streamId].indexOf(sender);
+ if (idx !== -1) {
+ this._shimmedLocalStreams[streamId].splice(idx, 1);
+ }
+ if (this._shimmedLocalStreams[streamId].length === 1) {
+ delete this._shimmedLocalStreams[streamId];
+ }
+ });
+ }
+ return origRemoveTrack.apply(this, arguments);
+ };
+}
+
+export function shimAddTrackRemoveTrack(window, browserDetails) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ // shim addTrack and removeTrack.
+ if (window.RTCPeerConnection.prototype.addTrack &&
+ browserDetails.version >= 65) {
+ return shimAddTrackRemoveTrackWithNative(window);
+ }
+
+ // also shim pc.getLocalStreams when addTrack is shimmed
+ // to return the original streams.
+ const origGetLocalStreams = window.RTCPeerConnection.prototype
+ .getLocalStreams;
+ window.RTCPeerConnection.prototype.getLocalStreams =
+ function getLocalStreams() {
+ const nativeStreams = origGetLocalStreams.apply(this);
+ this._reverseStreams = this._reverseStreams || {};
+ return nativeStreams.map(stream => this._reverseStreams[stream.id]);
+ };
+
+ const origAddStream = window.RTCPeerConnection.prototype.addStream;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+
+ stream.getTracks().forEach(track => {
+ const alreadyExists = this.getSenders().find(s => s.track === track);
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.',
+ 'InvalidAccessError');
+ }
+ });
+ // Add identity mapping for consistency with addTrack.
+ // Unless this is being used with a stream from addTrack.
+ if (!this._reverseStreams[stream.id]) {
+ const newStream = new window.MediaStream(stream.getTracks());
+ this._streams[stream.id] = newStream;
+ this._reverseStreams[newStream.id] = stream;
+ stream = newStream;
+ }
+ origAddStream.apply(this, [stream]);
+ };
+
+ const origRemoveStream = window.RTCPeerConnection.prototype.removeStream;
+ window.RTCPeerConnection.prototype.removeStream =
+ function removeStream(stream) {
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+
+ origRemoveStream.apply(this, [(this._streams[stream.id] || stream)]);
+ delete this._reverseStreams[(this._streams[stream.id] ?
+ this._streams[stream.id].id : stream.id)];
+ delete this._streams[stream.id];
+ };
+
+ window.RTCPeerConnection.prototype.addTrack =
+ function addTrack(track, stream) {
+ if (this.signalingState === 'closed') {
+ throw new DOMException(
+ 'The RTCPeerConnection\'s signalingState is \'closed\'.',
+ 'InvalidStateError');
+ }
+ const streams = [].slice.call(arguments, 1);
+ if (streams.length !== 1 ||
+ !streams[0].getTracks().find(t => t === track)) {
+ // this is not fully correct but all we can manage without
+ // [[associated MediaStreams]] internal slot.
+ throw new DOMException(
+ 'The adapter.js addTrack polyfill only supports a single ' +
+ ' stream which is associated with the specified track.',
+ 'NotSupportedError');
+ }
+
+ const alreadyExists = this.getSenders().find(s => s.track === track);
+ if (alreadyExists) {
+ throw new DOMException('Track already exists.',
+ 'InvalidAccessError');
+ }
+
+ this._streams = this._streams || {};
+ this._reverseStreams = this._reverseStreams || {};
+ const oldStream = this._streams[stream.id];
+ if (oldStream) {
+ // this is using odd Chrome behaviour, use with caution:
+ // https://bugs.chromium.org/p/webrtc/issues/detail?id=7815
+ // Note: we rely on the high-level addTrack/dtmf shim to
+ // create the sender with a dtmf sender.
+ oldStream.addTrack(track);
+
+ // Trigger ONN async.
+ Promise.resolve().then(() => {
+ this.dispatchEvent(new Event('negotiationneeded'));
+ });
+ } else {
+ const newStream = new window.MediaStream([track]);
+ this._streams[stream.id] = newStream;
+ this._reverseStreams[newStream.id] = stream;
+ this.addStream(newStream);
+ }
+ return this.getSenders().find(s => s.track === track);
+ };
+
+ // replace the internal stream id with the external one and
+ // vice versa.
+ function replaceInternalStreamId(pc, description) {
+ let sdp = description.sdp;
+ Object.keys(pc._reverseStreams || []).forEach(internalId => {
+ const externalStream = pc._reverseStreams[internalId];
+ const internalStream = pc._streams[externalStream.id];
+ sdp = sdp.replace(new RegExp(internalStream.id, 'g'),
+ externalStream.id);
+ });
+ return new RTCSessionDescription({
+ type: description.type,
+ sdp
+ });
+ }
+ function replaceExternalStreamId(pc, description) {
+ let sdp = description.sdp;
+ Object.keys(pc._reverseStreams || []).forEach(internalId => {
+ const externalStream = pc._reverseStreams[internalId];
+ const internalStream = pc._streams[externalStream.id];
+ sdp = sdp.replace(new RegExp(externalStream.id, 'g'),
+ internalStream.id);
+ });
+ return new RTCSessionDescription({
+ type: description.type,
+ sdp
+ });
+ }
+ ['createOffer', 'createAnswer'].forEach(function(method) {
+ const nativeMethod = window.RTCPeerConnection.prototype[method];
+ const methodObj = {[method]() {
+ const args = arguments;
+ const isLegacyCall = arguments.length &&
+ typeof arguments[0] === 'function';
+ if (isLegacyCall) {
+ return nativeMethod.apply(this, [
+ (description) => {
+ const desc = replaceInternalStreamId(this, description);
+ args[0].apply(null, [desc]);
+ },
+ (err) => {
+ if (args[1]) {
+ args[1].apply(null, err);
+ }
+ }, arguments[2]
+ ]);
+ }
+ return nativeMethod.apply(this, arguments)
+ .then(description => replaceInternalStreamId(this, description));
+ }};
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+
+ const origSetLocalDescription =
+ window.RTCPeerConnection.prototype.setLocalDescription;
+ window.RTCPeerConnection.prototype.setLocalDescription =
+ function setLocalDescription() {
+ if (!arguments.length || !arguments[0].type) {
+ return origSetLocalDescription.apply(this, arguments);
+ }
+ arguments[0] = replaceExternalStreamId(this, arguments[0]);
+ return origSetLocalDescription.apply(this, arguments);
+ };
+
+ // TODO: mangle getStats: https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamstats-streamidentifier
+
+ const origLocalDescription = Object.getOwnPropertyDescriptor(
+ window.RTCPeerConnection.prototype, 'localDescription');
+ Object.defineProperty(window.RTCPeerConnection.prototype,
+ 'localDescription', {
+ get() {
+ const description = origLocalDescription.get.apply(this);
+ if (description.type === '') {
+ return description;
+ }
+ return replaceInternalStreamId(this, description);
+ }
+ });
+
+ window.RTCPeerConnection.prototype.removeTrack =
+ function removeTrack(sender) {
+ if (this.signalingState === 'closed') {
+ throw new DOMException(
+ 'The RTCPeerConnection\'s signalingState is \'closed\'.',
+ 'InvalidStateError');
+ }
+ // We can not yet check for sender instanceof RTCRtpSender
+ // since we shim RTPSender. So we check if sender._pc is set.
+ if (!sender._pc) {
+ throw new DOMException('Argument 1 of RTCPeerConnection.removeTrack ' +
+ 'does not implement interface RTCRtpSender.', 'TypeError');
+ }
+ const isLocal = sender._pc === this;
+ if (!isLocal) {
+ throw new DOMException('Sender was not created by this connection.',
+ 'InvalidAccessError');
+ }
+
+ // Search for the native stream the senders track belongs to.
+ this._streams = this._streams || {};
+ let stream;
+ Object.keys(this._streams).forEach(streamid => {
+ const hasTrack = this._streams[streamid].getTracks()
+ .find(track => sender.track === track);
+ if (hasTrack) {
+ stream = this._streams[streamid];
+ }
+ });
+
+ if (stream) {
+ if (stream.getTracks().length === 1) {
+ // if this is the last track of the stream, remove the stream. This
+ // takes care of any shimmed _senders.
+ this.removeStream(this._reverseStreams[stream.id]);
+ } else {
+ // relying on the same odd chrome behaviour as above.
+ stream.removeTrack(sender.track);
+ }
+ this.dispatchEvent(new Event('negotiationneeded'));
+ }
+ };
+}
+
+export function shimPeerConnection(window, browserDetails) {
+ if (!window.RTCPeerConnection && window.webkitRTCPeerConnection) {
+ // very basic support for old versions.
+ window.RTCPeerConnection = window.webkitRTCPeerConnection;
+ }
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+
+ // shim implicit creation of RTCSessionDescription/RTCIceCandidate
+ if (browserDetails.version < 53) {
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate']
+ .forEach(function(method) {
+ const nativeMethod = window.RTCPeerConnection.prototype[method];
+ const methodObj = {[method]() {
+ arguments[0] = new ((method === 'addIceCandidate') ?
+ window.RTCIceCandidate :
+ window.RTCSessionDescription)(arguments[0]);
+ return nativeMethod.apply(this, arguments);
+ }};
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ }
+}
+
+// Attempt to fix ONN in plan-b mode.
+export function fixNegotiationNeeded(window, browserDetails) {
+ utils.wrapPeerConnectionEvent(window, 'negotiationneeded', e => {
+ const pc = e.target;
+ if (browserDetails.version < 72 || (pc.getConfiguration &&
+ pc.getConfiguration().sdpSemantics === 'plan-b')) {
+ if (pc.signalingState !== 'stable') {
+ return;
+ }
+ }
+ return e;
+ });
+}
diff --git a/node_modules/webrtc-adapter/src/js/chrome/getdisplaymedia.js b/node_modules/webrtc-adapter/src/js/chrome/getdisplaymedia.js
new file mode 100644
index 0000000..1e8f6ec
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/chrome/getdisplaymedia.js
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+export function shimGetDisplayMedia(window, getSourceId) {
+ if (window.navigator.mediaDevices &&
+ 'getDisplayMedia' in window.navigator.mediaDevices) {
+ return;
+ }
+ if (!(window.navigator.mediaDevices)) {
+ return;
+ }
+ // getSourceId is a function that returns a promise resolving with
+ // the sourceId of the screen/window/tab to be shared.
+ if (typeof getSourceId !== 'function') {
+ console.error('shimGetDisplayMedia: getSourceId argument is not ' +
+ 'a function');
+ return;
+ }
+ window.navigator.mediaDevices.getDisplayMedia =
+ function getDisplayMedia(constraints) {
+ return getSourceId(constraints)
+ .then(sourceId => {
+ const widthSpecified = constraints.video && constraints.video.width;
+ const heightSpecified = constraints.video &&
+ constraints.video.height;
+ const frameRateSpecified = constraints.video &&
+ constraints.video.frameRate;
+ constraints.video = {
+ mandatory: {
+ chromeMediaSource: 'desktop',
+ chromeMediaSourceId: sourceId,
+ maxFrameRate: frameRateSpecified || 3
+ }
+ };
+ if (widthSpecified) {
+ constraints.video.mandatory.maxWidth = widthSpecified;
+ }
+ if (heightSpecified) {
+ constraints.video.mandatory.maxHeight = heightSpecified;
+ }
+ return window.navigator.mediaDevices.getUserMedia(constraints);
+ });
+ };
+}
diff --git a/node_modules/webrtc-adapter/src/js/chrome/getusermedia.js b/node_modules/webrtc-adapter/src/js/chrome/getusermedia.js
new file mode 100644
index 0000000..7b29d20
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/chrome/getusermedia.js
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+import * as utils from '../utils.js';
+const logging = utils.log;
+
+export function shimGetUserMedia(window, browserDetails) {
+ const navigator = window && window.navigator;
+
+ if (!navigator.mediaDevices) {
+ return;
+ }
+
+ const constraintsToChrome_ = function(c) {
+ if (typeof c !== 'object' || c.mandatory || c.optional) {
+ return c;
+ }
+ const cc = {};
+ Object.keys(c).forEach(key => {
+ if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
+ return;
+ }
+ const r = (typeof c[key] === 'object') ? c[key] : {ideal: c[key]};
+ if (r.exact !== undefined && typeof r.exact === 'number') {
+ r.min = r.max = r.exact;
+ }
+ const oldname_ = function(prefix, name) {
+ if (prefix) {
+ return prefix + name.charAt(0).toUpperCase() + name.slice(1);
+ }
+ return (name === 'deviceId') ? 'sourceId' : name;
+ };
+ if (r.ideal !== undefined) {
+ cc.optional = cc.optional || [];
+ let oc = {};
+ if (typeof r.ideal === 'number') {
+ oc[oldname_('min', key)] = r.ideal;
+ cc.optional.push(oc);
+ oc = {};
+ oc[oldname_('max', key)] = r.ideal;
+ cc.optional.push(oc);
+ } else {
+ oc[oldname_('', key)] = r.ideal;
+ cc.optional.push(oc);
+ }
+ }
+ if (r.exact !== undefined && typeof r.exact !== 'number') {
+ cc.mandatory = cc.mandatory || {};
+ cc.mandatory[oldname_('', key)] = r.exact;
+ } else {
+ ['min', 'max'].forEach(mix => {
+ if (r[mix] !== undefined) {
+ cc.mandatory = cc.mandatory || {};
+ cc.mandatory[oldname_(mix, key)] = r[mix];
+ }
+ });
+ }
+ });
+ if (c.advanced) {
+ cc.optional = (cc.optional || []).concat(c.advanced);
+ }
+ return cc;
+ };
+
+ const shimConstraints_ = function(constraints, func) {
+ if (browserDetails.version >= 61) {
+ return func(constraints);
+ }
+ constraints = JSON.parse(JSON.stringify(constraints));
+ if (constraints && typeof constraints.audio === 'object') {
+ const remap = function(obj, a, b) {
+ if (a in obj && !(b in obj)) {
+ obj[b] = obj[a];
+ delete obj[a];
+ }
+ };
+ constraints = JSON.parse(JSON.stringify(constraints));
+ remap(constraints.audio, 'autoGainControl', 'googAutoGainControl');
+ remap(constraints.audio, 'noiseSuppression', 'googNoiseSuppression');
+ constraints.audio = constraintsToChrome_(constraints.audio);
+ }
+ if (constraints && typeof constraints.video === 'object') {
+ // Shim facingMode for mobile & surface pro.
+ let face = constraints.video.facingMode;
+ face = face && ((typeof face === 'object') ? face : {ideal: face});
+ const getSupportedFacingModeLies = browserDetails.version < 66;
+
+ if ((face && (face.exact === 'user' || face.exact === 'environment' ||
+ face.ideal === 'user' || face.ideal === 'environment')) &&
+ !(navigator.mediaDevices.getSupportedConstraints &&
+ navigator.mediaDevices.getSupportedConstraints().facingMode &&
+ !getSupportedFacingModeLies)) {
+ delete constraints.video.facingMode;
+ let matches;
+ if (face.exact === 'environment' || face.ideal === 'environment') {
+ matches = ['back', 'rear'];
+ } else if (face.exact === 'user' || face.ideal === 'user') {
+ matches = ['front'];
+ }
+ if (matches) {
+ // Look for matches in label, or use last cam for back (typical).
+ return navigator.mediaDevices.enumerateDevices()
+ .then(devices => {
+ devices = devices.filter(d => d.kind === 'videoinput');
+ let dev = devices.find(d => matches.some(match =>
+ d.label.toLowerCase().includes(match)));
+ if (!dev && devices.length && matches.includes('back')) {
+ dev = devices[devices.length - 1]; // more likely the back cam
+ }
+ if (dev) {
+ constraints.video.deviceId = face.exact
+ ? {exact: dev.deviceId}
+ : {ideal: dev.deviceId};
+ }
+ constraints.video = constraintsToChrome_(constraints.video);
+ logging('chrome: ' + JSON.stringify(constraints));
+ return func(constraints);
+ });
+ }
+ }
+ constraints.video = constraintsToChrome_(constraints.video);
+ }
+ logging('chrome: ' + JSON.stringify(constraints));
+ return func(constraints);
+ };
+
+ const shimError_ = function(e) {
+ if (browserDetails.version >= 64) {
+ return e;
+ }
+ return {
+ name: {
+ PermissionDeniedError: 'NotAllowedError',
+ PermissionDismissedError: 'NotAllowedError',
+ InvalidStateError: 'NotAllowedError',
+ DevicesNotFoundError: 'NotFoundError',
+ ConstraintNotSatisfiedError: 'OverconstrainedError',
+ TrackStartError: 'NotReadableError',
+ MediaDeviceFailedDueToShutdown: 'NotAllowedError',
+ MediaDeviceKillSwitchOn: 'NotAllowedError',
+ TabCaptureError: 'AbortError',
+ ScreenCaptureError: 'AbortError',
+ DeviceCaptureError: 'AbortError'
+ }[e.name] || e.name,
+ message: e.message,
+ constraint: e.constraint || e.constraintName,
+ toString() {
+ return this.name + (this.message && ': ') + this.message;
+ }
+ };
+ };
+
+ const getUserMedia_ = function(constraints, onSuccess, onError) {
+ shimConstraints_(constraints, c => {
+ navigator.webkitGetUserMedia(c, onSuccess, e => {
+ if (onError) {
+ onError(shimError_(e));
+ }
+ });
+ });
+ };
+ navigator.getUserMedia = getUserMedia_.bind(navigator);
+
+ // Even though Chrome 45 has navigator.mediaDevices and a getUserMedia
+ // function which returns a Promise, it does not accept spec-style
+ // constraints.
+ if (navigator.mediaDevices.getUserMedia) {
+ const origGetUserMedia = navigator.mediaDevices.getUserMedia.
+ bind(navigator.mediaDevices);
+ navigator.mediaDevices.getUserMedia = function(cs) {
+ return shimConstraints_(cs, c => origGetUserMedia(c).then(stream => {
+ if (c.audio && !stream.getAudioTracks().length ||
+ c.video && !stream.getVideoTracks().length) {
+ stream.getTracks().forEach(track => {
+ track.stop();
+ });
+ throw new DOMException('', 'NotFoundError');
+ }
+ return stream;
+ }, e => Promise.reject(shimError_(e))));
+ };
+ }
+}
diff --git a/node_modules/webrtc-adapter/src/js/common_shim.js b/node_modules/webrtc-adapter/src/js/common_shim.js
new file mode 100644
index 0000000..96d7c8e
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/common_shim.js
@@ -0,0 +1,462 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+import SDPUtils from 'sdp';
+import * as utils from './utils';
+
+export function shimRTCIceCandidate(window) {
+ // foundation is arbitrarily chosen as an indicator for full support for
+ // https://w3c.github.io/webrtc-pc/#rtcicecandidate-interface
+ if (!window.RTCIceCandidate || (window.RTCIceCandidate && 'foundation' in
+ window.RTCIceCandidate.prototype)) {
+ return;
+ }
+
+ const NativeRTCIceCandidate = window.RTCIceCandidate;
+ window.RTCIceCandidate = function RTCIceCandidate(args) {
+ // Remove the a= which shouldn't be part of the candidate string.
+ if (typeof args === 'object' && args.candidate &&
+ args.candidate.indexOf('a=') === 0) {
+ args = JSON.parse(JSON.stringify(args));
+ args.candidate = args.candidate.substring(2);
+ }
+
+ if (args.candidate && args.candidate.length) {
+ // Augment the native candidate with the parsed fields.
+ const nativeCandidate = new NativeRTCIceCandidate(args);
+ const parsedCandidate = SDPUtils.parseCandidate(args.candidate);
+ for (const key in parsedCandidate) {
+ if (!(key in nativeCandidate)) {
+ Object.defineProperty(nativeCandidate, key,
+ {value: parsedCandidate[key]});
+ }
+ }
+
+ // Override serializer to not serialize the extra attributes.
+ nativeCandidate.toJSON = function toJSON() {
+ return {
+ candidate: nativeCandidate.candidate,
+ sdpMid: nativeCandidate.sdpMid,
+ sdpMLineIndex: nativeCandidate.sdpMLineIndex,
+ usernameFragment: nativeCandidate.usernameFragment,
+ };
+ };
+ return nativeCandidate;
+ }
+ return new NativeRTCIceCandidate(args);
+ };
+ window.RTCIceCandidate.prototype = NativeRTCIceCandidate.prototype;
+
+ // Hook up the augmented candidate in onicecandidate and
+ // addEventListener('icecandidate', ...)
+ utils.wrapPeerConnectionEvent(window, 'icecandidate', e => {
+ if (e.candidate) {
+ Object.defineProperty(e, 'candidate', {
+ value: new window.RTCIceCandidate(e.candidate),
+ writable: 'false'
+ });
+ }
+ return e;
+ });
+}
+
+export function shimRTCIceCandidateRelayProtocol(window) {
+ if (!window.RTCIceCandidate || (window.RTCIceCandidate && 'relayProtocol' in
+ window.RTCIceCandidate.prototype)) {
+ return;
+ }
+
+ // Hook up the augmented candidate in onicecandidate and
+ // addEventListener('icecandidate', ...)
+ utils.wrapPeerConnectionEvent(window, 'icecandidate', e => {
+ if (e.candidate) {
+ const parsedCandidate = SDPUtils.parseCandidate(e.candidate.candidate);
+ if (parsedCandidate.type === 'relay') {
+ // This is a libwebrtc-specific mapping of local type preference
+ // to relayProtocol.
+ e.candidate.relayProtocol = {
+ 0: 'tls',
+ 1: 'tcp',
+ 2: 'udp',
+ }[parsedCandidate.priority >> 24];
+ }
+ }
+ return e;
+ });
+}
+
+export function shimMaxMessageSize(window, browserDetails) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+
+ if (!('sctp' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'sctp', {
+ get() {
+ return typeof this._sctp === 'undefined' ? null : this._sctp;
+ }
+ });
+ }
+
+ const sctpInDescription = function(description) {
+ if (!description || !description.sdp) {
+ return false;
+ }
+ const sections = SDPUtils.splitSections(description.sdp);
+ sections.shift();
+ return sections.some(mediaSection => {
+ const mLine = SDPUtils.parseMLine(mediaSection);
+ return mLine && mLine.kind === 'application'
+ && mLine.protocol.indexOf('SCTP') !== -1;
+ });
+ };
+
+ const getRemoteFirefoxVersion = function(description) {
+ // TODO: Is there a better solution for detecting Firefox?
+ const match = description.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);
+ if (match === null || match.length < 2) {
+ return -1;
+ }
+ const version = parseInt(match[1], 10);
+ // Test for NaN (yes, this is ugly)
+ return version !== version ? -1 : version;
+ };
+
+ const getCanSendMaxMessageSize = function(remoteIsFirefox) {
+ // Every implementation we know can send at least 64 KiB.
+ // Note: Although Chrome is technically able to send up to 256 KiB, the
+ // data does not reach the other peer reliably.
+ // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=8419
+ let canSendMaxMessageSize = 65536;
+ if (browserDetails.browser === 'firefox') {
+ if (browserDetails.version < 57) {
+ if (remoteIsFirefox === -1) {
+ // FF < 57 will send in 16 KiB chunks using the deprecated PPID
+ // fragmentation.
+ canSendMaxMessageSize = 16384;
+ } else {
+ // However, other FF (and RAWRTC) can reassemble PPID-fragmented
+ // messages. Thus, supporting ~2 GiB when sending.
+ canSendMaxMessageSize = 2147483637;
+ }
+ } else if (browserDetails.version < 60) {
+ // Currently, all FF >= 57 will reset the remote maximum message size
+ // to the default value when a data channel is created at a later
+ // stage. :(
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
+ canSendMaxMessageSize =
+ browserDetails.version === 57 ? 65535 : 65536;
+ } else {
+ // FF >= 60 supports sending ~2 GiB
+ canSendMaxMessageSize = 2147483637;
+ }
+ }
+ return canSendMaxMessageSize;
+ };
+
+ const getMaxMessageSize = function(description, remoteIsFirefox) {
+ // Note: 65536 bytes is the default value from the SDP spec. Also,
+ // every implementation we know supports receiving 65536 bytes.
+ let maxMessageSize = 65536;
+
+ // FF 57 has a slightly incorrect default remote max message size, so
+ // we need to adjust it here to avoid a failure when sending.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1425697
+ if (browserDetails.browser === 'firefox'
+ && browserDetails.version === 57) {
+ maxMessageSize = 65535;
+ }
+
+ const match = SDPUtils.matchPrefix(description.sdp,
+ 'a=max-message-size:');
+ if (match.length > 0) {
+ maxMessageSize = parseInt(match[0].substring(19), 10);
+ } else if (browserDetails.browser === 'firefox' &&
+ remoteIsFirefox !== -1) {
+ // If the maximum message size is not present in the remote SDP and
+ // both local and remote are Firefox, the remote peer can receive
+ // ~2 GiB.
+ maxMessageSize = 2147483637;
+ }
+ return maxMessageSize;
+ };
+
+ const origSetRemoteDescription =
+ window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription =
+ function setRemoteDescription() {
+ this._sctp = null;
+ // Chrome decided to not expose .sctp in plan-b mode.
+ // As usual, adapter.js has to do an 'ugly worakaround'
+ // to cover up the mess.
+ if (browserDetails.browser === 'chrome' && browserDetails.version >= 76) {
+ const {sdpSemantics} = this.getConfiguration();
+ if (sdpSemantics === 'plan-b') {
+ Object.defineProperty(this, 'sctp', {
+ get() {
+ return typeof this._sctp === 'undefined' ? null : this._sctp;
+ },
+ enumerable: true,
+ configurable: true,
+ });
+ }
+ }
+
+ if (sctpInDescription(arguments[0])) {
+ // Check if the remote is FF.
+ const isFirefox = getRemoteFirefoxVersion(arguments[0]);
+
+ // Get the maximum message size the local peer is capable of sending
+ const canSendMMS = getCanSendMaxMessageSize(isFirefox);
+
+ // Get the maximum message size of the remote peer.
+ const remoteMMS = getMaxMessageSize(arguments[0], isFirefox);
+
+ // Determine final maximum message size
+ let maxMessageSize;
+ if (canSendMMS === 0 && remoteMMS === 0) {
+ maxMessageSize = Number.POSITIVE_INFINITY;
+ } else if (canSendMMS === 0 || remoteMMS === 0) {
+ maxMessageSize = Math.max(canSendMMS, remoteMMS);
+ } else {
+ maxMessageSize = Math.min(canSendMMS, remoteMMS);
+ }
+
+ // Create a dummy RTCSctpTransport object and the 'maxMessageSize'
+ // attribute.
+ const sctp = {};
+ Object.defineProperty(sctp, 'maxMessageSize', {
+ get() {
+ return maxMessageSize;
+ }
+ });
+ this._sctp = sctp;
+ }
+
+ return origSetRemoteDescription.apply(this, arguments);
+ };
+}
+
+export function shimSendThrowTypeError(window) {
+ if (!(window.RTCPeerConnection &&
+ 'createDataChannel' in window.RTCPeerConnection.prototype)) {
+ return;
+ }
+
+ // Note: Although Firefox >= 57 has a native implementation, the maximum
+ // message size can be reset for all data channels at a later stage.
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
+
+ function wrapDcSend(dc, pc) {
+ const origDataChannelSend = dc.send;
+ dc.send = function send() {
+ const data = arguments[0];
+ const length = data.length || data.size || data.byteLength;
+ if (dc.readyState === 'open' &&
+ pc.sctp && length > pc.sctp.maxMessageSize) {
+ throw new TypeError('Message too large (can send a maximum of ' +
+ pc.sctp.maxMessageSize + ' bytes)');
+ }
+ return origDataChannelSend.apply(dc, arguments);
+ };
+ }
+ const origCreateDataChannel =
+ window.RTCPeerConnection.prototype.createDataChannel;
+ window.RTCPeerConnection.prototype.createDataChannel =
+ function createDataChannel() {
+ const dataChannel = origCreateDataChannel.apply(this, arguments);
+ wrapDcSend(dataChannel, this);
+ return dataChannel;
+ };
+ utils.wrapPeerConnectionEvent(window, 'datachannel', e => {
+ wrapDcSend(e.channel, e.target);
+ return e;
+ });
+}
+
+
+/* shims RTCConnectionState by pretending it is the same as iceConnectionState.
+ * See https://bugs.chromium.org/p/webrtc/issues/detail?id=6145#c12
+ * for why this is a valid hack in Chrome. In Firefox it is slightly incorrect
+ * since DTLS failures would be hidden. See
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=1265827
+ * for the Firefox tracking bug.
+ */
+export function shimConnectionState(window) {
+ if (!window.RTCPeerConnection ||
+ 'connectionState' in window.RTCPeerConnection.prototype) {
+ return;
+ }
+ const proto = window.RTCPeerConnection.prototype;
+ Object.defineProperty(proto, 'connectionState', {
+ get() {
+ return {
+ completed: 'connected',
+ checking: 'connecting'
+ }[this.iceConnectionState] || this.iceConnectionState;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(proto, 'onconnectionstatechange', {
+ get() {
+ return this._onconnectionstatechange || null;
+ },
+ set(cb) {
+ if (this._onconnectionstatechange) {
+ this.removeEventListener('connectionstatechange',
+ this._onconnectionstatechange);
+ delete this._onconnectionstatechange;
+ }
+ if (cb) {
+ this.addEventListener('connectionstatechange',
+ this._onconnectionstatechange = cb);
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+
+ ['setLocalDescription', 'setRemoteDescription'].forEach((method) => {
+ const origMethod = proto[method];
+ proto[method] = function() {
+ if (!this._connectionstatechangepoly) {
+ this._connectionstatechangepoly = e => {
+ const pc = e.target;
+ if (pc._lastConnectionState !== pc.connectionState) {
+ pc._lastConnectionState = pc.connectionState;
+ const newEvent = new Event('connectionstatechange', e);
+ pc.dispatchEvent(newEvent);
+ }
+ return e;
+ };
+ this.addEventListener('iceconnectionstatechange',
+ this._connectionstatechangepoly);
+ }
+ return origMethod.apply(this, arguments);
+ };
+ });
+}
+
+export function removeExtmapAllowMixed(window, browserDetails) {
+ /* remove a=extmap-allow-mixed for webrtc.org < M71 */
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ if (browserDetails.browser === 'chrome' && browserDetails.version >= 71) {
+ return;
+ }
+ if (browserDetails.browser === 'safari' && browserDetails.version >= 605) {
+ return;
+ }
+ const nativeSRD = window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription =
+ function setRemoteDescription(desc) {
+ if (desc && desc.sdp && desc.sdp.indexOf('\na=extmap-allow-mixed') !== -1) {
+ const sdp = desc.sdp.split('\n').filter((line) => {
+ return line.trim() !== 'a=extmap-allow-mixed';
+ }).join('\n');
+ // Safari enforces read-only-ness of RTCSessionDescription fields.
+ if (window.RTCSessionDescription &&
+ desc instanceof window.RTCSessionDescription) {
+ arguments[0] = new window.RTCSessionDescription({
+ type: desc.type,
+ sdp,
+ });
+ } else {
+ desc.sdp = sdp;
+ }
+ }
+ return nativeSRD.apply(this, arguments);
+ };
+}
+
+export function shimAddIceCandidateNullOrEmpty(window, browserDetails) {
+ // Support for addIceCandidate(null or undefined)
+ // as well as addIceCandidate({candidate: "", ...})
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=978582
+ // Note: must be called before other polyfills which change the signature.
+ if (!(window.RTCPeerConnection && window.RTCPeerConnection.prototype)) {
+ return;
+ }
+ const nativeAddIceCandidate =
+ window.RTCPeerConnection.prototype.addIceCandidate;
+ if (!nativeAddIceCandidate || nativeAddIceCandidate.length === 0) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.addIceCandidate =
+ function addIceCandidate() {
+ if (!arguments[0]) {
+ if (arguments[1]) {
+ arguments[1].apply(null);
+ }
+ return Promise.resolve();
+ }
+ // Firefox 68+ emits and processes {candidate: "", ...}, ignore
+ // in older versions.
+ // Native support for ignoring exists for Chrome M77+.
+ // Safari ignores as well, exact version unknown but works in the same
+ // version that also ignores addIceCandidate(null).
+ if (((browserDetails.browser === 'chrome' && browserDetails.version < 78)
+ || (browserDetails.browser === 'firefox'
+ && browserDetails.version < 68)
+ || (browserDetails.browser === 'safari'))
+ && arguments[0] && arguments[0].candidate === '') {
+ return Promise.resolve();
+ }
+ return nativeAddIceCandidate.apply(this, arguments);
+ };
+}
+
+// Note: Make sure to call this ahead of APIs that modify
+// setLocalDescription.length
+export function shimParameterlessSetLocalDescription(window, browserDetails) {
+ if (!(window.RTCPeerConnection && window.RTCPeerConnection.prototype)) {
+ return;
+ }
+ const nativeSetLocalDescription =
+ window.RTCPeerConnection.prototype.setLocalDescription;
+ if (!nativeSetLocalDescription || nativeSetLocalDescription.length === 0) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.setLocalDescription =
+ function setLocalDescription() {
+ let desc = arguments[0] || {};
+ if (typeof desc !== 'object' || (desc.type && desc.sdp)) {
+ return nativeSetLocalDescription.apply(this, arguments);
+ }
+ // The remaining steps should technically happen when SLD comes off the
+ // RTCPeerConnection's operations chain (not ahead of going on it), but
+ // this is too difficult to shim. Instead, this shim only covers the
+ // common case where the operations chain is empty. This is imperfect, but
+ // should cover many cases. Rationale: Even if we can't reduce the glare
+ // window to zero on imperfect implementations, there's value in tapping
+ // into the perfect negotiation pattern that several browsers support.
+ desc = {type: desc.type, sdp: desc.sdp};
+ if (!desc.type) {
+ switch (this.signalingState) {
+ case 'stable':
+ case 'have-local-offer':
+ case 'have-remote-pranswer':
+ desc.type = 'offer';
+ break;
+ default:
+ desc.type = 'answer';
+ break;
+ }
+ }
+ if (desc.sdp || (desc.type !== 'offer' && desc.type !== 'answer')) {
+ return nativeSetLocalDescription.apply(this, [desc]);
+ }
+ const func = desc.type === 'offer' ? this.createOffer : this.createAnswer;
+ return func.apply(this)
+ .then(d => nativeSetLocalDescription.apply(this, [d]));
+ };
+}
diff --git a/node_modules/webrtc-adapter/src/js/firefox/firefox_shim.js b/node_modules/webrtc-adapter/src/js/firefox/firefox_shim.js
new file mode 100644
index 0000000..4b9852b
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/firefox/firefox_shim.js
@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+import * as utils from '../utils';
+export {shimGetUserMedia} from './getusermedia';
+export {shimGetDisplayMedia} from './getdisplaymedia';
+
+export function shimOnTrack(window) {
+ if (typeof window === 'object' && window.RTCTrackEvent &&
+ ('receiver' in window.RTCTrackEvent.prototype) &&
+ !('transceiver' in window.RTCTrackEvent.prototype)) {
+ Object.defineProperty(window.RTCTrackEvent.prototype, 'transceiver', {
+ get() {
+ return {receiver: this.receiver};
+ }
+ });
+ }
+}
+
+export function shimPeerConnection(window, browserDetails) {
+ if (typeof window !== 'object' ||
+ !(window.RTCPeerConnection || window.mozRTCPeerConnection)) {
+ return; // probably media.peerconnection.enabled=false in about:config
+ }
+ if (!window.RTCPeerConnection && window.mozRTCPeerConnection) {
+ // very basic support for old versions.
+ window.RTCPeerConnection = window.mozRTCPeerConnection;
+ }
+
+ if (browserDetails.version < 53) {
+ // shim away need for obsolete RTCIceCandidate/RTCSessionDescription.
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate']
+ .forEach(function(method) {
+ const nativeMethod = window.RTCPeerConnection.prototype[method];
+ const methodObj = {[method]() {
+ arguments[0] = new ((method === 'addIceCandidate') ?
+ window.RTCIceCandidate :
+ window.RTCSessionDescription)(arguments[0]);
+ return nativeMethod.apply(this, arguments);
+ }};
+ window.RTCPeerConnection.prototype[method] = methodObj[method];
+ });
+ }
+
+ const modernStatsTypes = {
+ inboundrtp: 'inbound-rtp',
+ outboundrtp: 'outbound-rtp',
+ candidatepair: 'candidate-pair',
+ localcandidate: 'local-candidate',
+ remotecandidate: 'remote-candidate'
+ };
+
+ const nativeGetStats = window.RTCPeerConnection.prototype.getStats;
+ window.RTCPeerConnection.prototype.getStats = function getStats() {
+ const [selector, onSucc, onErr] = arguments;
+ return nativeGetStats.apply(this, [selector || null])
+ .then(stats => {
+ if (browserDetails.version < 53 && !onSucc) {
+ // Shim only promise getStats with spec-hyphens in type names
+ // Leave callback version alone; misc old uses of forEach before Map
+ try {
+ stats.forEach(stat => {
+ stat.type = modernStatsTypes[stat.type] || stat.type;
+ });
+ } catch (e) {
+ if (e.name !== 'TypeError') {
+ throw e;
+ }
+ // Avoid TypeError: "type" is read-only, in old versions. 34-43ish
+ stats.forEach((stat, i) => {
+ stats.set(i, Object.assign({}, stat, {
+ type: modernStatsTypes[stat.type] || stat.type
+ }));
+ });
+ }
+ }
+ return stats;
+ })
+ .then(onSucc, onErr);
+ };
+}
+
+export function shimSenderGetStats(window) {
+ if (!(typeof window === 'object' && window.RTCPeerConnection &&
+ window.RTCRtpSender)) {
+ return;
+ }
+ if (window.RTCRtpSender && 'getStats' in window.RTCRtpSender.prototype) {
+ return;
+ }
+ const origGetSenders = window.RTCPeerConnection.prototype.getSenders;
+ if (origGetSenders) {
+ window.RTCPeerConnection.prototype.getSenders = function getSenders() {
+ const senders = origGetSenders.apply(this, []);
+ senders.forEach(sender => sender._pc = this);
+ return senders;
+ };
+ }
+
+ const origAddTrack = window.RTCPeerConnection.prototype.addTrack;
+ if (origAddTrack) {
+ window.RTCPeerConnection.prototype.addTrack = function addTrack() {
+ const sender = origAddTrack.apply(this, arguments);
+ sender._pc = this;
+ return sender;
+ };
+ }
+ window.RTCRtpSender.prototype.getStats = function getStats() {
+ return this.track ? this._pc.getStats(this.track) :
+ Promise.resolve(new Map());
+ };
+}
+
+export function shimReceiverGetStats(window) {
+ if (!(typeof window === 'object' && window.RTCPeerConnection &&
+ window.RTCRtpSender)) {
+ return;
+ }
+ if (window.RTCRtpSender && 'getStats' in window.RTCRtpReceiver.prototype) {
+ return;
+ }
+ const origGetReceivers = window.RTCPeerConnection.prototype.getReceivers;
+ if (origGetReceivers) {
+ window.RTCPeerConnection.prototype.getReceivers = function getReceivers() {
+ const receivers = origGetReceivers.apply(this, []);
+ receivers.forEach(receiver => receiver._pc = this);
+ return receivers;
+ };
+ }
+ utils.wrapPeerConnectionEvent(window, 'track', e => {
+ e.receiver._pc = e.srcElement;
+ return e;
+ });
+ window.RTCRtpReceiver.prototype.getStats = function getStats() {
+ return this._pc.getStats(this.track);
+ };
+}
+
+export function shimRemoveStream(window) {
+ if (!window.RTCPeerConnection ||
+ 'removeStream' in window.RTCPeerConnection.prototype) {
+ return;
+ }
+ window.RTCPeerConnection.prototype.removeStream =
+ function removeStream(stream) {
+ utils.deprecated('removeStream', 'removeTrack');
+ this.getSenders().forEach(sender => {
+ if (sender.track && stream.getTracks().includes(sender.track)) {
+ this.removeTrack(sender);
+ }
+ });
+ };
+}
+
+export function shimRTCDataChannel(window) {
+ // rename DataChannel to RTCDataChannel (native fix in FF60):
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1173851
+ if (window.DataChannel && !window.RTCDataChannel) {
+ window.RTCDataChannel = window.DataChannel;
+ }
+}
+
+export function shimAddTransceiver(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(typeof window === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ const origAddTransceiver = window.RTCPeerConnection.prototype.addTransceiver;
+ if (origAddTransceiver) {
+ window.RTCPeerConnection.prototype.addTransceiver =
+ function addTransceiver() {
+ this.setParametersPromises = [];
+ // WebIDL input coercion and validation
+ let sendEncodings = arguments[1] && arguments[1].sendEncodings;
+ if (sendEncodings === undefined) {
+ sendEncodings = [];
+ }
+ sendEncodings = [...sendEncodings];
+ const shouldPerformCheck = sendEncodings.length > 0;
+ if (shouldPerformCheck) {
+ // If sendEncodings params are provided, validate grammar
+ sendEncodings.forEach((encodingParam) => {
+ if ('rid' in encodingParam) {
+ const ridRegex = /^[a-z0-9]{0,16}$/i;
+ if (!ridRegex.test(encodingParam.rid)) {
+ throw new TypeError('Invalid RID value provided.');
+ }
+ }
+ if ('scaleResolutionDownBy' in encodingParam) {
+ if (!(parseFloat(encodingParam.scaleResolutionDownBy) >= 1.0)) {
+ throw new RangeError('scale_resolution_down_by must be >= 1.0');
+ }
+ }
+ if ('maxFramerate' in encodingParam) {
+ if (!(parseFloat(encodingParam.maxFramerate) >= 0)) {
+ throw new RangeError('max_framerate must be >= 0.0');
+ }
+ }
+ });
+ }
+ const transceiver = origAddTransceiver.apply(this, arguments);
+ if (shouldPerformCheck) {
+ // Check if the init options were applied. If not we do this in an
+ // asynchronous way and save the promise reference in a global object.
+ // This is an ugly hack, but at the same time is way more robust than
+ // checking the sender parameters before and after the createOffer
+ // Also note that after the createoffer we are not 100% sure that
+ // the params were asynchronously applied so we might miss the
+ // opportunity to recreate offer.
+ const {sender} = transceiver;
+ const params = sender.getParameters();
+ if (!('encodings' in params) ||
+ // Avoid being fooled by patched getParameters() below.
+ (params.encodings.length === 1 &&
+ Object.keys(params.encodings[0]).length === 0)) {
+ params.encodings = sendEncodings;
+ sender.sendEncodings = sendEncodings;
+ this.setParametersPromises.push(sender.setParameters(params)
+ .then(() => {
+ delete sender.sendEncodings;
+ }).catch(() => {
+ delete sender.sendEncodings;
+ })
+ );
+ }
+ }
+ return transceiver;
+ };
+ }
+}
+
+export function shimGetParameters(window) {
+ if (!(typeof window === 'object' && window.RTCRtpSender)) {
+ return;
+ }
+ const origGetParameters = window.RTCRtpSender.prototype.getParameters;
+ if (origGetParameters) {
+ window.RTCRtpSender.prototype.getParameters =
+ function getParameters() {
+ const params = origGetParameters.apply(this, arguments);
+ if (!('encodings' in params)) {
+ params.encodings = [].concat(this.sendEncodings || [{}]);
+ }
+ return params;
+ };
+ }
+}
+
+export function shimCreateOffer(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(typeof window === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ const origCreateOffer = window.RTCPeerConnection.prototype.createOffer;
+ window.RTCPeerConnection.prototype.createOffer = function createOffer() {
+ if (this.setParametersPromises && this.setParametersPromises.length) {
+ return Promise.all(this.setParametersPromises)
+ .then(() => {
+ return origCreateOffer.apply(this, arguments);
+ })
+ .finally(() => {
+ this.setParametersPromises = [];
+ });
+ }
+ return origCreateOffer.apply(this, arguments);
+ };
+}
+
+export function shimCreateAnswer(window) {
+ // https://github.com/webrtcHacks/adapter/issues/998#issuecomment-516921647
+ // Firefox ignores the init sendEncodings options passed to addTransceiver
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
+ if (!(typeof window === 'object' && window.RTCPeerConnection)) {
+ return;
+ }
+ const origCreateAnswer = window.RTCPeerConnection.prototype.createAnswer;
+ window.RTCPeerConnection.prototype.createAnswer = function createAnswer() {
+ if (this.setParametersPromises && this.setParametersPromises.length) {
+ return Promise.all(this.setParametersPromises)
+ .then(() => {
+ return origCreateAnswer.apply(this, arguments);
+ })
+ .finally(() => {
+ this.setParametersPromises = [];
+ });
+ }
+ return origCreateAnswer.apply(this, arguments);
+ };
+}
diff --git a/node_modules/webrtc-adapter/src/js/firefox/getdisplaymedia.js b/node_modules/webrtc-adapter/src/js/firefox/getdisplaymedia.js
new file mode 100644
index 0000000..0ecce44
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/firefox/getdisplaymedia.js
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+export function shimGetDisplayMedia(window, preferredMediaSource) {
+ if (window.navigator.mediaDevices &&
+ 'getDisplayMedia' in window.navigator.mediaDevices) {
+ return;
+ }
+ if (!(window.navigator.mediaDevices)) {
+ return;
+ }
+ window.navigator.mediaDevices.getDisplayMedia =
+ function getDisplayMedia(constraints) {
+ if (!(constraints && constraints.video)) {
+ const err = new DOMException('getDisplayMedia without video ' +
+ 'constraints is undefined');
+ err.name = 'NotFoundError';
+ // from https://heycam.github.io/webidl/#idl-DOMException-error-names
+ err.code = 8;
+ return Promise.reject(err);
+ }
+ if (constraints.video === true) {
+ constraints.video = {mediaSource: preferredMediaSource};
+ } else {
+ constraints.video.mediaSource = preferredMediaSource;
+ }
+ return window.navigator.mediaDevices.getUserMedia(constraints);
+ };
+}
diff --git a/node_modules/webrtc-adapter/src/js/firefox/getusermedia.js b/node_modules/webrtc-adapter/src/js/firefox/getusermedia.js
new file mode 100644
index 0000000..6b7d87b
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/firefox/getusermedia.js
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+import * as utils from '../utils';
+
+export function shimGetUserMedia(window, browserDetails) {
+ const navigator = window && window.navigator;
+ const MediaStreamTrack = window && window.MediaStreamTrack;
+
+ navigator.getUserMedia = function(constraints, onSuccess, onError) {
+ // Replace Firefox 44+'s deprecation warning with unprefixed version.
+ utils.deprecated('navigator.getUserMedia',
+ 'navigator.mediaDevices.getUserMedia');
+ navigator.mediaDevices.getUserMedia(constraints).then(onSuccess, onError);
+ };
+
+ if (!(browserDetails.version > 55 &&
+ 'autoGainControl' in navigator.mediaDevices.getSupportedConstraints())) {
+ const remap = function(obj, a, b) {
+ if (a in obj && !(b in obj)) {
+ obj[b] = obj[a];
+ delete obj[a];
+ }
+ };
+
+ const nativeGetUserMedia = navigator.mediaDevices.getUserMedia.
+ bind(navigator.mediaDevices);
+ navigator.mediaDevices.getUserMedia = function(c) {
+ if (typeof c === 'object' && typeof c.audio === 'object') {
+ c = JSON.parse(JSON.stringify(c));
+ remap(c.audio, 'autoGainControl', 'mozAutoGainControl');
+ remap(c.audio, 'noiseSuppression', 'mozNoiseSuppression');
+ }
+ return nativeGetUserMedia(c);
+ };
+
+ if (MediaStreamTrack && MediaStreamTrack.prototype.getSettings) {
+ const nativeGetSettings = MediaStreamTrack.prototype.getSettings;
+ MediaStreamTrack.prototype.getSettings = function() {
+ const obj = nativeGetSettings.apply(this, arguments);
+ remap(obj, 'mozAutoGainControl', 'autoGainControl');
+ remap(obj, 'mozNoiseSuppression', 'noiseSuppression');
+ return obj;
+ };
+ }
+
+ if (MediaStreamTrack && MediaStreamTrack.prototype.applyConstraints) {
+ const nativeApplyConstraints =
+ MediaStreamTrack.prototype.applyConstraints;
+ MediaStreamTrack.prototype.applyConstraints = function(c) {
+ if (this.kind === 'audio' && typeof c === 'object') {
+ c = JSON.parse(JSON.stringify(c));
+ remap(c, 'autoGainControl', 'mozAutoGainControl');
+ remap(c, 'noiseSuppression', 'mozNoiseSuppression');
+ }
+ return nativeApplyConstraints.apply(this, [c]);
+ };
+ }
+ }
+}
diff --git a/node_modules/webrtc-adapter/src/js/safari/safari_shim.js b/node_modules/webrtc-adapter/src/js/safari/safari_shim.js
new file mode 100644
index 0000000..cfd09a3
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/safari/safari_shim.js
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+'use strict';
+import * as utils from '../utils';
+
+export function shimLocalStreamsAPI(window) {
+ if (typeof window !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ if (!('getLocalStreams' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.getLocalStreams =
+ function getLocalStreams() {
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ return this._localStreams;
+ };
+ }
+ if (!('addStream' in window.RTCPeerConnection.prototype)) {
+ const _addTrack = window.RTCPeerConnection.prototype.addTrack;
+ window.RTCPeerConnection.prototype.addStream = function addStream(stream) {
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ if (!this._localStreams.includes(stream)) {
+ this._localStreams.push(stream);
+ }
+ // Try to emulate Chrome's behaviour of adding in audio-video order.
+ // Safari orders by track id.
+ stream.getAudioTracks().forEach(track => _addTrack.call(this, track,
+ stream));
+ stream.getVideoTracks().forEach(track => _addTrack.call(this, track,
+ stream));
+ };
+
+ window.RTCPeerConnection.prototype.addTrack =
+ function addTrack(track, ...streams) {
+ if (streams) {
+ streams.forEach((stream) => {
+ if (!this._localStreams) {
+ this._localStreams = [stream];
+ } else if (!this._localStreams.includes(stream)) {
+ this._localStreams.push(stream);
+ }
+ });
+ }
+ return _addTrack.apply(this, arguments);
+ };
+ }
+ if (!('removeStream' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.removeStream =
+ function removeStream(stream) {
+ if (!this._localStreams) {
+ this._localStreams = [];
+ }
+ const index = this._localStreams.indexOf(stream);
+ if (index === -1) {
+ return;
+ }
+ this._localStreams.splice(index, 1);
+ const tracks = stream.getTracks();
+ this.getSenders().forEach(sender => {
+ if (tracks.includes(sender.track)) {
+ this.removeTrack(sender);
+ }
+ });
+ };
+ }
+}
+
+export function shimRemoteStreamsAPI(window) {
+ if (typeof window !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ if (!('getRemoteStreams' in window.RTCPeerConnection.prototype)) {
+ window.RTCPeerConnection.prototype.getRemoteStreams =
+ function getRemoteStreams() {
+ return this._remoteStreams ? this._remoteStreams : [];
+ };
+ }
+ if (!('onaddstream' in window.RTCPeerConnection.prototype)) {
+ Object.defineProperty(window.RTCPeerConnection.prototype, 'onaddstream', {
+ get() {
+ return this._onaddstream;
+ },
+ set(f) {
+ if (this._onaddstream) {
+ this.removeEventListener('addstream', this._onaddstream);
+ this.removeEventListener('track', this._onaddstreampoly);
+ }
+ this.addEventListener('addstream', this._onaddstream = f);
+ this.addEventListener('track', this._onaddstreampoly = (e) => {
+ e.streams.forEach(stream => {
+ if (!this._remoteStreams) {
+ this._remoteStreams = [];
+ }
+ if (this._remoteStreams.includes(stream)) {
+ return;
+ }
+ this._remoteStreams.push(stream);
+ const event = new Event('addstream');
+ event.stream = stream;
+ this.dispatchEvent(event);
+ });
+ });
+ }
+ });
+ const origSetRemoteDescription =
+ window.RTCPeerConnection.prototype.setRemoteDescription;
+ window.RTCPeerConnection.prototype.setRemoteDescription =
+ function setRemoteDescription() {
+ const pc = this;
+ if (!this._onaddstreampoly) {
+ this.addEventListener('track', this._onaddstreampoly = function(e) {
+ e.streams.forEach(stream => {
+ if (!pc._remoteStreams) {
+ pc._remoteStreams = [];
+ }
+ if (pc._remoteStreams.indexOf(stream) >= 0) {
+ return;
+ }
+ pc._remoteStreams.push(stream);
+ const event = new Event('addstream');
+ event.stream = stream;
+ pc.dispatchEvent(event);
+ });
+ });
+ }
+ return origSetRemoteDescription.apply(pc, arguments);
+ };
+ }
+}
+
+export function shimCallbacksAPI(window) {
+ if (typeof window !== 'object' || !window.RTCPeerConnection) {
+ return;
+ }
+ const prototype = window.RTCPeerConnection.prototype;
+ const origCreateOffer = prototype.createOffer;
+ const origCreateAnswer = prototype.createAnswer;
+ const setLocalDescription = prototype.setLocalDescription;
+ const setRemoteDescription = prototype.setRemoteDescription;
+ const addIceCandidate = prototype.addIceCandidate;
+
+ prototype.createOffer =
+ function createOffer(successCallback, failureCallback) {
+ const options = (arguments.length >= 2) ? arguments[2] : arguments[0];
+ const promise = origCreateOffer.apply(this, [options]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+
+ prototype.createAnswer =
+ function createAnswer(successCallback, failureCallback) {
+ const options = (arguments.length >= 2) ? arguments[2] : arguments[0];
+ const promise = origCreateAnswer.apply(this, [options]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+
+ let withCallback = function(description, successCallback, failureCallback) {
+ const promise = setLocalDescription.apply(this, [description]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.setLocalDescription = withCallback;
+
+ withCallback = function(description, successCallback, failureCallback) {
+ const promise = setRemoteDescription.apply(this, [description]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.setRemoteDescription = withCallback;
+
+ withCallback = function(candidate, successCallback, failureCallback) {
+ const promise = addIceCandidate.apply(this, [candidate]);
+ if (!failureCallback) {
+ return promise;
+ }
+ promise.then(successCallback, failureCallback);
+ return Promise.resolve();
+ };
+ prototype.addIceCandidate = withCallback;
+}
+
+export function shimGetUserMedia(window) {
+ const navigator = window && window.navigator;
+
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
+ // shim not needed in Safari 12.1
+ const mediaDevices = navigator.mediaDevices;
+ const _getUserMedia = mediaDevices.getUserMedia.bind(mediaDevices);
+ navigator.mediaDevices.getUserMedia = (constraints) => {
+ return _getUserMedia(shimConstraints(constraints));
+ };
+ }
+
+ if (!navigator.getUserMedia && navigator.mediaDevices &&
+ navigator.mediaDevices.getUserMedia) {
+ navigator.getUserMedia = function getUserMedia(constraints, cb, errcb) {
+ navigator.mediaDevices.getUserMedia(constraints)
+ .then(cb, errcb);
+ }.bind(navigator);
+ }
+}
+
+export function shimConstraints(constraints) {
+ if (constraints && constraints.video !== undefined) {
+ return Object.assign({},
+ constraints,
+ {video: utils.compactObject(constraints.video)}
+ );
+ }
+
+ return constraints;
+}
+
+export function shimRTCIceServerUrls(window) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ // migrate from non-spec RTCIceServer.url to RTCIceServer.urls
+ const OrigPeerConnection = window.RTCPeerConnection;
+ window.RTCPeerConnection =
+ function RTCPeerConnection(pcConfig, pcConstraints) {
+ if (pcConfig && pcConfig.iceServers) {
+ const newIceServers = [];
+ for (let i = 0; i < pcConfig.iceServers.length; i++) {
+ let server = pcConfig.iceServers[i];
+ if (server.urls === undefined && server.url) {
+ utils.deprecated('RTCIceServer.url', 'RTCIceServer.urls');
+ server = JSON.parse(JSON.stringify(server));
+ server.urls = server.url;
+ delete server.url;
+ newIceServers.push(server);
+ } else {
+ newIceServers.push(pcConfig.iceServers[i]);
+ }
+ }
+ pcConfig.iceServers = newIceServers;
+ }
+ return new OrigPeerConnection(pcConfig, pcConstraints);
+ };
+ window.RTCPeerConnection.prototype = OrigPeerConnection.prototype;
+ // wrap static methods. Currently just generateCertificate.
+ if ('generateCertificate' in OrigPeerConnection) {
+ Object.defineProperty(window.RTCPeerConnection, 'generateCertificate', {
+ get() {
+ return OrigPeerConnection.generateCertificate;
+ }
+ });
+ }
+}
+
+export function shimTrackEventTransceiver(window) {
+ // Add event.transceiver member over deprecated event.receiver
+ if (typeof window === 'object' && window.RTCTrackEvent &&
+ 'receiver' in window.RTCTrackEvent.prototype &&
+ !('transceiver' in window.RTCTrackEvent.prototype)) {
+ Object.defineProperty(window.RTCTrackEvent.prototype, 'transceiver', {
+ get() {
+ return {receiver: this.receiver};
+ }
+ });
+ }
+}
+
+export function shimCreateOfferLegacy(window) {
+ const origCreateOffer = window.RTCPeerConnection.prototype.createOffer;
+ window.RTCPeerConnection.prototype.createOffer =
+ function createOffer(offerOptions) {
+ if (offerOptions) {
+ if (typeof offerOptions.offerToReceiveAudio !== 'undefined') {
+ // support bit values
+ offerOptions.offerToReceiveAudio =
+ !!offerOptions.offerToReceiveAudio;
+ }
+ const audioTransceiver = this.getTransceivers().find(transceiver =>
+ transceiver.receiver.track.kind === 'audio');
+ if (offerOptions.offerToReceiveAudio === false && audioTransceiver) {
+ if (audioTransceiver.direction === 'sendrecv') {
+ if (audioTransceiver.setDirection) {
+ audioTransceiver.setDirection('sendonly');
+ } else {
+ audioTransceiver.direction = 'sendonly';
+ }
+ } else if (audioTransceiver.direction === 'recvonly') {
+ if (audioTransceiver.setDirection) {
+ audioTransceiver.setDirection('inactive');
+ } else {
+ audioTransceiver.direction = 'inactive';
+ }
+ }
+ } else if (offerOptions.offerToReceiveAudio === true &&
+ !audioTransceiver) {
+ this.addTransceiver('audio', {direction: 'recvonly'});
+ }
+
+ if (typeof offerOptions.offerToReceiveVideo !== 'undefined') {
+ // support bit values
+ offerOptions.offerToReceiveVideo =
+ !!offerOptions.offerToReceiveVideo;
+ }
+ const videoTransceiver = this.getTransceivers().find(transceiver =>
+ transceiver.receiver.track.kind === 'video');
+ if (offerOptions.offerToReceiveVideo === false && videoTransceiver) {
+ if (videoTransceiver.direction === 'sendrecv') {
+ if (videoTransceiver.setDirection) {
+ videoTransceiver.setDirection('sendonly');
+ } else {
+ videoTransceiver.direction = 'sendonly';
+ }
+ } else if (videoTransceiver.direction === 'recvonly') {
+ if (videoTransceiver.setDirection) {
+ videoTransceiver.setDirection('inactive');
+ } else {
+ videoTransceiver.direction = 'inactive';
+ }
+ }
+ } else if (offerOptions.offerToReceiveVideo === true &&
+ !videoTransceiver) {
+ this.addTransceiver('video', {direction: 'recvonly'});
+ }
+ }
+ return origCreateOffer.apply(this, arguments);
+ };
+}
+
+export function shimAudioContext(window) {
+ if (typeof window !== 'object' || window.AudioContext) {
+ return;
+ }
+ window.AudioContext = window.webkitAudioContext;
+}
+
diff --git a/node_modules/webrtc-adapter/src/js/utils.js b/node_modules/webrtc-adapter/src/js/utils.js
new file mode 100644
index 0000000..c03f0fa
--- /dev/null
+++ b/node_modules/webrtc-adapter/src/js/utils.js
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree.
+ */
+/* eslint-env node */
+'use strict';
+
+let logDisabled_ = true;
+let deprecationWarnings_ = true;
+
+/**
+ * Extract browser version out of the provided user agent string.
+ *
+ * @param {!string} uastring userAgent string.
+ * @param {!string} expr Regular expression used as match criteria.
+ * @param {!number} pos position in the version string to be returned.
+ * @return {!number} browser version.
+ */
+export function extractVersion(uastring, expr, pos) {
+ const match = uastring.match(expr);
+ return match && match.length >= pos && parseInt(match[pos], 10);
+}
+
+// Wraps the peerconnection event eventNameToWrap in a function
+// which returns the modified event object (or false to prevent
+// the event).
+export function wrapPeerConnectionEvent(window, eventNameToWrap, wrapper) {
+ if (!window.RTCPeerConnection) {
+ return;
+ }
+ const proto = window.RTCPeerConnection.prototype;
+ const nativeAddEventListener = proto.addEventListener;
+ proto.addEventListener = function(nativeEventName, cb) {
+ if (nativeEventName !== eventNameToWrap) {
+ return nativeAddEventListener.apply(this, arguments);
+ }
+ const wrappedCallback = (e) => {
+ const modifiedEvent = wrapper(e);
+ if (modifiedEvent) {
+ if (cb.handleEvent) {
+ cb.handleEvent(modifiedEvent);
+ } else {
+ cb(modifiedEvent);
+ }
+ }
+ };
+ this._eventMap = this._eventMap || {};
+ if (!this._eventMap[eventNameToWrap]) {
+ this._eventMap[eventNameToWrap] = new Map();
+ }
+ this._eventMap[eventNameToWrap].set(cb, wrappedCallback);
+ return nativeAddEventListener.apply(this, [nativeEventName,
+ wrappedCallback]);
+ };
+
+ const nativeRemoveEventListener = proto.removeEventListener;
+ proto.removeEventListener = function(nativeEventName, cb) {
+ if (nativeEventName !== eventNameToWrap || !this._eventMap
+ || !this._eventMap[eventNameToWrap]) {
+ return nativeRemoveEventListener.apply(this, arguments);
+ }
+ if (!this._eventMap[eventNameToWrap].has(cb)) {
+ return nativeRemoveEventListener.apply(this, arguments);
+ }
+ const unwrappedCb = this._eventMap[eventNameToWrap].get(cb);
+ this._eventMap[eventNameToWrap].delete(cb);
+ if (this._eventMap[eventNameToWrap].size === 0) {
+ delete this._eventMap[eventNameToWrap];
+ }
+ if (Object.keys(this._eventMap).length === 0) {
+ delete this._eventMap;
+ }
+ return nativeRemoveEventListener.apply(this, [nativeEventName,
+ unwrappedCb]);
+ };
+
+ Object.defineProperty(proto, 'on' + eventNameToWrap, {
+ get() {
+ return this['_on' + eventNameToWrap];
+ },
+ set(cb) {
+ if (this['_on' + eventNameToWrap]) {
+ this.removeEventListener(eventNameToWrap,
+ this['_on' + eventNameToWrap]);
+ delete this['_on' + eventNameToWrap];
+ }
+ if (cb) {
+ this.addEventListener(eventNameToWrap,
+ this['_on' + eventNameToWrap] = cb);
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+}
+
+export function disableLog(bool) {
+ if (typeof bool !== 'boolean') {
+ return new Error('Argument type: ' + typeof bool +
+ '. Please use a boolean.');
+ }
+ logDisabled_ = bool;
+ return (bool) ? 'adapter.js logging disabled' :
+ 'adapter.js logging enabled';
+}
+
+/**
+ * Disable or enable deprecation warnings
+ * @param {!boolean} bool set to true to disable warnings.
+ */
+export function disableWarnings(bool) {
+ if (typeof bool !== 'boolean') {
+ return new Error('Argument type: ' + typeof bool +
+ '. Please use a boolean.');
+ }
+ deprecationWarnings_ = !bool;
+ return 'adapter.js deprecation warnings ' + (bool ? 'disabled' : 'enabled');
+}
+
+export function log() {
+ if (typeof window === 'object') {
+ if (logDisabled_) {
+ return;
+ }
+ if (typeof console !== 'undefined' && typeof console.log === 'function') {
+ console.log.apply(console, arguments);
+ }
+ }
+}
+
+/**
+ * Shows a deprecation warning suggesting the modern and spec-compatible API.
+ */
+export function deprecated(oldMethod, newMethod) {
+ if (!deprecationWarnings_) {
+ return;
+ }
+ console.warn(oldMethod + ' is deprecated, please use ' + newMethod +
+ ' instead.');
+}
+
+/**
+ * Browser detector.
+ *
+ * @return {object} result containing browser and version
+ * properties.
+ */
+export function detectBrowser(window) {
+ // Returned result object.
+ const result = {browser: null, version: null};
+
+ // Fail early if it's not a browser
+ if (typeof window === 'undefined' || !window.navigator ||
+ !window.navigator.userAgent) {
+ result.browser = 'Not a browser.';
+ return result;
+ }
+
+ const {navigator} = window;
+
+ if (navigator.mozGetUserMedia) { // Firefox.
+ result.browser = 'firefox';
+ result.version = extractVersion(navigator.userAgent,
+ /Firefox\/(\d+)\./, 1);
+ } else if (navigator.webkitGetUserMedia ||
+ (window.isSecureContext === false && window.webkitRTCPeerConnection)) {
+ // Chrome, Chromium, Webview, Opera.
+ // Version matches Chrome/WebRTC version.
+ // Chrome 74 removed webkitGetUserMedia on http as well so we need the
+ // more complicated fallback to webkitRTCPeerConnection.
+ result.browser = 'chrome';
+ result.version = extractVersion(navigator.userAgent,
+ /Chrom(e|ium)\/(\d+)\./, 2);
+ } else if (window.RTCPeerConnection &&
+ navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) { // Safari.
+ result.browser = 'safari';
+ result.version = extractVersion(navigator.userAgent,
+ /AppleWebKit\/(\d+)\./, 1);
+ result.supportsUnifiedPlan = window.RTCRtpTransceiver &&
+ 'currentDirection' in window.RTCRtpTransceiver.prototype;
+ } else { // Default fallthrough: not supported.
+ result.browser = 'Not a supported browser.';
+ return result;
+ }
+
+ return result;
+}
+
+/**
+ * Checks if something is an object.
+ *
+ * @param {*} val The something you want to check.
+ * @return true if val is an object, false otherwise.
+ */
+function isObject(val) {
+ return Object.prototype.toString.call(val) === '[object Object]';
+}
+
+/**
+ * Remove all empty objects and undefined values
+ * from a nested object -- an enhanced and vanilla version
+ * of Lodash's `compact`.
+ */
+export function compactObject(data) {
+ if (!isObject(data)) {
+ return data;
+ }
+
+ return Object.keys(data).reduce(function(accumulator, key) {
+ const isObj = isObject(data[key]);
+ const value = isObj ? compactObject(data[key]) : data[key];
+ const isEmptyObject = isObj && !Object.keys(value).length;
+ if (value === undefined || isEmptyObject) {
+ return accumulator;
+ }
+ return Object.assign(accumulator, {[key]: value});
+ }, {});
+}
+
+/* iterates the stats graph recursively. */
+export function walkStats(stats, base, resultSet) {
+ if (!base || resultSet.has(base.id)) {
+ return;
+ }
+ resultSet.set(base.id, base);
+ Object.keys(base).forEach(name => {
+ if (name.endsWith('Id')) {
+ walkStats(stats, stats.get(base[name]), resultSet);
+ } else if (name.endsWith('Ids')) {
+ base[name].forEach(id => {
+ walkStats(stats, stats.get(id), resultSet);
+ });
+ }
+ });
+}
+
+/* filter getStats for a sender/receiver track. */
+export function filterStats(result, track, outbound) {
+ const streamStatsType = outbound ? 'outbound-rtp' : 'inbound-rtp';
+ const filteredResult = new Map();
+ if (track === null) {
+ return filteredResult;
+ }
+ const trackStats = [];
+ result.forEach(value => {
+ if (value.type === 'track' &&
+ value.trackIdentifier === track.id) {
+ trackStats.push(value);
+ }
+ });
+ trackStats.forEach(trackStat => {
+ result.forEach(stats => {
+ if (stats.type === streamStatsType && stats.trackId === trackStat.id) {
+ walkStats(result, stats, filteredResult);
+ }
+ });
+ });
+ return filteredResult;
+}
+
diff --git a/node_modules/zxing-wasm/LICENSE b/node_modules/zxing-wasm/LICENSE
new file mode 100644
index 0000000..5dd3d5b
--- /dev/null
+++ b/node_modules/zxing-wasm/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Ze-Zheng Wu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/node_modules/zxing-wasm/README.md b/node_modules/zxing-wasm/README.md
new file mode 100644
index 0000000..38d65ef
--- /dev/null
+++ b/node_modules/zxing-wasm/README.md
@@ -0,0 +1,246 @@
+# zxing-wasm
+
+[](https://www.npmjs.com/package/zxing-wasm/v/latest) [](https://www.npmjs.com/package/zxing-wasm/v/latest) [](https://cdn.jsdelivr.net/npm/zxing-wasm@latest/) [](https://app.netlify.com/sites/zxing-wasm/deploys)
+
+[ZXing-C++](https://github.com/zxing-cpp/zxing-cpp) WebAssembly as an ES/CJS module with types. Read or write barcodes in your browser (or other JS runtimes like node)!
+
+Visit [this online demo](https://zxing-wasm-demo.netlify.app/) to quickly explore its basic functions. It works best on the latest chromium browsers.
+
+## Build
+
+```bash
+git clone --recurse-submodules https://github.com/Sec-ant/zxing-wasm
+cd zxing-wasm
+npm i
+# install cmake first:
+# https://cmake.org/download/
+npm run cmake
+# install emscripten first:
+# https://emscripten.org/docs/getting_started/downloads.html
+npm run build:wasm
+npm run build
+```
+
+## Install
+
+```
+npm i zxing-wasm
+```
+
+## Documentation
+
+https://zxing-wasm.netlify.app/
+
+## Demo
+
+Demo page: https://zxing-wasm-demo.netlify.app/
+
+Demo source: https://github.com/Sec-ant/zxing-wasm-demo
+
+## Usage
+
+This package exports 3 subpaths: `full`, `reader` and `writer`. You can choose whichever fits your needs. If you use TypeScript, you should set [`moduleResolution`](https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution) to [`bundler`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler), [`node16` or `nodenext`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext-1) in your `tsconfig.json` file to properly resolve the exported module.
+
+### `zxing-wasm` or `zxing-wasm/full`
+
+These 2 subpaths include functions to both read and write barcodes. The wasm binary size is ~1.17 MB.
+
+```ts
+import {
+ readBarcodesFromImageFile,
+ readBarcodesFromImageData,
+ writeBarcodeToImageFile,
+} from "zxing-wasm";
+```
+
+or
+
+```ts
+import {
+ readBarcodesFromImageFile,
+ readBarcodesFromImageData,
+ writeBarcodeToImageFile,
+} from "zxing-wasm/full";
+```
+
+### `zxing-wasm/reader`
+
+This subpath only includes functions to read barcodes. The wasm binary size is ~930 KB.
+
+```ts
+import {
+ readBarcodesFromImageFile,
+ readBarcodesFromImageData,
+} from "zxing-wasm/reader";
+```
+
+### `zxing-wasm/writer`
+
+This subpath only includes a function to write barcodes. The wasm binary size is ~330 KB.
+
+```ts
+import { writeBarcodeToImageFile } from "zxing-wasm/writer";
+```
+
+### IIFE Scripts
+
+Apart from ES and CJS modules, this package also ships IIFE scripts. The registered global variable is named `ZXingWASM`.
+
+```html
+
+
+
+
+
+
+
+
+```
+
+### [`readBarcodesFromImageFile`](https://zxing-wasm.netlify.app/functions/full.readBarcodesFromImageFile.html) and [`readBarcodesFromImageData`](https://zxing-wasm.netlify.app/functions/full.readBarcodesFromImageData.html)
+
+These 2 functions are for reading barcodes.
+
+[`readBarcodesFromImageFile`](https://zxing-wasm.netlify.app/functions/full.readBarcodesFromImageFile.html) accepts an image [`Blob`](https://developer.mozilla.org/docs/Web/API/Blob) or an image [`File`](https://developer.mozilla.org/docs/Web/API/File) as the first input. They're encoded images, e.g. `.png` `.jpg` files.
+
+[`readBarcodesFromImageData`](https://zxing-wasm.netlify.app/functions/full.readBarcodesFromImageData.html) accepts an [`ImageData`](https://developer.mozilla.org/docs/Web/API/ImageData) as the first input. They're raw pixels that usually acquired from [`