|
@@ -127,10 +127,20 @@ class NodeSipSession {
|
127
|
127
|
//获取设备目录
|
128
|
128
|
this.catalog = await this.getCatalog();
|
129
|
129
|
|
|
130
|
+ //console.log(this.catalog);
|
|
131
|
+ let channels = "";
|
|
132
|
+ let firstChid= "";
|
|
133
|
+ for(var key in this.catalog.devicelist){
|
|
134
|
+ let chn = this.catalog.devicelist[key];
|
|
135
|
+ channels += chn.DeviceID + "=" + chn.Name + "|";
|
|
136
|
+ if(firstChid=="") firstChid = chn.DeviceID;
|
|
137
|
+ }
|
|
138
|
+ //console.log(channels);
|
|
139
|
+
|
130
|
140
|
//ntv 提交状态,自动开启视频...
|
131
|
141
|
this.authModule = authModule;
|
132
|
142
|
this.auto_play = auto_play;
|
133
|
|
- this.authModule.status(this.id,1,(data)=>{
|
|
143
|
+ this.authModule.status(this.id,1,channels,(data)=>{
|
134
|
144
|
if(data.code==0){
|
135
|
145
|
Logger.log("设备在线状态已上报!");
|
136
|
146
|
}else{
|
|
@@ -139,17 +149,27 @@ class NodeSipSession {
|
139
|
149
|
|
140
|
150
|
});
|
141
|
151
|
|
142
|
|
- await this.startRealPlay(this.id,auto_play);
|
|
152
|
+ //ntv 尝试自动开启视频,只开启第一个通道。 TODO: 对于硬盘录像机,应可以开启多个通道
|
|
153
|
+ await this.startRealPlay(firstChid,auto_play);
|
143
|
154
|
}
|
144
|
155
|
|
145
|
156
|
//ntv add 自动发realplay消息 TODO streamServer配置项增加服务器ip选项,使摄像头可以推送到其他服务器。
|
146
|
157
|
async startRealPlay(channelId,auto_play) {
|
147
|
158
|
let config = this.config;
|
148
|
|
- if(config.GB28181.streamServer.enable && (auto_play || config.GB28181.streamServer.auto_play)){
|
149
|
|
- let host = config.GB28181.sipServer.host;
|
150
|
|
- let port = config.GB28181.streamServer.listen;
|
151
|
|
- let mode = 1;
|
152
|
|
- Logger.log(`[${channelId}] auto send real play message`);
|
|
159
|
+ if(auto_play || (config.GB28181.streamServer.enable && config.GB28181.streamServer.auto_play) ){
|
|
160
|
+ let host = config.GB28181.rtp_server.server;
|
|
161
|
+ let port = config.GB28181.rtp_server.port;
|
|
162
|
+ let mode = config.GB28181.rtp_server.mode;
|
|
163
|
+ if(host==""){
|
|
164
|
+ if(config.GB28181.streamServer.enable){
|
|
165
|
+ host = config.GB28181.sipServer.host;
|
|
166
|
+ }else{
|
|
167
|
+ Logger.log("No stream server is defined!");
|
|
168
|
+ return;
|
|
169
|
+ }
|
|
170
|
+
|
|
171
|
+ }
|
|
172
|
+ Logger.log(`[${channelId}] auto send real play message.`);
|
153
|
173
|
this.sendRealPlayMessage(channelId,host,port,mode);
|
154
|
174
|
}
|
155
|
175
|
}
|
|
@@ -166,7 +186,7 @@ class NodeSipSession {
|
166
|
186
|
this.isStarting = false;
|
167
|
187
|
context.sessions.delete(this.id);
|
168
|
188
|
|
169
|
|
- this.authModule.status(this.id,0,(data)=>{
|
|
189
|
+ this.authModule.status(this.id,0,"",(data)=>{
|
170
|
190
|
if(data.code==0){
|
171
|
191
|
Logger.log("设备离线状态已上报!");
|
172
|
192
|
}else{
|
|
@@ -768,7 +788,7 @@ class NodeSipSession {
|
768
|
788
|
|
769
|
789
|
//预览 channelId 通道国标编码
|
770
|
790
|
sendRealPlayMessage(channelId, rhost, rport, mode) {
|
771
|
|
-
|
|
791
|
+ Logger.log("Start real play " + this.id + ":" + channelId + " " + rhost + ":" + rport + " mode:" + mode);
|
772
|
792
|
return new Promise((resolve, reject) => {
|
773
|
793
|
|
774
|
794
|
let result = { result: true, message: 'OK' };
|
|
@@ -942,6 +962,7 @@ class NodeSipSession {
|
942
|
962
|
|
943
|
963
|
//停止实时预览
|
944
|
964
|
async sendStopRealPlayMessage(channelId, rhost, rport) {
|
|
965
|
+ Logger.log("Stop real play " + this.id + ":" + channelId + " " + rhost + ":" + rport);
|
945
|
966
|
return new Promise((resolve, reject) => {
|
946
|
967
|
let result = { result: false, message: '没有找到视频通道!' };
|
947
|
968
|
|