|
@@ -173,7 +173,7 @@ if ("function" === typeof importScripts) {
|
|
//end refactor
|
|
//end refactor
|
|
|
|
|
|
Decoder.prototype.resetDecoder = function () {
|
|
Decoder.prototype.resetDecoder = function () {
|
|
- console.log("[xmedia] isFirstFrame 设置 TRUE");
|
|
|
|
|
|
+ //console.log("[xmedia] isFirstFrame 设置 TRUE");
|
|
this.isFirstFrame = 1;
|
|
this.isFirstFrame = 1;
|
|
this.expected_frameCnt = 1;
|
|
this.expected_frameCnt = 1;
|
|
|
|
|
|
@@ -338,7 +338,7 @@ if ("function" === typeof importScripts) {
|
|
if (this.isSlotEmpty(index)) {
|
|
if (this.isSlotEmpty(index)) {
|
|
//lost
|
|
//lost
|
|
// debugger
|
|
// debugger
|
|
- console.log("[xmedia] return on SLOT EMPTY, prev: %s", prevSeq);
|
|
|
|
|
|
+ //console.log("[xmedia] return on SLOT EMPTY, prev: %s", prevSeq);
|
|
this.consumerWaitingIDR = true;
|
|
this.consumerWaitingIDR = true;
|
|
this.consumerPrevPts = this.seqAdd(this.consumerPrevPts, 1, 65536);
|
|
this.consumerPrevPts = this.seqAdd(this.consumerPrevPts, 1, 65536);
|
|
return true;
|
|
return true;
|
|
@@ -347,10 +347,10 @@ if ("function" === typeof importScripts) {
|
|
if (!this.slotHasMedia(index)) {
|
|
if (!this.slotHasMedia(index)) {
|
|
// pure meta
|
|
// pure meta
|
|
// debugger
|
|
// debugger
|
|
- console.log(
|
|
|
|
- "[xmedia] return on meta, prev: %s, cur: %s",
|
|
|
|
- mediaArray[index].pts
|
|
|
|
- );
|
|
|
|
|
|
+ // console.log(
|
|
|
|
+ // "[xmedia] return on meta, prev: %s, cur: %s",
|
|
|
|
+ // mediaArray[index].pts
|
|
|
|
+ // );
|
|
this.consumerPrevPts = mediaArray[index].pts;
|
|
this.consumerPrevPts = mediaArray[index].pts;
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -380,12 +380,12 @@ if ("function" === typeof importScripts) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- console.log(
|
|
|
|
- "[xmedia] return finally, prev: %s, cur: %s",
|
|
|
|
- this.prevSeq,
|
|
|
|
- this.consumerCurrPts,
|
|
|
|
- Date.now() - testLastestTime
|
|
|
|
- );
|
|
|
|
|
|
+ // console.log(
|
|
|
|
+ // "[xmedia] return finally, prev: %s, cur: %s",
|
|
|
|
+ // this.prevSeq,
|
|
|
|
+ // this.consumerCurrPts,
|
|
|
|
+ // Date.now() - testLastestTime
|
|
|
|
+ // );
|
|
|
|
|
|
testLastestTime = String(Date.now()).slice();
|
|
testLastestTime = String(Date.now()).slice();
|
|
this.consumerPrevPts = this.consumerCurrPts;
|
|
this.consumerPrevPts = this.consumerCurrPts;
|
|
@@ -415,11 +415,19 @@ if ("function" === typeof importScripts) {
|
|
// mediaArray[index].isIDR,
|
|
// mediaArray[index].isIDR,
|
|
// mediaArray[index].media.length
|
|
// mediaArray[index].media.length
|
|
// );
|
|
// );
|
|
- console.log("metaverse----core, pts: %s, isIDR: %s, length: %s",
|
|
|
|
|
|
+ console.log("pts: %s, isIDR: %s, length: %s",
|
|
mediaArray[index].pts,
|
|
mediaArray[index].pts,
|
|
mediaArray[index].isIDR,
|
|
mediaArray[index].isIDR,
|
|
mediaArray[index].media.length,
|
|
mediaArray[index].media.length,
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+ self.postMessage({
|
|
|
|
+ t: 11,
|
|
|
|
+ pts: mediaArray[index].pts,
|
|
|
|
+ isIDR: mediaArray[index].isIDR,
|
|
|
|
+ metadataLength: mediaArray[index].media.length,
|
|
|
|
+ });
|
|
|
|
+
|
|
// var loginfo = 'pts: %s, isIDR: %s, length: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length
|
|
// var loginfo = 'pts: %s, isIDR: %s, length: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length
|
|
|
|
|
|
needToSkip = this.skipFrameUntilI && !mediaArray[index].isIDR;
|
|
needToSkip = this.skipFrameUntilI && !mediaArray[index].isIDR;
|
|
@@ -440,9 +448,9 @@ if ("function" === typeof importScripts) {
|
|
// console.log("procBufItem", index, mediaArray[index]);
|
|
// console.log("procBufItem", index, mediaArray[index]);
|
|
|
|
|
|
if (this.slotHasContent(index) && !needToSkip) {
|
|
if (this.slotHasContent(index) && !needToSkip) {
|
|
- console.log("[xmedia] %s ------------ 001", mediaArray[index].pts);
|
|
|
|
|
|
+ //console.log("[xmedia] %s ------------ 001", mediaArray[index].pts);
|
|
if(mediaArray[index].metadata.mediaSrc){
|
|
if(mediaArray[index].metadata.mediaSrc){
|
|
- console.log("角度:"+ mediaArray[index].metadata.newUserStates[0].playerState.camera.angle.yaw);
|
|
|
|
|
|
+ //console.log("角度:"+ mediaArray[index].metadata.newUserStates[0].playerState.camera.angle.yaw);
|
|
}
|
|
}
|
|
|
|
|
|
let objData = {
|
|
let objData = {
|
|
@@ -455,33 +463,33 @@ if ("function" === typeof importScripts) {
|
|
|
|
|
|
// -------------------
|
|
// -------------------
|
|
if (this.checkPktOrderInConsumer(index)) {
|
|
if (this.checkPktOrderInConsumer(index)) {
|
|
- console.log("[xmedia] %s ------------ 002", mediaArray[index].pts);
|
|
|
|
|
|
+ //console.log("[xmedia] %s ------------ 002", mediaArray[index].pts);
|
|
this.decodeFrame(objData);
|
|
this.decodeFrame(objData);
|
|
}
|
|
}
|
|
|
|
|
|
if (mediaArray[index].isIDR) {
|
|
if (mediaArray[index].isIDR) {
|
|
- console.log("[xmedia] %s ------------ 003", mediaArray[index].pts);
|
|
|
|
|
|
+ //console.log("[xmedia] %s ------------ 003", mediaArray[index].pts);
|
|
// console.log("mediaArray[index].isIDR: this.skipFrameUntilI = false")
|
|
// console.log("mediaArray[index].isIDR: this.skipFrameUntilI = false")
|
|
this.skipFrameUntilI = false;
|
|
this.skipFrameUntilI = false;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- console.log("[xmedia] %s ------------ 004", mediaArray[index].pts);
|
|
|
|
|
|
+ //console.log("[xmedia] %s ------------ 004", mediaArray[index].pts);
|
|
if (this.slotHasMedia(index)) { //非空帧
|
|
if (this.slotHasMedia(index)) { //非空帧
|
|
- console.log("[xmedia] %s ------------ 005", mediaArray[index].pts);
|
|
|
|
|
|
+ //console.log("[xmedia] %s ------------ 005", mediaArray[index].pts);
|
|
//need to skip, waiting I Frame
|
|
//need to skip, waiting I Frame
|
|
//dropCache++
|
|
//dropCache++
|
|
this.dropPkt += 1;
|
|
this.dropPkt += 1;
|
|
// MARKER META1META2
|
|
// MARKER META1META2
|
|
// self.postMessage({ t: MessageEvent.OnlyEmitSignal, meta_only: true, meta: mediaArray[index].meta, metadata: mediaArray[index].metadata })
|
|
// self.postMessage({ t: MessageEvent.OnlyEmitSignal, meta_only: true, meta: mediaArray[index].meta, metadata: mediaArray[index].metadata })
|
|
} else {
|
|
} else {
|
|
- console.log("[xmedia] %s ------------ 006", mediaArray[index].pts);
|
|
|
|
|
|
+ //console.log("[xmedia] %s ------------ 006", mediaArray[index].pts);
|
|
// no media
|
|
// no media
|
|
if (mediaArray[index].meta != null) {
|
|
if (mediaArray[index].meta != null) {
|
|
- console.log("Work-IT2 掉帧3")
|
|
|
|
|
|
+ //console.log("Work-IT2 掉帧3")
|
|
this.checkPktOrderInConsumer(index);
|
|
this.checkPktOrderInConsumer(index);
|
|
- console.log("[xmedia] %s ------------ 007", mediaArray[index].pts);
|
|
|
|
|
|
+ //console.log("[xmedia] %s ------------ 007", mediaArray[index].pts);
|
|
// Still frame
|
|
// Still frame
|
|
- console.log("[send signal]", mediaArray[index].pts);
|
|
|
|
|
|
+ //console.log("[send signal]", mediaArray[index].pts);
|
|
self.postMessage({
|
|
self.postMessage({
|
|
t: MessageEvent.OnlyEmitSignal,
|
|
t: MessageEvent.OnlyEmitSignal,
|
|
meta_only: true,
|
|
meta_only: true,
|
|
@@ -490,19 +498,19 @@ if ("function" === typeof importScripts) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- console.log("Work-IT2 掉帧4")
|
|
|
|
- console.log("[xmedia] %s ------------ 008", mediaArray[index].pts);
|
|
|
|
|
|
+ //console.log("Work-IT2 掉帧4")
|
|
|
|
+ //console.log("[xmedia] %s ------------ 008", mediaArray[index].pts);
|
|
// Lost_rcv++
|
|
// Lost_rcv++
|
|
// console.log("lost_rcv++: this.skipFrameUntilI = true")
|
|
// console.log("lost_rcv++: this.skipFrameUntilI = true")
|
|
// console.info('[xmedia] FFFFF This code should not be executed!!!!')
|
|
// console.info('[xmedia] FFFFF This code should not be executed!!!!')
|
|
- console.info(
|
|
|
|
- "[xmedia] null pkt sneaked into profBufItem without harm"
|
|
|
|
- );
|
|
|
|
|
|
+ // console.info(
|
|
|
|
+ // "[xmedia] null pkt sneaked into profBufItem without harm"
|
|
|
|
+ // );
|
|
this.skipFrameUntilI = true;
|
|
this.skipFrameUntilI = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log('procBufItem');
|
|
|
|
|
|
+ //console.log('procBufItem');
|
|
this.dumpJitterBufInfo("Leaving Decoder.prototype.procBufItem, " + loginfo);
|
|
this.dumpJitterBufInfo("Leaving Decoder.prototype.procBufItem, " + loginfo);
|
|
this.lastObj = mediaArray[index];
|
|
this.lastObj = mediaArray[index];
|
|
this.resetBufItem(index);
|
|
this.resetBufItem(index);
|
|
@@ -535,7 +543,7 @@ if ("function" === typeof importScripts) {
|
|
this.resetBufItem(index);
|
|
this.resetBufItem(index);
|
|
}
|
|
}
|
|
if (!breakWhenIDR) {
|
|
if (!breakWhenIDR) {
|
|
- console.log("[xmedia] isFirstFrame 设置 TRUE");
|
|
|
|
|
|
+ //console.log("[xmedia] isFirstFrame 设置 TRUE");
|
|
this.isFirstFrame = true;
|
|
this.isFirstFrame = true;
|
|
}
|
|
}
|
|
this.dumpJitterBufInfo("Leaving Decoder.prototype.flushBuffer");
|
|
this.dumpJitterBufInfo("Leaving Decoder.prototype.flushBuffer");
|
|
@@ -591,7 +599,7 @@ if ("function" === typeof importScripts) {
|
|
this.procBufItem(this.readPtr);
|
|
this.procBufItem(this.readPtr);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
//console.log("[xmedia] 掉帧", error);
|
|
//console.log("[xmedia] 掉帧", error);
|
|
- console.log("Work-IT2 掉帧2")
|
|
|
|
|
|
+ //console.log("Work-IT2 掉帧2")
|
|
}
|
|
}
|
|
|
|
|
|
// if (this.getNumOfPktToBeDec() > this.prevBufNum) {
|
|
// if (this.getNumOfPktToBeDec() > this.prevBufNum) {
|
|
@@ -863,17 +871,17 @@ if ("function" === typeof importScripts) {
|
|
// console.log("[xmedia] 000-2 isIDR: %s, mediaLen: %s", isIDR, mediaLen)
|
|
// console.log("[xmedia] 000-2 isIDR: %s, mediaLen: %s", isIDR, mediaLen)
|
|
// console.log("[xmedia] 000-3 this.isPFrame(isIDR, mediaLen): %s", this.isPFrame(isIDR, mediaLen))
|
|
// console.log("[xmedia] 000-3 this.isPFrame(isIDR, mediaLen): %s", this.isPFrame(isIDR, mediaLen))
|
|
if (this.isPFrame(isIDR, mediaLen)) {
|
|
if (this.isPFrame(isIDR, mediaLen)) {
|
|
- console.log("[xmedia] 001: isPFrame TRUE");
|
|
|
|
|
|
+ //console.log("[xmedia] 001: isPFrame TRUE");
|
|
this.packetsDrop += 1;
|
|
this.packetsDrop += 1;
|
|
// MARKER META1META2
|
|
// MARKER META1META2
|
|
dropPkt = true;
|
|
dropPkt = true;
|
|
}
|
|
}
|
|
if (this.isIFrame(isIDR, mediaLen)) {
|
|
if (this.isIFrame(isIDR, mediaLen)) {
|
|
- console.log("[xmedia] 002: isIFrame TRUE");
|
|
|
|
|
|
+ //console.log("[xmedia] 002: isIFrame TRUE");
|
|
this.isFirstFrame = false;
|
|
this.isFirstFrame = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log("[xmedia] 003: dropPkt: %s", dropPkt);
|
|
|
|
|
|
+ //console.log("[xmedia] 003: dropPkt: %s", dropPkt);
|
|
return dropPkt;
|
|
return dropPkt;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -886,7 +894,7 @@ if ("function" === typeof importScripts) {
|
|
};
|
|
};
|
|
|
|
|
|
Decoder.prototype.receiveFrame = function (data) {
|
|
Decoder.prototype.receiveFrame = function (data) {
|
|
- console.log("[xmedia] receiveFrame");
|
|
|
|
|
|
+ //console.log("[xmedia] receiveFrame");
|
|
var key = data.cachedKey;
|
|
var key = data.cachedKey;
|
|
var pts = data.frameCnt;
|
|
var pts = data.frameCnt;
|
|
var meta = data.data.subarray(0, data.metaLen);
|
|
var meta = data.data.subarray(0, data.metaLen);
|
|
@@ -905,7 +913,7 @@ if ("function" === typeof importScripts) {
|
|
// this.updateMediaMetaStats(data);
|
|
// this.updateMediaMetaStats(data);
|
|
|
|
|
|
if (this.isFirstFrame) {
|
|
if (this.isFirstFrame) {
|
|
- console.log("[xmedia] isFirstFrame = true. pts:%s", pts);
|
|
|
|
|
|
+ //console.log("[xmedia] isFirstFrame = true. pts:%s", pts);
|
|
if (this.isPFrame(data.isIDR, media.byteLength)) {
|
|
if (this.isPFrame(data.isIDR, media.byteLength)) {
|
|
// MARKER META1META2
|
|
// MARKER META1META2
|
|
this.packetsDrop += 1;
|
|
this.packetsDrop += 1;
|
|
@@ -915,7 +923,7 @@ if ("function" === typeof importScripts) {
|
|
this.prevSeq = this.seqDiff(pts, 1, 65536);
|
|
this.prevSeq = this.seqDiff(pts, 1, 65536);
|
|
this.readPtr = this.writePtr = pts % CACHE_BUF_LENGTH;
|
|
this.readPtr = this.writePtr = pts % CACHE_BUF_LENGTH;
|
|
if (data.isIDR) {
|
|
if (data.isIDR) {
|
|
- console.log("[xmedia] isFirstFrame 设置 FALSE");
|
|
|
|
|
|
+ //console.log("[xmedia] isFirstFrame 设置 FALSE");
|
|
this.isFirstFrame = false;
|
|
this.isFirstFrame = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -962,11 +970,11 @@ if ("function" === typeof importScripts) {
|
|
this.packetsLost -= 1;
|
|
this.packetsLost -= 1;
|
|
// this.packetdisorder +=1
|
|
// this.packetdisorder +=1
|
|
}
|
|
}
|
|
- console.log(
|
|
|
|
- "[xmedia] disorder frame received. preSeq: %s, pts: %s",
|
|
|
|
- this.prevSeq,
|
|
|
|
- pts
|
|
|
|
- );
|
|
|
|
|
|
+ // console.log(
|
|
|
|
+ // "[xmedia] disorder frame received. preSeq: %s, pts: %s",
|
|
|
|
+ // this.prevSeq,
|
|
|
|
+ // pts
|
|
|
|
+ // );
|
|
if (this.seqDiff(this.prevSeq, pts, 65536) < this.getNumOfPktToBeDec()) {
|
|
if (this.seqDiff(this.prevSeq, pts, 65536) < this.getNumOfPktToBeDec()) {
|
|
// slot for pts is not handled yet. just put it back:
|
|
// slot for pts is not handled yet. just put it back:
|
|
console.log(
|
|
console.log(
|
|
@@ -1300,7 +1308,7 @@ if ("function" === typeof importScripts) {
|
|
var poc = Module.getValue(resultBuffer + 32, "i32");
|
|
var poc = Module.getValue(resultBuffer + 32, "i32");
|
|
var pts = data.frameCnt;
|
|
var pts = data.frameCnt;
|
|
|
|
|
|
- console.log("ret", ret);
|
|
|
|
|
|
+ //console.log("ret", ret);
|
|
|
|
|
|
if (ret != 0) {
|
|
if (ret != 0) {
|
|
printConsole.log(
|
|
printConsole.log(
|
|
@@ -1408,7 +1416,7 @@ if ("function" === typeof importScripts) {
|
|
cachedFirstFrame = objData;
|
|
cachedFirstFrame = objData;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log("this.startEmit", this.startEmit);
|
|
|
|
|
|
+ //console.log("this.startEmit", this.startEmit);
|
|
|
|
|
|
// if (cacheBuffer != null) {
|
|
// if (cacheBuffer != null) {
|
|
// Module._free(cacheBuffer)
|
|
// Module._free(cacheBuffer)
|
|
@@ -1425,7 +1433,7 @@ if ("function" === typeof importScripts) {
|
|
Decoder.prototype.receiveBuffer = function (data) {
|
|
Decoder.prototype.receiveBuffer = function (data) {
|
|
framesReturned++;
|
|
framesReturned++;
|
|
send_out_buffer -= 1;
|
|
send_out_buffer -= 1;
|
|
- console.log("receiveBuffer", data);
|
|
|
|
|
|
+ //console.log("receiveBuffer", data);
|
|
YUVArray.push({ status: 0, buffer: data.buffer });
|
|
YUVArray.push({ status: 0, buffer: data.buffer });
|
|
};
|
|
};
|
|
|
|
|