From 06a510e7f3025a7c9de8c76359750dd6e9a79080 Mon Sep 17 00:00:00 2001 From: lawrencehj <1934378145@qq.com> Date: Sun, 14 Mar 2021 20:54:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dssrc=E9=87=8A=E6=94=BE?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98=E3=80=81=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?branch=E5=AD=97=E6=AE=B5=E4=BB=A5=E7=AC=A6=E5=90=88=E5=9B=BD?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../session/VideoStreamSessionManager.java | 17 ++++++++------ .../transmit/cmd/impl/SIPCommander.java | 22 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java index c69faf96..65e1e5f6 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java @@ -15,6 +15,7 @@ import org.springframework.stereotype.Component; public class VideoStreamSessionManager { private ConcurrentHashMap sessionMap = new ConcurrentHashMap<>(); + private ConcurrentHashMap ssrcMap = new ConcurrentHashMap<>(); public String createPlaySsrc(){ return SsrcUtil.getPlaySsrc(); @@ -24,16 +25,18 @@ public class VideoStreamSessionManager { return SsrcUtil.getPlayBackSsrc(); } - public void put(String ssrc,ClientTransaction transaction){ - sessionMap.put(ssrc, transaction); + public void put(String streamId,String ssrc,ClientTransaction transaction){ + sessionMap.put(streamId, transaction); + ssrcMap.put(streamId, ssrc); } - public ClientTransaction get(String ssrc){ - return sessionMap.get(ssrc); + public ClientTransaction get(String streamId){ + return sessionMap.get(streamId); } - public void remove(String ssrc) { - sessionMap.remove(ssrc); - SsrcUtil.releaseSsrc(ssrc); + public void remove(String streamId) { + sessionMap.remove(streamId); + SsrcUtil.releaseSsrc(ssrcMap.get(streamId)); + ssrcMap.remove(streamId); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 912189c9..a9ace7be 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -235,7 +235,7 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("\r\n"); String tm = Long.toString(System.currentTimeMillis()); - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "ViaPtzBranch", "FromPtz" + tm, null); + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null); transmitRequest(device, request); return true; @@ -272,7 +272,7 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("\r\n"); String tm = Long.toString(System.currentTimeMillis()); - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "ViaPtzBranch", "FromPtz" + tm, null); + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null); transmitRequest(device, request); return true; } catch (SipException | ParseException | InvalidArgumentException e) { @@ -387,9 +387,7 @@ public class SIPCommander implements ISIPCommander { Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "FromInvt" + tm, null, ssrc); ClientTransaction transaction = transmitRequest(device, request, errorEvent); - streamSession.put(streamId, transaction); - - + streamSession.put(streamId,ssrc, transaction); } catch ( SipException | ParseException | InvalidArgumentException e) { e.printStackTrace(); @@ -487,7 +485,7 @@ public class SIPCommander implements ISIPCommander { Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null); ClientTransaction transaction = transmitRequest(device, request, errorEvent); - streamSession.put(streamId, transaction); + streamSession.put(streamId, ssrc, transaction); } catch ( SipException | ParseException | InvalidArgumentException e) { e.printStackTrace(); @@ -893,7 +891,7 @@ public class SIPCommander implements ISIPCommander { catalogXml.append("\r\n"); String tm = Long.toString(System.currentTimeMillis()); - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "z9hG4bK-ViaDeviceInfo" + tm, "FromDev" + tm, null); + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "z9hG4bK-ViaDeviceInfo-" + tm, "FromDev" + tm, null); transmitRequest(device, request); @@ -923,7 +921,7 @@ public class SIPCommander implements ISIPCommander { catalogXml.append("\r\n"); String tm = Long.toString(System.currentTimeMillis()); - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "z9hG4bK-ViaCatalog" + tm, "FromCat" + tm, null); + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "z9hG4bK-ViaCatalog-" + tm, "FromCat" + tm, null); transmitRequest(device, request, errorEvent); } catch (SipException | ParseException | InvalidArgumentException e) { @@ -958,7 +956,7 @@ public class SIPCommander implements ISIPCommander { recordInfoXml.append("\r\n"); String tm = Long.toString(System.currentTimeMillis()); - Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), "ViaRecordInfoBranch", "fromRec" + tm, null); + Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), "z9hG4bK-ViaRecordInfo-" + tm, "fromRec" + tm, null); transmitRequest(device, request); } catch (SipException | ParseException | InvalidArgumentException e) { @@ -1101,7 +1099,7 @@ public class SIPCommander implements ISIPCommander { mobilePostitionXml.append("\r\n"); String tm = Long.toString(System.currentTimeMillis()); - Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), "viaTagPos" + tm, "fromTagPos" + tm, null); + Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), "z9hG4bK-viaPos-" + tm, "fromTagPos" + tm, null); transmitRequest(device, request, errorEvent); @@ -1134,7 +1132,7 @@ public class SIPCommander implements ISIPCommander { subscribePostitionXml.append("\r\n"); String tm = Long.toString(System.currentTimeMillis()); - Request request = headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), "viaTagPos" + tm, "fromTagPos" + tm, null, expires, "presence" ); //Position;id=" + tm.substring(tm.length() - 4)); + Request request = headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), "z9hG4bK-viaPos-" + tm, "fromTagPos" + tm, null, expires, "presence" ); //Position;id=" + tm.substring(tm.length() - 4)); transmitRequest(device, request); return true; @@ -1187,7 +1185,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("\r\n"); String tm = Long.toString(System.currentTimeMillis()); - Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), "viaTagPos" + tm, "fromTagPos" + tm, null, expires, "presence" ); + Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), "z9hG4bK-viaPos-" + tm, "fromTagPos" + tm, null, expires, "presence" ); transmitRequest(device, request); return true;