修正国标级联消息处理中根据通道ID获取通道信息

pull/1642/head
648540858 2024-09-24 21:38:34 +08:00
parent 4f52333506
commit 03a7daffad
8 changed files with 41 additions and 44 deletions

View File

@ -113,7 +113,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
Platform parentPlatform = platformService.queryPlatformByServerGBId(fromUserId);
if (parentPlatform != null) {
DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpItem.getChannelId());
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(sendRtpItem.getChannelId());
if (!userSetting.getServerId().equals(sendRtpItem.getServerId())) {
WVPResult wvpResult = redisRpcService.startSendRtp(sendRtpItem.getChannelId(), sendRtpItem);
if (wvpResult.getCode() == 0) {

View File

@ -160,7 +160,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
log.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId);
return;
}
DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpItem.getChannelId());
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(sendRtpItem.getChannelId());
if (deviceChannel == null) {
log.info("[收到bye] {} 通知设备停止推流时未找到通道信息", streamId);
return;
@ -196,7 +196,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
platformService.stopBroadcast(platform, channel, ssrcTransaction.getStream(), false,
mediaServerService.getOne(mediaServerId));
Device device = deviceService.getDeviceByDeviceId(ssrcTransaction.getDeviceId());
DeviceChannel deviceChannel = deviceChannelService.getOneById(ssrcTransaction.getChannelId());
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(ssrcTransaction.getChannelId());
playService.stopAudioBroadcast(device, deviceChannel);
}
@ -206,7 +206,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
log.info("[收到bye] 未找到设备:{} ", ssrcTransaction.getDeviceId());
return;
}
DeviceChannel channel = deviceChannelService.getOneById(ssrcTransaction.getChannelId());
DeviceChannel channel = deviceChannelService.getOneForSourceById(ssrcTransaction.getChannelId());
if (channel == null) {
log.info("[收到bye] 未找到通道,设备:{} 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
return;

View File

@ -214,7 +214,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId());
try {
mediaServerService.startSendRtpPassive(mediaServer, sendRtpItem, 5);
DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpItem.getChannelId());
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(sendRtpItem.getChannelId());
if (deviceChannel != null) {
redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, deviceChannel, platform);
}
@ -451,7 +451,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
}
return;
}else {
deviceChannel = deviceChannelService.getOneById(audioBroadcastCatchList.get(0).getChannelId());
deviceChannel = deviceChannelService.getOneForSourceById(audioBroadcastCatchList.get(0).getChannelId());
}
}
AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(deviceChannel.getId());

View File

@ -117,7 +117,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I
return;
}
// 获取通道的原始信息
DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpInfo.getChannelId());
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(sendRtpInfo.getChannelId());
// 向原始通道转发控制消息
ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME);
String contentType = header.getContentType();

View File

@ -93,34 +93,9 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}
return;
}
// 根据通道ID获取所属设备
Device device = deviceService.getDeviceByChannelId(channel.getGbId());
if (device == null) {
// 不存在则回复404
log.warn("[INFO 消息] 通道所属设备不存在, 通道ID {}", channel.getGbId());
try {
responseAck(request, Response.NOT_FOUND, "device not found");
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 错误信息: {}", e.getMessage());
}
return;
}
log.info("[deviceControl] 命令: {}, 平台: {}{}->{}", deviceControlType, platform.getName(),
platform.getServerGBId(), channel.getGbId());
log.info("[deviceControl] 命令: {}, 平台: {}{}->{}{}/{}", deviceControlType, platform.getName(),
platform.getServerGBId(), device.getName(), device.getDeviceId(), channel.getGbId());
DeviceChannel deviceChannel = deviceChannelService.getOneById(channel.getGbId());
if (deviceChannel == null) {
// 拒绝远程启动命令
log.warn("[deviceControl] 未找到设备原始通道, 平台: {}{}),通道编号:{}", platform.getName(),
platform.getServerGBId(), channelId);
try {
responseAck(request, Response.NOT_FOUND, "channel not found");
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 错误信息: {}", e.getMessage());
}
return;
}
// !platform.getServerGBId().equals(targetGBId) 判断是为了过滤本平台内互相级联的情况
if (!ObjectUtils.isEmpty(deviceControlType)) {
switch (deviceControlType) {
case PTZ:
@ -158,13 +133,35 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
/**
*
*
* @param device
* @param channelId id
* @param rootElement
* @param request
*/
private void handlePtzCmd(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) {
private void handlePtzCmd(CommonGBChannel channel, Element rootElement, SIPRequest request, DeviceControlType type) {
// 根据通道ID获取所属设备
Device device = deviceService.getDeviceByChannelId(channel.getGbId());
if (device == null) {
// 不存在则回复404
log.warn("[INFO 消息] 通道所属设备不存在, 通道ID {}", channel.getGbId());
try {
responseAck(request, Response.NOT_FOUND, "device not found");
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 错误信息: {}", e.getMessage());
}
return;
}
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId());
if (deviceChannel == null) {
// 拒绝远程启动命令
log.warn("[deviceControl] 未找到设备原始通道, 平台: {}{}),通道编号:{}", platform.getName(),
platform.getServerGBId(), channelId);
try {
responseAck(request, Response.NOT_FOUND, "channel not found");
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 错误信息: {}", e.getMessage());
}
return;
}
log.info("[deviceControl] 命令: {}, 设备: {}{} 通道{}{}", type, device.getName(), device.getDeviceId(),
deviceChannel.getName(), deviceChannel.getDeviceId());
String cmdString = getText(rootElement, type.getVal());
try {
cmder.fronEndCmd(device, channelId, cmdString,

View File

@ -106,7 +106,7 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp
responseAck(request, Response.NOT_FOUND, "device not found");
return;
}
DeviceChannel deviceChannel = deviceChannelService.getOneById(channel.getGbId());
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId());
if (deviceChannel == null) {
responseAck(request, Response.NOT_FOUND, "channel not found");
return;

View File

@ -124,7 +124,7 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
return;
}
// 获取通道的原始信息
DeviceChannel deviceChannel = deviceChannelService.getOneById(channel.getGbId());
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId());
// 接收录像数据
recordEndEventListener.addEndEventHandler(device.getDeviceId(), deviceChannel.getDeviceId(), (recordInfo)->{
try {

View File

@ -179,7 +179,7 @@ public class MediaServiceImpl implements IMediaService {
String deviceId = ssrcTransaction.getDeviceId();
Integer channelId = ssrcTransaction.getChannelId();
DeviceChannel deviceChannel = deviceChannelService.getOneById(channelId);
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channelId);
if (deviceChannel != null) {
result.setEnable_audio(deviceChannel.isHasAudio());
}
@ -234,7 +234,7 @@ public class MediaServiceImpl implements IMediaService {
if (inviteInfo.getType() == InviteSessionType.DOWNLOAD) {
return false;
}
DeviceChannel deviceChannel = deviceChannelService.getOneById(inviteInfo.getChannelId());
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(inviteInfo.getChannelId());
if (deviceChannel == null) {
return false;
}