修复集群推流BUG
This commit is contained in:
@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.session;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -13,6 +14,7 @@ import java.util.Set;
|
||||
/**
|
||||
* ssrc使用
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SSRCFactory {
|
||||
|
||||
@@ -93,6 +95,7 @@ public class SSRCFactory {
|
||||
String redisKey = SSRC_INFO_KEY + userSetting.getServerId() + "_" + mediaServerId;
|
||||
Long size = redisTemplate.opsForSet().size(redisKey);
|
||||
if (size == null || size == 0) {
|
||||
log.info("[获取 SSRC 失败] redisKey: {}", redisKey);
|
||||
throw new RuntimeException("ssrc已经用完");
|
||||
} else {
|
||||
// 在集合中移除并返回一个随机成员。
|
||||
|
||||
@@ -172,10 +172,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
// 点播成功, TODO 可以在此处检测cancel命令是否存在,存在则不发送
|
||||
if (userSetting.getUseCustomSsrcForParentInvite()) {
|
||||
// 上级平台点播时不使用上级平台指定的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.getPlayBackSsrc(streamInfo.getMediaServer().getId());
|
||||
inviteInfo.setSsrc(ssrc);
|
||||
: ssrcFactory.getPlayBackSsrc(streamInfo.getMediaServer().getId());
|
||||
inviteInfo.setSsrc(ssrc);
|
||||
}
|
||||
}
|
||||
// 构建sendRTP内容
|
||||
SendRtpInfo sendRtpItem = sendRtpServerService.createSendRtpInfo(streamInfo.getMediaServer(),
|
||||
|
||||
@@ -181,7 +181,8 @@ public class RedisRpcStreamPushController extends RpcController {
|
||||
*/
|
||||
@RedisRpcMapping("play")
|
||||
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();
|
||||
if (id <= 0) {
|
||||
response.setStatusCode(ErrorCode.ERROR400.getCode());
|
||||
|
||||
@@ -194,7 +194,9 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
|
||||
|
||||
@Override
|
||||
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);
|
||||
RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout(), TimeUnit.SECONDS);
|
||||
if (response == null) {
|
||||
|
||||
Reference in New Issue
Block a user