Commit e05d0aa0a96747c1ccaf89d7fbf7445a45836445
1 parent
0e38e743
修复ssrc变化时端口变化的问题
Showing
8 changed files
with
25 additions
and
14 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
| @@ -315,7 +315,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | @@ -315,7 +315,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | ||
| 315 | 315 | ||
| 316 | Device device = redisCatchStorage.getDevice(deviceId); | 316 | Device device = redisCatchStorage.getDevice(deviceId); |
| 317 | if (device == null || device.getOnline() == 0) { | 317 | if (device == null || device.getOnline() == 0) { |
| 318 | - logger.warn("[收到 目录订阅]:{}, 但是设备已经离线", (device != null ? device.getDeviceId():"" )); | 318 | + logger.warn("[收到目录订阅]:{}, 但是设备已经离线", (device != null ? device.getDeviceId():"" )); |
| 319 | return; | 319 | return; |
| 320 | } | 320 | } |
| 321 | Element rootElement = getRootElement(evt, device.getCharset()); | 321 | Element rootElement = getRootElement(evt, device.getCharset()); |
| @@ -336,14 +336,14 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | @@ -336,14 +336,14 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | ||
| 336 | Element eventElement = itemDevice.element("Event"); | 336 | Element eventElement = itemDevice.element("Event"); |
| 337 | String event; | 337 | String event; |
| 338 | if (eventElement == null) { | 338 | if (eventElement == null) { |
| 339 | - logger.warn("[收到 目录订阅]:{}, 但是Event为空, 设为默认值 ADD", (device != null ? device.getDeviceId():"" )); | 339 | + logger.warn("[收到目录订阅]:{}, 但是Event为空, 设为默认值 ADD", (device != null ? device.getDeviceId():"" )); |
| 340 | event = CatalogEvent.ADD; | 340 | event = CatalogEvent.ADD; |
| 341 | }else { | 341 | }else { |
| 342 | event = eventElement.getText().toUpperCase(); | 342 | event = eventElement.getText().toUpperCase(); |
| 343 | } | 343 | } |
| 344 | DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device, event); | 344 | DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device, event); |
| 345 | channel.setDeviceId(device.getDeviceId()); | 345 | channel.setDeviceId(device.getDeviceId()); |
| 346 | - logger.info("[收到 目录订阅]:{}/{}", device.getDeviceId(), channel.getChannelId()); | 346 | + logger.info("[收到目录订阅]:{}/{}", device.getDeviceId(), channel.getChannelId()); |
| 347 | switch (event) { | 347 | switch (event) { |
| 348 | case CatalogEvent.ON: | 348 | case CatalogEvent.ON: |
| 349 | // 上线 | 349 | // 上线 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java
| @@ -44,7 +44,7 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp | @@ -44,7 +44,7 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp | ||
| 44 | 44 | ||
| 45 | @Override | 45 | @Override |
| 46 | public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { | 46 | public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { |
| 47 | - logger.info("接收到DeviceInfo查询消息"); | 47 | + logger.info("[DeviceInfo查询]消息"); |
| 48 | FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); | 48 | FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); |
| 49 | try { | 49 | try { |
| 50 | // 回复200 OK | 50 | // 回复200 OK |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java
| @@ -26,7 +26,7 @@ import javax.sip.message.Response; | @@ -26,7 +26,7 @@ import javax.sip.message.Response; | ||
| 26 | @Component | 26 | @Component |
| 27 | public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { | 27 | public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { |
| 28 | 28 | ||
| 29 | - private Logger logger = LoggerFactory.getLogger(RegisterResponseProcessor.class); | 29 | + private final Logger logger = LoggerFactory.getLogger(RegisterResponseProcessor.class); |
| 30 | private final String method = "REGISTER"; | 30 | private final String method = "REGISTER"; |
| 31 | 31 | ||
| 32 | @Autowired | 32 | @Autowired |
| @@ -69,11 +69,11 @@ public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { | @@ -69,11 +69,11 @@ public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { | ||
| 69 | 69 | ||
| 70 | ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformGBId); | 70 | ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformGBId); |
| 71 | if (parentPlatformCatch == null) { | 71 | if (parentPlatformCatch == null) { |
| 72 | - logger.warn(String.format("收到 %s 的注册/注销%S请求, 但是平台缓存信息未查询到!!!", platformGBId, response.getStatusCode())); | 72 | + logger.warn(String.format("[收到注册/注销%S请求]平台:%s,但是平台缓存信息未查询到!!!", response.getStatusCode(),platformGBId)); |
| 73 | return; | 73 | return; |
| 74 | } | 74 | } |
| 75 | String action = parentPlatformCatch.getParentPlatform().getExpires().equals("0") ? "注销" : "注册"; | 75 | String action = parentPlatformCatch.getParentPlatform().getExpires().equals("0") ? "注销" : "注册"; |
| 76 | - logger.info(String.format("收到 %s %s的%S响应", platformGBId, action, response.getStatusCode() )); | 76 | + logger.info(String.format("[%s %S响应]%s ", action, response.getStatusCode(), platformGBId )); |
| 77 | ParentPlatform parentPlatform = parentPlatformCatch.getParentPlatform(); | 77 | ParentPlatform parentPlatform = parentPlatformCatch.getParentPlatform(); |
| 78 | if (parentPlatform == null) { | 78 | if (parentPlatform == null) { |
| 79 | logger.warn(String.format("收到 %s %s的%S请求, 但是平台信息未查询到!!!", platformGBId, action, response.getStatusCode())); | 79 | logger.warn(String.format("收到 %s %s的%S请求, 但是平台信息未查询到!!!", platformGBId, action, response.getStatusCode())); |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
| @@ -87,7 +87,7 @@ public class ZLMRTPServerFactory { | @@ -87,7 +87,7 @@ public class ZLMRTPServerFactory { | ||
| 87 | return result; | 87 | return result; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | - public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc) { | 90 | + public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc, Integer port) { |
| 91 | int result = -1; | 91 | int result = -1; |
| 92 | // 查询此rtp server 是否已经存在 | 92 | // 查询此rtp server 是否已经存在 |
| 93 | JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId); | 93 | JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId); |
| @@ -105,7 +105,11 @@ public class ZLMRTPServerFactory { | @@ -105,7 +105,11 @@ public class ZLMRTPServerFactory { | ||
| 105 | param.put("enable_tcp", 1); | 105 | param.put("enable_tcp", 1); |
| 106 | param.put("stream_id", streamId); | 106 | param.put("stream_id", streamId); |
| 107 | // 推流端口设置0则使用随机端口 | 107 | // 推流端口设置0则使用随机端口 |
| 108 | - param.put("port", 0); | 108 | + if (port == null) { |
| 109 | + param.put("port", 0); | ||
| 110 | + }else { | ||
| 111 | + param.put("port", port); | ||
| 112 | + } | ||
| 109 | param.put("ssrc", ssrc); | 113 | param.put("ssrc", ssrc); |
| 110 | JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param); | 114 | JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param); |
| 111 | 115 |
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
| @@ -48,6 +48,8 @@ public interface IMediaServerService { | @@ -48,6 +48,8 @@ public interface IMediaServerService { | ||
| 48 | 48 | ||
| 49 | SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback); | 49 | SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback); |
| 50 | 50 | ||
| 51 | + SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback, Integer port); | ||
| 52 | + | ||
| 51 | void closeRTPServer(String deviceId, String channelId, String ssrc); | 53 | void closeRTPServer(String deviceId, String channelId, String ssrc); |
| 52 | 54 | ||
| 53 | void clearRTPServer(MediaServerItem mediaServerItem); | 55 | void clearRTPServer(MediaServerItem mediaServerItem); |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| @@ -121,7 +121,7 @@ public class MediaServerServiceImpl implements IMediaServerService { | @@ -121,7 +121,7 @@ public class MediaServerServiceImpl implements IMediaServerService { | ||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | @Override | 123 | @Override |
| 124 | - public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, boolean isPlayback) { | 124 | + public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, boolean isPlayback, Integer port) { |
| 125 | if (mediaServerItem == null || mediaServerItem.getId() == null) { | 125 | if (mediaServerItem == null || mediaServerItem.getId() == null) { |
| 126 | return null; | 126 | return null; |
| 127 | } | 127 | } |
| @@ -149,7 +149,7 @@ public class MediaServerServiceImpl implements IMediaServerService { | @@ -149,7 +149,7 @@ public class MediaServerServiceImpl implements IMediaServerService { | ||
| 149 | } | 149 | } |
| 150 | int rtpServerPort = mediaServerItem.getRtpProxyPort(); | 150 | int rtpServerPort = mediaServerItem.getRtpProxyPort(); |
| 151 | if (mediaServerItem.isRtpEnable()) { | 151 | if (mediaServerItem.isRtpEnable()) { |
| 152 | - rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0); | 152 | + rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0, port); |
| 153 | } | 153 | } |
| 154 | redisUtil.set(key, mediaServerItem); | 154 | redisUtil.set(key, mediaServerItem); |
| 155 | return new SSRCInfo(rtpServerPort, ssrc, streamId); | 155 | return new SSRCInfo(rtpServerPort, ssrc, streamId); |
| @@ -157,6 +157,11 @@ public class MediaServerServiceImpl implements IMediaServerService { | @@ -157,6 +157,11 @@ public class MediaServerServiceImpl implements IMediaServerService { | ||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | @Override | 159 | @Override |
| 160 | + public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback) { | ||
| 161 | + return openRTPServer(mediaServerItem, streamId, ssrc, ssrcCheck, isPlayback, null); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + @Override | ||
| 160 | public void closeRTPServer(String deviceId, String channelId, String stream) { | 165 | public void closeRTPServer(String deviceId, String channelId, String stream) { |
| 161 | String mediaServerId = streamSession.getMediaServerId(deviceId, channelId, stream); | 166 | String mediaServerId = streamSession.getMediaServerId(deviceId, channelId, stream); |
| 162 | String ssrc = streamSession.getSSRC(deviceId, channelId, stream); | 167 | String ssrc = streamSession.getSSRC(deviceId, channelId, stream); |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -323,7 +323,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -323,7 +323,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 323 | // 关闭rtp server | 323 | // 关闭rtp server |
| 324 | mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | 324 | mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); |
| 325 | // 重新开启ssrc server | 325 | // 重新开启ssrc server |
| 326 | - mediaServerService.openRTPServer(mediaServerItem, finalSsrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false); | 326 | + mediaServerService.openRTPServer(mediaServerItem, finalSsrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false, finalSsrcInfo.getPort()); |
| 327 | 327 | ||
| 328 | } | 328 | } |
| 329 | } | 329 | } |
src/main/java/com/genersoft/iot/vmp/service/impl/RedisStreamMsgListener.java
| @@ -46,7 +46,7 @@ public class RedisStreamMsgListener implements MessageListener { | @@ -46,7 +46,7 @@ public class RedisStreamMsgListener implements MessageListener { | ||
| 46 | 46 | ||
| 47 | JSONObject steamMsgJson = JSON.parseObject(message.getBody(), JSONObject.class); | 47 | JSONObject steamMsgJson = JSON.parseObject(message.getBody(), JSONObject.class); |
| 48 | if (steamMsgJson == null) { | 48 | if (steamMsgJson == null) { |
| 49 | - logger.warn("[收到 redis 流变化]消息解析失败"); | 49 | + logger.warn("[收到redis 流变化]消息解析失败"); |
| 50 | return; | 50 | return; |
| 51 | } | 51 | } |
| 52 | String serverId = steamMsgJson.getString("serverId"); | 52 | String serverId = steamMsgJson.getString("serverId"); |
| @@ -55,7 +55,7 @@ public class RedisStreamMsgListener implements MessageListener { | @@ -55,7 +55,7 @@ public class RedisStreamMsgListener implements MessageListener { | ||
| 55 | // 自己发送的消息忽略即可 | 55 | // 自己发送的消息忽略即可 |
| 56 | return; | 56 | return; |
| 57 | } | 57 | } |
| 58 | - logger.info("[收到 redis 流变化]: {}", new String(message.getBody())); | 58 | + logger.info("[收到redis 流变化]: {}", new String(message.getBody())); |
| 59 | String app = steamMsgJson.getString("app"); | 59 | String app = steamMsgJson.getString("app"); |
| 60 | String stream = steamMsgJson.getString("stream"); | 60 | String stream = steamMsgJson.getString("stream"); |
| 61 | boolean register = steamMsgJson.getBoolean("register"); | 61 | boolean register = steamMsgJson.getBoolean("register"); |