|
@@ -9,6 +9,9 @@ import configuration from 'src/config/configuration';
|
|
|
// import * as BreakPointIds from '../../ws/points-BreakPointId.json';
|
|
|
// import { SceneService } from 'src/scene/scene.service';
|
|
|
|
|
|
+const MaxDelayTime = 80; //超过这个值就需要干预(操作杆)
|
|
|
+const MaxBufferCameraInfo = 3; //超过这个值就需要干预(操作杆)
|
|
|
+
|
|
|
const seqExeAsyncFn = (asyncFn) => {
|
|
|
let runPromise = null;
|
|
|
return function seq(...args) {
|
|
@@ -27,8 +30,6 @@ const seqExeAsyncFn = (asyncFn) => {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-let moveInterval = 3;
|
|
|
-
|
|
|
@Injectable()
|
|
|
export class MoveService implements OnModuleInit {
|
|
|
constructor(
|
|
@@ -357,7 +358,7 @@ export class MoveService implements OnModuleInit {
|
|
|
);
|
|
|
const user = this.users[userId];
|
|
|
let i;
|
|
|
- for (i = 1; i < moveFrames.length; i += moveInterval) {
|
|
|
+ for (i = 1; i < moveFrames.length; i+=3) {
|
|
|
const moveFrame = moveFrames[i];
|
|
|
const reply = JSON.parse(JSON.stringify(this.reply));
|
|
|
if (reply.traceIds.indexOf(traceId) == -1) {
|
|
@@ -660,12 +661,13 @@ export class MoveService implements OnModuleInit {
|
|
|
const traceId = actionRequest['trace_id'];
|
|
|
const dir_action = actionRequest['dir_action'];
|
|
|
const actionType = actionRequest['action_type'];
|
|
|
+ const time_delay = actionRequest['time_delay'];
|
|
|
const user = this.users[userId];
|
|
|
const breakPointId = user.breakPointId;
|
|
|
const appId = user.appId;
|
|
|
- moveInterval = 1;
|
|
|
const replys = [];
|
|
|
- const step = 0.5;
|
|
|
+ const step = 0.4;
|
|
|
+ //const step = 1;
|
|
|
const closestDis = 50; //小于这个距离就跳到邻居呼吸点
|
|
|
const distance = step * dir_action.speed_level;
|
|
|
let angle = null;
|
|
@@ -794,6 +796,12 @@ export class MoveService implements OnModuleInit {
|
|
|
);
|
|
|
this.reply.actionResponses[0].actionType = actionType;
|
|
|
|
|
|
+ console.log('20220708_延时->'+time_delay);
|
|
|
+ //网络延迟的情况下,就暂时不推流
|
|
|
+ if(time_delay && time_delay>MaxDelayTime){
|
|
|
+ console.log('20220708_cameraInfos不取值');
|
|
|
+ return this.reply;
|
|
|
+ }
|
|
|
const cameraInfo = this.getCameraInfo();
|
|
|
if (cameraInfo != null) {
|
|
|
console.log(
|
|
@@ -1060,9 +1068,9 @@ export class MoveService implements OnModuleInit {
|
|
|
// } else {
|
|
|
// chooseBreakPointId = neighPoints[0].breakPointId;
|
|
|
// }
|
|
|
- if (closestNeighorId == null) {
|
|
|
- debugger;
|
|
|
- }
|
|
|
+ // if (closestNeighorId == null) {
|
|
|
+ // debugger;
|
|
|
+ // }
|
|
|
chooseBreakPointId = closestNeighorId;
|
|
|
return await this.moveCamera(
|
|
|
breakPointId,
|
|
@@ -1295,7 +1303,17 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
|
|
|
setCameraInfo(appId, moveFrames, startBreakPointId, endBreakPointId) {
|
|
|
- for (let i = 0; i < moveFrames.length; i += moveInterval) {
|
|
|
+ let moveInterval = 1;
|
|
|
+ console.log('20220708_cameraInfos设置->'+this.cameraInfos.length);
|
|
|
+ if(this.cameraInfos.length>MaxBufferCameraInfo){
|
|
|
+ moveInterval = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ let flag = false;
|
|
|
+ for (let i = 0; i < moveFrames.length; ++i) {
|
|
|
+ // if(i!=0 && i%moveInterval == 0){
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
moveFrames[i].endBreakPointId = endBreakPointId;
|
|
|
moveFrames[i].mediaSrc =
|
|
|
'/' +
|
|
@@ -1330,11 +1348,51 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
if (i == 0 || i == moveFrames.length - 1) {
|
|
|
moveFrames[i].isIDR = true;
|
|
|
+ if(i == moveFrames.length - 1){
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
} else {
|
|
|
moveFrames[i].isIDR = false;
|
|
|
}
|
|
|
this.cameraInfos.push(moveFrames[i]);
|
|
|
}
|
|
|
+ if(!flag){
|
|
|
+ const cameraInfo = moveFrames[moveFrames.length-1];
|
|
|
+ cameraInfo.endBreakPointId = endBreakPointId;
|
|
|
+ cameraInfo.mediaSrc =
|
|
|
+ '/' +
|
|
|
+ appId +
|
|
|
+ '/' +
|
|
|
+ startBreakPointId +
|
|
|
+ '/' +
|
|
|
+ cameraInfo.file_name.substring(
|
|
|
+ 0,
|
|
|
+ cameraInfo.file_name.indexOf('.'),
|
|
|
+ ) +
|
|
|
+ '/' +
|
|
|
+ cameraInfo.file_name +
|
|
|
+ '?m=' +
|
|
|
+ new Date().getTime();
|
|
|
+
|
|
|
+ if (startBreakPointId > endBreakPointId) {
|
|
|
+ cameraInfo.mediaSrc =
|
|
|
+ '/' +
|
|
|
+ appId +
|
|
|
+ '/' +
|
|
|
+ endBreakPointId +
|
|
|
+ '/' +
|
|
|
+ cameraInfo.file_name.substring(
|
|
|
+ 0,
|
|
|
+ cameraInfo.file_name.indexOf('.'),
|
|
|
+ ) +
|
|
|
+ '/' +
|
|
|
+ cameraInfo.file_name +
|
|
|
+ '?m=' +
|
|
|
+ new Date().getTime();
|
|
|
+ }
|
|
|
+ cameraInfo.isIDR = true;
|
|
|
+ this.cameraInfos.push(cameraInfo);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
addCameraInfo(cameraPosition, cameraAngle, mediaSrc, isIDR) {
|
|
@@ -1349,6 +1407,7 @@ export class MoveService implements OnModuleInit {
|
|
|
getCameraInfo() {
|
|
|
if (this.cameraInfos.length > 0) {
|
|
|
const item = this.cameraInfos.shift();
|
|
|
+ console.log('20220708_cameraInfos取值->'+this.cameraInfos.length);
|
|
|
return item;
|
|
|
} else {
|
|
|
return null;
|
|
@@ -1357,6 +1416,7 @@ 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();
|
|
@@ -1389,7 +1449,6 @@ export class MoveService implements OnModuleInit {
|
|
|
user.camera.position = JSON.parse(
|
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
|
);
|
|
|
-
|
|
|
user.camera.angle = JSON.parse(JSON.stringify(cameraInfo.camera_angle));
|
|
|
|
|
|
this.sendingFrameForJoystick = true;
|
|
@@ -1405,6 +1464,13 @@ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
stopJoystick(userId) {
|
|
|
console.log('20220627test:stopJoystick');
|
|
|
this.reply.traceIds = [];
|