gemercheung 3 years ago
parent
commit
bc6a519a2b

+ 3 - 3
config.production1.yaml

@@ -1,8 +1,8 @@
 app:
 app:
   prefix: /mnt/metaverse/scene
   prefix: /mnt/metaverse/scene
-  startPoint: 141
-  appId: '0000000007'
-
+  startPoint: 22
+  appId: '0000000008'
+# 141--->0000000007
 log:
 log:
   logFolder: /var/log/metaverse
   logFolder: /var/log/metaverse
 
 

+ 1 - 0
restart.sh

@@ -1,3 +1,4 @@
 #! /bin/bash
 #! /bin/bash
+cp config.production1.yaml config.yaml
 npm run build
 npm run build
 NODE_ENV=production pm2 restart main
 NODE_ENV=production pm2 restart main

+ 4 - 3
src/meta.gateway.ts

@@ -35,11 +35,12 @@ initLogger('Debug');
   path: '/ws',
   path: '/ws',
 })
 })
 export class MetaGateway
 export class MetaGateway
-  implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect {
+  implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect
+{
   constructor(
   constructor(
     private readonly sceneService: SceneService,
     private readonly sceneService: SceneService,
     private readonly configService: ConfigService,
     private readonly configService: ConfigService,
-  ) { }
+  ) {}
   private logger: Logger = new Logger('MetaGateway');
   private logger: Logger = new Logger('MetaGateway');
   private peer: PeerConnection = null;
   private peer: PeerConnection = null;
   private timer: NodeJS.Timeout;
   private timer: NodeJS.Timeout;
@@ -291,7 +292,7 @@ export class MetaGateway
           }
           }
         },
         },
       );
       );
-    } catch (error) { }
+    } catch (error) {}
   }
   }
 
 
   handleConnection(client: WebSocket, ...args: any[]) {
   handleConnection(client: WebSocket, ...args: any[]) {

+ 38 - 38
src/move/move.service.ts

@@ -284,7 +284,7 @@ export class MoveService implements OnModuleInit {
       this.reply['actionResponses'][0].traceId = traceId;
       this.reply['actionResponses'][0].traceId = traceId;
       //const index = Math.floor((user.camera.angle.yaw + 1) / 45) % 8; //过渡需要
       //const index = Math.floor((user.camera.angle.yaw + 1) / 45) % 8; //过渡需要
       const index = this.getMoveIndex(user.camera.angle.yaw);
       const index = this.getMoveIndex(user.camera.angle.yaw);
-      
+
       for (let i = 0; i < path.length - 1; ++i) {
       for (let i = 0; i < path.length - 1; ++i) {
         const start_break_point_id = path[i];
         const start_break_point_id = path[i];
         const end_break_point_id = path[i + 1];
         const end_break_point_id = path[i + 1];
@@ -321,7 +321,7 @@ export class MoveService implements OnModuleInit {
             'newUserStates'
             'newUserStates'
           ][0].renderInfo.isMoving = 0;
           ][0].renderInfo.isMoving = 0;
         }
         }
-        
+
         for (let j = 0; j < pathReplys.length; ++j) {
         for (let j = 0; j < pathReplys.length; ++j) {
           pathReplys[j].actionResponses[0].actionType = actionType;
           pathReplys[j].actionResponses[0].actionType = actionType;
         }
         }
@@ -520,7 +520,7 @@ export class MoveService implements OnModuleInit {
       reply.endBreakPointId = endBreakPointId;
       reply.endBreakPointId = endBreakPointId;
       replys.push(reply);
       replys.push(reply);
     }
     }
-    replys[replys.length-1].isIDR = true;
+    replys[replys.length - 1].isIDR = true;
     return replys;
     return replys;
   }
   }
 
 
