@zoom/meetingsdk
Version:
Zoom MeetingSDK-Web Client
1 lines • 169 kB
JavaScript
(window.webpackJsonpJsMediaSDK_Instance=window.webpackJsonpJsMediaSDK_Instance||[]).push([[3],{100:function(e,t,i){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,i,a){void 0===a&&(a=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,a,s)}:function(e,t,i,a){void 0===a&&(a=i),e[a]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return s(t,e),t},r=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(s,n){function r(e){try{c(a.next(e))}catch(e){n(e)}}function o(e){try{c(a.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,o)}c((a=a.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.replaceComma=t.isDevelopment=t.compareResourceUsageState=t.compareArrays=t.decodeString=t.encodeString=t.base64ToArrayBuffer=t.arrayBufferToBase64=t.decompress=t.compress=t.setTrackContentHint=t.stopMediaStream=t.stopMediaStreams=t.getStreamId=t.getNodeId=void 0;const o=n(i(99));function c(e){(null==e?void 0:e.getTracks)&&e.getTracks().forEach(e=>{e.stop()})}function d(e,t){return r(this,void 0,void 0,(function*(){const a=(new TextEncoder).encode(e);if(window.CompressionStream){const e=new CompressionStream(t),i=e.writable.getWriter();return i.write(a),i.close(),new Response(e.readable).arrayBuffer()}{const{gzip:e}=yield Promise.resolve().then(()=>n(i(109)));return e(a).buffer}}))}function l(e,t){return r(this,void 0,void 0,(function*(){if(window.DecompressionStream){const i=new DecompressionStream(t),a=i.writable.getWriter();return a.write(e),a.close(),new Response(i.readable).arrayBuffer().then((function(e){return(new TextDecoder).decode(e)}))}{const{ungzip:t}=yield Promise.resolve().then(()=>n(i(109)));return(new TextDecoder).decode(t(e).buffer)}}))}function h(e){let t="";const i=new Uint8Array(e);for(let e=0;e<i.byteLength;e++)t+=String.fromCharCode(i[e]);return btoa(t)}function u(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<i.length;e++)i[e]=t.charCodeAt(e);return i.buffer}t.getNodeId=function(e){return 4294966272&e},t.getStreamId=function(e,t){let i=0;switch(t){case o.SESSION_ID.VIDEO:i=o.STREAM_ID_MASK.VIDEO;break;case o.SESSION_ID.AUDIO:i=o.STREAM_ID_MASK.AUDIO;break;case o.SESSION_ID.SHARE:i=o.STREAM_ID_MASK.SHARE}return-4&e|i},t.stopMediaStreams=function(e){e&&(Array.isArray(e)?e.forEach(e=>{c(e)}):c(e))},t.stopMediaStream=c,t.setTrackContentHint=function(e,t){if(e.contentHint=t,e.contentHint!==t)throw new Error("Invalid track contentHint: "+t)},t.compress=d,t.decompress=l,t.arrayBufferToBase64=h,t.base64ToArrayBuffer=u,t.encodeString=function(e,t){return r(this,void 0,void 0,(function*(){switch(t){case o.TEXT_ENCODING.GZIP_BASE64:return h(yield d(e,"gzip"));case o.TEXT_ENCODING.PLAIN:return e;default:return null}}))},t.decodeString=function(e,t){return r(this,void 0,void 0,(function*(){switch(t){case o.TEXT_ENCODING.GZIP_BASE64:return l(u(e),"gzip");case o.TEXT_ENCODING.PLAIN:return e;default:return null}}))},t.compareArrays=function(e,t){return e.length===t.length&&e.every((e,i)=>e===t[i])},t.compareResourceUsageState=function(e,t){return e-t},t.isDevelopment=function(){return!1},t.replaceComma=function(e,t="|"){return e?e.toString().replaceAll(/[,,]/g,t):""}},101:function(e,t,i){"use strict";i.r(t);var a=i(102),s=i(99),n=i(100);const r=new class{constructor(){this.setTrace()}setTrace(e,t){t&&(t.log||t.info)&&t.error&&t.warn?(this.log=t.log||t.info,this.info=t.info||t.log,this.debug=t.debug||t.log,this.verbose=this._verbose,this.error=t.error,this.warn=t.warn):(this.verbose=this._verbose.bind(this),this.log=this._log.bind(this),this.info=this._info.bind(this),this.debug=this._debug.bind(this),this.error=this._error.bind(this),this.warn=this._warn.bind(this)),this.level=e||s.TRACE_LEVEL.INFO,this.level=this.level<s.TRACE_LEVEL.ERROR?s.TRACE_LEVEL.ERROR:this.level,this.level=this.level>s.TRACE_LEVEL.VERBOSE?s.TRACE_LEVEL.VERBOSE:this.level,this.getLevel=()=>this.level,this._trace=(e,t)=>{switch(e){case"log":console.log(...t);break;case"debug":console.debug(...t);break;case"info":console.info(...t);break;case"warn":console.warn(...t);break;case"error":console.error(...t)}}}getTracer(e){var t=this;return n.isDevelopment()?{log:function(){for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];return t.log(e,...a)},debug:function(){for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];return t.debug(e,...a)},info:function(){for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];return t.info(e,...a)},warn:function(){for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];return t.warn(e,...a)},error:function(){for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];return t.error(e,...a)}}:{log:()=>{},debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}}}setTelemetry(e){this._telemetry="function"==typeof e?e:null}monitorLog(e){e&&this._telemetry&&this._telemetry({type:a.eventOut.MONITOR,data:e})}directSendMonitorLog(e){e&&this._telemetry&&this._telemetry({type:a.eventOut.DIRECT_MONITOR,data:e})}globalTrace(e){e&&this._telemetry&&this._telemetry({type:a.eventOut.GLOBAL_TRACE,data:e})}_verbose(){if(this.level>=s.TRACE_LEVEL.VERBOSE){const e=[...arguments];return e.unshift("[VERBOSE]"),this._trace("log",e),!0}return!1}_debug(){return this.level>=s.TRACE_LEVEL.DEBUG&&(this._trace("debug",arguments),!0)}_log(){return this.level>=s.TRACE_LEVEL.INFO&&(this._trace("log",arguments),!0)}_info(){return this.level>=s.TRACE_LEVEL.INFO&&(this._trace("info",arguments),!0)}_warn(){return this.level>=s.TRACE_LEVEL.WARN&&(this._trace("warn",arguments),!0)}_error(){return this.level>=s.TRACE_LEVEL.ERROR&&(this._trace("error",arguments),!0)}};t.default=r},102:function(e,t,i){"use strict";var a,s;Object.defineProperty(t,"__esModule",{value:!0}),t.eventOut=t.eventExt=void 0,function(e){e.NOTIFY_SDK_JOIN_RWG_SUCCESS="NOTIFY_SDK_JOIN_RWG_SUCCESS",e.NOTIFY_SDK_JOIN_RWG_FAILURE="NOTIFY_SDK_JOIN_RWG_FAILURE",e.VIDEO_STREAMS="VIDEO_STREAMS",e.WMSC_MESSAGE_FROM_RWG="WMSC_MESSAGE_FROM_RWG",e.NOTIFY_WMSC_VIDEO_TAG_MAPPING="NOTIFY_WMSC_VIDEO_TAG_MAPPING",e.NOTIFY_SDK_SUBSCRIBE_VIDEO="NOTIFY_SDK_SUBSCRIBE_VIDEO",e.NOTIFY_SDK_UNSUBSCRIBE_VIDEO="NOTIFY_SDK_UNSUBSCRIBE_VIDEO",e.NOTIFY_SDK_ACTIVE_VIDEO_INDICATION="NOTIFY_SDK_ACTIVE_VIDEO_INDICATION",e.UPDATE_WMSC_PARAMS="UPDATE_WMSC_PARAMS"}(a||(t.eventExt=a={})),function(e){e.ERROR="ERROR",e.WMSC_MESSAGE_TO_RWG_BY_SDK="WMSC_MESSAGE_TO_RWG_BY_SDK",e.WMSC_MAPPING_STREAMID_AND_MID="WMSC_MAPPING_STREAMID_AND_MID",e.GLOBAL_TRACE="GLOBAL_TRACE",e.MONITOR="MONITOR",e.DIRECT_MONITOR="DIRECT_MONITOR",e.SDP_NEGOTIATION_FAIL="SDP_NEGOTIATION_FAIL",e.CREATE_VIDEO_STREAMS_SUCCESS="CREATE_VIDEO_STREAMS_SUCCESS",e.CREATE_VIDEO_STREAMS_FAIL="CREATE_VIDEO_STREAMS_FAIL",e.V_RECEV_PC_CONNECTED="V_RECEV_PC_CONNECTED",e.V_SEND_PC_CONNECTED="V_SEND_PC_CONNECTED",e.VIDEO_SOURCE_UPDATED="VIDEO_SOURCE_UPDATED",e.VIDEO_TAG_MAPPED="VIDEO_TAG_MAPPED",e.VIDEO_QOS_DATA="VIDEO_QOS_DATA",e.UPDATE_VIDEO_CAPTURE_CONSTRAINTS="UPDATE_VIDEO_CAPTURE_CONSTRAINTS",e.ERROR_MESSAGE="ERROR_MESSAGE",e.NETWORK_QUALITY_CHANGE="NETWORK_QUALITY_CHANGE"}(s||(t.eventOut=s={}))},104:function(e,t,i){"use strict";i.r(t),i.d(t,"BrowserInfo",(function(){return n}));var a=i(14),s=i.n(a);class n{constructor(){this.browser=void 0,this.browserVersion=void 0,this.os=void 0,this.osVersion=void 0,this.hardwareConcurrency=navigator.hardwareConcurrency||1,this.isMobile=this._isMobile(navigator.userAgent),this._getBrowserAndOSVersions(navigator.userAgent)}_getBrowserAndOSVersions(e){for(const[t,i]of Object.entries(n.regex)){const a=e.match(i);if(a)switch(t){case"iOS":this.os=t,this.osVersion=a[1].replace(/_/g,".");break;case"macOS":this.os=t;break;case"Windows":case"Android":case"ChromeOS":this.os=t,this.osVersion=a[1];break;case"Linux":e.match(n.regex.Android)||(this.os=t);break;case"SafariIOS":this.browser||(this.browser="Safari",this.browserVersion=a[1].split("/")[1]),this.os="iOS",this.osVersion=a[2];break;default:this.browser||(this.browser=t,this.browserVersion=a[1])}}}_isMobile(e){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e)}getMajorBrowserVersion(){var e;const t=parseInt(null===(e=this.browserVersion)||void 0===e?void 0:e.split(".")[0],10);return isNaN(t)?void 0:t}getMinorBrowserVersion(){var e;const t=parseInt(null===(e=this.browserVersion)||void 0===e?void 0:e.split(".")[1],10);return isNaN(t)?void 0:t}isBrowserVersionGreaterEqualThan(e,t){const i=this.getMajorBrowserVersion(),a=this.getMinorBrowserVersion();return i>e||i===e&&a>=t}getMajorOsVersion(){var e;const t=parseInt(null===(e=this.osVersion)||void 0===e?void 0:e.split(".")[0],10);return isNaN(t)?void 0:t}getMinorOsVersion(){var e;const t=parseInt(null===(e=this.osVersion)||void 0===e?void 0:e.split(".")[1],10);return isNaN(t)?void 0:t}isOsVersionGreaterEqualThan(e,t){const i=this.getMajorOsVersion(),a=this.getMinorOsVersion();return i>e||i===e&&a>=t}}s()(n,"regex",{Chrome:/(?:Chrome|Chromium|CriOS)\/([\d.]+)/,Firefox:/(?:Firefox|FxiOS)\/([\d.]+)/,Safari:/Version\/([\d.]+)\sSafari/,SafariIOS:/(Version\/[\d.]+).*Mobile\/([\w]+)/,IE:/MSIE\s([\d.]+)/,Edge:/Edg\/([\d.]+)/,Opera:/(?:Opera|OPR)\/([\d.]+)/,Android:/Android\s([\d.]+)/,iOS:/(?:iPhone|iPad|iPod).*OS\s([\d_]+)/,Windows:/Windows NT\s([\d.]+)/,macOS:/Mac OS X\s([\d_.]+)/,Linux:/Linux/,ChromeOS:/CrOS/}),t.default=new n},105:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLowResolution=t.getLayerIdByVideoFormat=t.getMaxBitrateByVideoFormat=t.getMinBitrate=t.getTargetBitrate=t.getMaxBitrate=t.getMaxFramerate=t.findVideoFormat=t.findVideoFormatIndex=t.getLowestVideoFormat=t.getHighestVideoFormat=t.getVideoFormatByIndex=t.getLayerSettings=t.getMinEncodingBitrate=t.getMaxEnabledLayerId=t.isLayerEnabled=t.getMinEnabledLayerId=t.getEnabledLayerIds=t.getLayersSettings=t.setDefaultLayersSettings=t.setEnabledLayerIds=t.setLayersSettings=void 0;const a=i(108),s=[{layerId:4,width:1920,height:1080,maxFramerate:30,minBitrate:3e6,targetBitrate:4e6,maxBitrate:5e6},{layerId:4,width:1600,height:900,maxFramerate:30,minBitrate:15e5,targetBitrate:3e6,maxBitrate:35e5},{layerId:3,width:1280,height:720,maxFramerate:30,minBitrate:8e5,targetBitrate:2e6,maxBitrate:2e6},{layerId:3,width:960,height:540,maxFramerate:30,minBitrate:5e5,targetBitrate:8e5,maxBitrate:12e5},{layerId:2,width:640,height:360,maxFramerate:30,minBitrate:25e4,targetBitrate:5e5,maxBitrate:7e5},{layerId:2,width:480,height:270,maxFramerate:30,minBitrate:18e4,targetBitrate:35e4,maxBitrate:45e4},{layerId:1,width:320,height:180,maxFramerate:30,minBitrate:1e5,targetBitrate:15e4,maxBitrate:2e5},{layerId:1,width:256,height:144,maxFramerate:30,minBitrate:6e4,targetBitrate:1e5,maxBitrate:15e4}];function n(e){a.wmscConfig.setLayersSettings(e)}function r(){return a.wmscConfig.layersSettings}function o(){return a.wmscConfig.enabledLayerIds}function c(e){const t=r();if(!t||t.length<=e)return;const{width:i,height:a,maxFramerate:s,minBitrate:n,targetBitrate:o,maxBitrate:c}=t[e];return{width:i,height:a,maxFramerate:s,minBitrate:n,targetBitrate:o,maxBitrate:c}}function d(e){const t=r();if(!t)return;const i=t.findIndex(t=>t.layerId===e);return i>=0?c(i):void 0}function l(e){const t=r();if(t)for(let i=t.length-1;i>=0;i--)if(t[i].layerId===e)return c(i)}function h(e,t,i=!0){const a=r();if(!(null==a?void 0:a.length))return-1;const s=o();if(i)for(let i=0;i<a.length;i++){const n=a[i];if(s.includes(n.layerId)&&n.layerId===e&&t>=n.minBitrate&&t<=n.maxBitrate)return i}else for(let i=a.length-1;i>=0;i++){const n=a[i];if(s.includes(n.layerId)&&n.layerId===e&&t>=n.minBitrate&&t<=n.maxBitrate)return i}return-1}function u(e){return e.width*e.height<57600}t.setLayersSettings=n,t.setEnabledLayerIds=function(e){a.wmscConfig.setEnabledLayerIds(e)},t.setDefaultLayersSettings=function(e){const t=e?s.filter(({width:e,height:t})=>!u({width:e,height:t})):s;t.length&&(t[t.length-1].minBitrate=8e4),n(t)},t.getLayersSettings=r,t.getEnabledLayerIds=o,t.getMinEnabledLayerId=function(){return o()[0]},t.isLayerEnabled=function(e){return o().includes(e)},t.getMaxEnabledLayerId=function(){const e=o();return e[e.length-1]},t.getMinEncodingBitrate=function(){return 8e4},t.getLayerSettings=function(e){var t;const i=[];return null===(t=r())||void 0===t||t.forEach(t=>{t.layerId===e&&i.push(t)}),i},t.getVideoFormatByIndex=c,t.getHighestVideoFormat=d,t.getLowestVideoFormat=l,t.findVideoFormatIndex=h,t.findVideoFormat=function(e,t,i=!0){const a=h(e,t,i);if(a>=0)return c(a)},t.getMaxFramerate=function(e){var t;return(null===(t=d(e))||void 0===t?void 0:t.maxFramerate)||0},t.getMaxBitrate=function(e){var t;return(null===(t=d(e))||void 0===t?void 0:t.maxBitrate)||0},t.getTargetBitrate=function(e){var t;return(null===(t=d(e))||void 0===t?void 0:t.targetBitrate)||0},t.getMinBitrate=function(e){var t;return(null===(t=l(e))||void 0===t?void 0:t.minBitrate)||0},t.getMaxBitrateByVideoFormat=function(e,t){const i=d(e);if(i){const{width:e,height:a,maxBitrate:s}=i;return Math.floor(t.width*t.height/(e*a)*s)}},t.getLayerIdByVideoFormat=function(e){const t=e.width*e.height;return t>921600?4:t>307200?3:t>76800?2:t>19200?1:t>0?0:-1},t.isLowResolution=u},108:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wmscConfig=void 0;t.wmscConfig=new class{constructor(){this.confId="",this.nodeId="",this.maxCaptureVideoSize=4,this.maxRecvVideoNum=26,this.hdVideoEnabled=!1,this.isMacIntel=!1,this.videoSettings=null,this._enabledLayerIds=[],this._layersSettings=null,this.iceServers=[]}setConfig(e){const{confId:t,nodeId:i,maxCaptureResolution:a,maxVideoReceiveNum:s,HDVideo:n,isMacIntel:r,videoSettings:o,qosOptions:c,iceServers:d}=e;void 0!==t&&(this.confId=t),void 0!==i&&(this.nodeId=i),void 0!==a&&(this.maxCaptureVideoSize=a),void 0!==s&&(this.maxRecvVideoNum=s),void 0!==n&&(this.hdVideoEnabled=n),void 0!==r&&(this.isMacIntel=r),void 0!==o&&(this.videoSettings=o),void 0!==c&&(this.qosOptions=c),null!=d&&(this.iceServers=d||[])}getConfig(){const{confId:e,nodeId:t,maxRecvVideoNum:i,hdVideoEnabled:a,isMacIntel:s,videoSettings:n,qosOptions:r,iceServers:o}=this;return{confId:e,nodeId:t,maxRecvVideoNum:i,hdVideoEnabled:a,isMacIntel:s,videoSettings:n,qosOptions:r,iceServers:o}}setEnabledLayerIds(e){this._enabledLayerIds=e}get enabledLayerIds(){return this._enabledLayerIds}setLayersSettings(e){this._layersSettings=e}get layersSettings(){return this._layersSettings}}},112:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eventOut=t.eventExt=t.Wmsc=void 0;var a=i(121);Object.defineProperty(t,"Wmsc",{enumerable:!0,get:function(){return a.Wmsc}});var s=i(102);Object.defineProperty(t,"eventExt",{enumerable:!0,get:function(){return s.eventExt}}),Object.defineProperty(t,"eventOut",{enumerable:!0,get:function(){return s.eventOut}})},113:function(e,t,i){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,i,a){void 0===a&&(a=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,a,s)}:function(e,t,i,a){void 0===a&&(a=i),e[a]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return s(t,e),t},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WmscMidMgr=void 0;const o=r(i(101)),c=n(i(99)),d=r(i(104)),l=o.default.getTracer("WmscMidMgr"),h=e=>{l.log(e),o.default.monitorLog(""+e)};t.WmscMidMgr=class{constructor(e){this.mIdUsedStatus={},null==e||e.forEach(e=>{this.mIdUsedStatus[e]={userId:0,group:null,used:!1,videoStream:null,videoSize:-1,released:!0}}),this.user2VideoDom=new Map,this.hasPausedVideo=!1,this.activeSpeakerMId=c.DEFAULT_ACTIVE_SPEAKER_MID,this.userId2mId=new Map,this.userId2mId.set(1,"0"),this.hwDecoderLimit=c.MAX_RECV_MLINE_NUM+1}getNewMId(e,t=null){let i=this.userId2mId.get(e);if(void 0===i){let e="",t="";for(const a in this.mIdUsedStatus){const{used:s,released:n,preUserId:r}=this.mIdUsedStatus[a];if("0"!==a){if(!s){if(!r){i=a;break}n&&!e?e=a:t||(t=a)}if(parseInt(a,10)===this.hwDecoderLimit-1&&(e||t))break}}i||(i=e||t)}return i&&!this.mIdUsedStatus[i].used&&this._assignMid(i,e,t),i}_assignMid(e,t,i=null){this.mIdUsedStatus[e].userId=t,this.mIdUsedStatus[e].group=i,this.mIdUsedStatus[e].used=!0,t===c.ACTIVE_SPEAKER_ID&&(this.activeSpeakerMId=e);const{preUserId:a}=this.mIdUsedStatus[e];return a&&this.userId2mId.delete(a),this.userId2mId.set(t,e),e}releaseMId(e){const t=this.mIdUsedStatus[e];t&&(t.group=null,t.preUserId=t.userId,t.userId=0,t.used=!1,t.videoSize=-1)}getMId(e,t=null){const i=this.userId2mId.get(e);return void 0===i||this.mIdUsedStatus[i].userId!==e||this.mIdUsedStatus[i].group!==t?"":i}getUserId(e){return{userId:this.mIdUsedStatus[e].userId,group:this.mIdUsedStatus[e].group}}getVideoTags(e){const t=this.mIdUsedStatus[e].userId;if(t)return this.user2VideoDom.get(t)}saveVideoTag(e,t){const i=this.user2VideoDom.get(e)||[];i.push(t),this.user2VideoDom.set(e,i);for(const i in this.mIdUsedStatus)if(this.mIdUsedStatus[i].userId===e){this._setVideoTagStream(t,this.mIdUsedStatus[i].videoStream,e);break}}removeVideoTag(e,t){const i=this.user2VideoDom.get(e);if(i){for(let e=0;e<i.length;)i[e]===t?i.splice(e,1):e++;i.length||this.user2VideoDom.delete(e)}}updateUserId(e,t){const i=this.mIdUsedStatus[e];i&&(i.userId=t)}_setVideoTagStream(e,t,i){(!e.srcObject||e.srcObject&&t&&e.srcObject!==t)&&(e.srcObject=t,e.onpause=()=>{h(`WMSC_V_Tag_Pause: ${i}|${document.hidden}|${document.visibilityState}`),this.hasPausedVideo=!0})}updateVideoElement(e){if(this.mIdUsedStatus[e]){const t=this.mIdUsedStatus[e].userId,i=this.mIdUsedStatus[e].videoStream;(this.user2VideoDom.get(t)||[]).forEach(e=>{this._setVideoTagStream(e,i,t)})}}updateStream(e,t){this.mIdUsedStatus[e]&&(this.mIdUsedStatus[e].videoStream=t)}setVideoSize(e,t){this.mIdUsedStatus[e].videoSize=t}getVideoSizeByUserId(e){const t=this.userId2mId.get(e);return t?this.mIdUsedStatus[t].videoSize:-1}getUserIdByElem(e){let t=-1;return this.user2VideoDom.forEach((i,a)=>{for(let s=0;s<i.length;s++)if(e===i[s]){t=a;break}}),t}getHasPausedVideo(){return this.hasPausedVideo||Array.from(this.user2VideoDom.values()).flat().some(e=>e.paused)}playAllUsedVideoTag(){const e=Array.from(this.user2VideoDom.values()).flat().map(e=>{var t;if("visible"===document.visibilityState&&e.paused){const i=(null===(t=null==e?void 0:e.srcObject)||void 0===t?void 0:t.active)||!1;if(!(null==e?void 0:e.srcObject)||!i){const t=this.getUserIdByElem(e);return h(`WMSC_V_Tag_C_P: ${t}|${!!(null==e?void 0:e.srcObject)}|${i}`),Promise.reject(t)}return e.play().then(()=>Promise.resolve()).catch(t=>{const i=this.getUserIdByElem(e);return Promise.reject(`${i}|errorName:${null==t?void 0:t.name}|errorMessage:${null==t?void 0:t.message}`)})}return null}).filter(e=>!!e);return e.length<=0?Promise.resolve():Promise.all(e).then(()=>(this.hasPausedVideo=!1,Promise.resolve())).catch(e=>(this.hasPausedVideo=!0,Promise.reject(e)))}setMidReleasedStatus(e,t){this.mIdUsedStatus[e]&&(this.mIdUsedStatus[e].released=t)}getMidReleasedStatus(e){var t;return null===(t=this.mIdUsedStatus[e])||void 0===t?void 0:t.released}changeHWDecodeLimit(e){if(e===c.H264_HIGH_PROFILE&&("Edge"===d.default.browser||"Chrome"===d.default.browser)){if("macOS"===d.default.os||"Windows"===d.default.os)return void(this.hwDecoderLimit=8);if("ChromeOS"===d.default.os)return void(this.hwDecoderLimit=16)}this.hwDecoderLimit=c.MAX_RECV_MLINE_NUM+1}}},114:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this.status="pending",this.promise=new Promise((e,t)=>{this.reject=e=>(this.status="rejected",t(e)),this.resolve=t=>(this.status="fullfilled",e(t))}),this.then=this.promise.then,this.catch=this.promise.catch}}},121:function(e,t,i){"use strict";i.r(t);var a=i(108),s=i(101),n=i(99);class r{static splitSections(e){return e.split("\r\nm=").map((e,t)=>t>0?"m="+e:e)}static splitLines(e){return e.split("\r\n")}static parseVersionLine(e){return parseInt(e.substring(2),10)}static writeVersionLine(e){return"v=".concat(e)}static parseOriginLine(e){const[t,i,a,s,n,r]=e.substring(2).split(" ");return{userName:t,sessionId:i,sessionVersion:parseInt(a,10),netType:s,addressType:n,address:r}}static writeOriginLine(e){const{userName:t,sessionId:i,sessionVersion:a,netType:s,addressType:n,address:r}=e;return"o=".concat(t," ").concat(i," ").concat(a," ").concat(s," ").concat(n," ").concat(r)}static parseSessionNameLine(e){return e.substring(2)}static writeSessionNameLine(e){return"s=".concat(e)}static parseInformationLine(e){return e.substring(2)}static writeInformationLine(e){return"i=".concat(e)}static parseConnectionLine(e){const[t,i,a]=e.substring(2).split(" ");return{netType:t,addressType:i,address:a}}static writeConnectionLine(e){const{netType:t,addressType:i,address:a}=e;return"c=".concat(t," ").concat(i," ").concat(a)}static parseBandwidthLine(e){return parseInt(e.substring(7),10)}static writeBandwidthLine(e){return"b=TIAS:".concat(e)}static parseTimingLine(e){const[t,i]=e.substring(2).split(" ");return{startTime:parseInt(t,10),stopTime:parseInt(i,10)}}static writeTimingLine(e){const{startTime:t,stopTime:i}=e;return"t=".concat(t," ").concat(i)}static parseRtpMapLine(e){const t=e.substring(9).match(/^(\d+) (.*)/),i=t[2].split("/");return{payloadType:parseInt(t[1],10),codecName:i[0],clockRate:parseInt(i[1],10),channels:i.length>=3?parseInt(i[2],10):null}}static writeRtpMapLine(e){const{payloadType:t,codecName:i,clockRate:a,channels:s}=e;let n="a=rtpmap:".concat(t," ").concat(i,"/").concat(a);return null!=s&&(n+="/"+s),n}static parseFmtpLine(e){const t=e.substring(7).match(/^(\d+) (.*)/),i={payloadType:parseInt(t[1],10)};return t[2].includes("=")?i.params=new Map(t[2].split(";").map(e=>e.trim().split("="))):i.plain=t[2],i}static writeFmtpLine(e){const{payloadType:t,params:i,plain:a}=e;let s="a=fmtp:".concat(t," ");return i?(i.forEach((e,t)=>{null!=e&&(s+="".concat(t,"=").concat(e,";"))}),s=s.slice(0,-1)):s+=a,s}static parseRtcpFbLine(e){const t=e.substring(10).match(/^(\d+) (.*)/);return{payloadType:parseInt(t[1],10),params:t[2].split(" ")}}static writeRtcpFbLine(e){const{payloadType:t,params:i}=e;let a="a=rtcp-fb:".concat(t);return i.forEach(e=>{a+=" "+e}),a}static parseRidLine(e){const t=e.substring(6).match(/^(\S+) (send|recv)/);return{rid:t[1],direction:t[2]}}static writeRidLine(e){const{rid:t,direction:i}=e;return"a=rid:".concat(t," ").concat(i)}static parseSimulcastLine(e){const t=e.substring(12).match(/^(send|recv) (.*)/);return{direction:t[1],rids:t[2].split(";").map(e=>"~"===e[0]?{id:e.substring(1),paused:!0}:{id:e,paused:!1})}}static writeSimulcastLine(e){const{direction:t,rids:i}=e;let a="a=simulcast:".concat(t," ");return i.forEach(e=>{const t=e.paused?"~"+e.id:e.id;a+=t+";"}),a.slice(0,-1)}static parseExtensionMapLine(e){const t=e.substring(9).match(/^(\d+)(\/sendrecv|\/sendonly|\/recvonly|\/inactive)? (\S+)(\s\S+)?/);return{id:parseInt(t[1],10),direction:t[2]?t[2].substring(1):null,uri:t[3],attributes:t[4]?t[4].trimStart():null}}static writeExtensionMapLine(e){const{id:t,direction:i,uri:a,attributes:s}=e;let n="a=extmap:".concat(t);return null!=i&&(n+="/"+i),n+=" "+a,null!=s&&(n+=" "+s),n}static parseMidLine(e){return e.substring(6)}static writeMidLine(e){return"a=mid:".concat(e)}static writeDirectionLine(e){return"a=".concat(e)}static parseMsidLine(e){const[t,i]=e.substring(7).split(" ");return{streamId:t,trackId:i}}static writeMsidLine(e){const{streamId:t,trackId:i}=e;return"a=msid:".concat(t," ").concat(i)}static parseSsrcLine(e){const t=e.indexOf(" ");return{ssrc:parseInt(e.substring(7,t),10),attribute:e.substring(t+1)}}static writeSsrcLine(e){const{ssrc:t,attribute:i}=e;return"a=ssrc:".concat(t," ").concat(i)}static parseSsrcGroupLine(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t}}static writeSsrcGroupLine(e){const{semantics:t,ssrcs:i}=e;let a="a=ssrc-group:".concat(t);return i.forEach(e=>{a+=" "+e}),a}static parseGroupLine(e){const t=e.indexOf(" ");return{semantics:e.substring(8,t),ids:e.substring(t+1).split(" ")}}static writeGroupLine(e){const{semantics:t,ids:i}=e;let a="a=group:".concat(t);return i.forEach(e=>{a+=" "+e}),a}static writeExtMapAllowMixedLine(){return"a=extmap-allow-mixed"}static writeRtcpMuxLine(){return"a=rtcp-mux"}static writeRtcpReducedSizeLine(){return"a=rtcp-rsize"}static parseCandidateLine(e){const t=e.substring(12).split(" "),i={foundation:t[0],componentId:parseInt(t[1],10),transport:t[2],priority:parseInt(t[3],10),address:t[4],port:parseInt(t[5],10),candType:t[6],type:t[7],relAddress:null,relPort:null,candExtensions:[]};return"raddr"===t[8]&&"rport"===t[10]?(i.relAddress=t[9],i.relPort=parseInt(t[11],10),i.candExtensions=t.slice(12)):i.candExtensions=t.slice(8),i}static writeCandidateLine(e){const{foundation:t,componentId:i,transport:a,priority:s,address:n,port:r,candType:o,type:c,relAddress:d,relPort:l,candExtensions:h}=e;let u="a=candidate:".concat(t," ").concat(i," ").concat(a," ").concat(s)+" ".concat(n," ").concat(r," ").concat(o," ").concat(c);return null!=d&&null!=l&&(u+=" raddr ".concat(d," rport ").concat(l)),h.length&&(u+=" "+h.join(" ")),u}static parseSessionSection(e){const t={version:0,origin:null,sessionName:null,information:null,connection:null,bandwidth:null,timing:null,groups:[],extMapAllowMixed:null,otherLines:[]},i=this.splitLines(e);for(let e=0;e<i.length;e++){const a=i[e];a.length&&(a.match(/^v=/)?t.version=this.parseVersionLine(a):a.match(/^o=/)?t.origin=this.parseOriginLine(a):a.match(/^s=/)?t.sessionName=this.parseSessionNameLine(a):a.match(/^i=/)?t.information=this.parseInformationLine(a):a.match(/^c=/)?t.connection=this.parseConnectionLine(a):a.match(/^b=TIAS:/)?t.bandwidth=this.parseBandwidthLine(a):a.match(/^t=/)?t.timing=this.parseTimingLine(a):a.match(/^a=group:/)?t.groups.push(this.parseGroupLine(a)):a.match(/^a=extmap-allow-mixed$/)?t.extMapAllowMixed=!0:t.otherLines.push(a))}return t}static writeSessionSection(e){const t=[];return t.push(this.writeVersionLine(e.version)),null!=e.origin&&t.push(this.writeOriginLine(e.origin)),null!=e.sessionName&&t.push(this.writeSessionNameLine(e.sessionName)),null!=e.information&&t.push(this.writeInformationLine(e.information)),null!=e.connection&&t.push(this.writeConnectionLine(e.connection)),null!=e.bandwidth&&t.push(this.writeBandwidthLine(e.bandwidth)),null!=e.timing&&t.push(this.writeTimingLine(e.timing)),e.groups.forEach(e=>{t.push(this.writeGroupLine(e))}),e.extMapAllowMixed&&t.push(this.writeExtMapAllowMixedLine()),e.otherLines.length&&t.push(...e.otherLines),t.join("\r\n")+"\r\n"}static parseMediaSection(e){const t={type:null,port:null,protocol:null,connection:null,bandwidth:null,mid:null,direction:null,msid:null,rtcpMux:null,rtcpReducedSize:null,codecs:[],extensionMap:new Map,rids:[],simulcast:null,ssrcs:[],ssrcGroups:[],candidates:[],otherLines:[]},i=[],a=[],s=this.splitLines(e),n=s[0].split(" ");t.type=n[0].substring(2),t.port=parseInt(n[1],10),t.protocol=n[2],t.payloadTypes=n.slice(3).map(e=>parseInt(e,10));for(let e=1;e<s.length;e++){let n;const r=s[e];if(r.length)if(r.match(/^c=/))t.connection=this.parseConnectionLine(r);else if(r.match(/^b=TIAS:/))t.bandwidth=this.parseBandwidthLine(r);else if(r.match(/^a=rtpmap:/)){const e=this.parseRtpMapLine(r);t.codecs.push({...e,codecParams:new Map,fmtpLines:[],rtcpFbParams:[]})}else if(r.match(/^a=fmtp:/))i.push(r);else if(r.match(/^a=rtcp-fb:/))a.push(r);else if(r.match(/^a=rid:/))t.rids.push(this.parseRidLine(r));else if(r.match(/^a=simulcast:/))t.simulcast=this.parseSimulcastLine(r);else if(r.match(/^a=ssrc:/))t.ssrcs.push(this.parseSsrcLine(r));else if(r.match(/^a=ssrc-group:/))t.ssrcGroups.push(this.parseSsrcGroupLine(r));else if(r.match(/^a=extmap:/)){const e=this.parseExtensionMapLine(r);t.extensionMap.set(e.id,e)}else r.match(/^a=mid:/)?t.mid=this.parseMidLine(r):(n=r.match(/^a=(sendrecv|sendonly|recvonly|inactive)/))?t.direction=n[1]:r.match(/^a=msid:/)?t.msid=this.parseMsidLine(r):r.match(/^a=rtcp-mux$/)?t.rtcpMux=!0:r.match(/^a=rtcp-rsize$/)?t.rtcpReducedSize=!0:r.match(/^a=candidate:/)?t.candidates.push(this.parseCandidateLine(r)):t.otherLines.push(r)}return i.forEach(e=>{const i=this.parseFmtpLine(e),a=t.codecs.find(e=>e.payloadType===i.payloadType);a&&(i.params?i.params.forEach((e,t)=>{"apt"===t&&(a.associatedPayloadType=parseInt(e,10)),a.codecParams.set(t,e)}):(a.fmtpLines.push(i.plain),"red"===a.codecName&&(a.associatedPayloadType=parseInt(i.plain.split("/")[0],10))))}),a.forEach(e=>{const i=this.parseRtcpFbLine(e),a=t.codecs.find(e=>e.payloadType===i.payloadType);a&&a.rtcpFbParams.push(i.params)}),t}static writeMediaSection(e){const t=[];let i="m=".concat(e.type," ").concat(e.port," ").concat(e.protocol);return e.payloadTypes.forEach(e=>{i+=" "+e}),t.push(i),e.connection&&t.push(this.writeConnectionLine(e.connection)),e.bandwidth&&t.push(this.writeBandwidthLine(e.bandwidth)),e.otherLines.length&&t.push(...e.otherLines),t.push(this.writeMidLine(e.mid)),e.extensionMap.size&&e.extensionMap.forEach((e,i)=>{t.push(this.writeExtensionMapLine(e))}),t.push(this.writeDirectionLine(e.direction)),e.msid&&t.push(this.writeMsidLine(e.msid)),e.rtcpMux&&t.push(this.writeRtcpMuxLine()),e.rtcpReducedSize&&t.push(this.writeRtcpReducedSizeLine()),e.codecs.forEach(e=>{const{payloadType:i,codecName:a,clockRate:s,channels:n,codecParams:r,fmtpLines:o,rtcpFbParams:c}=e;t.push(this.writeRtpMapLine({payloadType:i,codecName:a,clockRate:s,channels:n})),c.forEach(e=>{t.push(this.writeRtcpFbLine({payloadType:i,params:e}))}),r.size&&t.push(this.writeFmtpLine({payloadType:i,params:r})),o.forEach(e=>{t.push(this.writeFmtpLine({payloadType:i,plain:e}))})}),e.ssrcGroups.forEach(e=>{t.push(this.writeSsrcGroupLine(e))}),e.ssrcs.forEach(e=>{t.push(this.writeSsrcLine(e))}),e.rids.forEach(e=>{t.push(this.writeRidLine(e))}),e.candidates.forEach(e=>{t.push(this.writeCandidateLine(e))}),e.simulcast&&t.push(this.writeSimulcastLine(e.simulcast)),t.join("\r\n")+"\r\n"}static parse(e){const t={session:null,media:[],application:[]},i=this.splitSections(e);return t.session=this.parseSessionSection(i.shift()),i.forEach(e=>{const i=this.parseMediaSection(e);"audio"!==i.type&&"video"!==i.type||t.media.push(i),"application"===i.type&&t.application.push(i)}),t}static write(e){let t=this.writeSessionSection(e.session);return e.media.forEach(e=>{t+=this.writeMediaSection(e)}),e.application.forEach(e=>{t+=this.writeMediaSection(e)}),t}}var o=i(104);class c{static parseSdp(e){return r.parse(e)}static writeSdp(e){return r.write(e)}static generateSsrc(){return Math.floor(4294967294*Math.random())+1}static generateId(){return Math.random().toString(36).substring(2,12)}static generateSessionId(){return Math.random().toString().substring(2,22)}static generateUuid(){const e=Array.from(Array(256).keys()).map(e=>e.toString(16).padStart(2,"0")),t=crypto.getRandomValues(new Uint8Array(16));t[6]=15&t[6]|64,t[8]=63&t[8]|128;return Array.from(t.entries()).map(t=>{let[i,a]=t;return[4,6,8,10].includes(i)?"-".concat(e[a]):e[a]}).join("")}static getSessionBoilerplate(){return"v=\r\no=- ".concat(this.generateSessionId()," 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n")}static getNtpSeconds(){return Math.floor((Date.now()+(Date.UTC(1970,0,1)-Date.UTC(1900,0,1)))/1e3)}static findHeaderExtensionByUri(e,t){for(const[i,a]of e.extensionMap)if(a.uri===t)return i;return-1}static addHeaderExtension(e,t){if(-1!==this.findHeaderExtensionByUri(e,t.uri))return!1;let i=0;e.extensionMap.forEach((e,t)=>{t>i&&(i=t)});const a=i+1;return e.extensionMap.set(a,{id:a,...t}),!0}static removeHeaderExtensionByUri(e,t){let i=!1;return e.extensionMap.forEach((e,a,s)=>{e.uri===t&&(s.delete(a),i=!0)}),i}static removeMidRidHeaderExtensions(e){e.extensionMap.forEach((e,t,i)=>{/^urn:ietf:params:rtp-hdrext:sdes:(?:mid|rtp-stream-id|repaired-rtp-stream-id)$/.test(e.uri)&&i.delete(t)})}static updateCodecParameters(e,t,i,a,s){e.media.filter(e=>e.type===t&&e.direction===i).forEach(e=>{e.codecs.filter(e=>e.codecName===a).forEach(e=>{s.forEach((t,i)=>{e.codecParams.set(i,t)})})})}static filterCodecs(e,t){e.media.forEach(e=>{const i=[];e.codecs.forEach(e=>{t.includes(e.codecName)&&i.push(e.payloadType)}),e.codecs.forEach(e=>{i.includes(e.associatedPayloadType)&&i.push(e.payloadType)}),e.payloadTypes=e.payloadTypes.filter(e=>i.includes(e)),e.codecs=e.codecs.filter(e=>i.includes(e.payloadType))}),e.media=e.media.filter(e=>e.payloadTypes.length)}static filterH264Profiles(e,t,i){e.media.filter(e=>e.direction===t).forEach(e=>{const t=[];e.codecs.filter(e=>"H264"===e.codecName).forEach(e=>{var a;const s=parseInt(null===(a=e.codecParams.get("profile-level-id"))||void 0===a?void 0:a.substring(0,2),16);i.includes(s)&&t.push(e.payloadType)}),e.codecs.forEach(e=>{t.includes(e.associatedPayloadType)&&t.push(e.payloadType)}),e.payloadTypes=e.payloadTypes.filter(e=>t.includes(e)),e.codecs=e.codecs.filter(e=>t.includes(e.payloadType))})}static getH264ProfileIds(e,t,i){const a=new Set,s=e.media.find(e=>"video"===e.type&&e.direction===t);return null==s||s.codecs.forEach(e=>{if("H264"===e.codecName&&(void 0===i||parseInt(e.codecParams.get("packetization-mode"))===i)){var t;const i=parseInt(null===(t=e.codecParams.get("profile-level-id"))||void 0===t?void 0:t.substring(0,2),16);i&&a.add(i)}}),Array.from(a.values())}static mungeEgressLocalOffer(e,t){c.filterCodecs(e,["H264"]);const i=e.media.find(e=>"video"===e.type&&"sendonly"===e.direction);if(!i)throw new Error("Failed to find a video media section for send");if(t>1){i.rids=[],i.simulcast=null,i.ssrcs=[],i.ssrcGroups=[];const e=i.codecs.some(e=>"rtx"===e.codecName),a=[],s=c.generateUuid(),n="- ".concat(c.generateUuid());for(let r=0;r<t;r++){const t=c.generateSsrc();if(a.push(t),i.ssrcs.push({ssrc:t,attribute:"cname:"+s}),i.ssrcs.push({ssrc:t,attribute:"msid:"+n}),e){const e=c.generateSsrc();i.ssrcs.push({ssrc:e,attribute:"cname:"+s}),i.ssrcs.push({ssrc:e,attribute:"msid:"+n}),i.ssrcGroups.push({semantics:"FID",ssrcs:[t,e]})}}i.ssrcGroups.push({semantics:"SIM",ssrcs:a})}c.removeMidRidHeaderExtensions(i),"iOS"===o.default.os&&15===o.default.getMajorOsVersion()&&1===o.default.getMinorOsVersion()||c.removeHeaderExtensionByUri(i,"urn:3gpp:video-orientation"),c.addHeaderExtension(i,{uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time"}),t>1&&(e.session.extMapAllowMixed=!0,c.addHeaderExtension(i,{uri:"http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00"}))}static mungeEgressOfferToRemote(e){e.session.timing={startTime:c.getNtpSeconds(),stopTime:0}}static mungeEgressAnswer(e,t){t&&c.updateCodecParameters(e,"video","recvonly","H264",t)}static mungeIngressLocalOffer(e,t){c.filterCodecs(e,["H264","flexfec-03"]),t&&c.updateCodecParameters(e,"video","recvonly","H264",t)}}var d=i(105),l=i(14),h=i.n(l);class u{constructor(e){this._array=new Array(e),this._size=e,this._index=0,this._count=0}get size(){return this._size}get count(){return this._count}empty(){return 0===this._count}full(){return this._count===this._size}clear(){this._array=new Array(this._size),this._index=0,this._count=0}fill(e){return this._array.fill(e),this._index=0,this._count=this._size,this}get lastIndex(){return 0===this._index?this._size-1:this._index-1}nextIndex(e){return(e+1)%this._size}push(e){this._array[this._index]=e,this._index=this.nextIndex(this._index),this._count<this._size&&this._count++}pop(){if(this.empty())return;const e=this.lastIndex;return this._index=e,this._size>0&&this._size--,this._array[e]}at(e){if(!(this._count<this._size&&e>=this._count))return this._array[e]}front(){if(!this.empty())return this._array[this._count<this.size?0:this._index]}back(){if(!this.empty())return this._array[this.lastIndex]}unwrap(){return this._count<this._size?this._array.slice(0,this._count):[...this._array.slice(this._index),...this._array.slice(0,this._index)]}findIndex(e){if(this._count<this._size){for(let t=0;t<this._count;t++)if(e(this._array[t]))return t}else{for(let t=this._index;t<this._size;t++)if(e(this._array[t]))return t;for(let t=0;t<this._index;t++)if(e(this._array[t]))return t}return-1}findLastIndex(e){if(this._count<this._size){for(let t=this._count-1;t>=0;t--)if(e(this._array[t]))return t}else{for(let t=this._size-1;t>=this._index;t--)if(e(this._array[t]))return t;for(let t=this._index-1;t>=0;t--)if(e(this._array[t]))return t}return-1}find(e){const t=this.findIndex(e);return-1===t?void 0:this._array[t]}findLast(e){const t=this.findLastIndex(e);return-1===t?void 0:this._array[t]}}var m=i(100);s.default.getTracer("WmscStats");class S{constructor(){this.sendStatsMonitor=new g({cacheSize:S.sendStatsCacheSize}),this.recvStatsMonitor=new p({cacheSize:S.recvStatsCacheSize}),this.sendUsageStatsEnabled=!1,this.recvUsageStatsEnabled=!1,this.resourceUsageStatsReportTimestamp=0,this.resourceUsageStatsIntervalId=null,this.outgoingBitrateStatsCallback=null,this.resourceUsageStatsCallback=null}getSendStatsMonitor(){return this.sendStatsMonitor}getRecvStatsMonitor(){return this.recvStatsMonitor}setOptions(e){const{sendUsageStatsEnabled:t,recvUsageStatsEnabled:i}=e||{};void 0!==t&&(this.sendUsageStatsEnabled=t),void 0!==i&&(this.recvUsageStatsEnabled=i)}start(e){e&&this.setOptions(e),this.sendUsageStatsEnabled&&this.sendStatsMonitor.setOptions({outboundRtpStatsEnabled:!0}),this.sendStatsMonitor.start(),this.recvUsageStatsEnabled&&this.recvStatsMonitor.setOptions({inboundRtpStatsEnabled:!0}),this.recvStatsMonitor.start(),(this.sendUsageStatsEnabled||this.recvUsageStatsEnabled)&&(this.resourceUsageStatsIntervalId=setInterval(()=>{this._reportResourceUsageStats()},S.resourceUsageCheckInterval))}stop(){this.sendStatsMonitor.stop(),this.recvStatsMonitor.stop(),clearInterval(this.resourceUsageStatsIntervalId),this.resourceUsageStatsIntervalId=null}reset(){this.sendStatsMonitor.reset(),this.recvStatsMonitor.reset(),this.resourceUsageStatsReportTimestamp=0}registerOutgoingBitrateStatsCallback(e){this.sendStatsMonitor.outgoingBitrateStatsCallback=e}registerResourceUsageStatsCallback(e){this.resourceUsageStatsCallback=e}_reportResourceUsageStats(){const e={};let t=0;if(this.sendUsageStatsEnabled){const i=this._getSendResourceUsageStats();i&&(e.send={...i},t=Math.max(t,i.timestamp))}if(this.recvUsageStatsEnabled){const i=this._getRecvResourceUsageStats();i&&(e.recv={...i},t=Math.max(t,i.timestamp))}this.resourceUsageStatsReportTimestamp=t,this.resourceUsageStatsCallback(e)}_getSendResourceUsageStats(){if(!this.sendStatsMonitor.isStarted())return;const e=this.sendStatsMonitor.getOutboundRtpStats(),t=1e3/d.getVideoFormatByIndex(0).maxFramerate;let i=0,a=0,s=0,r=n.RESOURCE_USAGE_STATE.NONE;for(const[o,c]of e){const e=c.back(),o=Math.max(this.resourceUsageStatsReportTimestamp-500,e.timestamp-S.resourceUsageCheckInterval-500),d=c.find(e=>e.timestamp>o);if(!d)continue;const l=e.framesEncoded-d.framesEncoded,h=e.timestamp-d.timestamp;if(0===l||h<S.resourceUsageMinTimeSlice)continue;const u=e.framesSent-d.framesSent,g=l?1e3*(e.totalEncodeTime-d.totalEncodeTime)/l:0;let p,_,E=n.RESOURCE_USAGE_STATE.NONE,v=n.RESOURCE_USAGE_STATE.NONE,f=n.RESOURCE_USAGE_STATE.NONE;if(v=l>u||l>=S.encodeTimeMinFrameCount&&g>=t*S.encodeTimeFactorThresholdCritical?n.RESOURCE_USAGE_STATE.OVERUSING:l<=u&&l>=S.encodeTimeMinFrameCount&&g<t*S.encodeTimeFactorThresholdNormal?n.RESOURCE_USAGE_STATE.UNDERUSING:n.RESOURCE_USAGE_STATE.NORMAL,e.qualityLimitationDurations&&(p=1e3*(e.qualityLimitationDurations.cpu-d.qualityLimitationDurations.cpu)/h,_=1e3*(e.qualityLimitationDurations.other-d.qualityLimitationDurations.other)/h,f=p>=S.qualityLimitationRatioThresholdCritical||_>=S.qualityLimitationRatioThresholdCritical?n.RESOURCE_USAGE_STATE.OVERUSING:p<S.qualityLimitationRatioThresholdNormal&&_<S.qualityLimitationRatioThresholdNormal?n.RESOURCE_USAGE_STATE.UNDERUSING:n.RESOURCE_USAGE_STATE.NORMAL),E=v,m.compareResourceUsageState(f,E)>0&&(E=f),i+=l,a+=u,s=Math.max(s,e.timestamp),m.compareResourceUsageState(E,r)>0&&(r=E),r===n.RESOURCE_USAGE_STATE.OVERUSING)break}return{usageState:r,framesEncoded:i,framesSent:a,timestamp:s}}_getRecvResourceUsageStats(){if(!this.recvStatsMonitor.isStarted())return;const e=this.recvStatsMonitor.getInboundRtpStats();let t=0,i=0,a=0,s=0,r=n.RESOURCE_USAGE_STATE.NONE;for(const[o,c]of e){const e=c.back(),o=Math.max(this.resourceUsageStatsReportTimestamp-500,e.timestamp-S.resourceUsageCheckInterval-500),d=c.find(e=>e.timestamp>o);if(!d)continue;const l=e.timestamp-d.timestamp,h=e.framesReceived-d.framesReceived;if(0===h||l<S.resourceUsageMinTimeSlice)continue;const u=e.framesDropped-d.framesDropped,g=e.framesDecoded-d.framesDecoded,p=l/h,_=g?1e3*(e.totalDecodeTime-d.totalDecodeTime)/g:0;let E=n.RESOURCE_USAGE_STATE.NONE;if(t+=h,i+=u,a+=g,s=Math.max(s,e.timestamp),E=g>=S.decodeTimeMinFrameCount&&_>=p*S.decodeTimeFactorThresholdCritical?n.RESOURCE_USAGE_STATE.OVERUSING:g>=S.decodeTimeMinFrameCount&&_<p*S.decodeTimeFactorThresholdNormal?n.RESOURCE_USAGE_STATE.UNDERUSING:n.RESOURCE_USAGE_STATE.NORMAL,m.compareResourceUsageState(E,r)>0&&(r=E),r===n.RESOURCE_USAGE_STATE.OVERUSING)break}return{usageState:r,framesReceived:t,framesDropped:i,framesDecoded:a,timestamp:s}}}h()(S,"sendStatsCacheSize",6),h()(S,"recvStatsCacheSize",6),h()(S,"resourceUsageMinTimeSlice",4500),h()(S,"resourceUsageCheckInterval",5e3),h()(S,"encodeTimeMinFrameCount",20),h()(S,"encodeTimeFactorThresholdNormal",.9),h()(S,"encodeTimeFactorThresholdCritical",1.1),h()(S,"qualityLimitationRatioThresholdNormal",.05),h()(S,"qualityLimitationRatioThresholdCritical",.95),h()(S,"decodeTimeMinFrameCount",20),h()(S,"decodeTimeFactorThresholdNormal",.9),h()(S,"decodeTimeFactorThresholdCritical",1.1);class g{constructor(e){this.cacheSize=e.cacheSize||10,this.started=!1,this.selectedCandidatePairId=null,this.roundTripTime=0,this.remoteCandidateId=null,this.networkProtocol=null,this.localCandidateId=null,this.candidateType=null,this.outboundRtpStatsEnabled=!1,this.outboundRtpStatsMap=new Map}reset(){this.resetCandidateStats(),this.resetOutboundRtpStats()}resetCandidateStats(){this.selectedCandidatePairId=null,this.roundTripTime=0,this.remoteCandidateId=null,this.networkProtocol=null}resetOutboundRtpStats(){this.outboundRtpStatsMap.clear()}setOptions(e){const{outboundRtpStatsEnabled:t}=e||{};void 0!==t&&(this.outboundRtpStatsEnabled=t)}start(e){e&&this.setOptions(e),this.started=!0}stop(){this.started=!1}isStarted(){return this.started}getNetworkProtocol(){return this.networkProtocol}getCurrentRoundTripTime(){return this.roundTripTime}getOutboundRtpStats(){return this.outboundRtpStatsMap}onStatsReport(e){if(this.started)switch(e.type){case"transport":this.onTransportStats(e);break;case"candidate-pair":this.onCandidatePairStats(e);break;case"remote-candidate":this.onRemoteCandidateStats(e);break;case"outbound-rtp":this.onOutboundRtpStats(e);break;case"local-candidate":this.onLocalCandidateStats(e)}}onTransportStats(e){const{selectedCandidatePairId:t,dtlsState:i}=e;"connected"===i&&(this.selectedCandidatePairId=t)}onCandidatePairStats(e){const{id:t,state:i,nominated:a,availableOutgoingBitrate:s,currentRoundTripTime:n,remoteCandidateId:r,timestamp:o,localCandidateId:c}=e;t===this.selectedCandidatePairId&&"succeeded"===i&&a&&(this.roundTripTime=n,this.remoteCandidateId=r,this.localCandidateId=c,s&&this.outgoingBitrateStatsCallback({availableOutgoingBitrate:s,timestamp:o}))}onRemoteCandidateStats(e){const{id:t,protocol:i,port:a}=e;if(t===this.remoteCandidateId&&!this.networkProtocol){this.networkProtocol=i;const e="WMSC_Network_Change: send|".concat(i,"|").concat(a);s.default.globalTrace({logLevel:"log",log:e,tags:["WMSC_Network_Change"]}),s.default.monitorLog(e)}}onLocalCandidateStats(e){const{id:t,candidateType:i}=e;if(t==this.localCandidateId&&this.candidateType!=i){this.candidateType=i;const e="WMSC_LocalCandidatae_Change:send|".concat(i);s.default.globalTrace({logLevel:"directReport",log:e,tags:["WMSC_LocalCandidatae_Change"]}),s.default.monitorLog(e)}}onOutboundRtpStats(e){if(!this.outboundRtpStatsEnabled)return;const{ssrc:t,framesEncoded:i,framesSent:a,totalEncodeTime:s,qualityLimitationDurations:n,timestamp:r}=e;let o=this.outboundRtpStatsMap.get(t);o||(o=new u(this.cacheSize),this.outboundRtpStatsMap.set(t,o)),o.push({framesEncoded:i,framesSent:a,totalEncodeTime:s,qualityLimitationDurations:n,timestamp:r})}}class p{constructor(e){this.cacheSize=e.cacheSize||10,this.started=!1,this.selectedCandidatePairId=null,this.roundTripTime=0,this.remoteCandidateId=null,this.networkProtocol=null,this.localCandidateId=null,this.candidateType=null,this.inboundRtpStatsEnabled=!1,this.inboundRtpStatsMap=new Map}reset(){this.resetCandidateStats(),this.resetInboundRtpStats()}resetCandidateStats(){this.selectedCandidatePairId=null,this.roundTripTime=0,this.remoteCandidateId=null,this.networkProtocol=null}resetInboundRtpStats(){this.inboundRtpStatsMap.clear()}setOptions(e){const{inboundRtpStatsEnabled:t}=e||{};void 0!==t&&(this.inboundRtpStatsEnabled=t)}start(e){e&&this.setOptions(e),this.started=!0}stop(){this.started=!1}isStarted(){return this.started}getNetworkProtocol(){return this.networkProtocol}getCurrentRoundTripTime(){return this.roundTripTime}getInboundRtpStats(){return this.inboundRtpStatsMap}onStatsReport(e){if(this.started)switch(e.type){case"transport":this.onTransportStats(e);break;case"candidate-pair":this.onCandidatePairStats(e);break;case"remote-candidate":this.onRemoteCandidateStats(e);break;case"inbound-rtp":this.onInboundRtpStats(e);break;case"local-candidate":this.onLocalCandidateStats(e)}}onTransportStats(e){const{selectedCandidatePairId:t,dtlsState:i}=e;"connected"===i&&(this.selectedCandidatePairId=t)}onCandidatePairStats(e){const{id:t,state:i,nominated:a,currentRoundTripTime:s,remoteCandidateId:n,localCandidateId:r}=e;t===this.selectedCandidatePairId&&"succeeded"===i&&a&&(this.roundTripTime=s,this.remoteCandidateId=n,this.localCandidateId=r)}onRemoteCandidateStats(e){const{id:t,protocol:i,port:a}=e;if(t===this.remoteCandidateId&&!this.networkProtocol){this.networkProtocol=i;const e="WMSC_Network_Change: recv|".concat(i,"|").concat(a);s.default.globalTrace({logLevel:"log",log:e,tags:["WMSC_Network_Change"]}),s.default.monitorLog(e)}}onLocalCandidateStats(e){const{id:t,candidateType:i}=e;if(t==this.localCandidateId&&this.candidateType!=i){this.localCandidateId=t,this.candidateType=i;const e="WMSC_LocalCandidatae_Change:recv|".concat(i);s.default.globalTrace({logLevel:"directReport",log:e,tags:["WMSC_LocalCandidatae_Change"]}),s.default.monitorLog(e)}}onInboundRtpStats(e){if(!this.inboundRtpStatsEnabled)return;const{ssrc:t,framesDecoded:i,framesDropped:a,framesReceived:s,keyFramesDecoded:n,totalDecodeTime:r,pliCount:o,timestamp:c}=e;let d=this.inboundRtpStatsMap.get(t);d||(d=new u(this.cacheSize),this.inboundRtpStatsMap.set(t,d)),d.push({framesDecoded:i,framesDropped:a,framesReceived:s,keyFramesDecoded:n,totalDecodeTime:r,pliCount:o,timestamp:c})}}var _=new S;class E{static mean(e){if(e.length)return e.reduce((e,t)=>e+t,0)/e.length}static median(e){if(!e.length)return;e.sort((e,t)=>e-t);const t=Math.floor(e.length/2);return e.length%2!=0?e[t]:(e[t-1]+e[t])/2}static variance(e){if(!e.length)return;const t=e.reduce((e,t)=>e+t,0)/e.length,i=e.map(e=>Math.pow(e-t,2));return i.reduce((e,t)=>e+t,0)/i.length}static expMovingAverage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5;if(!e.length)return[];const i=[e[0]];for(let a=1;a<e.length;a++)i.push(t*e[a]+(1-t)*i[a-1]);return i}static bestFitSlope(e){if(e.length<2)return;const t=e.length;let i=0,a=0,s=0,n=0;for(let r=0;r<t;r++)i+=r,a+=e[r],s+=r*e[r],n+=r*r;return(t*s-i*a)/(t*n-i*i)}}const v=s.default.getTracer("WmscQosMgr"),f=e=>{v.log(e),s.default.monitorLog("".concat(e))},I=Object.freeze({Hold:0,Increase:1,Decrease:2}),T=Object.freeze({None:0,Increase:1,Decrease:2}),C=Object.freeze({User:0,OutgoingBandwidth:1,ReceiverBandwidth:2,Other:3});class R{constructor(){this.outgoingBandwidthAdaptationEnabled=!0,this.receiverBandwidthAdaptationEnabled=!0,this.outgoingBandwidthProbingEnabled=!1,this.lossDetectionEnabled=!0,this.performanceAdaptationEnabled=!0,this.sendActive=!1,this.requestedLayerIds=[],this.additionalSubLayerIds=[],this.layersAllocation=[],this.layersAllocationCache=null,this.layersAllocationUpdateTimeoutId=null,this.isUpdatingLayers=!1,this.maxSubVideoSize=-1,this.maxFeasibleSendSize=4,this.sendUsageAdjustments=new u(R.resourceUsageAdjustmentHistorySize),this.sendUsageIncreaseFailedAttempts=0,this.sendUsageIncreaseFailedTime=0,this.encoderRestartedTime=0,this.maxFeasibleRecvSize=n.MIN_DEGRADATION_VIDEO_SIZE_RECV,this.recvUsageAdjustments=new u(R.resourceUsageAdjustmentHistorySize),this.recvUsageIncreaseFailedAttempts=0,this.recvUsageIncreaseFailedTime=0,this.outgoingBitrateStats=new u(R.outgoingBitrateStatsCacheSize),this.minOutgoingBitrate=8e4,this.outgoingBandwidth=5e5,this.outgoingBandwidthInProbing=!1,this.outgoingBandwidthProbedTime=0,this.outgoingBandwidthProbingTimeoutId=null,this.receiverBandwidth=1/0,this.receiverBandwidthReport=null,this.receiverL3BandwidthEvaluation=null,this.receiverBandwidthUpdatePending=!1,this.receiverBandwidthUpdateTimeoutId=null,this.isDualCall=!0,this.receiverStats=new u(R.receiverStatsCacheSize),this.minOutgoingBitrateAdjustments=new u(