解决单端口兼容宇视平台

This commit is contained in:
smy 2024-04-17 17:31:59 +08:00
parent 3cd3e97cd7
commit 24c3f459f2
3 changed files with 73 additions and 10 deletions

View File

@ -14,6 +14,11 @@ public interface IInviteStreamService {
*/
void updateInviteInfo(InviteInfo inviteInfo);
/**
* 新增点播的状态信息
*/
void insertInviteInfo(InviteInfo inviteInfo);
InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream);
/**
@ -31,6 +36,16 @@ public interface IInviteStreamService {
String deviceId,
String channelId,
String stream);
/**
* 移除点播的状态信息
*/
void removeInviteInfo(InviteSessionType type,
String deviceId,
String channelId,
String stream,
String ssrc);
/**
* 移除点播的状态信息
*/

View File

@ -121,6 +121,23 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
redisTemplate.opsForValue().set(key, inviteInfoForUpdate);
}
@Override
public void insertInviteInfo(InviteInfo inviteInfo) {
if (inviteInfo == null || (inviteInfo.getDeviceId() == null || inviteInfo.getChannelId() == null)) {
logger.warn("[更新Invite信息],参数不全: {}", JSON.toJSON(inviteInfo));
return;
}
InviteInfo inviteInfoForUpdate = inviteInfo;
String key = VideoManagerConstants.INVITE_PREFIX +
":" + inviteInfoForUpdate.getType() +
":" + inviteInfoForUpdate.getDeviceId() +
":" + inviteInfoForUpdate.getChannelId() +
":" + inviteInfoForUpdate.getStream()+
":" + inviteInfoForUpdate.getSsrcInfo().getSsrc();
redisTemplate.opsForValue().set(key, inviteInfoForUpdate);
}
@Override
public InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream) {
@ -194,6 +211,19 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
}
}
@Override
public void removeInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream, String ssrc) {
String key = VideoManagerConstants.INVITE_PREFIX +
":" + (type != null ? type : "*") +
":" + (deviceId != null ? deviceId : "*") +
":" + (channelId != null ? channelId : "*") +
":" + (stream != null ? stream : "*") +
":" + (ssrc != null ? ssrc : "*");
logger.warn("删除指定key:{}", key);
redisTemplate.delete(key);
}
@Override
public void removeInviteInfoByDeviceAndChannel(InviteSessionType inviteSessionType, String deviceId, String channelId) {
removeInviteInfo(inviteSessionType, deviceId, channelId, null);

View File

@ -921,7 +921,26 @@ public class PlayServiceImpl implements IPlayService {
}
}
}else {
if (ssrcInResponse != null) {
//1.将ssrc释放回队列
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
//2.redis中获取此ssrc的数据
InviteInfo inviteInfoBySSRC = inviteStreamService.getInviteInfoBySSRC(ssrcInfo.getSsrc());
//3.如果redis中有此数据则删除+替换ssrc
if(inviteInfoBySSRC != null){
//删除
inviteStreamService.removeInviteInfo(
InviteSessionType.PLAY,
inviteInfoBySSRC.getDeviceId(),
inviteInfoBySSRC.getChannelId(),
inviteInfoBySSRC.getStream(),
ssrcInfo.getSsrc());
//添加
ssrcInfo.setSsrc(ssrcInResponse);
inviteInfo.setSsrcInfo(ssrcInfo);
inviteInfo.setStream(ssrcInfo.getStream());
inviteStreamService.insertInviteInfo(inviteInfoBySSRC);
}
// 单端口
// 重新订阅流上线
SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(inviteInfo.getDeviceId(),
@ -934,7 +953,6 @@ public class PlayServiceImpl implements IPlayService {
}
}
}
}