Workers.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
  1. const defaultLogger = {
  2. info: console.log,
  3. debug: console.log,
  4. error: console.error,
  5. infoAndReportMeasurement: (...i)=>{}
  6. };
  7. const USER_ID = "987412365"
  8. , PAGE_SESSION = "aaabbbccc"
  9. , SERVER_SESSION = "cccbbbaaa"
  10. , COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/"
  11. , FRAME_COMPOSE_LENGTH = 5;
  12. let count = 0
  13. import CircularArray from "./CircularArray.js"
  14. export default class Workers {
  15. constructor(e, t) {
  16. this.rtcp = e,
  17. this.cacheSize = 0,
  18. this.cacheBuffer = new Uint8Array(262144),
  19. this.cacheFrameCnt = 0,
  20. this.startReceiveTime = 0,
  21. this.cacheFrameComposes = new Array(0),
  22. this.cacheSizes = new Array(5).fill(0),
  23. this.cacheFrameCnts = new Array(5).fill(-1),
  24. this.cacheStartReceiveTimes = new Array(5).fill(0),
  25. this.cacheBuffers = [new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144)],
  26. this.panoCacheSize = 0,
  27. this.panoCacheBuffer = new Uint8Array(2097152),
  28. this.cachePanoTileID = 0,
  29. this.receivedMedia = 0,
  30. this.receivedMedia_worker = 0,
  31. this.receivedYUV = 0,
  32. this.receivedEmit = 0,
  33. this.returnFrames = 0,
  34. this.lastReturnFrames = 0,
  35. this.lastReceivedEmit = 0,
  36. this.mediaBytesReceived = 0,
  37. this.metaBytesReceived = 0,
  38. this.noWasmBytesReceived = 0,
  39. this.rtcBytesReceived = 0,
  40. this.rtcMessageReceived = 0,
  41. this.packetsDrop = 0,
  42. this.framesAwait = 0,
  43. this.sendOutBuffer = 0,
  44. this.decodeTimePerFrame = 0,
  45. this.decodeTimeMaxFrame = 0,
  46. this.lastRenderTs = 0,
  47. this.JankTimes = 0,
  48. this.bigJankTimes = 0,
  49. this.DecodeJankTimes = 0,
  50. this.bigDecodeJankTimes = 0,
  51. this.saveframe = !1,
  52. this.SaveMediaStream = !1,
  53. this.packetsLost = 0,
  54. this.showAllReceivedMetadata = !1,
  55. this.firstMediaArraval = 0,
  56. this.firstMediaReceived = !1,
  57. this.firstYUVDecoded = 0,
  58. this.firstRender = 0,
  59. this.firstYUVReceived = !1,
  60. this.reconnectSignal = !1,
  61. this.serverFrameSlow = 0,
  62. this.serverFrameFast = 0,
  63. this.clientFrameSlow = 0,
  64. this.clientFrameFast = 0,
  65. this.lastServerTS = 0,
  66. this.lastClientTS = 0,
  67. this.lastSeq = 0,
  68. this.lastIsPureMeta = !1,
  69. this.lastHBPacketTs = 0,
  70. this.HBPacketInterval = 0,
  71. this.lastHBPacketSrvSentTs = 0,
  72. this.HBPacketIntervalSrvSent = 0,
  73. this.cachedLength = 2,
  74. this.cachedStreams = new Array(this.cachedLength),
  75. this.cachedMetas = new Array(this.cachedLength),
  76. this.cachedPtss = new Array(this.cachedLength),
  77. this.cachedRender = Array(this.cachedLength).fill(!1),
  78. this.cachedResolution = new Array(this.cachedLength),
  79. this.getPtr = 0,
  80. this.setPtr = 0,
  81. this.receiveIframes = 0,
  82. this.decodeIframes = 0,
  83. this.prevSenderTs = -1,
  84. this.serverSendTimeArray = new CircularArray(120,!1,[]),
  85. this.inPanoMode = !1,
  86. this.PanoStatus = {
  87. x: 0,
  88. y: 0,
  89. z: 0,
  90. tiles: []
  91. },
  92. this.DynamicPanoTest = !1,
  93. this.PanoMask = new ArrayBuffer(8),
  94. this.PanoView = new DataView(this.PanoMask),
  95. this.userId_test = "",
  96. this.PendingMasks = [],
  97. this.traceIdMap = new Map,
  98. this.responseTimeArray = [],
  99. this.processTimeArray = [],
  100. this.displayTimeArray = [],
  101. this.overallTimeArray = [],
  102. this.responseMiss = 0,
  103. this.processMiss = 0,
  104. this.displayMiss = 0,
  105. this.updateYUVCircular = new CircularArray(120,!1,[]),
  106. this.updateDropFrame = 0,
  107. this.metaParseAraay = [],
  108. this.responseMoveMiss = 0,
  109. this.processMoveMiss = 0,
  110. this.displayMoveMiss = 0,
  111. this.MovingTraceId = "",
  112. this.PendingMovingTraceId = "",
  113. this.inMovingMode = !1,
  114. this.StartMovingTs = 0,
  115. this.PendingStartMovingTs = 0,
  116. this.moveEvent = "",
  117. this.MoveToFrameCnt = 0,
  118. this.lastIsMoving = 0,
  119. this.MoveResponseDelay = 0,
  120. this.MoveProcessDelay = 0,
  121. this.MoveDisplayDelay = 0,
  122. this.lastMoveResponseTime = 0,
  123. this.lastMoveProcessTime = 0,
  124. this.lastMoveDisplayTime = 0,
  125. this.moveResponseCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
  126. this.moveProcessCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
  127. this.moveDisplayCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
  128. this.moveStartPts = -1,
  129. this.frameServerCircular = new CircularArray(120,!1,[]),
  130. this.srvMetaIntervalCircular = new CircularArray(120,!1,[]),
  131. this.srvMediaIntervalCircular = new CircularArray(120,!1,[]),
  132. this.srvHBMetaIntervalCircular = new CircularArray(120,!1,[]),
  133. this.srvHBMetaIntervalSrvSentCircular = new CircularArray(120,!1,[]),
  134. this.frameClientCircular = new CircularArray(120,!1,[]),
  135. this.firstUpdateYUV = !0,
  136. this.functionMap = new Map,
  137. this.WASM_VERSION = "WASM-1.1",
  138. this.frameHistory = [],
  139. this.getVersion = function() {
  140. return DECODER_VERSION
  141. }
  142. ,
  143. this.downloadBlob = (r,n,o)=>{
  144. const a = new Blob([r],{
  145. type: o
  146. })
  147. , s = window.URL.createObjectURL(a);
  148. this.downloadURL(s, n),
  149. setTimeout(function() {
  150. return window.URL.revokeObjectURL(s)
  151. }, 1e3)
  152. }
  153. ,
  154. this.downloadURL = function(r, n) {
  155. const o = document.createElement("a");
  156. o.href = r,
  157. o.download = n,
  158. document.body.appendChild(o),
  159. o.style.display = "none",
  160. o.click(),
  161. o.remove()
  162. }
  163. ,
  164. this.Stringify = function(r) {
  165. let n = "";
  166. for (let a = 0; a < r.length / 8192; a++)
  167. n += String.fromCharCode.apply(null, r.slice(a * 8192, (a + 1) * 8192));
  168. return n
  169. }
  170. ,
  171. this._rtcp = e
  172. }
  173. registerLogger(e) {
  174. //defaultLogger = e
  175. }
  176. registerFunction(e, t) {
  177. this.functionMap.set(e, t)
  178. }
  179. hasFrmCntInCache(e) {
  180. let t = -1;
  181. for (let r = 0; r < this.cacheFrameComposes.length; r++)
  182. this.cacheFrameComposes[r].frameCnt == e && (t = r);
  183. return t
  184. }
  185. requestPanoramaTest(e, t, r, n, o) {
  186. const a = o
  187. , s = {
  188. action_type: 16,
  189. change_rotation_render_type_action: {
  190. render_type: 5,
  191. player: {
  192. position: {
  193. x: 0,
  194. y: 0,
  195. z: 0
  196. },
  197. angle: {
  198. yaw: 0,
  199. pitch: 0,
  200. roll: 0
  201. }
  202. },
  203. camera: {
  204. position: {
  205. x: e,
  206. y: t,
  207. z: r
  208. },
  209. angle: {
  210. yaw: 0,
  211. pitch: 0,
  212. roll: 0
  213. }
  214. },
  215. client_pano_titles_bitmap: n
  216. },
  217. trace_id: a,
  218. user_id: this.userId_test,
  219. packet_id: a
  220. };
  221. defaultLogger.debug("send data: ", s),
  222. this._rtcp.sendData(s)
  223. }
  224. onRotateInPanoMode(e) {
  225. const t = e.traceId
  226. , r = {};
  227. r.width = 1280,
  228. r.height = 720,
  229. r.horz_fov = 92,
  230. r.angle = {
  231. yaw: 100,
  232. pitch: 30
  233. };
  234. const n = new ArrayBuffer(8)
  235. , o = new DataView(n);
  236. getTilesInView(r, n);
  237. const a = n.slice(0);
  238. this.PendingMasks.unshift({
  239. buffer: a,
  240. angle: r.angle
  241. }),
  242. MaskSetToOne(18, this.PanoView),
  243. operateForDataView(o, this.PanoView, o, (s,l)=>s ^ s & l),
  244. this.requestPanoramaTest(0, 0, 0, [o.getUint8(0), o.getUint8(1), o.getUint8(2), o.getUint8(3), o.getUint8(4), o.getUint8(5), o.getUint8(6), o.getUint8(7)], t)
  245. }
  246. processMetaWithTraceId(e) {
  247. for (const t of e.traceIds) {
  248. if (this.traceIdMap.has(t)) {
  249. const r = this.traceIdMap.get(t);
  250. r != null && (r.receiveTime = Date.now(),
  251. r.status = 1)
  252. }
  253. if (t == this.PendingMovingTraceId) {
  254. this.inMovingMode = !0,
  255. this.MovingTraceId = this.PendingMovingTraceId,
  256. this.StartMovingTs = this.PendingStartMovingTs,
  257. this.PendingMovingTraceId = "",
  258. this.PendingStartMovingTs = 0,
  259. defaultLogger.info("MoveTo TraceId match", this.StartMovingTs, Date.now());
  260. const r = Date.now();
  261. this.lastMoveResponseTime = r,
  262. this.lastMoveProcessTime = r,
  263. this.lastMoveDisplayTime = r,
  264. this.frameServerCircular.clear(),
  265. this.frameClientCircular.clear()
  266. }
  267. }
  268. }
  269. onTraceId(e, t=this) {
  270. const r = e.traceId
  271. , n = e.timestamp
  272. , o = e.event;
  273. if (o === "Rotation") {
  274. const a = {
  275. traceId: r,
  276. pts: 0,
  277. startTime: n,
  278. receiveTime: 0,
  279. readyTime: 0,
  280. displayTime: 0,
  281. status: 0
  282. };
  283. this.traceIdMap.set(r, a);
  284. const s = setTimeout(()=>{
  285. if (s && clearTimeout(s),
  286. this.traceIdMap.has(r)) {
  287. const l = this.traceIdMap.get(r);
  288. switch (l == null ? void 0 : l.status) {
  289. case 0:
  290. {
  291. this.responseMiss += 1;
  292. break
  293. }
  294. case 1:
  295. {
  296. this.processMiss += 1;
  297. const u = l.receiveTime - l.startTime;
  298. this.responseTimeArray.push(u);
  299. break
  300. }
  301. case 2:
  302. {
  303. this.displayMiss += 1;
  304. const u = l.receiveTime - l.startTime
  305. , c = l.readyTime - l.receiveTime;
  306. this.responseTimeArray.push(u),
  307. this.processTimeArray.push(c);
  308. break
  309. }
  310. case 3:
  311. defaultLogger.debug("status is 3")
  312. }
  313. }
  314. }
  315. , 1e3)
  316. } else
  317. o === "MoveTo" ? (defaultLogger.info("receive moveto traceId ", r, " at timestamp", n),
  318. this.PendingMovingTraceId = r,
  319. this.PendingStartMovingTs = n,
  320. this.moveEvent = o,
  321. this.frameServerCircular.clear()) : o === "GetOnAirship" || o === "GetOnVehicle" ? (defaultLogger.info("receive airship traceId ", r, " at timestamp ", n),
  322. this.PendingMovingTraceId = r,
  323. this.PendingStartMovingTs = n,
  324. this.moveEvent = o,
  325. this.frameServerCircular.clear()) : (o === "GetOffAirship" || o === "GetOffVehicle") && this.clearMoveArray()
  326. }
  327. executeFunction(e, t) {
  328. if (this.functionMap.has(e)) {
  329. const r = this.functionMap.get(e);
  330. r != null && r(t)
  331. }
  332. }
  333. UpdateStats(e) {
  334. var t;
  335. (t = this._rtcp.connection) == null || t.getStats(null).then(r=>{
  336. r.forEach(n=>{
  337. n.type == "data-channel" && (this.rtcMessageReceived = n.messagesReceived - n.messagesSent,
  338. this.rtcBytesReceived = n.bytesReceived)
  339. }
  340. )
  341. }
  342. ),
  343. this.receivedMedia_worker = e.data.framesReceived,
  344. this.receivedYUV = e.data.framesDecoded,
  345. this.receivedEmit = e.data.framesRendered,
  346. this.mediaBytesReceived = e.data.mediaBytesReceived,
  347. this.metaBytesReceived = e.data.metaBytesReceived,
  348. this.packetsLost = e.data.packetsLost,
  349. this.packetsDrop = e.data.packetsDrop,
  350. this.framesAwait = e.data.framesAwait,
  351. this.decodeTimePerFrame = e.data.decodeTimePerFrame,
  352. this.decodeTimeMaxFrame = e.data.decodeTimeMaxFrame,
  353. this.returnFrames = e.data.framesReturned,
  354. this.sendOutBuffer = e.data.sendOutBuffer,
  355. this.DecodeJankTimes = e.data.JankTimes,
  356. this.bigDecodeJankTimes = e.data.bigJankTimes,
  357. this.receiveIframes = e.data.receivedIframe,
  358. this.decodeIframes = e.data.decodedIframe
  359. }
  360. ReceiveDecodeMessage(e) {
  361. var n;
  362. if (!this.firstYUVReceived) {
  363. this.firstYUVDecoded = e.data.yuv_ts;
  364. const o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  365. defaultLogger.infoAndReportMeasurement({
  366. metric: "firstYUVDecodedAt",
  367. value: o,
  368. group: "joinRoom"
  369. }),
  370. this.firstRender = Date.now();
  371. const a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  372. defaultLogger.infoAndReportMeasurement({
  373. metric: "firstRenderAt",
  374. value: a,
  375. group: "joinRoom"
  376. }),
  377. this.firstYUVReceived = !0,
  378. this.lastRenderTs = Date.now()
  379. }
  380. if(!this.cachedRender[this.setPtr] && this.cachedMetas[this.setPtr] != null){
  381. if(this.cachedStreams[this.setPtr] != null && this.cachedStreams[this.setPtr].byteLength != 0)
  382. {
  383. if(e.data.data == null){
  384. // this.executeFunction("stream", {
  385. // stream: this.cachedStreams[this.setPtr],
  386. // width: this.cachedResolution[this.setPtr].width,
  387. // height: this.cachedResolution[this.setPtr].height,
  388. // pts: this.cachedPtss[this.setPtr]
  389. // }),
  390. // this.executeFunction("signal", {
  391. // signal: this.cachedMetas[this.setPtr],
  392. // pts: this.cachedPtss[this.setPtr],
  393. // alreadyUpdateYUV: !0
  394. // })
  395. }
  396. else{
  397. this.updateDropFrame += 1
  398. }
  399. // this.decoderWorker.postMessage({
  400. // t: 2,
  401. // frameCnt: this.cachedPtss[this.setPtr],
  402. // buffer: this.cachedStreams[this.setPtr]
  403. // }, [this.cachedStreams[this.setPtr].buffer])
  404. }
  405. this.getPtr = (this.getPtr + 1) % this.cachedLength
  406. }
  407. const t = e.data.metadata;
  408. if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
  409. for (const o of t.traceIds)
  410. if (this.traceIdMap.has(o)) {
  411. const a = this.traceIdMap.get(o);
  412. a != null && (a.readyTime = Date.now(),
  413. a.status = 2)
  414. }
  415. }
  416. e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs);
  417. this.userId_test = this.rtcp.network.room.userId;
  418. if (this.inMovingMode) {
  419. const o = Date.now()
  420. const a = o - this.lastMoveProcessTime;
  421. this.moveProcessCircular.add(a);
  422. this.lastMoveProcessTime = o;
  423. }
  424. const r = this.setPtr;
  425. this.cachedStreams[r] = e.data.data;
  426. this.cachedMetas[r] = e.data.metadata;
  427. this.cachedPtss[r] = e.data.pts;
  428. this.cachedRender[r] = !1;
  429. this.cachedResolution[r] = {
  430. width: e.data.width,
  431. height: e.data.height
  432. },
  433. this.setPtr = (this.setPtr + 1) % this.cachedLength
  434. }
  435. // SendCacheFrameInfo(e) {
  436. // var h, f, d, _, g, m, v;
  437. // const t = e.data.cachedKey
  438. // , r = e.data.metadata
  439. // , n = t
  440. // , o = r
  441. // , a = (d = (f = (h = o.newUserStates) == null ? void 0 : h.find(y=>y.userId === this.rtcp.network.room.userId)) == null ? void 0 : f.playerState) == null ? void 0 : d.roomTypeId
  442. // , s = this.rtcp.network.room.skinId
  443. // , l = (v = (m = (g = (_ = o.newUserStates) == null ? void 0 : _.find(y=>y.userId === this._rtcp.network.room.userId)) == null ? void 0 : g.playerState) == null ? void 0 : m.player) == null ? void 0 : v.position
  444. // , u = {
  445. // MsgType: 1,
  446. // FrameCacheMsg: {
  447. // FrameIndex: n,
  448. // RoomTypeId: a,
  449. // SkinID: s,
  450. // Position: l
  451. // }
  452. // };
  453. // let c = "";
  454. // try {
  455. // c = JSON.stringify(u)
  456. // } catch (y) {
  457. // defaultLogger.error(y);
  458. // return
  459. // }
  460. // }
  461. ReceivePanoramaDecodeMessage(e) {
  462. defaultLogger.info("Receive Panorama Image in Workers.ts"),
  463. MaskSetToOne(e.data.tileId, this.PanoView);
  464. let t = 0, r;
  465. const n = this.PendingMasks.length;
  466. for (t = 0; t < n; t++) {
  467. const o = this.PendingMasks[t].buffer
  468. , a = new DataView(o)
  469. , s = new ArrayBuffer(8)
  470. , l = new DataView(s);
  471. if (operateForDataView(this.PanoView, a, l, (u,c)=>c ^ u & c),
  472. IsAll0(l)) {
  473. r = this.PendingMasks[t].angle;
  474. break
  475. }
  476. }
  477. for (let o = t; o < n; o++)
  478. this.PendingMasks.pop();
  479. this.executeFunction("panorama", {
  480. data: e.data.data,
  481. tileId: e.data.tileId,
  482. pos: {
  483. x: e.data.x,
  484. y: e.data.y,
  485. z: e.data.z
  486. },
  487. uuid: e.data.uuid,
  488. finished: !0,
  489. matchAngle: r
  490. })
  491. }
  492. enable_decoder_queue_logging() {
  493. this.decoderWorker.postMessage({
  494. t: 100,
  495. status: !0
  496. })
  497. }
  498. disable_decoder_queue_logging() {
  499. this.decoderWorker.postMessage({
  500. t: 100,
  501. status: !1
  502. })
  503. }
  504. async init(e={
  505. width: 1280,
  506. height: 720
  507. }) {
  508. for (let r = 0; r < FRAME_COMPOSE_LENGTH; r++) {
  509. const n = {
  510. buffer: new Uint8Array(2621440),
  511. size: 0,
  512. startReceiveTime: 0,
  513. serverTime: 0,
  514. frameCnt: -1
  515. };
  516. this.cacheFrameComposes.push(n)
  517. }
  518. const t = new Blob([decoder],{
  519. type: "application/javascript"
  520. });
  521. this.decoderWorker = new Worker(URL.createObjectURL(t));
  522. this.decoderWorker.postMessage({
  523. t: 9,
  524. url: WASM_URLS[WASM_Version],
  525. jitterLength: DECODER_PASSIVE_JITTER
  526. });
  527. window.decoderWorker = this.decoderWorker;
  528. this.decoderWorker.postMessage({
  529. t: 1,
  530. config: e
  531. });
  532. return new Promise(r=>{
  533. this.decoderWorker.onmessage = n=>{
  534. switch (n.data.t) {
  535. case 0:
  536. this.ReceiveDecodeMessage(n);
  537. break;
  538. case 1:
  539. this.UpdateStats(n);
  540. break;
  541. case 2:
  542. r();
  543. break;
  544. case 3:
  545. //this.SendCacheFrameInfo(n);
  546. break;
  547. case 4:
  548. {
  549. const o = new Date().toISOString()
  550. , a = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + o + ".264";
  551. let downloadURL = function(r, n) {
  552. const o = document.createElement("a");
  553. o.href = r,
  554. o.download = n,
  555. document.body.appendChild(o),
  556. o.style.display = "none",
  557. o.click(),
  558. o.remove()
  559. }
  560. downloadURL(n.data.link, a)
  561. //uploadStream(COS_PREFIX + a, n.data.fileObj);
  562. break
  563. }
  564. case 5:
  565. // this.executeFunction("signal", {
  566. // signal: n.data.metadata,
  567. // pts: -1,
  568. // alreadyUpdateYUV: !1
  569. // });
  570. break;
  571. case 6:
  572. defaultLogger.infoAndReportMeasurement(n.data),
  573. defaultLogger.debug("WASM Ready Cost");
  574. break;
  575. case 7:
  576. this.ReceivePanoramaDecodeMessage(n);
  577. break;
  578. case 8:
  579. {
  580. const o = {
  581. MstType: 0
  582. };
  583. let a = "";
  584. try {
  585. a = JSON.stringify(o)
  586. } catch (l) {
  587. defaultLogger.error(l);
  588. return
  589. }
  590. const s = "wasm:" + a;
  591. this._rtcp.sendStringData(s);
  592. break
  593. }
  594. case 9:
  595. {
  596. defaultLogger.info(n.data.printMsg);
  597. break
  598. }
  599. case 10:
  600. {
  601. defaultLogger.error(n.data.printMsg),
  602. this.executeFunction("error", {
  603. code: n.data.code,
  604. message: n.data.printMsg
  605. });
  606. break
  607. }
  608. default:
  609. defaultLogger.error("Receive unknown message event from decoder"),
  610. defaultLogger.debug(n.data);
  611. break
  612. }
  613. }
  614. }
  615. )
  616. }
  617. UpdateYUV() {
  618. ++count
  619. if(count>100){
  620. return
  621. }
  622. var t, r;
  623. const e = this.getPtr;
  624. if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
  625. const n = Date.now();
  626. if (this.firstUpdateYUV) {
  627. const h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
  628. defaultLogger.infoAndReportMeasurement({
  629. metric: "firstUpdateStreamLength",
  630. value: h,
  631. group: "joinRoom"
  632. }),
  633. this.firstUpdateYUV = !1
  634. }
  635. this.cachedStreams[e] != null && this.executeFunction("stream", {
  636. stream: this.cachedStreams[e],
  637. width: this.cachedResolution[e].width,
  638. height: this.cachedResolution[e].height,
  639. pts: this.cachedPtss[e]
  640. });
  641. const o = Date.now();
  642. this.cachedStreams[e] != null && this.decoderWorker.postMessage({
  643. t: 2,
  644. frameCnt: this.cachedPtss[e],
  645. buffer: this.cachedStreams[e]
  646. }, [this.cachedStreams[e].buffer]);
  647. // const a = Date.now()
  648. // , s = o - n
  649. // , l = a - o;
  650. // (s > 33 || l > 10) && defaultLogger.debug("[wwwarning] updateYUV takes ", s, " ms, postMessage takes ", l, " ms for index ", this.cachedPtss[e]),
  651. // o - this.lastRenderTs > 84 && this.JankTimes++,
  652. // o - this.lastRenderTs > 125 && this.bigJankTimes++,
  653. // this.lastRenderTs = o;
  654. // const u = o - n;
  655. // this.updateYUVCircular.add(u);
  656. // const c = this.cachedMetas[e];
  657. // if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
  658. // for (const h of c.traceIds)
  659. // if (this.traceIdMap.has(h)) {
  660. // const f = this.traceIdMap.get(h);
  661. // if (f != null) {
  662. // f.displayTime = Date.now(),
  663. // f.status = 3;
  664. // const d = f.receiveTime - f.startTime
  665. // , _ = f.readyTime - f.receiveTime
  666. // , g = f.displayTime - f.readyTime
  667. // , m = f.displayTime - f.startTime;
  668. // this.responseTimeArray.push(d),
  669. // this.processTimeArray.push(_),
  670. // this.displayTimeArray.push(g),
  671. // this.overallTimeArray.push(m),
  672. // this.traceIdMap.delete(h)
  673. // }
  674. // }
  675. // }
  676. // this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs)
  677. // if (this.inMovingMode) {
  678. // const h = Date.now()
  679. // , f = h - this.lastMoveDisplayTime;
  680. // this.moveDisplayCircular.add(f),
  681. // this.lastMoveDisplayTime = h
  682. // }
  683. this.executeFunction("signal", {
  684. signal: this.cachedMetas[e],
  685. pts: this.cachedPtss[e],
  686. alreadyUpdateYUV: !0
  687. })
  688. this.cachedRender[e] = !0;
  689. this.getPtr = (this.getPtr + 1) % this.cachedLength
  690. }
  691. }
  692. unmarshalPano(e) {
  693. const t = new DataView(e);
  694. if (t.getUint32(0) != 1723558763)
  695. return !1;
  696. console.log("Receive Pano Message"),
  697. t.getUint16(4);
  698. const n = t.getUint16(6)
  699. , o = t.getUint32(8)
  700. , a = t.getUint32(12) - (1 << 30) * 2
  701. , s = t.getUint32(16) - (1 << 30) * 2
  702. , l = t.getUint32(20) - (1 << 30) * 2
  703. , u = t.getUint32(24)
  704. , c = new Uint8Array(e).subarray(28, 64)
  705. , h = String.fromCharCode.apply(null, c)
  706. , f = t.getUint32(64)
  707. , d = e.byteLength - n;
  708. if (d == u) {
  709. const g = {
  710. data: new Uint8Array(e).subarray(n),
  711. mediaLen: u,
  712. tileId: o,
  713. uuid: h,
  714. x: a,
  715. y: s,
  716. z: l
  717. };
  718. this.decoderWorker.postMessage({
  719. t: 8,
  720. data: g
  721. })
  722. } else {
  723. const _ = new Uint8Array(e,n,d);
  724. if (this.cachePanoTileID == o) {
  725. if (this.panoCacheBuffer.set(_, f),
  726. this.panoCacheSize += d,
  727. this.panoCacheSize === u) {
  728. const m = {
  729. data: new Uint8Array(this.panoCacheBuffer).slice(0, u),
  730. mediaLen: u,
  731. tileId: o,
  732. uuid: h,
  733. x: a,
  734. y: s,
  735. z: l
  736. };
  737. this.decoderWorker.postMessage({
  738. t: 8,
  739. data: m
  740. }),
  741. this.panoCacheSize = 0
  742. }
  743. } else
  744. this.panoCacheBuffer.set(_, f),
  745. this.panoCacheSize = d,
  746. this.cachePanoTileID = o
  747. }
  748. return !0
  749. }
  750. clearMoveArray() {
  751. this.MovingTraceId = "",
  752. this.inMovingMode = !1,
  753. this.StartMovingTs = 0,
  754. this.MoveToFrameCnt = 0,
  755. this.MoveResponseDelay = 0,
  756. this.MoveProcessDelay = 0,
  757. this.MoveDisplayDelay = 0,
  758. this.moveStartPts = -1,
  759. this.moveResponseCircular.clear(),
  760. this.moveProcessCircular.clear(),
  761. this.moveDisplayCircular.clear(),
  762. this.moveEvent = ""
  763. }
  764. getIsMoving(e) {
  765. let t;
  766. if (typeof e.newUserStates != "undefined")
  767. for (let r = 0; r < e.newUserStates.length; r++) {
  768. const n = e.newUserStates[r];
  769. if (n.userId == this.rtcp.network.room.userId) {
  770. t = n.renderInfo.isMoving;
  771. break
  772. }
  773. }
  774. return t
  775. }
  776. isHeartBeatPacket(e, t) {
  777. return new DataView(e).getUint32(0) == 2009889916
  778. }
  779. resetSendTimeDiff() {
  780. this.prevSenderTs = 0,
  781. this.serverSendTimeArray.clear()
  782. }
  783. calcSendTimeDiff(e) {
  784. if (this.prevSenderTs == -1) {
  785. this.prevSenderTs = e;
  786. return
  787. }
  788. const t = e - this.prevSenderTs;
  789. this.serverSendTimeArray.add(t),
  790. this.prevSenderTs = e
  791. }
  792. unmarshalStream(e) {
  793. var T, C, A, S, P, R, M, x, I, w;
  794. const t = new DataView(e);
  795. if (t.getUint32(0) != 1437227610)
  796. {
  797. return !1;
  798. }
  799. t.getUint16(4);
  800. const n = t.getUint16(6)
  801. , o = t.getUint16(8)
  802. , a = o
  803. , s = t.getUint16(10);
  804. let l = !1;
  805. s == 1 && (l = !0);
  806. const u = t.getUint32(12)
  807. , c = t.getUint32(16)
  808. , h = t.getUint32(20)
  809. , f = t.getUint16(24)
  810. , d = t.getUint16(26)
  811. , _ = t.getUint32(28)
  812. , g = t.getUint32(n - 4)
  813. , m = u + c
  814. , v = e.byteLength - n
  815. , y = new Uint8Array(e,n,v);
  816. this.calcSendTimeDiff(h);
  817. let b;
  818. if (this.inPanoMode && (c > 0 || f))
  819. {
  820. defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode")
  821. return !0;
  822. }
  823. if (v === m) {
  824. this.receivedMedia++;
  825. const O = new Uint8Array(e).subarray(n);
  826. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  827. const D = Date.now();
  828. D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
  829. const F = c === 0
  830. , V = h - this.lastServerTS;
  831. if(this.lastServerTS != 0)
  832. {
  833. if((o + 65536 - this.lastSeq) % 65536 === 1 && this.lastIsPureMeta == F){
  834. F ? this.srvMetaIntervalCircular.add(V) : this.srvMediaIntervalCircular.add(V)
  835. }
  836. this.frameServerCircular.add(V);
  837. this.frameClientCircular.add(D - this.lastClientTS);
  838. }
  839. this.lastSeq = o;
  840. this.lastIsPureMeta = F;
  841. this.lastServerTS = h;
  842. this.lastClientTS = D;
  843. const N = O.subarray(0, u)
  844. , L = Date.now()
  845. , k = JSON.parse(this.Stringify(N))
  846. , U = Date.now();
  847. this.showAllReceivedMetadata && console.log(h, D, k);
  848. this.metaParseAraay.push(U - L);
  849. (T = k.traceIds) != null && T.length && this.processMetaWithTraceId(k);
  850. c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o);
  851. if(this.moveStartPts == o){
  852. this.MoveResponseDelay = Date.now() - this.StartMovingTs;
  853. console.log("move response delay: ", o, this.moveStartPts, this.MoveResponseDelay)
  854. }
  855. const z = this.getIsMoving(k);
  856. this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray();
  857. typeof z != "undefined" && (this.lastIsMoving = z);
  858. if (this.inMovingMode) {
  859. const G = Date.now()
  860. , W = G - this.lastMoveResponseTime;
  861. this.moveResponseCircular.add(W);
  862. this.lastMoveResponseTime = G;
  863. }
  864. if(f || d){
  865. b = (P = (S = (A = (C = k.newUserStates) == null ? void 0 : C.find(G=>G.userId === this._rtcp.network.room.userId)) == null ? void 0 : A.playerState) == null ? void 0 : S.player) == null ? void 0 : P.position
  866. }
  867. const H = {
  868. t: 0,
  869. data: O,
  870. mediaLen: c,
  871. metaLen: u,
  872. metadata: k,
  873. frameCnt: a,
  874. server_ts: h,
  875. isIDR: l,
  876. cacheRequest: d,
  877. cached: f,
  878. cachedKey: _,
  879. position: b
  880. };
  881. if (this.inPanoMode)
  882. {
  883. this.executeFunction("signal", {
  884. signal: k,
  885. pts: -1,
  886. alreadyUpdateYUV: !0
  887. });
  888. return !0;
  889. }
  890. this.decoderWorker.postMessage(H, [O.buffer]);
  891. if (!this.firstMediaReceived) {
  892. this.firstMediaArraval = Date.now();
  893. const G = this.firstMediaArraval - this.rtcp.network.room._startTime;
  894. defaultLogger.infoAndReportMeasurement({
  895. metric: "firstMediaArravalAt",
  896. value: G,
  897. group: "joinRoom"
  898. });
  899. this.firstMediaReceived = !0;
  900. }
  901. }
  902. else {
  903. const O = this.hasFrmCntInCache(a);
  904. if (O != -1)
  905. {
  906. this.cacheFrameComposes[O].buffer.set(y, g);
  907. this.cacheFrameComposes[O].size += v;
  908. if (this.cacheFrameComposes[O].size === m) {
  909. const D = new Uint8Array(this.cacheFrameComposes[O].buffer).slice(0, m);
  910. this.cacheFrameComposes[O].frameCnt = -1;
  911. this.cacheFrameComposes[O].size = 0;
  912. this.cacheFrameComposes[O].startReceiveTime = 0;
  913. this.cacheFrameComposes[O].serverTime = 0;
  914. this.receivedMedia++;
  915. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  916. const F = Date.now();
  917. F - this.lastClientTS > 60 ? this.clientFrameSlow++ : F - this.lastClientTS < 16 && this.clientFrameFast++;
  918. if(this.lastServerTS != 0)
  919. {
  920. this.frameServerCircular.add(h - this.lastServerTS);
  921. this.frameClientCircular.add(F - this.lastClientTS);
  922. }
  923. this.lastServerTS = h;
  924. this.lastClientTS = F;
  925. const V = D.subarray(0, u)
  926. , N = Date.now()
  927. , L = JSON.parse(this.Stringify(V))
  928. , k = Date.now();
  929. this.showAllReceivedMetadata && console.log(h, F, L);
  930. this.metaParseAraay.push(k - N);
  931. (R = L.traceIds) != null && R.length && this.processMetaWithTraceId(L);
  932. c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o);
  933. this.moveStartPts == o && (this.MoveResponseDelay = Date.now() - this.StartMovingTs);
  934. const U = this.getIsMoving(L);
  935. this.inMovingMode && U == 0 && this.lastIsMoving == 1 && this.clearMoveArray();
  936. typeof U != "undefined" && (this.lastIsMoving = U);
  937. if (this.inMovingMode) {
  938. const H = Date.now()
  939. , G = H - this.lastMoveResponseTime;
  940. this.moveResponseCircular.add(G);
  941. this.lastMoveResponseTime = H;
  942. }
  943. (f || d) && (b = (w = (I = (x = (M = L.newUserStates) == null ? void 0 : M.find(H=>H.userId === this._rtcp.network.room.userId)) == null ? void 0 : x.playerState) == null ? void 0 : I.player) == null ? void 0 : w.position);
  944. const z = {
  945. t: 0,
  946. data: D,
  947. mediaLen: c,
  948. metaLen: u,
  949. metadata: L,
  950. frameCnt: a,
  951. server_ts: h,
  952. isIDR: l,
  953. cacheRequest: d,
  954. cached: f,
  955. cachedKey: _,
  956. position: b
  957. };
  958. if (this.inPanoMode)
  959. {
  960. this.executeFunction("signal", {
  961. signal: L,
  962. pts: -1,
  963. alreadyUpdateYUV: !0
  964. });
  965. return !0;
  966. }
  967. this.decoderWorker.postMessage(z, [D.buffer]);
  968. if (!this.firstMediaReceived) {
  969. this.firstMediaArraval = Date.now();
  970. const H = this.firstMediaArraval - this.rtcp.network.room._startTime;
  971. defaultLogger.infoAndReportMeasurement({
  972. metric: "firstMediaArravalAt",
  973. value: H,
  974. group: "joinRoom"
  975. }),
  976. this.firstMediaReceived = !0
  977. }
  978. }
  979. else
  980. {
  981. this.cacheFrameComposes[O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
  982. }
  983. }
  984. else if (O == -1) {
  985. let D = this.hasFrmCntInCache(-1);
  986. if (D == -1) {
  987. let F = Date.now() + 1e18
  988. , V = -1;
  989. for (let N = 0; N < this.cacheFrameComposes.length; N++)
  990. this.cacheFrameComposes[N].serverTime < F && (F = this.cacheFrameComposes[N].serverTime,
  991. V = N);
  992. D = V
  993. }
  994. this.cacheFrameComposes[D].buffer.set(y, g);
  995. this.cacheFrameComposes[D].size = v;
  996. this.cacheFrameComposes[D].frameCnt = a;
  997. this.cacheFrameComposes[D].startReceiveTime = Date.now();
  998. this.cacheFrameComposes[D].serverTime = h;
  999. }
  1000. }
  1001. return !0
  1002. }
  1003. reset() {
  1004. defaultLogger.debug("Worker reset is called"),
  1005. this.cacheFrameCnt = 0,
  1006. this.receivedMedia = 0,
  1007. this.reconnectSignal = !0,
  1008. this.decoderWorker.postMessage({
  1009. t: 4
  1010. })
  1011. }
  1012. dataHandleOff(e) {
  1013. defaultLogger.debug("hhh")
  1014. }
  1015. dataHandle(e) {
  1016. if(this.saveframe){
  1017. this.decoderWorker.postMessage({
  1018. t: 6
  1019. }),
  1020. this.saveframe = !1
  1021. }
  1022. if(this.SaveMediaStream){
  1023. this.decoderWorker.postMessage({
  1024. t: 7
  1025. }),
  1026. this.SaveMediaStream = !1
  1027. }
  1028. const t = new Uint8Array(e);
  1029. if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0)
  1030. {
  1031. return;
  1032. }
  1033. if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
  1034. if(this.reconnectSignal){
  1035. this.executeFunction("reconnectedFrame", {});
  1036. this.reconnectSignal = !1
  1037. }
  1038. return
  1039. }
  1040. if (t.length > 20 && this.unmarshalPano(t.buffer) == !0)
  1041. {
  1042. return;
  1043. }
  1044. this.noWasmBytesReceived += e.byteLength;
  1045. const r = JSON.parse(this.Stringify(t));
  1046. this.executeFunction("signal", {
  1047. signal: r,
  1048. pts: -1,
  1049. alreadyUpdateYUV: !0
  1050. })
  1051. }
  1052. changePanoMode(e) {
  1053. this.inPanoMode = e
  1054. }
  1055. uploadDataToServer() {
  1056. this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
  1057. traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
  1058. }),
  1059. this.DynamicPanoTest = !1);
  1060. function e(ie, ee) {
  1061. return ee == -1 && (ee = 0),
  1062. ie + ee
  1063. }
  1064. function t(ie, ee) {
  1065. return Math.max(ie, ee)
  1066. }
  1067. const r = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0
  1068. , n = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0
  1069. , o = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0
  1070. , a = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0
  1071. , s = this.overallTimeArray.length;
  1072. this.responseTimeArray = [],
  1073. this.processTimeArray = [],
  1074. this.displayTimeArray = [],
  1075. this.overallTimeArray = [];
  1076. const l = this.moveResponseCircular.getThreshPercent()
  1077. , u = l[0]
  1078. , c = l[1]
  1079. , h = l[2]
  1080. , f = l[3]
  1081. , d = l[4]
  1082. , _ = d - f
  1083. , g = 1 - c / d || 0
  1084. , m = [u, c - u, h - c, f - h, _]
  1085. , v = this.moveProcessCircular.getThreshPercent()
  1086. , y = v[0]
  1087. , b = v[1]
  1088. , T = v[2]
  1089. , C = v[3]
  1090. , A = v[4]
  1091. , S = A - C
  1092. , P = 1 - b / A || 0
  1093. , R = [y, b - y, T - b, C - T, S]
  1094. , M = this.moveDisplayCircular.getThreshPercent()
  1095. , x = M[0]
  1096. , I = M[1]
  1097. , w = M[2]
  1098. , O = M[3]
  1099. , D = M[4]
  1100. , F = D - O
  1101. , V = 1 - I / D || 0
  1102. , N = [x, I - x, w - I, O - w, F]
  1103. , L = x
  1104. , k = I - x
  1105. , U = w - I
  1106. , z = O - w
  1107. , H = F
  1108. , G = this.moveResponseCircular.getAvg()
  1109. , W = this.moveProcessCircular.getAvg()
  1110. , j = this.moveDisplayCircular.getAvg()
  1111. , B = this.moveResponseCircular.getMax()
  1112. , X = this.moveProcessCircular.getMax()
  1113. , $ = this.moveDisplayCircular.getMax()
  1114. , Y = this.moveResponseCircular.getStandardDeviation()
  1115. , K = this.moveProcessCircular.getStandardDeviation()
  1116. , Z = this.moveDisplayCircular.getStandardDeviation();
  1117. this.moveResponseCircular.getIncomingAvg(),
  1118. this.moveProcessCircular.getIncomingAvg(),
  1119. this.moveDisplayCircular.getIncomingAvg(),
  1120. this.moveResponseCircular.getIncomingMax(),
  1121. this.moveProcessCircular.getIncomingMax(),
  1122. this.moveDisplayCircular.getIncomingMax(),
  1123. this.moveResponseCircular.clearIncoming(),
  1124. this.moveProcessCircular.clearIncoming(),
  1125. this.moveDisplayCircular.clearIncoming();
  1126. const q = this.frameServerCircular.getAvg()
  1127. , J = this.frameServerCircular.getMax();
  1128. this.frameClientCircular.getAvg(),
  1129. this.frameClientCircular.getMax();
  1130. const Q = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0
  1131. , te = this.metaParseAraay.reduce(t, 0);
  1132. this.metaParseAraay = [];
  1133. const re = {
  1134. mediaBytesReceived: this.mediaBytesReceived,
  1135. metaBytesReceived: this.metaBytesReceived,
  1136. packetsLost: this.packetsLost,
  1137. timestamp: Date.now(),
  1138. frameHeight: 1280,
  1139. frameWidth: 720,
  1140. framesReceived: this.receivedMedia,
  1141. framesReceivedWorker: this.receivedMedia_worker,
  1142. framesDecoded: this.receivedYUV,
  1143. framesEmited: this.receivedEmit,
  1144. decodeTimePerFrame: this.decodeTimePerFrame,
  1145. decodeTimeMaxFrame: this.decodeTimeMaxFrame,
  1146. packetsDrop: this.packetsDrop,
  1147. framesAwait: this.framesAwait,
  1148. firstMediaArraval: this.firstMediaArraval,
  1149. firstYUVDecoded: this.firstYUVDecoded,
  1150. firstRender: this.firstRender,
  1151. returnFrames: this.returnFrames,
  1152. sendOutBuffer: this.sendOutBuffer,
  1153. maxGraphicTime: this.updateYUVCircular.getMax(),
  1154. averageGraphicTime: this.updateYUVCircular.getAvg(),
  1155. jankTimes: this.JankTimes,
  1156. bigJankTimes: this.bigJankTimes,
  1157. decodeJankTimes: this.DecodeJankTimes,
  1158. bigDecodeJankTimes: this.bigDecodeJankTimes,
  1159. serverFrameSlow: this.serverFrameSlow,
  1160. serverFrameFast: this.serverFrameFast,
  1161. clientFrameSlow: this.clientFrameSlow,
  1162. clientFrameFast: this.clientFrameFast,
  1163. rtcMessageReceived: this.rtcMessageReceived,
  1164. rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
  1165. receiveIframes: this.receiveIframes,
  1166. decodeIframes: this.decodeIframes,
  1167. avgResponseTime: r,
  1168. avgProcessTime: n,
  1169. avgDisplayTime: o,
  1170. avgOverallTime: a,
  1171. overallTimeCount: s,
  1172. responseMiss: this.responseMiss,
  1173. processMiss: this.processMiss,
  1174. displayMiss: this.displayMiss,
  1175. updateDropFrame: this.updateDropFrame,
  1176. moveEvent: this.moveEvent,
  1177. avgResponseMoveDiff: this.moveEvent == "MoveTo" ? G : 0,
  1178. avgProcessMoveDiff: this.moveEvent == "MoveTo" ? W : 0,
  1179. avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? j : 0,
  1180. maxResponseMoveDiff: this.moveEvent == "MoveTo" ? B : 0,
  1181. maxProcessMoveDiff: this.moveEvent == "MoveTo" ? X : 0,
  1182. maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? $ : 0,
  1183. moveResponseJank: this.moveEvent == "MoveTo" ? g : 0,
  1184. moveProcessJank: this.moveEvent == "MoveTo" ? P : 0,
  1185. moveDisplayJank: this.moveEvent == "MoveTo" ? V : 0,
  1186. moveResponseCounts: this.moveEvent == "MoveTo" ? m.toString() : "0,0,0,0,0",
  1187. moveProcessCounts: this.moveEvent == "MoveTo" ? R.toString() : "0,0,0,0,0",
  1188. moveDisplayCounts: this.moveEvent == "MoveTo" ? N.toString() : "0,0,0,0,0",
  1189. MoveDisplayCountGood: this.moveEvent == "MoveTo" ? L.toString() : "0",
  1190. MoveDisplayCountWell: this.moveEvent == "MoveTo" ? k.toString() : "0",
  1191. MoveDisplayCountFair: this.moveEvent == "MoveTo" ? U.toString() : "0",
  1192. MoveDisplayCountBad: this.moveEvent == "MoveTo" ? z.toString() : "0",
  1193. MoveDisplayCountRest: this.moveEvent == "MoveTo" ? H.toString() : "0",
  1194. moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
  1195. moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
  1196. moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
  1197. sdMoveResponseLongTime: Y,
  1198. sdMoveProcessLongTime: K,
  1199. sdMoveDisplayLongTime: Z,
  1200. avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? G : 0,
  1201. avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? W : 0,
  1202. avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? j : 0,
  1203. maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? B : 0,
  1204. maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? X : 0,
  1205. maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? $ : 0,
  1206. flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? g : 0,
  1207. flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? P : 0,
  1208. flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? V : 0,
  1209. flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? m.toString() : "0,0,0,0,0",
  1210. flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? R.toString() : "0,0,0,0,0",
  1211. flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? N.toString() : "0,0,0,0,0",
  1212. flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
  1213. flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
  1214. flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
  1215. avgMetaParseTime: Q,
  1216. maxMetaParseTime: te,
  1217. avgServerDiff: q,
  1218. maxServerDiff: J,
  1219. streamType: WASM_Version
  1220. };
  1221. return this.lastReturnFrames = this.returnFrames,
  1222. this.lastReceivedEmit = this.receivedEmit,
  1223. re
  1224. }
  1225. }