From c4fc4abf7cbaa621f7ca1946f67c786c6cd55b68 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 17 十月 2022 09:39:21 +0800
Subject: [PATCH] 优化代码空字符串判断
---
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java | 36 +++++++++++++++++-------------------
1 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java
index a1e98f9..66f5442 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java
@@ -19,6 +19,7 @@
import org.springframework.stereotype.Component;
import javax.sip.InvalidArgumentException;
import javax.sip.RequestEvent;
+import javax.sip.ServerTransaction;
import javax.sip.SipException;
import javax.sip.header.*;
import javax.sip.message.Response;
@@ -65,9 +66,12 @@
CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME);
// 鍏堜粠浼氳瘽鍐呮煡鎵�
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
- if (ssrcTransaction != null) { // 鍏煎娴峰悍 濯掍綋閫氱煡 娑堟伅from瀛楁涓嶆槸璁惧ID鐨勯棶棰�
+
+ // 鍏煎娴峰悍 濯掍綋閫氱煡 娑堟伅from瀛楁涓嶆槸璁惧ID鐨勯棶棰�
+ if (ssrcTransaction != null) {
deviceId = ssrcTransaction.getDeviceId();
}
+ ServerTransaction serverTransaction = getServerTransaction(evt);
// 鏌ヨ璁惧鏄惁瀛樺湪
Device device = redisCatchStorage.getDevice(deviceId);
// 鏌ヨ涓婄骇骞冲彴鏄惁瀛樺湪
@@ -86,46 +90,40 @@
}
if (device == null && parentPlatform == null) {
// 涓嶅瓨鍦ㄥ垯鍥炲404
- responseAck(evt, Response.NOT_FOUND, "device "+ deviceId +" not found");
+ responseAck(serverTransaction, Response.NOT_FOUND, "device "+ deviceId +" not found");
logger.warn("[璁惧鏈壘鍒� ]锛� {}", deviceId);
if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){
- SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(new DeviceNotFoundEvent(evt.getDialog()));
+ DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog());
+ deviceNotFoundEvent.setCallId(callIdHeader.getCallId());
+ SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(deviceNotFoundEvent);
sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult);
};
}else {
ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME);
String contentType = header.getContentType();
String contentSubType = header.getContentSubType();
- if ("Application".equals(contentType) && "MANSRTSP".equals(contentSubType)) {
+ if ("Application".equalsIgnoreCase(contentType) && "MANSRTSP".equalsIgnoreCase(contentSubType)) {
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId());
String streamId = sendRtpItem.getStreamId();
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (null == streamInfo) {
- responseAck(evt, Response.NOT_FOUND, "stream " + streamId + " not found");
+ responseAck(serverTransaction, Response.NOT_FOUND, "stream " + streamId + " not found");
return;
}
Device device1 = storager.queryVideoDevice(streamInfo.getDeviceID());
cmder.playbackControlCmd(device1,streamInfo,new String(evt.getRequest().getRawContent()),eventResult -> {
// 澶辫触鐨勫洖澶�
try {
- responseAck(evt, eventResult.statusCode, eventResult.msg);
- } catch (SipException e) {
- e.printStackTrace();
- } catch (InvalidArgumentException e) {
- e.printStackTrace();
- } catch (ParseException e) {
- e.printStackTrace();
+ responseAck(serverTransaction, eventResult.statusCode, eventResult.msg);
+ } catch (SipException | InvalidArgumentException | ParseException e) {
+ logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 褰曞儚鎺у埗: {}", e.getMessage());
}
}, eventResult -> {
// 鎴愬姛鐨勫洖澶�
try {
- responseAck(evt, eventResult.statusCode);
- } catch (SipException e) {
- e.printStackTrace();
- } catch (InvalidArgumentException e) {
- e.printStackTrace();
- } catch (ParseException e) {
- e.printStackTrace();
+ responseAck(serverTransaction, eventResult.statusCode);
+ } catch (SipException | InvalidArgumentException | ParseException e) {
+ logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 褰曞儚鎺у埗: {}", e.getMessage());
}
});
}
--
Gitblit v1.8.0