Browse Source

move joystick add rorate IDR

gemercheung 3 years ago
parent
commit
d9d98e2742
2 changed files with 31 additions and 23 deletions
  1. 1 1
      config.yaml
  2. 30 22
      src/scene/scene.service.ts

+ 1 - 1
config.yaml

@@ -6,7 +6,7 @@ log:
   logFolder: /var/log/metaverse
 
 queueConfig:
-  move: 10
+  move: 50
   rotate: 2
 
 http:

+ 30 - 22
src/scene/scene.service.ts

@@ -25,7 +25,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;
@@ -433,7 +433,10 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           // 头数组[0] rotate 序列, 头是关键key
           walkingRes[0].forEach((item: StreamReplyType, index: number) => {
             item.mType = 'rotate';
-            item.DIR = index === 0 ? 1 : 3;
+            // item.DIR = index === 0 ? 1 : 3;
+            const IDRflag = index % 5 === 0 ? 1 : 3;
+            const dir = this.isHeaderOrLast(index, walkingRes[0].length - 1);
+            item.DIR = dir ? 1 : IDRflag;
           });
         } else {
           this.logger.log('rotateCamData无数据');
@@ -444,11 +447,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           for (let i = 1; i < walkingRes.length; i++) {
             Array.from(walkingRes[i]).forEach(
               (item: StreamReplyType, index: number) => {
+                const IDRflag = index % 5 === 0 ? 1 : 3;
                 const dir = this.isHeaderOrLast(
                   index,
                   walkingRes[i].length - 1,
                 );
-                item.DIR = dir ? 1 : 3;
+                item.DIR = dir ? 1 : IDRflag;
                 //将每段最后一个推入lastMovingPointArray
                 if (index === walkingRes[i].length - 1) {
                   this.lastMovingPointArray.push({
@@ -518,7 +522,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-1', joystickRes);
@@ -530,8 +534,10 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         if (rotateCamData?.length) {
           // 头数组[0] rotate 序列, 头是关键key
           joystickRes[0].forEach((item: StreamReplyType, index: number) => {
+            const IDRflag = index % 5 === 0 ? 1 : 3;
+            const dir = this.isHeaderOrLast(index, joystickRes[0].length - 1);
+            item.DIR = dir ? 1 : IDRflag;
             item.mType = 'rotate';
-            item.DIR = index === 0 ? 1 : 3;
           });
         } else {
           this.logger.log('rotateCamData无数据');
@@ -542,11 +548,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
             this.logger.log('joystickRes-2', joystickRes[i]);
             Array.from(joystickRes[i]).forEach(
               (item: StreamReplyType, index: number) => {
+                const IDRflag = index % 5 === 0 ? 1 : 3;
                 const dir = this.isHeaderOrLast(
                   index,
                   joystickRes[i].length - 1,
                 );
-                item.DIR = dir ? 1 : 3;
+                item.DIR = dir ? 1 : IDRflag;
                 // 将每段最后一个推入lastMovingPointArray
                 if (index === joystickRes[i].length - 1) {
                   this.lastMovingPointArray.push({
@@ -677,14 +684,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(
@@ -863,7 +870,8 @@ 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;
@@ -874,12 +882,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(
@@ -950,7 +958,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,