gemercheung vor 3 Jahren
Ursprung
Commit
9a778b96a6
5 geänderte Dateien mit 131 neuen und 41 gelöschten Zeilen
  1. 39 0
      config.dev.yaml
  2. 39 0
      config.production.yaml
  3. 14 14
      config.yaml
  4. 38 26
      src/scene/scene.service.ts
  5. 1 1
      src/scene/stream/stream.service.ts

+ 39 - 0
config.dev.yaml

@@ -0,0 +1,39 @@
+http:
+  host: '0.0.0.0'
+  port: 6688
+
+
+# grpc:
+#   url: '221.4.210.172:23000'
+grpc:
+  url: '192.168.0.200:3000'
+
+# redis:
+#   port: 26379
+#   host: '221.4.210.172' #远程调试需要设置bindip 为0.0.0.0 并且设置密码
+#   password: '' # 非远程不需要密码
+#   decode_responses: true
+#   db: 9
+
+redis:
+  port: 6379
+  host: '192.168.0.47' #远程调试需要设置bindip 为0.0.0.0 并且设置密码
+  password: '' # 非远程不需要密码
+  decode_responses: true
+  db: 9
+
+stun:
+  server: ['stun:172.18.156.41:3478', 'stun:120.24.252.95:3478']
+  portRangeBegin: 52000
+  portRangeEnd: 53000
+
+server:
+  private_ip: 172.18.197.114
+  public_ip: 120.24.252.95
+
+  
+# PRIVATE_IP=172.18.197.114
+# PUBLIC_IP=120.24.252.95
+# STUNS_SEVER="stun:172.18.156.41:3478,stun:120.24.252.95:3478"
+# GRPC_URL="192.168.0.48:3000"
+# REDIS_URL="redis://:192.168.0.47:6379/9"

+ 39 - 0
config.production.yaml

@@ -0,0 +1,39 @@
+http:
+  host: '0.0.0.0'
+  port: 6688
+
+
+grpc:
+  url: '221.4.210.172:23000'
+# grpc:
+#   url: '192.168.0.47:3000'
+
+redis:
+  port: 26379
+  host: '221.4.210.172' #远程调试需要设置bindip 为0.0.0.0 并且设置密码
+  password: '' # 非远程不需要密码
+  decode_responses: true
+  db: 9
+
+# redis:
+#   port: 6379
+#   host: '192.168.0.47' #远程调试需要设置bindip 为0.0.0.0 并且设置密码
+#   password: '' # 非远程不需要密码
+#   decode_responses: true
+#   db: 9
+
+stun:
+  server: ['stun:172.18.156.41:3478', 'stun:120.24.252.95:3478']
+  portRangeBegin: 52000
+  portRangeEnd: 53000
+
+server:
+  private_ip: 172.18.197.114
+  public_ip: 120.24.252.95
+
+
+# PRIVATE_IP=172.18.197.114
+# PUBLIC_IP=120.24.252.95
+# STUNS_SEVER="stun:172.18.156.41:3478,stun:120.24.252.95:3478"
+# GRPC_URL="192.168.0.48:3000"
+# REDIS_URL="redis://:192.168.0.47:6379/9"

+ 14 - 14
config.yaml

@@ -3,25 +3,25 @@ http:
   port: 6688
 
 
-# grpc:
-#   url: '221.4.210.172:23000'
 grpc:
-  url: '192.168.0.200:3000'
-
-# redis:
-#   port: 26379
-#   host: '221.4.210.172' #远程调试需要设置bindip 为0.0.0.0 并且设置密码
-#   password: '' # 非远程不需要密码
-#   decode_responses: true
-#   db: 9
+  url: '221.4.210.172:23000'
+# grpc:
+#   url: '192.168.0.47:3000'
 
 redis:
-  port: 6379
-  host: '192.168.0.47' #远程调试需要设置bindip 为0.0.0.0 并且设置密码
+  port: 26379
+  host: '221.4.210.172' #远程调试需要设置bindip 为0.0.0.0 并且设置密码
   password: '' # 非远程不需要密码
   decode_responses: true
   db: 9
 
+# redis:
+#   port: 6379
+#   host: '192.168.0.47' #远程调试需要设置bindip 为0.0.0.0 并且设置密码
+#   password: '' # 非远程不需要密码
+#   decode_responses: true
+#   db: 9
+
 stun:
   server: ['stun:172.18.156.41:3478', 'stun:120.24.252.95:3478']
   portRangeBegin: 52000
@@ -31,9 +31,9 @@ server:
   private_ip: 172.18.197.114
   public_ip: 120.24.252.95
 
-  
+
 # PRIVATE_IP=172.18.197.114
 # PUBLIC_IP=120.24.252.95
 # STUNS_SEVER="stun:172.18.156.41:3478,stun:120.24.252.95:3478"
 # GRPC_URL="192.168.0.48:3000"
-# REDIS_URL="redis://:192.168.0.47:6379/9"
+# REDIS_URL="redis://:192.168.0.47:6379/9"

+ 38 - 26
src/scene/scene.service.ts

@@ -142,7 +142,6 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
   async rotate(request: RotateRequest) {
     try {
-
       const reply = this.sceneGrpcService.rotate(request);
       if (!this.onSteaming) {
         const redisMeta = await this.cacheService.rpop(
@@ -157,28 +156,28 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
             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: 1,
-              };
-              this.streamService.pushFrameToSteam(stream);
+              // 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);
             }
           }
         }
@@ -248,13 +247,13 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
   }
   updateStatus() {
     const reply = {
-      data: { action_type: 1009, echo_msg: { echoMsg: '1652857098550' } },
+      data: { action_type: 1009, echo_msg: { echoMsg: Date.now() } },
       track: false,
     };
     this.streamService.pushNormalDataToStream(reply);
   }
 
-  updateUserStatus() {
+  async updateUserStatus() {
     const reply = {
       actionType: 1024,
       pointType: 100,
@@ -326,7 +325,20 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       code: 0,
       msg: '',
     };
-    this.streamService.pushNormalDataToStream(reply);
+    const redisMeta = await this.cacheService.rpop(
+      `updateFrameMetadata:${this.user_id}`,
+    );
+    //TODO 接入redis数据
+    console.log('redisMeta', redisMeta);
+    if (redisMeta && redisMeta.length > 0) {
+      const meta = JSON.parse(redisMeta);
+      'mediaSrc' in meta && delete meta.mediaSrc;
+      meta.action_type = 1024;
+      this.streamService.pushNormalDataToStream(meta);
+    } else {
+      this.streamService.pushNormalDataToStream(reply);
+    }
+    // this.streamService.pushNormalDataToStream(reply);
   }
   handleStartCountingFrame() {
     this._frameInteval = setInterval(async () => {

+ 1 - 1
src/scene/stream/stream.service.ts

@@ -49,7 +49,7 @@ export class StreamService {
       // 16 bit slot
       statusPack.setUint16(6, this.block);
       statusPack.setUint16(8, frame);
-      statusPack.setUint16(10, 1);
+      statusPack.setUint16(10, 255);
       statusPack.setUint16(24, 0);
       statusPack.setUint16(26, 0);