From cbd6a57e15a0637095b577d6d716a99f724f952a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 16 Oct 2024 17:53:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=AD=E9=9F=B3=E5=AF=B9?= =?UTF-8?q?=E8=AE=B2=E6=8E=A5=E5=8F=A3=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/controller/PlayController.java | 5 +++-- .../iot/vmp/gb28181/service/IPlayService.java | 2 +- .../vmp/gb28181/service/impl/PlayServiceImpl.java | 13 ++++--------- .../media/service/impl/MediaServerServiceImpl.java | 7 ++++++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java index b4519c43..8c53ca62 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java @@ -211,11 +211,12 @@ public class PlayController { if (device == null) { throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到设备: " + deviceId); } - if (channelId == null) { + DeviceChannel channel = deviceChannelService.getOneForSource(device.getId(), channelId); + if (channel == null) { throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到通道: " + channelId); } - return playService.audioBroadcast(device, channelId, broadcastMode); + return playService.audioBroadcast(device, channel, broadcastMode); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java index 80e063b3..7f8bc014 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java @@ -38,7 +38,7 @@ public interface IPlayService { void zlmServerOnline(String mediaServerId); - AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode); + AudioBroadcastResult audioBroadcast(Device device, DeviceChannel deviceChannel, Boolean broadcastMode); boolean audioBroadcastCmd(Device device, DeviceChannel channel, MediaServer mediaServerItem, String app, String stream, int timeout, boolean isFromPlatform, AudioBroadcastEvent event) throws InvalidArgumentException, ParseException, SipException; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index f5076be9..04fdd0b9 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -1197,23 +1197,18 @@ public class PlayServiceImpl implements IPlayService { } @Override - public AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode) { + public AudioBroadcastResult audioBroadcast(Device device, DeviceChannel deviceChannel, Boolean broadcastMode) { // TODO 必须多端口模式才支持语音喊话鹤语音对讲 - if (device == null || channelId == null) { - return null; - } - log.info("[语音喊话] device: {}, channel: {}", device.getDeviceId(), channelId); - DeviceChannel deviceChannel = deviceChannelService.getOne(device.getDeviceId(), channelId); - if (deviceChannel == null) { - log.warn("开启语音广播的时候未找到通道: {}", channelId); + if (device == null || deviceChannel == null) { return null; } + log.info("[语音喊话] device: {}, channel: {}", device.getDeviceId(), deviceChannel.getDeviceId()); MediaServer mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null); if (broadcastMode == null) { broadcastMode = true; } String app = broadcastMode?"broadcast":"talk"; - String stream = device.getDeviceId() + "_" + channelId; + String stream = device.getDeviceId() + "_" + deviceChannel.getDeviceId(); AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult(); audioBroadcastResult.setApp(app); audioBroadcastResult.setStream(stream); diff --git a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java index c1b560fe..59c9e229 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java @@ -795,7 +795,12 @@ public class MediaServerServiceImpl implements IMediaServerService { } streamInfoResult.setIp(addr); - streamInfoResult.setServerId(mediaInfo.getServerId()); + if (mediaInfo != null) { + streamInfoResult.setServerId(mediaInfo.getServerId()); + }else { + streamInfoResult.setServerId(userSetting.getServerId()); + } + streamInfoResult.setMediaServer(mediaServer); String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId; streamInfoResult.setRtmp(addr, mediaServer.getRtmpPort(),mediaServer.getRtmpSSlPort(), app, stream, callIdParam);