修复设备断网导致超时的空指针异常
parent
26e2e8b2a3
commit
cf5ca3afb9
|
@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.common.InviteInfo;
|
||||||
import com.genersoft.iot.vmp.common.InviteSessionStatus;
|
import com.genersoft.iot.vmp.common.InviteSessionStatus;
|
||||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
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.MediaArrivalEvent;
|
||||||
import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
|
import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
|
||||||
import com.genersoft.iot.vmp.service.IInviteStreamService;
|
import com.genersoft.iot.vmp.service.IInviteStreamService;
|
||||||
|
@ -40,6 +41,9 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IVideoManagerStorage storage;
|
private IVideoManagerStorage storage;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserSetting userSetting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流到来的处理
|
* 流到来的处理
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +71,11 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void updateInviteInfo(InviteInfo inviteInfo) {
|
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
|
@Override
|
||||||
|
@ -148,7 +156,12 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
|
||||||
if (inviteInfoInDb.getSsrcInfo() != null) {
|
if (inviteInfoInDb.getSsrcInfo() != null) {
|
||||||
inviteInfoInDb.getSsrcInfo().setStream(stream);
|
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;
|
return inviteInfoInDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -459,9 +459,11 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
ErrorCallback<Object> callback) {
|
ErrorCallback<Object> callback) {
|
||||||
|
|
||||||
if (mediaServerItem == null || ssrcInfo == null) {
|
if (mediaServerItem == null || ssrcInfo == null) {
|
||||||
callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(),
|
if (callback != null) {
|
||||||
InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(),
|
callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(),
|
||||||
null);
|
InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(),
|
||||||
|
null);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.info("[点播开始] deviceId: {}, channelId: {},码流类型:{}, 收流端口: {}, 码流:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}",
|
logger.info("[点播开始] deviceId: {}, channelId: {},码流类型:{}, 收流端口: {}, 码流:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}",
|
||||||
|
@ -473,8 +475,9 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
// 释放ssrc
|
// 释放ssrc
|
||||||
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
|
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
|
||||||
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream());
|
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream());
|
||||||
|
if (callback != null) {
|
||||||
callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "点播端口分配异常", null);
|
callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "点播端口分配异常", null);
|
||||||
|
}
|
||||||
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
|
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
|
||||||
InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "点播端口分配异常", null);
|
InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "点播端口分配异常", null);
|
||||||
return;
|
return;
|
||||||
|
@ -494,8 +497,9 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
logger.info("[点播超时] 收流超时 deviceId: {}, channelId: {},码流:{},端口:{}, SSRC: {}",
|
logger.info("[点播超时] 收流超时 deviceId: {}, channelId: {},码流:{},端口:{}, SSRC: {}",
|
||||||
device.getDeviceId(), channel.getChannelId(), channel.getStreamIdentification(),
|
device.getDeviceId(), channel.getChannelId(), channel.getStreamIdentification(),
|
||||||
ssrcInfo.getPort(), ssrcInfo.getSsrc());
|
ssrcInfo.getPort(), ssrcInfo.getSsrc());
|
||||||
|
if (callback != null) {
|
||||||
callback.run(InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), 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,
|
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
|
||||||
InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null);
|
InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null);
|
||||||
inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId());
|
inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId());
|
||||||
|
@ -531,14 +535,19 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
// hook响应
|
// hook响应
|
||||||
StreamInfo streamInfo = onPublishHandlerForPlay(hookData.getMediaServer(), hookData.getMediaInfo(), device.getDeviceId(), channel.getChannelId());
|
StreamInfo streamInfo = onPublishHandlerForPlay(hookData.getMediaServer(), hookData.getMediaInfo(), device.getDeviceId(), channel.getChannelId());
|
||||||
if (streamInfo == null){
|
if (streamInfo == null){
|
||||||
callback.run(InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(),
|
if (callback != null) {
|
||||||
InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), 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,
|
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
|
||||||
InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(),
|
InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(),
|
||||||
InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null);
|
InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null);
|
||||||
return;
|
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,
|
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
|
||||||
InviteErrorCode.SUCCESS.getCode(),
|
InviteErrorCode.SUCCESS.getCode(),
|
||||||
InviteErrorCode.SUCCESS.getMsg(),
|
InviteErrorCode.SUCCESS.getMsg(),
|
||||||
|
@ -558,8 +567,9 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
|
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
|
||||||
|
|
||||||
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream());
|
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream());
|
||||||
|
if (callback != null) {
|
||||||
callback.run(event.statusCode, event.msg, null);
|
callback.run(event.statusCode, event.msg, null);
|
||||||
|
}
|
||||||
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
|
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
|
||||||
InviteErrorCode.ERROR_FOR_RESET_SSRC.getCode(),
|
InviteErrorCode.ERROR_FOR_RESET_SSRC.getCode(),
|
||||||
String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg), null);
|
String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg), null);
|
||||||
|
@ -575,9 +585,10 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
|
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
|
||||||
|
|
||||||
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream());
|
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcInfo.getStream());
|
||||||
|
if (callback != null) {
|
||||||
callback.run(InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
|
callback.run(InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
|
||||||
InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);
|
InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);
|
||||||
|
}
|
||||||
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
|
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
|
||||||
InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
|
InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
|
||||||
InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);
|
InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);
|
||||||
|
|
|
@ -2,4 +2,4 @@ spring:
|
||||||
application:
|
application:
|
||||||
name: wvp
|
name: wvp
|
||||||
profiles:
|
profiles:
|
||||||
active: local271
|
active: local272
|
Loading…
Reference in New Issue