gemercheung 3 سال پیش
والد
کامیت
8c69b65899
1فایلهای تغییر یافته به همراه92 افزوده شده و 86 حذف شده
  1. 92 86
      src/scene/scene.service.ts

+ 92 - 86
src/scene/scene.service.ts

@@ -26,7 +26,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     private rotateService: RotateService,
     private moveService: MoveService,
     private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
-  ) {}
+  ) { }
   @Client(grpcClientOptions) private readonly client: ClientGrpc;
 
   public _frameInteval: NodeJS.Timeout;
@@ -269,16 +269,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         const playerAngle = newUserStates.playerState.player.angle;
         this.logger.log(
           '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;
         console.log('moveService.stop-1:' + breakPointId);
@@ -327,7 +327,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
             const rounded = Number(inMillSeconds).toFixed(3);
             this.logger.log(
               `[timer]-rotate-入队列前: ${rounded}ms -->` +
-                JSON.stringify(stream),
+              JSON.stringify(stream),
             );
 
             this.roQueue.next(stream);
@@ -431,15 +431,15 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       console.log('进入1 - searchRoad');
       this.logger.log(
         '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(
         '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);
 
@@ -509,16 +509,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         if (seqs?.length) {
           this.logger.log(
             '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 inMillSeconds = stop - start;
@@ -611,22 +611,22 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         }
         clearTimeout(this._JoyStickingTimeout);
         this._JoyStickingTimeout = setTimeout(() => {
-          const complementFrame = this.moveService.complementFrame(
-            this.user_id,
-          ) as StreamReplyType;
-          console.log('has-complementFrame', complementFrame);
-          if (complementFrame) {
-            pushJoyStickSteam(complementFrame);
-          } else {
-            this.frameCnt.next(hasPush.frame);
-            this.logger.log('joystick opt done');
-            this.logger.log('joystick 交权给空流,当前pts', hasPush.frame);
-            // this.frameCnt.next(res.frame);
-            this.onJoysticking.next(false);
-            this.resumeStream();
-            this.joystickFrameCnt = -1;
-            this.isJoystickHasStream = false;
-          }
+          // const complementFrame = this.moveService.complementFrame(
+          //   this.user_id,
+          // ) as StreamReplyType;
+          // console.log('has-complementFrame', complementFrame);
+          // if (complementFrame) {
+          //   pushJoyStickSteam(complementFrame);
+          // } else {
+          this.frameCnt.next(hasPush.frame);
+          this.logger.log('joystick opt done');
+          this.logger.log('joystick 交权给空流,当前pts', hasPush.frame);
+          // this.frameCnt.next(res.frame);
+          this.onJoysticking.next(false);
+          this.resumeStream();
+          this.joystickFrameCnt = -1;
+          this.isJoystickHasStream = false;
+          // }
         }, 200);
       } else {
         console.error('joystick-流地址有误::', joystickRes.mediaSrc);
@@ -642,7 +642,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       const joystickRes = await this.moveService.seqExeJoystick(request);
       this.logger.log(
         'joystick-breakPointId:' +
-          this.moveService.users[this.user_id].breakPointId,
+        this.moveService.users[this.user_id].breakPointId,
       );
       // 有数据 [0]是rotate数据,[1-infinity]是walking数据
       this.logger.log('joystickRes', JSON.stringify(joystickRes));
@@ -658,11 +658,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         //     ),
         console.log(
           'handlejoysticktesttest:' +
-            joystickRes.mediaSrc +
-            ',相机坐标:' +
-            JSON.stringify(
-              joystickRes.newUserStates[0].playerState.player.position,
-            ),
+          joystickRes.mediaSrc +
+          ',相机坐标:' +
+          JSON.stringify(
+            joystickRes.newUserStates[0].playerState.player.position,
+          ),
         );
         if (joystickRes.mediaSrc) {
           pushJoyStickSteam(joystickRes);
@@ -693,10 +693,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
                   'joystick-位置流 交权给空流,当前pts',
                   res.frame,
                 );
-                // this.frameCnt.next(res.frame);
-                this.onJoysticking.next(false);
-                this.resumeStream();
-                this.joystickFrameCnt = -1;
+                const complementFrame = this.moveService.complementFrame(
+                  this.user_id,
+                ) as StreamReplyType;
+                console.log('has-complementFrame', complementFrame);
+                if (complementFrame) {
+                  pushJoyStickSteam(complementFrame);
+                } else {
+                  this.onJoysticking.next(false);
+                  this.resumeStream();
+                  this.joystickFrameCnt = -1;
+                }
               }, 200);
             } else {
               console.error(
@@ -799,14 +806,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           };
           this.logger.log(
             '[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,
           );
           this.logger.log(
@@ -1002,8 +1009,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
           const IDRflag = this._rotateCurrentFame % 5 === 0 ? 1 : 3;
           this.logger.log(
-            `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${
-              this._rotateCurrentFame
+            `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${this._rotateCurrentFame
             } IDRflag:${IDRflag}`,
           );
           stream.DIR = this.rotateFirstIDR ? 1 : IDRflag;
@@ -1014,12 +1020,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
           this.logger.log(
             '[media-rotate]: ' +
-              ', frame: ' +
-              stream.frame +
-              ', rotateframeCnt: ' +
-              this.rotateframeCnt +
-              ', clipPath: ' +
-              stream.clipPath,
+            ', frame: ' +
+            stream.frame +
+            ', rotateframeCnt: ' +
+            this.rotateframeCnt +
+            ', clipPath: ' +
+            stream.clipPath,
             // stream.metaData,
           );
           // this.logger.log(
@@ -1081,12 +1087,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           this.logger.log('frame', frame);
           console.log(
             'mock' +
-              ' maxMessageSize: ' +
-              this.channel.maxMessageSize() +
-              ' bytesReceived: ' +
-              this.peer.bytesReceived() +
-              ' bytesSent: ' +
-              this.peer.bytesSent(),
+            ' maxMessageSize: ' +
+            this.channel.maxMessageSize() +
+            ' bytesReceived: ' +
+            this.peer.bytesReceived() +
+            ' bytesSent: ' +
+            this.peer.bytesSent(),
           );
           if (frame === 1) {
             redisData = await this.rotateService.echo(this.user_id, true);
@@ -1101,7 +1107,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
                 delete redisData.mediaSrc;
                 this.logger.log(
                   `user:${this.user_id}:first render stream` +
-                    JSON.stringify({ path: clipPath, meta: redisData }),
+                  JSON.stringify({ path: clipPath, meta: redisData }),
                 );
                 const status = await this.pushFirstRender(
                   clipPath,
@@ -1129,15 +1135,15 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
             console.log(
               '空白流条件-->:' +
-                isOk +
-                ' onMoving: ' +
-                this.onMoving.value +
-                ' onRotating: ' +
-                this.onRotating.value +
-                ' onJoysticking: ' +
-                this.onJoysticking.value +
-                ' firstRender: ' +
-                this.firstRender,
+              isOk +
+              ' onMoving: ' +
+              this.onMoving.value +
+              ' onRotating: ' +
+              this.onRotating.value +
+              ' onJoysticking: ' +
+              this.onJoysticking.value +
+              ' firstRender: ' +
+              this.firstRender,
             );
           }