合并主线

结构优化
648540858 2023-07-01 18:33:42 +08:00
parent 975ace051b
commit c551164c89
3 changed files with 18 additions and 43 deletions

View File

@ -1026,9 +1026,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
device.getDeviceId(), broadcastCatch.getChannelId(), device.getDeviceId(), broadcastCatch.getChannelId(),
mediaTransmissionTCP, false, ssrcFromCallback -> { mediaTransmissionTCP, false);
return redisCatchStorage.querySendRTPServer(requesterId, channelId, null, callIdHeader.getCallId()) != null;
});
if (sendRtpItem == null) { if (sendRtpItem == null) {
logger.warn("服务器端口资源不足"); logger.warn("服务器端口资源不足");

View File

@ -236,11 +236,6 @@ 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);
} }
@ -334,18 +329,14 @@ public class ZLMRTPServerFactory {
// 如果是非严格模式,需要关闭端口占用 // 如果是非严格模式,需要关闭端口占用
JSONObject startSendRtpStreamResult = null; JSONObject startSendRtpStreamResult = null;
if (sendRtpItem.getLocalPort() != 0) { if (sendRtpItem.getLocalPort() != 0) {
HookSubscribeForRtpServerTimeout hookSubscribeForRtpServerTimeout = HookSubscribeFactory.on_rtp_server_timeout(sendRtpItem.getSsrc(), null, mediaInfo.getId()); if (sendRtpItem.isTcpActive()) {
hookSubscribe.removeSubscribe(hookSubscribeForRtpServerTimeout); startSendRtpStreamResult = startSendRtpPassive(mediaInfo, param);
if (releasePort(mediaInfo, sendRtpItem.getSsrc())) { System.out.println(JSON.toJSON(param));
if (sendRtpItem.isTcpActive()) { }else {
startSendRtpStreamResult = startSendRtpPassive(mediaInfo, param); param.put("is_udp", is_Udp);
System.out.println(JSON.toJSON(param)); param.put("dst_url", sendRtpItem.getIp());
}else { param.put("dst_port", sendRtpItem.getPort());
param.put("is_udp", is_Udp); startSendRtpStreamResult = startSendRtpStream(mediaInfo, param);
param.put("dst_url", sendRtpItem.getIp());
param.put("dst_port", sendRtpItem.getPort());
startSendRtpStreamResult = startSendRtpStream(mediaInfo, param);
}
} }
}else { }else {
if (sendRtpItem.isTcpActive()) { if (sendRtpItem.isTcpActive()) {

View File

@ -16,14 +16,10 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.*;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
@ -94,7 +90,7 @@ public class PlayServiceImpl implements IPlayService {
private IInviteStreamService inviteStreamService; private IInviteStreamService inviteStreamService;
@Autowired @Autowired
private DeferredResultHolder resultHolder; private SendRtpPortManager sendRtpPortManager;
@Autowired @Autowired
private ZLMRESTfulUtils zlmresTfulUtils; private ZLMRESTfulUtils zlmresTfulUtils;
@ -235,9 +231,7 @@ public class PlayServiceImpl implements IPlayService {
sendRtpItem.setReceiveStream(stream + "_talk"); sendRtpItem.setReceiveStream(stream + "_talk");
String callId = SipUtils.getNewCallId(); String callId = SipUtils.getNewCallId();
int port = zlmrtpServerFactory.keepPort(mediaServerItem, playSsrc, 0, ssrcFromCallback ->{ int port = sendRtpPortManager.getNextPort(mediaServerItem.getId());
return redisCatchStorage.querySendRTPServer(device.getDeviceId(), channelId, null, callId) != null;
});
//端口获取失败的ssrcInfo 没有必要发送点播指令 //端口获取失败的ssrcInfo 没有必要发送点播指令
if (port <= 0) { if (port <= 0) {
logger.info("[语音对讲] 端口分配异常deviceId={},channelId={}", device.getDeviceId(), channelId); logger.info("[语音对讲] 端口分配异常deviceId={},channelId={}", device.getDeviceId(), channelId);
@ -265,9 +259,6 @@ public class PlayServiceImpl implements IPlayService {
} }
}, userSetting.getPlayTimeout()); }, userSetting.getPlayTimeout());
zlmrtpServerFactory.releasePort(mediaServerItem, playSsrc);
Map<String, Object> param = new HashMap<>(12); Map<String, Object> param = new HashMap<>(12);
param.put("vhost","__defaultVhost__"); param.put("vhost","__defaultVhost__");
param.put("app", sendRtpItem.getApp()); param.put("app", sendRtpItem.getApp());
@ -1467,18 +1458,13 @@ public class PlayServiceImpl implements IPlayService {
// 如果是严格模式,需要关闭端口占用 // 如果是严格模式,需要关闭端口占用
JSONObject startSendRtpStreamResult = null; JSONObject startSendRtpStreamResult = null;
if (sendRtpItem.getLocalPort() != 0) { if (sendRtpItem.getLocalPort() != 0) {
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);