修复ssrc释放失败问题、修正branch字段以符合国标

This commit is contained in:
lawrencehj 2021-03-14 20:54:51 +08:00
parent 12eb57f146
commit 06a510e7f3
2 changed files with 20 additions and 19 deletions

View File

@ -15,6 +15,7 @@ import org.springframework.stereotype.Component;
public class VideoStreamSessionManager {
private ConcurrentHashMap<String, ClientTransaction> sessionMap = new ConcurrentHashMap<>();
private ConcurrentHashMap<String, String> 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);
}
}

View File

@ -235,7 +235,7 @@ public class SIPCommander implements ISIPCommander {
ptzXml.append("</Control>\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("</Control>\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("</Query>\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("</Query>\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("</Query>\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("</Query>\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("</Query>\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("</Query>\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;