gemercheung 3 rokov pred
rodič
commit
1f5d28e310
3 zmenil súbory, kde vykonal 72 pridanie a 32 odobranie
  1. 66 28
      src/Workers.js
  2. 2 2
      src/main.js
  3. 4 2
      src/v2Decoder/index.js

+ 66 - 28
src/Workers.js

@@ -999,8 +999,9 @@ export default class Workers {
   // backup main unmarshalStreamBk
   unmarshalStream(e) {
     var lt, ft, ht, pt, dt, _t, mt, vt, yt, Et;
-    const i = Date.now(),
-      o = new DataView(e);
+
+    const i = Date.now();
+    const o = new DataView(e);
 
     if (o.getUint32(0) != 1437227610) return false; // 32位0bit 流标识位
 
@@ -1008,11 +1009,11 @@ export default class Workers {
     const c = o.getUint16(6), // 16位6bit 36 ? 可能是混数
       d = o.getUint16(8), // 16位8bit 存当前帧数
       fCnt = d,
-      b = o.getUint16(10); // 1 3 255 1,3 ? 方向 空包 255
+      b = o.getUint16(10); // 1 3 255 1,3 ? 方向 空包 255 可能是 DIR 方向
     let k = false;
     b == 1 && (k = true); //
-    const j = o.getUint32(12), // 16位12bit ? 帧 byteLength 长度
-      $ = o.getUint32(16), // 16位16bit  ?当前大小  0 是空包
+    const j = o.getUint32(12), // 16位12bit ? 帧 byteLength 长度 metaLen
+      $ = o.getUint32(16), // 16位16bit  有效流总大小  0 是空包 metaLen
       _e = o.getUint32(20), // calcSendTimeDiff 与时间有关
       et = o.getUint16(24), // 大多数为 0,待定 与inPanoMode 开关有关系
       tt = o.getUint16(26), // 0 / 1 待定  与用户状态有关
@@ -1024,8 +1025,21 @@ export default class Workers {
 
     this.calcSendTimeDiff(_e);
 
-    console.log("流--", e.byteLength);
-    console.log("gemer1", fCnt, ot, it);
+    // console.log("流--", e.byteLength);
+
+    console.log("gemer", {
+      byteLength: e.byteLength,
+      frame: fCnt,
+      mediaLen: $,
+      metaLen: j,
+      serverTime: _e,
+      it: it,
+      start: c,
+      end: ot,
+      total: nt,
+      isPureMeta: ot === nt,
+      at: at,
+    });
 
     // debugger;
     const down = Date.now();
@@ -1072,8 +1086,7 @@ export default class Workers {
       const Mt = JSON.parse(this.Stringify(bt)); // json 与帧map的坐标数据
       const Pt = Date.now();
 
-      // console.log("gemer2", fCnt, JSON.stringify(Mt));
-
+      console.log("gemer2", fCnt, it, Mt);
 
       this.showAllReceivedMetadata && console.log(_e, gt, Mt);
 
@@ -1161,20 +1174,34 @@ export default class Workers {
       ) {
         this.firstMediaArraval = Date.now();
         const Ct = this.firstMediaArraval - this.rtcp.network.room._startTime;
+
         defaultLogger.infoAndReportMeasurement({
           metric: "firstMediaArravalAt",
           value: Ct,
           group: "joinRoom",
         });
-        this.downloadBlob(
-          [At.buffer],
-          `first.h264`,
-          "application/octet-stream"
-        );
+        // this.downloadBlob(
+        //   [At.buffer],
+        //   `first.h264`,
+        //   "application/octet-stream"
+        // );
         this.firstMediaReceived = true;
       }
     } else {
       const At = this.hasFrmCntInCache(fCnt);
+      // console.log("At", At, at, it);
+      // console.log(
+      //   "this.cacheFrameComposes[At].buffer",
+      //   this.cacheFrameComposes[At],
+      // );
+
+      // if (At !== -1) {
+      //   console.log(
+      //     "this.cacheFrameComposes[At].buffer",
+      //     this.cacheFrameComposes[At].buffer
+      //   );
+      // }
+
       if (At != -1)
         if (
           (this.cacheFrameComposes[At].buffer.set(at, it),
@@ -1186,15 +1213,18 @@ export default class Workers {
             nt
           );
 
-          (this.cacheFrameComposes[At].frameCnt = -1),
-            (this.cacheFrameComposes[At].size = 0),
-            (this.cacheFrameComposes[At].startReceiveTime = 0),
-            (this.cacheFrameComposes[At].serverTime = 0),
-            this.receivedMedia++,
-            _e - this.lastServerTS > 60
-              ? this.serverFrameSlow++
-              : _e - this.lastServerTS < 16 && this.serverFrameFast++;
+          this.cacheFrameComposes[At].frameCnt = -1;
+          this.cacheFrameComposes[At].size = 0;
+          this.cacheFrameComposes[At].startReceiveTime = 0;
+          this.cacheFrameComposes[At].serverTime = 0;
+          this.receivedMedia++;
+
+          _e - this.lastServerTS > 60
+            ? this.serverFrameSlow++
+            : _e - this.lastServerTS < 16 && this.serverFrameFast++;
+
           const St = Date.now();
+
           St - this.lastClientTS > 60
             ? this.clientFrameSlow++
             : St - this.lastClientTS < 16 && this.clientFrameFast++,
@@ -1204,10 +1234,11 @@ export default class Workers {
             (this.lastServerTS = _e),
             (this.lastClientTS = St);
 
-          const xt = gt.subarray(0, j),
-            bt = Date.now(),
-            Rt = JSON.parse(this.Stringify(xt)),
-            Mt = Date.now();
+          const xt = gt.subarray(0, j);
+          // console.log("xt", xt);
+          const bt = Date.now();
+          const Rt = JSON.parse(this.Stringify(xt));
+          const Mt = Date.now();
 
           this.showAllReceivedMetadata && console.log(_e, St, Rt),
             this.metaParseArray.push(Mt - bt),
@@ -1266,8 +1297,14 @@ export default class Workers {
           };
           //有效Iframe
           console.error("IT", fCnt, It);
-       
-          // this.downloadBlob([It.data], `${It.frameCnt}.gt.h264`, "application/octet-stream");
+          console.error("IT", fCnt, JSON.stringify(Rt));
+          console.log("IT-fCnt", It.data);
+
+          this.downloadBlob(
+            It.data.subarray(It.metaLen, It.metaLen + It.mediaLen),
+            `${It.frameCnt}.264`,
+            "application/json"
+          );
 
           if (this.inPanoMode) {
             // console.log("接受webrtc请求:" + JSON.stringify(Rt));
@@ -1355,6 +1392,7 @@ export default class Workers {
       // console.log("接受webrtc请求:心跳");
       return;
     }
+
     if (i.length > 36 && this.unmarshalStream(i.buffer) == true) {
       this.reconnectSignal &&
         (this.executeFunction("reconnectedFrame", {}),

+ 2 - 2
src/main.js

@@ -34,9 +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,

+ 4 - 2
src/v2Decoder/index.js

@@ -456,7 +456,7 @@ if ("function" === typeof importScripts) {
           this.checkPktOrderInConsumer(index);
           // 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,
@@ -844,7 +844,9 @@ if ("function" === typeof importScripts) {
       media = data.data.subarray(data.metaLen, data.metaLen + data.mediaLen);
     }
 
-    this.updateMediaMetaStats(data);
+    // console.log("[xmedia] media1", media);
+
+    // this.updateMediaMetaStats(data);
 
     if (this.isFirstFrame) {
       console.log("[xmedia] isFirstFrame = true. pts:%s", pts);