mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-06-16 16:37:50 +08:00
修复国标级联移除移除大量共享通道失败的BUG,修复国标级联推流鉴权失败的BUG
This commit is contained in:
parent
9aca5aab35
commit
0bd42d00b5
@ -36,6 +36,8 @@ import java.util.stream.Collectors;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||||
|
|
||||||
|
private static final int BATCH_SIZE = 500;
|
||||||
|
|
||||||
private final PlatformChannelMapper platformChannelMapper;
|
private final PlatformChannelMapper platformChannelMapper;
|
||||||
|
|
||||||
private final EventPublisher eventPublisher;
|
private final EventPublisher eventPublisher;
|
||||||
@ -450,34 +452,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
}
|
}
|
||||||
List<CommonGBChannel> channelListShare = platformChannelMapper.queryShare(platformId, null);
|
List<CommonGBChannel> channelListShare = platformChannelMapper.queryShare(platformId, null);
|
||||||
Assert.notEmpty(channelListShare, "未共享任何通道");
|
Assert.notEmpty(channelListShare, "未共享任何通道");
|
||||||
int result = platformChannelMapper.removeChannelsWithPlatform(platformId, channelListShare);
|
return removeChannelsFromDb(platform, platformId, channelListShare);
|
||||||
if (result > 0) {
|
|
||||||
// 查询通道相关的分组信息
|
|
||||||
Set<Region> regionSet = regionMapper.queryByChannelList(channelListShare);
|
|
||||||
Set<Region> deleteRegion = deleteEmptyRegion(regionSet, platformId);
|
|
||||||
if (!deleteRegion.isEmpty()) {
|
|
||||||
for (Region region : deleteRegion) {
|
|
||||||
channelListShare.add(0, CommonGBChannel.build(region));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询通道相关的分组信息
|
|
||||||
Set<Group> groupSet = groupMapper.queryByChannelList(channelListShare);
|
|
||||||
Set<Group> deleteGroup = deleteEmptyGroup(groupSet, platformId);
|
|
||||||
if (!deleteGroup.isEmpty()) {
|
|
||||||
for (Group group : deleteGroup) {
|
|
||||||
channelListShare.add(0, CommonGBChannel.build(group));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 发送消息
|
|
||||||
try {
|
|
||||||
// 发送catalog
|
|
||||||
eventPublisher.catalogEventPublish(platform, channelListShare, CatalogEvent.DEL);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("[移除全部关联通道] 发送失败,数量:{}", channelListShare.size(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -494,6 +469,44 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
removeChannels(platformId, channelList);
|
removeChannels(platformId, channelList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T> List<List<T>> partition(List<T> list, int size) {
|
||||||
|
List<List<T>> result = new ArrayList<>();
|
||||||
|
for (int i = 0; i < list.size(); i += size) {
|
||||||
|
result.add(list.subList(i, Math.min(i + size, list.size())));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int removeChannelsFromDb(Platform platform, Integer platformId, List<CommonGBChannel> channelList) {
|
||||||
|
List<List<CommonGBChannel>> batches = partition(channelList, BATCH_SIZE);
|
||||||
|
int totalResult = 0;
|
||||||
|
for (List<CommonGBChannel> batch : batches) {
|
||||||
|
totalResult += platformChannelMapper.removeChannelsWithPlatform(platformId, batch);
|
||||||
|
}
|
||||||
|
if (totalResult > 0) {
|
||||||
|
Set<Region> regionSet = regionMapper.queryByChannelList(channelList);
|
||||||
|
Set<Region> deleteRegion = deleteEmptyRegion(regionSet, platformId);
|
||||||
|
if (!deleteRegion.isEmpty()) {
|
||||||
|
for (Region region : deleteRegion) {
|
||||||
|
channelList.add(0, CommonGBChannel.build(region));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Set<Group> groupSet = groupMapper.queryByChannelList(channelList);
|
||||||
|
Set<Group> deleteGroup = deleteEmptyGroup(groupSet, platformId);
|
||||||
|
if (!deleteGroup.isEmpty()) {
|
||||||
|
for (Group group : deleteGroup) {
|
||||||
|
channelList.add(0, CommonGBChannel.build(group));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
eventPublisher.catalogEventPublish(platform, channelList, CatalogEvent.DEL);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("[取消共享通道] 发送失败,数量:{}", channelList.size(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalResult;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public int removeChannelList(Integer platformId, List<CommonGBChannel> channelList) {
|
public int removeChannelList(Integer platformId, List<CommonGBChannel> channelList) {
|
||||||
Platform platform = platformMapper.query(platformId);
|
Platform platform = platformMapper.query(platformId);
|
||||||
@ -513,36 +526,12 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
String deviceIds = channelList.stream().map(CommonGBChannel::getGbDeviceId).collect(Collectors.joining(","));
|
int result = removeChannelsFromDb(platform, platformId, channelList);
|
||||||
int result = platformChannelMapper.removeChannelsWithPlatform(platformId, channelList);
|
|
||||||
if (result <= 0) {
|
if (result <= 0) {
|
||||||
|
String deviceIds = channelList.stream().map(CommonGBChannel::getGbDeviceId).collect(Collectors.joining(","));
|
||||||
log.info("[取消共享通道] 平台{}未关联通道: {}", platformId, deviceIds);
|
log.info("[取消共享通道] 平台{}未关联通道: {}", platformId, deviceIds);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// 查询通道相关的分组信息
|
|
||||||
Set<Region> regionSet = regionMapper.queryByChannelList(channelList);
|
|
||||||
Set<Region> deleteRegion = deleteEmptyRegion(regionSet, platformId);
|
|
||||||
if (!deleteRegion.isEmpty()) {
|
|
||||||
for (Region region : deleteRegion) {
|
|
||||||
channelList.add(0, CommonGBChannel.build(region));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询通道相关的分组信息
|
|
||||||
Set<Group> groupSet = groupMapper.queryByChannelList(channelList);
|
|
||||||
Set<Group> deleteGroup = deleteEmptyGroup(groupSet, platformId);
|
|
||||||
if (!deleteGroup.isEmpty()) {
|
|
||||||
for (Group group : deleteGroup) {
|
|
||||||
channelList.add(0, CommonGBChannel.build(group));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 发送消息
|
|
||||||
try {
|
|
||||||
// 发送catalog
|
|
||||||
eventPublisher.catalogEventPublish(platform, channelList, CatalogEvent.DEL);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("[取消共享通道] 发送失败,数量:{}", channelList.size(), e);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -861,7 +861,9 @@ public class PlayServiceImpl implements IPlayService {
|
|||||||
log.info("[Invite 200OK] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse);
|
log.info("[Invite 200OK] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse);
|
||||||
String oldStreamId = String.format("%08x", Long.parseLong(ssrcInfo.getSsrc())).toUpperCase();
|
String oldStreamId = String.format("%08x", Long.parseLong(ssrcInfo.getSsrc())).toUpperCase();
|
||||||
String newStreamId = String.format("%08x", Long.parseLong(ssrcInResponse)).toUpperCase();
|
String newStreamId = String.format("%08x", Long.parseLong(ssrcInResponse)).toUpperCase();
|
||||||
receiveRtpServerService.refreshAuthenticateInfo(oldStreamId, newStreamId);
|
if (!mediaServerItem.isRtpEnable()) { // 多端口时按照端口绑定了stream,即使stream与ssrc不一致,也不会影响
|
||||||
|
receiveRtpServerService.refreshAuthenticateInfo(oldStreamId, newStreamId);
|
||||||
|
}
|
||||||
// ssrc 不一致
|
// ssrc 不一致
|
||||||
if (mediaServerItem.isRtpEnable()) {
|
if (mediaServerItem.isRtpEnable()) {
|
||||||
// 多端口
|
// 多端口
|
||||||
|
|||||||
@ -177,6 +177,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
|||||||
String sendSsrc = sendSsrcFactory.getSendSsrc(
|
String sendSsrc = sendSsrcFactory.getSendSsrc(
|
||||||
"Play".equalsIgnoreCase(finalInviteInfo.getSessionName()) ? "0" : "1");
|
"Play".equalsIgnoreCase(finalInviteInfo.getSessionName()) ? "0" : "1");
|
||||||
finalInviteInfo.setSsrc(sendSsrc);
|
finalInviteInfo.setSsrc(sendSsrc);
|
||||||
|
log.info("[上级INVITE] 使用自定义SSRC: {}", sendSsrc);
|
||||||
}
|
}
|
||||||
// 构建sendRTP内容
|
// 构建sendRTP内容
|
||||||
SendRtpInfo sendRtpItem = sendRtpServerService.createSendRtpInfo(streamInfo.getMediaServer(),
|
SendRtpInfo sendRtpItem = sendRtpServerService.createSendRtpInfo(streamInfo.getMediaServer(),
|
||||||
@ -224,8 +225,6 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
|||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
log.error("[命令发送失败] 上级INVITE 发送 200(SDP): {}", e.getMessage());
|
log.error("[命令发送失败] 上级INVITE 发送 200(SDP): {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user