Browse Source

优化国标级联目录推送,支持zlm新特性ssrc校验

648540858 3 years ago
parent
commit
4d975c21da

+ 13 - 0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java

@@ -129,6 +129,11 @@ public class Device {
 	 */
 	private int subscribeCycleForAlarm;
 
+	/**
+	 * 是否开启ssrc校验,默认关闭,开启可以防止串流
+	 */
+	private boolean ssrcCheck;
+
 
 	public String getDeviceId() {
 		return deviceId;
@@ -321,4 +326,12 @@ public class Device {
 	public void setSubscribeCycleForAlarm(int subscribeCycleForAlarm) {
 		this.subscribeCycleForAlarm = subscribeCycleForAlarm;
 	}
+
+	public boolean isSsrcCheck() {
+		return ssrcCheck;
+	}
+
+	public void setSsrcCheck(boolean ssrcCheck) {
+		this.ssrcCheck = ssrcCheck;
+	}
 }

+ 13 - 0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java

@@ -169,6 +169,11 @@ public class DeviceChannel {
 	 */
 	private boolean hasAudio;
 
+	/**
+	 * 标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
+	 */
+	private int channelType;
+
 	public int getId() {
 		return id;
 	}
@@ -441,4 +446,12 @@ public class DeviceChannel {
 	public void setUpdateTime(String updateTime) {
 		this.updateTime = updateTime;
 	}
+
+	public int getChannelType() {
+		return channelType;
+	}
+
+	public void setChannelType(int channelType) {
+		this.channelType = channelType;
+	}
 }

+ 21 - 16
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java

@@ -260,24 +260,27 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
                 catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
                 catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
                 catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
-                catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
-                catalogXml.append("<Owner>" + channel.getOwner() + "</Owner>\r\n");
-                catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
-                catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
                 catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
                 if (channel.getParentId() != null) {
                     catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
                 }
-                catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
                 catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
                 catalogXml.append("<Status>" + (channel.getStatus() == 0?"OFF":"ON") + "</Status>\r\n");
-                catalogXml.append("<Longitude>" + channel.getLongitude() + "</Longitude>\r\n");
-                catalogXml.append("<Latitude>" + channel.getLatitude() + "</Latitude>\r\n");
-                catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n");
-                catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n");
-                catalogXml.append("<Info>\r\n");
-                catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n");
-                catalogXml.append("</Info>\r\n");
+                catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
+                if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下字段
+                    catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
+                    catalogXml.append("<Owner>" + channel.getOwner() + "</Owner>\r\n");
+                    catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
+                    catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
+                    catalogXml.append("<Longitude>" + channel.getLongitude() + "</Longitude>\r\n");
+                    catalogXml.append("<Latitude>" + channel.getLatitude() + "</Latitude>\r\n");
+                    catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n");
+                    catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n");
+                    catalogXml.append("<Info>\r\n");
+                    catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n");
+                    catalogXml.append("</Info>\r\n");
+                }
+
                 catalogXml.append("</Item>\r\n");
             }
         }
@@ -539,10 +542,6 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
                 catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
                 catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
                 catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
-                catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
-                catalogXml.append("<Owner>0</Owner>\r\n");
-                catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n");
-                catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
                 catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
                 if (channel.getParentId() != null) {
                     catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
@@ -550,6 +549,12 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
                 catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
                 catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
                 catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
+                if (channel.getChannelType() == 2) {  // 业务分组/虚拟组织/行政区划 不设置以下属性
+                    catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
+                    catalogXml.append("<Owner>0</Owner>\r\n");
+                    catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n");
+                    catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
+                }
                 if (!"presence".equals(subscribeInfo.getEventType())) {
                     catalogXml.append("<Event>" + type + "</Event>\r\n");
                 }

+ 6 - 5
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java

@@ -83,10 +83,10 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
                         catalog.setParentId(parentPlatform.getDeviceGBId());
                     }
                     DeviceChannel deviceChannel = new DeviceChannel();
+                    // 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
+                    deviceChannel.setChannelType(2);
                     deviceChannel.setChannelId(catalog.getId());
                     deviceChannel.setName(catalog.getName());
-                    deviceChannel.setLongitude(0.0);
-                    deviceChannel.setLatitude(0.0);
                     deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
                     deviceChannel.setManufacture("wvp-pro");
                     deviceChannel.setStatus(1);
@@ -94,9 +94,6 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
                     deviceChannel.setParentId(catalog.getParentId());
                     deviceChannel.setRegisterWay(1);
                     deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
-                    deviceChannel.setModel("live");
-                    deviceChannel.setOwner("wvp-pro");
-                    deviceChannel.setSecrecy("0");
                     allChannels.add(deviceChannel);
                 }
             }
@@ -107,6 +104,8 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
                         channel.setCatalogId(parentPlatform.getDeviceGBId());
                     }
                     DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId());
+                    // 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
+                    deviceChannel.setChannelType(0);
                     deviceChannel.setParental(0);
                     deviceChannel.setParentId(channel.getCatalogId());
                     deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0, 6));
@@ -120,6 +119,8 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
                         gbStream.setCatalogId(null);
                     }
                     DeviceChannel deviceChannel = new DeviceChannel();
+                    // 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
+                    deviceChannel.setChannelType(1);
                     deviceChannel.setChannelId(gbStream.getGbId());
                     deviceChannel.setName(gbStream.getName());
                     deviceChannel.setLongitude(gbStream.getLongitude());

+ 2 - 1
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java

@@ -81,7 +81,7 @@ public class ZLMRTPServerFactory {
         return result;
     }
 
