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 86215f95..c9921065 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 @@ -51,7 +51,7 @@ public interface IPlayService { void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException; - void startPushStream(SendRtpInfo sendRtpItem, SIPResponse sipResponse, Platform platform, CallIdHeader callIdHeader); + void startPushStream(SendRtpInfo sendRtpItem, DeviceChannel channel, SIPResponse sipResponse, Platform platform, CallIdHeader callIdHeader); void startSendRtpStreamFailHand(SendRtpInfo sendRtpItem, Platform platform, CallIdHeader callIdHeader); 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 1e1990b0..a353ae7a 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 @@ -1414,7 +1414,7 @@ public class PlayServiceImpl implements IPlayService { } @Override - public void startPushStream(SendRtpInfo sendRtpItem, SIPResponse sipResponse, Platform platform, CallIdHeader callIdHeader) { + public void startPushStream(SendRtpInfo sendRtpItem, DeviceChannel channel, SIPResponse sipResponse, Platform platform, CallIdHeader callIdHeader) { // 开始发流 MediaServer mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); @@ -1425,7 +1425,7 @@ public class PlayServiceImpl implements IPlayService { } else { mediaServerService.startSendRtp(mediaInfo, sendRtpItem); } - redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, platform); + redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, channel, platform); }catch (ControllerException e) { log.error("RTP推流失败: {}", e.getMessage()); startSendRtpStreamFailHand(sendRtpItem, platform, callIdHeader); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java index ac9d11b1..d91910b3 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java @@ -4,8 +4,10 @@ import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.service.IPlatformService; import com.genersoft.iot.vmp.gb28181.service.IPlayService; @@ -63,6 +65,9 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In @Autowired private IDeviceService deviceService; + @Autowired + private IDeviceChannelService deviceChannelService; + @Autowired private IMediaServerService mediaServerService; @@ -103,11 +108,13 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In ); Platform parentPlatform = platformService.queryPlatformByServerGBId(fromUserId); + if (parentPlatform != null) { + DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpItem.getChannelId()); if (!userSetting.getServerId().equals(sendRtpItem.getServerId())) { WVPResult wvpResult = redisRpcService.startSendRtp(sendRtpItem.getRedisKey(), sendRtpItem); if (wvpResult.getCode() == 0) { - redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, parentPlatform); + redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, deviceChannel, parentPlatform); } } else { try { @@ -116,7 +123,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In } else { mediaServerService.startSendRtp(mediaInfo, sendRtpItem); } - redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, parentPlatform); + redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, deviceChannel, parentPlatform); }catch (ControllerException e) { log.error("RTP推流失败: {}", e.getMessage()); playService.startSendRtpStreamFailHand(sendRtpItem, parentPlatform, callIdHeader); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index c336fec7..f713e1ef 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -217,7 +217,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId()); try { mediaServerService.startSendRtpPassive(mediaServer, sendRtpItem, 5); - redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, platform); + DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpItem.getChannelId()); + if (deviceChannel != null) { + redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, deviceChannel, platform); + } }catch (ControllerException e) { log.warn("[上级Invite] tcp主动模式 发流失败", e); sendBye(platform, inviteInfo.getCallId()); @@ -911,7 +914,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements Boolean streamReady = mediaServerService.isStreamReady(mediaServerItem, broadcastCatch.getApp(), broadcastCatch.getStream()); if (streamReady) { - sendOk(device, sendRtpItem, sdp, request, mediaServerItem, mediaTransmissionTCP, gb28181Sdp.getSsrc()); + sendOk(device, deviceChannel, sendRtpItem, sdp, request, mediaServerItem, mediaTransmissionTCP, gb28181Sdp.getSsrc()); } else { log.warn("[语音通话], 未发现待推送的流,app={},stream={}", broadcastCatch.getApp(), broadcastCatch.getStream()); try { @@ -937,7 +940,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } } - SIPResponse sendOk(Device device, SendRtpInfo sendRtpItem, SessionDescription sdp, SIPRequest request, MediaServer mediaServerItem, boolean mediaTransmissionTCP, String ssrc) { + SIPResponse sendOk(Device device, DeviceChannel channel, SendRtpInfo sendRtpItem, SessionDescription sdp, SIPRequest request, MediaServer mediaServerItem, boolean mediaTransmissionTCP, String ssrc) { SIPResponse sipResponse = null; try { sendRtpItem.setStatus(2); @@ -986,7 +989,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements // 开启发流,大华在收到200OK后就会开始建立连接 if (!device.isBroadcastPushAfterAck()) { log.info("[语音喊话] 回复200OK后发现 BroadcastPushAfterAck为False,现在开始推流"); - playService.startPushStream(sendRtpItem, sipResponse, parentPlatform, request.getCallIdHeader()); + playService.startPushStream(sendRtpItem, channel, sipResponse, parentPlatform, request.getCallIdHeader()); } } catch (SipException | InvalidArgumentException | ParseException | SdpParseException e) { diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java index 70b75e81..308dd95c 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -208,7 +208,7 @@ public interface IRedisCatchStorage { void sendChannelAddOrDelete(String deviceId, String channelId, boolean add); - void sendPlatformStartPlayMsg(SendRtpInfo sendRtpItem, Platform platform); + void sendPlatformStartPlayMsg(SendRtpInfo sendRtpItem, DeviceChannel channel, Platform platform); void sendPlatformStopPlayMsg(SendRtpInfo sendRtpItem, Platform platform, CommonGBChannel channel); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index b51d88bc..fb40b946 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -662,10 +662,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } @Override - public void sendPlatformStartPlayMsg(SendRtpInfo sendRtpItem, Platform platform) { + public void sendPlatformStartPlayMsg(SendRtpInfo sendRtpItem, DeviceChannel channel, Platform platform) { if (sendRtpItem.getPlayType() == InviteStreamType.PUSH && platform != null) { MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0, sendRtpItem.getApp(), sendRtpItem.getStream(), - sendRtpItem.getChannelId(), platform.getServerGBId(), platform.getName(), userSetting.getServerId(), + channel.getDeviceId(), platform.getServerGBId(), platform.getName(), userSetting.getServerId(), sendRtpItem.getMediaServerId()); messageForPushChannel.setPlatFormIndex(platform.getId()); String key = VideoManagerConstants.VM_MSG_STREAM_START_PLAY_NOTIFY;