Workers.js 50 KB

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