|
@@ -58,13 +58,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
private streamServiceSub: any;
|
|
|
private roQueue: RxQueue = new DelayQueue(10);
|
|
|
private clickQueue: RxQueue = new DebounceQueue(500);
|
|
|
- private moveQueue: RxQueue = new DelayQueue(100);
|
|
|
+ private moveQueue: RxQueue = new DelayQueue(10);
|
|
|
private joystickQueue: RxQueue = new DebounceQueue(500);
|
|
|
private rotateTimeStamp: number;
|
|
|
private lastMoveCnt = -1;
|
|
|
|
|
|
private firstRender = false;
|
|
|
private latestBreakPointId: number;
|
|
|
+ private isHoldingStream = false;
|
|
|
|
|
|
public lastMoveStreamFrame = new BehaviorSubject<StreamFrameType>({
|
|
|
frame: -1,
|
|
@@ -142,10 +143,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
public holdSteam(): void {
|
|
|
clearInterval(this._frameInteval);
|
|
|
+ this.isHoldingStream = true;
|
|
|
}
|
|
|
|
|
|
public resumeStream(): void {
|
|
|
this.onMoving.next(false);
|
|
|
+ this.isHoldingStream = false;
|
|
|
this.moveframeCnt = -1;
|
|
|
this.rotateframeCnt = -1;
|
|
|
clearInterval(this._frameInteval);
|
|
@@ -228,7 +231,6 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
const trace_id = metaData.traceIds[0];
|
|
|
const userId = newUserStates.userId;
|
|
|
const breakPointId = metaData.breakPointId;
|
|
|
-
|
|
|
const cameraAngle = newUserStates.playerState.camera.angle;
|
|
|
const playerAngle = newUserStates.playerState.player.angle;
|
|
|
console.log('stop-data', trace_id, userId, cameraAngle, cameraAngle);
|
|
@@ -304,23 +306,31 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
req.clicking_action.clicking_point,
|
|
|
);
|
|
|
const walkingRes = await this.moveService.move(path, request);
|
|
|
- // this.moveService.rotateForAngle();
|
|
|
- console.log('walkingRes', walkingRes);
|
|
|
|
|
|
+ // console.log('walkingRes-front', walkingRes);
|
|
|
if (walkingRes && !this.onMoving.value) {
|
|
|
- console.log('walkingRes-front', walkingRes);
|
|
|
+ // console.log('walkingRes-front', walkingRes);
|
|
|
// shift出前第一个镜头数据
|
|
|
const rotateCamData = walkingRes.shift();
|
|
|
-
|
|
|
+ if (rotateCamData?.length) {
|
|
|
+ rotateCamData.forEach((item: StreamReplyType) => {
|
|
|
+ item.type = 'rotate';
|
|
|
+ });
|
|
|
+ }
|
|
|
// walkingRes marker to everybody
|
|
|
const seqs = Array.from(
|
|
|
walkingRes,
|
|
|
).flat() as any as StreamReplyType[];
|
|
|
|
|
|
if (seqs?.length) {
|
|
|
- this.handleSeqMoving(seqs);
|
|
|
+ const lastSeq = rotateCamData?.length
|
|
|
+ ? (Array.from(rotateCamData).concat(
|
|
|
+ seqs,
|
|
|
+ ) as any as StreamReplyType[])
|
|
|
+ : seqs;
|
|
|
+ this.handleSeqMoving(lastSeq);
|
|
|
} else {
|
|
|
- console.log('walking无数据');
|
|
|
+ console.error('walking-move无数据');
|
|
|
}
|
|
|
// this.lastMoveCnt = this.frameCnt.value + seqs.length;
|
|
|
}
|
|
@@ -345,17 +355,23 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
// shift出前第一个镜头数据
|
|
|
const rotateCamData = joystickRes.shift();
|
|
|
console.log('rotateCamData', rotateCamData);
|
|
|
- console.log('joystickRes-end', joystickRes);
|
|
|
-
|
|
|
if (rotateCamData?.length) {
|
|
|
+ rotateCamData.forEach((item: StreamReplyType) => {
|
|
|
+ item.type = 'rotate';
|
|
|
+ });
|
|
|
}
|
|
|
const seqs = Array.from(
|
|
|
joystickRes,
|
|
|
).flat() as any as StreamReplyType[];
|
|
|
- if (seqs?.length) {
|
|
|
- this.handleSeqMoving(seqs);
|
|
|
+ if (seqs?.length || rotateCamData?.length) {
|
|
|
+ const lastSeq = rotateCamData?.length
|
|
|
+ ? (Array.from(rotateCamData).concat(
|
|
|
+ seqs,
|
|
|
+ ) as any as StreamReplyType[])
|
|
|
+ : seqs;
|
|
|
+ this.handleSeqMoving(lastSeq);
|
|
|
} else {
|
|
|
- console.log('walking无数据');
|
|
|
+ console.warn('joystick-move无数据');
|
|
|
}
|
|
|
} else {
|
|
|
console.log('转交数据');
|
|
@@ -376,24 +392,29 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
if (!this.moveQueueSubscription) {
|
|
|
this.handleMoveSteam();
|
|
|
}
|
|
|
- console.log('walking-seqs', seqs);
|
|
|
+ console.log('moving-seqs', seqs.length);
|
|
|
this.onMoving.next(true);
|
|
|
this.holdSteam();
|
|
|
- this.moveframeCnt = this.frameCnt.value;
|
|
|
+
|
|
|
seqs.forEach((frame: StreamReplyType) => {
|
|
|
const mediaSrc = frame.mediaSrc;
|
|
|
let src = mediaSrc.split('?')[0];
|
|
|
// 临时本地替换路经
|
|
|
src = src.replace('/0000000001/', '');
|
|
|
const clipPath = join(__dirname, `../ws/video/${src}`);
|
|
|
- this.moveframeCnt += 1;
|
|
|
+ const type = frame.type?.length ? frame.type.slice() : 'move';
|
|
|
+
|
|
|
+ console.log('type', frame.type);
|
|
|
delete frame.mediaSrc;
|
|
|
+ delete frame.type;
|
|
|
+
|
|
|
const stream: StreamFrameType = {
|
|
|
- frame: this.moveframeCnt,
|
|
|
+ frame: -1,
|
|
|
clipPath: clipPath,
|
|
|
metaData: JSON.stringify(frame),
|
|
|
serverTime: this.mockserverTime,
|
|
|
DIR: 1,
|
|
|
+ type: type,
|
|
|
};
|
|
|
this.moveQueue.next(stream);
|
|
|
});
|
|
@@ -439,13 +460,19 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
serverTime: this.mockserverTime,
|
|
|
DIR: 3,
|
|
|
};
|
|
|
+ console.log(
|
|
|
+ '[media-move]',
|
|
|
+ this.moveframeCnt,
|
|
|
+ stream.clipPath,
|
|
|
+ stream.type,
|
|
|
+ );
|
|
|
+
|
|
|
this.lastMoveStreamFrame.next(streamData);
|
|
|
const res = await this.streamService.pushFrameToSteam(streamData);
|
|
|
if (res.done) {
|
|
|
clearTimeout(this._moveTimeout);
|
|
|
this._moveTimeout = setTimeout(() => {
|
|
|
- console.log('move 交权给空流', Date.now());
|
|
|
- console.log('move end');
|
|
|
+ console.log('move 交权给空流,当前pts', res.frame);
|
|
|
//TODO 每个结束点 updateUser metaData
|
|
|
const lastFrame = this.lastMoveStreamFrame.getValue();
|
|
|
const lastFrameMeta = JSON.parse(lastFrame.metaData);
|
|
@@ -458,6 +485,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.resumeStream();
|
|
|
this.rotateframeCnt = -1;
|
|
|
this.onMoving.next(false);
|
|
|
+ console.log('move end');
|
|
|
}, 300);
|
|
|
}
|
|
|
},
|
|
@@ -531,14 +559,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
}
|
|
|
|
|
|
async handleIframeRequest() {
|
|
|
- const lastStreamFrame = this.streamService.lastStreamFrame.getValue();
|
|
|
- lastStreamFrame.DIR = 1;
|
|
|
- console.log('lastStreamFrame', lastStreamFrame);
|
|
|
- const nextFrame = this.frameCnt.getValue() + 1;
|
|
|
- lastStreamFrame.frame = nextFrame;
|
|
|
- this.frameCnt.next(nextFrame);
|
|
|
- this.streamService.pushFrameToSteam(lastStreamFrame);
|
|
|
-
|
|
|
+ //TODO Iframe 最终传什么?
|
|
|
+ // const lastStreamFrame = this.streamService.lastStreamFrame.getValue();
|
|
|
+ // lastStreamFrame.DIR = 1;
|
|
|
+ // console.log('lastStreamFrame', lastStreamFrame);
|
|
|
+ // const nextFrame = this.frameCnt.getValue() + 1;
|
|
|
+ // lastStreamFrame.frame = nextFrame;
|
|
|
+ // this.frameCnt.next(nextFrame);
|
|
|
+ // this.streamService.pushFrameToSteam(lastStreamFrame);
|
|
|
// const redisDataAuto = await this.rotateService.echo(this.user_id);
|
|
|
// if (redisDataAuto) {
|
|
|
// 'mediaSrc' in redisDataAuto && delete redisDataAuto.mediaSrc;
|
|
@@ -647,6 +675,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.streamService.pushMetaDataToSteam(streamMeta);
|
|
|
} else {
|
|
|
this.stopStream();
|
|
|
+ console.log('空流无Redis数据');
|
|
|
throw new Error('空流无Redis数据');
|
|
|
}
|
|
|
}
|
|
@@ -666,7 +695,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.rotateframeCnt += 1;
|
|
|
|
|
|
stream.frame = this.rotateframeCnt;
|
|
|
- console.log('[media-rotate]', stream.frame, stream.clipPath);
|
|
|
+ console.log(
|
|
|
+ '[media-rotate]',
|
|
|
+ stream.frame,
|
|
|
+ this.rotateframeCnt,
|
|
|
+ stream.clipPath,
|
|
|
+ );
|
|
|
// this.logger.log(
|
|
|
// `roQueueSubscription:frame:${this.rotateframeCnt} ` +
|
|
|
// JSON.stringify(stream.metaData),
|