From 381c3bdc2079ece5147cf4cee004e9071edadf7a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 4 May 2023 16:04:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BD=E6=A0=87=E7=82=B9?= =?UTF-8?q?=E6=92=AD=E4=B8=8B=E7=BA=A7=E5=B9=B3=E5=8F=B0=EF=BC=8Cssrc?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9A=84=E6=97=B6=E5=8D=95=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=9B=B4=E6=96=B0rtpserver=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/impl/InviteRequestProcessor.java | 12 ++++++- .../iot/vmp/service/impl/PlayServiceImpl.java | 36 ++++--------------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index c2353206..7034a0e5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -349,7 +349,17 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements }else { ssrc = contentString.substring(ssrcIndex + 2, ssrcIndex + 12); } - logger.info("[上级点播] 用户:{}, 通道:{}, 地址:{}:{}, ssrc:{}", username, channelId, addressStr, port, ssrc); + String streamTypeStr = null; + if (mediaTransmissionTCP) { + if (tcpActive) { + streamTypeStr = "TCP-ACTIVE"; + }else { + streamTypeStr = "TCP-PASSIVE"; + } + }else { + streamTypeStr = "UDP"; + } + logger.info("[上级点播] 平台:{}, 通道:{}, 收流地址:{}:{},收流方式:{}, ssrc:{}", username, channelId, addressStr, port, streamTypeStr, ssrc); SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, device.getDeviceId(), channelId, mediaTransmissionTCP, platform.isRtcp()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 0347611c..96e4098a 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -326,9 +326,9 @@ public class PlayServiceImpl implements IPlayService { logger.info("[点播消息] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse); if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) { logger.info("[点播消息] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse); - if (!ssrcFactory.checkSsrc(mediaServerItem.getId(),ssrcInResponse)) { // ssrc 不可用 + logger.info("[点播消息] SSRC修正时发现ssrc不可使用 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse); // 释放ssrc ssrcFactory.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); @@ -337,8 +337,7 @@ public class PlayServiceImpl implements IPlayService { errorEvent.response(event); return; } - - // 单端口模式streamId也有变化,需要重新设置监听 + // 单端口模式streamId也有变化,重新设置监听即可 if (!mediaServerItem.isRtpEnable()) { // 添加订阅 HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); @@ -351,8 +350,11 @@ public class PlayServiceImpl implements IPlayService { onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId); hookEvent.response(mediaServerItemInUse, response); }); + return; } + + // 更新ssrc Boolean result = mediaServerService.updateRtpServerSSRC(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse); if (!result) { try { @@ -372,32 +374,8 @@ public class PlayServiceImpl implements IPlayService { event.statusCode = 500; errorEvent.response(event); } -// // 关闭rtp server -// mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream(), result->{ -// if (result) { -// // 重新开启ssrc server -// mediaServerService.openRTPServer(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false, ssrcInfo.getPort(), true, device.getStreamModeForParam()); -// }else { -// try { -// logger.warn("[停止点播] {}/{}", device.getDeviceId(), channelId); -// cmder.streamByeCmd(device, channelId, ssrcInfo.getStream(), null, null); -// } catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) { -// logger.error("[命令发送失败] 停止点播, 发送BYE: {}", e.getMessage()); -// throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); -// } -// -// dynamicTask.stop(timeOutTaskKey); -// // 释放ssrc -// mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); -// -// streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); -// event.msg = "下级自定义了ssrc,重新设置收流信息失败"; -// event.statusCode = 500; -// errorEvent.response(event); -// } -// }); - - + }else { + logger.info("[点播消息] 收到invite 200, 下级自定义了ssrc, 但是当前模式无需修正"); } } }, (event) -> {