Commit bf10cc1b355acbf247fae16ee31abad7046298d6

Authored by 648540858
Committed by GitHub
2 parents e752dbd1 ba3c38d7

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

修复device_channel的Id改变带来的tree查询bug
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
... ... @@ -225,7 +225,7 @@ public class SIPRequestHeaderProvider {
225 225 return request;
226 226 }
227 227  
228   - public Request createInfoRequest(Device device, StreamInfo streamInfo, String content, Long cseq)
  228 + public Request createInfoRequest(Device device, StreamInfo streamInfo, String content)
229 229 throws PeerUnavailableException, ParseException, InvalidArgumentException {
230 230 Request request = null;
231 231 if (streamInfo == null) return null;
... ... @@ -255,9 +255,8 @@ public class SIPRequestHeaderProvider {
255 255  
256 256 // Forwards
257 257 MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
258   - if (cseq == null) {
259   - cseq = redisCatchStorage.getCSEQ(Request.INFO);
260   - }
  258 +
  259 + cseq = redisCatchStorage.getCSEQ(Request.INVITE);
261 260 // ceq
262 261 CSeqHeader cSeqHeader = sipFactory.createHeaderFactory()
263 262 .createCSeqHeader(cseq, Request.INFO);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
... ... @@ -1620,7 +1620,7 @@ public class SIPCommander implements ISIPCommander {
1620 1620 content.append("PAUSE RTSP/1.0\r\n");
1621 1621 content.append("CSeq: " + cseq + "\r\n");
1622 1622 content.append("PauseTime: now\r\n");
1623   - Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq);
  1623 + Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
1624 1624 if (request == null) {
1625 1625 return;
1626 1626 }
... ... @@ -1651,7 +1651,7 @@ public class SIPCommander implements ISIPCommander {
1651 1651 content.append("PLAY RTSP/1.0\r\n");
1652 1652 content.append("CSeq: " + cseq + "\r\n");
1653 1653 content.append("Range: npt=now-\r\n");
1654   - Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq);
  1654 + Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
1655 1655 if (request == null) return;
1656 1656 logger.info(request.toString());
1657 1657 ClientTransaction clientTransaction = null;
... ... @@ -1680,7 +1680,7 @@ public class SIPCommander implements ISIPCommander {
1680 1680 content.append("CSeq: " + cseq + "\r\n");
1681 1681 content.append("Range: npt=" + Math.abs(seekTime) + "-\r\n");
1682 1682  
1683   - Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq);
  1683 + Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
1684 1684 if (request == null) return;
1685 1685 logger.info(request.toString());
1686 1686 ClientTransaction clientTransaction = null;
... ... @@ -1708,7 +1708,7 @@ public class SIPCommander implements ISIPCommander {
1708 1708 content.append("PLAY RTSP/1.0\r\n");
1709 1709 content.append("CSeq: " + cseq + "\r\n");
1710 1710 content.append("Scale: " + String.format("%.1f",speed) + "\r\n");
1711   - Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq);
  1711 + Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
1712 1712 if (request == null) return;
1713 1713 logger.info(request.toString());
1714 1714 ClientTransaction clientTransaction = null;
... ...
src/main/java/com/genersoft/iot/vmp/utils/node/BaseNode.java
... ... @@ -16,7 +16,7 @@ public class BaseNode<T> implements INode<T> {
16 16 /**
17 17 * 主键ID
18 18 */
19   - protected int id;
  19 + protected String channelId;
20 20  
21 21 /**
22 22 * 父节点ID
... ... @@ -50,12 +50,8 @@ public class BaseNode<T> implements INode<T> {
50 50 }
51 51  
52 52 @Override
53   - public int getId() {
54   - return id;
55   - }
56   -
57   - public void setId(int id) {
58   - this.id = id;
  53 + public String getChannelId() {
  54 + return channelId;
59 55 }
60 56  
61 57 @Override
... ... @@ -63,10 +59,6 @@ public class BaseNode<T> implements INode<T> {
63 59 return parentId;
64 60 }
65 61  
66   - public void setParentId(String parentId) {
67   - this.parentId = parentId;
68   - }
69   -
70 62 @Override
71 63 public List<T> getChildren() {
72 64 return children;
... ...
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNode.java
... ... @@ -15,8 +15,8 @@ public class ForestNode extends BaseNode&lt;ForestNode&gt; {
15 15 */
16 16 private Object content;
17 17  
18   - public ForestNode(int id, String parentId, Object content) {
19   - this.id = id;
  18 + public ForestNode(String id, String parentId, Object content) {
  19 + this.channelId = id;
20 20 this.parentId = parentId;
21 21 this.content = content;
22 22 }
... ...
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeManager.java
... ... @@ -17,15 +17,15 @@ public class ForestNodeManager&lt;T extends INode&lt;T&gt;&gt; {
17 17 /**
18 18 * 森林的所有节点
19 19 */
20   - private final ImmutableMap<Integer, T> nodeMap;
  20 + private final ImmutableMap<String, T> nodeMap;
21 21  
22 22 /**
23 23 * 森林的父节点ID
24 24 */
25   - private final Map<Integer, Object> parentIdMap = Maps.newHashMap();
  25 + private final Map<String, Object> parentIdMap = Maps.newHashMap();
26 26  
27 27 public ForestNodeManager(List<T> nodes) {
28   - nodeMap = Maps.uniqueIndex(nodes, INode::getId);
  28 + nodeMap = Maps.uniqueIndex(nodes, INode::getChannelId);
29 29 }
30 30  
31 31 /**
... ... @@ -46,7 +46,7 @@ public class ForestNodeManager&lt;T extends INode&lt;T&gt;&gt; {
46 46 *
47 47 * @param parentId 父节点ID
48 48 */
49   - public void addParentId(int parentId) {
  49 + public void addParentId(String parentId) {
50 50 parentIdMap.put(parentId, "");
51 51 }
52 52  
... ... @@ -58,7 +58,7 @@ public class ForestNodeManager&lt;T extends INode&lt;T&gt;&gt; {
58 58 public List<T> getRoot() {
59 59 List<T> roots = new ArrayList<>();
60 60 nodeMap.forEach((key, node) -> {
61   - if (node.getParentId() == null || parentIdMap.containsKey(node.getId())) {
  61 + if (node.getParentId() == null || parentIdMap.containsKey(node.getChannelId())) {
62 62 roots.add(node);
63 63 }
64 64 });
... ...
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeMerger.java
... ... @@ -25,7 +25,7 @@ public class ForestNodeMerger {
25 25 if (node != null) {
26 26 node.getChildren().add(forestNode);
27 27 } else {
28   - forestNodeManager.addParentId(forestNode.getId());
  28 + forestNodeManager.addParentId(forestNode.getChannelId());
29 29 }
30 30 }
31 31 });
... ... @@ -37,8 +37,8 @@ public class ForestNodeMerger {
37 37 items.forEach(forestNode -> {
38 38 if (forestNode.getParentId() != null) {
39 39 INode<T> node = forestNodeManager.getTreeNodeAt(forestNode.getParentId());
40   - if (CollectionUtil.contains(parentIds, forestNode.getId())){
41   - forestNodeManager.addParentId(forestNode.getId());
  40 + if (CollectionUtil.contains(parentIds, forestNode.getChannelId())){
  41 + forestNodeManager.addParentId(forestNode.getChannelId());
42 42 } else {
43 43 if (node != null){
44 44 node.getChildren().add(forestNode);
... ...
src/main/java/com/genersoft/iot/vmp/utils/node/INode.java
... ... @@ -14,7 +14,7 @@ public interface INode&lt;T&gt; extends Serializable {
14 14 *
15 15 * @return String
16 16 */
17   - int getId();
  17 + String getChannelId();
18 18  
19 19 /**
20 20 * 父主键
... ...