Merge branch 'wvp-28181-2.0' into main-dev
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.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/media/zlm/ZLMHttpHookListener.java
This commit is contained in:
@@ -23,6 +23,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;
|
||||
@@ -543,6 +544,13 @@ public class ZLMHttpHookListener {
|
||||
}
|
||||
redisCatchStorage.deleteSendRTPServer(parentPlatform.getServerGBId(), sendRtpItem.getChannelId(),
|
||||
sendRtpItem.getCallId(), sendRtpItem.getStream());
|
||||
if (InviteStreamType.PUSH == sendRtpItem.getPlayType()) {
|
||||
MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0,
|
||||
sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getChannelId(),
|
||||
sendRtpItem.getPlatformId(), parentPlatform.getName(), userSetting.getServerId(), sendRtpItem.getMediaServerId());
|
||||
messageForPushChannel.setPlatFormIndex(parentPlatform.getId());
|
||||
redisCatchStorage.sendPlatformStopPlayMsg(messageForPushChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -595,7 +603,7 @@ public class ZLMHttpHookListener {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// 推流具有主动性,暂时不做处理
|
||||
// TODO 推流具有主动性,暂时不做处理
|
||||
// StreamPushItem streamPushItem = streamPushService.getPush(app, streamId);
|
||||
// if (streamPushItem != null) {
|
||||
// // TODO 发送停止
|
||||
|
||||
@@ -227,13 +227,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;
|
||||
}
|
||||
@@ -265,11 +266,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;
|
||||
}
|
||||
@@ -290,10 +292,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);
|
||||
@@ -302,18 +308,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