Merge branch '2.6.8' into wvp-28181-2.0
# Conflicts: # src/main/java/com/genersoft/iot/vmp/conf/redis/RedisMsgListenConfig.java # src/main/java/com/genersoft/iot/vmp/gb28181/bean/Gb28181Sdp.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java # src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java # src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java # src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
This commit is contained in:
@@ -22,6 +22,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
|
||||
import com.genersoft.iot.vmp.service.*;
|
||||
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
@@ -468,6 +469,13 @@ public class ZLMHttpHookListener {
|
||||
}
|
||||
redisCatchStorage.deleteSendRTPServer(parentPlatform.getServerGBId(), sendRtpItem.getChannelId(),
|
||||
sendRtpItem.getCallId(), sendRtpItem.getStreamId());
|
||||
if (InviteStreamType.PUSH == sendRtpItem.getPlayType()) {
|
||||
MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0,
|
||||
sendRtpItem.getApp(), sendRtpItem.getStreamId(), sendRtpItem.getChannelId(),
|
||||
sendRtpItem.getPlatformId(), parentPlatform.getName(), userSetting.getServerId(), sendRtpItem.getMediaServerId());
|
||||
messageForPushChannel.setPlatFormIndex(parentPlatform.getId());
|
||||
redisCatchStorage.sendPlatformStopPlayMsg(messageForPushChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -513,7 +521,7 @@ public class ZLMHttpHookListener {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// 推流具有主动性,暂时不做处理
|
||||
// TODO 推流具有主动性,暂时不做处理
|
||||
// StreamPushItem streamPushItem = streamPushService.getPush(app, streamId);
|
||||
// if (streamPushItem != null) {
|
||||
// // TODO 发送停止
|
||||
|
||||
@@ -221,13 +221,14 @@ public class ZLMRTPServerFactory {
|
||||
* @param tcp 是否为tcp
|
||||
* @return SendRtpItem
|
||||
*/
|
||||
public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, String deviceId, String channelId, boolean tcp, boolean rtcp){
|
||||
public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId,
|
||||
String deviceId, String channelId, boolean tcp, boolean rtcp, KeepPortCallback callback){
|
||||
|
||||
// 默认为随机端口
|
||||
int localPort = 0;
|
||||
if (userSetting.getGbSendStreamStrict()) {
|
||||
if (userSetting.getGbSendStreamStrict()) {
|
||||
localPort = keepPort(serverItem, ssrc, localPort);
|
||||
localPort = keepPort(serverItem, ssrc, localPort, callback);
|
||||
if (localPort == 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -259,11 +260,12 @@ public class ZLMRTPServerFactory {
|
||||
* @param tcp 是否为tcp
|
||||
* @return SendRtpItem
|
||||
*/
|
||||
public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, String app, String stream, String channelId, boolean tcp, boolean rtcp){
|
||||
public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId,
|
||||
String app, String stream, String channelId, boolean tcp, boolean rtcp, KeepPortCallback callback){
|
||||
// 默认为随机端口
|
||||
int localPort = 0;
|
||||
if (userSetting.getGbSendStreamStrict()) {
|
||||
localPort = keepPort(serverItem, ssrc, localPort);
|
||||
localPort = keepPort(serverItem, ssrc, localPort, callback);
|
||||
if (localPort == 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -284,10 +286,14 @@ public class ZLMRTPServerFactory {
|
||||
return sendRtpItem;
|
||||
}
|
||||
|
||||
public interface KeepPortCallback{
|
||||
Boolean keep(String ssrc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保持端口,直到需要需要发流时再释放
|
||||
*/
|
||||
public int keepPort(MediaServerItem serverItem, String ssrc, Integer localPort) {
|
||||
public int keepPort(MediaServerItem serverItem, String ssrc, int localPort, KeepPortCallback keepPortCallback) {
|
||||
Map<String, Object> param = new HashMap<>(3);
|
||||
param.put("port", localPort);
|
||||
param.put("enable_tcp", 1);
|
||||
@@ -296,18 +302,20 @@ public class ZLMRTPServerFactory {
|
||||
if (jsonObject.getInteger("code") == 0) {
|
||||
localPort = jsonObject.getInteger("port");
|
||||
HookSubscribeForRtpServerTimeout hookSubscribeForRtpServerTimeout = HookSubscribeFactory.on_rtp_server_timeout(ssrc, null, serverItem.getId());
|
||||
// 订阅 zlm启动事件, 新的zlm也会从这里进入系统
|
||||
Integer finalLocalPort = localPort;
|
||||
hookSubscribe.addSubscribe(hookSubscribeForRtpServerTimeout,
|
||||
(MediaServerItem mediaServerItem, HookParam hookParam)->{
|
||||
logger.info("[上级点播] {}->监听端口到期继续保持监听: {}", ssrc, finalLocalPort);
|
||||
OnRtpServerTimeoutHookParam rtpServerTimeoutHookParam = (OnRtpServerTimeoutHookParam) hookParam;
|
||||
if (!ssrc.equals(rtpServerTimeoutHookParam.getSsrc())) {
|
||||
return;
|
||||
}
|
||||
int port = keepPort(serverItem, ssrc, finalLocalPort);
|
||||
if (port == 0) {
|
||||
logger.info("[上级点播] {}->监听端口失败,移除监听", ssrc);
|
||||
hookSubscribe.removeSubscribe(hookSubscribeForRtpServerTimeout);
|
||||
if (ssrc.equals(rtpServerTimeoutHookParam.getSsrc())) {
|
||||
if (keepPortCallback.keep(ssrc)) {
|
||||
logger.info("[上级点播] {}->监听端口到期继续保持监听", ssrc);
|
||||
keepPort(serverItem, ssrc, finalLocalPort, keepPortCallback);
|
||||
}else {
|
||||
logger.info("[上级点播] {}->发送取消,无需继续监听", ssrc);
|
||||
releasePort(serverItem, ssrc);
|
||||
}
|
||||
}
|
||||
});
|
||||
logger.info("[上级点播] {}->监听端口: {}", ssrc, localPort);
|
||||
|
||||
Reference in New Issue
Block a user