修复多平台推流无人观看redis通知
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.genersoft.iot.vmp.service.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||
|
||||
|
||||
public class RequestStopPushStreamMsg {
|
||||
|
||||
|
||||
private SendRtpItem sendRtpItem;
|
||||
|
||||
|
||||
private String platformName;
|
||||
|
||||
|
||||
private int platFormIndex;
|
||||
|
||||
public SendRtpItem getSendRtpItem() {
|
||||
return sendRtpItem;
|
||||
}
|
||||
|
||||
public void setSendRtpItem(SendRtpItem sendRtpItem) {
|
||||
this.sendRtpItem = sendRtpItem;
|
||||
}
|
||||
|
||||
public String getPlatformName() {
|
||||
return platformName;
|
||||
}
|
||||
|
||||
public void setPlatformName(String platformName) {
|
||||
this.platformName = platformName;
|
||||
}
|
||||
|
||||
|
||||
public int getPlatFormIndex() {
|
||||
return platFormIndex;
|
||||
}
|
||||
|
||||
public void setPlatFormIndex(int platFormIndex) {
|
||||
this.platFormIndex = platFormIndex;
|
||||
}
|
||||
|
||||
public static RequestStopPushStreamMsg getInstance(SendRtpItem sendRtpItem, String platformName, int platFormIndex) {
|
||||
RequestStopPushStreamMsg streamMsg = new RequestStopPushStreamMsg();
|
||||
streamMsg.setSendRtpItem(sendRtpItem);
|
||||
streamMsg.setPlatformName(platformName);
|
||||
streamMsg.setPlatFormIndex(platFormIndex);
|
||||
return streamMsg;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,17 @@ package com.genersoft.iot.vmp.service.bean;
|
||||
|
||||
public class WvpRedisMsgCmd {
|
||||
|
||||
/**
|
||||
* 请求获取推流信息
|
||||
*/
|
||||
public static final String GET_SEND_ITEM = "GetSendItem";
|
||||
/**
|
||||
* 请求推流的请求
|
||||
*/
|
||||
public static final String REQUEST_PUSH_STREAM = "RequestPushStream";
|
||||
/**
|
||||
* 停止推流的请求
|
||||
*/
|
||||
public static final String REQUEST_STOP_PUSH_STREAM = "RequestStopPushStream";
|
||||
|
||||
}
|
||||
|
||||
@@ -133,7 +133,10 @@ public class RedisGbPlayMsgListener implements MessageListener {
|
||||
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;
|
||||
@@ -397,6 +400,19 @@ public class RedisGbPlayMsgListener implements MessageListener {
|
||||
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 = "*";
|
||||
@@ -423,4 +439,36 @@ public class RedisGbPlayMsgListener implements MessageListener {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理收到的请求推流的请求
|
||||
*/
|
||||
private void requestStopPushStreamMsgHand(RequestStopPushStreamMsg streamMsg, String fromId, String serial) {
|
||||
SendRtpItem sendRtpItem = streamMsg.getSendRtpItem();
|
||||
if (sendRtpItem == null) {
|
||||
logger.info("[REDIS 执行其他平台的请求停止推流] 失败: sendRtpItem为NULL");
|
||||
return;
|
||||
}
|
||||
MediaServerItem 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RedisPushStreamCloseResponseListener implements MessageListener {
|
||||
MessageForPushChannel pushChannel = JSON.parseObject(message.getBody(), MessageForPushChannel.class);
|
||||
StreamPushItem push = streamPushService.getPush(pushChannel.getApp(), pushChannel.getStream());
|
||||
if (push != null) {
|
||||
List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByChnnelId(
|
||||
List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByChannelId(
|
||||
push.getGbId());
|
||||
if (!sendRtpItems.isEmpty()) {
|
||||
for (SendRtpItem sendRtpItem : sendRtpItems) {
|
||||
|
||||
Reference in New Issue
Block a user