From 379830f7ebd3d9b93bfbfeb52584e5e4de29a979 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 23 七月 2021 17:20:24 +0800
Subject: [PATCH] Merge pull request #129 from lawrencehj/wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java | 55 ++++++++++++++++++++++++++++++-------------------------
1 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
index 6341fb2..70e64a5 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
@@ -114,13 +114,13 @@
String cmd = XmlUtil.getText(rootElement, "CmdType");
if (MESSAGE_KEEP_ALIVE.equals(cmd)) {
- logger.info("鎺ユ敹鍒癒eepAlive娑堟伅");
+ logger.debug("鎺ユ敹鍒癒eepAlive娑堟伅");
processMessageKeepAlive(evt);
} else if (MESSAGE_CONFIG_DOWNLOAD.equals(cmd)) {
- logger.info("鎺ユ敹鍒癈onfigDownload娑堟伅");
+ logger.debug("鎺ユ敹鍒癈onfigDownload娑堟伅");
processMessageConfigDownload(evt);
} else if (MESSAGE_CATALOG.equals(cmd)) {
- logger.info("鎺ユ敹鍒癈atalog娑堟伅");
+ logger.debug("鎺ユ敹鍒癈atalog娑堟伅");
processMessageCatalogList(evt);
} else if (MESSAGE_DEVICE_INFO.equals(cmd)) {
// DeviceInfo娑堟伅澶勭悊
@@ -129,31 +129,31 @@
// DeviceStatus娑堟伅澶勭悊
processMessageDeviceStatus(evt);
} else if (MESSAGE_DEVICE_CONTROL.equals(cmd)) {
- logger.info("鎺ユ敹鍒癉eviceControl娑堟伅");
+ logger.debug("鎺ユ敹鍒癉eviceControl娑堟伅");
processMessageDeviceControl(evt);
} else if (MESSAGE_DEVICE_CONFIG.equals(cmd)) {
logger.info("鎺ユ敹鍒癉eviceConfig娑堟伅");
processMessageDeviceConfig(evt);
} else if (MESSAGE_ALARM.equals(cmd)) {
- logger.info("鎺ユ敹鍒癆larm娑堟伅");
+ logger.debug("鎺ユ敹鍒癆larm娑堟伅");
processMessageAlarm(evt);
} else if (MESSAGE_RECORD_INFO.equals(cmd)) {
- logger.info("鎺ユ敹鍒癛ecordInfo娑堟伅");
+ logger.debug("鎺ユ敹鍒癛ecordInfo娑堟伅");
processMessageRecordInfo(evt);
}else if (MESSAGE_MEDIA_STATUS.equals(cmd)) {
- logger.info("鎺ユ敹鍒癕ediaStatus娑堟伅");
+ logger.debug("鎺ユ敹鍒癕ediaStatus娑堟伅");
processMessageMediaStatus(evt);
} else if (MESSAGE_MOBILE_POSITION.equals(cmd)) {
- logger.info("鎺ユ敹鍒癕obilePosition娑堟伅");
+ logger.debug("鎺ユ敹鍒癕obilePosition娑堟伅");
processMessageMobilePosition(evt);
} else if (MESSAGE_PRESET_QUERY.equals(cmd)) {
- logger.info("鎺ユ敹鍒癙resetQuery娑堟伅");
+ logger.debug("鎺ユ敹鍒癙resetQuery娑堟伅");
processMessagePresetQuery(evt);
} else if (MESSAGE_BROADCAST.equals(cmd)) {
// Broadcast娑堟伅澶勭悊
processMessageBroadcast(evt);
} else {
- logger.info("鎺ユ敹鍒版秷鎭細" + cmd);
+ logger.debug("鎺ユ敹鍒版秷鎭細" + cmd);
responseAck(evt);
}
} catch (DocumentException | SipException |InvalidArgumentException | ParseException e) {
@@ -226,7 +226,7 @@
String name = rootElement.getName();
Element deviceIdElement = rootElement.element("DeviceID");
String deviceId = deviceIdElement.getText();
-
+ Device device = storager.queryVideoDevice(deviceId);
if (name.equalsIgnoreCase("Query")) { // 鍖哄垎鏄疪esponse鈥斺�旀煡璇㈠搷搴旓紝杩樻槸Query鈥斺�旀煡璇㈣姹�
logger.info("鎺ユ敹鍒癉eviceStatus鏌ヨ娑堟伅");
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
@@ -259,7 +259,7 @@
deferredResultHolder.invokeResult(msg);
if (offLineDetector.isOnline(deviceId)) {
- publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
+ publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE);
} else {
}
}
@@ -282,7 +282,7 @@
//String result = XmlUtil.getText(rootElement, "Result");
// 鍥炲200 OK
responseAck(evt);
- if (rootElement.getName().equals("Response")) {//} !XmlUtil.isEmpty(result)) {
+ if (rootElement.getName().equals("Response")) {//} !StringUtils.isEmpty(result)) {
// 姝ゅ鏄鏈钩鍙板彂鍑篋eviceControl鎸囦护鐨勫簲绛�
JSONObject json = new JSONObject();
XmlUtil.node2Json(rootElement, json);
@@ -299,7 +299,7 @@
String platformId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser();
String targetGBId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser();
// 杩滅▼鍚姩鍔熻兘
- if (!XmlUtil.isEmpty(XmlUtil.getText(rootElement, "TeleBoot"))) {
+ if (!StringUtils.isEmpty(XmlUtil.getText(rootElement, "TeleBoot"))) {
if (deviceId.equals(targetGBId)) {
// 杩滅▼鍚姩鏈钩鍙帮細闇�瑕佸湪閲嶆柊鍚姩绋嬪簭鍚庡厛瀵筍ipStack瑙g粦
logger.info("鎵ц杩滅▼鍚姩鏈钩鍙板懡浠�");
@@ -337,7 +337,7 @@
}
}
// 浜戝彴/鍓嶇鎺у埗鍛戒护
- if (!XmlUtil.isEmpty(XmlUtil.getText(rootElement,"PTZCmd")) && !deviceId.equals(targetGBId)) {
+ if (!StringUtils.isEmpty(XmlUtil.getText(rootElement,"PTZCmd")) && !deviceId.equals(targetGBId)) {
String cmdString = XmlUtil.getText(rootElement,"PTZCmd");
Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(platformId, deviceId);
cmder.fronEndCmd(device, deviceId, cmdString);
@@ -421,7 +421,7 @@
String deviceId = XmlUtil.getText(rootElement, "DeviceID");
// 鍥炲200 OK
responseAck(evt);
- if (rootElement.getName().equals("Response")) {// !XmlUtil.isEmpty(result)) {
+ if (rootElement.getName().equals("Response")) {// !StringUtils.isEmpty(result)) {
// 姝ゅ鏄鏈钩鍙板彂鍑篋eviceControl鎸囦护鐨勫簲绛�
JSONObject json = new JSONObject();
XmlUtil.node2Json(rootElement, json);
@@ -452,6 +452,7 @@
String requestName = rootElement.getName();
Element deviceIdElement = rootElement.element("DeviceID");
String deviceId = deviceIdElement.getTextTrim().toString();
+ Device device = storager.queryVideoDevice(deviceId);
if (requestName.equals("Query")) {
logger.info("鎺ユ敹鍒癉eviceInfo鏌ヨ娑堟伅");
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
@@ -467,8 +468,7 @@
cmderFroPlatform.deviceInfoResponse(parentPlatform, sn, fromHeader.getTag());
}
} else {
- logger.info("鎺ユ敹鍒癉eviceInfo搴旂瓟娑堟伅");
- Device device = storager.queryVideoDevice(deviceId);
+ logger.debug("鎺ユ敹鍒癉eviceInfo搴旂瓟娑堟伅");
if (device == null) {
return;
}
@@ -489,7 +489,7 @@
// 鍥炲200 OK
responseAck(evt);
if (offLineDetector.isOnline(deviceId)) {
- publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
+ publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE);
}
}
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
@@ -669,7 +669,7 @@
// 鍥炲200 OK
responseAck(evt);
if (offLineDetector.isOnline(deviceId)) {
- publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
+ publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE);
}
}
}
@@ -718,7 +718,7 @@
deviceAlarm.setLatitude(0.00);
}
- if (!XmlUtil.isEmpty(deviceAlarm.getAlarmMethod())) {
+ if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) {
if ( deviceAlarm.getAlarmMethod().equals("4")) {
MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setDeviceId(deviceAlarm.getDeviceId());
@@ -770,14 +770,19 @@
try {
Element rootElement = getRootElement(evt);
String deviceId = XmlUtil.getText(rootElement, "DeviceID");
- // 妫�鏌ヨ澶囨槸鍚﹀瓨鍦紝 涓嶅瓨鍦ㄥ垯涓嶅洖澶�
- if (storager.exists(deviceId)) {
+ Device device = storager.queryVideoDevice(deviceId);
+ // 妫�鏌ヨ澶囨槸鍚﹀瓨鍦ㄥ苟鍦ㄧ嚎锛� 涓嶅瓨鍦ㄥ垯涓嶅洖澶�
+ if (device != null && device.getOnline() == 1) {
// 鍥炲200 OK
responseAck(evt);
if (offLineDetector.isOnline(deviceId)) {
- publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
+ publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
} else {
}
+ }else {
+ logger.warn("鏀跺埌[ "+deviceId+" ]蹇冭烦淇℃伅, 浣嗘槸璁惧" + (device == null? "涓嶅瓨鍦�":"绂荤嚎") + ", 鍥炲401");
+ Response response = getMessageFactory().createResponse(Response.UNAUTHORIZED, evt.getRequest());
+ getServerTransaction(evt).sendResponse(response);
}
} catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
e.printStackTrace();
@@ -922,7 +927,7 @@
StreamInfo streamInfo = redisCatchStorage.queryPlaybackByDevice(deviceId, "*");
if (streamInfo != null) {
redisCatchStorage.stopPlayback(streamInfo);
- cmder.streamByeCmd(streamInfo.getStreamId());
+ cmder.streamByeCmd(streamInfo.getDeviceID(), streamInfo.getChannelId());
}
}
} catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
--
Gitblit v1.8.0