优化无人观看判断逻辑

This commit is contained in:
lin 2026-04-15 12:58:52 +08:00
parent 1e5ae10571
commit f961d6fc8d

View File

@ -3,12 +3,10 @@ package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.common.InviteInfo;
import com.genersoft.iot.vmp.common.InviteSessionStatus;
import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.common.enums.MediaStreamUtil;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.gb28181.session.SipInviteSessionManager;
@ -18,15 +16,15 @@ import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.bean.ResultForOnPublish;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IReceiveRtpServerService;
import com.genersoft.iot.vmp.service.IRecordPlanService;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.MediaServerUtils;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.OtherPsSendInfo;
import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
@ -154,57 +152,63 @@ public class MediaServiceImpl implements IMediaService {
return false;
}
// 国标类型的流
if (MediaStreamUtil.RTP_APP.equals(app)) {
result = userSetting.getStreamOnDemand();
// 国标流 点播/录像回放/录像下载
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, stream);
if (inviteInfo != null) {
if (inviteInfo.getStatus() == InviteSessionStatus.ok){
// 录像下载
if (inviteInfo.getType() == InviteSessionType.DOWNLOAD) {
return false;
switch (app) {
case MediaStreamUtil.RTP_APP -> {
result = userSetting.getStreamOnDemand();
if (MediaStreamUtil.isGB28181(app, stream)) {
// 国标流 点播/录像回放/录像下载
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, stream);
if (inviteInfo != null) {
if (inviteInfo.getStatus() == InviteSessionStatus.ok) {
// 录像下载
if (inviteInfo.getType() == InviteSessionType.DOWNLOAD) {
return false;
}
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(inviteInfo.getChannelId());
if (deviceChannel == null) {
return false;
}
}
}
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(inviteInfo.getChannelId());
if (deviceChannel == null) {
return false;
return result;
} else if (MediaStreamUtil.isJT1078(app, stream)) {
// 判断是否是1078播放类型
JTMediaStreamType jtMediaStreamType = ijt1078Service.checkStreamFromJt(stream);
if (jtMediaStreamType != null) {
String[] streamParamArray = stream.split("_");
if (jtMediaStreamType.equals(JTMediaStreamType.PLAY)) {
jt1078PlayService.stopPlay(streamParamArray[0], Integer.parseInt(streamParamArray[1]));
} else if (jtMediaStreamType.equals(JTMediaStreamType.PLAYBACK)) {
jt1078PlayService.stopPlayback(streamParamArray[0], Integer.parseInt(streamParamArray[1]));
}
}
}
return result;
}
}else if (MediaStreamUtil.RTP_APP.equals(app)) {
// 判断是否是1078播放类型
JTMediaStreamType jtMediaStreamType = ijt1078Service.checkStreamFromJt(stream);
if (jtMediaStreamType != null) {
String[] streamParamArray = stream.split("_");
if (jtMediaStreamType.equals(JTMediaStreamType.PLAY)) {
jt1078PlayService.stopPlay(streamParamArray[0], Integer.parseInt(streamParamArray[1]));
}else if (jtMediaStreamType.equals(JTMediaStreamType.PLAYBACK)) {
jt1078PlayService.stopPlayback(streamParamArray[0], Integer.parseInt(streamParamArray[1]));
}
}else {
return false;
}
}else if (MediaStreamUtil.GB28181_TALK.equals(app) || MediaStreamUtil.GB28181_BROADCAST.equals(app)) {
return false;
} else if (MediaStreamUtil.LOAD_MP4_APP.equals(app)) {
return true;
} else {
// 非国标流 推流/拉流代理
// 拉流代理
StreamProxy streamProxy = streamProxyService.getStreamProxyByAppAndStream(app, stream);
if (streamProxy != null) {
if (streamProxy.isEnableDisableNoneReader()) {
// 无人观看停用
// 修改数据
streamProxyService.stopByAppAndStream(app, stream);
return true;
} else {
// 无人观看不做处理
return false;
}
}else {
}
case MediaStreamUtil.GB28181_TALK, MediaStreamUtil.GB28181_BROADCAST -> {
return false;
}
case MediaStreamUtil.LOAD_MP4_APP -> {
return true;
}
case null, default -> {
// 非国标流 推流/拉流代理
// 拉流代理
StreamProxy streamProxy = streamProxyService.getStreamProxyByAppAndStream(app, stream);
if (streamProxy != null) {
if (streamProxy.isEnableDisableNoneReader()) {
// 无人观看停用
// 修改数据
streamProxyService.stopByAppAndStream(app, stream);
return true;
} else {
// 无人观看不做处理
return false;
}
} else {
return false;
}
}
}
return result;
}