gemercheung před 3 roky
rodič
revize
7dc2cf1727
10 změnil soubory, kde provedl 92 přidání a 79 odebrání
  1. 2 2
      dist/index.html
  2. 5 5
      index.js
  3. 2 1
      src/ActionsHandler.js
  4. 12 12
      src/EventsManager.js
  5. 16 16
      src/Reporter.js
  6. 43 35
      src/Workers.js
  7. 1 1
      src/Xverse.js
  8. 2 2
      src/config/socketConfig.js
  9. 2 2
      src/main.js
  10. 7 3
      src/v2Decoder/index.js

+ 2 - 2
dist/index.html

@@ -46,8 +46,8 @@
             PROD: "wss://eks.xverse.cn/ws"
         }
         , REPORT_URL = {
-            DEV: "https://xa.xverse.cn:6680/collect",
-            PROD: "https://xa.xverse.cn/collect"
+            DEV: "https://xa.xverse.cn:6680/collect1",
+            PROD: "https://xa.xverse.cn/collect1"
         }
         , MAX_RECONNECT_COUNT = 3
         , DEFAULT_JOINROOM_TIMEOUT = 15e3

+ 5 - 5
index.js

@@ -163345,11 +163345,11 @@ const log$f = new Logger("xverse")
         if (reporter.updateHeader({
             pageSession: _
         }),
-        reporter.updateReportUrl(REPORT_URL[er.env]),
-        d && reporter.updateBody({
-            sdkVersion: d,
-            appId: s
-        }),
+        // reporter.updateReportUrl(REPORT_URL[er.env]),
+        // d && reporter.updateBody({
+        //     sdkVersion: d,
+        //     appId: s
+        // }),
         log$f.infoAndReportMeasurement({
             metric: "sdkInit",
             startTime: Date.now(),

+ 2 - 1
src/ActionsHandler.js

@@ -361,7 +361,8 @@ export default class ActionsHandler {
                 rotation_action: {
                     vertical_move: pitch,
                     horizontal_move: -yaw
-                }
+                },
+                sampleRate: .02
             },
             sampleRate: .02
         })

+ 12 - 12
src/EventsManager.js

@@ -13,22 +13,22 @@ export default class EventsManager extends EventEmitter {
 
     remove(traceId, code, signal, needDelete) 
     {
-        // if (this.specialEvents.has(traceId) && !needDelete && code === Codes.Success) return;
+        if (this.specialEvents.has(traceId) && !needDelete && code === Codes.Success) return;
 
-        // this.events.get(traceId) && (
-        //     this.emit(traceId, {code, data:signal}),
-        //     this.events.delete(traceId),
-        //     this.specialEvents.delete(traceId)
-        // )
+        this.events.get(traceId) && (
+            this.emit(traceId, {code, data:signal}),
+            this.events.delete(traceId),
+            this.specialEvents.delete(traceId)
+        )
 
         // todo 写死数据纠正
-        if (this.specialEvents.has(this.traceId) && !needDelete && code === Codes.Success) return;
+        // if (this.specialEvents.has(this.traceId) && !needDelete && code === Codes.Success) return;
 
-        this.events.get(this.traceId) && (
-            this.emit(this.traceId, {code, data:signal}),
-            this.events.delete(this.traceId),
-            this.specialEvents.delete(this.traceId)
-        )
+        // this.events.get(this.traceId) && (
+        //     this.emit(this.traceId, {code, data:signal}),
+        //     this.events.delete(this.traceId),
+        //     this.specialEvents.delete(this.traceId)
+        // )
     }
 
     async track(e, t) 

+ 16 - 16
src/Reporter.js

@@ -65,22 +65,22 @@ export default class Reporter extends EventEmitter {
     }
     _post(e) {
         const t = this._reportUrl || REPORT_URL.DEV;
-        return new Promise((r,n)=>{
-            const o = new XMLHttpRequest;
-            o.open("POST", t),
-            o.setRequestHeader("Content-Type", "application/json");
-            try {
-                o.send(JSON.stringify(e))
-            } catch (a) {
-                console.error(a)
-            }
-            o.addEventListener("readystatechange", ()=>{
-                if (o.readyState == 4)
-                    return o.status == 200 ? r(o) : n("Unable to send log")
-            }
-            )
-        }
-        )
+        // return new Promise((r,n)=>{
+        //     const o = new XMLHttpRequest;
+        //     o.open("POST", t),
+        //     o.setRequestHeader("Content-Type", "application/json");
+        //     try {
+        //         o.send(JSON.stringify(e))
+        //     } catch (a) {
+        //         console.error(a)
+        //     }
+        //     o.addEventListener("readystatechange", ()=>{
+        //         if (o.readyState == 4)
+        //             return o.status == 200 ? r(o) : n("Unable to send log")
+        //     }
+        //     )
+        // }
+        // )
     }
 }
 

+ 43 - 35
src/Workers.js

@@ -11,6 +11,13 @@ let USER_ID = "987412365",
   COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/",
   FRAME_COMPOSE_LENGTH = 5;
 
