|
@@ -83,6 +83,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
private latestBreakPointId: number;
|
|
private latestBreakPointId: number;
|
|
private isHoldingStream = false;
|
|
private isHoldingStream = false;
|
|
private lastMovingPointArray: MovingLastUpdateType[] = [];
|
|
private lastMovingPointArray: MovingLastUpdateType[] = [];
|
|
|
|
+ private latestRotateRequest: any; // 最新Rotate的接收值
|
|
private latestWalkingRequest: any; // 最新waking的接收值
|
|
private latestWalkingRequest: any; // 最新waking的接收值
|
|
private hasJoystickMoveRequest = false; // 最新joystick的接收值
|
|
private hasJoystickMoveRequest = false; // 最新joystick的接收值
|
|
|
|
|
|
@@ -208,24 +209,21 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
async rotate(request: RotateRequest) {
|
|
async rotate(request: RotateRequest) {
|
|
if (this.isHasWalkingJoints()) {
|
|
if (this.isHasWalkingJoints()) {
|
|
this.globalOptLock = true;
|
|
this.globalOptLock = true;
|
|
|
|
+ } else {
|
|
|
|
+ console.log('开锁rotate或正常rotate');
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (
|
|
|
|
- this.onMoving.getValue() &&
|
|
|
|
- this.globalOptLock &&
|
|
|
|
- // this._rotateCount > 5 &&
|
|
|
|
- !this.rotateStopThrottle
|
|
|
|
- ) {
|
|
|
|
- this.handleRotateStop(request);
|
|
|
|
- debugger;
|
|
|
|
- }
|
|
|
|
|
|
+ this.latestRotateRequest = request;
|
|
|
|
+ // if (
|
|
|
|
+ // this.onMoving.getValue() &&
|
|
|
|
+ // this.globalOptLock &&
|
|
|
|
+ // // this._rotateCount > 5 &&
|
|
|
|
+ // !this.rotateStopThrottle
|
|
|
|
+ // ) {
|
|
|
|
+ // this.handleRotateStop(request);
|
|
|
|
+ // // debugger;
|
|
|
|
+ // }
|
|
this.handleRotate(request);
|
|
this.handleRotate(request);
|
|
this._rotateCount += 1;
|
|
this._rotateCount += 1;
|
|
- //this.logger.log('request', request)
|
|
|
|
- // this.roRequestQueue.next(request);
|
|
|
|
- // if (!this.roRequestQueueSub) {
|
|
|
|
- // this.handleRotate();
|
|
|
|
- // }
|
|
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* rotate请求队列
|
|
* rotate请求队列
|
|
@@ -234,7 +232,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
async handleRotate(request) {
|
|
async handleRotate(request) {
|
|
// try {
|
|
// try {
|
|
const rotateKey = this.firstRender && !this.globalOptLock;
|
|
const rotateKey = this.firstRender && !this.globalOptLock;
|
|
- console.log('handleRotate条件--->' + rotateKey);
|
|
|
|
|
|
+ console.log('handleRotate条件--->' + rotateKey, this.globalOptLock);
|
|
|
|
|
|
if (rotateKey) {
|
|
if (rotateKey) {
|
|
if (!this.roQueueSubscription) {
|
|
if (!this.roQueueSubscription) {
|
|
@@ -295,16 +293,90 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * rotate 推送队列
|
|
|
|
+ */
|
|
|
|
+ handleRotateStream() {
|
|
|
|
+ if (!this.roQueueSubscription) {
|
|
|
|
+ this.roQueueSubscription = this.roQueue.subscribe(
|
|
|
|
+ async (stream: StreamFrameType) => {
|
|
|
|
+ this.rotateTimeStamp = Date.now();
|
|
|
|
+ if (this.rotateframeCnt === -1) {
|
|
|
|
+ this.rotateframeCnt = this.frameCnt.value;
|
|
|
|
+ }
|
|
|
|
+ this.rotateframeCnt += 1;
|
|
|
|
+
|
|
|
|
+ stream.frame = this.rotateframeCnt;
|
|
|
|
+ this._rotateCurrentFame += 1;
|
|
|
|
+
|
|
|
|
+ const IDRflag = this._rotateCurrentFame % 5 === 0 ? 1 : 3;
|
|
|
|
+ this.logger.log(
|
|
|
|
+ `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${this._rotateCurrentFame
|
|
|
|
+ } IDRflag:${IDRflag}`,
|
|
|
|
+ );
|
|
|
|
+ stream.DIR = this.rotateFirstIDR ? 1 : IDRflag;
|
|
|
|
+
|
|
|
|
+ if (this.rotateFirstIDR) {
|
|
|
|
+ this.rotateFirstIDR = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.logger.log(
|
|
|
|
+ '[media-rotate]: ' +
|
|
|
|
+ ', frame: ' +
|
|
|
|
+ stream.frame +
|
|
|
|
+ ', rotateframeCnt: ' +
|
|
|
|
+ this.rotateframeCnt +
|
|
|
|
+ ', clipPath: ' +
|
|
|
|
+ stream.clipPath,
|
|
|
|
+ // stream.metaData,
|
|
|
|
+ );
|
|
|
|
+ // this.logger.log(
|
|
|
|
+ // `roQueueSubscription:frame:${this.rotateframeCnt} ` +
|
|
|
|
+ // JSON.stringify(stream.metaData),
|
|
|
|
+ // );
|
|
|
|
+
|
|
|
|
+ const res = await this.streamService.pushFrameToSteam(stream);
|
|
|
|
+ if (res.done) {
|
|
|
|
+ clearTimeout(this._rotateTimeout);
|
|
|
|
+ this._rotateTimeout = setTimeout(() => {
|
|
|
|
+ this.logger.log('rotate end', Date.now());
|
|
|
|
+ this.frameCnt.next(res.frame);
|
|
|
|
+ this.rotateframeCnt = -1;
|
|
|
|
+ this._rotateCurrentFame = -1;
|
|
|
|
+ // this.onMoving.next(false);
|
|
|
|
+ // this.onRotating.next(false);
|
|
|
|
+ this.latestRotateRequest = null;
|
|
|
|
+ this.rotateFirstIDR = true;
|
|
|
|
+ this.resumeStream();
|
|
|
|
+ //TODO rotate完后清除request队列
|
|
|
|
+ if (this.roRequestQueueSub) {
|
|
|
|
+ this.roRequestQueueSub.unsubscribe();
|
|
|
|
+ this.roRequestQueueSub = null;
|
|
|
|
+ }
|
|
|
|
+ }, 50);
|
|
|
|
+ } else {
|
|
|
|
+ console.error('流地址有误::', res.frame, JSON.stringify(res));
|
|
|
|
+ this.logger.error('流地址有误::', res.frame, JSON.stringify(res));
|
|
|
|
+ this.resumeStream();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 旋转中断逻辑
|
|
* 旋转中断逻辑
|
|
* 1. 行走间
|
|
* 1. 行走间
|
|
* 1.1 行走间中断只能在每段最后一帧,当前段一定要消费掉,在未消费,globalOptLock锁rotate,消费完 rotate
|
|
* 1.1 行走间中断只能在每段最后一帧,当前段一定要消费掉,在未消费,globalOptLock锁rotate,消费完 rotate
|
|
* 1.2 消费完要处理点位上传,清除当前段往后的都要清掉,回调各种stop function
|
|
* 1.2 消费完要处理点位上传,清除当前段往后的都要清掉,回调各种stop function
|
|
* 2.joystick间 complementFrame pools 解锁就可以
|
|
* 2.joystick间 complementFrame pools 解锁就可以
|
|
*/
|
|
*/
|
|
- async handleRotateStop(request) {
|
|
|
|
|
|
+ async handleRotateOrWalkingStop(request): Promise<boolean> {
|
|
this.rotateStopThrottle = true;
|
|
this.rotateStopThrottle = true;
|
|
const lastStreamFrame = this.lastMoveStreamFrame.getValue();
|
|
const lastStreamFrame = this.lastMoveStreamFrame.getValue();
|
|
- this.logger.log('lastStreamFrame', JSON.stringify(lastStreamFrame));
|
|
|
|
|
|
+ this.logger.log(
|
|
|
|
+ 'handleRotateOrWalkingStop-frame',
|
|
|
|
+ JSON.stringify(lastStreamFrame),
|
|
|
|
+ );
|
|
|
|
|
|
const metaData: StreamReplyType = JSON.parse(
|
|
const metaData: StreamReplyType = JSON.parse(
|
|
lastStreamFrame.metaData,
|
|
lastStreamFrame.metaData,
|
|
@@ -315,7 +387,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
console.log('stop-5', request.trace_id);
|
|
console.log('stop-5', request.trace_id);
|
|
//判断request是否是新的
|
|
//判断request是否是新的
|
|
if (metaData.traceIds.indexOf(request.trace_id) > -1) {
|
|
if (metaData.traceIds.indexOf(request.trace_id) > -1) {
|
|
- return;
|
|
|
|
|
|
+ return Promise.resolve(false);
|
|
}
|
|
}
|
|
console.log('currentUser-user_id', this.user_id);
|
|
console.log('currentUser-user_id', this.user_id);
|
|
const newUserStates: NewUserStatesType = metaData.newUserStates.find(
|
|
const newUserStates: NewUserStatesType = metaData.newUserStates.find(
|
|
@@ -350,9 +422,34 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
cameraAngle,
|
|
cameraAngle,
|
|
playerAngle,
|
|
playerAngle,
|
|
);
|
|
);
|
|
- this.logger.log('stop-redisMeta', redisMeta);
|
|
|
|
- this.onMoving.next(false);
|
|
|
|
- this.cleanMoveSteam();
|
|
|
|
|
|
+ this.logger.log('stop-redisMeta-frame', JSON.stringify(redisMeta));
|
|
|
|
+ if (redisMeta) {
|
|
|
|
+ const src = redisMeta.mediaSrc.split('?')[0];
|
|
|
|
+ const mediaSrc = this.configService.get('app.prefix') + src;
|
|
|
|
+ const streamData: StreamFrameType = {
|
|
|
|
+ frame: this.frameCnt.value + 1,
|
|
|
|
+ clipPath: mediaSrc,
|
|
|
|
+ metaData: JSON.stringify(redisMeta),
|
|
|
|
+ serverTime: this.mockserverTime,
|
|
|
|
+ DIR: 1,
|
|
|
|
+ };
|
|
|
|
+ //推最后一个STOPFrame
|
|
|
|
+ const hasPush = await this.streamService.pushFrameToSteam(streamData);
|
|
|
|
+ if (hasPush.done) {
|
|
|
|
+ this.frameCnt.next(hasPush.frame);
|
|
|
|
+ // this.onMoving.next(false);
|
|
|
|
+ // this.cleanMoveSteam();
|
|
|
|
+ return Promise.resolve(true);
|
|
|
|
+ // this.resumeStream();
|
|
|
|
+ } else {
|
|
|
|
+ console.error(
|
|
|
|
+ '暂停STOP::帧有问题',
|
|
|
|
+ hasPush.frame,
|
|
|
|
+ JSON.stringify(streamData),
|
|
|
|
+ );
|
|
|
|
+ return Promise.resolve(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -363,68 +460,104 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
async walking(request: MoveRequest) {
|
|
async walking(request: MoveRequest) {
|
|
this.latestWalkingRequest = request;
|
|
this.latestWalkingRequest = request;
|
|
this.logger.log('walking-trace_id', request.trace_id);
|
|
this.logger.log('walking-trace_id', request.trace_id);
|
|
|
|
+
|
|
|
|
+ // if (this.isHasWalkingJoints()) {
|
|
|
|
+ // console.log('lock-锁-walking', this.latestWalkingRequest);
|
|
|
|
+ // this.globalOptLock = true;
|
|
|
|
+ // }
|
|
|
|
+
|
|
// 进入正常walking流程
|
|
// 进入正常walking流程
|
|
if (!this.onMoving.getValue()) {
|
|
if (!this.onMoving.getValue()) {
|
|
console.log('walking-step-main-1', request.trace_id);
|
|
console.log('walking-step-main-1', request.trace_id);
|
|
this.latestWalkingRequest = null;
|
|
this.latestWalkingRequest = null;
|
|
this.handleWalking(request);
|
|
this.handleWalking(request);
|
|
|
|
+ } else {
|
|
|
|
+ this.globalOptLock = true;
|
|
|
|
+ console.log('lock-锁-walking', this.latestWalkingRequest);
|
|
}
|
|
}
|
|
- this.handleWalkingJoints(request);
|
|
|
|
|
|
+ this.handleWalkingJoints();
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* 一段walking每个Joints关节点
|
|
* 一段walking每个Joints关节点
|
|
* @param request
|
|
* @param request
|
|
*/
|
|
*/
|
|
- handleWalkingJoints(request) {
|
|
|
|
- // 监听每小段最后一帧
|
|
|
|
|
|
+ handleWalkingJoints() {
|
|
|
|
+ // 每个关节点
|
|
if (!this.moveSliceLastFrameSub) {
|
|
if (!this.moveSliceLastFrameSub) {
|
|
this.moveSliceLastFrameSub = this.moveSliceLastFrame.subscribe(
|
|
this.moveSliceLastFrameSub = this.moveSliceLastFrame.subscribe(
|
|
async (frame: MovingLastUpdateType) => {
|
|
async (frame: MovingLastUpdateType) => {
|
|
//TODO 正在行走时,有新的reqest
|
|
//TODO 正在行走时,有新的reqest
|
|
if (frame) {
|
|
if (frame) {
|
|
|
|
+ console.log('unlock-Joints', JSON.stringify(frame));
|
|
this.logger.log('Joints', JSON.stringify(frame));
|
|
this.logger.log('Joints', JSON.stringify(frame));
|
|
- if (this.latestWalkingRequest && this.onMoving.value) {
|
|
|
|
- this.logger.log('stop-data-1', frame);
|
|
|
|
- this.moveQueueSubscription.unsubscribe();
|
|
|
|
- this.moveQueueSubscription = null;
|
|
|
|
- this.moveQueue.clean();
|
|
|
|
- //step1 执行stop方法
|
|
|
|
- const metaData: StreamReplyType = frame.metaData;
|
|
|
|
- const newUserStates: NewUserStatesType =
|
|
|
|
- metaData.newUserStates.find(
|
|
|
|
- (item) => item.userId === this.user_id,
|
|
|
|
|
|
+ // 在全局锁的情况下
|
|
|
|
+ if (this.globalOptLock) {
|
|
|
|
+ // 这个旋转暂停
|
|
|
|
+ // if (!!this.latestRotateRequest && this.onMoving.value) {
|
|
|
|
+ // const hasStop = await this.handleRotateOrWalkingStop(
|
|
|
|
+ // this.latestRotateRequest,
|
|
|
|
+ // );
|
|
|
|
+ // console.log('旋转-hasStop', hasStop);
|
|
|
|
+ // this.clearWalkingJoints();
|
|
|
|
+ // this.cleanMoveSteam();
|
|
|
|
+ // this.globalOptLock = false;
|
|
|
|
+ // }
|
|
|
|
+ // 这个行走暂停
|
|
|
|
+ if (!!this.latestWalkingRequest && this.onMoving.value) {
|
|
|
|
+ const hasStop = await this.handleRotateOrWalkingStop(
|
|
|
|
+ this.latestWalkingRequest,
|
|
);
|
|
);
|
|
- const trace_id = metaData.traceIds[0];
|
|
|
|
- const userId = newUserStates.userId;
|
|
|
|
- const breakPointId = metaData.endBreakPointId;
|
|
|
|
- const cameraAngle = newUserStates.playerState.camera.angle;
|
|
|
|
- const playerAngle = newUserStates.playerState.player.angle;
|
|
|
|
- this.logger.log(
|
|
|
|
- 'stop-data-2',
|
|
|
|
- trace_id,
|
|
|
|
- userId,
|
|
|
|
- cameraAngle,
|
|
|
|
- cameraAngle,
|
|
|
|
- );
|
|
|
|
- console.log('moveService.stop-2:' + breakPointId);
|
|
|
|
- const redisMeta = await this.moveService.stop(
|
|
|
|
- trace_id,
|
|
|
|
- userId,
|
|
|
|
- breakPointId,
|
|
|
|
- cameraAngle,
|
|
|
|
- playerAngle,
|
|
|
|
- );
|
|
|
|
- this.logger.log('stop-redisMeta', JSON.stringify(redisMeta));
|
|
|
|
- // 2. 中断重新walking
|
|
|
|
- console.log(
|
|
|
|
- 'walking-step-reWalking-1',
|
|
|
|
- request.trace_id + ',' + this.latestWalkingRequest.trace_id,
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- this.logger.debug('重新行走---handleReWalking');
|
|
|
|
- console.log('重新行走---handleReWalking');
|
|
|
|
- this.handleReWalking(this.latestWalkingRequest);
|
|
|
|
|
|
+ console.log('walking-hasStop', hasStop);
|
|
|
|
+ this.clearWalkingJoints();
|
|
|
|
+ this.cleanMoveSteam();
|
|
|
|
+ this.globalOptLock = false;
|
|
|
|
+ console.log('unlock-walking');
|
|
|
|
+ this.handleReWalking(this.latestWalkingRequest);
|
|
|
|
+ // console.log('this', this.rewalking);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ // if (this.latestWalkingRequest && this.onMoving.value) {
|
|
|
|
+ // this.logger.log('stop-data-1', frame);
|
|
|
|
+ // this.moveQueueSubscription.unsubscribe();
|
|
|
|
+ // this.moveQueueSubscription = null;
|
|
|
|
+ // this.moveQueue.clean();
|
|
|
|
+ // //step1 执行stop方法
|
|
|
|
+ // const metaData: StreamReplyType = frame.metaData;
|
|
|
|
+ // const newUserStates: NewUserStatesType =
|
|
|
|
+ // metaData.newUserStates.find(
|
|
|
|
+ // (item) => item.userId === this.user_id,
|
|
|
|
+ // );
|
|
|
|
+ // const trace_id = metaData.traceIds[0];
|
|
|
|
+ // const userId = newUserStates.userId;
|
|
|
|
+ // const breakPointId = metaData.endBreakPointId;
|
|
|
|
+ // const cameraAngle = newUserStates.playerState.camera.angle;
|
|
|
|
+ // const playerAngle = newUserStates.playerState.player.angle;
|
|
|
|
+ // this.logger.log(
|
|
|
|
+ // 'stop-data-2',
|
|
|
|
+ // trace_id,
|
|
|
|
+ // userId,
|
|
|
|
+ // cameraAngle,
|
|
|
|
+ // cameraAngle,
|
|
|
|
+ // );
|
|
|
|
+ // console.log('moveService.stop-2:' + breakPointId);
|
|
|
|
+ // const redisMeta = await this.moveService.stop(
|
|
|
|
+ // trace_id,
|
|
|
|
+ // userId,
|
|
|
|
+ // breakPointId,
|
|
|
|
+ // cameraAngle,
|
|
|
|
+ // playerAngle,
|
|
|
|
+ // );
|
|
|
|
+ // this.logger.log('stop-redisMeta', JSON.stringify(redisMeta));
|
|
|
|
+ // // 2. 中断重新walking
|
|
|
|
+ // console.log(
|
|
|
|
+ // 'walking-step-reWalking-1',
|
|
|
|
+ // request.trace_id + ',' + this.latestWalkingRequest.trace_id,
|
|
|
|
+ // );
|
|
|
|
+
|
|
|
|
+ // this.logger.debug('重新行走---handleReWalking');
|
|
|
|
+ // console.log('重新行走---handleReWalking');
|
|
|
|
+ // this.handleReWalking(this.latestWalkingRequest);
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
);
|
|
);
|
|
@@ -559,7 +692,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
* @param request MoveRequest
|
|
* @param request MoveRequest
|
|
*/
|
|
*/
|
|
handleReWalking(request: MoveRequest) {
|
|
handleReWalking(request: MoveRequest) {
|
|
- this.latestWalkingRequest = null;
|
|
|
|
|
|
+ // this.latestWalkingRequest = null;
|
|
this.rewalking = true;
|
|
this.rewalking = true;
|
|
this.handleWalking(request);
|
|
this.handleWalking(request);
|
|
}
|
|
}
|
|
@@ -780,27 +913,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- cleanMoveSteam() {
|
|
|
|
- this.moveQueue.clean();
|
|
|
|
- if (this.moveQueueSubscription) {
|
|
|
|
- this.moveQueueSubscription.unsubscribe();
|
|
|
|
- this.moveQueueSubscription = null;
|
|
|
|
- }
|
|
|
|
- if (this.walkingSub) {
|
|
|
|
- this.walkingSub.unsubscribe();
|
|
|
|
- this.walkingSub = null;
|
|
|
|
- }
|
|
|
|
- if (this.moveSliceLastFrameSub) {
|
|
|
|
- this.lastMoveStreamFrame.next(null);
|
|
|
|
- this.moveSliceLastFrameSub.unsubscribe();
|
|
|
|
- this.moveSliceLastFrameSub = null;
|
|
|
|
- }
|
|
|
|
- // if (this.clickQueueSub) {
|
|
|
|
- // this.clickQueueSub.unsubscribe();
|
|
|
|
- // this.clickQueueSub = null;
|
|
|
|
- // }
|
|
|
|
- this.rotateStopThrottle = false;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
handleMoveSteam() {
|
|
handleMoveSteam() {
|
|
this.moveQueueSubscription = this.moveQueue.subscribe(
|
|
this.moveQueueSubscription = this.moveQueue.subscribe(
|
|
async (stream: StreamFrameType) => {
|
|
async (stream: StreamFrameType) => {
|
|
@@ -870,7 +983,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
this.lastMovingPointArray = [];
|
|
this.lastMovingPointArray = [];
|
|
this.hasJoystickMoveRequest = false;
|
|
this.hasJoystickMoveRequest = false;
|
|
this.cleanMoveSteam();
|
|
this.cleanMoveSteam();
|
|
- // this.globalOptLock = false;
|
|
|
|
|
|
+ this.globalOptLock = false;
|
|
this.resumeStream();
|
|
this.resumeStream();
|
|
this.logger.log('move end');
|
|
this.logger.log('move end');
|
|
}, 200);
|
|
}, 200);
|
|
@@ -888,6 +1001,28 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ cleanMoveSteam() {
|
|
|
|
+ this.moveQueue.clean();
|
|
|
|
+ if (this.moveQueueSubscription) {
|
|
|
|
+ this.moveQueueSubscription.unsubscribe();
|
|
|
|
+ this.moveQueueSubscription = null;
|
|
|
|
+ }
|
|
|
|
+ if (this.walkingSub) {
|
|
|
|
+ this.walkingSub.unsubscribe();
|
|
|
|
+ this.walkingSub = null;
|
|
|
|
+ }
|
|
|
|
+ if (this.moveSliceLastFrameSub) {
|
|
|
|
+ this.lastMoveStreamFrame.next(null);
|
|
|
|
+ this.moveSliceLastFrameSub.unsubscribe();
|
|
|
|
+ this.moveSliceLastFrameSub = null;
|
|
|
|
+ }
|
|
|
|
+ // if (this.clickQueueSub) {
|
|
|
|
+ // this.clickQueueSub.unsubscribe();
|
|
|
|
+ // this.clickQueueSub = null;
|
|
|
|
+ // }
|
|
|
|
+ this.rotateStopThrottle = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
handleDataChanelOpen(channel: DataChannel, peer: PeerConnection): void {
|
|
handleDataChanelOpen(channel: DataChannel, peer: PeerConnection): void {
|
|
this.channel = channel;
|
|
this.channel = channel;
|
|
this.peer = peer;
|
|
this.peer = peer;
|
|
@@ -920,7 +1055,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const msg: RTCMessageRequest = JSON.parse(parseData);
|
|
const msg: RTCMessageRequest = JSON.parse(parseData);
|
|
this.logger.error('lostIframe-message', JSON.stringify(msg));
|
|
this.logger.error('lostIframe-message', JSON.stringify(msg));
|
|
if (Number(msg.MstType) === 0) {
|
|
if (Number(msg.MstType) === 0) {
|
|
- this.handleIframeRequest();
|
|
|
|
|
|
+ // this.handleIframeRequest();
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
const msg: RTCMessageRequest = JSON.parse(message);
|
|
const msg: RTCMessageRequest = JSON.parse(message);
|
|
@@ -1007,76 +1142,6 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
this.logger.error('updateUserStatus::function', error.message);
|
|
this.logger.error('updateUserStatus::function', error.message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /**
|
|
|
|
- * rotate 推送队列
|
|
|
|
- */
|
|
|
|
- handleRotateStream() {
|
|
|
|
- if (!this.roQueueSubscription) {
|
|
|
|
- this.roQueueSubscription = this.roQueue.subscribe(
|
|
|
|
- async (stream: StreamFrameType) => {
|
|
|
|
- this.rotateTimeStamp = Date.now();
|
|
|
|
- if (this.rotateframeCnt === -1) {
|
|
|
|
- this.rotateframeCnt = this.frameCnt.value;
|
|
|
|
- }
|
|
|
|
- this.rotateframeCnt += 1;
|
|
|
|
-
|
|
|
|
- stream.frame = this.rotateframeCnt;
|
|
|
|
- this._rotateCurrentFame += 1;
|
|
|
|
-
|
|
|
|
- const IDRflag = this._rotateCurrentFame % 5 === 0 ? 1 : 3;
|
|
|
|
- this.logger.log(
|
|
|
|
- `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${this._rotateCurrentFame
|
|
|
|
- } IDRflag:${IDRflag}`,
|
|
|
|
- );
|
|
|
|
- stream.DIR = this.rotateFirstIDR ? 1 : IDRflag;
|
|
|
|
-
|
|
|
|
- if (this.rotateFirstIDR) {
|
|
|
|
- this.rotateFirstIDR = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.logger.log(
|
|
|
|
- '[media-rotate]: ' +
|
|
|
|
- ', frame: ' +
|
|
|
|
- stream.frame +
|
|
|
|
- ', rotateframeCnt: ' +
|
|
|
|
- this.rotateframeCnt +
|
|
|
|
- ', clipPath: ' +
|
|
|
|
- stream.clipPath,
|
|
|
|
- // stream.metaData,
|
|
|
|
- );
|
|
|
|
- // this.logger.log(
|
|
|
|
- // `roQueueSubscription:frame:${this.rotateframeCnt} ` +
|
|
|
|
- // JSON.stringify(stream.metaData),
|
|
|
|
- // );
|
|
|
|
-
|
|
|
|
- const res = await this.streamService.pushFrameToSteam(stream);
|
|
|
|
- if (res.done) {
|
|
|
|
- clearTimeout(this._rotateTimeout);
|
|
|
|
- this._rotateTimeout = setTimeout(() => {
|
|
|
|
- this.logger.log('rotate end', Date.now());
|
|
|
|
- this.frameCnt.next(res.frame);
|
|
|
|
- this.resumeStream();
|
|
|
|
- this.rotateframeCnt = -1;
|
|
|
|
- this._rotateCurrentFame = -1;
|
|
|
|
- this.onMoving.next(false);
|
|
|
|
- this.onRotating.next(false);
|
|
|
|
- this.rotateFirstIDR = true;
|
|
|
|
- //TODO rotate完后清除request队列
|
|
|
|
- if (this.roRequestQueueSub) {
|
|
|
|
- this.roRequestQueueSub.unsubscribe();
|
|
|
|
- this.roRequestQueueSub = null;
|
|
|
|
- }
|
|
|
|
- this.moveQueue.clean();
|
|
|
|
- }, 50);
|
|
|
|
- } else {
|
|
|
|
- console.error('流地址有误::', res.frame, JSON.stringify(res));
|
|
|
|
- this.logger.error('流地址有误::', res.frame, JSON.stringify(res));
|
|
|
|
- this.resumeStream();
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
pushFirstRender(clipPath: string, metaData: string): Promise<boolean> {
|
|
pushFirstRender(clipPath: string, metaData: string): Promise<boolean> {
|
|
return new Promise<boolean>(async (resolve, reject) => {
|
|
return new Promise<boolean>(async (resolve, reject) => {
|