From fff3d64f850b3ee61b9847cd80e7958c46cc6347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=84=E6=A2=A6=E8=9D=B6=E6=AE=87?= Date: Wed, 27 Jul 2022 18:31:33 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96pom=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E9=99=A4=E5=87=A0=E4=B8=AA=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E3=80=82=E5=B9=B6=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E5=87=A0=E4=B8=AA=20equals=E5=88=A4=E6=96=AD=E4=B8=8D=E7=B2=BE?= =?UTF-8?q?=E5=87=86=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 14 +++- .../genersoft/iot/vmp/conf/UserSetting.java | 1 - .../DefaultUserDetailsServiceImpl.java | 13 ++-- .../request/impl/ByeRequestProcessor.java | 2 +- .../service/impl/MediaServerServiceImpl.java | 72 +++++++++---------- .../iot/vmp/service/impl/PlayServiceImpl.java | 49 ++++++------- 6 files changed, 79 insertions(+), 72 deletions(-) diff --git a/pom.xml b/pom.xml index 12091242..ecf1aff3 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,13 @@ org.springframework.boot spring-boot-starter-data-redis + + + + io.lettuce + lettuce-core + + org.springframework.boot @@ -75,6 +82,12 @@ org.mybatis.spring.boot mybatis-spring-boot-starter 2.1.4 + + + com.zaxxer + HikariCP + + org.springframework.boot @@ -84,7 +97,6 @@ redis.clients jedis - ${jedis-version} diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index c0fcf01f..d28ddebc 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.conf; -import io.swagger.models.auth.In; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java index 63569ef1..509a1e03 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java @@ -1,9 +1,7 @@ package com.genersoft.iot.vmp.conf.security; -import com.genersoft.iot.vmp.conf.security.dto.LoginUser; -import com.genersoft.iot.vmp.service.IUserService; -import com.genersoft.iot.vmp.storager.dao.dto.User; -import com.github.xiaoymin.knife4j.core.util.StrUtil; +import java.time.LocalDateTime; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -12,7 +10,10 @@ import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Component; -import java.time.LocalDateTime; +import com.alibaba.excel.util.StringUtils; +import com.genersoft.iot.vmp.conf.security.dto.LoginUser; +import com.genersoft.iot.vmp.service.IUserService; +import com.genersoft.iot.vmp.storager.dao.dto.User; /** * 用户登录认证逻辑 @@ -27,7 +28,7 @@ public class DefaultUserDetailsServiceImpl implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - if (StrUtil.isBlank(username)) { + if (StringUtils.isBlank(username)) { logger.info("登录用户:{} 不存在", username); throw new UsernameNotFoundException("登录用户:" + username + " 不存在"); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java index 32688801..88973769 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java @@ -126,7 +126,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In SsrcTransaction ssrcTransactionForPlay = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, "play", null); if (ssrcTransactionForPlay != null){ SIPDialog dialogForPlay = (SIPDialog) SerializeUtils.deSerialize(ssrcTransactionForPlay.getDialog()); - if (dialogForPlay.getCallId().equals(callIdHeader.getCallId())){ + if (dialogForPlay.getCallId().getCallId().equals(callIdHeader.getCallId())){ // 释放ssrc MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransactionForPlay.getMediaServerId()); if (mediaServerItem != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index bba86a7f..894aa442 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -1,29 +1,13 @@ package com.genersoft.iot.vmp.service.impl; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; -import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IStreamProxyService; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.storager.dao.MediaServerMapper; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.utils.redis.JedisUtil; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import okhttp3.*; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -34,11 +18,30 @@ import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.util.StringUtils; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.genersoft.iot.vmp.common.VideoManagerConstants; +import com.genersoft.iot.vmp.conf.SipConfig; +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; +import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; +import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; +import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; +import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; +import com.genersoft.iot.vmp.service.IMediaServerService; +import com.genersoft.iot.vmp.service.bean.SSRCInfo; +import com.genersoft.iot.vmp.storager.dao.MediaServerMapper; +import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.utils.redis.JedisUtil; +import com.genersoft.iot.vmp.utils.redis.RedisUtil; +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; + +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; /** * 媒体服务器节点管理 @@ -81,12 +84,6 @@ public class MediaServerServiceImpl implements IMediaServerService { @Autowired private RedisUtil redisUtil; - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IStreamProxyService streamProxyService; - @Autowired private EventPublisher publisher; @@ -600,9 +597,6 @@ public class MediaServerServiceImpl implements IMediaServerService { boolean result = false; OkHttpClient client = new OkHttpClient(); String url = String.format("http://%s:%s/index/api/record", ip, port); - - FormBody.Builder builder = new FormBody.Builder(); - Request request = new Request.Builder() .get() .url(url) @@ -652,7 +646,7 @@ public class MediaServerServiceImpl implements IMediaServerService { mediaServerItemMap.put(mediaServerItem.getId(), mediaServerItem); } for (MediaServerItem mediaServerItem : allInCatch) { - if (mediaServerItemMap.get(mediaServerItem) == null) { + if (!mediaServerItemMap.containsKey(mediaServerItem.getId())) { delete(mediaServerItem.getId()); } } 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 ddfbc794..6c909491 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 @@ -1,19 +1,40 @@ package com.genersoft.iot.vmp.service.impl; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.List; +import java.util.Objects; +import java.util.UUID; + +import javax.sip.ResponseEvent; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.context.request.async.DeferredResult; + 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.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; +import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback; +import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo; +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; +import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; @@ -27,23 +48,11 @@ import com.genersoft.iot.vmp.service.bean.PlayBackResult; import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; -import gov.nist.javax.sip.stack.SIPDialog; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.util.ResourceUtils; -import org.springframework.web.context.request.async.DeferredResult; -import javax.sip.ResponseEvent; -import java.io.FileNotFoundException; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.*; +import gov.nist.javax.sip.stack.SIPDialog; @SuppressWarnings(value = {"rawtypes", "unchecked"}) @Service @@ -531,14 +540,6 @@ public class PlayServiceImpl implements IPlayService { StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); streamInfo.setStartTime(startTime); streamInfo.setEndTime(endTime); - if (streamInfo == null) { - logger.warn("录像下载API调用失败!"); - wvpResult.setCode(-1); - wvpResult.setMsg("录像下载API调用失败"); - downloadResult.setCode(-1); - hookCallBack.call(downloadResult); - return ; - } redisCatchStorage.startDownload(streamInfo, inviteStreamInfo.getCallId()); wvpResult.setCode(0); wvpResult.setMsg("success");