新增视频流接口
This commit is contained in:
parent
c440713b68
commit
361e92bd7e
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<HashMap> 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<Map>();
|
||||
|
|
Loading…
Reference in New Issue