소스 검색

添加直播开始日志

S0025136190 1 년 전
부모
커밋
8aa3fffe10

+ 12 - 5
Backend/sample/src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java

@@ -119,7 +119,8 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
 
 
 
-
+        long sTime = System.currentTimeMillis();
+        log.info("==========向飞机推送直播请求开始:" + sTime);
         TopicServicesResponse<ServicesReplyData<String>> response = abstractLivestreamService.liveStartPush(
                 SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()),
                 new LiveStartPushRequest()
@@ -133,7 +134,10 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
             log.info("推流失败,请确认推流地址有效:" + livestreamUrlDTO.getRtmpUrl());
             throw new RuntimeException("推流失败,请确认推流地址有效:" + livestreamUrlDTO.getRtmpUrl());
         }
-
+        long eTime = System.currentTimeMillis();
+        log.info("==========向飞机推送直播请求结束:" +  eTime + ",耗时:" + (eTime - sTime));
+        long ssTime = System.currentTimeMillis();
+        log.info("==========设置清晰度开始:" + ssTime);
         TopicServicesResponse<ServicesReplyData> qResponse = abstractLivestreamService.liveSetQuality(
                 SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveSetQualityRequest()
                         .setVideoQuality(liveParam.getVideoQuality())
@@ -143,7 +147,8 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
             log.info("设置清晰度"+liveParam.getVideoQuality().getQuality()+"失败.");
             throw new RuntimeException("设置清晰度"+liveParam.getVideoQuality().getQuality()+"失败.");
         }
-
+        long seTime = System.currentTimeMillis();
+        log.info("==========设置清晰度结束:" +  seTime + ",耗时:" + (seTime - ssTime));
         LiveDTO live = new LiveDTO();
 
         switch (liveParam.getUrlType()) {
@@ -186,14 +191,16 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
         if (HttpResultResponse.CODE_SUCCESS != responseResult.getCode()) {
             return responseResult;
         }
-
+        long sTime = System.currentTimeMillis();
+        log.info("==========请求直播中止开始:" + sTime);
         TopicServicesResponse<ServicesReplyData> response = abstractLivestreamService.liveStopPush(
                 SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveStopPushRequest()
                         .setVideoId(videoId));
         if (!response.getData().getResult().isSuccess()) {
             return HttpResultResponse.error(response.getData().getResult());
         }
-
+        long eTime = System.currentTimeMillis();
+        log.info("==========请求直播中止结束:" +  sTime + ",耗时:" + (eTime - sTime));
         return HttpResultResponse.success();
     }
 

+ 25 - 2
Backend/sample/src/main/java/com/dji/sample/manage/service/impl/ManageDeviceLivestreamUrlServiceImpl.java

