|
@@ -379,23 +379,34 @@ export default class Workers {
|
|
|
this.firstYUVReceived = !0,
|
|
|
this.lastRenderTs = Date.now()
|
|
|
}
|
|
|
- !this.cachedRender[this.setPtr] && this.cachedMetas[this.setPtr] != null && (this.cachedStreams[this.setPtr] != null && this.cachedStreams[this.setPtr].byteLength != 0 && (e.data.data == null ? (this.executeFunction("stream", {
|
|
|
- stream: this.cachedStreams[this.setPtr],
|
|
|
- width: this.cachedResolution[this.setPtr].width,
|
|
|
- height: this.cachedResolution[this.setPtr].height,
|
|
|
- pts: this.cachedPtss[this.setPtr]
|
|
|
- }),
|
|
|
- this.executeFunction("signal", {
|
|
|
- signal: this.cachedMetas[this.setPtr],
|
|
|
- pts: this.cachedPtss[this.setPtr],
|
|
|
- alreadyUpdateYUV: !0
|
|
|
- })) : 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);
|
|
|
+ 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,
|
|
|
+ height: this.cachedResolution[this.setPtr].height,
|
|
|
+ pts: this.cachedPtss[this.setPtr]
|
|
|
+ }),
|
|
|
+ this.executeFunction("signal", {
|
|
|
+ signal: this.cachedMetas[this.setPtr],
|
|
|
+ pts: this.cachedPtss[this.setPtr],
|
|
|
+ alreadyUpdateYUV: !0
|
|
|
+ })
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
const t = e.data.metadata;
|
|
|
if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
|
|
|
for (const o of t.traceIds)
|
|
@@ -405,19 +416,21 @@ export default class Workers {
|
|
|
a.status = 2)
|
|
|
}
|
|
|
}
|
|
|
- if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs),
|
|
|
- this.userId_test = this.rtcp.network.room.userId,
|
|
|
- this.inMovingMode) {
|
|
|
+
|
|
|
+ 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()
|
|
|
- , a = o - this.lastMoveProcessTime;
|
|
|
- this.moveProcessCircular.add(a),
|
|
|
- this.lastMoveProcessTime = o
|
|
|
+ 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.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
|
|
@@ -775,7 +788,9 @@ export default class Workers {
|
|
|
var T, C, A, S, P, R, M, x, I, w;
|
|
|
const t = new DataView(e);
|
|
|
if (t.getUint32(0) != 1437227610)
|
|
|
+ {
|
|
|
return !1;
|
|
|
+ }
|
|
|
t.getUint16(4);
|
|
|
const n = t.getUint16(6)
|
|
|
, o = t.getUint16(8)
|
|
@@ -796,8 +811,10 @@ export default class Workers {
|
|
|
this.calcSendTimeDiff(h);
|
|
|
let b;
|
|
|
if (this.inPanoMode && (c > 0 || f))
|
|
|
- return defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode"),
|
|
|
- !0;
|
|
|
+ {
|
|
|
+ defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode")
|
|
|
+ return !0;
|
|
|
+ }
|
|
|
if (v === m) {
|
|
|
this.receivedMedia++;
|
|
|
const O = new Uint8Array(e).subarray(n);
|
|
@@ -806,33 +823,43 @@ export default class Workers {
|
|
|
D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
|
|
|
const F = c === 0
|
|
|
, V = h - this.lastServerTS;
|
|
|
- this.lastServerTS != 0 && ((o + 65536 - this.lastSeq) % 65536 === 1 && this.lastIsPureMeta == F && (F ? this.srvMetaIntervalCircular.add(V) : this.srvMediaIntervalCircular.add(V)),
|
|
|
- this.frameServerCircular.add(V),
|
|
|
- this.frameClientCircular.add(D - this.lastClientTS)),
|
|
|
- this.lastSeq = o,
|
|
|
- this.lastIsPureMeta = F,
|
|
|
- this.lastServerTS = h,
|
|
|
+ if(this.lastServerTS != 0)
|
|
|
+ {
|
|
|
+ if((o + 65536 - this.lastSeq) % 65536 === 1 && this.lastIsPureMeta == F){
|
|
|
+ F ? this.srvMetaIntervalCircular.add(V) : this.srvMediaIntervalCircular.add(V)
|
|
|
+ }
|
|
|
+
|
|
|
+ this.frameServerCircular.add(V);
|
|
|
+ this.frameClientCircular.add(D - this.lastClientTS);
|
|
|
+ }
|
|
|
+ this.lastSeq = o;
|
|
|
+ this.lastIsPureMeta = F;
|
|
|
+ this.lastServerTS = h;
|
|
|
this.lastClientTS = D;
|
|
|
const N = O.subarray(0, u)
|
|
|
, L = Date.now()
|
|
|
, k = JSON.parse(this.Stringify(N))
|
|
|
, U = Date.now();
|
|
|
- this.showAllReceivedMetadata && console.log(h, D, k),
|
|
|
- this.metaParseAraay.push(U - L),
|
|
|
- (T = k.traceIds) != null && T.length && this.processMetaWithTraceId(k),
|
|
|
- c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o),
|
|
|
- this.moveStartPts == o && (this.MoveResponseDelay = Date.now() - this.StartMovingTs,
|
|
|
- console.log("move response delay: ", o, this.moveStartPts, this.MoveResponseDelay));
|
|
|
+ this.showAllReceivedMetadata && console.log(h, D, k);
|
|
|
+ this.metaParseAraay.push(U - L);
|
|
|
+ (T = k.traceIds) != null && T.length && this.processMetaWithTraceId(k);
|
|
|
+ c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o);
|
|
|
+ if(this.moveStartPts == o){
|
|
|
+ this.MoveResponseDelay = Date.now() - this.StartMovingTs;
|
|
|
+ console.log("move response delay: ", o, this.moveStartPts, this.MoveResponseDelay)
|
|
|
+ }
|
|
|
const z = this.getIsMoving(k);
|
|
|
- if (this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray(),
|
|
|
- typeof z != "undefined" && (this.lastIsMoving = z),
|
|
|
- this.inMovingMode) {
|
|
|
+ this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray();
|
|
|
+ typeof z != "undefined" && (this.lastIsMoving = z);
|
|
|
+ if (this.inMovingMode) {
|
|
|
const G = Date.now()
|
|
|
, W = G - this.lastMoveResponseTime;
|
|
|
- this.moveResponseCircular.add(W),
|
|
|
- this.lastMoveResponseTime = G
|
|
|
+ this.moveResponseCircular.add(W);
|
|
|
+ this.lastMoveResponseTime = G;
|
|
|
+ }
|
|
|
+ if(f || d){
|
|
|
+ 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
|
|
|
}
|
|
|
- (f || d) && (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);
|
|
|
const H = {
|
|
|
t: 0,
|
|
|
data: O,
|
|
@@ -848,59 +875,66 @@ export default class Workers {
|
|
|
position: b
|
|
|
};
|
|
|
if (this.inPanoMode)
|
|
|
- return this.executeFunction("signal", {
|
|
|
+ {
|
|
|
+ this.executeFunction("signal", {
|
|
|
signal: k,
|
|
|
pts: -1,
|
|
|
alreadyUpdateYUV: !0
|
|
|
- }),
|
|
|
- !0;
|
|
|
- if (this.decoderWorker.postMessage(H, [O.buffer]),
|
|
|
- !this.firstMediaReceived) {
|
|
|
+ });
|
|
|
+ return !0;
|
|
|
+ }
|
|
|
+ this.decoderWorker.postMessage(H, [O.buffer]);
|
|
|
+ if (!this.firstMediaReceived) {
|
|
|
this.firstMediaArraval = Date.now();
|
|
|
const G = this.firstMediaArraval - this.rtcp.network.room._startTime;
|
|
|
defaultLogger.infoAndReportMeasurement({
|
|
|
metric: "firstMediaArravalAt",
|
|
|
value: G,
|
|
|
group: "joinRoom"
|
|
|
- }),
|
|
|
- this.firstMediaReceived = !0
|
|
|
+ });
|
|
|
+ this.firstMediaReceived = !0;
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
const O = this.hasFrmCntInCache(a);
|
|
|
if (O != -1)
|
|
|
- if (this.cacheFrameComposes[O].buffer.set(y, g),
|
|
|
- this.cacheFrameComposes[O].size += v,
|
|
|
- this.cacheFrameComposes[O].size === m) {
|
|
|
+ {
|
|
|
+ this.cacheFrameComposes[O].buffer.set(y, g);
|
|
|
+ this.cacheFrameComposes[O].size += v;
|
|
|
+ if (this.cacheFrameComposes[O].size === m) {
|
|
|
const D = new Uint8Array(this.cacheFrameComposes[O].buffer).slice(0, m);
|
|
|
- this.cacheFrameComposes[O].frameCnt = -1,
|
|
|
- this.cacheFrameComposes[O].size = 0,
|
|
|
- this.cacheFrameComposes[O].startReceiveTime = 0,
|
|
|
- this.cacheFrameComposes[O].serverTime = 0,
|
|
|
- this.receivedMedia++,
|
|
|
+ this.cacheFrameComposes[O].frameCnt = -1;
|
|
|
+ this.cacheFrameComposes[O].size = 0;
|
|
|
+ this.cacheFrameComposes[O].startReceiveTime = 0;
|
|
|
+ this.cacheFrameComposes[O].serverTime = 0;
|
|
|
+ this.receivedMedia++;
|
|
|
h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
|
|
|
const F = Date.now();
|
|
|
- F - this.lastClientTS > 60 ? this.clientFrameSlow++ : F - this.lastClientTS < 16 && this.clientFrameFast++,
|
|
|
- this.lastServerTS != 0 && (this.frameServerCircular.add(h - this.lastServerTS),
|
|
|
- this.frameClientCircular.add(F - this.lastClientTS)),
|
|
|
- this.lastServerTS = h,
|
|
|
+ F - this.lastClientTS > 60 ? this.clientFrameSlow++ : F - this.lastClientTS < 16 && this.clientFrameFast++;
|
|
|
+ if(this.lastServerTS != 0)
|
|
|
+ {
|
|
|
+ this.frameServerCircular.add(h - this.lastServerTS);
|
|
|
+ this.frameClientCircular.add(F - this.lastClientTS);
|
|
|
+ }
|
|
|
+ this.lastServerTS = h;
|
|
|
this.lastClientTS = F;
|
|
|
const V = D.subarray(0, u)
|
|
|
, N = Date.now()
|
|
|
, L = JSON.parse(this.Stringify(V))
|
|
|
, k = Date.now();
|
|
|
- this.showAllReceivedMetadata && console.log(h, F, L),
|
|
|
- this.metaParseAraay.push(k - N),
|
|
|
- (R = L.traceIds) != null && R.length && this.processMetaWithTraceId(L),
|
|
|
- c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o),
|
|
|
+ this.showAllReceivedMetadata && console.log(h, F, L);
|
|
|
+ this.metaParseAraay.push(k - N);
|
|
|
+ (R = L.traceIds) != null && R.length && this.processMetaWithTraceId(L);
|
|
|
+ c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o);
|
|
|
this.moveStartPts == o && (this.MoveResponseDelay = Date.now() - this.StartMovingTs);
|
|
|
const U = this.getIsMoving(L);
|
|
|
- if (this.inMovingMode && U == 0 && this.lastIsMoving == 1 && this.clearMoveArray(),
|
|
|
- typeof U != "undefined" && (this.lastIsMoving = U),
|
|
|
- this.inMovingMode) {
|
|
|
+ this.inMovingMode && U == 0 && this.lastIsMoving == 1 && this.clearMoveArray();
|
|
|
+ typeof U != "undefined" && (this.lastIsMoving = U);
|
|
|
+ if (this.inMovingMode) {
|
|
|
const H = Date.now()
|
|
|
, G = H - this.lastMoveResponseTime;
|
|
|
- this.moveResponseCircular.add(G),
|
|
|
- this.lastMoveResponseTime = H
|
|
|
+ this.moveResponseCircular.add(G);
|
|
|
+ this.lastMoveResponseTime = H;
|
|
|
}
|
|
|
(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);
|
|
|
const z = {
|
|
@@ -918,14 +952,16 @@ export default class Workers {
|
|
|
position: b
|
|
|
};
|
|
|
if (this.inPanoMode)
|
|
|
- return this.executeFunction("signal", {
|
|
|
+ {
|
|
|
+ this.executeFunction("signal", {
|
|
|
signal: L,
|
|
|
pts: -1,
|
|
|
alreadyUpdateYUV: !0
|
|
|
- }),
|
|
|
- !0;
|
|
|
- if (this.decoderWorker.postMessage(z, [D.buffer]),
|
|
|
- !this.firstMediaReceived) {
|
|
|
+ });
|
|
|
+ return !0;
|
|
|
+ }
|
|
|
+ this.decoderWorker.postMessage(z, [D.buffer]);
|
|
|
+ if (!this.firstMediaReceived) {
|
|
|
this.firstMediaArraval = Date.now();
|
|
|
const H = this.firstMediaArraval - this.rtcp.network.room._startTime;
|
|
|
defaultLogger.infoAndReportMeasurement({
|
|
@@ -935,8 +971,12 @@ export default class Workers {
|
|
|
}),
|
|
|
this.firstMediaReceived = !0
|
|
|
}
|
|
|
- } else
|
|
|
+ }
|
|
|
+ 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);
|
|
|
if (D == -1) {
|
|
@@ -947,11 +987,11 @@ export default class Workers {
|
|
|
V = N);
|
|
|
D = V
|
|
|
}
|
|
|
- this.cacheFrameComposes[D].buffer.set(y, g),
|
|
|
- this.cacheFrameComposes[D].size = v,
|
|
|
- this.cacheFrameComposes[D].frameCnt = a,
|
|
|
- this.cacheFrameComposes[D].startReceiveTime = Date.now(),
|
|
|
- this.cacheFrameComposes[D].serverTime = h
|
|
|
+ this.cacheFrameComposes[D].buffer.set(y, g);
|
|
|
+ this.cacheFrameComposes[D].size = v;
|
|
|
+ this.cacheFrameComposes[D].frameCnt = a;
|
|
|
+ this.cacheFrameComposes[D].startReceiveTime = Date.now();
|
|
|
+ this.cacheFrameComposes[D].serverTime = h;
|
|
|
}
|
|
|
}
|
|
|
return !0
|
|
@@ -981,8 +1021,10 @@ export default class Workers {
|
|
|
if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0)
|
|
|
return;
|
|
|
if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
|
|
|
- this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}),
|
|
|
- this.reconnectSignal = !1);
|
|
|
+ if(this.reconnectSignal){
|
|
|
+ this.executeFunction("reconnectedFrame", {});
|
|
|
+ this.reconnectSignal = !1
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
if (t.length > 20 && this.unmarshalPano(t.buffer) == !0)
|