浏览代码

udpate the roate test

gemercheung 3 年之前
父节点
当前提交
30b134ee91
共有 2 个文件被更改,包括 25 次插入75 次删除
  1. 5 4
      src/meta.gateway.ts
  2. 20 71
      src/scene/scene.service.ts

+ 5 - 4
src/meta.gateway.ts

@@ -123,7 +123,7 @@ export class MetaGateway
 
     this.peer.onLocalCandidate((candidate, mid) => {
       if (/172\./.test(candidate)) {
-        console.error('private Ip process', candidate);
+        this.logger.log('server private Ip process', JSON.stringify(candidate));
         const PRIVATE_IP = this.configService.get('server.private_ip');
         if (candidate.includes(PRIVATE_IP)) {
           candidate = replaceToPublic(candidate);
@@ -133,8 +133,8 @@ export class MetaGateway
       }
 
       if (/192.168\./.test(candidate)) {
-        if (!/192.168.0\./.test(candidate)) {
-          console.warn('不是192.168.0.测试网段', candidate);
+        if (!/192.168.0\./.test(candidate) || !/192.168.10\./.test(candidate)) {
+          console.warn('不是192.168.0./192.168.10测试网段', candidate);
           return;
         }
         // if (candidate.includes(process.env.PRIVATE_IP)) {
@@ -231,7 +231,8 @@ export class MetaGateway
   handlerIceCandidate(client: any, payload: any) {
     const iceCandidate = Buffer.from(payload, 'base64').toString('utf-8');
     const candidate = JSON.parse(iceCandidate);
-    console.warn('收到ice_candidate', candidate);
+    // console.warn('收到ice_candidate',);
+    this.logger.log('server get ice_candidate', JSON.stringify(candidate));
     this.peer.addRemoteCandidate(candidate.candidate, candidate.sdpMid);
   }
 

+ 20 - 71
src/scene/scene.service.ts

@@ -76,7 +76,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
   constructor(
     private cacheService: CacheService,
     private streamService: StreamService,
-  ) { }
+  ) {}
   @Client(grpcClientOptions) private readonly client: ClientGrpc;
   private sceneGrpcService: SceneGrpcService;
 
@@ -151,7 +151,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     return this.sceneGrpcService.move(request);
   }
 
-  async rotate(request: RotateRequest) {
+  async rotate1(request: RotateRequest) {
     try {
       // const reply = this.sceneGrpcService.rotate(request);
       if (!this.onSteaming) {
@@ -203,21 +203,23 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     }
   }
 
-  async rotatebk(request: RotateRequest) {
+  async rotate(request: RotateRequest) {
     try {
-      const reply = this.sceneGrpcService.rotate(request);
-      const res = await this.cacheService.publish(
-        'test',
-        JSON.stringify(request),
-      );
+      // const reply = this.sceneGrpcService.rotate(request);
+      // const res = await this.cacheService.publish(
+      //   'test',
+      //   JSON.stringify(request),
+      // );
 
-      console.log('res', res);
+      // console.log('res', res);
 
       if (!this.onSteaming) {
         this.frameCnt += 1;
         this.RotateframeCnt = this.frameCnt;
         // this.cacheService
         this.testFrame += 1;
+        this.mockserverTime += 10;
+        this.onSteaming = true;
         if (this.testFrame > 358) this.testFrame = 0;
         const stream: StreamFrameType = {
           frame: this.frameCnt,
@@ -226,53 +228,19 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
             `../ws/video/100/100.${this.testFrame.padLeft(4, '0')}.h264`,
           ),
           metaData: JSON.stringify(frameMetaReply),
-          serverTime: 754871824,
-          DIR: 1,
+          serverTime: this.mockserverTime,
+          DIR: 3,
         };
         console.log('stream', this.frameCnt, stream.clipPath);
         this.streamService.pushFrameToSteam(stream);
-        const redisMeta = await this.cacheService.rpop(
-          `updateFrameMetadata:${this.user_id}`,
-        );
-        // this.frameCnt += 1;
-        if (redisMeta && redisMeta.length > 0) {
-          console.log('this.user_id', this.user_id);
-          const meta = JSON.parse(redisMeta);
-          if ('mediaSrc' in meta) {
-            console.log('meta', meta);
-            console.log('mediaSrc', meta.mediaSrc);
-
-            if (meta.mediaSrc.length > 0) {
-              // const testclipPath = meta.mediaSrc.replace(
-              //   '/mnt/oss/metaverse/scene/0000000001/100/',
-              //   '',
-              // );
-              // console.log('testclipPath', testclipPath);
-              // // const demoPath =
-              // //   this.frameCnt > 10
-              // //     ? path.join(__dirname, '../ws/video/53.h264')
-              // //     : path.join(__dirname, '../ws/video/2.h264');
-              // const demoPath = path.join(
-              //   __dirname,
-              //   `../ws/video/${testclipPath}`,
-              // );
-              // delete meta.mediaSrc;
-              // const stream: StreamFrameType = {
-              //   frame: this.frameCnt,
-              //   clipPath: demoPath,
-              //   metaData: JSON.stringify(meta),
-              //   serverTime: 754873824,
-              //   DIR: 3,
-              // };
-              // this.streamService.pushFrameToSteam(stream);
-            }
-          }
-        }
+        // const redisMeta = await this.cacheService.rpop(
+        //   `updateFrameMetadata:${this.user_id}`,
+        // );
       }
-      reply.subscribe((res: NormalReply) => {
-        if (res.code === 200) {
-        }
-      });
+      // reply.subscribe((res: NormalReply) => {
+      //   if (res.code === 200) {
+      //   }
+      // });
     } catch (error) {
       this.logger.error('rotate', error);
     }
@@ -661,23 +629,6 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           this.streamService.pushFrameToSteam(stream);
         }
 
-        // console.log('padLeft', );
-        // if (this.frameCnt > 2) {
-        //   setInterval(() => {
-        //     this.frameCnt += 1;
-        //     const stream: StreamFrameType = {
-        //       frame: this.frameCnt,
-        //       clipPath: path.join(
-        //         __dirname,
-        //         `../ws/video/100/100.${this.frameCnt.padLeft(4, '0')}.h264`,
-        //       ),
-        //       metaData: JSON.stringify(frameMetaReply),
-        //       serverTime: 754871824,
-        //     };
-        //     this.streamService.pushFrameToSteam(stream);
-        //   }, 1000 / 30);
-        // };
-
         if (this.frameCnt > 1 && !this.onSteaming) {
           const streamMeta: StreamMetaType = {
             frame: this.frameCnt,
@@ -685,8 +636,6 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           };
           this.streamService.pushMetaDataToSteam(streamMeta);
         }
-
-        // }
       } catch (error) {
         console.log('error', error);
       }