修复tcp主动的推流
parent
fb90dfdac5
commit
74ad4235f1
|
@ -302,7 +302,6 @@ public class ZLMRTPServerFactory {
|
||||||
param.put("port", localPort);
|
param.put("port", localPort);
|
||||||
param.put("enable_tcp", 1);
|
param.put("enable_tcp", 1);
|
||||||
param.put("stream_id", ssrc);
|
param.put("stream_id", ssrc);
|
||||||
param.put("re_use_port", 1);
|
|
||||||
JSONObject jsonObject = zlmresTfulUtils.openRtpServer(serverItem, param);
|
JSONObject jsonObject = zlmresTfulUtils.openRtpServer(serverItem, param);
|
||||||
if (jsonObject.getInteger("code") == 0) {
|
if (jsonObject.getInteger("code") == 0) {
|
||||||
localPort = jsonObject.getInteger("port");
|
localPort = jsonObject.getInteger("port");
|
||||||
|
@ -313,7 +312,7 @@ public class ZLMRTPServerFactory {
|
||||||
(MediaServerItem mediaServerItem, HookParam hookParam)->{
|
(MediaServerItem mediaServerItem, HookParam hookParam)->{
|
||||||
logger.info("[上级点播] {}->监听端口到期继续保持监听: {}", ssrc, finalLocalPort);
|
logger.info("[上级点播] {}->监听端口到期继续保持监听: {}", ssrc, finalLocalPort);
|
||||||
OnRtpServerTimeoutHookParam rtpServerTimeoutHookParam = (OnRtpServerTimeoutHookParam) hookParam;
|
OnRtpServerTimeoutHookParam rtpServerTimeoutHookParam = (OnRtpServerTimeoutHookParam) hookParam;
|
||||||
if (ssrc.equals(rtpServerTimeoutHookParam.getSsrc())) {
|
if (ssrc.equals(rtpServerTimeoutHookParam.getStream_id())) {
|
||||||
if (keepPortCallback.keep(ssrc)) {
|
if (keepPortCallback.keep(ssrc)) {
|
||||||
logger.info("[上级点播] {}->监听端口到期继续保持监听", ssrc);
|
logger.info("[上级点播] {}->监听端口到期继续保持监听", ssrc);
|
||||||
keepPort(serverItem, ssrc, finalLocalPort, keepPortCallback);
|
keepPort(serverItem, ssrc, finalLocalPort, keepPortCallback);
|
||||||
|
@ -337,11 +336,6 @@ public class ZLMRTPServerFactory {
|
||||||
public boolean releasePort(MediaServerItem serverItem, String ssrc) {
|
public boolean releasePort(MediaServerItem serverItem, String ssrc) {
|
||||||
logger.info("[保持端口] {}->释放监听端口", ssrc);
|
logger.info("[保持端口] {}->释放监听端口", ssrc);
|
||||||
boolean closeRTPServerResult = closeRtpServer(serverItem, ssrc);
|
boolean closeRTPServerResult = closeRtpServer(serverItem, ssrc);
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
HookSubscribeForRtpServerTimeout hookSubscribeForRtpServerTimeout = HookSubscribeFactory.on_rtp_server_timeout(ssrc, null, serverItem.getId());
|
HookSubscribeForRtpServerTimeout hookSubscribeForRtpServerTimeout = HookSubscribeFactory.on_rtp_server_timeout(ssrc, null, serverItem.getId());
|
||||||
// 订阅 zlm启动事件, 新的zlm也会从这里进入系统
|
// 订阅 zlm启动事件, 新的zlm也会从这里进入系统
|
||||||
hookSubscribe.removeSubscribe(hookSubscribeForRtpServerTimeout);
|
hookSubscribe.removeSubscribe(hookSubscribeForRtpServerTimeout);
|
||||||
|
@ -359,6 +353,11 @@ public class ZLMRTPServerFactory {
|
||||||
* 调用zlm RESTFUL API —— startSendRtpPassive
|
* 调用zlm RESTFUL API —— startSendRtpPassive
|
||||||
*/
|
*/
|
||||||
public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map<String, Object>param) {
|
public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map<String, Object>param) {
|
||||||
|
System.out.println("=====================");
|
||||||
|
for (String s : param.keySet()) {
|
||||||
|
System.out.println(s + ": " + param.get(s));
|
||||||
|
}
|
||||||
|
System.out.println("=========END============");
|
||||||
return zlmresTfulUtils.startSendRtpPassive(mediaServerItem, param);
|
return zlmresTfulUtils.startSendRtpPassive(mediaServerItem, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1467,14 +1467,18 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
// 如果是严格模式,需要关闭端口占用
|
// 如果是严格模式,需要关闭端口占用
|
||||||
JSONObject startSendRtpStreamResult = null;
|
JSONObject startSendRtpStreamResult = null;
|
||||||
if (sendRtpItem.getLocalPort() != 0) {
|
if (sendRtpItem.getLocalPort() != 0) {
|
||||||
zlmrtpServerFactory.releasePort(mediaInfo, sendRtpItem.getSsrc());
|
if (zlmrtpServerFactory.releasePort(mediaInfo, sendRtpItem.getSsrc())) {
|
||||||
if (sendRtpItem.isTcpActive()) {
|
if (sendRtpItem.isTcpActive()) {
|
||||||
startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param);
|
startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param);
|
||||||
} else {
|
} else {
|
||||||
param.put("dst_url", sendRtpItem.getIp());
|
param.put("dst_url", sendRtpItem.getIp());
|
||||||
param.put("dst_port", sendRtpItem.getPort());
|
param.put("dst_port", sendRtpItem.getPort());
|
||||||
startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
|
startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
// TODO 释放失败的处理
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (sendRtpItem.isTcpActive()) {
|
if (sendRtpItem.isTcpActive()) {
|
||||||
startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param);
|
startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param);
|
||||||
|
|
Loading…
Reference in New Issue