gemercheung 3 лет назад
Родитель
Сommit
136f1c49f0
1 измененных файлов с 21 добавлено и 8 удалено
  1. 21 8
      src/scene/scene.service.ts

+ 21 - 8
src/scene/scene.service.ts

@@ -1084,7 +1084,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);
@@ -1124,15 +1124,28 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
   async handleIframeRequest() {
     //TODO Iframe 最终传什么?
     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);
+              this.resumeStream();
+            } else {
+              console.error('补帧有误:', JSON.stringify(frameData));
+            }
+          }
         },
       );
     }