修复ssrc变化时端口变化的问题

pull/353/head
648540858 2022-07-29 11:57:04 +08:00
parent 0e38e743ce
commit e05d0aa0a9
8 changed files with 25 additions and 14 deletions

View File

@ -315,7 +315,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
Device device = redisCatchStorage.getDevice(deviceId);
if (device == null || device.getOnline() == 0) {
logger.warn("[收到 目录订阅]{}, 但是设备已经离线", (device != null ? device.getDeviceId():"" ));
logger.warn("[收到目录订阅]{}, 但是设备已经离线", (device != null ? device.getDeviceId():"" ));
return;
}
Element rootElement = getRootElement(evt, device.getCharset());
@ -336,14 +336,14 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
Element eventElement = itemDevice.element("Event");
String event;
if (eventElement == null) {
logger.warn("[收到 目录订阅]{}, 但是Event为空, 设为默认值 ADD", (device != null ? device.getDeviceId():"" ));
logger.warn("[收到目录订阅]{}, 但是Event为空, 设为默认值 ADD", (device != null ? device.getDeviceId():"" ));
event = CatalogEvent.ADD;
}else {
event = eventElement.getText().toUpperCase();
}
DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device, event);
channel.setDeviceId(device.getDeviceId());
logger.info("[收到 目录订阅]{}/{}", device.getDeviceId(), channel.getChannelId());
logger.info("[收到目录订阅]{}/{}", device.getDeviceId(), channel.getChannelId());
switch (event) {
case CatalogEvent.ON:
// 上线

View File

@ -44,7 +44,7 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp
@Override
public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) {
logger.info("接收到DeviceInfo查询消息");
logger.info("[DeviceInfo查询]消息");
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
try {
// 回复200 OK

View File

@ -26,7 +26,7 @@ import javax.sip.message.Response;
@Component
public class RegisterResponseProcessor extends SIPResponseProcessorAbstract {
private Logger logger = LoggerFactory.getLogger(RegisterResponseProcessor.class);
private final Logger logger = LoggerFactory.getLogger(RegisterResponseProcessor.class);
private final String method = "REGISTER";
@Autowired
@ -69,11 +69,11 @@ public class RegisterResponseProcessor extends SIPResponseProcessorAbstract {
ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformGBId);
if (parentPlatformCatch == null) {
logger.warn(String.format("收到 %s 的注册/注销%S请求, 但是平台缓存信息未查询到!!!", platformGBId, response.getStatusCode()));
logger.warn(String.format("[收到注册/注销%S请求]平台:%s但是平台缓存信息未查询到!!!", response.getStatusCode(),platformGBId));
return;
}
String action = parentPlatformCatch.getParentPlatform().getExpires().equals("0") ? "注销" : "注册";
logger.info(String.format("收到 %s %s的%S响应", platformGBId, action, response.getStatusCode() ));
logger.info(String.format("[%s %S响应]%s ", action, response.getStatusCode(), platformGBId ));
ParentPlatform parentPlatform = parentPlatformCatch.getParentPlatform();
if (parentPlatform == null) {
logger.warn(String.format("收到 %s %s的%S请求, 但是平台信息未查询到!!!", platformGBId, action, response.getStatusCode()));

View File

@ -87,7 +87,7 @@ public class ZLMRTPServerFactory {
return result;
}
public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc) {
public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc, Integer port) {
int result = -1;
// 查询此rtp server 是否已经存在
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId);
@ -105,7 +105,11 @@ public class ZLMRTPServerFactory {
param.put("enable_tcp", 1);
param.put("stream_id", streamId);
// 推流端口设置0则使用随机端口
if (port == null) {
param.put("port", 0);
}else {
param.put("port", port);
}
param.put("ssrc", ssrc);
JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param);

View File

@ -48,6 +48,8 @@ public interface IMediaServerService {
SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback);
SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback, Integer port);
void closeRTPServer(String deviceId, String channelId, String ssrc);
void clearRTPServer(MediaServerItem mediaServerItem);

View File

@ -121,7 +121,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
}
@Override
public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, boolean isPlayback) {
public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, boolean isPlayback, Integer port) {
if (mediaServerItem == null || mediaServerItem.getId() == null) {
return null;
}
@ -149,13 +149,18 @@ public class MediaServerServiceImpl implements IMediaServerService {
}
int rtpServerPort = mediaServerItem.getRtpProxyPort();
if (mediaServerItem.isRtpEnable()) {
rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0);
rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0, port);
}
redisUtil.set(key, mediaServerItem);
return new SSRCInfo(rtpServerPort, ssrc, streamId);
}
}
@Override
public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback) {
return openRTPServer(mediaServerItem, streamId, ssrc, ssrcCheck, isPlayback, null);
}
@Override
public void closeRTPServer(String deviceId, String channelId, String stream) {
String mediaServerId = streamSession.getMediaServerId(deviceId, channelId, stream);

View File

@ -323,7 +323,7 @@ public class PlayServiceImpl implements IPlayService {
// 关闭rtp server
mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
// 重新开启ssrc server
mediaServerService.openRTPServer(mediaServerItem, finalSsrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false);
mediaServerService.openRTPServer(mediaServerItem, finalSsrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false, finalSsrcInfo.getPort());
}
}

View File

@ -46,7 +46,7 @@ public class RedisStreamMsgListener implements MessageListener {
JSONObject steamMsgJson = JSON.parseObject(message.getBody(), JSONObject.class);
if (steamMsgJson == null) {
logger.warn("[收到 redis 流变化]消息解析失败");
logger.warn("[收到redis 流变化]消息解析失败");
return;
}
String serverId = steamMsgJson.getString("serverId");
@ -55,7 +55,7 @@ public class RedisStreamMsgListener implements MessageListener {
// 自己发送的消息忽略即可
return;
}
logger.info("[收到 redis 流变化] {}", new String(message.getBody()));
logger.info("[收到redis 流变化] {}", new String(message.getBody()));
String app = steamMsgJson.getString("app");
String stream = steamMsgJson.getString("stream");
boolean register = steamMsgJson.getBoolean("register");