|
@@ -87,6 +87,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
private logger: Logger = new Logger('SceneService');
|
|
|
private frameCntInterval = 1000;
|
|
|
public _frameInteval: NodeJS.Timeout;
|
|
|
+ public _frameTimeout: NodeJS.Timeout;
|
|
|
private channel: DataChannel;
|
|
|
public startSteaming = new BehaviorSubject<boolean>(false);
|
|
|
private user_id: string;
|
|
@@ -115,6 +116,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
}
|
|
|
|
|
|
startStream() {
|
|
|
+ clearInterval(this._frameInteval);
|
|
|
if (this.frameCnt.value === -1) {
|
|
|
this._frameInteval = setInterval(async () => {
|
|
|
const next = this.frameCnt.value + 1;
|
|
@@ -129,9 +131,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
resumeStream(value: number) {
|
|
|
this.frameCnt.next(value);
|
|
|
- this._frameInteval = setInterval(async () => {
|
|
|
- const next = this.frameCnt.value + 1;
|
|
|
- this.frameCnt.next(next);
|
|
|
+ clearTimeout(this._frameTimeout);
|
|
|
+ this._frameTimeout = setTimeout(() => {
|
|
|
+ this._frameInteval = setInterval(async () => {
|
|
|
+ const next = this.frameCnt.value + 1;
|
|
|
+ this.frameCnt.next(next);
|
|
|
+ }, 1000);
|
|
|
}, 1000);
|
|
|
}
|
|
|
|
|
@@ -723,7 +728,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
setTimeout(() => {
|
|
|
const now = Date.now();
|
|
|
if (now - this.rotateTimeStamp > 300) {
|
|
|
- this.resumeStream(this.rotateframeCnt);
|
|
|
+ const next = this.rotateframeCnt + 1;
|
|
|
+ this.resumeStream(next);
|
|
|
+ this.rotateframeCnt = -1;
|
|
|
}
|
|
|
}, 300);
|
|
|
},
|