|
@@ -34,6 +34,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
public _rotateTimeout: NodeJS.Timeout;
|
|
|
public _moveTimeout: NodeJS.Timeout;
|
|
|
public _JoyStickingSteamTimeout: NodeJS.Timeout;
|
|
|
+ public _packFrameTimeout: NodeJS.Timeout;
|
|
|
public startSteaming = new BehaviorSubject<boolean>(false);
|
|
|
public onRotating = new BehaviorSubject<boolean>(false);
|
|
|
public onMoving = new BehaviorSubject<boolean>(false);
|
|
@@ -100,7 +101,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
private isJoystickHasStream = false;
|
|
|
private hasJoystickFocusRepeat = false;
|
|
|
- private startSub: any
|
|
|
+ private startSub: any;
|
|
|
|
|
|
public users = {};
|
|
|
|
|
@@ -213,6 +214,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
exit() {
|
|
|
this.frameCnt.next(-1);
|
|
|
this.rotateService.deleteUser(this.user_id);
|
|
|
+ this.hasJoystickFocusRepeat = false;
|
|
|
if (this.startSub) {
|
|
|
this.startSub.unsubscribe();
|
|
|
this.startSub = null;
|
|
@@ -365,7 +367,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.roRequestQueueSub.unsubscribe();
|
|
|
this.roRequestQueueSub = null;
|
|
|
}
|
|
|
- }, 50);
|
|
|
+ }, 100);
|
|
|
} else {
|
|
|
console.error('流地址有误::', res.frame, JSON.stringify(res));
|
|
|
this.logger.error('流地址有误::', res.frame, JSON.stringify(res));
|
|
@@ -501,7 +503,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
async (frame: MovingLastUpdateType) => {
|
|
|
//TODO 正在行走时,有新的reqest
|
|
|
if (frame) {
|
|
|
- console.log('unlock-Joints', JSON.stringify(frame));
|
|
|
+ // console.log('unlock-Joints', JSON.stringify(frame));
|
|
|
this.logger.log('Joints', JSON.stringify(frame));
|
|
|
let isRotateStop = false;
|
|
|
let isWalkingStop = false;
|
|
@@ -646,6 +648,8 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.logger.log('walking-path', path);
|
|
|
if (!path) {
|
|
|
console.log('不存在--path', path);
|
|
|
+ this.cleanMoveSteam();
|
|
|
+ this.clearWalkingJoints();
|
|
|
this.resumeStream();
|
|
|
return;
|
|
|
}
|
|
@@ -1084,7 +1088,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
const msg: RTCMessageRequest = JSON.parse(parseData);
|
|
|
this.logger.error('lostIframe-message', JSON.stringify(msg));
|
|
|
if (Number(msg.MstType) === 0) {
|
|
|
- // this.handleIframeRequest();
|
|
|
+ this.handleIframeRequest();
|
|
|
}
|
|
|
} else {
|
|
|
const msg: RTCMessageRequest = JSON.parse(message);
|
|
@@ -1123,16 +1127,30 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
async handleIframeRequest() {
|
|
|
//TODO Iframe 最终传什么?
|
|
|
+ this.holdSteam();
|
|
|
this.requestIFrameQueue.next(this.streamService.lastStreamFrame.getValue());
|
|
|
if (!this.requestIFrameQueueSub) {
|
|
|
this.requestIFrameQueueSub = this.requestIFrameQueue.subscribe(
|
|
|
- (frameData: StreamFrameType) => {
|
|
|
- const nextFrame = this.frameCnt.getValue() + 1;
|
|
|
- this.logger.warn('lostIframe', nextFrame);
|
|
|
- frameData.frame = nextFrame;
|
|
|
- this.streamService.pushFrameToSteam(frameData);
|
|
|
- this.frameCnt.next(nextFrame);
|
|
|
- this.resumeStream();
|
|
|
+ async (frameData: StreamFrameType) => {
|
|
|
+ if (frameData) {
|
|
|
+ const nextFrame = this.frameCnt.getValue() + 1;
|
|
|
+ this.logger.warn('lostIframe', nextFrame);
|
|
|
+ frameData.frame = nextFrame;
|
|
|
+ frameData.DIR = 1;
|
|
|
+ const res = await this.streamService.pushFrameToSteam(frameData);
|
|
|
+ if (res.done) {
|
|
|
+ this.logger.error(
|
|
|
+ ' frame:' + res.frame + ' 补帧::' + JSON.stringify(frameData),
|
|
|
+ );
|
|
|
+ this.frameCnt.next(res.frame);
|
|
|
+ clearTimeout(this._packFrameTimeout);
|
|
|
+ this._packFrameTimeout = setTimeout(() => {
|
|
|
+ this.resumeStream();
|
|
|
+ }, 100);
|
|
|
+ } else {
|
|
|
+ console.error('补帧有误:', JSON.stringify(frameData));
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
);
|
|
|
}
|