From 361e92bd7e3954be1c576e1d0af7ab22dc4ddcd8 Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Tue, 24 May 2022 16:58:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=86=E9=A2=91=E6=B5=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FileController.java | 35 +++++++++++++++++++ .../monitormanage/service/MonitorService.java | 15 ++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/main/java/com/hisense/monitormanage/controller/FileController.java diff --git a/src/main/java/com/hisense/monitormanage/controller/FileController.java b/src/main/java/com/hisense/monitormanage/controller/FileController.java new file mode 100644 index 0000000..ea68df4 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/controller/FileController.java @@ -0,0 +1,35 @@ +package com.hisense.monitormanage.controller; + +import com.hisense.monitormanage.entity.Result; +import com.hisense.monitormanage.service.MonitorService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; + +@RestController +@RequestMapping("api/project") +@Api(tags="视频流") +public class FileController { + + @Autowired + private MonitorService monitorService; + + /** + * 根据摄像头标识获取视频流 + * @param channelCode + * @return + * @throws IOException + */ + @GetMapping("file") + @ApiOperation("根据摄像头标识获取视频流") + public Result File(String channelCode)throws IOException { + String s = monitorService.fileCode(channelCode); + Result success = Result.success(s); + return success; + } +} diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index 8e6101f..3e2f8b5 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -395,6 +395,21 @@ public class MonitorService { grabber.release(); } + } + public String fileCode(String code)throws IOException{ + String url = monitorDomain + "/videoService/realmonitor/uri?scheme=HLS&channelId=" + code; + + HttpHeaders headers = new HttpHeaders(); + headers.add("X-Subject-Token",token); + + ResponseEntity forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), HashMap.class ); + + HashMap body = forEntity.getBody(); + + String file = (String) body.get("url"); + + return file; + } static public List cameras = new LinkedList();