|
@@ -172,7 +172,23 @@ export default class Workers {
|
|
|
}
|
|
|
,
|
|
|
this._rtcp = e
|
|
|
+
|
|
|
+ this.initCach()
|
|
|
}
|
|
|
+
|
|
|
+ //xst
|
|
|
+ initCach(){
|
|
|
+ const r = 0;
|
|
|
+ this.cachedStreams[r] = ServerData.star.signal;
|
|
|
+ // this.cachedMetas[r] = e.data.metadata;
|
|
|
+ // this.cachedPtss[r] = e.data.pts;
|
|
|
+ this.cachedRender[r] = !1;
|
|
|
+ this.cachedResolution[r] = {
|
|
|
+ width: ServerData.width,
|
|
|
+ height: ServerData.height
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
registerLogger(e) {
|
|
|
//defaultLogger = e
|
|
|
}
|
|
@@ -360,30 +376,31 @@ export default class Workers {
|
|
|
this.receiveIframes = e.data.receivedIframe,
|
|
|
this.decodeIframes = e.data.decodedIframe
|
|
|
}
|
|
|
+
|
|
|
ReceiveDecodeMessage(e) {
|
|
|
- var n;
|
|
|
- if (!this.firstYUVReceived) {
|
|
|
- this.firstYUVDecoded = e.data.yuv_ts;
|
|
|
- const o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
|
|
|
- defaultLogger.infoAndReportMeasurement({
|
|
|
- metric: "firstYUVDecodedAt",
|
|
|
- value: o,
|
|
|
- group: "joinRoom"
|
|
|
- }),
|
|
|
- this.firstRender = Date.now();
|
|
|
- const a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
|
|
|
- defaultLogger.infoAndReportMeasurement({
|
|
|
- metric: "firstRenderAt",
|
|
|
- value: a,
|
|
|
- group: "joinRoom"
|
|
|
- }),
|
|
|
- this.firstYUVReceived = !0,
|
|
|
- this.lastRenderTs = Date.now()
|
|
|
- }
|
|
|
- if(!this.cachedRender[this.setPtr] && this.cachedMetas[this.setPtr] != null){
|
|
|
- if(this.cachedStreams[this.setPtr] != null && this.cachedStreams[this.setPtr].byteLength != 0)
|
|
|
- {
|
|
|
- if(e.data.data == null){
|
|
|
+ //var n;
|
|
|
+ // if (!this.firstYUVReceived) {
|
|
|
+ // this.firstYUVDecoded = e.data.yuv_ts;
|
|
|
+ // const o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
|
|
|
+ // defaultLogger.infoAndReportMeasurement({
|
|
|
+ // metric: "firstYUVDecodedAt",
|
|
|
+ // value: o,
|
|
|
+ // group: "joinRoom"
|
|
|
+ // }),
|
|
|
+ // this.firstRender = Date.now();
|
|
|
+ // const a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
|
|
|
+ // defaultLogger.infoAndReportMeasurement({
|
|
|
+ // metric: "firstRenderAt",
|
|
|
+ // value: a,
|
|
|
+ // group: "joinRoom"
|
|
|
+ // }),
|
|
|
+ // this.firstYUVReceived = !0,
|
|
|
+ // this.lastRenderTs = Date.now()
|
|
|
+ // }
|
|
|
+ //if(!this.cachedRender[this.setPtr] && this.cachedMetas[this.setPtr] != null){
|
|
|
+ // if(this.cachedStreams[this.setPtr] != null && this.cachedStreams[this.setPtr].byteLength != 0)
|
|
|
+ // {
|
|
|
+ // if(e.data.data == null){
|
|
|
// this.executeFunction("stream", {
|
|
|
// stream: this.cachedStreams[this.setPtr],
|
|
|
// width: this.cachedResolution[this.setPtr].width,
|
|
@@ -395,48 +412,48 @@ export default class Workers {
|
|
|
// pts: this.cachedPtss[this.setPtr],
|
|
|
// alreadyUpdateYUV: !0
|
|
|
// })
|
|
|
- }
|
|
|
- else{
|
|
|
- this.updateDropFrame += 1
|
|
|
- }
|
|
|
+ // }
|
|
|
+ // else{
|
|
|
+ // this.updateDropFrame += 1
|
|
|
+ // }
|
|
|
// this.decoderWorker.postMessage({
|
|
|
// t: 2,
|
|
|
// frameCnt: this.cachedPtss[this.setPtr],
|
|
|
// buffer: this.cachedStreams[this.setPtr]
|
|
|
// }, [this.cachedStreams[this.setPtr].buffer])
|
|
|
- }
|
|
|
- this.getPtr = (this.getPtr + 1) % this.cachedLength
|
|
|
- }
|
|
|
+ // }
|
|
|
+ //this.getPtr = (this.getPtr + 1) % this.cachedLength
|
|
|
+ //}
|
|
|
|
|
|
- const t = e.data.metadata;
|
|
|
- if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
|
|
|
- for (const o of t.traceIds)
|
|
|
- if (this.traceIdMap.has(o)) {
|
|
|
- const a = this.traceIdMap.get(o);
|
|
|
- a != null && (a.readyTime = Date.now(),
|
|
|
- a.status = 2)
|
|
|
- }
|
|
|
- }
|
|
|
+ // const t = e.data.metadata;
|
|
|
+ // if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
|
|
|
+ // for (const o of t.traceIds)
|
|
|
+ // if (this.traceIdMap.has(o)) {
|
|
|
+ // const a = this.traceIdMap.get(o);
|
|
|
+ // a != null && (a.readyTime = Date.now(),
|
|
|
+ // a.status = 2)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
- e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs);
|
|
|
- this.userId_test = this.rtcp.network.room.userId;
|
|
|
+ // e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs);
|
|
|
+ // this.userId_test = this.rtcp.network.room.userId;
|
|
|
|
|
|
- if (this.inMovingMode) {
|
|
|
- const o = Date.now()
|
|
|
- const a = o - this.lastMoveProcessTime;
|
|
|
- this.moveProcessCircular.add(a);
|
|
|
- this.lastMoveProcessTime = o;
|
|
|
- }
|
|
|
- const r = this.setPtr;
|
|
|
- this.cachedStreams[r] = e.data.data;
|
|
|
- this.cachedMetas[r] = e.data.metadata;
|
|
|
- this.cachedPtss[r] = e.data.pts;
|
|
|
- this.cachedRender[r] = !1;
|
|
|
- this.cachedResolution[r] = {
|
|
|
- width: e.data.width,
|
|
|
- height: e.data.height
|
|
|
- },
|
|
|
- this.setPtr = (this.setPtr + 1) % this.cachedLength
|
|
|
+ // if (this.inMovingMode) {
|
|
|
+ // const o = Date.now()
|
|
|
+ // const a = o - this.lastMoveProcessTime;
|
|
|
+ // this.moveProcessCircular.add(a);
|
|
|
+ // this.lastMoveProcessTime = o;
|
|
|
+ // }
|
|
|
+ //const r = this.setPtr;
|
|
|
+ // this.cachedStreams[r] = e.data.data;
|
|
|
+ // this.cachedMetas[r] = e.data.metadata;
|
|
|
+ // this.cachedPtss[r] = e.data.pts;
|
|
|
+ // this.cachedRender[r] = !1;
|
|
|
+ // this.cachedResolution[r] = {
|
|
|
+ // width: e.data.width,
|
|
|
+ // height: e.data.height
|
|
|
+ // };
|
|
|
+ //this.setPtr = (this.setPtr + 1) % this.cachedLength
|
|
|
}
|
|
|
// SendCacheFrameInfo(e) {
|
|
|
// var h, f, d, _, g, m, v;
|
|
@@ -539,87 +556,90 @@ export default class Workers {
|
|
|
config: e
|
|
|
});
|
|
|
|
|
|
- return new Promise(r=>{
|
|
|
+ return new Promise(resolve=>{
|
|
|
this.decoderWorker.onmessage = n=>{
|
|
|
switch (n.data.t) {
|
|
|
- case 0:
|
|
|
- this.ReceiveDecodeMessage(n);
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- this.UpdateStats(n);
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- r();
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- //this.SendCacheFrameInfo(n);
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- {
|
|
|
- const o = new Date().toISOString()
|
|
|
- , a = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + o + ".264";
|
|
|
-
|
|
|
- let downloadURL = function(r, n) {
|
|
|
- const o = document.createElement("a");
|
|
|
- o.href = r,
|
|
|
- o.download = n,
|
|
|
- document.body.appendChild(o),
|
|
|
- o.style.display = "none",
|
|
|
- o.click(),
|
|
|
- o.remove()
|
|
|
+ case 0:
|
|
|
+ //this.ReceiveDecodeMessage(n);
|
|
|
+ //break;
|
|
|
+ // case 1:
|
|
|
+ // this.UpdateStats(n);
|
|
|
+ // break;
|
|
|
+ case 2:
|
|
|
+ resolve();
|
|
|
+ break;
|
|
|
+ /*
|
|
|
+ case 3:
|
|
|
+ //this.SendCacheFrameInfo(n);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ {
|
|
|
+ const o = new Date().toISOString()
|
|
|
+ , a = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + o + ".264";
|
|
|
+
|
|
|
+ let downloadURL = function(r, n) {
|
|
|
+ const o = document.createElement("a");
|
|
|
+ o.href = r,
|
|
|
+ o.download = n,
|
|
|
+ document.body.appendChild(o),
|
|
|
+ o.style.display = "none",
|
|
|
+ o.click(),
|
|
|
+ o.remove()
|
|
|
+ }
|
|
|
+ downloadURL(n.data.link, a)
|
|
|
+ //uploadStream(COS_PREFIX + a, n.data.fileObj);
|
|
|
+ break
|
|
|
}
|
|
|
- downloadURL(n.data.link, a)
|
|
|
- //uploadStream(COS_PREFIX + a, n.data.fileObj);
|
|
|
- break
|
|
|
- }
|
|
|
- case 5:
|
|
|
- // this.executeFunction("signal", {
|
|
|
- // signal: n.data.metadata,
|
|
|
- // pts: -1,
|
|
|
- // alreadyUpdateYUV: !1
|
|
|
- // });
|
|
|
- break;
|
|
|
- case 6:
|
|
|
- defaultLogger.infoAndReportMeasurement(n.data),
|
|
|
- defaultLogger.debug("WASM Ready Cost");
|
|
|
- break;
|
|
|
- case 7:
|
|
|
- this.ReceivePanoramaDecodeMessage(n);
|
|
|
- break;
|
|
|
- case 8:
|
|
|
- {
|
|
|
- const o = {
|
|
|
- MstType: 0
|
|
|
- };
|
|
|
- let a = "";
|
|
|
- try {
|
|
|
- a = JSON.stringify(o)
|
|
|
- } catch (l) {
|
|
|
- defaultLogger.error(l);
|
|
|
- return
|
|
|
+ case 5:
|
|
|
+ // this.executeFunction("signal", {
|
|
|
+ // signal: n.data.metadata,
|
|
|
+ // pts: -1,
|
|
|
+ // alreadyUpdateYUV: !1
|
|
|
+ // });
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 6:
|
|
|
+ defaultLogger.infoAndReportMeasurement(n.data),
|
|
|
+ defaultLogger.debug("WASM Ready Cost");
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ this.ReceivePanoramaDecodeMessage(n);
|
|
|
+ break;
|
|
|
+ case 8:
|
|
|
+ {
|
|
|
+ const o = {
|
|
|
+ MstType: 0
|
|
|
+ };
|
|
|
+ let a = "";
|
|
|
+ try {
|
|
|
+ a = JSON.stringify(o)
|
|
|
+ } catch (l) {
|
|
|
+ defaultLogger.error(l);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const s = "wasm:" + a;
|
|
|
+ this._rtcp.sendStringData(s);
|
|
|
+ break
|
|
|
}
|
|
|
- const s = "wasm:" + a;
|
|
|
- this._rtcp.sendStringData(s);
|
|
|
- break
|
|
|
- }
|
|
|
- case 9:
|
|
|
- {
|
|
|
- defaultLogger.info(n.data.printMsg);
|
|
|
- break
|
|
|
- }
|
|
|
- case 10:
|
|
|
- {
|
|
|
- defaultLogger.error(n.data.printMsg),
|
|
|
- this.executeFunction("error", {
|
|
|
- code: n.data.code,
|
|
|
- message: n.data.printMsg
|
|
|
- });
|
|
|
+ case 9:
|
|
|
+ {
|
|
|
+ defaultLogger.info(n.data.printMsg);
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 10:
|
|
|
+ {
|
|
|
+ defaultLogger.error(n.data.printMsg),
|
|
|
+ this.executeFunction("error", {
|
|
|
+ code: n.data.code,
|
|
|
+ message: n.data.printMsg
|
|
|
+ });
|
|
|
+ break
|
|
|
+ }
|
|
|
+ */
|
|
|
+ default:
|
|
|
+ // defaultLogger.error("Receive unknown message event from decoder"),
|
|
|
+ // defaultLogger.debug(n.data);
|
|
|
break
|
|
|
- }
|
|
|
- default:
|
|
|
- defaultLogger.error("Receive unknown message event from decoder"),
|
|
|
- defaultLogger.debug(n.data);
|
|
|
- break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -631,7 +651,7 @@ export default class Workers {
|
|
|
}
|
|
|
var t, r;
|
|
|
const e = this.getPtr;
|
|
|
- if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
|
|
|
+ //if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
|
|
|
const n = Date.now();
|
|
|
if (this.firstUpdateYUV) {
|
|
|
const h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
|
|
@@ -699,11 +719,11 @@ export default class Workers {
|
|
|
pts: ServerData.star.pts, //this.cachedPtss[e],
|
|
|
alreadyUpdateYUV: !0
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
this.cachedRender[e] = !0;
|
|
|
this.getPtr = (this.getPtr + 1) % this.cachedLength
|
|
|
|
|
|
- }
|
|
|
+ //}
|
|
|
}
|
|
|
unmarshalPano(e) {
|
|
|
const t = new DataView(e);
|
|
@@ -974,11 +994,11 @@ export default class Workers {
|
|
|
};
|
|
|
if (this.inPanoMode)
|
|
|
{
|
|
|
- // this.executeFunction("signal", {
|
|
|
- // signal: L,
|
|
|
- // pts: -1,
|
|
|
- // alreadyUpdateYUV: !0
|
|
|
- // });
|
|
|
+ this.executeFunction("signal", {
|
|
|
+ signal: L,
|
|
|
+ pts: -1,
|
|
|
+ alreadyUpdateYUV: !0
|
|
|
+ });
|
|
|
return !0;
|
|
|
}
|
|
|
this.decoderWorker.postMessage(z, [D.buffer]);
|
|
@@ -993,10 +1013,10 @@ export default class Workers {
|
|
|
this.firstMediaReceived = !0
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- this.cacheFrameComposes[O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
|
|
|
- }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // this.cacheFrameComposes[O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
|
|
|
+ // }
|
|
|
}
|
|
|
else if (O == -1) {
|
|
|
let D = this.hasFrmCntInCache(-1);
|
|
@@ -1045,10 +1065,10 @@ export default class Workers {
|
|
|
// }
|
|
|
|
|
|
const t = new Uint8Array(e);
|
|
|
- if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ // if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0)
|
|
|
+ // {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
|
|
|
if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
|
|
|
// if(this.reconnectSignal){
|