修复集群推流BUG

This commit is contained in:
lin
2025-05-23 18:06:54 +08:00
parent 55f36f660b
commit 601d2b5d2b
4 changed files with 14 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.session;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -13,6 +14,7 @@ import java.util.Set;
/** /**
* ssrc使用 * ssrc使用
*/ */
@Slf4j
@Component @Component
public class SSRCFactory { public class SSRCFactory {
@@ -93,6 +95,7 @@ public class SSRCFactory {
String redisKey = SSRC_INFO_KEY + userSetting.getServerId() + "_" + mediaServerId; String redisKey = SSRC_INFO_KEY + userSetting.getServerId() + "_" + mediaServerId;
Long size = redisTemplate.opsForSet().size(redisKey); Long size = redisTemplate.opsForSet().size(redisKey);
if (size == null || size == 0) { if (size == null || size == 0) {
log.info("[获取 SSRC 失败] redisKey {}", redisKey);
throw new RuntimeException("ssrc已经用完"); throw new RuntimeException("ssrc已经用完");
} else { } else {
// 在集合中移除并返回一个随机成员。 // 在集合中移除并返回一个随机成员。

View File

@@ -172,10 +172,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
// 点播成功, TODO 可以在此处检测cancel命令是否存在存在则不发送 // 点播成功, TODO 可以在此处检测cancel命令是否存在存在则不发送
if (userSetting.getUseCustomSsrcForParentInvite()) { if (userSetting.getUseCustomSsrcForParentInvite()) {
// 上级平台点播时不使用上级平台指定的ssrc使用自定义的ssrc参考国标文档-点播外域设备媒体流SSRC处理方式 // 上级平台点播时不使用上级平台指定的ssrc使用自定义的ssrc参考国标文档-点播外域设备媒体流SSRC处理方式
String ssrc = "Play".equalsIgnoreCase(inviteInfo.getSessionName()) MediaServer mediaServer = mediaServerService.getOne(streamInfo.getMediaServer().getId());
if (mediaServer != null) {
String ssrc = "Play".equalsIgnoreCase(inviteInfo.getSessionName())
? ssrcFactory.getPlaySsrc(streamInfo.getMediaServer().getId()) ? ssrcFactory.getPlaySsrc(streamInfo.getMediaServer().getId())
: ssrcFactory.getPlayBackSsrc(streamInfo.getMediaServer().getId()); : ssrcFactory.getPlayBackSsrc(streamInfo.getMediaServer().getId());
inviteInfo.setSsrc(ssrc); inviteInfo.setSsrc(ssrc);
}
} }
// 构建sendRTP内容 // 构建sendRTP内容
SendRtpInfo sendRtpItem = sendRtpServerService.createSendRtpInfo(streamInfo.getMediaServer(), SendRtpInfo sendRtpItem = sendRtpServerService.createSendRtpInfo(streamInfo.getMediaServer(),

View File

@@ -181,7 +181,8 @@ public class RedisRpcStreamPushController extends RpcController {
*/ */
@RedisRpcMapping("play") @RedisRpcMapping("play")
public RedisRpcResponse play(RedisRpcRequest request) { public RedisRpcResponse play(RedisRpcRequest request) {
int id = Integer.parseInt(request.getParam().toString()); JSONObject paramJson = JSONObject.parseObject(request.getParam().toString());
int id = paramJson.getInteger("id");
RedisRpcResponse response = request.getResponse(); RedisRpcResponse response = request.getResponse();
if (id <= 0) { if (id <= 0) {
response.setStatusCode(ErrorCode.ERROR400.getCode()); response.setStatusCode(ErrorCode.ERROR400.getCode());

View File

@@ -194,7 +194,9 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
@Override @Override
public void playPush(String serverId, Integer id, ErrorCallback<StreamInfo> callback) { public void playPush(String serverId, Integer id, ErrorCallback<StreamInfo> callback) {
RedisRpcRequest request = buildRequest("streamPush/play", id + ""); JSONObject jsonObject = new JSONObject();
jsonObject.put("id", id);
RedisRpcRequest request = buildRequest("streamPush/play", jsonObject);
request.setToId(serverId); request.setToId(serverId);
RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout(), TimeUnit.SECONDS); RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout(), TimeUnit.SECONDS);
if (response == null) { if (response == null) {