Browse Source

bug修改

S0025136190 1 year ago
parent
commit
69ef7f938a

+ 1 - 0
Backend/sample/src/main/java/com/dji/sample/common/smsp/CallSmsp.java

@@ -95,6 +95,7 @@ public class CallSmsp {
             return rtmpUrlDTO;
         } catch (Exception e) {
             e.printStackTrace();
+            rtmpUrlDTO.setMessage("获取流媒体地址异常:"+e.getMessage());
             return rtmpUrlDTO;
         }
     }

+ 8 - 2
Backend/sample/src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java

@@ -13,6 +13,7 @@ import com.dji.sdk.common.HttpResultResponse;
 import com.dji.sdk.common.SDKManager;
 import com.dji.sdk.mqtt.services.ServicesReplyData;
 import com.dji.sdk.mqtt.services.TopicServicesResponse;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -27,6 +28,7 @@ import java.util.stream.Collectors;
  * @date 2021/11/22
  * @version 0.1
  */
+@Slf4j
 @Service
 @Transactional
 public class LiveStreamServiceImpl implements ILiveStreamService {
@@ -109,7 +111,9 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
                         .setVideoQuality(liveParam.getVideoQuality()));
 
         if (!response.getData().getResult().isSuccess()) {
-            throw new RuntimeException(response.getData().getResult().getMessage());
+            //throw new RuntimeException(response.getData().getResult().getMessage());
+            log.info("推流失败,请确认推流地址有效:" + livestreamUrlDTO.getRtmpUrl());
+            throw new RuntimeException("推流失败,请确认推流地址有效:" + livestreamUrlDTO.getRtmpUrl());
         }
 
         TopicServicesResponse<ServicesReplyData> qResponse = abstractLivestreamService.liveSetQuality(
@@ -117,7 +121,9 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
                         .setVideoQuality(liveParam.getVideoQuality())
                         .setVideoId(liveParam.getVideoId()));
         if (!qResponse.getData().getResult().isSuccess()) {
-            throw new RuntimeException(qResponse.getData().getResult().getMessage());
+            //throw new RuntimeException(qResponse.getData().getResult().getMessage());
+            log.info("设置清晰度"+liveParam.getVideoQuality().getQuality()+"失败.");
+            throw new RuntimeException("设置清晰度"+liveParam.getVideoQuality().getQuality()+"失败.");
         }
 
         LiveDTO live = new LiveDTO();

+ 4 - 10
Backend/sample/src/main/java/com/dji/sample/manage/service/impl/ManageDeviceLivestreamUrlServiceImpl.java

@@ -4,27 +4,22 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.dji.sample.common.smsp.CallSmsp;
 import com.dji.sample.common.util.DesUtil;
 import com.dji.sample.configuration.CustomConfiguration;
-import com.dji.sample.manage.dao.IDevicePayloadMapper;
 import com.dji.sample.manage.dao.IManageDeviceLivestreamUrlMapper;
 import com.dji.sample.manage.dao.IUserMapper;
 import com.dji.sample.manage.model.dto.ManageDeviceLivestreamUrlDTO;
 import com.dji.sample.manage.model.dto.RtmpUrlDTO;
-import com.dji.sample.manage.model.entity.DevicePayloadEntity;
 import com.dji.sample.manage.model.entity.ManageDeviceLivestreamUrlEntity;
 import com.dji.sample.manage.model.entity.UserEntity;
 import com.dji.sample.manage.model.enums.LiveUrlTypeEnum;
 import com.dji.sample.manage.model.enums.UserTypeEnum;
 import com.dji.sample.manage.service.IManageDeviceLivestreamUrlService;
 import com.dji.sdk.cloudapi.device.DeviceSubTypeEnum;
-import com.dji.sdk.common.HttpResultResponse;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -43,7 +38,7 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
 
 
     @Override
-    public ManageDeviceLivestreamUrlDTO getUrl(ManageDeviceLivestreamUrlDTO deviceLivestreamUrlDTO) {
+    public ManageDeviceLivestreamUrlDTO getUrl(ManageDeviceLivestreamUrlDTO deviceLivestreamUrlDTO,String protocal) {
 
 
         QueryWrapper<UserEntity> userWrapper = new QueryWrapper<>();
@@ -62,7 +57,7 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
         }
 
         //获取rtmp地址
-        RtmpUrlDTO rtmpUrlDTO = CallSmsp.getRtmp(tokenMap.get("Token"),deviceLivestreamUrlDTO.getDeviceSn());
+        RtmpUrlDTO rtmpUrlDTO = CallSmsp.getRtmp(tokenMap.get("Token"),deviceLivestreamUrlDTO.getDeviceSn(),protocal);
         ManageDeviceLivestreamUrlDTO rtmpDto = new ManageDeviceLivestreamUrlDTO();
 
         //获取数据库中deviceSn对应的url信息
@@ -72,14 +67,13 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
         List<ManageDeviceLivestreamUrlEntity> urlListFromDB = mapper.selectList(wrapper);
 
         if(urlListFromDB.size() == 0 && rtmpUrlDTO.getMessage() != null ){
-            log.debug("The result is null.");
             if(tokenMap.get("message") != null) {
                 throw new RuntimeException (tokenMap.get("message"));
             }
             if(rtmpUrlDTO.getMessage() != null) {
                 throw new RuntimeException (rtmpUrlDTO.getMessage());
             }
-            throw new RuntimeException ("The result is null.");
+            throw new RuntimeException ("获取推流拉流地址异常,请联系技术人员确认!");
         }
         List<ManageDeviceLivestreamUrlDTO> rtmpList =  new ArrayList<>();
         if (rtmpUrlDTO.getList().size() > 0) {
@@ -145,7 +139,7 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
                 rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
                 rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
             } else {
-                throw new RuntimeException("the url is null.");
+                throw new RuntimeException("没有获取到可以使用的推流和拉流地址");
             }
         }
         return rtmpDto;