-    public int createRTPServer(MediaServerItem mediaServerItem, String streamId) {
+    public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc) {
         int result = -1;
         // 查询此rtp server 是否已经存在
         JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId);
@@ -94,6 +94,7 @@ public class ZLMRTPServerFactory {
         param.put("enable_tcp", 1);
         param.put("stream_id", streamId);
         param.put("port", 0);
+        param.put("ssrc", ssrc);
         JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param);
 
         if (openRtpServerResultJson != null) {

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java

@@ -44,9 +44,9 @@ public interface IMediaServerService {
 
     void updateVmServer(List<MediaServerItem>  mediaServerItemList);
 
-    SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId);
+    SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean ssrcCheck);
 
-    SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback);
+    SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean ssrcCheck, boolean isPlayback);
 
     void closeRTPServer(String deviceId, String channelId, String ssrc);
 

+ 4 - 4
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java

@@ -117,12 +117,12 @@ public class MediaServerServiceImpl implements IMediaServerService {
     }
 
     @Override
-    public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId) {
-        return openRTPServer(mediaServerItem, streamId, false);
+    public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean ssrcCheck) {
+        return openRTPServer(mediaServerItem, streamId, ssrcCheck,false);
     }
 
     @Override
-    public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback) {
+    public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean ssrcCheck, boolean isPlayback) {
         if (mediaServerItem == null || mediaServerItem.getId() == null) {
             return null;
         }
@@ -146,7 +146,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
             }
             int rtpServerPort = mediaServerItem.getRtpProxyPort();
             if (mediaServerItem.isRtpEnable()) {
-                rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId);
+                rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0);
             }
             redisUtil.set(key, mediaServerItem);
             return new SSRCInfo(rtpServerPort, ssrc, streamId);

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

@@ -188,7 +188,7 @@ public class PlayServiceImpl implements IPlayService {
             if (mediaServerItem.isRtpEnable()) {
                 streamId = String.format("%s_%s", device.getDeviceId(), channelId);
             }
-            SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId);
+            SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck());
             play(mediaServerItem, ssrcInfo, device, channelId, (mediaServerItemInUse, response)->{
                 if (hookEvent != null) {
                     hookEvent.response(mediaServerItem, response);
@@ -232,7 +232,7 @@ public class PlayServiceImpl implements IPlayService {
             streamId = String.format("%s_%s", device.getDeviceId(), channelId);
         }
         if (ssrcInfo == null) {
-            ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId);
+            ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck());
         }
 
         // 超时处理

+ 3 - 0
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java

@@ -37,6 +37,7 @@ public interface DeviceMapper {
                 "subscribeCycleForMobilePosition," +
                 "mobilePositionSubmissionInterval," +
                 "subscribeCycleForAlarm," +
+                "ssrcCheck," +
                 "online" +
             ") VALUES (" +
                 "#{deviceId}," +
@@ -59,6 +60,7 @@ public interface DeviceMapper {
                 "#{subscribeCycleForMobilePosition}," +
                 "#{mobilePositionSubmissionInterval}," +
                 "#{subscribeCycleForAlarm}," +
+                "#{ssrcCheck}," +
                 "#{online}" +
             ")")
     int add(Device device);
@@ -84,6 +86,7 @@ public interface DeviceMapper {
                 "<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=${subscribeCycleForMobilePosition}</if>" +
                 "<if test=\"mobilePositionSubmissionInterval != null\">, mobilePositionSubmissionInterval=${mobilePositionSubmissionInterval}</if>" +
                 "<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=${subscribeCycleForAlarm}</if>" +
+                "<if test=\"ssrcCheck != null\">, ssrcCheck=${ssrcCheck}</if>" +
                 "WHERE deviceId='${deviceId}'"+
             " </script>"})
     int update(Device device);

+ 14 - 1
web_src/src/components/dialog/catalogEdit.vue

@@ -13,11 +13,24 @@
       <div id="shared" style="margin-top: 1rem;margin-right: 100px;">
         <el-form ref="form" :rules="rules" :model="form" label-width="140px" >
           <el-form-item label="节点编号" prop="id" >
-            <el-input v-model="form.id" :disabled="isEdit"></el-input>
+            <el-tooltip class="item" effect="dark" content="" placement="top-start">
+              <div slot="content">
+                建议的类型:
+                <br/>
+                &emsp;&emsp;行政区划(可选2位/4位/6位/8位/10位数字,例如:130432,表示河北省邯郸市广平县)
+                <br/>
+                &emsp;&emsp;业务分组(第11、12、13位215,例如:34020000002150000001)
+                <br/>
+                &emsp;&emsp;虚拟组织(第11、12、13位216,例如:34020000002160000001)
+              </div>
+              <el-input v-model="form.id" :disabled="isEdit"></el-input>
+            </el-tooltip>
           </el-form-item>
           <el-form-item label="节点名称" prop="name">
             <el-input v-model="form.name" clearable></el-input>
           </el-form-item>
+
+
           <el-form-item>
             <div style="float: right;">
               <el-button type="primary" @click="onSubmit" >确认</el-button>

+ 3 - 0
web_src/src/components/dialog/deviceEdit.vue

@@ -45,6 +45,9 @@
           <el-form-item v-if="form.subscribeCycleForMobilePosition > 0" label="移动位置报送间隔" prop="subscribeCycleForCatalog" >
             <el-input v-model="form.mobilePositionSubmissionInterval" clearable ></el-input>
           </el-form-item>
+          <el-form-item label="其他选项">
+            <el-checkbox label="SSRC校验" v-model="form.ssrcCheck" style="float: left"></el-checkbox>
+          </el-form-item>
           <el-form-item>
             <div style="float: right;">
               <el-button type="primary" @click="onSubmit" >确认</el-button>