Browse Source

Merge pull request #399 from nikmu/wvp-28181-2.0

修复device_channel的Id改变带来的tree查询bug
pull/403/head
648540858 3 years ago
committed by GitHub
parent
commit
bf10cc1b35
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
  2. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
  3. 14
      src/main/java/com/genersoft/iot/vmp/utils/node/BaseNode.java
  4. 4
      src/main/java/com/genersoft/iot/vmp/utils/node/ForestNode.java
  5. 10
      src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeManager.java
  6. 6
      src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeMerger.java
  7. 2
      src/main/java/com/genersoft/iot/vmp/utils/node/INode.java

7
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java

@ -225,7 +225,7 @@ public class SIPRequestHeaderProvider {
return request; return request;
} }
public Request createInfoRequest(Device device, StreamInfo streamInfo, String content, Long cseq) public Request createInfoRequest(Device device, StreamInfo streamInfo, String content)
throws PeerUnavailableException, ParseException, InvalidArgumentException { throws PeerUnavailableException, ParseException, InvalidArgumentException {
Request request = null; Request request = null;
if (streamInfo == null) return null; if (streamInfo == null) return null;
@ -255,9 +255,8 @@ public class SIPRequestHeaderProvider {
// Forwards // Forwards
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
if (cseq == null) {
cseq = redisCatchStorage.getCSEQ(Request.INFO); cseq = redisCatchStorage.getCSEQ(Request.INVITE);
}
// ceq // ceq
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory() CSeqHeader cSeqHeader = sipFactory.createHeaderFactory()
.createCSeqHeader(cseq, Request.INFO); .createCSeqHeader(cseq, Request.INFO);

8
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@ -1620,7 +1620,7 @@ public class SIPCommander implements ISIPCommander {
content.append("PAUSE RTSP/1.0\r\n"); content.append("PAUSE RTSP/1.0\r\n");
content.append("CSeq: " + cseq + "\r\n"); content.append("CSeq: " + cseq + "\r\n");
content.append("PauseTime: now\r\n"); content.append("PauseTime: now\r\n");
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq); Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
if (request == null) { if (request == null) {
return; return;
} }
@ -1651,7 +1651,7 @@ public class SIPCommander implements ISIPCommander {
content.append("PLAY RTSP/1.0\r\n"); content.append("PLAY RTSP/1.0\r\n");
content.append("CSeq: " + cseq + "\r\n"); content.append("CSeq: " + cseq + "\r\n");
content.append("Range: npt=now-\r\n"); content.append("Range: npt=now-\r\n");
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq); Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
if (request == null) return; if (request == null) return;
logger.info(request.toString()); logger.info(request.toString());
ClientTransaction clientTransaction = null; ClientTransaction clientTransaction = null;
@ -1680,7 +1680,7 @@ public class SIPCommander implements ISIPCommander {
content.append("CSeq: " + cseq + "\r\n"); content.append("CSeq: " + cseq + "\r\n");
content.append("Range: npt=" + Math.abs(seekTime) + "-\r\n"); content.append("Range: npt=" + Math.abs(seekTime) + "-\r\n");
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq); Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
if (request == null) return; if (request == null) return;
logger.info(request.toString()); logger.info(request.toString());
ClientTransaction clientTransaction = null; ClientTransaction clientTransaction = null;
@ -1708,7 +1708,7 @@ public class SIPCommander implements ISIPCommander {
content.append("PLAY RTSP/1.0\r\n"); content.append("PLAY RTSP/1.0\r\n");
content.append("CSeq: " + cseq + "\r\n"); content.append("CSeq: " + cseq + "\r\n");
content.append("Scale: " + String.format("%.1f",speed) + "\r\n"); content.append("Scale: " + String.format("%.1f",speed) + "\r\n");
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq); Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
if (request == null) return; if (request == null) return;
logger.info(request.toString()); logger.info(request.toString());
ClientTransaction clientTransaction = null; ClientTransaction clientTransaction = null;

14
src/main/java/com/genersoft/iot/vmp/utils/node/BaseNode.java

@ -16,7 +16,7 @@ public class BaseNode<T> implements INode<T> {
/** /**
* 主键ID * 主键ID
*/ */
protected int id; protected String channelId;
/** /**
* 父节点ID * 父节点ID
@ -50,12 +50,8 @@ public class BaseNode<T> implements INode<T> {
} }
@Override @Override
public int getId() { public String getChannelId() {
return id; return channelId;
}
public void setId(int id) {
this.id = id;
} }
@Override @Override
@ -63,10 +59,6 @@ public class BaseNode<T> implements INode<T> {
return parentId; return parentId;
} }
public void setParentId(String parentId) {
this.parentId = parentId;
}
@Override @Override
public List<T> getChildren() { public List<T> getChildren() {
return children; return children;

4
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNode.java

@ -15,8 +15,8 @@ public class ForestNode extends BaseNode<ForestNode> {
*/ */
private Object content; private Object content;
public ForestNode(int id, String parentId, Object content) { public ForestNode(String id, String parentId, Object content) {
this.id = id; this.channelId = id;
this.parentId = parentId; this.parentId = parentId;
this.content = content; this.content = content;
} }

10
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeManager.java

@ -17,15 +17,15 @@ public class ForestNodeManager<T extends INode<T>> {
/** /**
* 森林的所有节点 * 森林的所有节点
*/ */
private final ImmutableMap<Integer, T> nodeMap; private final ImmutableMap<String, T> nodeMap;
/** /**
* 森林的父节点ID * 森林的父节点ID
*/ */
private final Map<Integer, Object> parentIdMap = Maps.newHashMap(); private final Map<String, Object> parentIdMap = Maps.newHashMap();
public ForestNodeManager(List<T> nodes) { public ForestNodeManager(List<T> nodes) {
nodeMap = Maps.uniqueIndex(nodes, INode::getId); nodeMap = Maps.uniqueIndex(nodes, INode::getChannelId);
} }
/** /**
@ -46,7 +46,7 @@ public class ForestNodeManager<T extends INode<T>> {
* *
* @param parentId 父节点ID * @param parentId 父节点ID
*/ */
public void addParentId(int parentId) { public void addParentId(String parentId) {
parentIdMap.put(parentId, ""); parentIdMap.put(parentId, "");
} }
@ -58,7 +58,7 @@ public class ForestNodeManager<T extends INode<T>> {
public List<T> getRoot() { public List<T> getRoot() {
List<T> roots = new ArrayList<>(); List<T> roots = new ArrayList<>();
nodeMap.forEach((key, node) -> { nodeMap.forEach((key, node) -> {
if (node.getParentId() == null || parentIdMap.containsKey(node.getId())) { if (node.getParentId() == null || parentIdMap.containsKey(node.getChannelId())) {
roots.add(node); roots.add(node);
} }
}); });

6
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeMerger.java

@ -25,7 +25,7 @@ public class ForestNodeMerger {
if (node != null) { if (node != null) {
node.getChildren().add(forestNode); node.getChildren().add(forestNode);
} else { } else {
forestNodeManager.addParentId(forestNode.getId()); forestNodeManager.addParentId(forestNode.getChannelId());
} }
} }
}); });
@ -37,8 +37,8 @@ public class ForestNodeMerger {
items.forEach(forestNode -> { items.forEach(forestNode -> {
if (forestNode.getParentId() != null) { if (forestNode.getParentId() != null) {
INode<T> node = forestNodeManager.getTreeNodeAt(forestNode.getParentId()); INode<T> node = forestNodeManager.getTreeNodeAt(forestNode.getParentId());
if (CollectionUtil.contains(parentIds, forestNode.getId())){ if (CollectionUtil.contains(parentIds, forestNode.getChannelId())){
forestNodeManager.addParentId(forestNode.getId()); forestNodeManager.addParentId(forestNode.getChannelId());
} else { } else {
if (node != null){ if (node != null){
node.getChildren().add(forestNode); node.getChildren().add(forestNode);

2
src/main/java/com/genersoft/iot/vmp/utils/node/INode.java

@ -14,7 +14,7 @@ public interface INode<T> extends Serializable {
* *
* @return String * @return String
*/ */
int getId(); String getChannelId();
/** /**
* 父主键 * 父主键

Loading…
Cancel
Save