| | |
| | | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServer; |
| | | import com.genersoft.iot.vmp.media.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.service.bean.*; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | |
| | | case WvpRedisMsgCmd.REQUEST_PUSH_STREAM: |
| | | RequestPushStreamMsg param = JSON.to(RequestPushStreamMsg.class, wvpRedisMsg.getContent()); |
| | | requestPushStreamMsgHand(param, wvpRedisMsg.getFromId(), wvpRedisMsg.getSerial()); |
| | | |
| | | break; |
| | | case WvpRedisMsgCmd.REQUEST_STOP_PUSH_STREAM: |
| | | RequestStopPushStreamMsg streamMsg = JSON.to(RequestStopPushStreamMsg.class, wvpRedisMsg.getContent()); |
| | | requestStopPushStreamMsgHand(streamMsg, wvpRedisMsg.getFromId(), wvpRedisMsg.getSerial()); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | * 处理收到的请求推流的请求 |
| | | */ |
| | | private void requestPushStreamMsgHand(RequestPushStreamMsg requestPushStreamMsg, String fromId, String serial) { |
| | | MediaServerItem mediaInfo = mediaServerService.getOne(requestPushStreamMsg.getMediaServerId()); |
| | | MediaServer mediaInfo = mediaServerService.getOne(requestPushStreamMsg.getMediaServerId()); |
| | | if (mediaInfo == null) { |
| | | // TODO 回复错误 |
| | | return; |
| | |
| | | * 处理收到的请求sendItem的请求 |
| | | */ |
| | | private void requestSendItemMsgHand(RequestSendItemMsg content, String toId, String serial) { |
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(content.getMediaServerId()); |
| | | MediaServer mediaServerItem = mediaServerService.getOne(content.getMediaServerId()); |
| | | if (mediaServerItem == null) { |
| | | logger.info("[回复推流信息] 流媒体{}不存在 ", content.getMediaServerId()); |
| | | |
| | |
| | | /** |
| | | * 将获取到的sendItem发送出去 |
| | | */ |
| | | private void responseSendItem(MediaServerItem mediaServerItem, RequestSendItemMsg content, String toId, String serial) { |
| | | private void responseSendItem(MediaServer mediaServerItem, RequestSendItemMsg content, String toId, String serial) { |
| | | SendRtpItem sendRtpItem = zlmServerFactory.createSendRtpItem(mediaServerItem, content.getIp(), |
| | | content.getPort(), content.getSsrc(), content.getPlatformId(), |
| | | content.getApp(), content.getStream(), content.getChannelId(), |
| | |
| | | redisTemplate.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | } |
| | | |
| | | /** |
| | | * 发送请求推流的消息 |
| | | */ |
| | | public void sendMsgForStopSendRtpStream(String serverId, RequestStopPushStreamMsg streamMsg) { |
| | | String key = UUID.randomUUID().toString(); |
| | | WvpRedisMsg redisMsg = WvpRedisMsg.getRequestInstance(userSetting.getServerId(), serverId, |
| | | WvpRedisMsgCmd.REQUEST_STOP_PUSH_STREAM, key, JSON.toJSONString(streamMsg)); |
| | | |
| | | JSONObject jsonObject = (JSONObject)JSON.toJSON(redisMsg); |
| | | logger.info("[REDIS 请求其他平台停止推流] {}: {}", serverId, jsonObject); |
| | | redisTemplate.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | } |
| | | |
| | | private SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId) { |
| | | if (platformGbId == null) { |
| | | platformGbId = "*"; |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理收到的请求推流的请求 |
| | | */ |
| | | private void requestStopPushStreamMsgHand(RequestStopPushStreamMsg streamMsg, String fromId, String serial) { |
| | | SendRtpItem sendRtpItem = streamMsg.getSendRtpItem(); |
| | | if (sendRtpItem == null) { |
| | | logger.info("[REDIS 执行其他平台的请求停止推流] 失败: sendRtpItem为NULL"); |
| | | return; |
| | | } |
| | | MediaServer mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); |
| | | if (mediaInfo == null) { |
| | | // TODO 回复错误 |
| | | return; |
| | | } |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("vhost","__defaultVhost__"); |
| | | param.put("app",sendRtpItem.getApp()); |
| | | param.put("stream",sendRtpItem.getStream()); |
| | | param.put("ssrc", sendRtpItem.getSsrc()); |
| | | |
| | | if (zlmServerFactory.stopSendRtpStream(mediaInfo, param)) { |
| | | logger.info("[REDIS 执行其他平台的请求停止推流] 成功: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); |
| | | // 发送redis消息 |
| | | MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0, |
| | | sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getChannelId(), |
| | | sendRtpItem.getPlatformId(), streamMsg.getPlatformName(), userSetting.getServerId(), sendRtpItem.getMediaServerId()); |
| | | messageForPushChannel.setPlatFormIndex(streamMsg.getPlatFormIndex()); |
| | | redisCatchStorage.sendPlatformStopPlayMsg(messageForPushChannel); |
| | | } |
| | | |
| | | } |
| | | } |