@@ -45,7 +45,8 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
     @Override
     public ManageDeviceLivestreamUrlDTO getUrl(ManageDeviceLivestreamUrlDTO deviceLivestreamUrlDTO,String protocal) {
 
-
+        long sTime = System.currentTimeMillis();
+        log.info("==========获取流媒体Url开始:" + sTime);
         QueryWrapper<UserEntity> userWrapper = new QueryWrapper<>();
         userWrapper.lambda().eq(UserEntity::getUserType, UserTypeEnum.API.getVal()).eq(UserEntity::getClientId, CustomConfiguration.clientId);
         UserEntity userEntity = userMapper.selectOne(userWrapper);
@@ -56,16 +57,25 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
         //密码解密
         String password = DesUtil.getDecryptData(userEntity.getPassword(),userEntity.getSalt());
         //获取token
+        long tSTime = System.currentTimeMillis();
+        log.info("==========获取流媒体token开始:" + tSTime);
         Map<String,String> tokenMap = CallSmsp.getSmspToken(userEntity.getUsername(),password,protocal);
         if(tokenMap.get("Token") == null) {
             log.info("调用流媒体服务,获取token失败");
         }
-
+        long tETime = System.currentTimeMillis();
+        log.info("==========获取流媒体token结束:" + tETime + ",耗时:" + (tETime - tSTime));
         //获取rtmp地址
+        long trSTime = System.currentTimeMillis();
+        log.info("==========获取流媒体rtmp开始:" + trSTime);
         RtmpUrlDTO rtmpUrlDTO = CallSmsp.getRtmp(tokenMap.get("Token"),deviceLivestreamUrlDTO.getDeviceSn(),protocal);
+        long trETime = System.currentTimeMillis();
+        log.info("==========获取流媒体rtmp结束:" + trETime + ",耗时:" + (trETime - trSTime));
         ManageDeviceLivestreamUrlDTO rtmpDto = new ManageDeviceLivestreamUrlDTO();
 
         //获取数据库中deviceSn对应的url信息
+        long dbSTime = System.currentTimeMillis();
+        log.info("==========查询数据库信息:" + dbSTime);
         QueryWrapper<ManageDeviceLivestreamUrlEntity> wrapper = new QueryWrapper<>();
         wrapper.lambda().eq(ManageDeviceLivestreamUrlEntity::getDeviceSn,deviceLivestreamUrlDTO.getDeviceSn())
                 .eq(ManageDeviceLivestreamUrlEntity::getWorkspaceId,deviceLivestreamUrlDTO.getWorkspaceId());
@@ -93,22 +103,28 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
                 .collect(Collectors.toList());
         if (filterIndexList.size() > 0) {
             //筛选数据库中channelId相同的记录
+            log.info("==========payloadIndex数据库中存在============");
             List<ManageDeviceLivestreamUrlDTO> channelList =
                     rtmpList.stream().filter(channelData -> filterIndexList.get(0).getChannelId().equals(channelData.getChannelId()))
                     .collect(Collectors.toList());
             if (channelList.size() > 0) {
+                log.info("==========rtmp存在,更新rtmpUrl============");
                 update(filterIndexList,channelList);
                 rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
                 rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
             } else {
                 if(rtmpList.size() > 0) {
                     //筛选数据库中不存在的记录
+                    log.info("==========rtmp不存在,新增rtmpUrl============");
                     channelList = rtmpList.stream().filter(channelData -> !urlL.contains(channelData.getChannelId()))
                             .collect(Collectors.toList());
                     update(filterIndexList,channelList);
                     rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
                     rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
+                    long dbETime = System.currentTimeMillis();
+                    log.info("==========查询数据库结束:" + trETime + ",耗时:" + (dbETime - dbSTime));
                 } else {
+                    log.info("==========rtmp存在,直接返回rtmpUrl============");
                     for(ManageDeviceLivestreamUrlEntity url : filterIndexList) {
                         if (url.getUrlType().equals(LiveUrlTypeEnum.RTMP.getVal())) {
                             rtmpDto.setRtmpUrl(url.getUrl());
@@ -116,10 +132,13 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
                             rtmpDto.setWebRtcUrl(url.getUrl());
                         }
                     }
+                    long dbETime = System.currentTimeMillis();
+                    log.info("==========查询数据库结束:" + trETime + ",耗时:" + (dbETime - dbSTime));
                 }
             }
         } else {
             //数据库中不存在
+            log.info("==========数据库中都存在,第一次使用该摄像头,新增记录============");
             List<ManageDeviceLivestreamUrlDTO> channelList =
                     rtmpList.stream().filter(channelData -> !urlL.contains(channelData.getChannelId()))
                             .collect(Collectors.toList());
@@ -146,7 +165,11 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
             } else {
                 throw new RuntimeException("没有获取到可以使用的推流和拉流地址");
             }
+            long dbETime = System.currentTimeMillis();
+            log.info("==========查询数据库结束:" + trETime + ",耗时:" + (dbETime - dbSTime));
         }
+        long eTime = System.currentTimeMillis();
+        log.info("==========获取流媒体Url开结束:" + trETime + ",耗时:" + (eTime - sTime));
         return rtmpDto;
     }