Browse Source

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

pull/439/head
648540858 3 years ago
parent
commit
4d975c21da
  1. 13
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
  2. 13
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java
  3. 23
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
  4. 11
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java
  5. 3
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
  6. 4
      src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
  7. 8
      src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
  8. 4
      src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
  9. 3
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
  10. 13
      web_src/src/components/dialog/catalogEdit.vue
  11. 3
      web_src/src/components/dialog/deviceEdit.vue

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

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

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

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

23
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java

@ -260,17 +260,18 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n"); catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\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"); catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
if (channel.getParentId() != null) { if (channel.getParentId() != null) {
catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); 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("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
catalogXml.append("<Status>" + (channel.getStatus() == 0?"OFF":"ON") + "</Status>\r\n"); catalogXml.append("<Status>" + (channel.getStatus() == 0?"OFF":"ON") + "</Status>\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("<Longitude>" + channel.getLongitude() + "</Longitude>\r\n");
catalogXml.append("<Latitude>" + channel.getLatitude() + "</Latitude>\r\n"); catalogXml.append("<Latitude>" + channel.getLatitude() + "</Latitude>\r\n");
catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n"); catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n");
@ -278,6 +279,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
catalogXml.append("<Info>\r\n"); catalogXml.append("<Info>\r\n");
catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n"); catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n");
catalogXml.append("</Info>\r\n"); catalogXml.append("</Info>\r\n");
}
catalogXml.append("</Item>\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("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n"); catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\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"); catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
if (channel.getParentId() != null) { if (channel.getParentId() != null) {
catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); 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("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\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())) { if (!"presence".equals(subscribeInfo.getEventType())) {
catalogXml.append("<Event>" + type + "</Event>\r\n"); catalogXml.append("<Event>" + type + "</Event>\r\n");
} }

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

3
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java

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

4
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java

@ -44,9 +44,9 @@ public interface IMediaServerService {
void updateVmServer(List<MediaServerItem> mediaServerItemList); 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); void closeRTPServer(String deviceId, String channelId, String ssrc);

8
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java

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

4
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

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

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

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

13
web_src/src/components/dialog/catalogEdit.vue

@ -13,11 +13,24 @@
<div id="shared" style="margin-top: 1rem;margin-right: 100px;"> <div id="shared" style="margin-top: 1rem;margin-right: 100px;">
<el-form ref="form" :rules="rules" :model="form" label-width="140px" > <el-form ref="form" :rules="rules" :model="form" label-width="140px" >
<el-form-item label="节点编号" prop="id" > <el-form-item label="节点编号" prop="id" >
<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;业务分组第111213位215例如34020000002150000001
<br/>
&emsp;&emsp;虚拟组织第111213位216例如34020000002160000001
</div>
<el-input v-model="form.id" :disabled="isEdit"></el-input> <el-input v-model="form.id" :disabled="isEdit"></el-input>
</el-tooltip>
</el-form-item> </el-form-item>
<el-form-item label="节点名称" prop="name"> <el-form-item label="节点名称" prop="name">
<el-input v-model="form.name" clearable></el-input> <el-input v-model="form.name" clearable></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<div style="float: right;"> <div style="float: right;">
<el-button type="primary" @click="onSubmit" >确认</el-button> <el-button type="primary" @click="onSubmit" >确认</el-button>

3
web_src/src/components/dialog/deviceEdit.vue

@ -45,6 +45,9 @@
<el-form-item v-if="form.subscribeCycleForMobilePosition > 0" label="移动位置报送间隔" prop="subscribeCycleForCatalog" > <el-form-item v-if="form.subscribeCycleForMobilePosition > 0" label="移动位置报送间隔" prop="subscribeCycleForCatalog" >
<el-input v-model="form.mobilePositionSubmissionInterval" clearable ></el-input> <el-input v-model="form.mobilePositionSubmissionInterval" clearable ></el-input>
</el-form-item> </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> <el-form-item>
<div style="float: right;"> <div style="float: right;">
<el-button type="primary" @click="onSubmit" >确认</el-button> <el-button type="primary" @click="onSubmit" >确认</el-button>

Loading…
Cancel
Save