gemercheung 3 년 전
부모
커밋
9398381f7d
1개의 변경된 파일83개의 추가작업 그리고 70개의 파일을 삭제
  1. 83 70
      src/scene/scene.service.ts

+ 83 - 70
src/scene/scene.service.ts

@@ -38,7 +38,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;
@@ -263,7 +263,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     console.log('rotateUnlock条件--->' + rotateUnlock, this.globalOptLock);
 
     if (rotateUnlock) {
-      console.log('20220627test:handleRotate')
+      console.log('20220627test:handleRotate');
       const start = performance.now();
       // 当move时处理 _rotateCount是移动端同时触发的问题,rotateStopThrottle是减少重复抖动stop的处理。
       this.holdSteam();
@@ -290,7 +290,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),
             );
             if (!this.stopRotated) {
               await this.seqExehandleRotateStream(stream);
@@ -455,7 +455,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
    */
   async handleRotateOrWalkingStop(request): Promise<boolean> {
     this.rotateStopThrottle = true;
-    this.isStopJointing = true
+    this.isStopJointing = true;
     const lastStreamFrame = this.lastMoveStreamFrame.getValue();
     this.logger.log(
       'handleRotateOrWalkingStop-frame',
@@ -486,16 +486,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);
@@ -523,7 +523,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       if (hasPush.done) {
         //console.log('20220627test:handleRotateOrWalkingStop-stop:'+streamData.clipPath+'**'+streamData.frame);
         this.frameCnt.next(hasPush.frame);
-        this.isStopJointing = false
+        this.isStopJointing = false;
         // this.onMoving.next(false);
         // this.cleanMoveSteam();
         return Promise.resolve(true);
@@ -701,15 +701,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);
 
@@ -764,16 +764,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;
@@ -822,23 +822,21 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
    * joystick 二合一推流
    * @param joystickRes StreamMetaType | StreamFrameType;
    */
-  handlePushJoyStickSteamSeq = seqExeAsyncFn(this.handlePushJoyStickSteam)
+  handlePushJoyStickSteamSeq = seqExeAsyncFn(this.handlePushJoyStickSteam);
 
   async handlePushJoyStickSteam(joystickRes: StreamReplyType) {
     this.holdSteam();
-    this.globalOptLock = true
+    this.globalOptLock = true;
 
     //console.log('joystickRes有mediaSrc', joystickRes.mediaSrc);
     console.log(
       'handlejoystick-angle->相机角度-------------------------:' +
-      joystickRes['newUserStates'][0].playerState.camera.angle.yaw,
+        joystickRes['newUserStates'][0].playerState.camera.angle.yaw,
     );
     let streamData: StreamFrameType | StreamMetaType;
 
-    // if (this.joystickFrameCnt === -1) {
     this.joystickFrameCnt = this.frameCnt.getValue() + 1;
-    // }
-    // this.joystickFrameCnt += 1;
+
     const hasMedia = joystickRes?.mediaSrc && joystickRes?.mediaSrc.length > 0;
 
     if (hasMedia) {
@@ -853,7 +851,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         serverTime: this.mockserverTime,
         DIR: setDIR,
       };
-
+      console.log(
+        'handlejoystick-hasMedia->-------------------------:' +
+          ' frame: ' +
+          streamData.frame +
+          mediaSrc +
+          '  IDR :' +
+          setDIR,
+      );
     } else {
       streamData = {
         frame: this.joystickFrameCnt,
@@ -861,15 +866,18 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       };
     }
 
-    console.log('20220627test-complementFrame 进行1' + '***' + streamData.frame);
+    console.log(
+      '20220627test-complementFrame 进行1' + '***' + streamData.frame,
+    );
+
     // 过滤新东西, 推完给回false
     this.moveService.sendingFrameForJoystick = true;
 
     const hasPush = hasMedia
       ? await this.streamService.pushFrameToSteam(streamData as StreamFrameType)
       : await this.streamService.pushMetaDataToSteam(
-        streamData as StreamMetaType,
-      );
+          streamData as StreamMetaType,
+        );
 
     if (hasPush.done) {
       this.isJoystickHasStream = true;
@@ -902,7 +910,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           this.user_id,
         ) as StreamReplyType;
         if (complementFrame) {
-          console.log('20220627test-complementFrame 进行' + complementFrame.mediaSrc + '***' + this.frameCnt.value);
+          console.log(
+            '20220627test-complementFrame 进行' +
+              complementFrame.mediaSrc +
+              '***' +
+              this.frameCnt.value,
+          );
           // 第二次或N次进入时如果有值直接重新进入流主程
           this.handlePushJoyStickSteamSeq(complementFrame);
           this.globalOptLock = true;
@@ -973,7 +986,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));
@@ -1056,14 +1069,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(
@@ -1084,7 +1097,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
             // this.logger.log('path-update-index', isLastFrameIndex);
 
             if (res.done) {
-              this.frameCnt.next(res.frame)
+              this.frameCnt.next(res.frame);
               //关节点入库
               if (isLastFrameIndex > -1) {
                 //this.logger.log('path-update-array', this.lastMovingPointArray);
@@ -1315,12 +1328,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(),
             ' state: ' + this.peer.state(),
           );
           if (frame === 1) {
@@ -1342,7 +1355,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,
@@ -1371,17 +1384,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
             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,
             );
           }