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();