xushiting 3 年之前
父节点
当前提交
0f2db388f7
共有 6 个文件被更改,包括 96 次插入79 次删除
  1. 1 1
      src/CircularArray.js
  2. 1 1
      src/Logger.js
  3. 39 30
      src/Workers.js
  4. 1 1
      src/XAvatarManager.js
  5. 1 1
      src/XMaterialComponent.js
  6. 53 45
      src/v2Decoder/index.js

+ 1 - 1
src/CircularArray.js

@@ -97,7 +97,7 @@ export default class CircularArray {
     getAvg() {
         const e = this.sum / this.count || 0
           , t = this.computeAvg(this.circularData) || 0;
-        return Math.abs(e - t) > .01 && console.error("avg value mismatch: ", e, t),
+        return Math.abs(e - t) > .01 ,//&& console.error("avg value mismatch: ", e, t),
         this.computeAvg(this.circularData) || 0
     }
     getMax(e=!0) {

+ 1 - 1
src/Logger.js

@@ -20,7 +20,7 @@ export default class Logger{
         if (this.atleast(t)) {
             const n = e == "debug" ? "info" : e
               , o = this.prefix(e);
-            console[n].call(null, o, ...r)
+            //console[n].call(null, o, ...r)
         }
         if (e !== "debug" && e !== "info") {
             const n = r.map(o=>{

+ 39 - 30
src/Workers.js

@@ -522,7 +522,7 @@ export default class Workers {
 
         //重新decode cache ptr
 
-        console.log("this.cachedStreams", this.cachedStreams, this.setPtr);
+        //console.log("this.cachedStreams", this.cachedStreams, this.setPtr);
 
         this.decoderWorker.postMessage(
           {
@@ -731,7 +731,7 @@ export default class Workers {
                 "-" +
                 c +
                 ".264";
-            console.log(" s.data.fileObj", s.data.fileObj);
+            //console.log(" s.data.fileObj", s.data.fileObj);
             // uploadStream(COS_PREFIX + d, s.data.fileObj);
             break;
           }
@@ -765,7 +765,7 @@ export default class Workers {
             }
             const _ = "wasm:" + d;
             this._rtcp.sendStringData(_);
-            console.log("meta——丢帧" + s.data.metadata); //.newUserStates[0].playerState.user.camera.yaw);
+            //console.log("meta——丢帧" + s.data.metadata); //.newUserStates[0].playerState.user.camera.yaw);
             break;
           }
           case 9: {
@@ -780,6 +780,14 @@ export default class Workers {
               });
             break;
           }
+          case 11:{
+            console.log("Workers:pts: %s, isIDR: %s, length: %s",
+              s.data.pts,
+              s.data.isIDR,
+              s.data.metadataLength,
+            );
+            break;
+          }
           default:
             defaultLogger.error("Receive unknown message event from decoder"),
               defaultLogger.debug(s.data);
@@ -897,11 +905,11 @@ export default class Workers {
       //   "接受webrtc请求(定时执行UpdateYUV):" +
       //     JSON.stringify(this.cachedMetas[e])
       // );
-      console.log("回传", {
-        signal: this.cachedMetas[e],
-        pts: this.cachedPtss[e],
-        alreadyUpdateYUV: true,
-      });
+      // console.log("回传", {
+      //   signal: this.cachedMetas[e],
+      //   pts: this.cachedPtss[e],
+      //   alreadyUpdateYUV: true,
+      // });
       this.executeFunction("signal", {
         signal: this.cachedMetas[e],
         pts: this.cachedPtss[e],
@@ -919,7 +927,7 @@ export default class Workers {
       o = i.getUint32(0);
     if (o == 1723558763) return true;
     if (o != 2296221069) return false;
-    console.log("Receive Pano Message"), i.getUint16(4);
+    //console.log("Receive Pano Message"), i.getUint16(4);
     const s = i.getUint16(6),
       c = i.getUint32(8),
       d = i.getUint32(12),
@@ -1069,7 +1077,7 @@ export default class Workers {
       });
     }
     let copyIDR = b;
-    console.log("metaverse----IDR:" + copyIDR);
+    //console.log("metaverse----IDR:" + copyIDR);
 
     // debugger;
     const down = Date.now();
@@ -1116,9 +1124,9 @@ export default class Workers {
       const Mt = JSON.parse(this.Stringify(bt)); // json 与帧map的坐标数据
       const Pt = Date.now();
 
-      console.log("gemer2", fCnt, it, Mt);
+      //console.log("gemer2", fCnt, it, Mt);
 
-      this.showAllReceivedMetadata && console.log(_e, gt, Mt);
+      //this.showAllReceivedMetadata && console.log(_e, gt, Mt);
 
       // console.log("Pt - Rt", Pt - Rt, Pt, Rt);
       this.metaParseArray.push(Pt - Rt);
@@ -1131,13 +1139,14 @@ export default class Workers {
           this.inMovingMode &&
           (this.moveStartPts = d),
         this.moveStartPts == d &&
-          ((this.MoveResponseDelay = Date.now() - this.StartMovingTs),
-          console.log(
-            "move response delay: ",
-            d,
-            this.moveStartPts,
-            this.MoveResponseDelay
-          ));
+          ((this.MoveResponseDelay = Date.now() - this.StartMovingTs)
+          // console.log(
+          //   "move response delay: ",
+          //   d,
+          //   this.moveStartPts,
+          //   this.MoveResponseDelay
+          // )
+          );
 
       const It = this.getIsMoving(Mt);
 
@@ -1258,7 +1267,7 @@ export default class Workers {
           const Rt = JSON.parse(this.Stringify(xt));
           const Mt = Date.now();
 
-          this.showAllReceivedMetadata && console.log(_e, St, Rt),
+          this.showAllReceivedMetadata, // && console.log(_e, St, Rt),
             this.metaParseArray.push(Mt - bt),
             (_t = Rt.traceIds) != null &&
               _t.length &&
@@ -1315,16 +1324,16 @@ export default class Workers {
           };
           //有效Iframe
           //console.error("IT", It);
-          console.log("Work-It1.data", fCnt, It.data);
-          console.log(
-            "Work-IT2",
-            fCnt,
-            It.metadata.mediaSrc +
-              "," +
-              JSON.stringify(
-                It.metadata.newUserStates[0].playerState.player.position
-              )
-          );
+          // console.log("Work-It1.data", fCnt, It.data);
+          // console.log(
+          //   "Work-IT2",
+          //   fCnt,
+          //   It.metadata.mediaSrc +
+          //     "," +
+          //     JSON.stringify(
+          //       It.metadata.newUserStates[0].playerState.player.position
+          //     )
+          // );
           // testFrame += 1;
           // console.error("IT", fCnt, JSON.stringify(Rt));
           //console.error("traceIds", fCnt, Rt.traceIds.length);

+ 1 - 1
src/XAvatarManager.js

@@ -544,7 +544,7 @@ export default class XAvatarManager {
                 const s = a.instantiateModelsToScene();
                 // zeg 此时body_man缩放已经0.01
                 // s.rootNodes[0]._children[0]._scaling.setAll(0.014)
-                console.log("body_man缩放", s.rootNodes[0]._children[0]._scaling)
+                //console.log("body_man缩放", s.rootNodes[0]._children[0]._scaling)
                 a.xReferenceCount++;
                 const l = {
                     isRender: !1,

+ 1 - 1
src/XMaterialComponent.js

@@ -110,7 +110,7 @@ export default class XMaterialComponent {
     fov == -1 && (fov = this.yuvInfo.fov);
 
     if (this._isUpdateYUV == !0) {
-      console.log('执行:updateRawYUVData')
+      //console.log('执行:updateRawYUVData')
       const yuvInfo = { width, height, fov }
       const videosResOriArrayIndex = this._videoRawYUVTexArray.findId(width, height)
       const currentVideoId = this._videoRawYUVTexArray.getCurrentVideoTexId();

+ 53 - 45
src/v2Decoder/index.js

@@ -173,7 +173,7 @@ if ("function" === typeof importScripts) {
   //end refactor
 
   Decoder.prototype.resetDecoder = function () {
-    console.log("[xmedia] isFirstFrame 设置 TRUE");
+    //console.log("[xmedia] isFirstFrame 设置 TRUE");
     this.isFirstFrame = 1;
     this.expected_frameCnt = 1;
 
@@ -338,7 +338,7 @@ if ("function" === typeof importScripts) {
     if (this.isSlotEmpty(index)) {
       //lost
       // 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.consumerPrevPts = this.seqAdd(this.consumerPrevPts, 1, 65536);
       return true;
@@ -347,10 +347,10 @@ if ("function" === typeof importScripts) {
     if (!this.slotHasMedia(index)) {
       // pure meta
       // 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;
       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();
     this.consumerPrevPts = this.consumerCurrPts;
@@ -415,11 +415,19 @@ if ("function" === typeof importScripts) {
     //   mediaArray[index].isIDR,
     //   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].isIDR,
       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
 
     needToSkip = this.skipFrameUntilI && !mediaArray[index].isIDR;
@@ -440,9 +448,9 @@ if ("function" === typeof importScripts) {
     // console.log("procBufItem", index, mediaArray[index]);
 
     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){
-        console.log("角度:"+ mediaArray[index].metadata.newUserStates[0].playerState.camera.angle.yaw);
+        //console.log("角度:"+ mediaArray[index].metadata.newUserStates[0].playerState.camera.angle.yaw);
       }
       
       let objData = {
@@ -455,33 +463,33 @@ if ("function" === typeof importScripts) {
 
       // -------------------
       if (this.checkPktOrderInConsumer(index)) {
-        console.log("[xmedia] %s ------------ 002", mediaArray[index].pts);
+        //console.log("[xmedia] %s ------------ 002", mediaArray[index].pts);
         this.decodeFrame(objData);
       }
 
       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")
         this.skipFrameUntilI = false;
       }
     } else {
-      console.log("[xmedia] %s ------------ 004", mediaArray[index].pts);
+      //console.log("[xmedia] %s ------------ 004", mediaArray[index].pts);
       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
         //dropCache++
         this.dropPkt += 1;
         // MARKER META1META2
         // self.postMessage({ t: MessageEvent.OnlyEmitSignal, meta_only: true, meta: mediaArray[index].meta, metadata: mediaArray[index].metadata })
       } else {
-        console.log("[xmedia] %s ------------ 006", mediaArray[index].pts);
+        //console.log("[xmedia] %s ------------ 006", mediaArray[index].pts);
         // no media
         if (mediaArray[index].meta != null) {
-          console.log("Work-IT2 掉帧3")
+          //console.log("Work-IT2 掉帧3")
           this.checkPktOrderInConsumer(index);
-          console.log("[xmedia] %s ------------ 007", mediaArray[index].pts);
+          //console.log("[xmedia] %s ------------ 007", mediaArray[index].pts);
           // Still frame
-          console.log("[send signal]", mediaArray[index].pts);
+          //console.log("[send signal]", mediaArray[index].pts);
           self.postMessage({
             t: MessageEvent.OnlyEmitSignal,
             meta_only: true,
@@ -490,19 +498,19 @@ if ("function" === typeof importScripts) {
           });
         } 
         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++
           // console.log("lost_rcv++: this.skipFrameUntilI = true")
           // 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;
         }
       }
     }
-    console.log('procBufItem');
+    //console.log('procBufItem');
     this.dumpJitterBufInfo("Leaving Decoder.prototype.procBufItem, " + loginfo);
     this.lastObj = mediaArray[index];
     this.resetBufItem(index);
@@ -535,7 +543,7 @@ if ("function" === typeof importScripts) {
       this.resetBufItem(index);
     }
     if (!breakWhenIDR) {
-      console.log("[xmedia] isFirstFrame 设置 TRUE");
+      //console.log("[xmedia] isFirstFrame 设置 TRUE");
       this.isFirstFrame = true;
     }
     this.dumpJitterBufInfo("Leaving Decoder.prototype.flushBuffer");
@@ -591,7 +599,7 @@ if ("function" === typeof importScripts) {
       this.procBufItem(this.readPtr);
     } catch (error) {
       //console.log("[xmedia] 掉帧", error);
-      console.log("Work-IT2 掉帧2")
+      //console.log("Work-IT2 掉帧2")
     }
 
     // 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-3 this.isPFrame(isIDR, mediaLen): %s", this.isPFrame(isIDR, mediaLen))
       if (this.isPFrame(isIDR, mediaLen)) {
-        console.log("[xmedia] 001: isPFrame TRUE");
+        //console.log("[xmedia] 001: isPFrame TRUE");
         this.packetsDrop += 1;
         // MARKER META1META2
         dropPkt = true;
       }
       if (this.isIFrame(isIDR, mediaLen)) {
-        console.log("[xmedia] 002: isIFrame TRUE");
+        //console.log("[xmedia] 002: isIFrame TRUE");
         this.isFirstFrame = false;
       }
     }
-    console.log("[xmedia] 003: dropPkt: %s", dropPkt);
+    //console.log("[xmedia] 003: dropPkt: %s", dropPkt);
     return dropPkt;
   };
 
@@ -886,7 +894,7 @@ if ("function" === typeof importScripts) {
   };
 
   Decoder.prototype.receiveFrame = function (data) {
-    console.log("[xmedia] receiveFrame");
+    //console.log("[xmedia] receiveFrame");
     var key = data.cachedKey;
     var pts = data.frameCnt;
     var meta = data.data.subarray(0, data.metaLen);
@@ -905,7 +913,7 @@ if ("function" === typeof importScripts) {
     // this.updateMediaMetaStats(data);
 
     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)) {
         // MARKER META1META2
         this.packetsDrop += 1;
@@ -915,7 +923,7 @@ if ("function" === typeof importScripts) {
       this.prevSeq = this.seqDiff(pts, 1, 65536);
       this.readPtr = this.writePtr = pts % CACHE_BUF_LENGTH;
       if (data.isIDR) {
-        console.log("[xmedia] isFirstFrame 设置 FALSE");
+        //console.log("[xmedia] isFirstFrame 设置 FALSE");
         this.isFirstFrame = false;
       }
     }
@@ -962,11 +970,11 @@ if ("function" === typeof importScripts) {
         this.packetsLost -= 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()) {
         // slot for pts is not handled yet. just put it back:
         console.log(
@@ -1300,7 +1308,7 @@ if ("function" === typeof importScripts) {
       var poc = Module.getValue(resultBuffer + 32, "i32");
       var pts = data.frameCnt;
 
-      console.log("ret", ret);
+      //console.log("ret", ret);
 
       if (ret != 0) {
         printConsole.log(
@@ -1408,7 +1416,7 @@ if ("function" === typeof importScripts) {
         cachedFirstFrame = objData;
       }
     }
-    console.log("this.startEmit", this.startEmit);
+    //console.log("this.startEmit", this.startEmit);
 
     // if (cacheBuffer != null) {
     //   Module._free(cacheBuffer)
@@ -1425,7 +1433,7 @@ if ("function" === typeof importScripts) {
   Decoder.prototype.receiveBuffer = function (data) {
     framesReturned++;
     send_out_buffer -= 1;
-    console.log("receiveBuffer", data);
+    //console.log("receiveBuffer", data);
     YUVArray.push({ status: 0, buffer: data.buffer });
   };