临时提交
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
|
||||
public class SendRtpItem {
|
||||
|
||||
/**
|
||||
@@ -89,7 +91,7 @@ public class SendRtpItem {
|
||||
/**
|
||||
* invite 的 callId
|
||||
*/
|
||||
private String CallId;
|
||||
private String callId;
|
||||
|
||||
/**
|
||||
* invite 的 fromTag
|
||||
@@ -242,11 +244,11 @@ public class SendRtpItem {
|
||||
}
|
||||
|
||||
public String getCallId() {
|
||||
return CallId;
|
||||
return callId;
|
||||
}
|
||||
|
||||
public void setCallId(String callId) {
|
||||
CallId = callId;
|
||||
this.callId = callId;
|
||||
}
|
||||
|
||||
public InviteStreamType getPlayType() {
|
||||
@@ -364,7 +366,7 @@ public class SendRtpItem {
|
||||
", localPort=" + localPort +
|
||||
", mediaServerId='" + mediaServerId + '\'' +
|
||||
", serverId='" + serverId + '\'' +
|
||||
", CallId='" + CallId + '\'' +
|
||||
", CallId='" + callId + '\'' +
|
||||
", fromTag='" + fromTag + '\'' +
|
||||
", toTag='" + toTag + '\'' +
|
||||
", pt=" + pt +
|
||||
@@ -376,4 +378,15 @@ public class SendRtpItem {
|
||||
", sessionName='" + sessionName + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getRedisKey() {
|
||||
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX +
|
||||
serverId + "_"
|
||||
+ mediaServerId + "_"
|
||||
+ platformId + "_"
|
||||
+ channelId + "_"
|
||||
+ stream + "_"
|
||||
+ callId;
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
|
||||
logger.info("[收到ACK]: 来自->{}", fromUserId);
|
||||
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId());
|
||||
if (sendRtpItem == null) {
|
||||
logger.warn("[收到ACK]:未找到来自{},目标为({})的推流信息",fromUserId, toUserId);
|
||||
logger.warn("[收到ACK]:未找到来自{},callId: {}", fromUserId, callIdHeader.getCallId());
|
||||
return;
|
||||
}
|
||||
// tcp主动时,此时是级联下级平台,在回复200ok时,本地已经请求zlm开启监听,跳过下面步骤
|
||||
@@ -117,7 +117,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
|
||||
if (parentPlatform != null) {
|
||||
Map<String, Object> param = getSendRtpParam(sendRtpItem);
|
||||
if (!userSetting.getServerId().equals(sendRtpItem.getServerId())) {
|
||||
WVPResult wvpResult = redisRpcService.startSendRtp(sendRtpItem);
|
||||
WVPResult wvpResult = redisRpcService.startSendRtp(sendRtpItem.getRedisKey(), sendRtpItem);
|
||||
if (wvpResult.getCode() == 0) {
|
||||
MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0, sendRtpItem.getApp(), sendRtpItem.getStream(),
|
||||
sendRtpItem.getChannelId(), parentPlatform.getServerGBId(), parentPlatform.getName(), userSetting.getServerId(),
|
||||
|
||||
@@ -137,7 +137,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
|
||||
if (platform != null) {
|
||||
redisCatchStorage.sendPlatformStopPlayMsg(sendRtpItem, platform);
|
||||
if (!userSetting.getServerId().equals(sendRtpItem.getServerId())) {
|
||||
redisRpcService.stopSendRtp(sendRtpItem);
|
||||
redisRpcService.stopSendRtp(sendRtpItem.getRedisKey());
|
||||
redisCatchStorage.deleteSendRTPServer(null, null, sendRtpItem.getCallId(), null);
|
||||
}else {
|
||||
MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sdp.*;
|
||||
@@ -85,6 +86,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
@Autowired
|
||||
private IRedisRpcService redisRpcService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private SSRCFactory ssrcFactory;
|
||||
|
||||
@@ -604,6 +608,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
|
||||
StreamPushItem transform = streamPushService.transform(pushListItem);
|
||||
transform.setSelf(userSetting.getServerId().equals(pushListItem.getSeverId()));
|
||||
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
||||
// 开始推流
|
||||
sendPushStream(sendRtpItem, mediaServerItem, platform, request);
|
||||
}else {
|
||||
@@ -766,7 +771,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel);
|
||||
// 设置超时
|
||||
dynamicTask.startDelay(sendRtpItem.getCallId(), () -> {
|
||||
redisRpcService.stopWaitePushStreamOnline(sendRtpItem);
|
||||
redisRpcService.stopWaitePushStreamOnline(sendRtpItem.getRedisKey(), sendRtpItem);
|
||||
logger.info("[ app={}, stream={} ] 等待设备开始推流超时", sendRtpItem.getApp(), sendRtpItem.getStream());
|
||||
try {
|
||||
responseAck(request, Response.REQUEST_TIMEOUT); // 超时
|
||||
@@ -775,8 +780,27 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
}
|
||||
}, userSetting.getPlatformPlayTimeout());
|
||||
//
|
||||
redisRpcService.waitePushStreamOnline(sendRtpItem, (sendRtpItemFromRedis) -> {
|
||||
redisRpcService.waitePushStreamOnline(sendRtpItem, (sendRtpItemKey) -> {
|
||||
dynamicTask.stop(sendRtpItem.getCallId());
|
||||
if (sendRtpItemKey == null) {
|
||||
logger.warn("[级联点播] 等待推流得到结果未空: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream());
|
||||
try {
|
||||
responseAck(request, Response.BUSY_HERE);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("未处理的异常 ", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
SendRtpItem sendRtpItemFromRedis = (SendRtpItem)redisTemplate.opsForValue().get(sendRtpItemKey);
|
||||
if (sendRtpItemFromRedis == null) {
|
||||
logger.warn("[级联点播] 等待推流, 未找到redis中缓存的发流信息: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream());
|
||||
try {
|
||||
responseAck(request, Response.BUSY_HERE);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("未处理的异常 ", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (sendRtpItemFromRedis.getServerId().equals(userSetting.getServerId())) {
|
||||
logger.info("[级联点播] 等待的推流在本平台上线 {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream());
|
||||
int localPort = sendRtpPortManager.getNextPort(mediaServerItem);
|
||||
@@ -784,11 +808,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
logger.warn("上级点时创建sendRTPItem失败,可能是服务器端口资源不足");
|
||||
try {
|
||||
responseAck(request, Response.BUSY_HERE);
|
||||
} catch (SipException e) {
|
||||
logger.error("未处理的异常 ", e);
|
||||
} catch (InvalidArgumentException e) {
|
||||
logger.error("未处理的异常 ", e);
|
||||
} catch (ParseException e) {
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("未处理的异常 ", e);
|
||||
}
|
||||
return;
|
||||
@@ -814,7 +834,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
redisPushStreamResponseListener.addEvent(sendRtpItem.getApp(), sendRtpItem.getStream(), response -> {
|
||||
if (response.getCode() != 0) {
|
||||
dynamicTask.stop(sendRtpItem.getCallId());
|
||||
redisRpcService.stopWaitePushStreamOnline(sendRtpItem);
|
||||
redisRpcService.stopWaitePushStreamOnline(sendRtpItem.getRedisKey(), sendRtpItem);
|
||||
try {
|
||||
responseAck(request, Response.TEMPORARILY_UNAVAILABLE, response.getMsg());
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
@@ -831,7 +851,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
*/
|
||||
private void otherWvpPushStream(SendRtpItem sendRtpItem, SIPRequest request, ParentPlatform platform) {
|
||||
logger.info("[级联点播] 来自其他wvp的推流 {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream());
|
||||
sendRtpItem = redisRpcService.getSendRtpItem(sendRtpItem);
|
||||
sendRtpItem = redisRpcService.getSendRtpItem(sendRtpItem.getRedisKey());
|
||||
if (sendRtpItem == null) {
|
||||
return;
|
||||
}
|
||||
// 写入redis, 超时时回复
|
||||
sendRtpItem.setStatus(1);
|
||||
SIPResponse response = sendStreamAck(request, sendRtpItem, platform);
|
||||
|
||||
Reference in New Issue
Block a user