|
@@ -26,7 +26,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
private rotateService: RotateService,
|
|
private rotateService: RotateService,
|
|
private moveService: MoveService,
|
|
private moveService: MoveService,
|
|
private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
|
|
private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
|
|
- ) {}
|
|
|
|
|
|
+ ) { }
|
|
@Client(grpcClientOptions) private readonly client: ClientGrpc;
|
|
@Client(grpcClientOptions) private readonly client: ClientGrpc;
|
|
|
|
|
|
public _frameInteval: NodeJS.Timeout;
|
|
public _frameInteval: NodeJS.Timeout;
|
|
@@ -71,15 +71,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
private roQueue: RxQueue = new DelayQueue(
|
|
private roQueue: RxQueue = new DelayQueue(
|
|
Number(this.configService.get('queueConfig.rotate')) || 20,
|
|
Number(this.configService.get('queueConfig.rotate')) || 20,
|
|
);
|
|
);
|
|
- private clickQueue: RxQueue = new DebounceQueue(500);
|
|
|
|
private moveQueue: RxQueue = new DelayQueue(
|
|
private moveQueue: RxQueue = new DelayQueue(
|
|
Number(this.configService.get('queueConfig.move')) || 20,
|
|
Number(this.configService.get('queueConfig.move')) || 20,
|
|
);
|
|
);
|
|
- private joystickQueue: RxQueue = new DebounceQueue(500);
|
|
|
|
|
|
+ // private joystickQueue: RxQueue = new DelayQueue(
|
|
|
|
+ // Number(this.configService.get('queueConfig.joystick')) || 10,
|
|
|
|
+ // );
|
|
private requestIFrameQueue: RxQueue = new DebounceQueue(2000);
|
|
private requestIFrameQueue: RxQueue = new DebounceQueue(2000);
|
|
|
|
|
|
private requestIFrameQueueSub: any;
|
|
private requestIFrameQueueSub: any;
|
|
private roRequestQueueSub: any;
|
|
private roRequestQueueSub: any;
|
|
|
|
+ private joystickQueueSub: any;
|
|
private rotateTimeStamp: number;
|
|
private rotateTimeStamp: number;
|
|
private rewalking = false;
|
|
private rewalking = false;
|
|
private firstRender = false;
|
|
private firstRender = false;
|
|
@@ -97,14 +99,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
clipPath: '',
|
|
clipPath: '',
|
|
metaData: '',
|
|
metaData: '',
|
|
});
|
|
});
|
|
- public lastMoveStreamFrameBk: StreamFrameType = {
|
|
|
|
- frame: -1,
|
|
|
|
- clipPath: '',
|
|
|
|
- metaData: '',
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ private isJoystickHasStream = false;
|
|
|
|
+
|
|
|
|
|
|
public users = {};
|
|
public users = {};
|
|
|
|
|
|
|
|
+ public sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
|
|
|
+
|
|
onModuleInit(): void {
|
|
onModuleInit(): void {
|
|
this.sceneGrpcService =
|
|
this.sceneGrpcService =
|
|
this.client.getService<SceneGrpcService>('SceneGrpcService');
|
|
this.client.getService<SceneGrpcService>('SceneGrpcService');
|
|
@@ -267,16 +269,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const playerAngle = newUserStates.playerState.player.angle;
|
|
const playerAngle = newUserStates.playerState.player.angle;
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'stop-data-0' +
|
|
'stop-data-0' +
|
|
- 'trace_id: ' +
|
|
|
|
- trace_id +
|
|
|
|
- 'userId:' +
|
|
|
|
- userId +
|
|
|
|
- 'breakPointId :' +
|
|
|
|
- breakPointId +
|
|
|
|
- 'cameraAngle :' +
|
|
|
|
- JSON.stringify(cameraAngle) +
|
|
|
|
- 'playerAngle: ' +
|
|
|
|
- JSON.stringify(playerAngle),
|
|
|
|
|
|
+ 'trace_id: ' +
|
|
|
|
+ trace_id +
|
|
|
|
+ 'userId:' +
|
|
|
|
+ userId +
|
|
|
|
+ 'breakPointId :' +
|
|
|
|
+ breakPointId +
|
|
|
|
+ 'cameraAngle :' +
|
|
|
|
+ JSON.stringify(cameraAngle) +
|
|
|
|
+ 'playerAngle: ' +
|
|
|
|
+ JSON.stringify(playerAngle),
|
|
);
|
|
);
|
|
//debugger;
|
|
//debugger;
|
|
console.log('moveService.stop-1:' + breakPointId);
|
|
console.log('moveService.stop-1:' + breakPointId);
|
|
@@ -325,7 +327,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const rounded = Number(inMillSeconds).toFixed(3);
|
|
const rounded = Number(inMillSeconds).toFixed(3);
|
|
this.logger.log(
|
|
this.logger.log(
|
|
`[timer]-rotate-入队列前: ${rounded}ms -->` +
|
|
`[timer]-rotate-入队列前: ${rounded}ms -->` +
|
|
- JSON.stringify(stream),
|
|
|
|
|
|
+ JSON.stringify(stream),
|
|
);
|
|
);
|
|
|
|
|
|
this.roQueue.next(stream);
|
|
this.roQueue.next(stream);
|
|
@@ -429,15 +431,15 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
console.log('进入1 - searchRoad');
|
|
console.log('进入1 - searchRoad');
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'handleWalking-users' +
|
|
'handleWalking-users' +
|
|
- JSON.stringify(this.moveService.users) +
|
|
|
|
- ' this.user_id: ' +
|
|
|
|
- this.user_id,
|
|
|
|
|
|
+ JSON.stringify(this.moveService.users) +
|
|
|
|
+ ' this.user_id: ' +
|
|
|
|
+ this.user_id,
|
|
);
|
|
);
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'handleWalking-currentUser' +
|
|
'handleWalking-currentUser' +
|
|
- JSON.stringify(user) +
|
|
|
|
- ' this.user_id: ' +
|
|
|
|
- this.user_id,
|
|
|
|
|
|
+ JSON.stringify(user) +
|
|
|
|
+ ' this.user_id: ' +
|
|
|
|
+ this.user_id,
|
|
);
|
|
);
|
|
console.log('path-start' + user.breakPointId);
|
|
console.log('path-start' + user.breakPointId);
|
|
|
|
|
|
@@ -507,16 +509,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
if (seqs?.length) {
|
|
if (seqs?.length) {
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'walking --队列总览:' +
|
|
'walking --队列总览:' +
|
|
- ' 总段数: ' +
|
|
|
|
- walkingRes.length +
|
|
|
|
- ' 镜头帧数:' +
|
|
|
|
- walkingRes[0].length +
|
|
|
|
- ' 行走段数:' +
|
|
|
|
- (walkingRes[0]?.length
|
|
|
|
- ? walkingRes.length - 1
|
|
|
|
- : walkingRes.length) +
|
|
|
|
- ' 队列总帧数:' +
|
|
|
|
- seqs.length,
|
|
|
|
|
|
+ ' 总段数: ' +
|
|
|
|
+ walkingRes.length +
|
|
|
|
+ ' 镜头帧数:' +
|
|
|
|
+ walkingRes[0].length +
|
|
|
|
+ ' 行走段数:' +
|
|
|
|
+ (walkingRes[0]?.length
|
|
|
|
+ ? walkingRes.length - 1
|
|
|
|
+ : walkingRes.length) +
|
|
|
|
+ ' 队列总帧数:' +
|
|
|
|
+ seqs.length,
|
|
);
|
|
);
|
|
const stop = performance.now();
|
|
const stop = performance.now();
|
|
const inMillSeconds = stop - start;
|
|
const inMillSeconds = stop - start;
|
|
@@ -572,7 +574,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const joystickRes = await this.moveService.seqExeJoystick(request);
|
|
const joystickRes = await this.moveService.seqExeJoystick(request);
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'joystick-breakPointId:' +
|
|
'joystick-breakPointId:' +
|
|
- this.moveService.users[this.user_id].breakPointId,
|
|
|
|
|
|
+ this.moveService.users[this.user_id].breakPointId,
|
|
);
|
|
);
|
|
// 有数据 [0]是rotate数据,[1-infinity]是walking数据
|
|
// 有数据 [0]是rotate数据,[1-infinity]是walking数据
|
|
this.logger.log('joystickRes-1', joystickRes);
|
|
this.logger.log('joystickRes-1', joystickRes);
|
|
@@ -588,11 +590,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
// ),
|
|
// ),
|
|
console.log(
|
|
console.log(
|
|
'handlejoysticktesttest:' +
|
|
'handlejoysticktesttest:' +
|
|
- joystickRes.mediaSrc +
|
|
|
|
- ',相机坐标:' +
|
|
|
|
- JSON.stringify(
|
|
|
|
- joystickRes.newUserStates[0].playerState.player.position,
|
|
|
|
- ),
|
|
|
|
|
|
+ joystickRes.mediaSrc +
|
|
|
|
+ ',相机坐标:' +
|
|
|
|
+ JSON.stringify(
|
|
|
|
+ joystickRes.newUserStates[0].playerState.player.position,
|
|
|
|
+ ),
|
|
);
|
|
);
|
|
if (joystickRes.mediaSrc) {
|
|
if (joystickRes.mediaSrc) {
|
|
this.holdSteam();
|
|
this.holdSteam();
|
|
@@ -615,16 +617,21 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
DIR: setDIR,
|
|
DIR: setDIR,
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ if (this.isJoystickHasStream) {
|
|
|
|
+ await this.sleep(10);
|
|
|
|
+ }
|
|
|
|
+
|
|
const hasPush = await this.streamService.pushFrameToSteam(streamData);
|
|
const hasPush = await this.streamService.pushFrameToSteam(streamData);
|
|
if (hasPush.done) {
|
|
if (hasPush.done) {
|
|
|
|
+ this.isJoystickHasStream = true;
|
|
console.log('joystick-hasPush', hasPush);
|
|
console.log('joystick-hasPush', hasPush);
|
|
this.moveService.sendingFrameForJoystick = false;
|
|
this.moveService.sendingFrameForJoystick = false;
|
|
const data = joystickRes as StreamReplyType;
|
|
const data = joystickRes as StreamReplyType;
|
|
- console.log('handlejoystick-moveOver:'+data.moveOver)
|
|
|
|
|
|
+ console.log('handlejoystick-moveOver:' + data.moveOver);
|
|
if (data?.moveOver && data.moveOver) {
|
|
if (data?.moveOver && data.moveOver) {
|
|
// moveOver
|
|
// moveOver
|
|
console.log('回传updateUser', data);
|
|
console.log('回传updateUser', data);
|
|
- const userId = this.user_id;
|
|
|
|
|
|
+ // const userId = this.user_id;
|
|
// 回传点暂时有问题,待修复
|
|
// 回传点暂时有问题,待修复
|
|
//const breakPointId = data.endBreakPointId || data.breakPointId;
|
|
//const breakPointId = data.endBreakPointId || data.breakPointId;
|
|
//const lastReply = JSON.stringify(joystickRes);
|
|
//const lastReply = JSON.stringify(joystickRes);
|
|
@@ -639,6 +646,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
this.onJoysticking.next(false);
|
|
this.onJoysticking.next(false);
|
|
this.resumeStream();
|
|
this.resumeStream();
|
|
this.joystickFrameCnt = -1;
|
|
this.joystickFrameCnt = -1;
|
|
|
|
+ this.isJoystickHasStream = false;
|
|
}, 200);
|
|
}, 200);
|
|
} else {
|
|
} else {
|
|
console.error(
|
|
console.error(
|
|
@@ -708,6 +716,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
this.logger.error('joystick', error.message);
|
|
this.logger.error('joystick', error.message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 主要处理moving的序列动作
|
|
* 主要处理moving的序列动作
|
|
* @param seqs StreamReplyType[]
|
|
* @param seqs StreamReplyType[]
|
|
@@ -781,14 +792,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
};
|
|
};
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'[media-move]: ' +
|
|
'[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,
|
|
// stream.metaData,
|
|
);
|
|
);
|
|
this.logger.log(
|
|
this.logger.log(
|
|
@@ -984,8 +995,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
const IDRflag = this._rotateCurrentFame % 5 === 0 ? 1 : 3;
|
|
const IDRflag = this._rotateCurrentFame % 5 === 0 ? 1 : 3;
|
|
this.logger.log(
|
|
this.logger.log(
|
|
- `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${
|
|
|
|
- this._rotateCurrentFame
|
|
|
|
|
|
+ `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${this._rotateCurrentFame
|
|
} IDRflag:${IDRflag}`,
|
|
} IDRflag:${IDRflag}`,
|
|
);
|
|
);
|
|
stream.DIR = this.rotateFirstIDR ? 1 : IDRflag;
|
|
stream.DIR = this.rotateFirstIDR ? 1 : IDRflag;
|
|
@@ -996,12 +1006,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'[media-rotate]: ' +
|
|
'[media-rotate]: ' +
|
|
- ', frame: ' +
|
|
|
|
- stream.frame +
|
|
|
|
- ', rotateframeCnt: ' +
|
|
|
|
- this.rotateframeCnt +
|
|
|
|
- ', clipPath: ' +
|
|
|
|
- stream.clipPath,
|
|
|
|
|
|
+ ', frame: ' +
|
|
|
|
+ stream.frame +
|
|
|
|
+ ', rotateframeCnt: ' +
|
|
|
|
+ this.rotateframeCnt +
|
|
|
|
+ ', clipPath: ' +
|
|
|
|
+ stream.clipPath,
|
|
// stream.metaData,
|
|
// stream.metaData,
|
|
);
|
|
);
|
|
// this.logger.log(
|
|
// this.logger.log(
|
|
@@ -1063,12 +1073,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
this.logger.log('frame', frame);
|
|
this.logger.log('frame', frame);
|
|
console.log(
|
|
console.log(
|
|
'mock' +
|
|
'mock' +
|
|
- ' maxMessageSize: ' +
|
|
|
|
- this.channel.maxMessageSize() +
|
|
|
|
- ' bytesReceived: ' +
|
|
|
|
- this.peer.bytesReceived() +
|
|
|
|
- ' bytesSent: ' +
|
|
|
|
- this.peer.bytesSent(),
|
|
|
|
|
|
+ ' maxMessageSize: ' +
|
|
|
|
+ this.channel.maxMessageSize() +
|
|
|
|
+ ' bytesReceived: ' +
|
|
|
|
+ this.peer.bytesReceived() +
|
|
|
|
+ ' bytesSent: ' +
|
|
|
|
+ this.peer.bytesSent(),
|
|
);
|
|
);
|
|
if (frame === 1) {
|
|
if (frame === 1) {
|
|
redisData = await this.rotateService.echo(this.user_id, true);
|
|
redisData = await this.rotateService.echo(this.user_id, true);
|
|
@@ -1083,7 +1093,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
delete redisData.mediaSrc;
|
|
delete redisData.mediaSrc;
|
|
this.logger.log(
|
|
this.logger.log(
|
|
`user:${this.user_id}:first render stream` +
|
|
`user:${this.user_id}:first render stream` +
|
|
- JSON.stringify({ path: clipPath, meta: redisData }),
|
|
|
|
|
|
+ JSON.stringify({ path: clipPath, meta: redisData }),
|
|
);
|
|
);
|
|
const status = await this.pushFirstRender(
|
|
const status = await this.pushFirstRender(
|
|
clipPath,
|
|
clipPath,
|
|
@@ -1111,15 +1121,15 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
console.log(
|
|
console.log(
|
|
'空白流条件-->:' +
|
|
'空白流条件-->:' +
|
|
- isOk +
|
|
|
|
- ' onMoving: ' +
|
|
|
|
- this.onMoving.value +
|
|
|
|
- ' onRotating: ' +
|
|
|
|
- this.onRotating.value +
|
|
|
|
- ' onJoysticking: ' +
|
|
|
|
- this.onJoysticking.value +
|
|
|
|
- ' firstRender: ' +
|
|
|
|
- this.firstRender,
|
|
|
|
|
|
+ isOk +
|
|
|
|
+ ' onMoving: ' +
|
|
|
|
+ this.onMoving.value +
|
|
|
|
+ ' onRotating: ' +
|
|
|
|
+ this.onRotating.value +
|
|
|
|
+ ' onJoysticking: ' +
|
|
|
|
+ this.onJoysticking.value +
|
|
|
|
+ ' firstRender: ' +
|
|
|
|
+ this.firstRender,
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|