Browse Source

移除多余字段

pull/399/head
648540858 3 years ago
parent
commit
1c95f1b4aa
  1. 2
      DOCKERFILE
  2. 12
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java
  3. 33
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java
  4. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
  5. 17
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
  6. 10
      src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
  7. 41
      src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java

2
DOCKERFILE

@ -85,7 +85,7 @@ RUN echo '#!/bin/bash' > run.sh && \
echo 'nohup /opt/media/MediaServer -d -m 3 &' >> run.sh && \ echo 'nohup /opt/media/MediaServer -d -m 3 &' >> run.sh && \
echo 'cd /opt/wvp' >> run.sh && \ echo 'cd /opt/wvp' >> run.sh && \
echo 'if [${WVP_CONFIG}]; then' >> run.sh && \ echo 'if [${WVP_CONFIG}]; then' >> run.sh && \
echo ' java -jar *.jar --spring.confi g.location=/opt/wvp/config/application.yml --media.record-assist-port=18081 ${WVP_CONFIG}' >> run.sh && \ echo ' java -jar *.jar --spring.config.location=/opt/wvp/config/application.yml --media.record-assist-port=18081 ${WVP_CONFIG}' >> run.sh && \
echo 'else' >> run.sh && \ echo 'else' >> run.sh && \
echo ' java -jar *.jar --spring.config.location=/opt/wvp/config/application.yml --media.record-assist-port=18081 --media.ip=127.0.0.1 --media.sdp-ip=${WVP_IP} --sip.ip=${WVP_IP} --media.stream-ip=${WVP_IP}' >> run.sh && \ echo ' java -jar *.jar --spring.config.location=/opt/wvp/config/application.yml --media.record-assist-port=18081 --media.ip=127.0.0.1 --media.sdp-ip=${WVP_IP} --sip.ip=${WVP_IP} --media.stream-ip=${WVP_IP}' >> run.sh && \
echo 'fi' >> run.sh echo 'fi' >> run.sh

12
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java

@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.gb28181.bean;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@Component @Component
@ -34,4 +36,14 @@ public class SubscribeHolder {
public void removeMobilePositionSubscribe(String platformId) { public void removeMobilePositionSubscribe(String platformId) {
mobilePositionMap.remove(platformId); mobilePositionMap.remove(platformId);
} }
public List<String> getAllCatalogSubscribePlatform() {
List<String> platforms = new ArrayList<>();
if(catalogMap.size() > 0) {
for (String key : catalogMap.keySet()) {
platforms.add(catalogMap.get(key).getId());
}
}
return platforms;
}
} }

33
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java

@ -14,17 +14,11 @@ public class SubscribeInfo {
public SubscribeInfo(RequestEvent evt, String id) { public SubscribeInfo(RequestEvent evt, String id) {
this.id = id; this.id = id;
Request request = evt.getRequest(); Request request = evt.getRequest();
CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME);
this.callId = callIdHeader.getCallId();
FromHeader fromHeader = (FromHeader)request.getHeader(FromHeader.NAME);
this.fromTag = fromHeader.getTag();
ExpiresHeader expiresHeader = (ExpiresHeader)request.getHeader(ExpiresHeader.NAME); ExpiresHeader expiresHeader = (ExpiresHeader)request.getHeader(ExpiresHeader.NAME);
this.expires = expiresHeader.getExpires(); this.expires = expiresHeader.getExpires();
EventHeader eventHeader = (EventHeader)request.getHeader(EventHeader.NAME); EventHeader eventHeader = (EventHeader)request.getHeader(EventHeader.NAME);
this.eventId = eventHeader.getEventId(); this.eventId = eventHeader.getEventId();
this.eventType = eventHeader.getEventType(); this.eventType = eventHeader.getEventType();
ViaHeader viaHeader = (ViaHeader)request.getHeader(ViaHeader.NAME);
this.branch = viaHeader.getBranch();
this.transaction = evt.getServerTransaction(); this.transaction = evt.getServerTransaction();
this.dialog = evt.getDialog(); this.dialog = evt.getDialog();
} }
@ -34,9 +28,6 @@ public class SubscribeInfo {
private String callId; private String callId;
private String eventId; private String eventId;
private String eventType; private String eventType;
private String fromTag;
private String toTag;
private String branch;
private ServerTransaction transaction; private ServerTransaction transaction;
private Dialog dialog; private Dialog dialog;
@ -52,18 +43,6 @@ public class SubscribeInfo {
return callId; return callId;
} }
public String getFromTag() {
return fromTag;
}
public void setToTag(String toTag) {
this.toTag = toTag;
}
public String getToTag() {
return toTag;
}
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
@ -76,10 +55,6 @@ public class SubscribeInfo {
this.callId = callId; this.callId = callId;
} }
public void setFromTag(String fromTag) {
this.fromTag = fromTag;
}
public String getEventId() { public String getEventId() {
return eventId; return eventId;
} }
@ -96,14 +71,6 @@ public class SubscribeInfo {
this.eventType = eventType; this.eventType = eventType;
} }
public String getBranch() {
return branch;
}
public void setBranch(String branch) {
this.branch = branch;
}
public ServerTransaction getTransaction() { public ServerTransaction getTransaction() {
return transaction; return transaction;
} }

2
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java

