test pc 3 éve
szülő
commit
757fdd315a
3 módosított fájl, 40 hozzáadás és 47 törlés
  1. 37 38
      src/move/move.service.ts
  2. 2 3
      src/scene/scene.service.ts
  3. 1 6
      src/scene/stream/stream.d.ts

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

@@ -48,7 +48,7 @@ export class MoveService implements OnModuleInit {
     traceIds: [],
     vehicle: null,
     mediaSrc: null,
-    joystickIDR: false,
+    isIDR: false,
     newUserStates: [
       {
         userId: 'dcff36ae4fc1d',
@@ -270,6 +270,12 @@ export class MoveService implements OnModuleInit {
       );
       for (let i = 0; i < checkReplys.length; ++i) {
         checkReplys[i].actionResponses[0].actionType = actionType;
+        if(i == 0|| i == checkReplys.length-1){
+          checkReplys[i].isIDR = true;
+        }
+        else {
+          checkReplys[i].isIDR = false;
+        }
       }
       //replys['P' + user.breakPointId + 'T' + user.breakPointId] = checkReplys;
       replys.push(checkReplys);
@@ -281,26 +287,9 @@ export class MoveService implements OnModuleInit {
       //const index = Math.floor((user.camera.angle.yaw + 1) / 45) % 8; //过渡需要
       const index = this.getMoveIndex(user.camera.angle.yaw);
       for (let i = 0; i < path.length - 1; ++i) {
-        let pathReplys = [];
         const start_break_point_id = path[i];
         const end_break_point_id = path[i + 1];
-        /*
-        //读redis里的数据,按照frame_index的大小排序
-        const key =
-          'moveframe:app_id:' +
-          appId +
-          ':start_break_point_id:' +
-          start_break_point_id +
-          ':end_break_point_id:' +
-          end_break_point_id +
-          ':angle:' +
-          index;
-        const moveFramesRes = await this.cacheService.get(key);
-        if (moveFramesRes == null) {
-          return replys;
-        }
-        const moveFrames = JSON.parse(moveFramesRes);
-        */
+
         const moveFrames = await this.getMoveFrames(
           appId,
           start_break_point_id,
@@ -311,7 +300,7 @@ export class MoveService implements OnModuleInit {
           return replys;
         }
 
-        pathReplys = this.createCacheReplys(
+        let pathReplys = this.createCacheReplys(
           appId,
           moveFrames,
           traceId,
@@ -321,10 +310,15 @@ export class MoveService implements OnModuleInit {
           false,
         );
 
-        if (i == path.length - 2) {
-          pathReplys[pathReplys.length - 1][
-            'newUserStates'
-          ][0].renderInfo.isMoving = 0;
+        //第一段
+        if(i == 0){   
+          //第一帧
+          pathReplys[0].isIDR = true;
+        }
+        //最后一段
+        else if (i == path.length - 2) {
+          //最后一帧
+          pathReplys[pathReplys.length - 1]['newUserStates'][0].renderInfo.isMoving = 0;
         }
         for (let j = 0; j < pathReplys.length; ++j) {
           pathReplys[j].actionResponses[0].actionType = actionType;
@@ -439,6 +433,12 @@ export class MoveService implements OnModuleInit {
 
       reply.startBreakPointId = startBreakPointId;
       reply.endBreakPointId = endBreakPointId;
+      if (i == moveFrames.length - 1){
+        reply.isIDR = true;
+      }
+      else{
+        reply.isIDR = false;
+      }
       replys.push(reply);
     }
     if (i != moveFrames.length - 1) {
@@ -515,6 +515,7 @@ export class MoveService implements OnModuleInit {
       }
       reply.startBreakPointId = startBreakPointId;
       reply.endBreakPointId = endBreakPointId;
+      reply.isIDR = true;
       replys.push(reply);
     }
     return replys;
@@ -1110,7 +1111,7 @@ export class MoveService implements OnModuleInit {
 
           if (cameraInfo.mediaSrc) {
             this.reply.mediaSrc = cameraInfo.mediaSrc;
-            this.reply.joystickIDR = cameraInfo.joystickIDR;
+            this.reply.isIDR = cameraInfo.isIDR;
           }
 
           user.camera.position = JSON.parse(
@@ -1188,7 +1189,7 @@ export class MoveService implements OnModuleInit {
 
         if (cameraInfo.mediaSrc) {
           this.reply.mediaSrc = cameraInfo.mediaSrc;
-          this.reply.joystickIDR = cameraInfo.joystickIDR;
+          this.reply.isIDR = cameraInfo.isIDR;
         }
 
         user.camera.position = JSON.parse(
@@ -1239,15 +1240,15 @@ export class MoveService implements OnModuleInit {
       );
 
       for (let i = 0; i < checkReplys.length; ++i) {
-        let joystickIDR = false;
+        let isIDR = false;
         if (i == 0 || i == checkReplys.length - 1) {
-          joystickIDR = true;
+          isIDR = true;
         }
         this.addCameraInfo(
           checkReplys[i]['newUserStates'][0].playerState.camera.position,
           checkReplys[i]['newUserStates'][0].playerState.camera.angle,
           checkReplys[i].mediaSrc,
-          joystickIDR,
+          isIDR,
         );
       }
 
@@ -1295,7 +1296,7 @@ export class MoveService implements OnModuleInit {
 
         if (cameraInfo.mediaSrc) {
           this.reply.mediaSrc = cameraInfo.mediaSrc;
-          this.reply.joystickIDR = cameraInfo.joystickIDR;
+          this.reply.isIDR = cameraInfo.isIDR;
         }
         this.sendingFrameForJoystick = true;
       }
@@ -1339,23 +1340,21 @@ export class MoveService implements OnModuleInit {
           '?m=' +
           new Date().getTime();
       }
-      if (i == 0) {
-        moveFrames[i].joystickIDR = true;
-      } else if (i == moveFrames.length - 1) {
-        moveFrames[i].joystickIDR = true;
+      if (i == 0 || i == moveFrames.length - 1) {
+        moveFrames[i].isIDR = true;
       } else {
-        moveFrames[i].joystickIDR = false;
+        moveFrames[i].isIDR = false;
       }
       this.cameraInfos.push(moveFrames[i]);
     }
   }
 
-  addCameraInfo(cameraPosition, cameraAngle, mediaSrc, joystickIDR) {
+  addCameraInfo(cameraPosition, cameraAngle, mediaSrc, isIDR) {
     this.cameraInfos.push({
       camera_position: cameraPosition,
       camera_angle: cameraAngle,
       mediaSrc: mediaSrc,
-      joystickIDR: joystickIDR,
+      isIDR: isIDR,
     });
   }
 
@@ -1396,7 +1395,7 @@ export class MoveService implements OnModuleInit {
 
       if (cameraInfo.mediaSrc) {
         this.reply.mediaSrc = cameraInfo.mediaSrc;
-        this.reply.joystickIDR = cameraInfo.joystickIDR;
+        this.reply.isIDR = cameraInfo.isIDR;
       }
 
       user.camera.position = JSON.parse(

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

@@ -329,7 +329,6 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
             } IDRflag:${IDRflag}`,
           );
           stream.DIR = this.rotateFirstIDR ? 1 : IDRflag;
-
           if (this.rotateFirstIDR) {
             this.rotateFirstIDR = false;
           }
@@ -762,7 +761,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       const src = joystickRes.mediaSrc.split('?')[0];
       const mediaSrc = this.configService.get('app.prefix') + src;
       // IDR flag设置为I帧
-      const setDIR = joystickRes.joystickIDR ? 1 : 3;
+      const setDIR = joystickRes.isIDR ? 1 : 3;
       streamData = {
         frame: this.joystickFrameCnt,
         clipPath: mediaSrc,
@@ -794,7 +793,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       }
       this.moveService.sendingFrameForJoystick = false;
       const data = joystickRes as StreamReplyType;
-      console.log('handlejoystick-joystickIDR:' + data.joystickIDR);
+      console.log('handlejoystick-isIDR:' + data.isIDR);
       // if (data?.moveOver && data.moveOver) {
       //   // moveOver
       //   console.log('回传updateUser', data);

+ 1 - 6
src/scene/stream/stream.d.ts

@@ -82,12 +82,7 @@ interface StreamReplyType {
   breakPointId?: number; //临时记录存在的点()
   mType?: string; //类型
   DIR: ?number;
-<<<<<<< HEAD
-  moveStart?: boolean;
-  moveOver?: boolean;
-=======
->>>>>>> master
-  joystickIDR?: boolean;
+  isIDR?: boolean;
 }
 
 // interface NewUserStatesType{