|
@@ -802,10 +802,10 @@ export class MoveService implements OnModuleInit {
|
|
|
// console.log('20220708_cameraInfos不取值');
|
|
|
// return this.reply;
|
|
|
// }
|
|
|
- if(user.lastJoyStickMediaSrc){
|
|
|
- user.lastJoyStickMediaSrc = false;
|
|
|
- return this.reply;
|
|
|
- }
|
|
|
+ // if(user.lastJoyStickMediaSrc){
|
|
|
+ // user.lastJoyStickMediaSrc = false;
|
|
|
+ // return this.reply;
|
|
|
+ // }
|
|
|
const cameraInfo = this.getCameraInfo();
|
|
|
if (cameraInfo != null) {
|
|
|
console.log(
|
|
@@ -820,6 +820,7 @@ export class MoveService implements OnModuleInit {
|
|
|
this.reply.mediaSrc = cameraInfo.mediaSrc;
|
|
|
this.reply.isIDR = cameraInfo.isIDR;
|
|
|
user.lastJoyStickMediaSrc = true;
|
|
|
+ console.log('20220708_mediaSrc1:'+cameraInfo.mediaSrc);
|
|
|
}
|
|
|
|
|
|
user.camera.position = JSON.parse(
|
|
@@ -1313,12 +1314,13 @@ export class MoveService implements OnModuleInit {
|
|
|
// if(this.cameraInfos.length>MaxBufferCameraInfo){
|
|
|
// moveInterval = 1;
|
|
|
// }
|
|
|
- let moveInterval = 4;
|
|
|
+ let moveInterval = 2;
|
|
|
let flag = false;
|
|
|
for (let i = 0; i < moveFrames.length; ++i) {
|
|
|
- if(i!=0 && i%moveInterval == 0){
|
|
|
+ if(i!= 0 && i!= moveFrames.length-1 && i%moveInterval == 0){
|
|
|
continue;
|
|
|
}
|
|
|
+ moveFrames[i].startBreakPointId = startBreakPointId;
|
|
|
moveFrames[i].endBreakPointId = endBreakPointId;
|
|
|
moveFrames[i].mediaSrc =
|
|
|
'/' +
|
|
@@ -1351,6 +1353,7 @@ export class MoveService implements OnModuleInit {
|
|
|
'?m=' +
|
|
|
new Date().getTime();
|
|
|
}
|
|
|
+ console.log('20220708_mediaSrc3:'+moveFrames[i].mediaSrc);
|
|
|
if (i == 0 || i == moveFrames.length - 1) {
|
|
|
moveFrames[i].isIDR = true;
|
|
|
if(i == moveFrames.length - 1){
|
|
@@ -1397,6 +1400,7 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
cameraInfo.isIDR = true;
|
|
|
this.cameraInfos.push(cameraInfo);
|
|
|
+ console.log('20220708_mediaSrc4:'+cameraInfo.mediaSrc);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1421,7 +1425,6 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
complementFrame(userId) {
|
|
|
if (this.cameraInfos.length > 0) {
|
|
|
- this.updateCameraInfoForDely();
|
|
|
console.log('20220627test-执行complementFrame,' + new Date().getTime());
|
|
|
const user = this.users[userId];
|
|
|
const cameraInfo = this.cameraInfos.shift();
|
|
@@ -1469,11 +1472,150 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- updateCameraInfoForDely(){
|
|
|
- if (this.cameraInfos.length > 20) {
|
|
|
- let _interval = Math.floor(this.cameraInfos.length/12);
|
|
|
- this.cameraInfos = this.cameraInfos.filter((itme,index)=>index%_interval === 0);
|
|
|
+ // createDefaultReply(userId){
|
|
|
+ // const user = this.users[userId];
|
|
|
+ // this.reply.traceIds = [];
|
|
|
+ // this.reply['newUserStates'][0].userId = userId;
|
|
|
+ // this.reply['actionResponses'][0].traceId = null;
|
|
|
+ // this.reply['newUserStates'][0].playerState.player.angle.yaw =
|
|
|
+ // user.player.angle.yaw;
|
|
|
+ // this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
|
|
|
+ // JSON.stringify(user.player.position),
|
|
|
+ // );
|
|
|
+ // this.reply['newUserStates'][0].playerState.camera.angle = JSON.parse(
|
|
|
+ // JSON.stringify(user.camera.angle),
|
|
|
+ // );
|
|
|
+ // this.reply['newUserStates'][0].playerState.camera.position = JSON.parse(
|
|
|
+ // JSON.stringify(user.camera.position),
|
|
|
+ // );
|
|
|
+
|
|
|
+ // this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
|
|
|
+ // JSON.stringify(user.player.position),
|
|
|
+ // );
|
|
|
+ // this.reply['newUserStates'][0].renderInfo.isMoving = 0;
|
|
|
+ // this.reply['actionResponses'][0].traceId = null;
|
|
|
+ // return JSON.parse(JSON.stringify(this.reply));
|
|
|
+ // }
|
|
|
+
|
|
|
+ async updateCameraInfoForDely(appId,userId,path){
|
|
|
+
|
|
|
+ if(path == null){
|
|
|
+ this.cameraInfos = [];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const user = this.users[userId];
|
|
|
+ const index = this.getMoveIndex(user.camera.angle.yaw);
|
|
|
+ let frames = [];
|
|
|
+
|
|
|
+ let pointIds = [];
|
|
|
+
|
|
|
+ for (let i = 0; i < path.length - 1; ++i) {
|
|
|
+ const start_break_point_id = path[i];
|
|
|
+ const end_break_point_id = path[i + 1];
|
|
|
+ const moveFrames = await this.getMoveFrames(
|
|
|
+ appId,
|
|
|
+ start_break_point_id,
|
|
|
+ end_break_point_id,
|
|
|
+ index,
|
|
|
+ );
|
|
|
+ if (!moveFrames) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ frames = frames.concat(moveFrames)
|
|
|
+ pointIds.push({
|
|
|
+ index:frames.length,
|
|
|
+ startBreakPointId:start_break_point_id,
|
|
|
+ endBreakPointId:end_break_point_id
|
|
|
+ });
|
|
|
}
|
|
|
+ this.cameraInfos = [];
|
|
|
+ const interval = Math.floor(frames.length/12);
|
|
|
+ for (let i = 0; i < frames.length-1; i+=interval) {
|
|
|
+ const frame = frames[i];
|
|
|
+ let isIDR = false;
|
|
|
+ if(i == 0){
|
|
|
+ isIDR = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ let startBreakPointId,endBreakPointId;
|
|
|
+ for(let j=0;j<pointIds.length;++j){
|
|
|
+ if(i<pointIds[j].index+1){
|
|
|
+ startBreakPointId = pointIds[j].startBreakPointId;
|
|
|
+ endBreakPointId = pointIds[j].endBreakPointId;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let mediaSrc =
|
|
|
+ '/' +
|
|
|
+ appId +
|
|
|
+ '/' +
|
|
|
+ startBreakPointId +
|
|
|
+ '/' +
|
|
|
+ frame.file_name.substring(0, frame.file_name.indexOf('.')) +
|
|
|
+ '/' +
|
|
|
+ frame.file_name +
|
|
|
+ '?m=' +
|
|
|
+ new Date().getTime();
|
|
|
+ if (startBreakPointId > endBreakPointId) {
|
|
|
+ mediaSrc =
|
|
|
+ '/' +
|
|
|
+ appId +
|
|
|
+ '/' +
|
|
|
+ endBreakPointId +
|
|
|
+ '/' +
|
|
|
+ frame.file_name.substring(0, frame.file_name.indexOf('.')) +
|
|
|
+ '/' +
|
|
|
+ frame.file_name +
|
|
|
+ '?m=' +
|
|
|
+ new Date().getTime();
|
|
|
+ }
|
|
|
+ console.log('20220708_mediaSrc2:'+mediaSrc);
|
|
|
+ this.cameraInfos.push({
|
|
|
+ startBreakPointId:startBreakPointId,
|
|
|
+ endBreakPointId:endBreakPointId,
|
|
|
+ camera_position: frame.camera_position,
|
|
|
+ camera_angle: frame.camera_angle,
|
|
|
+ mediaSrc: mediaSrc,
|
|
|
+ isIDR: isIDR,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ const startBreakPointId = pointIds[pointIds.length-1].startBreakPointId;
|
|
|
+ const endBreakPointId = pointIds[pointIds.length-1].endBreakPointId;
|
|
|
+ const frame = frames[frames.length-1];
|
|
|
+ let mediaSrc =
|
|
|
+ '/' +
|
|
|
+ appId +
|
|
|
+ '/' +
|
|
|
+ startBreakPointId +
|
|
|
+ '/' +
|
|
|
+ frame.file_name.substring(0, frame.file_name.indexOf('.')) +
|
|
|
+ '/' +
|
|
|
+ frame.file_name +
|
|
|
+ '?m=' +
|
|
|
+ new Date().getTime();
|
|
|
+ if (startBreakPointId > endBreakPointId) {
|
|
|
+ frame.mediaSrc =
|
|
|
+ '/' +
|
|
|
+ appId +
|
|
|
+ '/' +
|
|
|
+ endBreakPointId +
|
|
|
+ '/' +
|
|
|
+ frame.file_name.substring(0, frame.file_name.indexOf('.')) +
|
|
|
+ '/' +
|
|
|
+ frame.file_name +
|
|
|
+ '?m=' +
|
|
|
+ new Date().getTime();
|
|
|
+ }
|
|
|
+ this.cameraInfos.push({
|
|
|
+ startBreakPointId:startBreakPointId,
|
|
|
+ endBreakPointId:endBreakPointId,
|
|
|
+ camera_position: frame.camera_position,
|
|
|
+ camera_angle: frame.camera_angle,
|
|
|
+ mediaSrc: mediaSrc,
|
|
|
+ isIDR: true,
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
stopJoystick(userId) {
|