修复合并PR时的数据导入问题

This commit is contained in:
lin 2026-04-13 11:05:45 +08:00
parent 2e149dc2a2
commit c35bb73091

View File

@ -120,9 +120,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
@Override @Override
public void process(RequestEvent evt) { public void process(RequestEvent evt) {
SIPRequest request = (SIPRequest)evt.getRequest(); SIPRequest request = (SIPRequest) evt.getRequest();
InviteMessageInfo inviteInfo = null;
try { try {
InviteMessageInfo inviteInfo = decode(evt); inviteInfo = decode(evt);
// 查询请求是否来自上级平台\设备 // 查询请求是否来自上级平台\设备
Platform platform = platformService.queryPlatformByServerGBId(inviteInfo.getRequesterId()); Platform platform = platformService.queryPlatformByServerGBId(inviteInfo.getRequesterId());
@ -130,7 +131,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
inviteFromDeviceHandle(request, inviteInfo); inviteFromDeviceHandle(request, inviteInfo);
} else { } else {
// 查询平台下是否有该通道 // 查询平台下是否有该通道
CommonGBChannel channel= channelService.queryOneWithPlatform(platform.getId(), inviteInfo.getTargetChannelId()); CommonGBChannel channel = channelService.queryOneWithPlatform(platform.getId(), inviteInfo.getTargetChannelId());
if (channel == null) { if (channel == null) {
log.info("[上级INVITE] 通道不存在返回404: {}", inviteInfo.getTargetChannelId()); log.info("[上级INVITE] 通道不存在返回404: {}", inviteInfo.getTargetChannelId());
try { try {
@ -143,9 +144,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
} }
log.info("[上级INVITE] 平台:{} 通道:{}({}), 收流地址:{}:{},收流方式:{}, 点播类型:{}, SSRC{}", log.info("[上级INVITE] 平台:{} 通道:{}({}), 收流地址:{}:{},收流方式:{}, 点播类型:{}, SSRC{}",
platform.getName(), channel.getGbName(), channel.getGbDeviceId(), inviteInfo.getIp(), platform.getName(), channel.getGbName(), channel.getGbDeviceId(), inviteInfo.getIp(),
inviteInfo.getPort(), inviteInfo.isTcp()?(inviteInfo.isTcpActive()?"TCP主动":"TCP被动"): "UDP", inviteInfo.getPort(), inviteInfo.isTcp() ? (inviteInfo.isTcpActive() ? "TCP主动" : "TCP被动") : "UDP",
inviteInfo.getSessionName(), inviteInfo.getSsrc()); inviteInfo.getSessionName(), inviteInfo.getSsrc());
if(!userSetting.getUseCustomSsrcForParentInvite() && ObjectUtils.isEmpty(inviteInfo.getSsrc())) { if (!userSetting.getUseCustomSsrcForParentInvite() && ObjectUtils.isEmpty(inviteInfo.getSsrc())) {
log.warn("[上级INVITE] 点播失败, 上级未携带SSRC, 并且本级未设置使用自定义SSRC"); log.warn("[上级INVITE] 点播失败, 上级未携带SSRC, 并且本级未设置使用自定义SSRC");
// 通道存在发100TRYING // 通道存在发100TRYING
try { try {
@ -162,53 +163,54 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
log.error("[命令发送失败] 上级INVITE TRYING: {}", e.getMessage()); log.error("[命令发送失败] 上级INVITE TRYING: {}", e.getMessage());
} }
InviteMessageInfo finalInviteInfo = inviteInfo;
channelPlayService.startInvite(channel, inviteInfo, platform, ((code, msg, streamInfo) -> { channelPlayService.startInvite(channel, inviteInfo, platform, ((code, msg, streamInfo) -> {
if (code != InviteErrorCode.SUCCESS.getCode()) { if (code != InviteErrorCode.SUCCESS.getCode()) {
try { try {
responseAck(request, Response.BUSY_HERE , msg); responseAck(request, Response.BUSY_HERE, msg);
} catch (SipException | InvalidArgumentException | ParseException e) { } catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 上级INVITE 点播失败: {}", e.getMessage()); log.error("[命令发送失败] 上级INVITE 点播失败: {}", e.getMessage());
} }
}else { } else {
// 点播成功 TODO 可以在此处检测cancel命令是否存在存在则不发送 // 点播成功 TODO 可以在此处检测cancel命令是否存在存在则不发送
if (userSetting.getUseCustomSsrcForParentInvite()) { if (userSetting.getUseCustomSsrcForParentInvite()) {
// 上级平台点播时不使用上级平台指定的ssrc使用自定义的ssrc参考国标文档-点播外域设备媒体流SSRC处理方式 // 上级平台点播时不使用上级平台指定的ssrc使用自定义的ssrc参考国标文档-点播外域设备媒体流SSRC处理方式
MediaServer mediaServer = mediaServerService.getOne(streamInfo.getMediaServer().getId()); MediaServer mediaServer = mediaServerService.getOne(streamInfo.getMediaServer().getId());
if (mediaServer != null) { if (mediaServer != null) {
String ssrc = "Play".equalsIgnoreCase(inviteInfo.getSessionName()) String ssrc = "Play".equalsIgnoreCase(finalInviteInfo.getSessionName())
? ssrcFactory.getPlaySsrc(streamInfo.getMediaServer().getId()) ? ssrcFactory.getPlaySsrc(streamInfo.getMediaServer().getId())
: ssrcFactory.getPlayBackSsrc(streamInfo.getMediaServer().getId()); : ssrcFactory.getPlayBackSsrc(streamInfo.getMediaServer().getId());
inviteInfo.setSsrc(ssrc); finalInviteInfo.setSsrc(ssrc);
inviteInfo.setAllocatedSsrc(ssrc); finalInviteInfo.setAllocatedSsrc(ssrc);
inviteInfo.setAllocatedSsrcMediaServerId(streamInfo.getMediaServer().getId()); finalInviteInfo.setAllocatedSsrcMediaServerId(streamInfo.getMediaServer().getId());
} }
} }
// 构建sendRTP内容 // 构建sendRTP内容
SendRtpInfo sendRtpItem = sendRtpServerService.createSendRtpInfo(streamInfo.getMediaServer(), SendRtpInfo sendRtpItem = sendRtpServerService.createSendRtpInfo(streamInfo.getMediaServer(),
inviteInfo.getIp(), inviteInfo.getPort(), inviteInfo.getSsrc(), platform.getServerGBId(), finalInviteInfo.getIp(), finalInviteInfo.getPort(), finalInviteInfo.getSsrc(), platform.getServerGBId(),
streamInfo.getApp(), streamInfo.getStream(), streamInfo.getApp(), streamInfo.getStream(),
channel.getGbId(), inviteInfo.isTcp(), platform.isRtcp()); channel.getGbId(), finalInviteInfo.isTcp(), platform.isRtcp());
sendRtpItem.setAllocatedSsrc(inviteInfo.getAllocatedSsrc()); sendRtpItem.setAllocatedSsrc(finalInviteInfo.getAllocatedSsrc());
if (inviteInfo.isTcp() && inviteInfo.isTcpActive()) { if (finalInviteInfo.isTcp() && finalInviteInfo.isTcpActive()) {
sendRtpItem.setTcpActive(true); sendRtpItem.setTcpActive(true);
} }
sendRtpItem.setStatus(1); sendRtpItem.setStatus(1);
sendRtpItem.setCallId(inviteInfo.getCallId()); sendRtpItem.setCallId(finalInviteInfo.getCallId());
sendRtpItem.setPlayTypeByChannelDataType(channel.getDataType(), inviteInfo.getSessionName()); sendRtpItem.setPlayTypeByChannelDataType(channel.getDataType(), finalInviteInfo.getSessionName());
sendRtpItem.setServerId(streamInfo.getServerId()); sendRtpItem.setServerId(streamInfo.getServerId());
sendRtpServerService.update(sendRtpItem); sendRtpServerService.update(sendRtpItem);
String sdpIp = streamInfo.getMediaServer().getSdpIp(); String sdpIp = streamInfo.getMediaServer().getSdpIp();
if (!ObjectUtils.isEmpty(platform.getSendStreamIp())) { if (!ObjectUtils.isEmpty(platform.getSendStreamIp())) {
sdpIp = platform.getSendStreamIp(); sdpIp = platform.getSendStreamIp();
} }
String content = createSendSdp(sendRtpItem, inviteInfo, sdpIp); String content = createSendSdp(sendRtpItem, finalInviteInfo, sdpIp);
// 超时未收到Ack应该回复bye,当前等待时间为10秒 // 超时未收到Ack应该回复bye,当前等待时间为10秒
dynamicTask.startDelay(inviteInfo.getCallId(), () -> { dynamicTask.startDelay(finalInviteInfo.getCallId(), () -> {
log.info("[Ack ] 等待超时, {}/{}", inviteInfo.getCallId(), channel.getGbDeviceId()); log.info("[Ack ] 等待超时, {}/{}", finalInviteInfo.getCallId(), channel.getGbDeviceId());
mediaServerService.releaseSsrc(streamInfo.getMediaServer().getId(), sendRtpItem.getSsrcToRelease()); mediaServerService.releaseSsrc(streamInfo.getMediaServer().getId(), sendRtpItem.getSsrcToRelease());
// 回复bye // 回复bye
sendBye(platform, inviteInfo.getCallId()); sendBye(platform, finalInviteInfo.getCallId());
}, 60 * 1000); }, 60 * 1000);
try { try {
responseSdpAck(request, content, platform); responseSdpAck(request, content, platform);
@ -225,9 +227,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
if (deviceChannel != null) { if (deviceChannel != null) {
redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, deviceChannel, platform); redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, deviceChannel, platform);
} }
}catch (ControllerException e) { } catch (ControllerException e) {
log.warn("[上级INVITE] tcp主动模式 发流失败", e); log.warn("[上级INVITE] tcp主动模式 发流失败", e);
sendBye(platform, inviteInfo.getCallId()); sendBye(platform, finalInviteInfo.getCallId());
} }
} }
} }
@ -246,14 +248,14 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
} catch (SipException | InvalidArgumentException | ParseException sendException) { } catch (SipException | InvalidArgumentException | ParseException sendException) {
log.error("[命令发送失败] invite BAD_REQUEST: {}", sendException.getMessage()); log.error("[命令发送失败] invite BAD_REQUEST: {}", sendException.getMessage());
} }
}catch (PlayException e) { } catch (PlayException e) {
releaseAllocatedSsrc(inviteInfo); releaseAllocatedSsrc(inviteInfo);
try { try {
responseAck(request, e.getCode(), e.getMsg()); responseAck(request, e.getCode(), e.getMsg());
} catch (SipException | InvalidArgumentException | ParseException sendException) { } catch (SipException | InvalidArgumentException | ParseException sendException) {
log.error("[命令发送失败] invite 点播失败: {}", sendException.getMessage()); log.error("[命令发送失败] invite 点播失败: {}", sendException.getMessage());
} }
}catch (Exception e) { } catch (Exception e) {
log.error("[Invite处理异常] ", e); log.error("[Invite处理异常] ", e);
releaseAllocatedSsrc(inviteInfo); releaseAllocatedSsrc(inviteInfo);
try { try {