@ -74,7 +74,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
} }
}else { }else {
// 获取所用订阅 // 获取所用订阅
List<String> platforms = redisCatchStorage.getAllSubscribePlatform(); List<String> platforms = subscribeHolder.getAllCatalogSubscribePlatform();
if (event.getDeviceChannels() != null) { if (event.getDeviceChannels() != null) {
if (platforms.size() > 0) { if (platforms.size() > 0) {
for (DeviceChannel deviceChannel : event.getDeviceChannels()) { for (DeviceChannel deviceChannel : event.getDeviceChannels()) {

17
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java

@ -158,20 +158,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
String interval = XmlUtil.getText(rootElement, "Interval"); // GPS上报时间间隔 String interval = XmlUtil.getText(rootElement, "Interval"); // GPS上报时间间隔
dynamicTask.startCron(key, new GPSSubscribeTask(redisCatchStorage, sipCommanderForPlatform, storager, platformId, sn, key, subscribeHolder), Integer.parseInt(interval)); dynamicTask.startCron(key, new GPSSubscribeTask(redisCatchStorage, sipCommanderForPlatform, storager, platformId, sn, key, subscribeHolder), Integer.parseInt(interval));
subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo); subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo);
// redisCatchStorage.updateSubscribe(key, subscribeInfo);
}else if (subscribeInfo.getExpires() == 0) { }else if (subscribeInfo.getExpires() == 0) {
dynamicTask.stop(key); dynamicTask.stop(key);
// redisCatchStorage.delSubscribe(key);
subscribeHolder.removeMobilePositionSubscribe(platformId); subscribeHolder.removeMobilePositionSubscribe(platformId);
} }
try { try {
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId);
Response response = responseXmlAck(evt, resultXml.toString(), parentPlatform); responseXmlAck(evt, resultXml.toString(), parentPlatform);
ToHeader toHeader = (ToHeader)response.getHeader(ToHeader.NAME);
subscribeInfo.setToTag(toHeader.getTag());
redisCatchStorage.updateSubscribe(key, subscribeInfo);
} catch (SipException e) { } catch (SipException e) {
e.printStackTrace(); e.printStackTrace();
} catch (InvalidArgumentException e) { } catch (InvalidArgumentException e) {
@ -211,21 +205,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
.append("</Response>\r\n"); .append("</Response>\r\n");
if (subscribeInfo.getExpires() > 0) { if (subscribeInfo.getExpires() > 0) {
// redisCatchStorage.updateSubscribe(key, subscribeInfo);
subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo); subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo);
}else if (subscribeInfo.getExpires() == 0) { }else if (subscribeInfo.getExpires() == 0) {
// redisCatchStorage.delSubscribe(key);
subscribeHolder.removeCatalogSubscribe(platformId); subscribeHolder.removeCatalogSubscribe(platformId);
} }
try { try {
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId);
Response response = responseXmlAck(evt, resultXml.toString(), parentPlatform); responseXmlAck(evt, resultXml.toString(), parentPlatform);
ToHeader toHeader = (ToHeader)response.getHeader(ToHeader.NAME);
subscribeInfo.setToTag(toHeader.getTag());
// redisCatchStorage.updateSubscribe(key, subscribeInfo);
subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo);
} catch (SipException e) { } catch (SipException e) {
e.printStackTrace(); e.printStackTrace();
} catch (InvalidArgumentException e) { } catch (InvalidArgumentException e) {

10
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java

@ -204,18 +204,8 @@ public interface IRedisCatchStorage {
void resetAllSN(); void resetAllSN();
void updateSubscribe(String key, SubscribeInfo subscribeInfo);
SubscribeInfo getSubscribe(String key);
void delSubscribe(String key);
MediaItem getStreamInfo(String app, String streamId, String mediaServerId); MediaItem getStreamInfo(String app, String streamId, String mediaServerId);
List<SubscribeInfo> getAllSubscribe();
List<String> getAllSubscribePlatform();
void addCpuInfo(double cpuInfo); void addCpuInfo(double cpuInfo);
void addMemInfo(double memInfo); void addMemInfo(double memInfo);

41
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java

@ -490,21 +490,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
return (GPSMsgInfo)redis.get(key); return (GPSMsgInfo)redis.get(key);
} }
@Override
public void updateSubscribe(String key, SubscribeInfo subscribeInfo) {
redis.set(key, subscribeInfo, subscribeInfo.getExpires());
}
@Override
public SubscribeInfo getSubscribe(String key) {
return (SubscribeInfo)redis.get(key);
}
@Override
public void delSubscribe(String key) {
redis.del(key);
}
@Override @Override
public List<GPSMsgInfo> getAllGpsMsgInfo() { public List<GPSMsgInfo> getAllGpsMsgInfo() {
String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_*"; String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_*";
@ -535,32 +520,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
return result; return result;
} }
@Override
public List<SubscribeInfo> getAllSubscribe() {
String scanKey = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_*";
List<SubscribeInfo> result = new ArrayList<>();
List<Object> keys = redis.scan(scanKey);
for (int i = 0; i < keys.size(); i++) {
String key = (String) keys.get(i);
SubscribeInfo subscribeInfo = (SubscribeInfo) redis.get(key);
result.add(subscribeInfo);
}
return result;
}
@Override
public List<String> getAllSubscribePlatform() {
String scanKey = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_*";
List<String> result = new ArrayList<>();
List<Object> keys = redis.scan(scanKey);
for (int i = 0; i < keys.size(); i++) {
String key = (String) keys.get(i);
String platformId = key.substring(scanKey.length() - 1);
result.add(platformId);
}
return result;
}
@Override @Override
public void addCpuInfo(double cpuInfo) { public void addCpuInfo(double cpuInfo) {
String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetup.getServerId(); String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetup.getServerId();

Loading…
Cancel
Save