Commit 8ea6e192d9f986045adbaeab54ea062938e9693e

Authored by 648540858
1 parent 14699711

优化拉流代理表单以及逻辑

sql/mysql.sql
@@ -446,7 +446,7 @@ CREATE TABLE `stream_proxy` ( @@ -446,7 +446,7 @@ CREATE TABLE `stream_proxy` (
446 `ffmpeg_cmd_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, 446 `ffmpeg_cmd_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
447 `rtp_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, 447 `rtp_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
448 `mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, 448 `mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
449 - `enable_hls` bit(1) DEFAULT NULL, 449 + `enable_audio` bit(1) DEFAULT NULL,
450 `enable_mp4` bit(1) DEFAULT NULL, 450 `enable_mp4` bit(1) DEFAULT NULL,
451 `enable` bit(1) NOT NULL, 451 `enable` bit(1) NOT NULL,
452 `status` bit(1) NOT NULL, 452 `status` bit(1) NOT NULL,
sql/update.sql
@@ -36,3 +36,8 @@ alter table device @@ -36,3 +36,8 @@ alter table device
36 36
37 alter table device 37 alter table device
38 modify hostAddress varchar(50) null; 38 modify hostAddress varchar(50) null;
  39 +
  40 +alter table stream_proxy
  41 + change enable_hls enable_audio bit null;
  42 +
  43 +
src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java
1 package com.genersoft.iot.vmp.conf; 1 package com.genersoft.iot.vmp.conf;
2 2
3 import com.genersoft.iot.vmp.conf.exception.ControllerException; 3 import com.genersoft.iot.vmp.conf.exception.ControllerException;
4 -import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener;  
5 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; 4 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
6 import com.genersoft.iot.vmp.vmanager.bean.WVPResult; 5 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
7 import org.slf4j.Logger; 6 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory; 7 import org.slf4j.LoggerFactory;
9 import org.springframework.http.HttpStatus; 8 import org.springframework.http.HttpStatus;
  9 +import org.springframework.http.ResponseEntity;
10 import org.springframework.security.authentication.BadCredentialsException; 10 import org.springframework.security.authentication.BadCredentialsException;
11 import org.springframework.web.bind.annotation.ExceptionHandler; 11 import org.springframework.web.bind.annotation.ExceptionHandler;
12 import org.springframework.web.bind.annotation.ResponseStatus; 12 import org.springframework.web.bind.annotation.ResponseStatus;
@@ -40,8 +40,8 @@ public class GlobalExceptionHandler { @@ -40,8 +40,8 @@ public class GlobalExceptionHandler {
40 */ 40 */
41 @ExceptionHandler(ControllerException.class) 41 @ExceptionHandler(ControllerException.class)
42 @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) 42 @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
43 - public WVPResult<String> exceptionHandler(ControllerException e) {  
44 - return WVPResult.fail(e.getCode(), e.getMsg()); 43 + public ResponseEntity<WVPResult<String>> exceptionHandler(ControllerException e) {
  44 + return new ResponseEntity<>(WVPResult.fail(e.getCode(), e.getMsg()), HttpStatus.OK);
45 } 45 }
46 46
47 /** 47 /**
@@ -51,7 +51,7 @@ public class GlobalExceptionHandler { @@ -51,7 +51,7 @@ public class GlobalExceptionHandler {
51 */ 51 */
52 @ExceptionHandler(BadCredentialsException.class) 52 @ExceptionHandler(BadCredentialsException.class)
53 @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) 53 @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
54 - public WVPResult<String> exceptionHandler(BadCredentialsException e) {  
55 - return WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMessage()); 54 + public ResponseEntity<WVPResult<String>> exceptionHandler(BadCredentialsException e) {
  55 + return new ResponseEntity<>(WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMessage()), HttpStatus.OK);
56 } 56 }
57 } 57 }
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -505,6 +505,7 @@ public class ZLMHttpHookListener { @@ -505,6 +505,7 @@ public class ZLMHttpHookListener {
505 // 修改数据 505 // 修改数据
506 streamProxyService.stop(param.getApp(), param.getStream()); 506 streamProxyService.stop(param.getApp(), param.getStream());
507 }else { 507 }else {
  508 + // 无人观看不做处理
508 ret.put("close", false); 509 ret.put("close", false);
509 } 510 }
510 return ret; 511 return ret;
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
@@ -236,14 +236,13 @@ public class ZLMRESTfulUtils { @@ -236,14 +236,13 @@ public class ZLMRESTfulUtils {
236 } 236 }
237 237
238 public JSONObject addFFmpegSource(MediaServerItem mediaServerItem, String src_url, String dst_url, String timeout_ms, 238 public JSONObject addFFmpegSource(MediaServerItem mediaServerItem, String src_url, String dst_url, String timeout_ms,
239 - boolean enable_hls, boolean enable_mp4, String ffmpeg_cmd_key){ 239 + boolean enable_audio, boolean enable_mp4, String ffmpeg_cmd_key){
240 logger.info(src_url); 240 logger.info(src_url);
241 logger.info(dst_url); 241 logger.info(dst_url);
242 Map<String, Object> param = new HashMap<>(); 242 Map<String, Object> param = new HashMap<>();
243 param.put("src_url", src_url); 243 param.put("src_url", src_url);
244 param.put("dst_url", dst_url); 244 param.put("dst_url", dst_url);
245 param.put("timeout_ms", timeout_ms); 245 param.put("timeout_ms", timeout_ms);
246 - param.put("enable_hls", enable_hls);  
247 param.put("enable_mp4", enable_mp4); 246 param.put("enable_mp4", enable_mp4);
248 param.put("ffmpeg_cmd_key", ffmpeg_cmd_key); 247 param.put("ffmpeg_cmd_key", ffmpeg_cmd_key);
249 return sendPost(mediaServerItem, "addFFmpegSource",param, null); 248 return sendPost(mediaServerItem, "addFFmpegSource",param, null);
@@ -287,19 +286,14 @@ public class ZLMRESTfulUtils { @@ -287,19 +286,14 @@ public class ZLMRESTfulUtils {
287 return sendPost(mediaServerItem, "restartServer",null, null); 286 return sendPost(mediaServerItem, "restartServer",null, null);
288 } 287 }
289 288
290 - public JSONObject addStreamProxy(MediaServerItem mediaServerItem, String app, String stream, String url, boolean enable_hls, boolean enable_mp4, String rtp_type) { 289 + public JSONObject addStreamProxy(MediaServerItem mediaServerItem, String app, String stream, String url, boolean enable_audio, boolean enable_mp4, String rtp_type) {
291 Map<String, Object> param = new HashMap<>(); 290 Map<String, Object> param = new HashMap<>();
292 param.put("vhost", "__defaultVhost__"); 291 param.put("vhost", "__defaultVhost__");
293 param.put("app", app); 292 param.put("app", app);
294 param.put("stream", stream); 293 param.put("stream", stream);
295 param.put("url", url); 294 param.put("url", url);
296 - param.put("enable_hls", enable_hls?1:0);  
297 param.put("enable_mp4", enable_mp4?1:0); 295 param.put("enable_mp4", enable_mp4?1:0);
298 - param.put("enable_rtmp", 1);  
299 - param.put("enable_fmp4", 1);  
300 - param.put("enable_audio", 1);  
301 - param.put("enable_rtsp", 1);  
302 - param.put("add_mute_audio", 1); 296 + param.put("enable_audio", enable_audio?1:0);
303 param.put("rtp_type", rtp_type); 297 param.put("rtp_type", rtp_type);
304 return sendPost(mediaServerItem, "addStreamProxy",param, null); 298 return sendPost(mediaServerItem, "addStreamProxy",param, null);
305 } 299 }
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java
@@ -31,8 +31,8 @@ public class StreamProxyItem extends GbStream { @@ -31,8 +31,8 @@ public class StreamProxyItem extends GbStream {
31 private String rtp_type; 31 private String rtp_type;
32 @Schema(description = "是否启用") 32 @Schema(description = "是否启用")
33 private boolean enable; 33 private boolean enable;
34 - @Schema(description = "是否启用HLS")  
35 - private boolean enable_hls; 34 + @Schema(description = "是否启用音频")
  35 + private boolean enable_audio;
36 @Schema(description = "是否启用MP4") 36 @Schema(description = "是否启用MP4")
37 private boolean enable_mp4; 37 private boolean enable_mp4;
38 @Schema(description = "是否 无人观看时删除") 38 @Schema(description = "是否 无人观看时删除")
@@ -40,8 +40,6 @@ public class StreamProxyItem extends GbStream { @@ -40,8 +40,6 @@ public class StreamProxyItem extends GbStream {
40 40
41 @Schema(description = "是否 无人观看时自动停用") 41 @Schema(description = "是否 无人观看时自动停用")
42 private boolean enable_disable_none_reader; 42 private boolean enable_disable_none_reader;
43 - @Schema(description = "上级平台国标ID")  
44 - private String platformGbId;  
45 @Schema(description = "创建时间") 43 @Schema(description = "创建时间")
46 private String createTime; 44 private String createTime;
47 45
@@ -139,14 +137,6 @@ public class StreamProxyItem extends GbStream { @@ -139,14 +137,6 @@ public class StreamProxyItem extends GbStream {
139 this.enable = enable; 137 this.enable = enable;
140 } 138 }
141 139
142 - public boolean isEnable_hls() {  
143 - return enable_hls;  
144 - }  
145 -  
146 - public void setEnable_hls(boolean enable_hls) {  
147 - this.enable_hls = enable_hls;  
148 - }  
149 -  
150 public boolean isEnable_mp4() { 140 public boolean isEnable_mp4() {
151 return enable_mp4; 141 return enable_mp4;
152 } 142 }
@@ -155,19 +145,12 @@ public class StreamProxyItem extends GbStream { @@ -155,19 +145,12 @@ public class StreamProxyItem extends GbStream {
155 this.enable_mp4 = enable_mp4; 145 this.enable_mp4 = enable_mp4;
156 } 146 }
157 147
158 -  
159 - public String getPlatformGbId() {  
160 - return platformGbId;  
161 - }  
162 -  
163 - public void setPlatformGbId(String platformGbId) {  
164 - this.platformGbId = platformGbId;  
165 - }  
166 - 148 + @Override
167 public String getCreateTime() { 149 public String getCreateTime() {
168 return createTime; 150 return createTime;
169 } 151 }
170 152
  153 + @Override
171 public void setCreateTime(String createTime) { 154 public void setCreateTime(String createTime) {
172 this.createTime = createTime; 155 this.createTime = createTime;
173 } 156 }
@@ -187,4 +170,12 @@ public class StreamProxyItem extends GbStream { @@ -187,4 +170,12 @@ public class StreamProxyItem extends GbStream {
187 public void setEnable_disable_none_reader(boolean enable_disable_none_reader) { 170 public void setEnable_disable_none_reader(boolean enable_disable_none_reader) {
188 this.enable_disable_none_reader = enable_disable_none_reader; 171 this.enable_disable_none_reader = enable_disable_none_reader;
189 } 172 }
  173 +
  174 + public boolean isEnable_audio() {
  175 + return enable_audio;
  176 + }
  177 +
  178 + public void setEnable_audio(boolean enable_audio) {
  179 + this.enable_audio = enable_audio;
  180 + }
190 } 181 }
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
@@ -5,23 +5,22 @@ import com.alibaba.fastjson2.JSONObject; @@ -5,23 +5,22 @@ import com.alibaba.fastjson2.JSONObject;
5 import com.genersoft.iot.vmp.common.StreamInfo; 5 import com.genersoft.iot.vmp.common.StreamInfo;
6 import com.genersoft.iot.vmp.conf.UserSetting; 6 import com.genersoft.iot.vmp.conf.UserSetting;
7 import com.genersoft.iot.vmp.conf.exception.ControllerException; 7 import com.genersoft.iot.vmp.conf.exception.ControllerException;
8 -import com.genersoft.iot.vmp.gb28181.bean.GbStream;  
9 import com.genersoft.iot.vmp.gb28181.event.EventPublisher; 8 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
10 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; 9 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
11 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; 10 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
12 -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;  
13 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 11 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
14 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; 12 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
  13 +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
15 import com.genersoft.iot.vmp.service.IGbStreamService; 14 import com.genersoft.iot.vmp.service.IGbStreamService;
16 import com.genersoft.iot.vmp.service.IMediaServerService; 15 import com.genersoft.iot.vmp.service.IMediaServerService;
17 import com.genersoft.iot.vmp.service.IMediaService; 16 import com.genersoft.iot.vmp.service.IMediaService;
  17 +import com.genersoft.iot.vmp.service.IStreamProxyService;
18 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 18 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
19 import com.genersoft.iot.vmp.storager.IVideoManagerStorage; 19 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
20 import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; 20 import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
21 import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; 21 import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
22 import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; 22 import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
23 import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; 23 import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
24 -import com.genersoft.iot.vmp.service.IStreamProxyService;  
25 import com.genersoft.iot.vmp.utils.DateUtil; 24 import com.genersoft.iot.vmp.utils.DateUtil;
26 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; 25 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
27 import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; 26 import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo;
@@ -35,7 +34,9 @@ import org.springframework.transaction.TransactionDefinition; @@ -35,7 +34,9 @@ import org.springframework.transaction.TransactionDefinition;
35 import org.springframework.transaction.TransactionStatus; 34 import org.springframework.transaction.TransactionStatus;
36 import org.springframework.util.ObjectUtils; 35 import org.springframework.util.ObjectUtils;
37 36
38 -import java.util.*; 37 +import java.util.HashMap;
  38 +import java.util.List;
  39 +import java.util.Map;
39 40
40 /** 41 /**
41 * 视频代理业务 42 * 视频代理业务
@@ -107,7 +108,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -107,7 +108,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
107 param.getStream() ); 108 param.getStream() );
108 param.setDst_url(dstUrl); 109 param.setDst_url(dstUrl);
109 StringBuffer resultMsg = new StringBuffer(); 110 StringBuffer resultMsg = new StringBuffer();
110 - boolean streamLive = false;  
111 param.setMediaServerId(mediaInfo.getId()); 111 param.setMediaServerId(mediaInfo.getId());
112 boolean saveResult; 112 boolean saveResult;
113 // 更新 113 // 更新
@@ -124,7 +124,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -124,7 +124,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
124 if (param.isEnable()) { 124 if (param.isEnable()) {
125 JSONObject jsonObject = addStreamProxyToZlm(param); 125 JSONObject jsonObject = addStreamProxyToZlm(param);
126 if (jsonObject == null || jsonObject.getInteger("code") != 0) { 126 if (jsonObject == null || jsonObject.getInteger("code") != 0) {
127 - streamLive = false;  
128 resultMsg.append(", 但是启用失败,请检查流地址是否可用"); 127 resultMsg.append(", 但是启用失败,请检查流地址是否可用");
129 param.setEnable(false); 128 param.setEnable(false);
130 // 直接移除 129 // 直接移除
@@ -134,28 +133,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -134,28 +133,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
134 updateStreamProxy(param); 133 updateStreamProxy(param);
135 } 134 }
136 135
137 -  
138 }else { 136 }else {
139 - streamLive = true;  
140 resultForStreamInfo = mediaService.getStreamInfoByAppAndStream( 137 resultForStreamInfo = mediaService.getStreamInfoByAppAndStream(
141 mediaInfo, param.getApp(), param.getStream(), null, null); 138 mediaInfo, param.getApp(), param.getStream(), null, null);
142 139
143 } 140 }
144 } 141 }
145 - if ( !ObjectUtils.isEmpty(param.getPlatformGbId()) && streamLive) {  
146 - List<GbStream> gbStreams = new ArrayList<>();  
147 - gbStreams.add(param);  
148 - if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId(), param.getCatalogId())){  
149 - return resultForStreamInfo;  
150 - }else {  
151 - resultMsg.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败");  
152 - throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString());  
153 - }  
154 - }else {  
155 - if (!streamLive) {  
156 - throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString());  
157 - }  
158 - }  
159 return resultForStreamInfo; 142 return resultForStreamInfo;
160 } 143 }
161 144
@@ -245,10 +228,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -245,10 +228,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
245 } 228 }
246 if ("default".equals(param.getType())){ 229 if ("default".equals(param.getType())){
247 result = zlmresTfulUtils.addStreamProxy(mediaServerItem, param.getApp(), param.getStream(), param.getUrl(), 230 result = zlmresTfulUtils.addStreamProxy(mediaServerItem, param.getApp(), param.getStream(), param.getUrl(),
248 - param.isEnable_hls(), param.isEnable_mp4(), param.getRtp_type()); 231 + param.isEnable_audio(), param.isEnable_mp4(), param.getRtp_type());
249 }else if ("ffmpeg".equals(param.getType())) { 232 }else if ("ffmpeg".equals(param.getType())) {
250 result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrc_url(), param.getDst_url(), 233 result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrc_url(), param.getDst_url(),
251 - param.getTimeout_ms() + "", param.isEnable_hls(), param.isEnable_mp4(), 234 + param.getTimeout_ms() + "", param.isEnable_audio(), param.isEnable_mp4(),
252 param.getFfmpeg_cmd_key()); 235 param.getFfmpeg_cmd_key());
253 } 236 }
254 return result; 237 return result;
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java
@@ -12,9 +12,9 @@ import java.util.List; @@ -12,9 +12,9 @@ import java.util.List;
12 public interface StreamProxyMapper { 12 public interface StreamProxyMapper {
13 13
14 @Insert("INSERT INTO stream_proxy (type, name, app, stream,mediaServerId, url, src_url, dst_url, " + 14 @Insert("INSERT INTO stream_proxy (type, name, app, stream,mediaServerId, url, src_url, dst_url, " +
15 - "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_hls, enable_mp4, enable, status, enable_remove_none_reader, enable_disable_none_reader, createTime) VALUES" + 15 + "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_audio, enable_mp4, enable, status, enable_remove_none_reader, enable_disable_none_reader, createTime) VALUES" +
16 "('${type}','${name}', '${app}', '${stream}', '${mediaServerId}','${url}', '${src_url}', '${dst_url}', " + 16 "('${type}','${name}', '${app}', '${stream}', '${mediaServerId}','${url}', '${src_url}', '${dst_url}', " +
17 - "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_hls}, ${enable_mp4}, ${enable}, ${status}, " + 17 + "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_audio}, ${enable_mp4}, ${enable}, ${status}, " +
18 "${enable_remove_none_reader}, ${enable_disable_none_reader}, '${createTime}' )") 18 "${enable_remove_none_reader}, ${enable_disable_none_reader}, '${createTime}' )")
19 int add(StreamProxyItem streamProxyDto); 19 int add(StreamProxyItem streamProxyDto);
20 20
@@ -30,7 +30,7 @@ public interface StreamProxyMapper { @@ -30,7 +30,7 @@ public interface StreamProxyMapper {
30 "timeout_ms=#{timeout_ms}, " + 30 "timeout_ms=#{timeout_ms}, " +
31 "ffmpeg_cmd_key=#{ffmpeg_cmd_key}, " + 31 "ffmpeg_cmd_key=#{ffmpeg_cmd_key}, " +
32 "rtp_type=#{rtp_type}, " + 32 "rtp_type=#{rtp_type}, " +
33 - "enable_hls=#{enable_hls}, " + 33 + "enable_audio=#{enable_audio}, " +
34 "enable=#{enable}, " + 34 "enable=#{enable}, " +
35 "status=#{status}, " + 35 "status=#{status}, " +
36 "enable_remove_none_reader=#{enable_remove_none_reader}, " + 36 "enable_remove_none_reader=#{enable_remove_none_reader}, " +
web_src/src/components/StreamProxyList.vue
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 <el-table-column label="类型" width="100" > 32 <el-table-column label="类型" width="100" >
33 <template slot-scope="scope"> 33 <template slot-scope="scope">
34 <div slot="reference" class="name-wrapper"> 34 <div slot="reference" class="name-wrapper">
35 - <el-tag size="medium">{{scope.row.type}}</el-tag> 35 + <el-tag size="medium">{{scope.row.type === "default"? "直接代理":"FFMPEG代理"}}</el-tag>
36 </div> 36 </div>
37 </template> 37 </template>
38 </el-table-column> 38 </el-table-column>
@@ -55,15 +55,15 @@ @@ -55,15 +55,15 @@
55 </template> 55 </template>
56 </el-table-column> 56 </el-table-column>
57 <el-table-column prop="createTime" label="创建时间" min-width="150" show-overflow-tooltip/> 57 <el-table-column prop="createTime" label="创建时间" min-width="150" show-overflow-tooltip/>
58 - <el-table-column label="转HLS" min-width="120" > 58 + <el-table-column label="音频" min-width="120" >
59 <template slot-scope="scope"> 59 <template slot-scope="scope">
60 <div slot="reference" class="name-wrapper"> 60 <div slot="reference" class="name-wrapper">
61 - <el-tag size="medium" v-if="scope.row.enable_hls">已启用</el-tag>  
62 - <el-tag size="medium" type="info" v-if="!scope.row.enable_hls">未启用</el-tag> 61 + <el-tag size="medium" v-if="scope.row.enable_audio">已启用</el-tag>
  62 + <el-tag size="medium" type="info" v-if="!scope.row.enable_audio">未启用</el-tag>
63 </div> 63 </div>
64 </template> 64 </template>
65 </el-table-column> 65 </el-table-column>
66 - <el-table-column label="MP4录制" min-width="120" > 66 + <el-table-column label="录制" min-width="120" >
67 <template slot-scope="scope"> 67 <template slot-scope="scope">
68 <div slot="reference" class="name-wrapper"> 68 <div slot="reference" class="name-wrapper">
69 <el-tag size="medium" v-if="scope.row.enable_mp4">已启用</el-tag> 69 <el-tag size="medium" v-if="scope.row.enable_mp4">已启用</el-tag>
@@ -71,11 +71,12 @@ @@ -71,11 +71,12 @@
71 </div> 71 </div>
72 </template> 72 </template>
73 </el-table-column> 73 </el-table-column>
74 - <el-table-column label="无人观看自动删除" min-width="160" > 74 + <el-table-column label="无人观看" min-width="160" >
75 <template slot-scope="scope"> 75 <template slot-scope="scope">
76 <div slot="reference" class="name-wrapper"> 76 <div slot="reference" class="name-wrapper">
77 - <el-tag size="medium" v-if="scope.row.enable_remove_none_reader">已启用</el-tag>  
78 - <el-tag size="medium" type="info" v-if="!scope.row.enable_remove_none_reader">未启用</el-tag> 77 + <el-tag size="medium" v-if="scope.row.enable_remove_none_reader">移除</el-tag>
  78 + <el-tag size="medium" v-if="scope.row.enable_disable_none_reader">停用</el-tag>
  79 + <el-tag size="medium" type="info" v-if="!scope.row.enable_remove_none_reader && !scope.row.enable_disable_none_reader">不做处理</el-tag>
79 </div> 80 </div>
80 </template> 81 </template>
81 </el-table-column> 82 </el-table-column>
@@ -131,7 +132,6 @@ @@ -131,7 +132,6 @@
131 currentPage:1, 132 currentPage:1,
132 count:15, 133 count:15,
133 total:0, 134 total:0,
134 - getListLoading: false,  
135 startBtnLoading: false 135 startBtnLoading: false
136 }; 136 };
137 }, 137 },
@@ -139,7 +139,7 @@ @@ -139,7 +139,7 @@
139 }, 139 },
140 mounted() { 140 mounted() {
141 this.initData(); 141 this.initData();
142 - this.updateLooper = setInterval(this.initData, 1000); 142 + this.startUpdateList()
143 }, 143 },
144 destroyed() { 144 destroyed() {
145 this.$destroy('videojs'); 145 this.$destroy('videojs');
@@ -149,6 +149,12 @@ @@ -149,6 +149,12 @@
149 initData: function() { 149 initData: function() {
150 this.getStreamProxyList(); 150 this.getStreamProxyList();
151 }, 151 },
  152 + stopUpdateList: function (){
  153 + window.clearInterval(this.updateLooper)
  154 + },
  155 + startUpdateList: function (){
  156 + this.updateLooper = setInterval(this.initData, 1000);
  157 + },
152 currentChange: function(val){ 158 currentChange: function(val){
153 this.currentPage = val; 159 this.currentPage = val;
154 this.getStreamProxyList(); 160 this.getStreamProxyList();
@@ -159,7 +165,6 @@ @@ -159,7 +165,6 @@
159 }, 165 },
160 getStreamProxyList: function() { 166 getStreamProxyList: function() {
161 let that = this; 167 let that = this;
162 - this.getListLoading = true;  
163 this.$axios({ 168 this.$axios({
164 method: 'get', 169 method: 'get',
165 url:`/api/proxy/list`, 170 url:`/api/proxy/list`,
@@ -175,23 +180,18 @@ @@ -175,23 +180,18 @@
175 } 180 }
176 that.streamProxyList = res.data.data.list; 181 that.streamProxyList = res.data.data.list;
177 } 182 }
178 - that.getListLoading = false;  
179 }).catch(function (error) { 183 }).catch(function (error) {
180 console.log(error); 184 console.log(error);
181 - that.getListLoading = false;  
182 }); 185 });
183 }, 186 },
184 addStreamProxy: function(){ 187 addStreamProxy: function(){
185 this.$refs.streamProxyEdit.openDialog(null, this.initData) 188 this.$refs.streamProxyEdit.openDialog(null, this.initData)
186 }, 189 },
187 addOnvif: function(){ 190 addOnvif: function(){
188 - this.getListLoading = true;  
189 - this.getListLoading = true;  
190 this.$axios({ 191 this.$axios({
191 method: 'get', 192 method: 'get',
192 url:`/api/onvif/search?timeout=3000`, 193 url:`/api/onvif/search?timeout=3000`,
193 }).then((res) =>{ 194 }).then((res) =>{
194 - this.getListLoading = false;  
195 if (res.data.code === 0 ){ 195 if (res.data.code === 0 ){
196 if (res.data.data.length > 0) { 196 if (res.data.data.length > 0) {
197 this.$refs.onvifEdit.openDialog(res.data.data, (url)=>{ 197 this.$refs.onvifEdit.openDialog(res.data.data, (url)=>{
@@ -208,7 +208,6 @@ @@ -208,7 +208,6 @@
208 } 208 }
209 209
210 }).catch((error)=> { 210 }).catch((error)=> {
211 - this.getListLoading = false;  
212 this.$message.error(error.response.data.msg); 211 this.$message.error(error.response.data.msg);
213 }); 212 });
214 213
@@ -217,7 +216,6 @@ @@ -217,7 +216,6 @@
217 }, 216 },
218 play: function(row){ 217 play: function(row){
219 let that = this; 218 let that = this;
220 - this.getListLoading = true;  
221 this.$axios({ 219 this.$axios({
222 method: 'get', 220 method: 'get',
223 url:`/api/push/getPlayUrl`, 221 url:`/api/push/getPlayUrl`,
@@ -227,7 +225,6 @@ @@ -227,7 +225,6 @@
227 mediaServerId: row.mediaServerId 225 mediaServerId: row.mediaServerId
228 } 226 }
229 }).then(function (res) { 227 }).then(function (res) {
230 - that.getListLoading = false;  
231 if (res.data.code === 0) { 228 if (res.data.code === 0) {
232 that.$refs.devicePlayer.openDialog("streamPlay", null, null, { 229 that.$refs.devicePlayer.openDialog("streamPlay", null, null, {
233 streamInfo: res.data.data, 230 streamInfo: res.data.data,
@@ -243,13 +240,11 @@ @@ -243,13 +240,11 @@
243 240
244 }).catch(function (error) { 241 }).catch(function (error) {
245 console.log(error); 242 console.log(error);
246 - that.getListLoading = false;  
247 }); 243 });
248 244
249 }, 245 },
250 deleteStreamProxy: function(row){ 246 deleteStreamProxy: function(row){
251 let that = this; 247 let that = this;
252 - this.getListLoading = true;  
253 that.$axios({ 248 that.$axios({
254 method:"delete", 249 method:"delete",
255 url:"/api/proxy/del", 250 url:"/api/proxy/del",
@@ -258,16 +253,13 @@ @@ -258,16 +253,13 @@
258 stream: row.stream 253 stream: row.stream
259 } 254 }
260 }).then((res)=>{ 255 }).then((res)=>{
261 - that.getListLoading = false;  
262 that.initData() 256 that.initData()
263 }).catch(function (error) { 257 }).catch(function (error) {
264 console.log(error); 258 console.log(error);
265 - that.getListLoading = false;  
266 }); 259 });
267 }, 260 },
268 start: function(row){ 261 start: function(row){
269 - let that = this;  
270 - this.getListLoading = true; 262 + this.stopUpdateList()
271 this.$set(row, 'startBtnLoading', true) 263 this.$set(row, 'startBtnLoading', true)
272 this.$axios({ 264 this.$axios({
273 method: 'get', 265 method: 'get',
@@ -276,28 +268,31 @@ @@ -276,28 +268,31 @@
276 app: row.app, 268 app: row.app,
277 stream: row.stream 269 stream: row.stream
278 } 270 }
279 - }).then(function (res) {  
280 - that.getListLoading = false;  
281 - that.$set(row, 'startBtnLoading', false) 271 + }).then((res)=> {
282 if (res.data.code === 0){ 272 if (res.data.code === 0){
283 - that.initData() 273 + this.initData()
284 }else { 274 }else {
285 - that.$message({ 275 + this.$message({
286 showClose: true, 276 showClose: true,
287 - message: "保存失败,请检查地址是否可用!", 277 + message: "启动失败,请检查地址是否可用!",
288 type: "error", 278 type: "error",
289 }); 279 });
290 } 280 }
291 -  
292 - }).catch(function (error) { 281 + this.$set(row, 'startBtnLoading', false)
  282 + this.startUpdateList()
  283 + }).catch((error)=> {
293 console.log(error); 284 console.log(error);
294 - that.getListLoading = false;  
295 - that.$set(row, 'startBtnLoading', false) 285 + this.$message({
  286 + showClose: true,
  287 + message: "启动失败,请检查地址是否可用!",
  288 + type: "error",
  289 + });
  290 + this.$set(row, 'startBtnLoading', false)
  291 + this.startUpdateList()
296 }); 292 });
297 }, 293 },
298 stop: function(row){ 294 stop: function(row){
299 let that = this; 295 let that = this;
300 - this.getListLoading = true;  
301 this.$axios({ 296 this.$axios({
302 method: 'get', 297 method: 'get',
303 url:`/api/proxy/stop`, 298 url:`/api/proxy/stop`,
@@ -306,11 +301,9 @@ @@ -306,11 +301,9 @@
306 stream: row.stream 301 stream: row.stream
307 } 302 }
308 }).then(function (res) { 303 }).then(function (res) {
309 - that.getListLoading = false;  
310 that.initData() 304 that.initData()
311 }).catch(function (error) { 305 }).catch(function (error) {
312 console.log(error); 306 console.log(error);
313 - that.getListLoading = false;  
314 }); 307 });
315 }, 308 },
316 refresh: function (){ 309 refresh: function (){
web_src/src/components/dialog/StreamProxyEdit.vue
@@ -83,31 +83,23 @@ @@ -83,31 +83,23 @@
83 <el-option label="组播" value="2"></el-option> 83 <el-option label="组播" value="2"></el-option>
84 </el-select> 84 </el-select>
85 </el-form-item> 85 </el-form-item>
86 -  
87 - <el-form-item label="国标平台">  
88 - <el-select  
89 - v-model="proxyParam.platformGbId"  
90 - style="width: 100%"  
91 - placeholder="请选择国标平台"  
92 - >  
93 - <el-option  
94 - v-for="item in platformList"  
95 - :key="item.name"  
96 - :label="item.name"  
97 - :value="item.serverGBId">  
98 - <span style="float: left">{{ item.name }}</span>  
99 - <span style="float: right; color: #8492a6; font-size: 13px">{{ item.serverGBId }}</span>  
100 - </el-option>  
101 - </el-select>  
102 - </el-form-item> 86 + <el-form-item label="无人观看" prop="rtp_type" >
  87 + <el-select
  88 + @change="noneReaderHandler"
  89 + v-model="proxyParam.none_reader"
  90 + style="width: 100%"
  91 + placeholder="请选择无人观看的处理方式"
  92 + >
  93 + <el-option label="不做处理" value="0"></el-option>
  94 + <el-option label="停用" value="1"></el-option>
  95 + <el-option label="移除" value="2"></el-option>
  96 + </el-select>
  97 + </el-form-item>
103 <el-form-item label="其他选项"> 98 <el-form-item label="其他选项">
104 <div style="float: left;"> 99 <div style="float: left;">
105 <el-checkbox label="启用" v-model="proxyParam.enable" ></el-checkbox> 100 <el-checkbox label="启用" v-model="proxyParam.enable" ></el-checkbox>
106 - <el-checkbox label="转HLS" v-model="proxyParam.enable_hls" ></el-checkbox>  
107 - <el-checkbox label="MP4录制" v-model="proxyParam.enable_mp4" ></el-checkbox>  
108 - <el-checkbox label="无人观看自动删除" v-model="proxyParam.enable_remove_none_reader" @change="removeNoneReader"></el-checkbox>  
109 - <el-checkbox label="无人观看停止拉流" v-model="proxyParam.enable_disable_none_reader" @change="disableNoneReaderHandType"></el-checkbox>  
110 - 101 + <el-checkbox label="开启音频" v-model="proxyParam.enable_audio" ></el-checkbox>
  102 + <el-checkbox label="录制" v-model="proxyParam.enable_mp4" ></el-checkbox>
111 </div> 103 </div>
112 104
113 </el-form-item> 105 </el-form-item>
@@ -169,10 +161,11 @@ export default { @@ -169,10 +161,11 @@ export default {
169 gbId: null, 161 gbId: null,
170 rtp_type: null, 162 rtp_type: null,
171 enable: true, 163 enable: true,
172 - enable_hls: true, 164 + enable_audio: true,
173 enable_mp4: false, 165 enable_mp4: false,
  166 + none_reader: null,
174 enable_remove_none_reader: false, 167 enable_remove_none_reader: false,
175 - enable_disable_none_reader: true, 168 + enable_disable_none_reader: false,
176 platformGbId: null, 169 platformGbId: null,
177 mediaServerId: null, 170 mediaServerId: null,
178 }, 171 },
@@ -196,6 +189,7 @@ export default { @@ -196,6 +189,7 @@ export default {
196 this.listChangeCallback = callback; 189 this.listChangeCallback = callback;
197 if (proxyParam != null) { 190 if (proxyParam != null) {
198 this.proxyParam = proxyParam; 191 this.proxyParam = proxyParam;
  192 + this.proxyParam.none_reader = null;
199 } 193 }
200 194
201 let that = this; 195 let that = this;
@@ -233,26 +227,26 @@ export default { @@ -233,26 +227,26 @@ export default {
233 }, 227 },
234 onSubmit: function () { 228 onSubmit: function () {
235 this.dialogLoading = true; 229 this.dialogLoading = true;
236 - var that = this;  
237 - that.$axios({ 230 + this.noneReaderHandler();
  231 + this.$axios({
238 method: 'post', 232 method: 'post',
239 url:`/api/proxy/save`, 233 url:`/api/proxy/save`,
240 - data: that.proxyParam  
241 - }).then(function (res) {  
242 - that.dialogLoading = false; 234 + data: this.proxyParam
  235 + }).then((res)=> {
  236 + this.dialogLoading = false;
243 if (typeof (res.data.code) != "undefined" && res.data.code === 0) { 237 if (typeof (res.data.code) != "undefined" && res.data.code === 0) {
244 - that.$message({ 238 + this.$message({
245 showClose: true, 239 showClose: true,
246 message: res.data.msg, 240 message: res.data.msg,
247 type: "success", 241 type: "success",
248 }); 242 });
249 - that.showDialog = false;  
250 - if (that.listChangeCallback != null) {  
251 - that.listChangeCallback();  
252 - that.dialogLoading = false; 243 + this.showDialog = false;
  244 + if (this.listChangeCallback != null) {
  245 + this.listChangeCallback();
  246 + this.dialogLoading = false;
253 } 247 }
254 } 248 }
255 - }).catch(function (error) { 249 + }).catch((error) =>{
256 console.log(error); 250 console.log(error);
257 this.dialogLoading = false; 251 this.dialogLoading = false;
258 }); 252 });
@@ -280,12 +274,18 @@ export default { @@ -280,12 +274,18 @@ export default {
280 this.platform.expires = "300"; 274 this.platform.expires = "300";
281 } 275 }
282 }, 276 },
283 - removeNoneReader: function(checked) {  
284 - this.proxyParam.enable_disable_none_reader = !checked; 277 + noneReaderHandler: function() {
  278 + if (this.proxyParam.none_reader === null || this.proxyParam.none_reader === "0") {
  279 + this.proxyParam.enable_disable_none_reader = false;
  280 + this.proxyParam.enable_remove_none_reader = false;
  281 + }else if (this.proxyParam.none_reader === "1"){
  282 + this.proxyParam.enable_disable_none_reader = true;
  283 + this.proxyParam.enable_remove_none_reader = false;
  284 + }else if (this.proxyParam.none_reader ==="2"){
  285 + this.proxyParam.enable_disable_none_reader = false;
  286 + this.proxyParam.enable_remove_none_reader = true;
  287 + }
285 }, 288 },
286 - disableNoneReaderHandType: function(checked) {  
287 - this.proxyParam.enable_remove_none_reader = !checked;  
288 - }  
289 }, 289 },
290 }; 290 };
291 </script> 291 </script>