gemercheung 3 年之前
父节点
当前提交
b33a12bf7d
共有 4 个文件被更改,包括 31 次插入30 次删除
  1. 9 9
      src/Workers.js
  2. 1 1
      src/XSceneManager.js
  3. 2 3
      src/main.js
  4. 19 17
      src/v2Decoder/index.js

+ 9 - 9
src/Workers.js

@@ -11,7 +11,7 @@ let USER_ID = "987412365",
   COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/",
   FRAME_COMPOSE_LENGTH = 5;
 
-let testFrame = 0;
+let testFrame = -1;
 
 Number.prototype.padLeft = function (n, str) {
   return Array(n - String(this).length + 1).join(str || '0') + this;
@@ -813,7 +813,7 @@ export default class Workers {
       }
 
       if (this.cachedStreams[e] != null) {
-        console.log("cachedStreams", this.cachedStreams[e], e);
+        // console.log("cachedStreams", this.cachedStreams[e], e);
         this.executeFunction("stream", {
           stream: this.cachedStreams[e],
           width: this.cachedResolution[e].width,
@@ -1312,17 +1312,17 @@ export default class Workers {
           //有效Iframe
 
           console.error("IT", fCnt, It);
-          // testFrame += 1;
+          testFrame += 1;
           // console.error("IT", fCnt, JSON.stringify(Rt));
           console.error("traceIds", fCnt, Rt.traceIds.length);
           // console.log("IT-fCnt", It.data);
-          // console.log("testFrame", testFrame);
+          console.log("testFrame", testFrame);
 
-          // this.downloadBlob(
-          //   It.data.subarray(It.metaLen, It.metaLen + It.mediaLen),
-          //   `${testFrame.padLeft(4,'0')}.frame.h264`,
-          //   "application/octet-stream"
-          // );
+          this.downloadBlob(
+            It.data.subarray(It.metaLen, It.metaLen + It.mediaLen),
+            `100.${testFrame.padLeft(4,'0')}.h264`,
+            "application/octet-stream"
+          );
 
           if (this.inPanoMode) {
             // console.log("接受webrtc请求:" + JSON.stringify(Rt));

+ 1 - 1
src/XSceneManager.js

@@ -59,7 +59,7 @@ export default class XSceneManager {
         this.engine.doNotHandleContextLost = !0,
         this.scene.clearCachedVertexData(),
         this.scene.cleanCachedTextureBuffer(),
-        // this.scene.debugLayer.show({ embedMode: true, }),    // BABYLON调试工具栏
+        this.scene.debugLayer.show({ embedMode: true, }),    // BABYLON调试工具栏
 
         this.urlTransformer = options.urlTransformer || (s=>Promise.resolve(s)),
         options.logger && defaultLog.setLogger(options.logger),

+ 2 - 3
src/main.js

@@ -34,10 +34,9 @@ const l = async()=>{
             avatarId: 'KGe_Boy',
             roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
             userId: nickname,
-            // wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
+            wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
             // wsServerUrl: "ws://localhost:6688/ws",
-            wsServerUrl: "wss://meta-socket.4dage.com/ws",
-
+            // wsServerUrl: "wss://meta-socket.4dage.com/ws",
             appId: "10016",
             token: " ",
             nickname: nickname,

+ 19 - 17
src/v2Decoder/index.js

@@ -336,7 +336,7 @@ if ("function" === typeof importScripts) {
     if (this.isSlotEmpty(index)) {
       //lost
       // debugger
-      // console.log("[xmedia] return on SLOT EMPTY, prev: %s", prev)
+      console.log("[xmedia] return on SLOT EMPTY, prev: %s", prevSeq)
       this.consumerWaitingIDR = true;
       this.consumerPrevPts = this.seqAdd(this.consumerPrevPts, 1, 65536);
       return true;
@@ -345,7 +345,7 @@ if ("function" === typeof importScripts) {
     if (!this.slotHasMedia(index)) {
       // pure meta
       // debugger
-      // console.log("[xmedia] return on meta, prev: %s, cur: %s", this., mediaArray[index].pts)
+      console.log("[xmedia] return on meta, prev: %s, cur: %s", mediaArray[index].pts)
       this.consumerPrevPts = mediaArray[index].pts;
       return true;
     }
@@ -375,7 +375,7 @@ if ("function" === typeof importScripts) {
       }
     }
 
-    // console.log("[xmedia] return finally, prev: %s, cur: %s", prev, cur)
+    console.log("[xmedia] return finally, prev: %s, cur: %s", this.prevSeq, this.consumerCurrPts);
     this.consumerPrevPts = this.consumerCurrPts;
 
     this.consumerWaitingIDR = false;
@@ -421,10 +421,10 @@ if ("function" === typeof importScripts) {
       ", needToSkip: " +
       needToSkip;
 
-    console.log("procBufItem", index, mediaArray[index]);
+    // 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)
       let objData = {
         media: mediaArray[index].media,
         frameCnt: mediaArray[index].pts,
@@ -435,30 +435,30 @@ 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) {
           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);
           self.postMessage({
@@ -468,7 +468,7 @@ if ("function" === typeof importScripts) {
             metadata: mediaArray[index].metadata,
           });
         } else {
-          // console.log("[xmedia] %s ------------ 008", mediaArray[index].pts)
+          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!!!!')
@@ -811,17 +811,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;
   };
 
@@ -841,6 +841,7 @@ if ("function" === typeof importScripts) {
 
     if (data.cached) {
       media = IFrameCacheBuffer[JSON.stringify(data.position)][key];
+     
     } else if (data.cacheRequest) {
       media = data.data.subarray(data.metaLen, data.metaLen + data.mediaLen);
       self.decoder.cacheFrame(data);
@@ -857,6 +858,7 @@ if ("function" === typeof importScripts) {
       if (this.isPFrame(data.isIDR, media.byteLength)) {
         // MARKER META1META2
         this.packetsDrop += 1;
+       console.log('fk1')
         return;
       }
       this.prevSeq = this.seqDiff(pts, 1, 65536);
@@ -906,10 +908,10 @@ 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('put disorder frame to enc_queue, pkt:%s, prevPts: %s, numOfPktToBeDec: %s', pts, this.prevSeq, this.getNumOfPktToBeDec())
+        console.log('put disorder frame to enc_queue, pkt:%s, prevPts: %s, numOfPktToBeDec: %s', pts, this.prevSeq, this.getNumOfPktToBeDec())
       } else {
         //dropDisorder++
         console.error(