From f7ed06e5f506dd65299fa2e0356a0e438305c7ee Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 28 Nov 2024 14:38:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=9A=E7=94=A8=E7=82=B9?= =?UTF-8?q?=E6=92=AD=E4=BB=A3=E7=A0=81=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CommonChannelController.java | 16 +------- .../service/IGbChannelPlayService.java | 2 + .../impl/GbChannelPlayServiceImpl.java | 38 ++++++++++++------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java index 6f5295da..44d11b0b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java @@ -240,21 +240,7 @@ public class CommonChannelController { result.setResult(WVPResult.fail(code, msg)); } }; - - if (channel.getGbDeviceDbId() != null) { - // 国标通道 - channelPlayService.playGbDeviceChannel(channel, callback); - } else if (channel.getStreamProxyId() != null) { - // 拉流代理 - channelPlayService.playProxy(channel, callback); - } else if (channel.getStreamPushId() != null) { - // 推流 - channelPlayService.playPush(channel, null, null, callback); - } else { - // 通道数据异常 - log.error("[点播通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); - } + channelPlayService.play(channel, null, callback); return result; } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java index 8abb0160..4f577939 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java @@ -10,6 +10,8 @@ public interface IGbChannelPlayService { void start(CommonGBChannel channel, InviteInfo inviteInfo, Platform platform, ErrorCallback callback); + void play(CommonGBChannel channel, Platform platform, ErrorCallback callback); + void playGbDeviceChannel(CommonGBChannel channel, ErrorCallback callback); void playProxy(CommonGBChannel channel, ErrorCallback callback); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java index 01f6ff8c..e0a736c7 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java @@ -39,20 +39,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { } log.info("[点播通用通道] 类型:{}, 通道: {}({})", inviteInfo.getSessionName(), channel.getGbName(), channel.getGbDeviceId()); if ("Play".equalsIgnoreCase(inviteInfo.getSessionName())) { - if (channel.getGbDeviceDbId() != null) { - // 国标通道 - playGbDeviceChannel(channel, callback); - } else if (channel.getStreamProxyId() != null) { - // 拉流代理 - playProxy(channel, callback); - } else if (channel.getStreamPushId() != null) { - // 推流 - playPush(channel, platform.getServerGBId(), platform.getName(), callback); - } else { - // 通道数据异常 - log.error("[点播通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); - } + play(channel, platform, callback); }else if ("Playback".equals(inviteInfo.getSessionName())) { if (channel.getGbDeviceDbId() != null) { // 国标通道 @@ -101,6 +88,29 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { } } + @Override + public void play(CommonGBChannel channel, Platform platform, ErrorCallback callback) { + if (channel.getGbDeviceDbId() != null) { + // 国标通道 + playGbDeviceChannel(channel, callback); + } else if (channel.getStreamProxyId() != null) { + // 拉流代理 + playProxy(channel, callback); + } else if (channel.getStreamPushId() != null) { + if (platform != null) { + // 推流 + playPush(channel, platform.getServerGBId(), platform.getName(), callback); + }else { + // 推流 + playPush(channel, null, null, callback); + } + } else { + // 通道数据异常 + log.error("[点播通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId()); + throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); + } + } + @Override public void playGbDeviceChannel(CommonGBChannel channel, ErrorCallback callback){ // 国标通道