@@ -683,10 +683,10 @@ export class MoveService implements OnModuleInit {
 
 
       //可行走的区域
       //可行走的区域
       const area = [
       const area = [
-        {x:-600,y:-300},
-        {x:-600,y:250},
-        {x:550,y:250},
-        {x:550,y:-300}
+        { x: -600, y: -300 },
+        { x: -600, y: 250 },
+        { x: 550, y: 250 },
+        { x: 550, y: -300 },
       ];
       ];
 
 
       //找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
       //找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
@@ -716,7 +716,7 @@ export class MoveService implements OnModuleInit {
       this.reply.mediaSrc = null;
       this.reply.mediaSrc = null;
 
 
       //人在哪个角度
       //人在哪个角度
-      let _angle = this.getAngle(
+      const _angle = this.getAngle(
         breakPoint.position,
         breakPoint.position,
         { x: breakPoint.position.x + 1, y: breakPoint.position.y },
         { x: breakPoint.position.x + 1, y: breakPoint.position.y },
         playerPosition,
         playerPosition,
@@ -739,21 +739,26 @@ export class MoveService implements OnModuleInit {
           neighPoint.position,
           neighPoint.position,
         );
         );
 
 
-        let distance = this.getDistance(playerPosition,neighPoint.position);
-        if(closestNeighorId == null || closestDisNeighor>distance){
-          closestNeighorId = surroundPointIds[i]
+        const distance = this.getDistance(playerPosition, neighPoint.position);
+        if (closestNeighorId == null || closestDisNeighor > distance) {
+          closestNeighorId = surroundPointIds[i];
           closestDisNeighor = distance;
           closestDisNeighor = distance;
         }
         }
 
 
-        if((this.getOffsetAngle(angle , _angle)<90)&&(minAngleNeighorId == null || this.getOffsetAngle(closestAngleNeighor , _angle)>this.getOffsetAngle(angle , _angle))){
-          minAngleNeighorId = surroundPointIds[i]
+        if (
+          this.getOffsetAngle(angle, _angle) < 90 &&
+          (minAngleNeighorId == null ||
+            this.getOffsetAngle(closestAngleNeighor, _angle) >
+              this.getOffsetAngle(angle, _angle))
+        ) {
+          minAngleNeighorId = surroundPointIds[i];
           closestAngleNeighor = angle;
           closestAngleNeighor = angle;
         }
         }
       }
       }
 
 
       //超出范围了
       //超出范围了
       if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
       if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
-        console.log('20220627test-joystick-moveCamera')
+        console.log('20220627test-joystick-moveCamera');
         return await this.moveCamera(
         return await this.moveCamera(
           breakPointId,
           breakPointId,
           closestNeighorId,
           closestNeighorId,
@@ -762,13 +767,12 @@ export class MoveService implements OnModuleInit {
           traceId,
           traceId,
           actionType,
           actionType,
         );
         );
-      } 
-      else {
-        let inside = this.isPointInPoly(playerPosition, area);
+      } else {
+        const inside = this.isPointInPoly(playerPosition, area);
         //超出区域
         //超出区域
-        if(!inside){
-          if(minAngleNeighorId != null){
-            console.log('20220627test-joystick-moveDirect')
+        if (!inside) {
+          if (minAngleNeighorId != null) {
+            console.log('20220627test-joystick-moveDirect');
             return await this.moveDirect(
             return await this.moveDirect(
               playerPosition,
               playerPosition,
               closestDis,
               closestDis,
@@ -779,8 +783,7 @@ export class MoveService implements OnModuleInit {
               traceId,
               traceId,
               actionType,
               actionType,
             );
             );
-          }
-          else{
+          } else {
             return null;
             return null;
           }
           }
         }
         }
@@ -793,7 +796,9 @@ export class MoveService implements OnModuleInit {
 
 
         const cameraInfo = this.getCameraInfo();
         const cameraInfo = this.getCameraInfo();
         if (cameraInfo != null) {
         if (cameraInfo != null) {
-          console.log('20220627test-joystick-自由-合并,'+this.cameraInfos.length)
+          console.log(
+            '20220627test-joystick-自由-合并,' + this.cameraInfos.length,
+          );
           this.reply['newUserStates'][0].playerState.camera.position =
           this.reply['newUserStates'][0].playerState.camera.position =
             cameraInfo.camera_position;
             cameraInfo.camera_position;
           this.reply['newUserStates'][0].playerState.camera.angle =
           this.reply['newUserStates'][0].playerState.camera.angle =
@@ -814,9 +819,8 @@ export class MoveService implements OnModuleInit {
           user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
           user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
 
 
           this.sendingFrameForJoystick = true;
           this.sendingFrameForJoystick = true;
-        } 
-        else{
-          console.log('20220627test-joystick-自由-不合并')
+        } else {
+          console.log('20220627test-joystick-自由-不合并');
         }
         }
         return this.reply;
         return this.reply;
       }
       }
@@ -1353,7 +1357,7 @@ export class MoveService implements OnModuleInit {
 
 
   complementFrame(userId) {
   complementFrame(userId) {
     if (this.cameraInfos.length > 0) {
     if (this.cameraInfos.length > 0) {
-      console.log('20220627test-执行complementFrame,'+new Date().getTime())
+      console.log('20220627test-执行complementFrame,' + new Date().getTime());
       const user = this.users[userId];
       const user = this.users[userId];
       const cameraInfo = this.cameraInfos.shift();
       const cameraInfo = this.cameraInfos.shift();
       this.reply.traceIds = [];
       this.reply.traceIds = [];
@@ -1666,11 +1670,7 @@ export class MoveService implements OnModuleInit {
 
 
     let inside = false;
     let inside = false;
 
 
-    for (
-      let i = 0, j = points.length - 1;
-      i < points.length;
-      j = i++
-    ) {
+    for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
       const pt1 = points[i];
       const pt1 = points[i];
       const pt2 = points[j];
       const pt2 = points[j];
 
 
@@ -1702,16 +1702,16 @@ export class MoveService implements OnModuleInit {
     return 0;
     return 0;
   }
   }
 
 
-  getOffsetAngle(angle1,angle2){
-    if(angle1<0){
-      angle1 = 360+angle1;
+  getOffsetAngle(angle1, angle2) {
+    if (angle1 < 0) {
+      angle1 = 360 + angle1;
       //return Math.min(Math.abs(angle1-angle2),Math.abs());
       //return Math.min(Math.abs(angle1-angle2),Math.abs());
     }
     }
 
 
-    if(angle2<0){
-      angle2 = 360+angle2;
+    if (angle2 < 0) {
+      angle2 = 360 + angle2;
     }
     }
 
 
-    return Math.min(Math.abs(angle1 - angle2),360 - Math.abs(angle1 - angle2))
+    return Math.min(Math.abs(angle1 - angle2), 360 - Math.abs(angle1 - angle2));
   }
   }
 }
 }

+ 7 - 1
src/rotate/rotate.service.ts

@@ -55,7 +55,13 @@ export class RotateService {
     },
     },
   };
   };
 
 
-  init(app_id: string, userId: string,skinId: string,roomId: string,avatar_id: string) {
+  init(
+    app_id: string,
+    userId: string,
+    skinId: string,
+    roomId: string,
+    avatar_id: string,
+  ) {
     const user = {
     const user = {
       appId: null,
       appId: null,
       userId: null,
       userId: null,

+ 7 - 1
src/scene/scene.service copy.ts

@@ -232,7 +232,13 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
   init(request: InitRequest) {
   init(request: InitRequest) {
     try {
     try {
       //this.rotateService.init(request.app_id, request.user_id);
       //this.rotateService.init(request.app_id, request.user_id);
-      this.rotateService.init(request.app_id, request.user_id,request.skin_id,request.roomId,request.avatar_id);
+      this.rotateService.init(
+        request.app_id,
+        request.user_id,
+        request.skin_id,
+        request.roomId,
+        request.avatar_id,
+      );
       this.cacheService.getClient();
       this.cacheService.getClient();
       // 加载
       // 加载
     } catch (error) {
     } catch (error) {

+ 7 - 1
src/scene/scene.service-b1.ts

@@ -196,7 +196,13 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
   init(request: InitRequest) {
   init(request: InitRequest) {
     try {
     try {
       //this.rotateService.init(request.app_id, request.user_id);
       //this.rotateService.init(request.app_id, request.user_id);
-      this.rotateService.init(request.app_id, request.user_id,request.skin_id,request.roomId,request.avatar_id);
+      this.rotateService.init(
+        request.app_id,
+        request.user_id,
+        request.skin_id,
+        request.roomId,
+        request.avatar_id,
+      );
       this.cacheService.getClient();
       this.cacheService.getClient();
       // 加载
       // 加载
     } catch (error) {
     } catch (error) {

+ 7 - 1
src/scene/scene.service-k1.ts

@@ -197,7 +197,13 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
   init(request: InitRequest) {
   init(request: InitRequest) {
     try {
     try {
       //this.rotateService.init(request.app_id, request.user_id);
       //this.rotateService.init(request.app_id, request.user_id);
-      this.rotateService.init(request.app_id, request.user_id,request.skin_id,request.roomId,request.avatar_id);
+      this.rotateService.init(
+        request.app_id,
+        request.user_id,
+        request.skin_id,
+        request.roomId,
+        request.avatar_id,
+      );
       this.cacheService.getClient();
       this.cacheService.getClient();
       // 加载
       // 加载
     } catch (error) {
     } catch (error) {

+ 84 - 71
src/scene/scene.service.ts

@@ -38,7 +38,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     private rotateService: RotateService,
     private rotateService: RotateService,
     private moveService: MoveService,
     private moveService: MoveService,
     private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
     private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
-  ) { }
+  ) {}
   @Client(grpcClientOptions) private readonly client: ClientGrpc;
   @Client(grpcClientOptions) private readonly client: ClientGrpc;
 
 
   public _frameInteval: NodeJS.Timeout;
   public _frameInteval: NodeJS.Timeout;
@@ -208,7 +208,13 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
 
   init(request: InitRequest) {
   init(request: InitRequest) {
     try {
     try {
-      this.rotateService.init(request.app_id, request.user_id,request.skin_id,request.roomId,request.avatar_id);
+      this.rotateService.init(
+        request.app_id,
+        request.user_id,
+        request.skin_id,
+        request.roomId,
+        request.avatar_id,
+      );
       this.cacheService.getClient();
       this.cacheService.getClient();
       console.log('rotateService::init');
       console.log('rotateService::init');
       this.startSub = this.startSteaming.subscribe((flag) => {
       this.startSub = this.startSteaming.subscribe((flag) => {
@@ -270,7 +276,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       const redisMeta: StreamReplyType = await this.rotateService.seqExeRotate(
       const redisMeta: StreamReplyType = await this.rotateService.seqExeRotate(
         request,
         request,
       );
       );
-      
+
       if (redisMeta && 'mediaSrc' in redisMeta) {
       if (redisMeta && 'mediaSrc' in redisMeta) {
         if (redisMeta.mediaSrc?.length) {
         if (redisMeta.mediaSrc?.length) {
           const src = redisMeta.mediaSrc.split('?')[0];
           const src = redisMeta.mediaSrc.split('?')[0];
@@ -291,7 +297,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
             const rounded = Number(inMillSeconds).toFixed(3);
             const rounded = Number(inMillSeconds).toFixed(3);
             this.logger.log(
             this.logger.log(
               `[timer]-rotate-入队列前: ${rounded}ms -->` +
               `[timer]-rotate-入队列前: ${rounded}ms -->` +
-              JSON.stringify(stream),
+                JSON.stringify(stream),
             );
             );
             if (!this.stopRotated) {
             if (!this.stopRotated) {
               await this.seqExehandleRotateStream(stream);
               await this.seqExehandleRotateStream(stream);
@@ -488,16 +494,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     const playerAngle = newUserStates.playerState.player.angle;
     const playerAngle = newUserStates.playerState.player.angle;
     this.logger.log(
     this.logger.log(
       'stop-data-0' +
       'stop-data-0' +
-      'trace_id: ' +
-      trace_id +
-      'userId:' +
-      userId +
-      'breakPointId :' +
-      breakPointId +
-      'cameraAngle :' +
-      JSON.stringify(cameraAngle) +
-      'playerAngle: ' +
-      JSON.stringify(playerAngle),
+        'trace_id: ' +
+        trace_id +
+        'userId:' +
+        userId +
+        'breakPointId :' +
+        breakPointId +
+        'cameraAngle :' +
+        JSON.stringify(cameraAngle) +
+        'playerAngle: ' +
+        JSON.stringify(playerAngle),
     );
     );
     //debugger;
     //debugger;
     console.log('moveService.stop-1:' + breakPointId);
     console.log('moveService.stop-1:' + breakPointId);
@@ -661,15 +667,15 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       console.log('进入1 - searchRoad');
       console.log('进入1 - searchRoad');
       this.logger.log(
       this.logger.log(
         'handleWalking-users' +
         'handleWalking-users' +
-        JSON.stringify(this.moveService.users) +
-        ' this.user_id: ' +
-        this.user_id,
+          JSON.stringify(this.moveService.users) +
+          ' this.user_id: ' +
+          this.user_id,
       );
       );
       this.logger.log(
       this.logger.log(
         'handleWalking-currentUser' +
         'handleWalking-currentUser' +
-        JSON.stringify(user) +
-        ' this.user_id: ' +
-        this.user_id,
+          JSON.stringify(user) +
+          ' this.user_id: ' +
+          this.user_id,
       );
       );
       console.log('path-start' + user.breakPointId);
       console.log('path-start' + user.breakPointId);
 
 
@@ -699,7 +705,10 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           for (let i = 0; i <= walkingRes.length - 1; i++) {
           for (let i = 0; i <= walkingRes.length - 1; i++) {
             Array.from(walkingRes[i]).forEach(
             Array.from(walkingRes[i]).forEach(
               (item: StreamReplyType, index: number) => {
               (item: StreamReplyType, index: number) => {
-                console.log('20220628test:handleWalking->'+item['newUserStates'][0].renderInfo.isMoving)
+                console.log(
+                  '20220628test:handleWalking->' +
+                    item['newUserStates'][0].renderInfo.isMoving,
+                );
                 //const IDRflag = index % 5 === 0 ? 1 : 3;
                 //const IDRflag = index % 5 === 0 ? 1 : 3;
                 const IDRflag = item.isIDR ? 1 : 3;
                 const IDRflag = item.isIDR ? 1 : 3;
                 const dir = this.isHeaderOrLast(
                 const dir = this.isHeaderOrLast(
@@ -725,16 +734,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         if (seqs?.length) {
         if (seqs?.length) {
           this.logger.log(
           this.logger.log(
             'walking --队列总览:' +
             'walking --队列总览:' +
-            ' 总段数: ' +
-            walkingRes.length +
-            ' 镜头帧数:' +
-            walkingRes[0].length +
-            ' 行走段数:' +
-            (walkingRes[0]?.length
-              ? walkingRes.length - 1
-              : walkingRes.length) +
-            ' 队列总帧数:' +
-            seqs.length,
+              ' 总段数: ' +
+              walkingRes.length +
+              ' 镜头帧数:' +
+              walkingRes[0].length +
+              ' 行走段数:' +
+              (walkingRes[0]?.length
+                ? walkingRes.length - 1
+                : walkingRes.length) +
+              ' 队列总帧数:' +
+              seqs.length,
           );
           );
           const stop = performance.now();
           const stop = performance.now();
           const inMillSeconds = stop - start;
           const inMillSeconds = stop - start;
@@ -792,7 +801,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     //console.log('joystickRes有mediaSrc', joystickRes.mediaSrc);
     //console.log('joystickRes有mediaSrc', joystickRes.mediaSrc);
     console.log(
     console.log(
       'handlejoystick-angle->相机角度-------------------------:' +
       'handlejoystick-angle->相机角度-------------------------:' +
-      joystickRes['newUserStates'][0].playerState.camera.angle.yaw,
+        joystickRes['newUserStates'][0].playerState.camera.angle.yaw,
     );
     );
     let streamData: StreamFrameType | StreamMetaType;
     let streamData: StreamFrameType | StreamMetaType;
 
 
@@ -814,11 +823,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       };
       };
       console.log(
       console.log(
         'handlejoystick-hasMedia->-------------------------:' +
         'handlejoystick-hasMedia->-------------------------:' +
-        ' frame: ' +
-        streamData.frame +
-        mediaSrc +
-        '  IDR :' +
-        setDIR,
+          ' frame: ' +
+          streamData.frame +
+          mediaSrc +
+          '  IDR :' +
+          setDIR,
       );
       );
     } else {
     } else {
       streamData = {
       streamData = {
@@ -837,8 +846,8 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     const hasPush = hasMedia
     const hasPush = hasMedia
       ? await this.streamService.pushFrameToSteam(streamData as StreamFrameType)
       ? await this.streamService.pushFrameToSteam(streamData as StreamFrameType)
       : await this.streamService.pushMetaDataToSteam(
       : await this.streamService.pushMetaDataToSteam(
-        streamData as StreamMetaType,
-      );
+          streamData as StreamMetaType,
+        );
 
 
     if (hasPush.done) {
     if (hasPush.done) {
       this.isJoystickHasStream = true;
       this.isJoystickHasStream = true;
@@ -875,9 +884,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         if (complementFrame) {
         if (complementFrame) {
           console.log(
           console.log(
             '20220627test-complementFrame 进行' +
             '20220627test-complementFrame 进行' +
-            complementFrame.mediaSrc +
-            '***' +
-            this.frameCnt.value,
+              complementFrame.mediaSrc +
+              '***' +
+              this.frameCnt.value,
           );
           );
           // 第二次或N次进入时如果有值直接重新进入流主程
           // 第二次或N次进入时如果有值直接重新进入流主程
           this.holdSteam();
           this.holdSteam();
@@ -950,7 +959,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       const joystickRes = await this.moveService.seqExeJoystick(request);
       const joystickRes = await this.moveService.seqExeJoystick(request);
       this.logger.log(
       this.logger.log(
         'joystick-breakPointId:' +
         'joystick-breakPointId:' +
-        this.moveService.users[this.user_id].breakPointId,
+          this.moveService.users[this.user_id].breakPointId,
       );
       );
       // 有数据 [0]是rotate数据,[1-infinity]是walking数据
       // 有数据 [0]是rotate数据,[1-infinity]是walking数据
       //this.logger.log('joystickRes', JSON.stringify(joystickRes));
       //this.logger.log('joystickRes', JSON.stringify(joystickRes));
@@ -1035,14 +1044,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         };
         };
         this.logger.log(
         this.logger.log(
           '[media-move]: ' +
           '[media-move]: ' +
-          ', moveframeCnt: ' +
-          this.moveframeCnt +
-          ', clipPath: ' +
-          stream.clipPath +
-          ', mType: ' +
-          stream.mType +
-          ', DIR: ' +
-          stream.DIR,
+            ', moveframeCnt: ' +
+            this.moveframeCnt +
+            ', clipPath: ' +
+            stream.clipPath +
+            ', mType: ' +
+            stream.mType +
+            ', DIR: ' +
+            stream.DIR,
           // stream.metaData,
           // stream.metaData,
         );
         );
         this.logger.log(
         this.logger.log(
@@ -1140,6 +1149,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     // this.startStream();
     // this.startStream();
     // this.handleStream();
     // this.handleStream();
     this.channel.onBufferedAmountLow(() => {
     this.channel.onBufferedAmountLow(() => {
+      console.error('onBufferedAmountLow-rtt', this.peer.rtt());
       console.error('onBufferedAmountLow', this.channel.bufferedAmount());
       console.error('onBufferedAmountLow', this.channel.bufferedAmount());
       //64k->65536 128k->131072
       //64k->65536 128k->131072
       this.channel.setBufferedAmountLowThreshold(262144);
       this.channel.setBufferedAmountLowThreshold(262144);
@@ -1300,14 +1310,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         try {
         try {
           this.logger.log('frame', frame);
           this.logger.log('frame', frame);
           console.log(
           console.log(
-            'mock' +
-            ' maxMessageSize: ' +
-            this.channel.maxMessageSize() +
-            ' bytesReceived: ' +
-            this.peer.bytesReceived() +
-            ' bytesSent: ' +
-            this.peer.bytesSent(),
-            ' state: ' + this.peer.state(),
+            'networkState:::--->' +
+              ' maxMessageSize: ' +
+              this.channel.maxMessageSize() +
+              ' bytesReceived: ' +
+              this.peer.bytesReceived() +
+              ' bytesSent: ' +
+              this.peer.bytesSent() +
+              ' rtt: ' +
+              this.peer.rtt() +
+              ' state: ' +
+              this.peer.state(),
           );
           );
           if (frame === 1) {
           if (frame === 1) {
             // redisData = await this.rotateService.echo(this.user_id, true);
             // redisData = await this.rotateService.echo(this.user_id, true);
@@ -1328,7 +1341,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
                 delete redisData.mediaSrc;
                 delete redisData.mediaSrc;
                 this.logger.log(
                 this.logger.log(
                   `user:${this.user_id}:first render stream` +
                   `user:${this.user_id}:first render stream` +
-                  JSON.stringify({ path: clipPath, meta: redisData }),
+                    JSON.stringify({ path: clipPath, meta: redisData }),
                 );
                 );
                 const status = await this.pushFirstRender(
                 const status = await this.pushFirstRender(
                   clipPath,
                   clipPath,
@@ -1357,17 +1370,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
 
             console.log(
             console.log(
               '空白流条件-->:' +
               '空白流条件-->:' +
-              isOk +
-              ' onMoving: ' +
-              this.onMoving.value +
-              ' onRotating: ' +
-              this.onRotating.value +
-              ' onJoysticking: ' +
-              this.onJoysticking.value +
-              ' onSteaming: ' +
-              this.onSteaming +
-              ' firstRender: ' +
-              this.firstRender,
+                isOk +
+                ' onMoving: ' +
+                this.onMoving.value +
+                ' onRotating: ' +
+                this.onRotating.value +
+                ' onJoysticking: ' +
+                this.onJoysticking.value +
+                ' onSteaming: ' +
+                this.onSteaming +
+                ' firstRender: ' +
+                this.firstRender,
             );
             );
           }
           }
 
 

+ 2 - 3
src/scene/stream/stream.service.ts

@@ -177,7 +177,7 @@ export class StreamService {
         console.log(
         console.log(
           'stream-size %s : frame: %s, IDR: %s',
           'stream-size %s : frame: %s, IDR: %s',
           ((coordBuff.byteLength + clipBuffer.byteLength) / 1024).toFixed(2) +
           ((coordBuff.byteLength + clipBuffer.byteLength) / 1024).toFixed(2) +
-          ' KB',
+            ' KB',
           frame,
           frame,
           dir,
           dir,
         );
         );
@@ -273,7 +273,6 @@ export class StreamService {
             return resolve({ frame: stream.frame, done: false });
             return resolve({ frame: stream.frame, done: false });
           }
           }
         }
         }
-
       } catch (error) {
       } catch (error) {
         this.logger.error(error);
         this.logger.error(error);
         return reject({ frame: stream.frame, done: false });
         return reject({ frame: stream.frame, done: false });
@@ -345,7 +344,7 @@ export class StreamService {
         console.log(
         console.log(
           'stream-size %s : frame: %s, IDR: %s',
           'stream-size %s : frame: %s, IDR: %s',
           ((coordBuff.byteLength + clipBuffer.byteLength) / 1024).toFixed(2) +
           ((coordBuff.byteLength + clipBuffer.byteLength) / 1024).toFixed(2) +
-          ' KB',
+            ' KB',
           frame,
           frame,
           dir,
           dir,
         );
         );