Commit b9b5d5af by xmh

分析流点播逻辑修改

平台需要配置 srs 的 ip,rtmp 端口,以及 http访问端口(这里要走nginx转发)
路径由平台进行拼接
1 parent e942ff0e
...@@ -2,6 +2,7 @@ package com.viontech.fanxing.commons.config; ...@@ -2,6 +2,7 @@ package com.viontech.fanxing.commons.config;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -19,6 +20,7 @@ import java.util.List; ...@@ -19,6 +20,7 @@ import java.util.List;
@Getter @Getter
@Setter @Setter
@ConfigurationProperties(prefix = "vion") @ConfigurationProperties(prefix = "vion")
@Slf4j
public class VionConfig { public class VionConfig {
private Image image; private Image image;
...@@ -31,7 +33,8 @@ public class VionConfig { ...@@ -31,7 +33,8 @@ public class VionConfig {
private List<String> supportedVideoFormats; private List<String> supportedVideoFormats;
/** 需要跳过 token 验证的 url 的正则表达式列表 */ /** 需要跳过 token 验证的 url 的正则表达式列表 */
private List<String> skipAuth; private List<String> skipAuth;
/** 平台srs的配置 */
private Srs srs;
public @Getter public @Getter
@Setter @Setter
...@@ -53,4 +56,26 @@ public class VionConfig { ...@@ -53,4 +56,26 @@ public class VionConfig {
private String port; private String port;
} }
public @Getter
@Setter
static class Srs {
private String ip;
private String rtmpPort = "1935";
private String httpPort = "8080";
public String getRtmpUrl(String taskUnid) {
String url = "rtmp://" + ip + ":" + rtmpPort + "/live/" + taskUnid;
log.debug(url);
return url;
}
public String getHttpUrl(String taskUnid) {
String url = "http://36.112.68.214:30008/live/" + taskUnid + ".flv";
// String url = "http://" + ip + ":" + httpPort + "/" + taskUnid + ".flv";
log.debug(url);
return url;
}
}
} }
...@@ -76,8 +76,8 @@ public class VAServerController { ...@@ -76,8 +76,8 @@ public class VAServerController {
@PostMapping("/startAnalyzeStream") @PostMapping("/startAnalyzeStream")
public Object startAnalyzeStream(@RequestBody JSONObject object) { public Object startAnalyzeStream(@RequestBody JSONObject object) {
String taskUnid = object.getString("taskUnid"); String taskUnid = object.getString("taskUnid");
String url = object.getString("url"); String s = vaServerService.startAnalyzeStream(taskUnid);
return vaServerService.startAnalyzeStream(taskUnid, url); return JsonMessageUtil.getSuccessJsonMsg("success", s);
} }
/** /**
......
...@@ -242,6 +242,6 @@ public class TaskController extends TaskBaseController { ...@@ -242,6 +242,6 @@ public class TaskController extends TaskBaseController {
} }
build.put("success", taskId); build.put("success", taskId);
} }
return JsonMessageUtil.getSuccessJsonMsg(build); return JsonMessageUtil.getSuccessJsonMsg("success", build);
} }
} }
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.task.service; package com.viontech.fanxing.task.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.config.VionConfig;
import com.viontech.fanxing.commons.constant.RedisKeys; import com.viontech.fanxing.commons.constant.RedisKeys;
import com.viontech.fanxing.commons.exception.FanXingException; import com.viontech.fanxing.commons.exception.FanXingException;
import com.viontech.fanxing.commons.model.Task; import com.viontech.fanxing.commons.model.Task;
...@@ -35,6 +36,8 @@ public class VAServerService { ...@@ -35,6 +36,8 @@ public class VAServerService {
private TaskDataService taskDataService; private TaskDataService taskDataService;
@Resource @Resource
private VAServerHttpService vaServerHttpService; private VAServerHttpService vaServerHttpService;
@Resource
private VionConfig vionConfig;
/** /**
* 设备注册 * 设备注册
...@@ -142,6 +145,9 @@ public class VAServerService { ...@@ -142,6 +145,9 @@ public class VAServerService {
public Object snapshot(String taskUnid) { public Object snapshot(String taskUnid) {
VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid); VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid);
if (vaServerInfo != null) { if (vaServerInfo != null) {
if (vaServerInfo.getStatus() == 0) {
throw new FanXingException("设备离线");
}
return vaServerHttpService.snapshot(taskUnid, vaServerInfo); return vaServerHttpService.snapshot(taskUnid, vaServerInfo);
} else { } else {
throw new FanXingException("任务不在运行状态", taskUnid); throw new FanXingException("任务不在运行状态", taskUnid);
...@@ -154,6 +160,9 @@ public class VAServerService { ...@@ -154,6 +160,9 @@ public class VAServerService {
public Object getAnalyzeStream(String taskUnid) { public Object getAnalyzeStream(String taskUnid) {
VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid); VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid);
if (vaServerInfo != null) { if (vaServerInfo != null) {
if (vaServerInfo.getStatus() == 0) {
throw new FanXingException("设备离线");
}
return vaServerHttpService.getAnalyzeStream(taskUnid, vaServerInfo); return vaServerHttpService.getAnalyzeStream(taskUnid, vaServerInfo);
} else { } else {
throw new FanXingException("任务不在运行状态", taskUnid); throw new FanXingException("任务不在运行状态", taskUnid);
...@@ -163,10 +172,20 @@ public class VAServerService { ...@@ -163,10 +172,20 @@ public class VAServerService {
/** /**
* 输出分析流 * 输出分析流
*/ */
public Object startAnalyzeStream(String taskUnid, String url) { public String startAnalyzeStream(String taskUnid) {
TaskData taskData = taskDataService.getRepository().getTaskDataByUnid(taskUnid);
if (taskData == null) {
throw new FanXingException("找不到对应的任务");
}
VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid); VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid);
if (vaServerInfo != null) { if (vaServerInfo != null) {
return vaServerHttpService.startAnalyzeStream(taskUnid, vaServerInfo, url); if (vaServerInfo.getStatus() == 0) {
throw new FanXingException("设备离线");
}
String rtmpUrl = vionConfig.getSrs().getRtmpUrl(taskUnid);
String httpUrl = vionConfig.getSrs().getHttpUrl(taskUnid);
vaServerHttpService.startAnalyzeStream(taskUnid, vaServerInfo, rtmpUrl);
return httpUrl;
} else { } else {
throw new FanXingException("任务不在运行状态", taskUnid); throw new FanXingException("任务不在运行状态", taskUnid);
} }
...@@ -186,6 +205,9 @@ public class VAServerService { ...@@ -186,6 +205,9 @@ public class VAServerService {
public JSONObject getStatus(String devId) { public JSONObject getStatus(String devId) {
VaServerInfo vaServerInfo = vaServerRedisRepository.getVAServerInfoById(devId); VaServerInfo vaServerInfo = vaServerRedisRepository.getVAServerInfoById(devId);
if (vaServerInfo != null) { if (vaServerInfo != null) {
if (vaServerInfo.getStatus() == 0) {
throw new FanXingException("设备离线");
}
return vaServerHttpService.status(vaServerInfo); return vaServerHttpService.status(vaServerInfo);
} else { } else {
throw new FanXingException("无法获取到对应的设备", devId); throw new FanXingException("无法获取到对应的设备", devId);
...@@ -198,6 +220,9 @@ public class VAServerService { ...@@ -198,6 +220,9 @@ public class VAServerService {
public Object switchScene(String taskUnid, String sceneId) { public Object switchScene(String taskUnid, String sceneId) {
VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid); VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid);
if (vaServerInfo != null) { if (vaServerInfo != null) {
if (vaServerInfo.getStatus() == 0) {
throw new FanXingException("设备离线");
}
return vaServerHttpService.switchScene(taskUnid, vaServerInfo, sceneId); return vaServerHttpService.switchScene(taskUnid, vaServerInfo, sceneId);
} else { } else {
throw new FanXingException("任务不在运行状态", taskUnid); throw new FanXingException("任务不在运行状态", taskUnid);
...@@ -222,6 +247,9 @@ public class VAServerService { ...@@ -222,6 +247,9 @@ public class VAServerService {
public Object getRotationStatus(String taskUnid) { public Object getRotationStatus(String taskUnid) {
VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid); VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid);
if (vaServerInfo != null) { if (vaServerInfo != null) {
if (vaServerInfo.getStatus() == 0) {
throw new FanXingException("设备离线");
}
return vaServerHttpService.getRotationStatus(taskUnid, vaServerInfo); return vaServerHttpService.getRotationStatus(taskUnid, vaServerInfo);
} else { } else {
throw new FanXingException("任务不在运行状态", taskUnid); throw new FanXingException("任务不在运行状态", taskUnid);
...@@ -231,6 +259,9 @@ public class VAServerService { ...@@ -231,6 +259,9 @@ public class VAServerService {
public JSONObject getCurrentScene(String taskUnid) { public JSONObject getCurrentScene(String taskUnid) {
VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid); VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid);
if (vaServerInfo != null) { if (vaServerInfo != null) {
if (vaServerInfo.getStatus() == 0) {
throw new FanXingException("设备离线");
}
return vaServerHttpService.getCurrentScene(taskUnid, vaServerInfo); return vaServerHttpService.getCurrentScene(taskUnid, vaServerInfo);
} else { } else {
throw new FanXingException("任务不在运行状态", taskUnid); throw new FanXingException("任务不在运行状态", taskUnid);
......
...@@ -54,6 +54,10 @@ logging: ...@@ -54,6 +54,10 @@ logging:
vion: vion:
redisson: redisson:
path: F:\myIDEAworkspace\jt\fanxing3\fanxing-commons\src\main\resources\redisson.yml path: F:\myIDEAworkspace\jt\fanxing3\fanxing-commons\src\main\resources\redisson.yml
srs:
ip: 192.168.9.233
rtmp-port: 1935
http-port: 8080
gateway: gateway:
ip: 192.168.9.233 ip: 192.168.9.233
port: 30000 port: 30000
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!