|
@@ -101,7 +101,10 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
metaData: '',
|
|
metaData: '',
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ public testTimer = 0;
|
|
|
|
+
|
|
private isJoystickHasStream = false;
|
|
private isJoystickHasStream = false;
|
|
|
|
+ private hasJoystickFocusRepeat = false
|
|
|
|
|
|
public users = {};
|
|
public users = {};
|
|
|
|
|
|
@@ -569,6 +572,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
*/
|
|
*/
|
|
async handlePushJoyStickSteam(joystickRes: StreamReplyType) {
|
|
async handlePushJoyStickSteam(joystickRes: StreamReplyType) {
|
|
this.holdSteam();
|
|
this.holdSteam();
|
|
|
|
+
|
|
console.log('joystickRes有mediaSrc', joystickRes.mediaSrc);
|
|
console.log('joystickRes有mediaSrc', joystickRes.mediaSrc);
|
|
let streamData: StreamFrameType | StreamMetaType;
|
|
let streamData: StreamFrameType | StreamMetaType;
|
|
|
|
|
|
@@ -614,58 +618,81 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
this.moveService.sendingFrameForJoystick = false;
|
|
this.moveService.sendingFrameForJoystick = false;
|
|
const data = joystickRes as StreamReplyType;
|
|
const data = joystickRes as StreamReplyType;
|
|
console.log('handlejoystick-moveOver:' + data.moveOver);
|
|
console.log('handlejoystick-moveOver:' + data.moveOver);
|
|
- if (data?.moveOver && data.moveOver) {
|
|
|
|
- // moveOver
|
|
|
|
- console.log('回传updateUser', data);
|
|
|
|
- // const userId = this.user_id;
|
|
|
|
- // 回传点暂时有问题,待修复
|
|
|
|
- //const breakPointId = data.endBreakPointId || data.breakPointId;
|
|
|
|
- //const lastReply = JSON.stringify(joystickRes);
|
|
|
|
- //this.moveService.updateUser(userId, breakPointId, lastReply);
|
|
|
|
- }
|
|
|
|
|
|
+ // if (data?.moveOver && data.moveOver) {
|
|
|
|
+ // // moveOver
|
|
|
|
+ // console.log('回传updateUser', data);
|
|
|
|
+ // // const userId = this.user_id;
|
|
|
|
+ // // 回传点暂时有问题,待修复
|
|
|
|
+ // //const breakPointId = data.endBreakPointId || data.breakPointId;
|
|
|
|
+ // //const lastReply = JSON.stringify(joystickRes);
|
|
|
|
+ // //this.moveService.updateUser(userId, breakPointId, lastReply);
|
|
|
|
+ // }
|
|
this.frameCnt.next(hasPush.frame);
|
|
this.frameCnt.next(hasPush.frame);
|
|
-
|
|
|
|
- // 最后一帧200ms
|
|
|
|
- clearTimeout(this._JoyStickingSteamTimeout);
|
|
|
|
- this._JoyStickingSteamTimeout = setTimeout(async () => {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 这个complementFrame 具体说明 pools 是complementFrame这个返回值
|
|
|
|
+ * 1. 第一次要在200ms后调用, 如有值(pools) 就要返回主流程执行,但设置hasJoystickFocusRepeat为true
|
|
|
|
+ * 2. 第二次或N进入在hasJoystickFocusRepeat为true并绕过200ms timeout,如pools有值返回(2)主流程直到pools为null
|
|
|
|
+ * 3. 如pools为空走回 200ms流程 (这时pools应该为空),交权回空流。
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ if (this.hasJoystickFocusRepeat) {
|
|
const complementFrame = this.moveService.complementFrame(
|
|
const complementFrame = this.moveService.complementFrame(
|
|
this.user_id,
|
|
this.user_id,
|
|
) as StreamReplyType;
|
|
) as StreamReplyType;
|
|
- console.log('has-complementFrame', complementFrame);
|
|
|
|
if (complementFrame) {
|
|
if (complementFrame) {
|
|
- const start = performance.now();
|
|
|
|
|
|
+ // 第二次或N次进入时如果有值直接重新进入流主程
|
|
this.handlePushJoyStickSteam(complementFrame);
|
|
this.handlePushJoyStickSteam(complementFrame);
|
|
- const stop = performance.now();
|
|
|
|
- const inMillSeconds = stop - start;
|
|
|
|
- const rounded = Number(inMillSeconds).toFixed(3);
|
|
|
|
- console.log(`complementFrame调用时间---->${rounded}`);
|
|
|
|
} else {
|
|
} else {
|
|
- this.logger.log('joystick opt done');
|
|
|
|
- this.logger.log('joystick 交权给空流,当前pts', hasPush.frame);
|
|
|
|
- // const stopFrameData = this.moveService.stopJoystick(this.user_id);
|
|
|
|
- // const stopFrame: StreamMetaType = {
|
|
|
|
- // frame: hasPush.frame + 1,
|
|
|
|
- // metaData: JSON.stringify(stopFrameData),
|
|
|
|
- // };
|
|
|
|
- // const stopRes = await this.streamService.pushMetaDataToSteam(
|
|
|
|
- // stopFrame,
|
|
|
|
- // );
|
|
|
|
- // console.log('stopFrame', stopFrame);
|
|
|
|
- // if (stopRes.done) {
|
|
|
|
- // }
|
|
|
|
- this.onJoysticking.next(false);
|
|
|
|
- this.resumeStream();
|
|
|
|
- this.joystickFrameCnt = -1;
|
|
|
|
- this.isJoystickHasStream = false;
|
|
|
|
- // this.frameCnt.next(res.frame);
|
|
|
|
|
|
+ // 第二次或N次无pool数据再次trigger handleJoystickStop
|
|
|
|
+ console.log('gemer-test-complementFrame-空2');
|
|
|
|
+ this.hasJoystickFocusRepeat = false;
|
|
|
|
+ this.testTimer = 0;
|
|
|
|
+ this.handleJoystickStop(hasPush);
|
|
}
|
|
}
|
|
- }, 200);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ this.handleJoystickStop(hasPush);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
console.error('joystick-流地址有误::', joystickRes.mediaSrc);
|
|
console.error('joystick-流地址有误::', joystickRes.mediaSrc);
|
|
this.logger.error('joystick-流地址有误::', joystickRes.mediaSrc);
|
|
this.logger.error('joystick-流地址有误::', joystickRes.mediaSrc);
|
|
this.resumeStream();
|
|
this.resumeStream();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * Joystick Stop function
|
|
|
|
+ */
|
|
|
|
+ handleJoystickStop(hasPush: StreamPushResponse) {
|
|
|
|
+ // 最后一帧200ms
|
|
|
|
+ clearTimeout(this._JoyStickingSteamTimeout);
|
|
|
|
+ this._JoyStickingSteamTimeout = setTimeout(async () => {
|
|
|
|
+ const complementFrame = this.moveService.complementFrame(
|
|
|
|
+ this.user_id,
|
|
|
|
+ ) as StreamReplyType;
|
|
|
|
+ // console.log('has-complementFrame', complementFrame);
|
|
|
|
+ console.log('gemer-test-complementFrame', complementFrame);
|
|
|
|
+ if (complementFrame) {
|
|
|
|
+ this.hasJoystickFocusRepeat = true;
|
|
|
|
+ this.testTimer += 1;
|
|
|
|
+ console.log('gemer-test-complementFrame-有值');
|
|
|
|
+ const start = performance.now();
|
|
|
|
+ this.handlePushJoyStickSteam(complementFrame);
|
|
|
|
+ const stop = performance.now();
|
|
|
|
+ console.log('gemer-test-handlePushJoyStickSteam', this.testTimer);
|
|
|
|
+ const inMillSeconds = stop - start;
|
|
|
|
+ const rounded = Number(inMillSeconds).toFixed(3);
|
|
|
|
+ console.log(`gemer-test-complementFrame调用时间---->${rounded}`);
|
|
|
|
+ } else {
|
|
|
|
+ console.log('gemer-test-complementFrame-空1');
|
|
|
|
+ this.logger.log('joystick opt done');
|
|
|
|
+ this.logger.log('joystick 交权给空流,当前pts', hasPush.frame);
|
|
|
|
+ this.hasJoystickFocusRepeat = false;
|
|
|
|
+ this.onJoysticking.next(false);
|
|
|
|
+ this.resumeStream();
|
|
|
|
+ this.joystickFrameCnt = -1;
|
|
|
|
+ this.isJoystickHasStream = false;
|
|
|
|
+ }
|
|
|
|
+ }, 200);
|
|
|
|
+ }
|
|
|
|
|
|
/***
|
|
/***
|
|
* joystick
|
|
* joystick
|