From cf5ca3afb9d4a5bdb990811c7c3fcbbfa0360edf Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 08 七月 2024 11:40:37 +0800
Subject: [PATCH] 修复设备断网导致超时的空指针异常
---
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 41 ++++++++++++++++++++++++++---------------
src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java | 17 +++++++++++++++--
src/main/resources/application.yml | 2 +-
3 files changed, 42 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java
index e5847f6..b34a1b7 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java
@@ -6,6 +6,7 @@
import com.genersoft.iot.vmp.common.InviteSessionStatus;
import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
+import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
import com.genersoft.iot.vmp.service.IInviteStreamService;
@@ -40,6 +41,9 @@
@Autowired
private IVideoManagerStorage storage;
+ @Autowired
+ private UserSetting userSetting;
+
/**
* 娴佸埌鏉ョ殑澶勭悊
*/
@@ -67,7 +71,11 @@
}
@Override
public void updateInviteInfo(InviteInfo inviteInfo) {
- updateInviteInfo(inviteInfo, null);
+ if (InviteSessionStatus.ready == inviteInfo.getStatus()) {
+ updateInviteInfo(inviteInfo, Long.valueOf(userSetting.getPlayTimeout()) * 2);
+ }else {
+ updateInviteInfo(inviteInfo, null);
+ }
}
@Override
@@ -148,7 +156,12 @@
if (inviteInfoInDb.getSsrcInfo() != null) {
inviteInfoInDb.getSsrcInfo().setStream(stream);
}
- redisTemplate.opsForValue().set(key, inviteInfoInDb);
+ if (InviteSessionStatus.ready == inviteInfo.getStatus()) {
+ redisTemplate.opsForValue().set(key, inviteInfoInDb, userSetting.getPlayTimeout() * 2, TimeUnit.SECONDS);
+ }else {
+ redisTemplate.opsForValue().set(key, inviteInfoInDb);
+ }
+
return inviteInfoInDb;
}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
index 39c67c2..0386ee9 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -459,9 +459,11 @@
ErrorCallback<Object> callback) {
if (mediaServerItem == null || ssrcInfo == null) {
- callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(),
- InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(),
- null);
+ if (callback != null) {
+ callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(),
+ InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(),
+ null);
+ }
return;
}
logger.info("[鐐规挱寮�濮媇 deviceId: {}, channelId: {},鐮佹祦绫诲瀷锛歿}, 鏀舵祦绔彛锛� {}, 鐮佹祦锛歿}, 鏀舵祦妯″紡锛歿}, SSRC: {}, SSRC鏍¢獙锛歿}",
@@ -473,8 +475,9 @@
// 閲婃斁ssrc
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream());
-
- callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "鐐规挱绔彛鍒嗛厤寮傚父", null);
+ if (callback != null) {
+ callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "鐐规挱绔彛鍒嗛厤寮傚父", null);
+ }
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "鐐规挱绔彛鍒嗛厤寮傚父", null);
return;
@@ -494,8 +497,9 @@
logger.info("[鐐规挱瓒呮椂] 鏀舵祦瓒呮椂 deviceId: {}, channelId: {},鐮佹祦锛歿}锛岀鍙o細{}, SSRC: {}",
device.getDeviceId(), channel.getChannelId(), channel.getStreamIdentification(),
ssrcInfo.getPort(), ssrcInfo.getSsrc());
-
- callback.run(InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null);
+ if (callback != null) {
+ callback.run(InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null);
+ }
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null);
inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId());
@@ -531,14 +535,19 @@
// hook鍝嶅簲
StreamInfo streamInfo = onPublishHandlerForPlay(hookData.getMediaServer(), hookData.getMediaInfo(), device.getDeviceId(), channel.getChannelId());
if (streamInfo == null){
- callback.run(InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(),
- InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null);
+ if (callback != null) {
+ callback.run(InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(),
+ InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null);
+ }
+
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(),
InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null);
return;
}
- callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
+ if (callback != null) {
+ callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
+ }
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
InviteErrorCode.SUCCESS.getCode(),
InviteErrorCode.SUCCESS.getMsg(),
@@ -558,8 +567,9 @@
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream());
-
- callback.run(event.statusCode, event.msg, null);
+ if (callback != null) {
+ callback.run(event.statusCode, event.msg, null);
+ }
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
InviteErrorCode.ERROR_FOR_RESET_SSRC.getCode(),
String.format("鐐规挱澶辫触锛� 閿欒鐮侊細 %s, %s", event.statusCode, event.msg), null);
@@ -575,9 +585,10 @@
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream());
-
- callback.run(InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
- InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);
+ if (callback != null) {
+ callback.run(InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
+ InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);
+ }
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index ddb05de..023c055 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -2,4 +2,4 @@
application:
name: wvp
profiles:
- active: local271
\ No newline at end of file
+ active: local272
\ No newline at end of file
--
Gitblit v1.8.0