Browse Source

支持级联云台控制

pull/446/head
648540858 3 years ago
parent
commit
5ed44c3e09
  1. 5
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java
  2. 6
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
  3. 4
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
  4. 1
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
  5. 30
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java
  6. 2
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java

5
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java

@ -4,7 +4,6 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor;
import gov.nist.javax.sip.message.SIPRequest;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -14,7 +13,6 @@ import org.springframework.stereotype.Component;
import javax.sip.*; import javax.sip.*;
import javax.sip.header.CSeqHeader; import javax.sip.header.CSeqHeader;
import javax.sip.header.CallIdHeader; import javax.sip.header.CallIdHeader;
import javax.sip.header.Header;
import javax.sip.message.Response; import javax.sip.message.Response;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -36,6 +34,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
@Autowired @Autowired
private SipSubscribe sipSubscribe; private SipSubscribe sipSubscribe;
// @Autowired // @Autowired
// @Qualifier(value = "taskExecutor") // @Qualifier(value = "taskExecutor")
// private ThreadPoolTaskExecutor poolTaskExecutor; // private ThreadPoolTaskExecutor poolTaskExecutor;
@ -73,7 +72,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
@Override @Override
@Async @Async
public void processRequest(RequestEvent requestEvent) { public void processRequest(RequestEvent requestEvent) {
logger.debug("\n收到请求:\n{}", requestEvent.getRequest()); logger.info("\n收到请求:\n{}", requestEvent.getRequest());
String method = requestEvent.getRequest().getMethod(); String method = requestEvent.getRequest().getMethod();
ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method);
if (sipRequestProcessor == null) { if (sipRequestProcessor == null) {

6
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java

@ -22,7 +22,6 @@ public interface ISIPCommander {
* @param channelId 预览通道 * @param channelId 预览通道
* @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
* @param upDown 镜头上移下移 0:停止 1:上移 2:下移 * @param upDown 镜头上移下移 0:停止 1:上移 2:下移
* @param moveSpeed 镜头移动速度
*/ */
boolean ptzdirectCmd(Device device,String channelId,int leftRight, int upDown); boolean ptzdirectCmd(Device device,String channelId,int leftRight, int upDown);
@ -52,7 +51,6 @@ public interface ISIPCommander {
* @param device 控制设备 * @param device 控制设备
* @param channelId 预览通道 * @param channelId 预览通道
* @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
* @param zoomSpeed 镜头缩放速度
*/ */
boolean ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed); boolean ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed);
@ -87,7 +85,7 @@ public interface ISIPCommander {
* @param channelId 预览通道 * @param channelId 预览通道
* @param cmdString 前端控制指令串 * @param cmdString 前端控制指令串
*/ */
boolean fronEndCmd(Device device, String channelId, String cmdString); boolean fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent);
/** /**
* 请求预览视频流 * 请求预览视频流
@ -181,7 +179,6 @@ public interface ISIPCommander {
* 报警布防/撤防命令 * 报警布防/撤防命令
* *
* @param device 视频设备 * @param device 视频设备
* @param setGuard true: SetGuard, false: ResetGuard
*/ */
boolean guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent); boolean guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent);
@ -315,7 +312,6 @@ public interface ISIPCommander {
* @param expires 订阅过期时间0 = 取消订阅 * @param expires 订阅过期时间0 = 取消订阅
* @param startPriority 报警起始级别可选 * @param startPriority 报警起始级别可选
* @param endPriority 报警终止级别可选 * @param endPriority 报警终止级别可选
* @param alarmMethods 报警方式条件可选
* @param alarmType 报警类型 * @param alarmType 报警类型
* @param startTime 报警发生起始时间可选 * @param startTime 报警发生起始时间可选
* @param endTime 报警发生终止时间可选 * @param endTime 报警发生终止时间可选

4
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@ -303,7 +303,7 @@ public class SIPCommander implements ISIPCommander {
* @param cmdString 前端控制指令串 * @param cmdString 前端控制指令串
*/ */
@Override @Override
public boolean fronEndCmd(Device device, String channelId, String cmdString) { public boolean fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) {
try { try {
StringBuffer ptzXml = new StringBuffer(200); StringBuffer ptzXml = new StringBuffer(200);
ptzXml.append("<?xml version=\"1.0\" ?>\r\n"); ptzXml.append("<?xml version=\"1.0\" ?>\r\n");
@ -323,7 +323,7 @@ public class SIPCommander implements ISIPCommander {
: udpSipProvider.getNewCallId(); : udpSipProvider.getNewCallId();
Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader);
transmitRequest(device, request); transmitRequest(device, request, errorEvent, okEvent);
return true; return true;
} catch (SipException | ParseException | InvalidArgumentException e) { } catch (SipException | ParseException | InvalidArgumentException e) {
e.printStackTrace(); e.printStackTrace();

1
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java

@ -70,7 +70,6 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
@Autowired @Autowired
private UserSetting userSetting; private UserSetting userSetting;
@Autowired @Autowired
private SubscribeHolder subscribeHolder; private SubscribeHolder subscribeHolder;

30
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java

@ -19,13 +19,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.ListeningPoint; import javax.sip.*;
import javax.sip.ObjectInUseException;
import javax.sip.RequestEvent;
import javax.sip.SipProvider;
import javax.sip.address.SipURI; import javax.sip.address.SipURI;
import javax.sip.header.HeaderAddress; import javax.sip.header.HeaderAddress;
import javax.sip.header.ToHeader; import javax.sip.header.ToHeader;
import java.text.ParseException;
import java.util.Iterator; import java.util.Iterator;
import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText;
@ -105,7 +103,29 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) { if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) {
String cmdString = getText(rootElement,"PTZCmd"); String cmdString = getText(rootElement,"PTZCmd");
Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
cmder.fronEndCmd(deviceForPlatform, channelId, cmdString); cmder.fronEndCmd(deviceForPlatform, channelId, cmdString, eventResult -> {
// 失败的回复
try {
responseAck(evt, eventResult.statusCode, eventResult.msg);
} catch (SipException e) {
e.printStackTrace();
} catch (InvalidArgumentException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}, eventResult -> {
// 成功的回复
try {
responseAck(evt, eventResult.statusCode);
} catch (SipException e) {
e.printStackTrace();
} catch (InvalidArgumentException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
});
} }
} }
} }

2
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java

@ -244,7 +244,7 @@ public class ZLMRTPServerFactory {
logger.error("RTP推流失败: 请检查ZLM服务"); logger.error("RTP推流失败: 请检查ZLM服务");
} else if (jsonObject.getInteger("code") == 0) { } else if (jsonObject.getInteger("code") == 0) {
result= true; result= true;
logger.info("RTP推流成功[ {}/{} ],本地推流端口:{}" ,param.get("app"), param.get("stream"), jsonObject.getString("local_port")); logger.info("RTP推流成功[ {}/{} ],{}->{}:{}, " ,param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port"));
} else { } else {
logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"),JSONObject.toJSON(param)); logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"),JSONObject.toJSON(param));
} }

Loading…
Cancel
Save