同步主线的代码,保持一致性

pull/893/head
‘sxh’ 2023-06-15 11:20:43 +08:00
parent 652489b47e
commit ccc0a99d68
3 changed files with 17 additions and 50 deletions

View File

@ -520,13 +520,13 @@ public class ZLMHttpHookListener {
// 拉流代理 // 拉流代理
StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream());
if (streamProxyItem != null) { if (streamProxyItem != null) {
if (streamProxyItem.isEnable_remove_none_reader()) { if (streamProxyItem.isEnableDisableNoneReader()) {
// 无人观看自动移除 // 无人观看自动移除
ret.put("close", true); ret.put("close", true);
streamProxyService.del(param.getApp(), param.getStream()); streamProxyService.del(param.getApp(), param.getStream());
String url = streamProxyItem.getUrl() != null ? streamProxyItem.getUrl() : streamProxyItem.getSrc_url(); String url = streamProxyItem.getUrl() != null ? streamProxyItem.getUrl() : streamProxyItem.getSrcUrl();
logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", param.getApp(), param.getStream(), url); logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", param.getApp(), param.getStream(), url);
} else if (streamProxyItem.isEnable_disable_none_reader()) { } else if (streamProxyItem.isEnableDisableNoneReader()) {
// 无人观看停用 // 无人观看停用
ret.put("close", true); ret.put("close", true);
// 修改数据 // 修改数据
@ -625,7 +625,7 @@ public class ZLMHttpHookListener {
} else { } else {
// 拉流代理 // 拉流代理
StreamProxyItem streamProxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); StreamProxyItem streamProxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream());
if (streamProxyByAppAndStream != null && streamProxyByAppAndStream.isEnable_disable_none_reader()) { if (streamProxyByAppAndStream != null && streamProxyByAppAndStream.isEnableDisableNoneReader()) {
streamProxyService.start(param.getApp(), param.getStream()); streamProxyService.start(param.getApp(), param.getStream());
} }
DeferredResult<HookResult> result = new DeferredResult<>(); DeferredResult<HookResult> result = new DeferredResult<>();

View File

@ -593,11 +593,13 @@ public class DeviceServiceImpl implements IDeviceService {
if(deviceInStore.isSwitchPrimarySubStream() != device.isSwitchPrimarySubStream()){ if(deviceInStore.isSwitchPrimarySubStream() != device.isSwitchPrimarySubStream()){
//当修改设备的主子码流开关时,需要校验是否存在流,如果存在流则直接关闭 //当修改设备的主子码流开关时,需要校验是否存在流,如果存在流则直接关闭
List<SsrcTransaction> ssrcTransactionForAll = streamSession.getSsrcTransactionForAll(device.getDeviceId(), null, null, null); List<SsrcTransaction> ssrcTransactionForAll = streamSession.getSsrcTransactionForAll(device.getDeviceId(), null, null, null);
for (SsrcTransaction ssrcTransaction: ssrcTransactionForAll) { if(ssrcTransactionForAll != null){
try { for (SsrcTransaction ssrcTransaction: ssrcTransactionForAll) {
cmder.streamByeCmd(device, ssrcTransaction.getChannelId(), ssrcTransaction.getStream(), null, null); try {
} catch (InvalidArgumentException | SsrcTransactionNotFoundException | ParseException | SipException e) { cmder.streamByeCmd(device, ssrcTransaction.getChannelId(), ssrcTransaction.getStream(), null, null);
throw new RuntimeException(e); } catch (InvalidArgumentException | SsrcTransactionNotFoundException | ParseException | SipException e) {
throw new RuntimeException(e);
}
} }
} }
deviceChannelMapper.clearPlay(device.getDeviceId()); deviceChannelMapper.clearPlay(device.getDeviceId());

View File

@ -428,27 +428,8 @@ public class PlayServiceImpl implements IPlayService {
logger.info("[点播消息] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse); logger.info("[点播消息] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse);
if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) { if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) {
logger.info("[点播消息] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse); logger.info("[点播消息] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse);
if (!ssrcFactory.checkSsrc(mediaServerItem.getId(),ssrcInResponse)) { // 释放ssrc
// ssrc 不可用 mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
logger.info("[点播消息] SSRC修正时发现ssrc不可使用 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse);
// 释放ssrc
ssrcFactory.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
callback.run(InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getCode(),
InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getMsg(), null);
if( device.isSwitchPrimarySubStream()){
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId,isSubStream, null,
InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getCode(),
InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getMsg(), null);
}else {
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null,
InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getCode(),
InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getMsg(), null);
}
return;
}
// 单端口模式streamId也有变化重新设置监听即可 // 单端口模式streamId也有变化重新设置监听即可
if (!mediaServerItem.isRtpEnable()) { if (!mediaServerItem.isRtpEnable()) {
// 添加订阅 // 添加订阅
@ -812,17 +793,8 @@ public class PlayServiceImpl implements IPlayService {
if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) { if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) {
logger.info("[录像回放] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse); logger.info("[录像回放] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse);
if (!ssrcFactory.checkSsrc(mediaServerItem.getId(),ssrcInResponse)) { // 释放ssrc
// ssrc 不可用 mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
logger.info("[录像回放] SSRC修正时发现ssrc不可使用 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse);
// 释放ssrc
dynamicTask.stop(playBackTimeOutTaskKey);
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
callback.run(InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getCode(),
InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getMsg(), null);
return;
}
// 单端口模式streamId也有变化需要重新设置监听 // 单端口模式streamId也有变化需要重新设置监听
if (!mediaServerItem.isRtpEnable()) { if (!mediaServerItem.isRtpEnable()) {
@ -1016,15 +988,8 @@ public class PlayServiceImpl implements IPlayService {
if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) { if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) {
logger.info("[录像下载] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse); logger.info("[录像下载] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse);
if (!ssrcFactory.checkSsrc(mediaServerItem.getId(),ssrcInResponse)) { // 释放ssrc
// ssrc 不可用 mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
// 释放ssrc
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
callback.run(InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getCode(),
InviteErrorCode.ERROR_FOR_SSRC_UNAVAILABLE.getMsg(), null);
return;
}
// 单端口模式streamId也有变化需要重新设置监听 // 单端口模式streamId也有变化需要重新设置监听
if (!mediaServerItem.isRtpEnable()) { if (!mediaServerItem.isRtpEnable()) {