|
@@ -99,6 +99,59 @@ public class RealTimePreviewVideoController {
|
|
|
}
|
|
}
|
|
|
return Result.error("请求失败");
|
|
return Result.error("请求失败");
|
|
|
}
|
|
}
|
|
|
|
|
+ @ApiOperation(value = "HLS、FLV、RTMP实时预览接口方式")
|
|
|
|
|
+ @PostMapping("/getHFRUrl")
|
|
|
|
|
+ public Result getHFRUrl(VideoPlayRequest request){
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ String jsonParams = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonParams = objectMapper.writeValueAsString(request);
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ log.error("JSON序列化失败: {}", e);
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ String authorization = redisTemplate
|
|
|
|
|
+ .opsForValue()
|
|
|
|
|
+ .get("Authorization:" + iccConfigProperty.getUsername());
|
|
|
|
|
+ // 创建请求体
|
|
|
|
|
+ RequestBody body = RequestBody.create(jsonParams, JSON);
|
|
|
|
|
+ // 构建请求
|
|
|
|
|
+ Request requestHttp = new Request.Builder()
|
|
|
|
|
+ .url("https://" + iccConfigProperty.getHost() + "/evo-apigw/admin/API/video/stream/realtime")
|
|
|
|
|
+ .addHeader("Authorization", authorization)
|
|
|
|
|
+ .post(body)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ // 发送请求
|
|
|
|
|
+ try (Response response = httpClient.newCall(requestHttp).execute()) {
|
|
|
|
|
+ if (!response.isSuccessful()) {
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ ResponseBody responseBody = response.body();
|
|
|
|
|
+ if (responseBody != null) {
|
|
|
|
|
+ String responseString = responseBody.string();
|
|
|
|
|
+ JsonNode rootNode = objectMapper.readTree(responseString);
|
|
|
|
|
+ JsonNode success = rootNode.path("success");
|
|
|
|
|
+ if("true".equals(success.asText())) {
|
|
|
|
|
+ JsonNode dataNode = rootNode.path("data");
|
|
|
|
|
+ if (dataNode != null) {
|
|
|
|
|
+ return Result.ok(dataNode);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return Result.ok(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ JsonNode code = rootNode.path("code");
|
|
|
|
|
+ if("1001".equals(code.asText())){
|
|
|
|
|
+ return Result.error("未查询到视频信息");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ return Result.error("HLS、FLV、RTMP实时预览失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ log.error("请求失败: {}", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@ApiOperation(value = "查询普通录像信息列表")
|
|
@ApiOperation(value = "查询普通录像信息列表")
|
|
|
@PostMapping("/queryOrdinaryList")
|
|
@PostMapping("/queryOrdinaryList")
|