Pre Merge pull request !29 from smy000/master

This commit is contained in:
smy000 2024-06-13 10:13:40 +00:00 committed by Gitee
commit deb9a9c74f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 73 additions and 10 deletions

View File

@ -14,6 +14,11 @@ public interface IInviteStreamService {
*/ */
void updateInviteInfo(InviteInfo inviteInfo); void updateInviteInfo(InviteInfo inviteInfo);
/**
* 新增点播的状态信息
*/
void insertInviteInfo(InviteInfo inviteInfo);
InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream); InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream);
/** /**
@ -31,6 +36,16 @@ public interface IInviteStreamService {
String deviceId, String deviceId,
String channelId, String channelId,
String stream); 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); 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 @Override
public InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream) { 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 @Override
public void removeInviteInfoByDeviceAndChannel(InviteSessionType inviteSessionType, String deviceId, String channelId) { public void removeInviteInfoByDeviceAndChannel(InviteSessionType inviteSessionType, String deviceId, String channelId) {
removeInviteInfo(inviteSessionType, deviceId, channelId, null); removeInviteInfo(inviteSessionType, deviceId, channelId, null);

View File

@ -918,7 +918,26 @@ public class PlayServiceImpl implements IPlayService {
} }
} }
}else { }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(), SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(inviteInfo.getDeviceId(),
@ -931,7 +950,6 @@ public class PlayServiceImpl implements IPlayService {
} }
} }
} }
}