From e89656122dc89b9b916741638846932ecfb40293 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Wed, 4 Oct 2023 22:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=A0=20zlm=20openRtpServer=20UDP=20?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=20rtpProcess=20Timeout=20=E6=96=AD=E6=B5=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E9=BB=98=E8=AE=A4=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=94=B6=E6=B5=81=E6=A8=A1=E5=BC=8F=E6=94=B9=E4=B8=BA=20TCP=5F?= =?UTF-8?q?ACTIVE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/RegisterRequestProcessor.java | 5 ++-- .../gb28181/service/play/PlayService.java | 28 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/register/request/RegisterRequestProcessor.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/register/request/RegisterRequestProcessor.java index a1bab8c..935e898 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/register/request/RegisterRequestProcessor.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/register/request/RegisterRequestProcessor.java @@ -7,6 +7,7 @@ import cn.skcks.docking.gb28181.core.sip.dto.SipTransactionInfo; import cn.skcks.docking.gb28181.core.sip.gb28181.constant.GB28181Constant; import cn.skcks.docking.gb28181.core.sip.gb28181.sip.GbSipDate; import cn.skcks.docking.gb28181.core.sip.listener.SipListener; +import cn.skcks.docking.gb28181.sdp.media.MediaStreamMode; import cn.skcks.docking.gb28181.sip.method.register.response.RegisterResponseBuilder; import cn.skcks.docking.gb28181.sip.utils.DigestAuthenticationHelper; import cn.skcks.docking.gb28181.core.sip.message.processor.MessageProcessor; @@ -139,14 +140,14 @@ public class RegisterRequestProcessor implements MessageProcessor { if (device == null) { device = new DockingDevice(); - device.setStreamMode(ListeningPoint.UDP); + device.setStreamMode(MediaStreamMode.TCP_ACTIVE.getMode()); device.setCharset(GB28181Constant.CHARSET); device.setGeoCoordSys(GB28181Constant.GEO_COORD_SYS); device.setDeviceId(deviceId); device.setOnLine(false); } else { if (ObjectUtils.isEmpty(device.getStreamMode())) { - device.setStreamMode(ListeningPoint.UDP); + device.setStreamMode(MediaStreamMode.TCP_ACTIVE.getMode()); } if (ObjectUtils.isEmpty(device.getCharset())) { device.setCharset(GB28181Constant.CHARSET); diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/play/PlayService.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/play/PlayService.java index dd1a90f..c7cf3de 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/play/PlayService.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/play/PlayService.java @@ -7,9 +7,7 @@ import cn.skcks.docking.gb28181.common.json.JsonUtils; import cn.skcks.docking.gb28181.common.redis.RedisUtil; import cn.skcks.docking.gb28181.core.sip.dto.SipTransactionInfo; import cn.skcks.docking.gb28181.core.sip.gb28181.cache.CacheUtil; -import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.GB28181Description; -import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.MediaSdpHelper; -import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.StreamMode; +import cn.skcks.docking.gb28181.sdp.GB28181Description; import cn.skcks.docking.gb28181.core.sip.message.processor.MessageProcessor; import cn.skcks.docking.gb28181.core.sip.message.request.SipRequestBuilder; import cn.skcks.docking.gb28181.core.sip.message.sender.SipMessageSender; @@ -25,6 +23,8 @@ import cn.skcks.docking.gb28181.media.dto.rtp.OpenRtpServerResp; import cn.skcks.docking.gb28181.media.dto.status.ResponseStatus; import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService; import cn.skcks.docking.gb28181.orm.mybatis.dynamic.model.DockingDevice; +import cn.skcks.docking.gb28181.sdp.GB28181SDPBuilder; +import cn.skcks.docking.gb28181.sdp.media.MediaStreamMode; import cn.skcks.docking.gb28181.service.docking.device.DockingDeviceService; import cn.skcks.docking.gb28181.service.ssrc.SsrcService; import gov.nist.javax.sip.message.SIPResponse; @@ -94,7 +94,7 @@ public class PlayService { } @SneakyThrows - private JsonResponse closeStream(String streamId, MediaSdpHelper.Action action, DockingDevice device, String channelId) { + private JsonResponse closeStream(String streamId, GB28181SDPBuilder.Action action, DockingDevice device, String channelId) { zlmMediaService.closeRtpServer(new CloseRtpServer(streamId)); String key = CacheUtil.getKey(action.getAction(), device.getDeviceId(), channelId); SipTransactionInfo transactionInfo = JsonUtils.parse(RedisUtil.StringOps.get(key), SipTransactionInfo.class); @@ -125,8 +125,8 @@ public class PlayService { return result; } - String streamId = MediaSdpHelper.getStreamId(deviceId, channelId); - String key = CacheUtil.getKey(MediaSdpHelper.Action.PLAY.getAction(), deviceId, channelId); + String streamId = GB28181SDPBuilder.getStreamId(deviceId, channelId); + String key = CacheUtil.getKey(GB28181SDPBuilder.Action.PLAY.getAction(), deviceId, channelId); if (RedisUtil.KeyOps.hasKey(key)) { result.setResult(JsonResponse.success(videoUrl(streamId))); return result; @@ -141,7 +141,7 @@ public class PlayService { } String ssrc = ssrcService.getPlaySsrc(); - GB28181Description description = MediaSdpHelper.play(deviceId, channelId, Connection.IP4, ip, port, ssrc, StreamMode.of(device.getStreamMode())); + GB28181Description description = GB28181SDPBuilder.Receiver.play(deviceId, channelId, Connection.IP4, ip, port, ssrc, MediaStreamMode.of(device.getStreamMode())); String transport = device.getTransport(); String senderIp = device.getLocalIp(); @@ -208,8 +208,8 @@ public class PlayService { return JsonResponse.error(null, "未找到设备"); } - String streamId = MediaSdpHelper.getStreamId(deviceId, channelId); - return closeStream(streamId, MediaSdpHelper.Action.PLAY, device, channelId); + String streamId = GB28181SDPBuilder.getStreamId(deviceId, channelId); + return closeStream(streamId, GB28181SDPBuilder.Action.PLAY, device, channelId); } @SneakyThrows @@ -217,13 +217,13 @@ public class PlayService { DockingDevice device = deviceService.getDevice(deviceId); long start = startTime.toInstant().getEpochSecond(); long end = endTime.toInstant().getEpochSecond(); - String streamId = MediaSdpHelper.getStreamId(deviceId, channelId, String.valueOf(start), String.valueOf(end)); + String streamId = GB28181SDPBuilder.getStreamId(deviceId, channelId, String.valueOf(start), String.valueOf(end)); DeferredResult> result = makeResult(deviceId, channelId, timeout, device); if (result.hasResult()) { return result; } - String key = CacheUtil.getKey(MediaSdpHelper.Action.PLAY_BACK.getAction(), deviceId, channelId); + String key = CacheUtil.getKey(GB28181SDPBuilder.Action.PLAY_BACK.getAction(), deviceId, channelId); if (RedisUtil.KeyOps.hasKey(key)) { result.setResult(JsonResponse.success(videoUrl(streamId))); return result; @@ -238,7 +238,7 @@ public class PlayService { } String ssrc = ssrcService.getPlaySsrc(); - GB28181Description description = MediaSdpHelper.playback(deviceId, channelId, Connection.IP4, ip, port, ssrc, StreamMode.of(device.getStreamMode()), startTime, endTime); + GB28181Description description = GB28181SDPBuilder.Receiver.playback(deviceId, channelId, Connection.IP4, ip, port, ssrc, MediaStreamMode.of(device.getStreamMode()), startTime, endTime); String transport = device.getTransport(); String senderIp = device.getLocalIp(); @@ -309,8 +309,8 @@ public class PlayService { long start = startTime.toInstant().getEpochSecond(); long end = endTime.toInstant().getEpochSecond(); - String streamId = MediaSdpHelper.getStreamId(deviceId, channelId, String.valueOf(start), String.valueOf(end)); - return closeStream(streamId, MediaSdpHelper.Action.PLAY_BACK, device, channelId); + String streamId = GB28181SDPBuilder.getStreamId(deviceId, channelId, String.valueOf(start), String.valueOf(end)); + return closeStream(streamId, GB28181SDPBuilder.Action.PLAY_BACK, device, channelId); } }