Переглянути джерело

修改标识,配置文件从文件读取

ntv-wangjian 3 роки тому
джерело
коміт
67a66b73a0
3 змінених файлів з 53 додано та 16 видалено
  1. 8
    4
      stream/server.js
  2. 13
    0
      stream/session.js
  3. 32
    12
      vag.js

+ 8
- 4
stream/server.js Переглянути файл

@@ -68,10 +68,12 @@ class NodeGB28181StreamServer {
68 68
 
69 69
         //停止播放,关闭推流客户端
70 70
         context.nodeEvent.on('stopPlayed', (ssrc) => {
71
-            if (context.publishers.has(ssrc)) {
72
-                let rtmpClient = context.publishers.get(ssrc);
71
+            //ntv mod 转换成string,否者检索不到,ssrc传入的时number
72
+            var key = '' + ssrc;
73
+            if (context.publishers.has(key)) {
74
+                let rtmpClient = context.publishers.get(key);
73 75
                 rtmpClient.stop();
74
-                context.publishers.delete(ssrc);
76
+                context.publishers.delete(key);
75 77
             }
76 78
         });
77 79
     }
@@ -188,7 +190,9 @@ class NodeGB28181StreamServer {
188 190
                 context.nodeEvent.emit('rtmpClientClose', ssrc);
189 191
             });
190 192
 
191
-            context.publishers.set(ssrc, rtmpClient);
193
+            //ntv 同时使用string key
194
+            var key = '' + ssrc;
195
+            context.publishers.set(key, rtmpClient);
192 196
         }
193 197
 
194 198
         let rtmpClinet = context.publishers.get(ssrc);

+ 13
- 0
stream/session.js Переглянути файл

@@ -11,6 +11,9 @@ class NodeGB28181StreamServerSession {
11 11
         this.ip = socket.remoteAddress;
12 12
         this.TAG = 'GB28181_TCP_Passive';
13 13
 
14
+        //ntv add
15
+        this.ssrc=null;
16
+
14 17
         context.sessions.set(this.id, this);
15 18
     }
16 19
 
@@ -44,6 +47,12 @@ class NodeGB28181StreamServerSession {
44 47
 
45 48
             Logger.log(`[${this.TAG} disconnect] id=${this.id}`);
46 49
 
50
+            //ntv add 
51
+            if(this.ssrc){
52
+                console.log("emit stopPlayed ..........................=",this.ssrc);
53
+                context.nodeEvent.emit('stopPlayed',this.ssrc);
54
+            }
55
+
47 56
             context.sessions.delete(this.id);
48 57
         }
49 58
     }
@@ -121,6 +130,10 @@ class NodeGB28181StreamServerSession {
121 130
 
122 131
 		//ntv-wangjian
123 132
         //Logger.log(`[${ssrc}] RTP Packet: timestamp:${timestamp} seqNumber:${seqNumber} length:${playload.length} `);
133
+        //ntv add
134
+        if(!that.ssrc){
135
+            that.ssrc = ssrc;
136
+        }
124 137
 
125 138
         switch (playloadType) {
126 139
             //PS封装

+ 32
- 12
vag.js Переглянути файл

@@ -1,18 +1,38 @@
1 1
 const NodeAPIServer = require('./api/server');
2 2
 const NodeGB28181Server = require('./GB28181Server');
3 3
 const NodeStreamServer = require('./stream/server');
4
-const config = require('./config');
4
+//const config = require('./config');
5
+const { json } = require('body-parser');
6
+const conf_file = '/etc/noveltv/mserver/conf/sipserver.conf';
5 7
 
6
-//信令服务
7
-let vagSignalService = new NodeGB28181Server(config);
8
-vagSignalService.run();
8
+const fs = require('fs');
9
+try {
10
+  console.log("---------------------------------");
11
+  console.log("Starting gb28181 sip server...");
12
+  console.log("Version=1.1.0");
13
+  console.log("Powered by BEIJING NOVEL-TV Inc.");
14
+  console.log("http://www.ruiboyun.com");
15
+  console.log("---------------------------------");
16
+  
17
+  const data = fs.readFileSync(conf_file, 'utf-8');
18
+  var config = JSON.parse(data);
19
+  if(!config){
20
+      console.log("解析配置文件失败!");
21
+  }else{
22
+        //信令服务
23
+        let vagSignalService = new NodeGB28181Server(config);
24
+        vagSignalService.run();
9 25
 
10
-//网关API服务
11
-let vagAPIService = new NodeAPIServer(config);
12
-vagAPIService.run();
26
+        //网关API服务
27
+        let vagAPIService = new NodeAPIServer(config);
28
+        vagAPIService.run();
13 29
 
14
-//流媒体服务
15
-if (config.GB28181.streamServer.enable) {
16
-    let vagStreamService = new NodeStreamServer(config);
17
-    vagStreamService.run();
18
-}
30
+        //流媒体服务
31
+        if (config.GB28181.streamServer.enable) {
32
+            let vagStreamService = new NodeStreamServer(config);
33
+            vagStreamService.run();
34
+        }
35
+  }
36
+} catch(e) {
37
+    console.log("读取配置文件失败!");
38
+}

Завантаження…
Відмінити
Зберегти