+let testFrame = 0;
+
+Number.prototype.padLeft = function (n, str) {
+  return Array(n - String(this).length + 1).join(str || '0') + this;
+};
+
+
 import CircularArray from "./CircularArray.js";
 import SecondArray from "./SecondArray.js";
 import v2Decoder from "./v2Decoder/index.js";
@@ -340,6 +347,7 @@ export default class Workers {
         displayTime: 0,
         status: 0,
       };
+
       this.traceIdMap.set(o, d);
       const _ = setTimeout(() => {
         if ((_ && clearTimeout(_), this.traceIdMap.has(o))) {
@@ -434,6 +442,7 @@ export default class Workers {
     }
   }
   UpdateStats(e) {
+    // console.log('UpdateStats',e.data);
     var i;
     (i = this._rtcp.connection) == null ||
       i.getStats(null).then((o) => {
@@ -886,11 +895,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],
@@ -1034,21 +1043,29 @@ export default class Workers {
 
     this.calcSendTimeDiff(_e);
 
-    // console.log("流--", e.byteLength);
+    // console.log("hey", Date.now() - _e);
 
-    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,
-    });
+    // console.log("流--", e.byteLength);
+    if (b !== 255) {
+      console.log("gemer1", {
+        byteLength: e.byteLength,
+        frame: fCnt,
+        mediaLen: $,
+        metaLen: j,
+        b: b,
+        cachedKey: rt,
+        serverTime: _e,
+        it: it,
+        start: c,
+        ot: ot,
+        nt: nt,
+        total: nt,
+        tt: tt,
+        et: et,
+        isPureMeta: ot === nt,
+        at: at,
+      });
+    }
 
     // debugger;
     const down = Date.now();
@@ -1166,7 +1183,7 @@ export default class Workers {
         cachedKey: rt,
         position: st,
       };
-      // console.warn('Dt',Dt);
+      // console.error('Dt',Dt);
       if (this.inPanoMode) {
         // console.log('接受webrtc请求:'+JSON.stringify(Mt));
         this.executeFunction("signal", {
@@ -1198,18 +1215,6 @@ export default class Workers {
       }
     } 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 (
@@ -1305,13 +1310,17 @@ export default class Workers {
             position: st,
           };
           //有效Iframe
+
           console.error("IT", fCnt, It);
-          console.error("IT", fCnt, JSON.stringify(Rt));
+          // 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);
 
           // this.downloadBlob(
           //   It.data.subarray(It.metaLen, It.metaLen + It.mediaLen),
-          //   `${It.frameCnt}.v2p.264`,
+          //   `${testFrame.padLeft(4,'0')}.frame.h264`,
           //   "application/octet-stream"
           // );
 
@@ -1337,7 +1346,6 @@ export default class Workers {
               value: Dt,
               group: "joinRoom",
             });
-            
             this.firstMediaReceived = true;
           }
         } else

+ 1 - 1
src/Xverse.js

@@ -23,7 +23,7 @@ export default class Xverse{
             pageSession: s
         })
 
-        reporter.updateReportUrl(REPORT_URL[this.env])
+        // reporter.updateReportUrl(REPORT_URL[this.env])
 
         a && reporter.updateBody({
             sdkVersion: a

+ 2 - 2
src/config/socketConfig.js

@@ -4,8 +4,8 @@ export default {
     PROD: "wss://eks.xverse.cn/ws",
   },
   REPORT_URL: {
-    DEV: "https://xa.xverse.cn:6680/collect",
-    PROD: "https://xa.xverse.cn/collect",
+    DEV: "https://xa.xverse.cn:6680/collect1",
+    PROD: "https://xa.xverse.cn/collect1",
   },
   MAX_RECONNECT_COUNT: 3,
   DEFAULT_JOINROOM_TIMEOUT: 15e3,

+ 2 - 2
src/main.js

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

+ 7 - 3
src/v2Decoder/index.js

@@ -408,7 +408,9 @@ if ("function" === typeof importScripts) {
 
     needToSkip = this.skipFrameUntilI && !mediaArray[index].isIDR;
     var loginfo =
-      "pts: " +
+      "index:" +
+      index +
+      ", pts: " +
       mediaArray[index].pts +
       ", isidr: " +
       mediaArray[index].isIDR +
@@ -419,6 +421,8 @@ if ("function" === typeof importScripts) {
       ", needToSkip: " +
       needToSkip;
 
+    console.log("procBufItem", index, mediaArray[index]);
+
     if (this.slotHasContent(index) && !needToSkip) {
       // console.log("[xmedia] %s ------------ 001", mediaArray[index].pts)
       let objData = {
@@ -556,7 +560,7 @@ if ("function" === typeof importScripts) {
       }
       return false;
     }
-
+    
     this.procBufItem(this.readPtr);
 
     // if (this.getNumOfPktToBeDec() > this.prevBufNum) {
@@ -1226,7 +1230,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(