|
@@ -9,8 +9,8 @@ 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 MaxDelayTime = 80; //超过这个值就需要干预(操作杆)
|
|
|
+const MaxBufferCameraInfo = 3; //超过这个值就需要干预(操作杆)
|
|
|
const MaxNet = 3;
|
|
|
|
|
|
const seqExeAsyncFn = (asyncFn) => {
|
|
@@ -359,7 +359,7 @@ export class MoveService implements OnModuleInit {
|
|
|
);
|
|
|
const user = this.users[userId];
|
|
|
let i;
|
|
|
- for (i = 1; i < moveFrames.length; i+=3) {
|
|
|
+ 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) {
|
|
@@ -797,17 +797,20 @@ export class MoveService implements OnModuleInit {
|
|
|
);
|
|
|
this.reply.actionResponses[0].actionType = actionType;
|
|
|
|
|
|
- console.log('20220708_延时->'+time_delay);
|
|
|
+ console.log('20220708_延时->' + time_delay);
|
|
|
// //网络延迟的情况下,就暂时不推流
|
|
|
- if(time_delay && time_delay>MaxDelayTime){
|
|
|
+ if (time_delay && time_delay > MaxDelayTime) {
|
|
|
user.netQua = 0;
|
|
|
- }
|
|
|
- else if(time_delay && time_delay<MaxDelayTime && user.netQua<MaxNet){
|
|
|
- ++user.netQua
|
|
|
+ } else if (
|
|
|
+ time_delay &&
|
|
|
+ time_delay < MaxDelayTime &&
|
|
|
+ user.netQua < MaxNet
|
|
|
+ ) {
|
|
|
+ ++user.netQua;
|
|
|
}
|
|
|
|
|
|
- if(user.netQua<MaxNet){
|
|
|
- if(user.lastJoyStickMediaSrc){
|
|
|
+ if (user.netQua < MaxNet) {
|
|
|
+ if (user.lastJoyStickMediaSrc) {
|
|
|
user.lastJoyStickMediaSrc = false;
|
|
|
return this.reply;
|
|
|
}
|
|
@@ -826,7 +829,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);
|
|
|
+ console.log('20220708_mediaSrc1:' + cameraInfo.mediaSrc);
|
|
|
}
|
|
|
|
|
|
user.camera.position = JSON.parse(
|
|
@@ -1275,7 +1278,13 @@ export class MoveService implements OnModuleInit {
|
|
|
chooseBreakPointId,
|
|
|
index,
|
|
|
);
|
|
|
- this.setCameraInfo(appId, userId, moveFrames, breakPointId, chooseBreakPointId);
|
|
|
+ this.setCameraInfo(
|
|
|
+ appId,
|
|
|
+ userId,
|
|
|
+ moveFrames,
|
|
|
+ breakPointId,
|
|
|
+ chooseBreakPointId,
|
|
|
+ );
|
|
|
|
|
|
user.breakPointId = chooseBreakPointId;
|
|
|
|
|
@@ -1314,7 +1323,7 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- setCameraInfo(appId, userId,moveFrames, startBreakPointId, endBreakPointId) {
|
|
|
+ setCameraInfo(appId, userId, moveFrames, startBreakPointId, endBreakPointId) {
|
|
|
// let moveInterval = 1;
|
|
|
// console.log('20220708_cameraInfos设置->'+this.cameraInfos.length);
|
|
|
// if(this.cameraInfos.length>MaxBufferCameraInfo){
|
|
@@ -1324,8 +1333,8 @@ export class MoveService implements OnModuleInit {
|
|
|
let moveInterval = 2;
|
|
|
let flag = false;
|
|
|
for (let i = 0; i < moveFrames.length; ++i) {
|
|
|
- if(user.netQua<MaxNet){
|
|
|
- if(i!= 0 && i!= moveFrames.length-1 && i%moveInterval == 0){
|
|
|
+ if (user.netQua < MaxNet) {
|
|
|
+ if (i != 0 && i != moveFrames.length - 1 && i % moveInterval == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
@@ -1363,10 +1372,10 @@ export class MoveService implements OnModuleInit {
|
|
|
'?m=' +
|
|
|
new Date().getTime();
|
|
|
}
|
|
|
- console.log('20220708_mediaSrc3:'+moveFrames[i].mediaSrc);
|
|
|
+ console.log('20220708_mediaSrc3:' + moveFrames[i].mediaSrc);
|
|
|
if (i == 0 || i == moveFrames.length - 1) {
|
|
|
moveFrames[i].isIDR = true;
|
|
|
- if(i == moveFrames.length - 1){
|
|
|
+ if (i == moveFrames.length - 1) {
|
|
|
flag = true;
|
|
|
}
|
|
|
} else {
|
|
@@ -1374,8 +1383,8 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
this.cameraInfos.push(moveFrames[i]);
|
|
|
}
|
|
|
- if(!flag){
|
|
|
- const cameraInfo = moveFrames[moveFrames.length-1];
|
|
|
+ if (!flag) {
|
|
|
+ const cameraInfo = moveFrames[moveFrames.length - 1];
|
|
|
cameraInfo.endBreakPointId = endBreakPointId;
|
|
|
cameraInfo.mediaSrc =
|
|
|
'/' +
|
|
@@ -1383,10 +1392,7 @@ export class MoveService implements OnModuleInit {
|
|
|
'/' +
|
|
|
startBreakPointId +
|
|
|
'/' +
|
|
|
- cameraInfo.file_name.substring(
|
|
|
- 0,
|
|
|
- cameraInfo.file_name.indexOf('.'),
|
|
|
- ) +
|
|
|
+ cameraInfo.file_name.substring(0, cameraInfo.file_name.indexOf('.')) +
|
|
|
'/' +
|
|
|
cameraInfo.file_name +
|
|
|
'?m=' +
|
|
@@ -1399,10 +1405,7 @@ export class MoveService implements OnModuleInit {
|
|
|
'/' +
|
|
|
endBreakPointId +
|
|
|
'/' +
|
|
|
- cameraInfo.file_name.substring(
|
|
|
- 0,
|
|
|
- cameraInfo.file_name.indexOf('.'),
|
|
|
- ) +
|
|
|
+ cameraInfo.file_name.substring(0, cameraInfo.file_name.indexOf('.')) +
|
|
|
'/' +
|
|
|
cameraInfo.file_name +
|
|
|
'?m=' +
|
|
@@ -1410,7 +1413,7 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
cameraInfo.isIDR = true;
|
|
|
this.cameraInfos.push(cameraInfo);
|
|
|
- console.log('20220708_mediaSrc4:'+cameraInfo.mediaSrc);
|
|
|
+ console.log('20220708_mediaSrc4:' + cameraInfo.mediaSrc);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1426,7 +1429,7 @@ export class MoveService implements OnModuleInit {
|
|
|
getCameraInfo() {
|
|
|
if (this.cameraInfos.length > 0) {
|
|
|
const item = this.cameraInfos.shift();
|
|
|
- console.log('20220708_cameraInfos取值->'+this.cameraInfos.length);
|
|
|
+ console.log('20220708_cameraInfos取值->' + this.cameraInfos.length);
|
|
|
return item;
|
|
|
} else {
|
|
|
return null;
|
|
@@ -1507,9 +1510,8 @@ export class MoveService implements OnModuleInit {
|
|
|
// return JSON.parse(JSON.stringify(this.reply));
|
|
|
// }
|
|
|
|
|
|
- async updateCameraInfoForDely(appId,userId,path){
|
|
|
-
|
|
|
- if(path == null){
|
|
|
+ async updateCameraInfoForDely(appId, userId, path) {
|
|
|
+ if (path == null) {
|
|
|
this.cameraInfos = [];
|
|
|
return;
|
|
|
}
|
|
@@ -1531,32 +1533,32 @@ export class MoveService implements OnModuleInit {
|
|
|
if (!moveFrames) {
|
|
|
return null;
|
|
|
}
|
|
|
- frames = frames.concat(moveFrames)
|
|
|
+ frames = frames.concat(moveFrames);
|
|
|
pointIds.push({
|
|
|
- index:frames.length,
|
|
|
- startBreakPointId:start_break_point_id,
|
|
|
- endBreakPointId:end_break_point_id
|
|
|
+ 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 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){
|
|
|
+ if (i == 0) {
|
|
|
isIDR = true;
|
|
|
}
|
|
|
|
|
|
- let startBreakPointId,endBreakPointId;
|
|
|
- for(let j=0;j<pointIds.length;++j){
|
|
|
- if(i<pointIds[j].index+1){
|
|
|
+ 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 =
|
|
|
+ let mediaSrc =
|
|
|
'/' +
|
|
|
appId +
|
|
|
'/' +
|
|
@@ -1580,10 +1582,10 @@ export class MoveService implements OnModuleInit {
|
|
|
'?m=' +
|
|
|
new Date().getTime();
|
|
|
}
|
|
|
- console.log('20220708_mediaSrc2:'+mediaSrc);
|
|
|
+ console.log('20220708_mediaSrc2:' + mediaSrc);
|
|
|
this.cameraInfos.push({
|
|
|
- startBreakPointId:startBreakPointId,
|
|
|
- endBreakPointId:endBreakPointId,
|
|
|
+ startBreakPointId: startBreakPointId,
|
|
|
+ endBreakPointId: endBreakPointId,
|
|
|
camera_position: frame.camera_position,
|
|
|
camera_angle: frame.camera_angle,
|
|
|
mediaSrc: mediaSrc,
|
|
@@ -1591,41 +1593,41 @@ export class MoveService implements OnModuleInit {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- const startBreakPointId = pointIds[pointIds.length-1].startBreakPointId;
|
|
|
- const endBreakPointId = pointIds[pointIds.length-1].endBreakPointId;
|
|
|
- const frame = frames[frames.length-1];
|
|
|
+ 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 +
|
|
|
'/' +
|
|
|
- startBreakPointId +
|
|
|
+ endBreakPointId +
|
|
|
'/' +
|
|
|
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,
|
|
|
- });
|
|
|
+ }
|
|
|
+ this.cameraInfos.push({
|
|
|
+ startBreakPointId: startBreakPointId,
|
|
|
+ endBreakPointId: endBreakPointId,
|
|
|
+ camera_position: frame.camera_position,
|
|
|
+ camera_angle: frame.camera_angle,
|
|
|
+ mediaSrc: mediaSrc,
|
|
|
+ isIDR: true,
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
stopJoystick(userId) {
|