Explorar el Código

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

648540858 hace 1 año
padre
commit
cbd6a57e15

+ 3 - 2
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);
 
 	}
 

+ 1 - 1
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;
 

+ 4 - 9
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);

+ 6 - 1
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);