临时提交

This commit is contained in:
648540858
2024-12-23 07:20:48 +08:00
parent 825daad355
commit 19453f7ca9
17 changed files with 101 additions and 59 deletions

View File

@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.gb28181.service.impl;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.InviteInfo;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
@@ -33,7 +34,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
@Override
public void start(CommonGBChannel channel, InviteInfo inviteInfo, Platform platform, ErrorCallback<StreamInfo> callback) {
if (channel == null || inviteInfo == null || callback == null) {
if (channel == null || inviteInfo == null || callback == null || channel.getDataType() == null) {
log.warn("[通用通道点播] 参数异常, channel: {}, inviteInfo: {}, callback: {}", channel != null, inviteInfo != null, callback != null);
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
@@ -41,14 +42,14 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
if ("Play".equalsIgnoreCase(inviteInfo.getSessionName())) {
play(channel, platform, callback);
}else if ("Playback".equals(inviteInfo.getSessionName())) {
if (channel.getGbDeviceDbId() != null) {
if (channel.getDataType() == ChannelDataType.GB28181.value) {
// 国标通道
playbackGbDeviceChannel(channel, inviteInfo.getStartTime(), inviteInfo.getStopTime(), callback);
} else if (channel.getStreamProxyId() != null) {
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY.value) {
// 拉流代理
log.warn("[回放通用通道] 不支持回放拉流代理的录像: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.FORBIDDEN, "forbidden");
} else if (channel.getStreamPushId() != null) {
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH.value) {
// 推流
log.warn("[回放通用通道] 不支持回放推流的录像: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.FORBIDDEN, "forbidden");
@@ -58,7 +59,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() != null) {
if (channel.getDataType() == ChannelDataType.GB28181.value) {
int downloadSpeed = 4;
try {
if (inviteInfo.getDownloadSpeed() != null){
@@ -68,11 +69,11 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
// 国标通道
downloadGbDeviceChannel(channel, inviteInfo.getStartTime(), inviteInfo.getStopTime(), downloadSpeed, callback);
} else if (channel.getStreamProxyId() != null) {
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY.value) {
// 拉流代理
log.warn("[下载通用通道录像] 不支持下载拉流代理的录像: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.FORBIDDEN, "forbidden");
} else if (channel.getStreamPushId() != null) {
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH.value) {
// 推流
log.warn("[下载通用通道录像] 不支持下载推流的录像: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.FORBIDDEN, "forbidden");
@@ -90,13 +91,13 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
@Override
public void play(CommonGBChannel channel, Platform platform, ErrorCallback<StreamInfo> callback) {
if (channel.getGbDeviceDbId() != null) {
if (channel.getDataType() == ChannelDataType.GB28181.value) {
// 国标通道
playGbDeviceChannel(channel, callback);
} else if (channel.getStreamProxyId() != null) {
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY.value) {
// 拉流代理
playProxy(channel, callback);
} else if (channel.getStreamPushId() != null) {
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH.value) {
if (platform != null) {
// 推流
playPush(channel, platform.getServerGBId(), platform.getName(), callback);
@@ -128,7 +129,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
public void playProxy(CommonGBChannel channel, ErrorCallback<StreamInfo> callback){
// 拉流代理通道
try {
StreamInfo streamInfo = streamProxyPlayService.start(channel.getStreamProxyId());
StreamInfo streamInfo = streamProxyPlayService.start(channel.getDataDeviceId());
if (streamInfo == null) {
callback.run(Response.BUSY_HERE, "busy here", null);
}else {
@@ -143,7 +144,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
public void playPush(CommonGBChannel channel, String platformDeviceId, String platformName, ErrorCallback<StreamInfo> callback){
// 推流
try {
streamPushPlayService.start(channel.getStreamPushId(), callback, platformDeviceId, platformName);
streamPushPlayService.start(channel.getDataDeviceId(), callback, platformDeviceId, platformName);
}catch (PlayException e) {
callback.run(e.getCode(), e.getMsg(), null);
}catch (Exception e) {

View File

@@ -53,7 +53,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public int add(CommonGBChannel commonGBChannel) {
if (commonGBChannel.getStreamPushId() != null && commonGBChannel.getStreamPushId() > 0) {
if (commonGBChannel.getDataType() != null && commonGBChannel.getDataDeviceId() > 0) {
CommonGBChannel commonGBChannelInDb = commonGBChannelMapper.queryByStreamPushId(commonGBChannel.getStreamPushId());
if (commonGBChannelInDb != null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "此推流已经关联通道");

View File

@@ -1648,7 +1648,7 @@ public class PlayServiceImpl implements IPlayService {
@Override
public void play(CommonGBChannel channel, ErrorCallback<StreamInfo> callback) {
Device device = deviceService.getDevice(channel.getGbDeviceDbId());
Device device = deviceService.getDevice(channel.getDataDeviceId());
if (device == null) {
log.warn("[点播] 未找到通道{}的设备信息", channel);
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
@@ -1668,7 +1668,7 @@ public class PlayServiceImpl implements IPlayService {
throw new PlayException(Response.BAD_REQUEST, "bad request");
}
// 国标通道
Device device = deviceService.getDevice(channel.getGbDeviceDbId());
Device device = deviceService.getDevice(channel.getDataDeviceId());
if (device == null) {
log.warn("[点播] 未找到通道{}的设备信息", channel);
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
@@ -1689,7 +1689,7 @@ public class PlayServiceImpl implements IPlayService {
throw new PlayException(Response.BAD_REQUEST, "bad request");
}
// 国标通道
Device device = deviceService.getDevice(channel.getGbDeviceDbId());
Device device = deviceService.getDevice(channel.getDataDeviceId());
if (device == null) {
log.warn("[点播] 未找到通道{}的设备信息", channel);
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");