|
@@ -25,7 +25,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
private rotateService: RotateService,
|
|
|
private moveService: MoveService,
|
|
|
private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
|
|
|
- ) { }
|
|
|
+ ) {}
|
|
|
@Client(grpcClientOptions) private readonly client: ClientGrpc;
|
|
|
|
|
|
public _frameInteval: NodeJS.Timeout;
|
|
@@ -36,11 +36,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
public startSteaming = new BehaviorSubject<boolean>(false);
|
|
|
public onRotating = new BehaviorSubject<boolean>(false);
|
|
|
public onMoving = new BehaviorSubject<boolean>(false);
|
|
|
+ public onJoysticking = new BehaviorSubject<boolean>(false);
|
|
|
public frameCnt = new BehaviorSubject<number>(-1);
|
|
|
private rotateframeCnt = -1;
|
|
|
private moveframeCnt = -1;
|
|
|
private joystickFrameCnt = -1;
|
|
|
- private moveKeyFrame = -1;
|
|
|
+ private rotateFirstIDR = true;
|
|
|
|
|
|
private sceneGrpcService: SceneGrpcService;
|
|
|
private channel: DataChannel;
|
|
@@ -518,6 +519,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
const joystickRes = await this.moveService.seqExeJoystick(request);
|
|
|
// 有数据 [0]是rotate数据,[1-infinity]是walking数据
|
|
|
console.log('joystickRes-1', joystickRes);
|
|
|
+ this.onJoysticking.next(true);
|
|
|
if (Array.isArray(joystickRes)) {
|
|
|
// 处理第一个镜头数据
|
|
|
const rotateCamData = joystickRes[0];
|
|
@@ -571,8 +573,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
console.warn('joystick-move无数据');
|
|
|
}
|
|
|
} else {
|
|
|
- console.warn('joystick-接收人物数据', this.onMoving);
|
|
|
- if (!this.onMoving.value) {
|
|
|
+ console.warn('joystick-接收人物数据', this.onMoving.getValue());
|
|
|
+ if (!this.onMoving.getValue()) {
|
|
|
+ // 在非行走时接受
|
|
|
this.holdSteam();
|
|
|
if (this.joystickFrameCnt === -1) {
|
|
|
this.joystickFrameCnt = this.frameCnt.getValue();
|
|
@@ -583,19 +586,19 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
metaData: JSON.stringify(joystickRes),
|
|
|
};
|
|
|
// console.log('rotate', stream, Date.now());
|
|
|
- clearTimeout(this._JoyStickingTimeout);
|
|
|
const res = await this.streamService.pushMetaDataToSteam(stream);
|
|
|
if (res.done) {
|
|
|
console.log('joystick-frame', res.frame);
|
|
|
this.frameCnt.next(res.frame);
|
|
|
+ clearTimeout(this._JoyStickingTimeout);
|
|
|
this._JoyStickingTimeout = setTimeout(() => {
|
|
|
console.log('joystick opt done');
|
|
|
console.log('joystick 交权给空流,当前pts', res.frame);
|
|
|
- const next = res.frame + 1;
|
|
|
- this.frameCnt.next(next);
|
|
|
+ // this.frameCnt.next(res.frame);
|
|
|
+ this.onJoysticking.next(false);
|
|
|
this.resumeStream();
|
|
|
this.joystickFrameCnt = -1;
|
|
|
- }, 300);
|
|
|
+ }, 100);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -616,7 +619,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.onMoving.next(true);
|
|
|
this.holdSteam();
|
|
|
//TODO Remove
|
|
|
- clearTimeout(this._JoyStickingTimeout);
|
|
|
+ // clearTimeout(this._JoyStickingTimeout);
|
|
|
|
|
|
seqs.forEach((frame: StreamReplyType) => {
|
|
|
const mediaSrc = frame.mediaSrc;
|
|
@@ -671,14 +674,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
};
|
|
|
console.log(
|
|
|
'[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,
|
|
|
);
|
|
|
console.log(
|
|
@@ -696,13 +699,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
if (isLastFrameIndex > -1) {
|
|
|
// console.log('path-update-array', this.lastMovingPointArray);
|
|
|
const currentMeta = this.lastMovingPointArray[isLastFrameIndex];
|
|
|
- // console.log('currentMeta', currentMeta);
|
|
|
- // const lastFrame = this.lastMoveStreamFrame.getValue();
|
|
|
- // const lastFrameMeta: StreamReplyType = JSON.parse(lastFrame.metaData);
|
|
|
const userId = this.user_id;
|
|
|
const breakPointId = currentMeta.metaData.endBreakPointId;
|
|
|
const lastReply = currentMeta.metaData;
|
|
|
- // console.log('path-update', breakPointId);
|
|
|
this.moveService.updateUser(userId, breakPointId, lastReply);
|
|
|
//debugger
|
|
|
this.lastMovingPointArray.splice(isLastFrameIndex, 1);
|
|
@@ -718,6 +717,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.resumeStream();
|
|
|
this.rotateframeCnt = -1;
|
|
|
this.onMoving.next(false);
|
|
|
+ this.onJoysticking.next(false);
|
|
|
this.cleanMoveSteam();
|
|
|
this.lastMovingPointArray = [];
|
|
|
this.hasJoystickMoveRequest = false;
|
|
@@ -858,14 +858,19 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.rotateframeCnt += 1;
|
|
|
|
|
|
stream.frame = this.rotateframeCnt;
|
|
|
+ stream.DIR = this.rotateFirstIDR ? 1 : 3;
|
|
|
+ if (this.rotateFirstIDR) {
|
|
|
+ this.rotateFirstIDR = false;
|
|
|
+ }
|
|
|
+
|
|
|
this.logger.log(
|
|
|
'[media-rotate]: ' +
|
|
|
- ', frame: ' +
|
|
|
- stream.frame +
|
|
|
- ', rotateframeCnt: ' +
|
|
|
- this.rotateframeCnt +
|
|
|
- ', clipPath: ' +
|
|
|
- stream.clipPath,
|
|
|
+ ', frame: ' +
|
|
|
+ stream.frame +
|
|
|
+ ', rotateframeCnt: ' +
|
|
|
+ this.rotateframeCnt +
|
|
|
+ ', clipPath: ' +
|
|
|
+ stream.clipPath,
|
|
|
// stream.metaData,
|
|
|
);
|
|
|
// this.logger.log(
|
|
@@ -883,6 +888,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.rotateframeCnt = -1;
|
|
|
this.onMoving.next(false);
|
|
|
this.onRotating.next(false);
|
|
|
+ this.rotateFirstIDR = true;
|
|
|
//TODO rotate完后清除request队列
|
|
|
if (this.roRequestQueueSub) {
|
|
|
this.roRequestQueueSub.unsubscribe();
|
|
@@ -934,7 +940,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
delete redisData.mediaSrc;
|
|
|
this.logger.log(
|
|
|
`user:${this.user_id}:first render stream` +
|
|
|
- JSON.stringify({ path: clipPath, meta: redisData }),
|
|
|
+ JSON.stringify({ path: clipPath, meta: redisData }),
|
|
|
);
|
|
|
const status = await this.pushFirstRender(
|
|
|
clipPath,
|
|
@@ -956,6 +962,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
frame > 1 &&
|
|
|
!this.onMoving.value &&
|
|
|
!this.onRotating.value &&
|
|
|
+ !this.onJoysticking.value &&
|
|
|
this.firstRender
|
|
|
) {
|
|
|
const redisDataAuto = await this.rotateService.echo(
|