|
@@ -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;
|
|
@@ -74,6 +74,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
private firstRender = false;
|
|
|
private latestBreakPointId: number;
|
|
|
private isHoldingStream = false;
|
|
|
+ private lastMovingPointArray: MovingLastUpdateType[] = [];
|
|
|
|
|
|
public lastMoveStreamFrame = new BehaviorSubject<StreamFrameType>({
|
|
|
frame: -1,
|
|
@@ -261,7 +262,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
);
|
|
|
const trace_id = metaData.traceIds[0];
|
|
|
const userId = newUserStates.userId;
|
|
|
- const breakPointId = metaData.breakPointId;
|
|
|
+ const breakPointId = metaData.endBreakPointId;
|
|
|
const cameraAngle = newUserStates.playerState.camera.angle;
|
|
|
const playerAngle = newUserStates.playerState.player.angle;
|
|
|
console.log('stop-data', trace_id, userId, cameraAngle, cameraAngle);
|
|
@@ -335,6 +336,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.clickQueueSub = this.clickQueue.subscribe(async (request) => {
|
|
|
const user = this.moveService.users[this.user_id];
|
|
|
console.log('进入1 - searchRoad');
|
|
|
+ console.log('path-start' + user.breakPointId);
|
|
|
const path = await this.getRouterService.searchRoad(
|
|
|
user.appId,
|
|
|
user.breakPointId,
|
|
@@ -376,6 +378,13 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
walkingRes[i].length - 1,
|
|
|
);
|
|
|
item.DIR = dir ? 1 : 3;
|
|
|
+ //将每段最后一个推入lastMovingPointArray
|
|
|
+ if (index === walkingRes[i].length - 1) {
|
|
|
+ this.lastMovingPointArray.push({
|
|
|
+ mediaSrc: item.mediaSrc,
|
|
|
+ metaData: item,
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
);
|
|
|
}
|
|
@@ -519,7 +528,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.moveframeCnt = this.frameCnt.value;
|
|
|
}
|
|
|
this.moveframeCnt += 1;
|
|
|
- this.latestBreakPointId = metaData.breakPointId;
|
|
|
+ this.latestBreakPointId = metaData.endBreakPointId;
|
|
|
|
|
|
const streamData: StreamFrameType = {
|
|
|
frame: this.moveframeCnt,
|
|
@@ -534,28 +543,53 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
stream.clipPath,
|
|
|
stream.mType,
|
|
|
stream.DIR,
|
|
|
- stream.metaData,
|
|
|
+ // stream.metaData,
|
|
|
);
|
|
|
|
|
|
+
|
|
|
this.lastMoveStreamFrame.next(streamData);
|
|
|
const res = await this.streamService.pushFrameToSteam(streamData);
|
|
|
+
|
|
|
+ const isLastFrameIndex = this.lastMovingPointArray.findIndex(
|
|
|
+ (item) => item.mediaSrc === metaData.mediaSrc,
|
|
|
+ );
|
|
|
+ // console.log('path-update-index', isLastFrameIndex);
|
|
|
+ //每一段的最后一帧
|
|
|
+ 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);
|
|
|
+ this.lastMovingPointArray.splice(isLastFrameIndex, 1);
|
|
|
+ }
|
|
|
+
|
|
|
if (res.done) {
|
|
|
clearTimeout(this._moveTimeout);
|
|
|
this._moveTimeout = setTimeout(() => {
|
|
|
console.log('move 交权给空流,当前pts', res.frame);
|
|
|
//TODO 每个结束点 updateUser metaData
|
|
|
- const lastFrame = this.lastMoveStreamFrame.getValue();
|
|
|
- const lastFrameMeta = JSON.parse(lastFrame.metaData);
|
|
|
-
|
|
|
- const userId = this.user_id;
|
|
|
- const breakPointId = lastFrameMeta.breakPointId;
|
|
|
- const lastReply = lastFrameMeta;
|
|
|
- this.moveService.updateUser(userId, breakPointId, lastReply);
|
|
|
+ // const lastFrame = this.lastMoveStreamFrame.getValue();
|
|
|
+ // const lastFrameMeta: StreamReplyType = JSON.parse(
|
|
|
+ // lastFrame.metaData,
|
|
|
+ // );
|
|
|
+
|
|
|
+ // const userId = this.user_id;
|
|
|
+ // const breakPointId = lastFrameMeta.endBreakPointId;
|
|
|
+ // const lastReply = lastFrameMeta;
|
|
|
+ // console.log('path-update', breakPointId);
|
|
|
+ // this.moveService.updateUser(userId, breakPointId, lastReply);
|
|
|
this.frameCnt.next(res.frame);
|
|
|
this.resumeStream();
|
|
|
this.rotateframeCnt = -1;
|
|
|
this.onMoving.next(false);
|
|
|
this.cleanMoveSteam();
|
|
|
+ this.lastMovingPointArray = [];
|
|
|
console.log('move end');
|
|
|
}, 300);
|
|
|
}
|
|
@@ -713,7 +747,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,
|
|
@@ -781,7 +815,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
stream.frame,
|
|
|
this.rotateframeCnt,
|
|
|
stream.clipPath,
|
|
|
- stream.metaData,
|
|
|
+ // stream.metaData,
|
|
|
);
|
|
|
// this.logger.log(
|
|
|
// `roQueueSubscription:frame:${this.rotateframeCnt} ` +
|