修复语音对讲接口空指针异常

pull/1651/head
648540858 2024-10-16 17:53:14 +08:00
parent 2492b0d638
commit cbd6a57e15
4 changed files with 14 additions and 13 deletions

View File

@ -211,11 +211,12 @@ public class PlayController {
if (device == null) { if (device == null) {
throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到设备: " + deviceId); 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); throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到通道: " + channelId);
} }
return playService.audioBroadcast(device, channelId, broadcastMode); return playService.audioBroadcast(device, channel, broadcastMode);
} }

View File

@ -38,7 +38,7 @@ public interface IPlayService {
void zlmServerOnline(String mediaServerId); 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; boolean audioBroadcastCmd(Device device, DeviceChannel channel, MediaServer mediaServerItem, String app, String stream, int timeout, boolean isFromPlatform, AudioBroadcastEvent event) throws InvalidArgumentException, ParseException, SipException;

View File

@ -1197,23 +1197,18 @@ public class PlayServiceImpl implements IPlayService {
} }
@Override @Override
public AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode) { public AudioBroadcastResult audioBroadcast(Device device, DeviceChannel deviceChannel, Boolean broadcastMode) {
// TODO 必须多端口模式才支持语音喊话鹤语音对讲 // TODO 必须多端口模式才支持语音喊话鹤语音对讲
if (device == null || channelId == null) { if (device == null || deviceChannel == null) {
return null;
}
log.info("[语音喊话] device {}, channel: {}", device.getDeviceId(), channelId);
DeviceChannel deviceChannel = deviceChannelService.getOne(device.getDeviceId(), channelId);
if (deviceChannel == null) {
log.warn("开启语音广播的时候未找到通道: {}", channelId);
return null; return null;
} }
log.info("[语音喊话] device {}, channel: {}", device.getDeviceId(), deviceChannel.getDeviceId());
MediaServer mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null); MediaServer mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
if (broadcastMode == null) { if (broadcastMode == null) {
broadcastMode = true; broadcastMode = true;
} }
String app = broadcastMode?"broadcast":"talk"; String app = broadcastMode?"broadcast":"talk";
String stream = device.getDeviceId() + "_" + channelId; String stream = device.getDeviceId() + "_" + deviceChannel.getDeviceId();
AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult(); AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
audioBroadcastResult.setApp(app); audioBroadcastResult.setApp(app);
audioBroadcastResult.setStream(stream); audioBroadcastResult.setStream(stream);

View File

@ -795,7 +795,12 @@ public class MediaServerServiceImpl implements IMediaServerService {
} }
streamInfoResult.setIp(addr); streamInfoResult.setIp(addr);
streamInfoResult.setServerId(mediaInfo.getServerId()); if (mediaInfo != null) {
streamInfoResult.setServerId(mediaInfo.getServerId());
}else {
streamInfoResult.setServerId(userSetting.getServerId());
}
streamInfoResult.setMediaServer(mediaServer); streamInfoResult.setMediaServer(mediaServer);
String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId; String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId;
streamInfoResult.setRtmp(addr, mediaServer.getRtmpPort(),mediaServer.getRtmpSSlPort(), app, stream, callIdParam); streamInfoResult.setRtmp(addr, mediaServer.getRtmpPort(),mediaServer.getRtmpSSlPort(), app, stream, callIdParam);