|
@@ -423,8 +423,8 @@ export default class Workers {
|
|
|
var b;
|
|
|
const i = Date.now()
|
|
|
, o = i - e.data.postTs;
|
|
|
- if (this.postMessageWaitArray.add(o),
|
|
|
- !this.firstYUVReceived) {
|
|
|
+ this.postMessageWaitArray.add(o);
|
|
|
+ if (!this.firstYUVReceived) {
|
|
|
this.firstYUVDecoded = e.data.yuv_ts;
|
|
|
const k = this.firstYUVDecoded - this.rtcp.network.room._startTime;
|
|
|
defaultLogger.infoAndReportMeasurement({
|
|
@@ -442,54 +442,66 @@ 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 s = e.data.metadata;
|
|
|
if ((b = s == null ? void 0 : s.traceIds) != null && b.length)
|
|
|
for (const k of s.traceIds) {
|
|
|
if (this.traceIdMap.has(k)) {
|
|
|
const j = this.traceIdMap.get(k);
|
|
|
- j != null && (j.readyTime = Date.now(),
|
|
|
- j.status = 2)
|
|
|
+ j != null && (j.readyTime = Date.now(),j.status = 2)
|
|
|
}
|
|
|
if (this.joyStickTraceIdMap.has(k)) {
|
|
|
const j = this.joyStickTraceIdMap.get(k);
|
|
|
- j != null && (j.readyTime = Date.now(),
|
|
|
- j.status = 2)
|
|
|
+ j != null && (j.readyTime = Date.now(),j.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 k = Date.now()
|
|
|
, j = k - this.lastMoveProcessTime;
|
|
|
this.moveProcessCircular.add(j),
|
|
|
this.lastMoveProcessTime = k
|
|
|
}
|
|
|
const c = this.setPtr;
|
|
|
- this.cachedStreams[c] = e.data.data,
|
|
|
- this.cachedMetas[c] = e.data.metadata,
|
|
|
- this.cachedPtss[c] = e.data.pts,
|
|
|
- this.cachedRender[c] = !1,
|
|
|
+ this.cachedStreams[c] = e.data.data;
|
|
|
+ this.cachedMetas[c] = e.data.metadata;
|
|
|
+ this.cachedPtss[c] = e.data.pts;
|
|
|
+ this.cachedRender[c] = !1;
|
|
|
this.cachedResolution[c] = {
|
|
|
width: e.data.width,
|
|
|
height: e.data.height
|
|
|
- },
|
|
|
+ };
|
|
|
this.setPtr = (this.setPtr + 1) % this.cachedLength;
|
|
|
const _ = Date.now() - i;
|
|
|
this.receiveYUVExecutionArray.add(_)
|
|
@@ -582,7 +594,7 @@ export default class Workers {
|
|
|
const i = new Blob([decoder],{
|
|
|
type: "application/javascript"
|
|
|
});
|
|
|
- return this.decoderWorker = new Worker(URL.createObjectURL(i)),
|
|
|
+ this.decoderWorker = new Worker(URL.createObjectURL(i)),
|
|
|
this.decoderWorker.postMessage({
|
|
|
t: 9,
|
|
|
url: WASM_URLS[WASM_Version],
|
|
@@ -591,8 +603,9 @@ export default class Workers {
|
|
|
this.decoderWorker.postMessage({
|
|
|
t: 1,
|
|
|
config: e
|
|
|
- }),
|
|
|
- new Promise(o=>{
|
|
|
+ });
|
|
|
+
|
|
|
+ return new Promise(o=>{
|
|
|
this.decoderWorker.onmessage = s=>{
|
|
|
switch (s.data.t) {
|
|
|
case 0:
|
|
@@ -615,6 +628,7 @@ export default class Workers {
|
|
|
break
|
|
|
}
|
|
|
case 5:
|
|
|
+ console.log('接受webrtc请求(来自worker):'+JSON.stringify(s.data.metadata))
|
|
|
this.executeFunction("signal", {
|
|
|
signal: s.data.metadata,
|
|
|
pts: -1,
|
|
@@ -743,13 +757,15 @@ export default class Workers {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs),
|
|
|
- this.inMovingMode) {
|
|
|
+
|
|
|
+ this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs);
|
|
|
+ if (this.inMovingMode) {
|
|
|
const $ = Date.now()
|
|
|
, _e = $ - this.lastMoveDisplayTime;
|
|
|
this.moveDisplayCircular.add(_e),
|
|
|
this.lastMoveDisplayTime = $
|
|
|
}
|
|
|
+ console.log('接受webrtc请求(定时执行UpdateYUV):'+JSON.stringify(this.cachedMetas[e]))
|
|
|
this.executeFunction("signal", {
|
|
|
signal: this.cachedMetas[e],
|
|
|
pts: this.cachedPtss[e],
|
|
@@ -934,12 +950,15 @@ export default class Workers {
|
|
|
position: st
|
|
|
};
|
|
|
if (this.inPanoMode)
|
|
|
- return this.executeFunction("signal", {
|
|
|
+ {
|
|
|
+ console.log('接受webrtc请求:'+JSON.stringify(Mt));
|
|
|
+ this.executeFunction("signal", {
|
|
|
signal: Mt,
|
|
|
pts: -1,
|
|
|
alreadyUpdateYUV: !0
|
|
|
- }),
|
|
|
- !0;
|
|
|
+ });
|
|
|
+ return !0;
|
|
|
+ }
|
|
|
if (this.decoderWorker.postMessage(Dt, [At.buffer]),
|
|
|
!this.firstMediaReceived) {
|
|
|
this.firstMediaArraval = Date.now();
|
|
@@ -1004,12 +1023,15 @@ export default class Workers {
|
|
|
position: st
|
|
|
};
|
|
|
if (this.inPanoMode)
|
|
|
- return this.executeFunction("signal", {
|
|
|
- signal: Rt,
|
|
|
- pts: -1,
|
|
|
- alreadyUpdateYUV: !0
|
|
|
- }),
|
|
|
- !0;
|
|
|
+ {
|
|
|
+ console.log('接受webrtc请求:'+JSON.stringify(Rt));
|
|
|
+ this.executeFunction("signal", {
|
|
|
+ signal: Rt,
|
|
|
+ pts: -1,
|
|
|
+ alreadyUpdateYUV: !0
|
|
|
+ });
|
|
|
+ return !0;
|
|
|
+ }
|
|
|
if (this.decoderWorker.postMessage(It, [gt.buffer]),
|
|
|
!this.firstMediaReceived) {
|
|
|
this.firstMediaArraval = Date.now();
|
|
@@ -1057,26 +1079,43 @@ export default class Workers {
|
|
|
defaultLogger.debug("hhh")
|
|
|
}
|
|
|
dataHandle(e) {
|
|
|
- this.saveframe && (this.decoderWorker.postMessage({
|
|
|
- t: 6
|
|
|
- }),
|
|
|
- this.saveframe = !1),
|
|
|
- this.SaveMediaStream && (this.decoderWorker.postMessage({
|
|
|
- t: 7
|
|
|
- }),
|
|
|
- this.SaveMediaStream = !1);
|
|
|
+
|
|
|
+ if(this.saveframe){
|
|
|
+ console.log('接受webrtc请求:录制视频')
|
|
|
+ this.decoderWorker.postMessage({
|
|
|
+ t: 6
|
|
|
+ });
|
|
|
+ this.saveframe = !1
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.SaveMediaStream){
|
|
|
+ console.log('接受webrtc请求:下载视频')
|
|
|
+ this.decoderWorker.postMessage({
|
|
|
+ t: 7
|
|
|
+ }),
|
|
|
+ this.SaveMediaStream = !1
|
|
|
+ }
|
|
|
+
|
|
|
const i = new Uint8Array(e);
|
|
|
if (i.length >= 4 && this.isHeartBeatPacket(i.buffer, i.length) == !0)
|
|
|
+ {
|
|
|
+ console.log('接受webrtc请求:心跳')
|
|
|
return;
|
|
|
+ }
|
|
|
if (i.length > 36 && this.unmarshalStream(i.buffer) == !0) {
|
|
|
this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}),
|
|
|
this.reconnectSignal = !1);
|
|
|
+ console.log('接受webrtc请求:视频流')
|
|
|
return
|
|
|
}
|
|
|
if (i.length > 20 && this.unmarshalPano(i.buffer) == !0)
|
|
|
+ {
|
|
|
+ console.log('接受webrtc请求:全景图')
|
|
|
return;
|
|
|
+ }
|
|
|
this.noWasmBytesReceived += e.byteLength;
|
|
|
const o = JSON.parse(this.Stringify(i));
|
|
|
+ console.log('接受webrtc请求:'+JSON.stringify(o));
|
|
|
this.executeFunction("signal", {
|
|
|
signal: o,
|
|
|
pts: -1,
|