From b6e604f2449bb65dfaafb0f0741ba54ff0d2f9c2 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 30 四月 2024 15:20:03 +0800
Subject: [PATCH] 修改云端录像详情页使用直接访问zlm的方式播放录像
---
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java | 45 +++++++++++++++++++++++++--------------------
1 files changed, 25 insertions(+), 20 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
old mode 100644
new mode 100755
index 6f7132e..26e9685
--- 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
@@ -2,16 +2,19 @@
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
+import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
+import com.genersoft.iot.vmp.media.service.IMediaServerService;
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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -24,7 +27,7 @@
@Tag(name = "濯掍綋娴佺浉鍏�")
@Controller
-@CrossOrigin
+
@RequestMapping(value = "/api/media")
public class MediaController {
@@ -34,9 +37,10 @@
private IRedisCatchStorage redisCatchStorage;
@Autowired
- private IMediaService mediaService;
- @Autowired
private IStreamProxyService streamProxyService;
+
+ @Autowired
+ private IMediaServerService mediaServerService;
/**
@@ -45,7 +49,7 @@
* @param stream 娴乮d
* @return
*/
- @Operation(summary = "鏍规嵁搴旂敤鍚嶅拰娴乮d鑾峰彇鎾斁鍦板潃")
+ @Operation(summary = "鏍规嵁搴旂敤鍚嶅拰娴乮d鑾峰彇鎾斁鍦板潃", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "app", description = "搴旂敤鍚�", required = true)
@Parameter(name = "stream", description = "娴乮d", required = true)
@Parameter(name = "mediaServerId", description = "濯掍綋鏈嶅姟鍣╥d")
@@ -53,19 +57,21 @@
@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);
+ throw new ControllerException(ErrorCode.ERROR400.getCode(), "鑾峰彇鎾斁鍦板潃閴存潈澶辫触");
}
}else {
// 鏄惁鐧婚檰鐢ㄦ埛, 鐧婚檰鐢ㄦ埛杩斿洖瀹屾暣淇℃伅
@@ -81,14 +87,13 @@
String host = request.getHeader("Host");
String localAddr = host.split(":")[0];
logger.info("浣跨敤{}浣滀负杩斿洖娴佺殑ip", localAddr);
- streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority);
+ streamInfo = mediaServerService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority);
}else {
- streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
+ streamInfo = mediaServerService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
}
- WVPResult<StreamInfo> result = new WVPResult<>();
if (streamInfo != null){
- return streamInfo;
+ return new StreamContent(streamInfo);
}else {
//鑾峰彇娴佸け璐ワ紝閲嶅惎鎷夋祦鍚庨噸璇曚竴娆�
streamProxyService.stop(app,stream);
@@ -102,12 +107,12 @@
String host = request.getHeader("Host");
String localAddr = host.split(":")[0];
logger.info("浣跨敤{}浣滀负杩斿洖娴佺殑ip", localAddr);
- streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority);
+ streamInfo = mediaServerService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority);
}else {
- streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
+ streamInfo = mediaServerService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
}
if (streamInfo != null){
- return streamInfo;
+ return new StreamContent(streamInfo);
}else {
throw new ControllerException(ErrorCode.ERROR100);
}
--
Gitblit v1.8.0