优化info消息的cseq计数
This commit is contained in:
@@ -14,7 +14,7 @@ import javax.sip.message.Request;
|
||||
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.session.InfoCseqCache;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -35,6 +35,9 @@ public class SIPRequestHeaderProvider {
|
||||
@Autowired
|
||||
private SipFactory sipFactory;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private VideoStreamSessionManager streamSession;
|
||||
|
||||
@@ -195,6 +198,7 @@ public class SIPRequestHeaderProvider {
|
||||
|
||||
// Forwards
|
||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
// ceq
|
||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.SUBSCRIBE);
|
||||
|
||||
@@ -218,7 +222,7 @@ public class SIPRequestHeaderProvider {
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createInfoRequest(Device device, StreamInfo streamInfo, String content)
|
||||
public Request createInfoRequest(Device device, StreamInfo streamInfo, String content, Long cseq)
|
||||
throws PeerUnavailableException, ParseException, InvalidArgumentException {
|
||||
Request request = null;
|
||||
Dialog dialog = streamSession.getDialog(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
||||
@@ -247,10 +251,12 @@ public class SIPRequestHeaderProvider {
|
||||
|
||||
// Forwards
|
||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
if (cseq == null) {
|
||||
cseq = redisCatchStorage.getCSEQ(Request.INFO);
|
||||
}
|
||||
// ceq
|
||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory()
|
||||
.createCSeqHeader(InfoCseqCache.CSEQCACHE.get(streamInfo.getStreamId()), Request.INFO);
|
||||
.createCSeqHeader(cseq, Request.INFO);
|
||||
|
||||
request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,
|
||||
fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.session.InfoCseqCache;
|
||||
import gov.nist.javax.sip.SipProviderImpl;
|
||||
import gov.nist.javax.sip.SipStackImpl;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
@@ -1553,12 +1552,12 @@ public class SIPCommander implements ISIPCommander {
|
||||
@Override
|
||||
public void playPauseCmd(Device device, StreamInfo streamInfo) {
|
||||
try {
|
||||
|
||||
Long cseq = redisCatchStorage.getCSEQ(Request.INFO);
|
||||
StringBuffer content = new StringBuffer(200);
|
||||
content.append("PAUSE RTSP/1.0\r\n");
|
||||
content.append("CSeq: " + InfoCseqCache.CSEQCACHE.get(streamInfo.getStreamId()) + "\r\n");
|
||||
content.append("CSeq: " + cseq + "\r\n");
|
||||
content.append("PauseTime: now\r\n");
|
||||
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
|
||||
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq);
|
||||
logger.info(request.toString());
|
||||
ClientTransaction clientTransaction = null;
|
||||
if ("TCP".equals(device.getTransport())) {
|
||||
@@ -1581,11 +1580,12 @@ public class SIPCommander implements ISIPCommander {
|
||||
@Override
|
||||
public void playResumeCmd(Device device, StreamInfo streamInfo) {
|
||||
try {
|
||||
Long cseq = redisCatchStorage.getCSEQ(Request.INFO);
|
||||
StringBuffer content = new StringBuffer(200);
|
||||
content.append("PLAY RTSP/1.0\r\n");
|
||||
content.append("CSeq: " + InfoCseqCache.CSEQCACHE.get(streamInfo.getStreamId()) + "\r\n");
|
||||
content.append("CSeq: " + cseq + "\r\n");
|
||||
content.append("Range: npt=now-\r\n");
|
||||
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
|
||||
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq);
|
||||
logger.info(request.toString());
|
||||
ClientTransaction clientTransaction = null;
|
||||
if ("TCP".equals(device.getTransport())) {
|
||||
@@ -1607,12 +1607,13 @@ public class SIPCommander implements ISIPCommander {
|
||||
@Override
|
||||
public void playSeekCmd(Device device, StreamInfo streamInfo, long seekTime) {
|
||||
try {
|
||||
Long cseq = redisCatchStorage.getCSEQ(Request.INFO);
|
||||
StringBuffer content = new StringBuffer(200);
|
||||
content.append("PLAY RTSP/1.0\r\n");
|
||||
content.append("CSeq: " + InfoCseqCache.CSEQCACHE.get(streamInfo.getStreamId()) + "\r\n");
|
||||
content.append("CSeq: " + cseq + "\r\n");
|
||||
content.append("Range: npt=" + Math.abs(seekTime) + "-\r\n");
|
||||
|
||||
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
|
||||
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq);
|
||||
logger.info(request.toString());
|
||||
ClientTransaction clientTransaction = null;
|
||||
if ("TCP".equals(device.getTransport())) {
|
||||
@@ -1634,11 +1635,12 @@ public class SIPCommander implements ISIPCommander {
|
||||
@Override
|
||||
public void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) {
|
||||
try {
|
||||
Long cseq = redisCatchStorage.getCSEQ(Request.INFO);
|
||||
StringBuffer content = new StringBuffer(200);
|
||||
content.append("PLAY RTSP/1.0\r\n");
|
||||
content.append("CSeq: " + InfoCseqCache.CSEQCACHE.get(streamInfo.getStreamId()) + "\r\n");
|
||||
content.append("CSeq: " + cseq + "\r\n");
|
||||
content.append("Scale: " + String.format("%.1f",speed) + "\r\n");
|
||||
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
|
||||
Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString(), cseq);
|
||||
logger.info(request.toString());
|
||||
ClientTransaction clientTransaction = null;
|
||||
if ("TCP".equals(device.getTransport())) {
|
||||
|
||||
Reference in New Issue
Block a user