| | |
| | | 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.timeout.ITimeoutProcessor; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import javax.sip.*; |
| | | import javax.sip.header.CSeqHeader; |
| | | import javax.sip.header.CallIdHeader; |
| | | import javax.sip.header.Header; |
| | | import javax.sip.message.Response; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | |
| | | @Autowired |
| | | private SipSubscribe sipSubscribe; |
| | | |
| | | |
| | | // @Autowired |
| | | // @Qualifier(value = "taskExecutor") |
| | |
| | | @Override |
| | | @Async |
| | | public void processRequest(RequestEvent requestEvent) { |
| | | logger.debug("\n收到请求:\n{}", requestEvent.getRequest()); |
| | | logger.info("\n收到请求:\n{}", requestEvent.getRequest()); |
| | | String method = requestEvent.getRequest().getMethod(); |
| | | ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); |
| | | if (sipRequestProcessor == null) { |
| | |
| | | * @param channelId 预览通道
|
| | | * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
|
| | | * @param upDown 镜头上移下移 0:停止 1:上移 2:下移
|
| | | * @param moveSpeed 镜头移动速度
|
| | | */
|
| | | boolean ptzdirectCmd(Device device,String channelId,int leftRight, int upDown);
|
| | |
|
| | |
| | | * @param device 控制设备
|
| | | * @param channelId 预览通道
|
| | | * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
|
| | | * @param zoomSpeed 镜头缩放速度
|
| | | */
|
| | | boolean ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed);
|
| | |
|
| | |
| | | * @param channelId 预览通道
|
| | | * @param cmdString 前端控制指令串
|
| | | */
|
| | | boolean fronEndCmd(Device device, String channelId, String cmdString);
|
| | | boolean fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent);
|
| | |
|
| | | /**
|
| | | * 请求预览视频流
|
| | |
| | | * 报警布防/撤防命令
|
| | | *
|
| | | * @param device 视频设备
|
| | | * @param setGuard true: SetGuard, false: ResetGuard
|
| | | */
|
| | | boolean guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent);
|
| | |
|
| | |
| | | * @param expires 订阅过期时间(0 = 取消订阅)
|
| | | * @param startPriority 报警起始级别(可选)
|
| | | * @param endPriority 报警终止级别(可选)
|
| | | * @param alarmMethods 报警方式条件(可选)
|
| | | * @param alarmType 报警类型
|
| | | * @param startTime 报警发生起始时间(可选)
|
| | | * @param endTime 报警发生终止时间(可选)
|
| | |
| | | * @param cmdString 前端控制指令串
|
| | | */
|
| | | @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 {
|
| | | StringBuffer ptzXml = new StringBuffer(200);
|
| | | ptzXml.append("<?xml version=\"1.0\" ?>\r\n");
|
| | |
| | | : udpSipProvider.getNewCallId();
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader);
|
| | | transmitRequest(device, request);
|
| | | transmitRequest(device, request, errorEvent, okEvent);
|
| | | return true;
|
| | | } catch (SipException | ParseException | InvalidArgumentException e) {
|
| | | e.printStackTrace();
|
| | |
| | | @Autowired |
| | | private UserSetting userSetting; |
| | | |
| | | |
| | | @Autowired |
| | | private SubscribeHolder subscribeHolder; |
| | | |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.sip.ListeningPoint; |
| | | import javax.sip.ObjectInUseException; |
| | | import javax.sip.RequestEvent; |
| | | import javax.sip.SipProvider; |
| | | import javax.sip.*; |
| | | import javax.sip.address.SipURI; |
| | | import javax.sip.header.HeaderAddress; |
| | | import javax.sip.header.ToHeader; |
| | | import java.text.ParseException; |
| | | import java.util.Iterator; |
| | | |
| | | import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; |
| | |
| | | if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) { |
| | | String cmdString = getText(rootElement,"PTZCmd"); |
| | | 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(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | |
| | | logger.error("RTP推流失败: 请检查ZLM服务"); |
| | | } else if (jsonObject.getInteger("code") == 0) { |
| | | 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 { |
| | | logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"),JSONObject.toJSON(param)); |
| | | } |