|
@@ -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;
|
|
@@ -230,6 +230,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
init(request: InitRequest) {
|
|
init(request: InitRequest) {
|
|
try {
|
|
try {
|
|
this.rotateService.init(request.app_id, request.user_id);
|
|
this.rotateService.init(request.app_id, request.user_id);
|
|
|
|
+ this.cacheService.getClient();
|
|
// 加载
|
|
// 加载
|
|
// let path: string;
|
|
// let path: string;
|
|
// if (process.env.NODE_ENV === 'development') {
|
|
// if (process.env.NODE_ENV === 'development') {
|
|
@@ -250,9 +251,6 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
// this.moveService.loadJSON(path);
|
|
// this.moveService.loadJSON(path);
|
|
// this.getRouterService.loadJSON(path);
|
|
// this.getRouterService.loadJSON(path);
|
|
- this.startSteaming.next(true);
|
|
|
|
- this.startStream();
|
|
|
|
- this.handleStream();
|
|
|
|
|
|
|
|
// this.moveService.init(request.app_id, request.user_id);
|
|
// this.moveService.init(request.app_id, request.user_id);
|
|
|
|
|
|
@@ -313,21 +311,28 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
if (metaData.traceIds.indexOf(request.trace_id) > -1) {
|
|
if (metaData.traceIds.indexOf(request.trace_id) > -1) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ console.log('currentUser-user_id', this.user_id);
|
|
const newUserStates: NewUserStatesType = metaData.newUserStates.find(
|
|
const newUserStates: NewUserStatesType = metaData.newUserStates.find(
|
|
(item) => item.userId === this.user_id,
|
|
(item) => item.userId === this.user_id,
|
|
);
|
|
);
|
|
|
|
+
|
|
const trace_id = metaData.traceIds[0];
|
|
const trace_id = metaData.traceIds[0];
|
|
const userId = newUserStates.userId;
|
|
const userId = newUserStates.userId;
|
|
const breakPointId = metaData.endBreakPointId;
|
|
const breakPointId = metaData.endBreakPointId;
|
|
const cameraAngle = newUserStates.playerState.camera.angle;
|
|
const cameraAngle = newUserStates.playerState.camera.angle;
|
|
const playerAngle = newUserStates.playerState.player.angle;
|
|
const playerAngle = newUserStates.playerState.player.angle;
|
|
this.logger.log(
|
|
this.logger.log(
|
|
- 'stop-data-0',
|
|
|
|
- trace_id,
|
|
|
|
- userId,
|
|
|
|
- cameraAngle,
|
|
|
|
- cameraAngle,
|
|
|
|
|
|
+ 'stop-data-0' +
|
|
|
|
+ 'trace_id: ' +
|
|
|
|
+ trace_id +
|
|
|
|
+ 'userId:' +
|
|
|
|
+ userId +
|
|
|
|
+ 'breakPointId :' +
|
|
|
|
+ breakPointId +
|
|
|
|
+ 'cameraAngle :' +
|
|
|
|
+ JSON.stringify(cameraAngle) +
|
|
|
|
+ 'playerAngle: ' +
|
|
|
|
+ JSON.stringify(playerAngle),
|
|
);
|
|
);
|
|
//debugger;
|
|
//debugger;
|
|
redisMeta = await this.moveService.stop(
|
|
redisMeta = await this.moveService.stop(
|
|
@@ -582,7 +587,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);
|
|
@@ -748,14 +753,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(
|
|
@@ -811,6 +816,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
handleDataChanelOpen(channel: DataChannel): void {
|
|
handleDataChanelOpen(channel: DataChannel): void {
|
|
this.channel = channel;
|
|
this.channel = channel;
|
|
this.streamService.setChannel(channel);
|
|
this.streamService.setChannel(channel);
|
|
|
|
+ this.startSteaming.next(true);
|
|
|
|
+ this.startStream();
|
|
|
|
+ this.handleStream();
|
|
}
|
|
}
|
|
|
|
|
|
handleDataChanelClose(): void {
|
|
handleDataChanelClose(): void {
|
|
@@ -941,7 +949,8 @@ 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;
|
|
@@ -952,12 +961,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(
|
|
@@ -1021,14 +1030,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const mediaSrc: string = redisData.mediaSrc || '';
|
|
const mediaSrc: string = redisData.mediaSrc || '';
|
|
if (mediaSrc.length > 0) {
|
|
if (mediaSrc.length > 0) {
|
|
const src = mediaSrc.split('?')[0];
|
|
const src = mediaSrc.split('?')[0];
|
|
- // 临时本地替换路经
|
|
|
|
- // src = src.replace('/10086/', '');
|
|
|
|
- // const clipPath = join(__dirname, `../ws/${src}`);
|
|
|
|
const clipPath = this.configService.get('app.prefix') + src;
|
|
const clipPath = this.configService.get('app.prefix') + src;
|
|
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,
|
|
@@ -1043,7 +1049,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- this.logger.error(`首屏::无数据:${frame}`);
|
|
|
|
|
|
+ this.logger.error(`first render problem:${frame}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (
|
|
if (
|