支持级联云台控制

pull/446/head
648540858 2022-04-02 14:13:32 +08:00
parent 2659f10551
commit 5ed44c3e09
6 changed files with 31 additions and 17 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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();

View File

@ -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;

View File

@ -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();
}
});
} }
} }
} }

View File

@ -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));
} }