Commit 9a0ea9e3223b3da2943781edaf659ee3567848a1
1 parent
8555d64f
修复级联点播时海康使用自定义ssrc的情况
Showing
4 changed files
with
16 additions
and
18 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -715,12 +715,10 @@ public class SIPCommander implements ISIPCommander { | @@ -715,12 +715,10 @@ public class SIPCommander implements ISIPCommander { | ||
| 715 | } | 715 | } |
| 716 | dialog = streamSession.getDialogByStream(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); | 716 | dialog = streamSession.getDialogByStream(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); |
| 717 | } | 717 | } |
| 718 | - if (ssrcTransaction != null) { | ||
| 719 | - MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId()); | ||
| 720 | - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc()); | ||
| 721 | - mediaServerService.closeRTPServer(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); | ||
| 722 | - streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); | ||
| 723 | - } | 718 | + MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId()); |
| 719 | + mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc()); | ||
| 720 | + mediaServerService.closeRTPServer(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); | ||
| 721 | + streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); | ||
| 724 | 722 | ||
| 725 | if (dialog == null) { | 723 | if (dialog == null) { |
| 726 | logger.warn("[ {} -> {}]停止视频流的时候发现对话已丢失", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); | 724 | logger.warn("[ {} -> {}]停止视频流的时候发现对话已丢失", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| @@ -31,6 +31,7 @@ import javax.sip.address.SipURI; | @@ -31,6 +31,7 @@ import javax.sip.address.SipURI; | ||
| 31 | import javax.sip.header.*; | 31 | import javax.sip.header.*; |
| 32 | import javax.sip.message.Request; | 32 | import javax.sip.message.Request; |
| 33 | import java.lang.reflect.Field; | 33 | import java.lang.reflect.Field; |
| 34 | +import java.net.InetAddress; | ||
| 34 | import java.text.ParseException; | 35 | import java.text.ParseException; |
| 35 | import java.util.ArrayList; | 36 | import java.util.ArrayList; |
| 36 | import java.util.HashSet; | 37 | import java.util.HashSet; |
| @@ -546,14 +547,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -546,14 +547,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 546 | } | 547 | } |
| 547 | notifyRequest.addHeader(event); | 548 | notifyRequest.addHeader(event); |
| 548 | SipURI sipURI = (SipURI) notifyRequest.getRequestURI(); | 549 | SipURI sipURI = (SipURI) notifyRequest.getRequestURI(); |
| 549 | - if (subscribeInfo.getTransaction() != null) { | ||
| 550 | - SIPRequest request = (SIPRequest) subscribeInfo.getTransaction().getRequest(); | ||
| 551 | - sipURI.setHost(request.getRemoteAddress().getHostAddress()); | ||
| 552 | - sipURI.setPort(request.getRemotePort()); | ||
| 553 | - }else { | ||
| 554 | - sipURI.setHost(parentPlatform.getServerIP()); | ||
| 555 | - sipURI.setPort(parentPlatform.getServerPort()); | ||
| 556 | - } | 550 | + sipURI.setHost(parentPlatform.getServerIP()); |
| 551 | + sipURI.setPort(parentPlatform.getServerPort()); | ||
| 557 | 552 | ||
| 558 | ClientTransaction transaction = null; | 553 | ClientTransaction transaction = null; |
| 559 | if ("TCP".equals(parentPlatform.getTransport())) { | 554 | if ("TCP".equals(parentPlatform.getTransport())) { |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| @@ -372,7 +372,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -372,7 +372,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 372 | if (mediaServerItem.isRtpEnable()) { | 372 | if (mediaServerItem.isRtpEnable()) { |
| 373 | streamId = String.format("%s_%s", device.getDeviceId(), channelId); | 373 | streamId = String.format("%s_%s", device.getDeviceId(), channelId); |
| 374 | } | 374 | } |
| 375 | - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, true, false); | 375 | + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, null, device.isSsrcCheck(), false); |
| 376 | sendRtpItem.setStreamId(ssrcInfo.getStream()); | 376 | sendRtpItem.setStreamId(ssrcInfo.getStream()); |
| 377 | // 写入redis, 超时时回复 | 377 | // 写入redis, 超时时回复 |
| 378 | redisCatchStorage.updateSendRTPSever(sendRtpItem); | 378 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -239,19 +239,20 @@ public class PlayServiceImpl implements IPlayService { | @@ -239,19 +239,20 @@ public class PlayServiceImpl implements IPlayService { | ||
| 239 | if (ssrcInfo == null) { | 239 | if (ssrcInfo == null) { |
| 240 | ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false); | 240 | ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false); |
| 241 | } | 241 | } |
| 242 | - | 242 | + logger.info("[点播开始] deviceId: {}, channelId: {}, SSRC: {}", device.getDeviceId(), channelId, ssrcInfo.getSsrc() ); |
| 243 | // 超时处理 | 243 | // 超时处理 |
| 244 | String timeOutTaskKey = UUID.randomUUID().toString(); | 244 | String timeOutTaskKey = UUID.randomUUID().toString(); |
| 245 | SSRCInfo finalSsrcInfo = ssrcInfo; | 245 | SSRCInfo finalSsrcInfo = ssrcInfo; |
| 246 | dynamicTask.startDelay( timeOutTaskKey,()->{ | 246 | dynamicTask.startDelay( timeOutTaskKey,()->{ |
| 247 | - logger.warn(String.format("设备点播超时,deviceId:%s ,channelId:%s", device.getDeviceId(), channelId)); | ||
| 248 | 247 | ||
| 249 | SIPDialog dialog = streamSession.getDialogByStream(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | 248 | SIPDialog dialog = streamSession.getDialogByStream(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); |
| 250 | if (dialog != null) { | 249 | if (dialog != null) { |
| 250 | + logger.info("[点播超时] 收流超时 deviceId: {}, channelId: {}", device.getDeviceId(), channelId); | ||
| 251 | timeoutCallback.run(1, "收流超时"); | 251 | timeoutCallback.run(1, "收流超时"); |
| 252 | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 | 252 | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 |
| 253 | cmder.streamByeCmd(device.getDeviceId(), channelId, finalSsrcInfo.getStream(), null); | 253 | cmder.streamByeCmd(device.getDeviceId(), channelId, finalSsrcInfo.getStream(), null); |
| 254 | }else { | 254 | }else { |
| 255 | + logger.info("[点播超时] 消息未响应 deviceId: {}, channelId: {}", device.getDeviceId(), channelId); | ||
| 255 | timeoutCallback.run(0, "点播超时"); | 256 | timeoutCallback.run(0, "点播超时"); |
| 256 | mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc()); | 257 | mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc()); |
| 257 | mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | 258 | mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); |
| @@ -266,6 +267,8 @@ public class PlayServiceImpl implements IPlayService { | @@ -266,6 +267,8 @@ public class PlayServiceImpl implements IPlayService { | ||
| 266 | // hook响应 | 267 | // hook响应 |
| 267 | onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId, uuid); | 268 | onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId, uuid); |
| 268 | hookEvent.response(mediaServerItemInuse, response); | 269 | hookEvent.response(mediaServerItemInuse, response); |
| 270 | + logger.info("[点播成功] deviceId: {}, channelId: {}", device.getDeviceId(), channelId); | ||
| 271 | + | ||
| 269 | }, (event) -> { | 272 | }, (event) -> { |
| 270 | ResponseEvent responseEvent = (ResponseEvent)event.event; | 273 | ResponseEvent responseEvent = (ResponseEvent)event.event; |
| 271 | String contentString = new String(responseEvent.getResponse().getRawContent()); | 274 | String contentString = new String(responseEvent.getResponse().getRawContent()); |
| @@ -279,8 +282,10 @@ public class PlayServiceImpl implements IPlayService { | @@ -279,8 +282,10 @@ public class PlayServiceImpl implements IPlayService { | ||
| 279 | if (ssrc.equals(ssrcInResponse)) { | 282 | if (ssrc.equals(ssrcInResponse)) { |
| 280 | return; | 283 | return; |
| 281 | } | 284 | } |
| 282 | - logger.info("[SIP 消息] 收到invite 200, 发现下级自定义了ssrc 开启修正"); | 285 | + logger.info("[点播消息] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse ); |
| 283 | if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) { | 286 | if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) { |
| 287 | + logger.info("[SIP 消息] SSRC修正 {}->{}", ssrc, ssrcInResponse); | ||
| 288 | + | ||
| 284 | if (!mediaServerItem.getSsrcConfig().checkSsrc(ssrcInResponse)) { | 289 | if (!mediaServerItem.getSsrcConfig().checkSsrc(ssrcInResponse)) { |
| 285 | // ssrc 不可用 | 290 | // ssrc 不可用 |
| 286 | // 释放ssrc | 291 | // 释放ssrc |