From 3962352ec32137e9561c2ba16e192f1f7fdebade Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 15 十二月 2021 11:07:59 +0800
Subject: [PATCH] 优化zlm状态变化事件代码
---
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
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 e06a7fc..dc0996a 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
@@ -18,7 +18,6 @@
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;
@@ -1163,7 +1162,7 @@
@Override
public boolean catalogQuery(Device device, SipSubscribe.Event errorEvent) {
// 娓呯┖閫氶亾
- storager.cleanChannelsForDevice(device.getDeviceId());
+// storager.cleanChannelsForDevice(device.getDeviceId());
try {
StringBuffer catalogXml = new StringBuffer(200);
catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
@@ -1196,14 +1195,15 @@
* @param endTime 缁撴潫鏃堕棿,鏍煎紡瑕佹眰锛歽yyy-MM-dd HH:mm:ss
*/
@Override
- public boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, SipSubscribe.Event errorEvent) {
-
+ public boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, SipSubscribe.Event errorEvent) {
+
+
try {
StringBuffer recordInfoXml = new StringBuffer(200);
recordInfoXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
recordInfoXml.append("<Query>\r\n");
recordInfoXml.append("<CmdType>RecordInfo</CmdType>\r\n");
- recordInfoXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
+ recordInfoXml.append("<SN>" + sn + "</SN>\r\n");
recordInfoXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
recordInfoXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "</StartTime>\r\n");
recordInfoXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "</EndTime>\r\n");
@@ -1552,12 +1552,12 @@
@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())) {
@@ -1580,11 +1580,12 @@
@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())) {
@@ -1606,12 +1607,13 @@
@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())) {
@@ -1633,11 +1635,12 @@
@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())) {
--
Gitblit v1.8.0