From d881cd7eb30866d2792ffa5ec552d7071cac6635 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: 星期四, 27 五月 2021 09:18:47 +0800 Subject: [PATCH] 解决录像回放未判断是否等待编码导致的回放失败 --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 30 ++++++++++++++---------------- 1 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index dfc6c16..630d018 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -1,8 +1,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; import java.text.ParseException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.sip.*; import javax.sip.address.SipURI; @@ -10,11 +8,11 @@ import javax.sip.header.ViaHeader; import javax.sip.message.Request; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.MediaServerConfig; +import com.genersoft.iot.vmp.conf.MediaConfig; +import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; @@ -82,13 +80,13 @@ @Autowired private ZLMRESTfulUtils zlmresTfulUtils; - @Value("${media.rtp.enable}") - private boolean rtpEnable; + @Autowired + private MediaConfig mediaConfig; - @Value("${media.seniorSdp}") + @Value("${userSettings.seniorSdp}") private boolean seniorSdp; - @Value("${media.autoApplyPlay}") + @Value("${userSettings.autoApplyPlay}") private boolean autoApplyPlay; @Value("${userSettings.waitTrack}") @@ -353,20 +351,20 @@ try { if (device == null) return; String ssrc = streamSession.createPlaySsrc(); - if (rtpEnable) { + if (mediaConfig.isRtpEnable()) { streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); }else { streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); } String streamMode = device.getStreamMode().toUpperCase(); - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); if (mediaInfo == null) { logger.warn("鐐规挱鏃跺彂鐜癦LM灏氭湭杩炴帴..."); return; } String mediaPort = null; // 浣跨敤鍔ㄦ�乽dp绔彛 - if (rtpEnable) { + if (mediaConfig.isRtpEnable()) { mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + ""; }else { mediaPort = mediaInfo.getRtpProxyPort(); @@ -470,7 +468,7 @@ public void playbackStreamCmd(Device device, String channelId, String startTime, String endTime, ZLMHttpHookSubscribe.Event event , SipSubscribe.Event errorEvent) { try { - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); String ssrc = streamSession.createPlayBackSsrc(); String streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); // 娣诲姞璁㈤槄 @@ -478,9 +476,9 @@ subscribeKey.put("app", "rtp"); subscribeKey.put("stream", streamId); subscribeKey.put("regist", true); - + logger.debug("褰曞儚鍥炴斁娣诲姞璁㈤槄锛岃闃呭唴瀹癸細" + subscribeKey.toString()); subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, json->{ - if (json.getJSONArray("tracks") == null) return; + if (waitTrack && json.getJSONArray("tracks") == null) return; event.response(json); subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey); }); @@ -495,7 +493,7 @@ +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n"); String mediaPort = null; // 浣跨敤鍔ㄦ�乽dp绔彛 - if (rtpEnable) { + if (mediaConfig.isRtpEnable()) { mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + ""; }else { mediaPort = mediaInfo.getRtpProxyPort(); @@ -1445,7 +1443,7 @@ @Override public void closeRTPServer(Device device, String channelId) { - if (rtpEnable) { + if (mediaConfig.isRtpEnable()) { String streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); zlmrtpServerFactory.closeRTPServer(streamId); } -- Gitblit v1.8.0