临时提交
This commit is contained in:
@@ -1,5 +1,35 @@
|
||||
package com.genersoft.iot.vmp.service;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISendRtpServerService {
|
||||
|
||||
SendRtpInfo createSendRtpInfo(MediaServer mediaServer, String ip, int port, String ssrc, String requesterId,
|
||||
String deviceId, Integer channelId, boolean isTcp, boolean rtcp);
|
||||
|
||||
SendRtpInfo createSendRtpInfo(MediaServer mediaServer, String ip, int port, String ssrc, String platformId,
|
||||
String app, String stream, Integer channelId, boolean tcp, boolean rtcp);
|
||||
|
||||
void update(SendRtpInfo sendRtpItem);
|
||||
|
||||
SendRtpInfo queryByChannelId(Integer channelId);
|
||||
|
||||
SendRtpInfo queryByCallId(String callId);
|
||||
|
||||
SendRtpInfo queryByStream(String stream);
|
||||
|
||||
void delete(SendRtpInfo sendRtpInfo);
|
||||
|
||||
void deleteByCallId(String callId);
|
||||
|
||||
void deleteByStream(String Stream);
|
||||
|
||||
void deleteByChannel(Integer channelId);
|
||||
|
||||
List<SendRtpInfo> queryAll();
|
||||
|
||||
boolean isChannelSendingRTP(Integer channelId);
|
||||
}
|
||||
|
||||
@@ -252,6 +252,7 @@ public class MediaServiceImpl implements IMediaService {
|
||||
sendRtpItem.getCallId(), sendRtpItem.getStream());
|
||||
if (InviteStreamType.PUSH == sendRtpItem.getPlayType()) {
|
||||
redisCatchStorage.sendPlatformStopPlayMsg(sendRtpItem, parentPlatform, channel);
|
||||
redisCatchStorage.sendPlatformStopPlayMsg(sendRtpItem, parentPlatform, channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,142 @@
|
||||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlayException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
|
||||
import com.genersoft.iot.vmp.service.ISendRtpServerService;
|
||||
import com.genersoft.iot.vmp.utils.JsonUtil;
|
||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SendRtpServerServiceImpl implements ISendRtpServerService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private SendRtpPortManager sendRtpPortManager;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
@Override
|
||||
public SendRtpInfo createSendRtpInfo(MediaServer mediaServer, String ip, int port, String ssrc, String requesterId,
|
||||
String deviceId, Integer channelId, boolean isTcp, boolean rtcp) {
|
||||
int localPort = sendRtpPortManager.getNextPort(mediaServer);
|
||||
if (localPort == 0) {
|
||||
return null;
|
||||
}
|
||||
return SendRtpInfo.getInstance(localPort, mediaServer, ip, port, ssrc, deviceId, null, channelId,
|
||||
isTcp, rtcp, userSetting.getServerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendRtpInfo createSendRtpInfo(MediaServer mediaServer, String ip, int port, String ssrc, String platformId,
|
||||
String app, String stream, Integer channelId, boolean tcp, boolean rtcp){
|
||||
|
||||
int localPort = sendRtpPortManager.getNextPort(mediaServer);
|
||||
if (localPort <= 0) {
|
||||
throw new PlayException(javax.sip.message.Response.SERVER_INTERNAL_ERROR, "server internal error");
|
||||
}
|
||||
return SendRtpInfo.getInstance(localPort, mediaServer, ip, port, ssrc, null, platformId, channelId,
|
||||
tcp, rtcp, userSetting.getServerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(SendRtpInfo sendRtpItem) {
|
||||
redisTemplate.opsForValue().set(VideoManagerConstants.SEND_RTP_INFO_CALLID + sendRtpItem.getCallId(), sendRtpItem);
|
||||
redisTemplate.opsForValue().set(VideoManagerConstants.SEND_RTP_INFO_STREAM + sendRtpItem.getStream(), sendRtpItem);
|
||||
redisTemplate.opsForValue().set(VideoManagerConstants.SEND_RTP_INFO_CHANNEL + sendRtpItem.getChannelId(), sendRtpItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendRtpInfo queryByChannelId(Integer channelId) {
|
||||
String key = VideoManagerConstants.SEND_RTP_INFO_CHANNEL + channelId;
|
||||
return JsonUtil.redisJsonToObject(redisTemplate, key, SendRtpInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendRtpInfo queryByCallId(String callId) {
|
||||
String key = VideoManagerConstants.SEND_RTP_INFO_CALLID + callId;
|
||||
return JsonUtil.redisJsonToObject(redisTemplate, key, SendRtpInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendRtpInfo queryByStream(String stream, String targetId) {
|
||||
String key = VideoManagerConstants.SEND_RTP_INFO_STREAM + stream;
|
||||
return JsonUtil.redisJsonToObject(redisTemplate, key, SendRtpInfo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除RTP推送信息缓存
|
||||
*/
|
||||
@Override
|
||||
public void delete(SendRtpInfo sendRtpInfo) {
|
||||
if (sendRtpInfo == null) {
|
||||
return;
|
||||
}
|
||||
redisTemplate.delete(VideoManagerConstants.SEND_RTP_INFO_CALLID + sendRtpInfo.getCallId());
|
||||
redisTemplate.delete(VideoManagerConstants.SEND_RTP_INFO_STREAM + sendRtpInfo.getStream());
|
||||
redisTemplate.delete(VideoManagerConstants.SEND_RTP_INFO_CHANNEL + sendRtpInfo.getChannelId());
|
||||
}
|
||||
@Override
|
||||
public void deleteByCallId(String callId) {
|
||||
SendRtpInfo sendRtpInfo = queryByCallId(callId);
|
||||
if (sendRtpInfo == null) {
|
||||
return;
|
||||
}
|
||||
delete(sendRtpInfo);
|
||||
}
|
||||
@Override
|
||||
public void deleteByStream(String Stream) {
|
||||
SendRtpInfo sendRtpInfo = queryByStream(Stream);
|
||||
if (sendRtpInfo == null) {
|
||||
return;
|
||||
}
|
||||
delete(sendRtpInfo);
|
||||
}
|
||||
@Override
|
||||
public void deleteByChannel(Integer channelId) {
|
||||
SendRtpInfo sendRtpInfo = queryByChannelId(channelId);
|
||||
if (sendRtpInfo == null) {
|
||||
return;
|
||||
}
|
||||
delete(sendRtpInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SendRtpInfo> queryAll() {
|
||||
String key = VideoManagerConstants.SEND_RTP_INFO_CALLID
|
||||
+ userSetting.getServerId() + ":*";
|
||||
List<Object> queryResult = RedisUtil.scan(redisTemplate, key);
|
||||
List<SendRtpInfo> result= new ArrayList<>();
|
||||
|
||||
for (Object o : queryResult) {
|
||||
String keyItem = (String) o;
|
||||
result.add((SendRtpInfo) redisTemplate.opsForValue().get(keyItem));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某个通道是否存在上级点播(RTP推送)
|
||||
*/
|
||||
@Override
|
||||
public boolean isChannelSendingRTP(Integer channelId) {
|
||||
SendRtpInfo sendRtpInfo = queryByChannelId(channelId);
|
||||
return sendRtpInfo != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,17 +7,17 @@ import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
|
||||
public interface IRedisRpcService {
|
||||
|
||||
SendRtpInfo getSendRtpItem(String sendRtpItemKey);
|
||||
SendRtpInfo getSendRtpItem(Integer sendRtpChannelId);
|
||||
|
||||
WVPResult startSendRtp(String sendRtpItemKey, SendRtpInfo sendRtpItem);
|
||||
WVPResult startSendRtp(Integer sendRtpChannelId, SendRtpInfo sendRtpItem);
|
||||
|
||||
WVPResult stopSendRtp(String sendRtpItemKey);
|
||||
WVPResult stopSendRtp(Integer sendRtpChannelId);
|
||||
|
||||
long waitePushStreamOnline(SendRtpInfo sendRtpItem, CommonCallback<String> callback);
|
||||
|
||||
void stopWaitePushStreamOnline(SendRtpInfo sendRtpItem);
|
||||
|
||||
void rtpSendStopped(String sendRtpItemKey);
|
||||
void rtpSendStopped(Integer sendRtpChannelId);
|
||||
|
||||
void removeCallback(long key);
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookType;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
|
||||
import com.genersoft.iot.vmp.service.ISendRtpServerService;
|
||||
import com.genersoft.iot.vmp.service.impl.SendRtpServerServiceImpl;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
@@ -62,6 +64,8 @@ public class RedisRpcController {
|
||||
|
||||
@Autowired
|
||||
private IPlatformService platformService;
|
||||
@Autowired
|
||||
private ISendRtpServerService sendRtpServerService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -99,7 +103,7 @@ public class RedisRpcController {
|
||||
String ssrc = "Play".equalsIgnoreCase(sendRtpItem.getSessionName()) ? ssrcFactory.getPlaySsrc(mediaServerItem.getId()) : ssrcFactory.getPlayBackSsrc(mediaServerItem.getId());
|
||||
sendRtpItem.setSsrc(ssrc);
|
||||
}
|
||||
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
||||
sendRtpServerService.update(sendRtpItem);
|
||||
redisTemplate.opsForValue().set(sendRtpItemKey, sendRtpItem);
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
response.setStatusCode(200);
|
||||
@@ -127,9 +131,9 @@ public class RedisRpcController {
|
||||
sendRtpItem.setLocalIp(mediaServer.getSdpIp());
|
||||
sendRtpItem.setServerId(userSetting.getServerId());
|
||||
|
||||
redisTemplate.opsForValue().set(sendRtpItem.getRedisKey(), sendRtpItem);
|
||||
sendRtpServerService.update(sendRtpItem);
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
response.setBody(sendRtpItem.getRedisKey());
|
||||
response.setBody(sendRtpItem.getChannelId());
|
||||
response.setStatusCode(200);
|
||||
}
|
||||
// 监听流上线。 流上线直接发送sendRtpItem消息给实际的信令处理者
|
||||
@@ -146,9 +150,9 @@ public class RedisRpcController {
|
||||
sendRtpItem.setLocalIp(hookData.getMediaServer().getSdpIp());
|
||||
sendRtpItem.setServerId(userSetting.getServerId());
|
||||
|
||||
redisTemplate.opsForValue().set(sendRtpItem.getRedisKey(), sendRtpItem);
|
||||
redisTemplate.opsForValue().set(sendRtpItem.getChannelId(), sendRtpItem);
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
response.setBody(sendRtpItem.getRedisKey());
|
||||
response.setBody(sendRtpItem.getChannelId());
|
||||
response.setStatusCode(200);
|
||||
// 手动发送结果
|
||||
sendResponse(response);
|
||||
|
||||
Reference in New Issue
Block a user