From 276f077dc7aafed06982f6fb0746f6a421ddf73b Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 23 十二月 2022 16:52:30 +0800
Subject: [PATCH] 优化接口

---
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java
index 6f7132e..d135fa2 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java
@@ -5,11 +5,11 @@
 import com.genersoft.iot.vmp.conf.security.SecurityUtils;
 import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
 import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
-import com.genersoft.iot.vmp.service.IStreamProxyService;
 import com.genersoft.iot.vmp.service.IMediaService;
+import com.genersoft.iot.vmp.service.IStreamProxyService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
-import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
+import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -53,16 +53,18 @@
     @Parameter(name = "useSourceIpAsStreamIp", description = "鏄惁浣跨敤璇锋眰IP浣滀负杩斿洖鐨勫湴鍧�IP")
     @GetMapping(value = "/stream_info_by_app_and_stream")
     @ResponseBody
-    public StreamInfo getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
-                                                             @RequestParam String stream,
-                                                             @RequestParam(required = false) String mediaServerId,
-                                                             @RequestParam(required = false) String callId,
-                                                             @RequestParam(required = false) Boolean useSourceIpAsStreamIp){
+    public StreamContent getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
+                                                     @RequestParam String stream,
+                                                     @RequestParam(required = false) String mediaServerId,
+                                                     @RequestParam(required = false) String callId,
+                                                     @RequestParam(required = false) Boolean useSourceIpAsStreamIp){
         boolean authority = false;
         if (callId != null) {
             // 鏉冮檺鏍¢獙
             StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
-            if (streamAuthorityInfo.getCallId().equals(callId)) {
+            if (streamAuthorityInfo != null
+                    && streamAuthorityInfo.getCallId() != null
+                    && streamAuthorityInfo.getCallId().equals(callId)) {
                 authority = true;
             }else {
                 throw new ControllerException(ErrorCode.ERROR400);
@@ -86,9 +88,8 @@
             streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
         }
 
-        WVPResult<StreamInfo> result = new WVPResult<>();
         if (streamInfo != null){
-            return  streamInfo;
+            return  new StreamContent(streamInfo);
         }else {
             //鑾峰彇娴佸け璐ワ紝閲嶅惎鎷夋祦鍚庨噸璇曚竴娆�
             streamProxyService.stop(app,stream);
@@ -107,7 +108,7 @@
                 streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
             }
             if (streamInfo != null){
-                return  streamInfo;
+                return new StreamContent(streamInfo);
             }else {
                 throw new ControllerException(ErrorCode.ERROR100);
             }

--
Gitblit v1.8.0