完善国标级联点播推流,拉流代理,国标

This commit is contained in:
648540858
2024-08-17 22:31:13 +08:00
parent 20f93d52d7
commit 9247c7e805
13 changed files with 53 additions and 40 deletions

View File

@@ -12,6 +12,7 @@ import com.github.pagehelper.PageInfo;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
import java.util.List;
/**
* 国标平台的业务类
@@ -84,4 +85,8 @@ public interface IPlatformService {
void addSimulatedSubscribeInfo(Platform parentPlatform);
Platform queryOne(Integer platformId);
List<Platform> queryEnablePlatformList();
}

View File

@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.PlayException;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService;
import com.genersoft.iot.vmp.gb28181.service.IPlayService;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyPlayService;
import com.genersoft.iot.vmp.streamPush.service.IStreamPushPlayService;
import lombok.extern.slf4j.Slf4j;
@@ -38,13 +39,13 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
}
log.info("[点播通用通道] 类型:{} 通道: {}({})", inviteInfo.getSessionName(), channel.getGbName(), channel.getGbDeviceId());
if ("Play".equalsIgnoreCase(inviteInfo.getSessionName())) {
if (channel.getGbDeviceDbId() > 0) {
if (channel.getGbDeviceDbId() != null) {
// 国标通道
playGbDeviceChannel(channel, callback);
} else if (channel.getStreamProxyId() > 0) {
} else if (channel.getStreamProxyId() != null) {
// 拉流代理
playProxy(channel, callback);
} else if (channel.getStreamPushId() > 0) {
} else if (channel.getStreamPushId() != null) {
// 推流
playPush(channel, platform.getServerGBId(), platform.getName(), callback);
} else {
@@ -53,14 +54,14 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}else if ("Playback".equals(inviteInfo.getSessionName())) {
if (channel.getGbDeviceDbId() > 0) {
if (channel.getGbDeviceDbId() != null) {
// 国标通道
playbackGbDeviceChannel(channel, inviteInfo.getStartTime(), inviteInfo.getStopTime(), callback);
} else if (channel.getStreamProxyId() > 0) {
} else if (channel.getStreamProxyId() != null) {
// 拉流代理
log.warn("[回放通用通道] 不支持回放拉流代理的录像: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.FORBIDDEN, "forbidden");
} else if (channel.getStreamPushId() > 0) {
} else if (channel.getStreamPushId() != null) {
// 推流
log.warn("[回放通用通道] 不支持回放推流的录像: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.FORBIDDEN, "forbidden");
@@ -70,7 +71,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}else if ("Download".equals(inviteInfo.getSessionName())) {
if (channel.getGbDeviceDbId() > 0) {
if (channel.getGbDeviceDbId() != null) {
int downloadSpeed = 4;
try {
if (inviteInfo.getDownloadSpeed() != null){
@@ -80,11 +81,11 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
// 国标通道
downloadGbDeviceChannel(channel, inviteInfo.getStartTime(), inviteInfo.getStopTime(), downloadSpeed, callback);
} else if (channel.getStreamProxyId() > 0) {
} else if (channel.getStreamProxyId() != null) {
// 拉流代理
log.warn("[下载通用通道录像] 不支持下载拉流代理的录像: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.FORBIDDEN, "forbidden");
} else if (channel.getStreamPushId() > 0) {
} else if (channel.getStreamPushId() != null) {
// 推流
log.warn("[下载通用通道录像] 不支持下载推流的录像: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.FORBIDDEN, "forbidden");
@@ -107,6 +108,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
} catch (PlayException e) {
callback.run(e.getCode(), e.getMsg(), null);
} catch (Exception e) {
log.error("[点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e);
callback.run(Response.BUSY_HERE, "busy here", null);
}
}
@@ -118,7 +120,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
if (streamInfo == null) {
callback.run(Response.BUSY_HERE, "busy here", null);
}else {
callback.run(Response.OK, "success", streamInfo);
callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
}
}catch (Exception e) {
callback.run(Response.BUSY_HERE, "busy here", null);

View File

@@ -370,7 +370,6 @@ public class GbChannelServiceImpl implements IGbChannelService {
return channelList;
}
private Set<Group> getAllGroup(Set<Group> regionChannelList ) {
if (regionChannelList.isEmpty()) {
return new HashSet<>();

View File

@@ -43,6 +43,7 @@ import javax.sip.InvalidArgumentException;
import javax.sip.ResponseEvent;
import javax.sip.SipException;
import java.text.ParseException;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.Vector;
@@ -365,7 +366,7 @@ public class PlatformServiceImpl implements IPlatformService {
@Override
public void offline(Platform platform, boolean stopRegister) {
log.info("[平台离线]{}", platform.getServerGBId());
log.info("[平台离线]{}({})", platform.getName(), platform.getServerGBId());
PlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(platform.getServerGBId());
platformCatch.setKeepAliveReply(0);
platformCatch.setRegisterAliveReply(0);
@@ -376,17 +377,17 @@ public class PlatformServiceImpl implements IPlatformService {
platformMapper.updateStatus(platform.getServerGBId(), false);
// 停止所有推流
log.info("[平台离线] {}, 停止所有推流", platform.getServerGBId());
log.info("[平台离线] {}({}), 停止所有推流", platform.getName(), platform.getServerGBId());
stopAllPush(platform.getServerGBId());
// 清除注册定时
log.info("[平台离线] {}, 停止定时注册任务", platform.getServerGBId());
log.info("[平台离线] {}({}), 停止定时注册任务", platform.getName(), platform.getServerGBId());
final String registerTaskKey = REGISTER_KEY_PREFIX + platform.getServerGBId();
if (dynamicTask.contains(registerTaskKey)) {
dynamicTask.stop(registerTaskKey);
}
// 清除心跳定时
log.info("[平台离线] {}, 停止定时发送心跳任务", platform.getServerGBId());
log.info("[平台离线] {}({}), 停止定时发送心跳任务", platform.getName(), platform.getServerGBId());
final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + platform.getServerGBId();
if (dynamicTask.contains(keepaliveTaskKey)) {
// 清除心跳任务
@@ -396,11 +397,11 @@ public class PlatformServiceImpl implements IPlatformService {
SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());
if (catalogSubscribe != null) {
if (catalogSubscribe.getExpires() > 0) {
log.info("[平台离线] {}, 停止目录订阅回复", platform.getServerGBId());
log.info("[平台离线] {}({}), 停止目录订阅回复", platform.getName(), platform.getServerGBId());
subscribeHolder.removeCatalogSubscribe(platform.getServerGBId());
}
}
log.info("[平台离线] {}, 停止移动位置订阅回复", platform.getServerGBId());
log.info("[平台离线] {}({}), 停止移动位置订阅回复", platform.getName(), platform.getServerGBId());
subscribeHolder.removeMobilePositionSubscribe(platform.getServerGBId());
// 发起定时自动重新注册
if (!stopRegister) {
@@ -436,7 +437,7 @@ public class PlatformServiceImpl implements IPlatformService {
// 添加注册任务
dynamicTask.startCron(registerTaskKey,
// 注册失败注册成功时由程序直接调用了online方法
()-> log.info("[国标级联] {},平台离线后持续发起注册,失败", platform.getServerGBId()),
()-> log.info("[国标级联] {}({}),平台离线后持续发起注册,失败", platform.getName(), platform.getServerGBId()),
60*1000);
}, null);
} catch (InvalidArgumentException | ParseException | SipException e) {
@@ -809,4 +810,9 @@ public class PlatformServiceImpl implements IPlatformService {
public Platform queryOne(Integer platformId) {
return platformMapper.query(platformId);
}
@Override
public List<Platform> queryEnablePlatformList() {
return platformMapper.queryEnablePlatformList();
}
}