Commit 720231d33f387c6d1bf13bdef653314c5c450809
1 parent
4d920745
添加发送媒体流, 添加媒体服务器节点管理ui,修复修改密码
Showing
30 changed files
with
890 additions
and
47 deletions
sql/mysql.sql
| @@ -140,6 +140,7 @@ create table media_server | @@ -140,6 +140,7 @@ create table media_server | ||
| 140 | streamNoneReaderDelayMS int not null, | 140 | streamNoneReaderDelayMS int not null, |
| 141 | rtpEnable int not null, | 141 | rtpEnable int not null, |
| 142 | rtpPortRange varchar(50) not null, | 142 | rtpPortRange varchar(50) not null, |
| 143 | + sendRtpPortRange varchar(50) not null, | ||
| 143 | recordAssistPort int not null, | 144 | recordAssistPort int not null, |
| 144 | defaultServer int not null, | 145 | defaultServer int not null, |
| 145 | createTime varchar(50) not null, | 146 | createTime varchar(50) not null, |
src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java
| @@ -18,6 +18,9 @@ import javax.servlet.http.HttpServletResponse; | @@ -18,6 +18,9 @@ import javax.servlet.http.HttpServletResponse; | ||
| 18 | import java.io.IOException; | 18 | import java.io.IOException; |
| 19 | import java.text.SimpleDateFormat; | 19 | import java.text.SimpleDateFormat; |
| 20 | 20 | ||
| 21 | +/** | ||
| 22 | + * @author lin | ||
| 23 | + */ | ||
| 21 | @WebFilter(filterName = "ApiAccessFilter", urlPatterns = "/api/*", asyncSupported=true) | 24 | @WebFilter(filterName = "ApiAccessFilter", urlPatterns = "/api/*", asyncSupported=true) |
| 22 | public class ApiAccessFilter extends OncePerRequestFilter { | 25 | public class ApiAccessFilter extends OncePerRequestFilter { |
| 23 | 26 |
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
| @@ -68,6 +68,10 @@ public class MediaConfig{ | @@ -68,6 +68,10 @@ public class MediaConfig{ | ||
| 68 | @Value("${media.rtp.port-range}") | 68 | @Value("${media.rtp.port-range}") |
| 69 | private String rtpPortRange; | 69 | private String rtpPortRange; |
| 70 | 70 | ||
| 71 | + | ||
| 72 | + @Value("${media.rtp.send-port-range}") | ||
| 73 | + private String sendRtpPortRange; | ||
| 74 | + | ||
| 71 | @Value("${media.record-assist-port:0}") | 75 | @Value("${media.record-assist-port:0}") |
| 72 | private Integer recordAssistPort = 0; | 76 | private Integer recordAssistPort = 0; |
| 73 | 77 | ||
| @@ -165,6 +169,14 @@ public class MediaConfig{ | @@ -165,6 +169,14 @@ public class MediaConfig{ | ||
| 165 | } | 169 | } |
| 166 | } | 170 | } |
| 167 | 171 | ||
| 172 | + public String getSipDomain() { | ||
| 173 | + return sipDomain; | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + public String getSendRtpPortRange() { | ||
| 177 | + return sendRtpPortRange; | ||
| 178 | + } | ||
| 179 | + | ||
| 168 | public MediaServerItem getMediaSerItem(){ | 180 | public MediaServerItem getMediaSerItem(){ |
| 169 | MediaServerItem mediaServerItem = new MediaServerItem(); | 181 | MediaServerItem mediaServerItem = new MediaServerItem(); |
| 170 | mediaServerItem.setId(id); | 182 | mediaServerItem.setId(id); |
| @@ -185,6 +197,7 @@ public class MediaConfig{ | @@ -185,6 +197,7 @@ public class MediaConfig{ | ||
| 185 | mediaServerItem.setStreamNoneReaderDelayMS(streamNoneReaderDelayMS); | 197 | mediaServerItem.setStreamNoneReaderDelayMS(streamNoneReaderDelayMS); |
| 186 | mediaServerItem.setRtpEnable(rtpEnable); | 198 | mediaServerItem.setRtpEnable(rtpEnable); |
| 187 | mediaServerItem.setRtpPortRange(rtpPortRange); | 199 | mediaServerItem.setRtpPortRange(rtpPortRange); |
| 200 | + mediaServerItem.setSendRtpPortRange(sendRtpPortRange); | ||
| 188 | mediaServerItem.setRecordAssistPort(recordAssistPort); | 201 | mediaServerItem.setRecordAssistPort(recordAssistPort); |
| 189 | 202 | ||
| 190 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 203 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
| @@ -21,6 +21,9 @@ import javax.servlet.http.HttpServletRequest; | @@ -21,6 +21,9 @@ import javax.servlet.http.HttpServletRequest; | ||
| 21 | import java.io.IOException; | 21 | import java.io.IOException; |
| 22 | import java.net.ConnectException; | 22 | import java.net.ConnectException; |
| 23 | 23 | ||
| 24 | +/** | ||
| 25 | + * @author lin | ||
| 26 | + */ | ||
| 24 | @SuppressWarnings(value = {"rawtypes", "unchecked"}) | 27 | @SuppressWarnings(value = {"rawtypes", "unchecked"}) |
| 25 | @Configuration | 28 | @Configuration |
| 26 | public class ProxyServletConfig { | 29 | public class ProxyServletConfig { |
| @@ -35,7 +38,7 @@ public class ProxyServletConfig { | @@ -35,7 +38,7 @@ public class ProxyServletConfig { | ||
| 35 | 38 | ||
| 36 | @Bean | 39 | @Bean |
| 37 | public ServletRegistrationBean zlmServletRegistrationBean(){ | 40 | public ServletRegistrationBean zlmServletRegistrationBean(){ |
| 38 | - ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new ZLMProxySerlet(),"/zlm/*"); | 41 | + ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new ZlmProxyServlet(),"/zlm/*"); |
| 39 | servletRegistrationBean.setName("zlm_Proxy"); | 42 | servletRegistrationBean.setName("zlm_Proxy"); |
| 40 | servletRegistrationBean.addInitParameter("targetUri", "http://127.0.0.1:6080"); | 43 | servletRegistrationBean.addInitParameter("targetUri", "http://127.0.0.1:6080"); |
| 41 | servletRegistrationBean.addUrlMappings(); | 44 | servletRegistrationBean.addUrlMappings(); |
| @@ -45,7 +48,7 @@ public class ProxyServletConfig { | @@ -45,7 +48,7 @@ public class ProxyServletConfig { | ||
| 45 | return servletRegistrationBean; | 48 | return servletRegistrationBean; |
| 46 | } | 49 | } |
| 47 | 50 | ||
| 48 | - class ZLMProxySerlet extends ProxyServlet{ | 51 | + class ZlmProxyServlet extends ProxyServlet{ |
| 49 | @Override | 52 | @Override |
| 50 | protected String rewriteQueryStringFromRequest(HttpServletRequest servletRequest, String queryString) { | 53 | protected String rewriteQueryStringFromRequest(HttpServletRequest servletRequest, String queryString) { |
| 51 | String queryStr = super.rewriteQueryStringFromRequest(servletRequest, queryString); | 54 | String queryStr = super.rewriteQueryStringFromRequest(servletRequest, queryString); |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
| @@ -8,6 +8,7 @@ import org.slf4j.Logger; | @@ -8,6 +8,7 @@ import org.slf4j.Logger; | ||
| 8 | import org.slf4j.LoggerFactory; | 8 | import org.slf4j.LoggerFactory; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
| 11 | +import org.springframework.util.StringUtils; | ||
| 11 | 12 | ||
| 12 | import java.util.HashMap; | 13 | import java.util.HashMap; |
| 13 | import java.util.Map; | 14 | import java.util.Map; |
| @@ -44,8 +45,15 @@ public class ZLMRTPServerFactory { | @@ -44,8 +45,15 @@ public class ZLMRTPServerFactory { | ||
| 44 | 45 | ||
| 45 | Map<String, Object> param = new HashMap<>(); | 46 | Map<String, Object> param = new HashMap<>(); |
| 46 | int result = -1; | 47 | int result = -1; |
| 47 | - int newPort = getPortFromportRange(mediaServerItem); | ||
| 48 | - param.put("port", newPort); | 48 | + /** |
| 49 | + * 不设置推流端口端则使用随机端口 | ||
| 50 | + */ | ||
| 51 | + if (StringUtils.isEmpty(mediaServerItem.getSendRtpPortRange())){ | ||
| 52 | + param.put("port", 0); | ||
| 53 | + }else { | ||
| 54 | + int newPort = getPortFromportRange(mediaServerItem); | ||
| 55 | + param.put("port", newPort); | ||
| 56 | + } | ||
| 49 | param.put("enable_tcp", 1); | 57 | param.put("enable_tcp", 1); |
| 50 | param.put("stream_id", streamId); | 58 | param.put("stream_id", streamId); |
| 51 | JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param); | 59 | JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param); |
| @@ -53,24 +61,24 @@ public class ZLMRTPServerFactory { | @@ -53,24 +61,24 @@ public class ZLMRTPServerFactory { | ||
| 53 | if (openRtpServerResultJson != null) { | 61 | if (openRtpServerResultJson != null) { |
| 54 | switch (openRtpServerResultJson.getInteger("code")){ | 62 | switch (openRtpServerResultJson.getInteger("code")){ |
| 55 | case 0: | 63 | case 0: |
| 56 | - result= newPort; | 64 | + result= openRtpServerResultJson.getInteger("port"); |
| 57 | break; | 65 | break; |
| 58 | case -300: // id已经存在, 可能已经在其他端口推流 | 66 | case -300: // id已经存在, 可能已经在其他端口推流 |
| 59 | Map<String, Object> closeRtpServerParam = new HashMap<>(); | 67 | Map<String, Object> closeRtpServerParam = new HashMap<>(); |
| 60 | closeRtpServerParam.put("stream_id", streamId); | 68 | closeRtpServerParam.put("stream_id", streamId); |
| 61 | zlmresTfulUtils.closeRtpServer(mediaServerItem, closeRtpServerParam); | 69 | zlmresTfulUtils.closeRtpServer(mediaServerItem, closeRtpServerParam); |
| 62 | - result = newPort; | 70 | + result = createRTPServer(mediaServerItem, streamId);; |
| 63 | break; | 71 | break; |
| 64 | case -400: // 端口占用 | 72 | case -400: // 端口占用 |
| 65 | result= createRTPServer(mediaServerItem, streamId); | 73 | result= createRTPServer(mediaServerItem, streamId); |
| 66 | break; | 74 | break; |
| 67 | default: | 75 | default: |
| 68 | - logger.error("创建RTP Server 失败 {}: " + openRtpServerResultJson.getString("msg"), newPort); | 76 | + logger.error("创建RTP Server 失败 {}: " + openRtpServerResultJson.getString("msg"), param.get("port")); |
| 69 | break; | 77 | break; |
| 70 | } | 78 | } |
| 71 | }else { | 79 | }else { |
| 72 | // 检查ZLM状态 | 80 | // 检查ZLM状态 |
| 73 | - logger.error("创建RTP Server 失败 {}: 请检查ZLM服务", newPort); | 81 | + logger.error("创建RTP Server 失败 {}: 请检查ZLM服务", param.get("port")); |
| 74 | } | 82 | } |
| 75 | return result; | 83 | return result; |
| 76 | } | 84 | } |
| @@ -98,7 +106,7 @@ public class ZLMRTPServerFactory { | @@ -98,7 +106,7 @@ public class ZLMRTPServerFactory { | ||
| 98 | private int getPortFromportRange(MediaServerItem mediaServerItem) { | 106 | private int getPortFromportRange(MediaServerItem mediaServerItem) { |
| 99 | int currentPort = mediaServerItem.getCurrentPort(); | 107 | int currentPort = mediaServerItem.getCurrentPort(); |
| 100 | if (currentPort == 0) { | 108 | if (currentPort == 0) { |
| 101 | - String[] portRangeStrArray = mediaServerItem.getRtpPortRange().split(","); | 109 | + String[] portRangeStrArray = mediaServerItem.getSendRtpPortRange().split(","); |
| 102 | portRangeArray[0] = Integer.parseInt(portRangeStrArray[0]); | 110 | portRangeArray[0] = Integer.parseInt(portRangeStrArray[0]); |
| 103 | portRangeArray[1] = Integer.parseInt(portRangeStrArray[1]); | 111 | portRangeArray[1] = Integer.parseInt(portRangeStrArray[1]); |
| 104 | } | 112 | } |
| @@ -229,7 +237,9 @@ public class ZLMRTPServerFactory { | @@ -229,7 +237,9 @@ public class ZLMRTPServerFactory { | ||
| 229 | */ | 237 | */ |
| 230 | public int totalReaderCount(MediaServerItem mediaServerItem, String app, String streamId) { | 238 | public int totalReaderCount(MediaServerItem mediaServerItem, String app, String streamId) { |
| 231 | JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtmp", streamId); | 239 | JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtmp", streamId); |
| 232 | - if (mediaInfo == null) return 0; | 240 | + if (mediaInfo == null) { |
| 241 | + return 0; | ||
| 242 | + } | ||
| 233 | return mediaInfo.getInteger("totalReaderCount"); | 243 | return mediaInfo.getInteger("totalReaderCount"); |
| 234 | } | 244 | } |
| 235 | 245 |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| @@ -108,8 +108,10 @@ public class ZLMRunner implements CommandLineRunner { | @@ -108,8 +108,10 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | public ZLMServerConfig getMediaServerConfig(MediaServerItem mediaServerItem) { | 110 | public ZLMServerConfig getMediaServerConfig(MediaServerItem mediaServerItem) { |
| 111 | - if (startGetMedia == null) return null; | ||
| 112 | - if ( startGetMedia.get(mediaServerItem.getId()) == null || !startGetMedia.get(mediaServerItem.getId())) return null; | 111 | + if (startGetMedia == null) { return null;} |
| 112 | + if ( startGetMedia.get(mediaServerItem.getId()) == null || !startGetMedia.get(mediaServerItem.getId())) { | ||
| 113 | + return null; | ||
| 114 | + } | ||
| 113 | JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); | 115 | JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); |
| 114 | ZLMServerConfig ZLMServerConfig = null; | 116 | ZLMServerConfig ZLMServerConfig = null; |
| 115 | if (responseJSON != null) { | 117 | if (responseJSON != null) { |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaServerItem.java
| @@ -41,14 +41,20 @@ public class MediaServerItem{ | @@ -41,14 +41,20 @@ public class MediaServerItem{ | ||
| 41 | 41 | ||
| 42 | private boolean rtpEnable; | 42 | private boolean rtpEnable; |
| 43 | 43 | ||
| 44 | + private boolean status; | ||
| 45 | + | ||
| 44 | private String rtpPortRange; | 46 | private String rtpPortRange; |
| 45 | 47 | ||
| 48 | + private String sendRtpPortRange; | ||
| 49 | + | ||
| 46 | private int recordAssistPort; | 50 | private int recordAssistPort; |
| 47 | 51 | ||
| 48 | private String createTime; | 52 | private String createTime; |
| 49 | 53 | ||
| 50 | private String updateTime; | 54 | private String updateTime; |
| 51 | 55 | ||
| 56 | + private String lastKeepaliveTime; | ||
| 57 | + | ||
| 52 | private boolean defaultServer; | 58 | private boolean defaultServer; |
| 53 | 59 | ||
| 54 | private SsrcConfig ssrcConfig; | 60 | private SsrcConfig ssrcConfig; |
| @@ -82,6 +88,7 @@ public class MediaServerItem{ | @@ -82,6 +88,7 @@ public class MediaServerItem{ | ||
| 82 | secret = zlmServerConfig.getApiSecret(); | 88 | secret = zlmServerConfig.getApiSecret(); |
| 83 | streamNoneReaderDelayMS = zlmServerConfig.getGeneralStreamNoneReaderDelayMS(); | 89 | streamNoneReaderDelayMS = zlmServerConfig.getGeneralStreamNoneReaderDelayMS(); |
| 84 | rtpEnable = false; // 默认使用单端口;直到用户自己设置开启多端口 | 90 | rtpEnable = false; // 默认使用单端口;直到用户自己设置开启多端口 |
| 91 | + rtpPortRange = "30000,30500"; // 默认使用30000,30500作为级联时发送流的端口号 | ||
| 85 | recordAssistPort = 0; // 默认关闭 | 92 | recordAssistPort = 0; // 默认关闭 |
| 86 | 93 | ||
| 87 | } | 94 | } |
| @@ -278,5 +285,27 @@ public class MediaServerItem{ | @@ -278,5 +285,27 @@ public class MediaServerItem{ | ||
| 278 | this.currentPort = currentPort; | 285 | this.currentPort = currentPort; |
| 279 | } | 286 | } |
| 280 | 287 | ||
| 288 | + public boolean isStatus() { | ||
| 289 | + return status; | ||
| 290 | + } | ||
| 281 | 291 | ||
| 292 | + public void setStatus(boolean status) { | ||
| 293 | + this.status = status; | ||
| 294 | + } | ||
| 295 | + | ||
| 296 | + public String getLastKeepaliveTime() { | ||
| 297 | + return lastKeepaliveTime; | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + public void setLastKeepaliveTime(String lastKeepaliveTime) { | ||
| 301 | + this.lastKeepaliveTime = lastKeepaliveTime; | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + public String getSendRtpPortRange() { | ||
| 305 | + return sendRtpPortRange; | ||
| 306 | + } | ||
| 307 | + | ||
| 308 | + public void setSendRtpPortRange(String sendRtpPortRange) { | ||
| 309 | + this.sendRtpPortRange = sendRtpPortRange; | ||
| 310 | + } | ||
| 282 | } | 311 | } |
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
| @@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | @@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | ||
| 4 | import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; | 4 | import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 6 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 6 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 7 | +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | ||
| 7 | 8 | ||
| 8 | import java.util.List; | 9 | import java.util.List; |
| 9 | 10 | ||
| @@ -49,7 +50,11 @@ public interface IMediaServerService { | @@ -49,7 +50,11 @@ public interface IMediaServerService { | ||
| 49 | 50 | ||
| 50 | void clearMediaServerForOnline(); | 51 | void clearMediaServerForOnline(); |
| 51 | 52 | ||
| 52 | - void add(MediaServerItem mediaSerItem); | 53 | + WVPResult<String> add(MediaServerItem mediaSerItem); |
| 53 | 54 | ||
| 54 | void resetOnlineServerItem(MediaServerItem serverItem); | 55 | void resetOnlineServerItem(MediaServerItem serverItem); |
| 56 | + | ||
| 57 | + WVPResult<MediaServerItem> checkMediaServer(String ip, int port, String secret); | ||
| 58 | + | ||
| 59 | + boolean checkMediaRecordServer(String ip, int port); | ||
| 55 | } | 60 | } |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| 1 | package com.genersoft.iot.vmp.service.impl; | 1 | package com.genersoft.iot.vmp.service.impl; |
| 2 | 2 | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 3 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 4 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 5 | import com.genersoft.iot.vmp.common.VideoManagerConstants; | 6 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| @@ -14,10 +15,11 @@ import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; | @@ -14,10 +15,11 @@ import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; | ||
| 14 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 15 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 15 | import com.genersoft.iot.vmp.service.IMediaServerService; | 16 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 16 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 17 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 17 | -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | ||
| 18 | import com.genersoft.iot.vmp.storager.dao.MediaServerMapper; | 18 | import com.genersoft.iot.vmp.storager.dao.MediaServerMapper; |
| 19 | import com.genersoft.iot.vmp.utils.redis.JedisUtil; | 19 | import com.genersoft.iot.vmp.utils.redis.JedisUtil; |
| 20 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; | 20 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 21 | +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | ||
| 22 | +import okhttp3.*; | ||
| 21 | import org.slf4j.Logger; | 23 | import org.slf4j.Logger; |
| 22 | import org.slf4j.LoggerFactory; | 24 | import org.slf4j.LoggerFactory; |
| 23 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -57,9 +59,6 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -57,9 +59,6 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 57 | private MediaServerMapper mediaServerMapper; | 59 | private MediaServerMapper mediaServerMapper; |
| 58 | 60 | ||
| 59 | @Autowired | 61 | @Autowired |
| 60 | - private IRedisCatchStorage redisCatchStorage; | ||
| 61 | - | ||
| 62 | - @Autowired | ||
| 63 | private VideoStreamSessionManager streamSession; | 62 | private VideoStreamSessionManager streamSession; |
| 64 | 63 | ||
| 65 | @Autowired | 64 | @Autowired |
| @@ -97,7 +96,9 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -97,7 +96,9 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 97 | 96 | ||
| 98 | @Override | 97 | @Override |
| 99 | public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId) { | 98 | public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId) { |
| 100 | - if (mediaServerItem == null || mediaServerItem.getId() == null) return null; | 99 | + if (mediaServerItem == null || mediaServerItem.getId() == null) { |
| 100 | + return null; | ||
| 101 | + } | ||
| 101 | // 获取mediaServer可用的ssrc | 102 | // 获取mediaServer可用的ssrc |
| 102 | String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + mediaServerItem.getId(); | 103 | String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + mediaServerItem.getId(); |
| 103 | 104 | ||
| @@ -107,7 +108,9 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -107,7 +108,9 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 107 | return null; | 108 | return null; |
| 108 | }else { | 109 | }else { |
| 109 | String ssrc = ssrcConfig.getPlaySsrc(); | 110 | String ssrc = ssrcConfig.getPlaySsrc(); |
| 110 | - if (streamId == null) streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); | 111 | + if (streamId == null) { |
| 112 | + streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); | ||
| 113 | + } | ||
| 111 | int rtpServerPort = mediaServerItem.getRtpProxyPort(); | 114 | int rtpServerPort = mediaServerItem.getRtpProxyPort(); |
| 112 | if (mediaServerItem.isRtpEnable()) { | 115 | if (mediaServerItem.isRtpEnable()) { |
| 113 | rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId); | 116 | rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId); |
| @@ -131,7 +134,9 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -131,7 +134,9 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 131 | 134 | ||
| 132 | @Override | 135 | @Override |
| 133 | public void releaseSsrc(MediaServerItem mediaServerItem, String ssrc) { | 136 | public void releaseSsrc(MediaServerItem mediaServerItem, String ssrc) { |
| 134 | - if (mediaServerItem == null || ssrc == null) return; | 137 | + if (mediaServerItem == null || ssrc == null) { |
| 138 | + return; | ||
| 139 | + } | ||
| 135 | SsrcConfig ssrcConfig = mediaServerItem.getSsrcConfig(); | 140 | SsrcConfig ssrcConfig = mediaServerItem.getSsrcConfig(); |
| 136 | ssrcConfig.releaseSsrc(ssrc); | 141 | ssrcConfig.releaseSsrc(ssrc); |
| 137 | mediaServerItem.setSsrcConfig(ssrcConfig); | 142 | mediaServerItem.setSsrcConfig(ssrcConfig); |
| @@ -141,7 +146,6 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -141,7 +146,6 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 141 | 146 | ||
| 142 | /** | 147 | /** |
| 143 | * zlm 重启后重置他的推流信息, TODO 给正在使用的设备发送停止命令 | 148 | * zlm 重启后重置他的推流信息, TODO 给正在使用的设备发送停止命令 |
| 144 | - * @param mediaServerItem | ||
| 145 | */ | 149 | */ |
| 146 | @Override | 150 | @Override |
| 147 | public void clearRTPServer(MediaServerItem mediaServerItem) { | 151 | public void clearRTPServer(MediaServerItem mediaServerItem) { |
| @@ -174,9 +178,15 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -174,9 +178,15 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 174 | public List<MediaServerItem> getAll() { | 178 | public List<MediaServerItem> getAll() { |
| 175 | List<MediaServerItem> result = new ArrayList<>(); | 179 | List<MediaServerItem> result = new ArrayList<>(); |
| 176 | List<Object> mediaServerKeys = redisUtil.scan(String.format("%S*", VideoManagerConstants.MEDIA_SERVER_PREFIX)); | 180 | List<Object> mediaServerKeys = redisUtil.scan(String.format("%S*", VideoManagerConstants.MEDIA_SERVER_PREFIX)); |
| 177 | - for (int i = 0; i < mediaServerKeys.size(); i++) { | ||
| 178 | - String key = (String) mediaServerKeys.get(i); | ||
| 179 | - result.add((MediaServerItem)redisUtil.get(key)); | 181 | + String onlineKey = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX; |
| 182 | + for (Object mediaServerKey : mediaServerKeys) { | ||
| 183 | + String key = (String) mediaServerKey; | ||
| 184 | + MediaServerItem mediaServerItem = (MediaServerItem) redisUtil.get(key); | ||
| 185 | + // 检查状态 | ||
| 186 | + if (redisUtil.zScore(onlineKey, mediaServerItem.getId()) != null) { | ||
| 187 | + mediaServerItem.setStatus(true); | ||
| 188 | + } | ||
| 189 | + result.add(mediaServerItem); | ||
| 180 | } | 190 | } |
| 181 | return result; | 191 | return result; |
| 182 | } | 192 | } |
| @@ -208,7 +218,9 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -208,7 +218,9 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 208 | */ | 218 | */ |
| 209 | @Override | 219 | @Override |
| 210 | public MediaServerItem getOne(String mediaServerId) { | 220 | public MediaServerItem getOne(String mediaServerId) { |
| 211 | - if (mediaServerId == null) return null; | 221 | + if (mediaServerId == null) { |
| 222 | + return null; | ||
| 223 | + } | ||
| 212 | String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + mediaServerId; | 224 | String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + mediaServerId; |
| 213 | return (MediaServerItem)redisUtil.get(key); | 225 | return (MediaServerItem)redisUtil.get(key); |
| 214 | } | 226 | } |
| @@ -225,8 +237,34 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -225,8 +237,34 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 225 | } | 237 | } |
| 226 | 238 | ||
| 227 | @Override | 239 | @Override |
| 228 | - public void add(MediaServerItem mediaSerItem) { | ||
| 229 | - mediaServerMapper.add(mediaSerItem); | 240 | + public WVPResult<String> add(MediaServerItem mediaServerItem) { |
| 241 | + WVPResult<String> result = new WVPResult<>(); | ||
| 242 | + mediaServerItem.setCreateTime(this.format.format(System.currentTimeMillis())); | ||
| 243 | + mediaServerItem.setUpdateTime(this.format.format(System.currentTimeMillis())); | ||
| 244 | + JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); | ||
| 245 | + if (responseJSON != null) { | ||
| 246 | + JSONArray data = responseJSON.getJSONArray("data"); | ||
| 247 | + if (data != null && data.size() > 0) { | ||
| 248 | + ZLMServerConfig zlmServerConfig= JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class); | ||
| 249 | + if (mediaServerMapper.queryOne(zlmServerConfig.getGeneralMediaServerId()) != null) { | ||
| 250 | + result.setCode(-1); | ||
| 251 | + result.setMsg("保存失败,媒体服务ID [ " + zlmServerConfig.getGeneralMediaServerId() + " ] 已存在,请修改媒体服务器配置"); | ||
| 252 | + return result; | ||
| 253 | + } | ||
| 254 | + zlmServerConfig.setIp(mediaServerItem.getIp()); | ||
| 255 | + handLeZLMServerConfig(zlmServerConfig); | ||
| 256 | + result.setCode(0); | ||
| 257 | + result.setMsg("success"); | ||
| 258 | + }else { | ||
| 259 | + result.setCode(-1); | ||
| 260 | + result.setMsg("连接失败"); | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + }else { | ||
| 264 | + result.setCode(-1); | ||
| 265 | + result.setMsg("连接失败"); | ||
| 266 | + } | ||
| 267 | + return result; | ||
| 230 | } | 268 | } |
| 231 | 269 | ||
| 232 | /** | 270 | /** |
| @@ -249,13 +287,27 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -249,13 +287,27 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 249 | // docker部署不会使用zlm配置的端口号不是默认的则不做更新, 配置修改需要自行修改server配置; | 287 | // docker部署不会使用zlm配置的端口号不是默认的则不做更新, 配置修改需要自行修改server配置; |
| 250 | MediaServerItem serverItemFromConfig = mediaConfig.getMediaSerItem(); | 288 | MediaServerItem serverItemFromConfig = mediaConfig.getMediaSerItem(); |
| 251 | serverItemFromConfig.setId(zlmServerConfig.getGeneralMediaServerId()); | 289 | serverItemFromConfig.setId(zlmServerConfig.getGeneralMediaServerId()); |
| 252 | - if (mediaConfig.getHttpPort() == 0) serverItemFromConfig.setHttpPort(zlmServerConfig.getHttpPort()); | ||
| 253 | - if (mediaConfig.getHttpSSlPort() == 0) serverItemFromConfig.setHttpSSlPort(zlmServerConfig.getHttpSSLport()); | ||
| 254 | - if (mediaConfig.getRtmpPort() == 0) serverItemFromConfig.setRtmpPort(zlmServerConfig.getRtmpPort()); | ||
| 255 | - if (mediaConfig.getRtmpSSlPort() == 0) serverItemFromConfig.setRtmpSSlPort(zlmServerConfig.getRtmpSslPort()); | ||
| 256 | - if (mediaConfig.getRtspPort() == 0) serverItemFromConfig.setRtspPort(zlmServerConfig.getRtspPort()); | ||
| 257 | - if (mediaConfig.getRtspSSLPort() == 0) serverItemFromConfig.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); | ||
| 258 | - if (mediaConfig.getRtpProxyPort() == 0) serverItemFromConfig.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); | 290 | + if (mediaConfig.getHttpPort() == 0) { |
| 291 | + serverItemFromConfig.setHttpPort(zlmServerConfig.getHttpPort()); | ||
| 292 | + } | ||
| 293 | + if (mediaConfig.getHttpSSlPort() == 0) { | ||
| 294 | + serverItemFromConfig.setHttpSSlPort(zlmServerConfig.getHttpSSLport()); | ||
| 295 | + } | ||
| 296 | + if (mediaConfig.getRtmpPort() == 0) { | ||
| 297 | + serverItemFromConfig.setRtmpPort(zlmServerConfig.getRtmpPort()); | ||
| 298 | + } | ||
| 299 | + if (mediaConfig.getRtmpSSlPort() == 0) { | ||
| 300 | + serverItemFromConfig.setRtmpSSlPort(zlmServerConfig.getRtmpSslPort()); | ||
| 301 | + } | ||
| 302 | + if (mediaConfig.getRtspPort() == 0) { | ||
| 303 | + serverItemFromConfig.setRtspPort(zlmServerConfig.getRtspPort()); | ||
| 304 | + } | ||
| 305 | + if (mediaConfig.getRtspSSLPort() == 0) { | ||
| 306 | + serverItemFromConfig.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); | ||
| 307 | + } | ||
| 308 | + if (mediaConfig.getRtpProxyPort() == 0) { | ||
| 309 | + serverItemFromConfig.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); | ||
| 310 | + } | ||
| 259 | if (serverItem != null){ | 311 | if (serverItem != null){ |
| 260 | mediaServerMapper.delDefault(); | 312 | mediaServerMapper.delDefault(); |
| 261 | mediaServerMapper.add(serverItemFromConfig); | 313 | mediaServerMapper.add(serverItemFromConfig); |
| @@ -319,9 +371,10 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -319,9 +371,10 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 319 | 371 | ||
| 320 | @Override | 372 | @Override |
| 321 | public void addCount(String mediaServerId) { | 373 | public void addCount(String mediaServerId) { |
| 322 | - if (mediaServerId == null) return; | 374 | + if (mediaServerId == null) { |
| 375 | + return; | ||
| 376 | + } | ||
| 323 | String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX; | 377 | String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX; |
| 324 | - Double aDouble = redisUtil.zScore(key, mediaServerId); | ||
| 325 | redisUtil.zIncrScore(key, mediaServerId, 1); | 378 | redisUtil.zIncrScore(key, mediaServerId, 1); |
| 326 | 379 | ||
| 327 | } | 380 | } |
| @@ -399,4 +452,71 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | @@ -399,4 +452,71 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR | ||
| 399 | } | 452 | } |
| 400 | 453 | ||
| 401 | 454 | ||
| 455 | + @Override | ||
| 456 | + public WVPResult<MediaServerItem> checkMediaServer(String ip, int port, String secret) { | ||
| 457 | + WVPResult<MediaServerItem> result = new WVPResult<>(); | ||
| 458 | + if (mediaServerMapper.queryOneByHostAndPort(ip, port) != null) { | ||
| 459 | + result.setCode(-1); | ||
| 460 | + result.setMsg("此连接已存在"); | ||
| 461 | + return result; | ||
| 462 | + } | ||
| 463 | + MediaServerItem mediaServerItem = new MediaServerItem(); | ||
| 464 | + mediaServerItem.setIp(ip); | ||
| 465 | + mediaServerItem.setHttpPort(port); | ||
| 466 | + mediaServerItem.setSecret(secret); | ||
| 467 | + JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); | ||
| 468 | + if (responseJSON == null) { | ||
| 469 | + result.setCode(-1); | ||
| 470 | + result.setMsg("连接失败"); | ||
| 471 | + return result; | ||
| 472 | + } | ||
| 473 | + JSONArray data = responseJSON.getJSONArray("data"); | ||
| 474 | + ZLMServerConfig zlmServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class); | ||
| 475 | + if (zlmServerConfig == null) { | ||
| 476 | + result.setCode(-1); | ||
| 477 | + result.setMsg("读取配置失败"); | ||
| 478 | + return result; | ||
| 479 | + } | ||
| 480 | + if (mediaServerMapper.queryOne(zlmServerConfig.getGeneralMediaServerId()) != null) { | ||
| 481 | + result.setCode(-1); | ||
| 482 | + result.setMsg("媒体服务ID [" + zlmServerConfig.getGeneralMediaServerId() + " ] 已存在,请修改媒体服务器配置"); | ||
| 483 | + return result; | ||
| 484 | + } | ||
| 485 | + mediaServerItem.setHttpSSlPort(zlmServerConfig.getHttpPort()); | ||
| 486 | + mediaServerItem.setRtmpPort(zlmServerConfig.getRtmpPort()); | ||
| 487 | + mediaServerItem.setRtmpSSlPort(zlmServerConfig.getRtmpSslPort()); | ||
| 488 | + mediaServerItem.setRtspPort(zlmServerConfig.getRtspPort()); | ||
| 489 | + mediaServerItem.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); | ||
| 490 | + mediaServerItem.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); | ||
| 491 | + mediaServerItem.setStreamIp(ip); | ||
| 492 | + mediaServerItem.setHookIp(sipConfig.getIp()); | ||
| 493 | + mediaServerItem.setSdpIp(ip); | ||
| 494 | + mediaServerItem.setStreamNoneReaderDelayMS(zlmServerConfig.getGeneralStreamNoneReaderDelayMS()); | ||
| 495 | + result.setCode(0); | ||
| 496 | + result.setMsg("成功"); | ||
| 497 | + result.setData(mediaServerItem); | ||
| 498 | + return result; | ||
| 499 | + } | ||
| 500 | + | ||
| 501 | + @Override | ||
| 502 | + public boolean checkMediaRecordServer(String ip, int port) { | ||
| 503 | + boolean result = false; | ||
| 504 | + OkHttpClient client = new OkHttpClient(); | ||
| 505 | + String url = String.format("http://%s:%s/index/api/record", ip, port); | ||
| 506 | + | ||
| 507 | + FormBody.Builder builder = new FormBody.Builder(); | ||
| 508 | + | ||
| 509 | + Request request = new Request.Builder() | ||
| 510 | + .get() | ||
| 511 | + .url(url) | ||
| 512 | + .build(); | ||
| 513 | + try { | ||
| 514 | + Response response = client.newCall(request).execute(); | ||
| 515 | + if (response != null) { | ||
| 516 | + result = true; | ||
| 517 | + } | ||
| 518 | + } catch (Exception e) {} | ||
| 519 | + | ||
| 520 | + return result; | ||
| 521 | + } | ||
| 402 | } | 522 | } |
src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java
| @@ -32,6 +32,7 @@ public interface MediaServerMapper { | @@ -32,6 +32,7 @@ public interface MediaServerMapper { | ||
| 32 | "streamNoneReaderDelayMS, " + | 32 | "streamNoneReaderDelayMS, " + |
| 33 | "rtpEnable, " + | 33 | "rtpEnable, " + |
| 34 | "rtpPortRange, " + | 34 | "rtpPortRange, " + |
| 35 | + "sendRtpPortRange, " + | ||
| 35 | "recordAssistPort, " + | 36 | "recordAssistPort, " + |
| 36 | "defaultServer, " + | 37 | "defaultServer, " + |
| 37 | "createTime, " + | 38 | "createTime, " + |
| @@ -55,6 +56,7 @@ public interface MediaServerMapper { | @@ -55,6 +56,7 @@ public interface MediaServerMapper { | ||
| 55 | "${streamNoneReaderDelayMS}, " + | 56 | "${streamNoneReaderDelayMS}, " + |
| 56 | "${rtpEnable}, " + | 57 | "${rtpEnable}, " + |
| 57 | "'${rtpPortRange}', " + | 58 | "'${rtpPortRange}', " + |
| 59 | + "'${sendRtpPortRange}', " + | ||
| 58 | "${recordAssistPort}, " + | 60 | "${recordAssistPort}, " + |
| 59 | "${defaultServer}, " + | 61 | "${defaultServer}, " + |
| 60 | "'${createTime}', " + | 62 | "'${createTime}', " + |
| @@ -79,6 +81,7 @@ public interface MediaServerMapper { | @@ -79,6 +81,7 @@ public interface MediaServerMapper { | ||
| 79 | "<if test=\"streamNoneReaderDelayMS != null\">, streamNoneReaderDelayMS=${streamNoneReaderDelayMS}</if>" + | 81 | "<if test=\"streamNoneReaderDelayMS != null\">, streamNoneReaderDelayMS=${streamNoneReaderDelayMS}</if>" + |
| 80 | "<if test=\"rtpEnable != null\">, rtpEnable=${rtpEnable}</if>" + | 82 | "<if test=\"rtpEnable != null\">, rtpEnable=${rtpEnable}</if>" + |
| 81 | "<if test=\"rtpPortRange != null\">, rtpPortRange='${rtpPortRange}'</if>" + | 83 | "<if test=\"rtpPortRange != null\">, rtpPortRange='${rtpPortRange}'</if>" + |
| 84 | + "<if test=\"sendRtpPortRange != null\">, sendRtpPortRange='${sendRtpPortRange}'</if>" + | ||
| 82 | "<if test=\"secret != null\">, secret='${secret}'</if>" + | 85 | "<if test=\"secret != null\">, secret='${secret}'</if>" + |
| 83 | "<if test=\"recordAssistPort != null\">, recordAssistPort=${recordAssistPort}</if>" + | 86 | "<if test=\"recordAssistPort != null\">, recordAssistPort=${recordAssistPort}</if>" + |
| 84 | "WHERE id='${id}'"+ | 87 | "WHERE id='${id}'"+ |
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
| @@ -57,7 +57,9 @@ public class ServerController { | @@ -57,7 +57,9 @@ public class ServerController { | ||
| 57 | @ApiOperation("流媒体服务列表") | 57 | @ApiOperation("流媒体服务列表") |
| 58 | @GetMapping(value = "/media_server/list") | 58 | @GetMapping(value = "/media_server/list") |
| 59 | @ResponseBody | 59 | @ResponseBody |
| 60 | - public WVPResult<List<MediaServerItem>> getMediaServerList(){ | 60 | + public WVPResult<List<MediaServerItem>> getMediaServerList(boolean detail){ |
| 61 | + List<MediaServerItem> all = mediaServerService.getAll(); | ||
| 62 | + | ||
| 61 | WVPResult<List<MediaServerItem>> result = new WVPResult<>(); | 63 | WVPResult<List<MediaServerItem>> result = new WVPResult<>(); |
| 62 | result.setCode(0); | 64 | result.setCode(0); |
| 63 | result.setMsg("success"); | 65 | result.setMsg("success"); |
| @@ -87,6 +89,60 @@ public class ServerController { | @@ -87,6 +89,60 @@ public class ServerController { | ||
| 87 | return result; | 89 | return result; |
| 88 | } | 90 | } |
| 89 | 91 | ||
| 92 | + @ApiOperation("测试流媒体服务") | ||
| 93 | + @ApiImplicitParams({ | ||
| 94 | + @ApiImplicitParam(name="ip", value = "流媒体服务IP", dataTypeClass = String.class), | ||
| 95 | + @ApiImplicitParam(name="port", value = "流媒体服务HTT端口", dataTypeClass = Integer.class), | ||
| 96 | + @ApiImplicitParam(name="secret", value = "流媒体服务secret", dataTypeClass = String.class), | ||
| 97 | + }) | ||
| 98 | + @GetMapping(value = "/media_server/check") | ||
| 99 | + @ResponseBody | ||
| 100 | + public WVPResult<MediaServerItem> checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret){ | ||
| 101 | + return mediaServerService.checkMediaServer(ip, port, secret); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @ApiOperation("测试流媒体录像管理服务") | ||
| 105 | + @ApiImplicitParams({ | ||
| 106 | + @ApiImplicitParam(name="ip", value = "流媒体服务IP", dataTypeClass = String.class), | ||
| 107 | + @ApiImplicitParam(name="port", value = "流媒体服务HTT端口", dataTypeClass = Integer.class), | ||
| 108 | + @ApiImplicitParam(name="secret", value = "流媒体服务secret", dataTypeClass = String.class), | ||
| 109 | + }) | ||
| 110 | + @GetMapping(value = "/media_server/record/check") | ||
| 111 | + @ResponseBody | ||
| 112 | + public WVPResult<String> checkMediaRecordServer(@RequestParam String ip, @RequestParam int port){ | ||
| 113 | + boolean checkResult = mediaServerService.checkMediaRecordServer(ip, port); | ||
| 114 | + WVPResult<String> result = new WVPResult<>(); | ||
| 115 | + if (checkResult) { | ||
| 116 | + result.setCode(0); | ||
| 117 | + result.setMsg("success"); | ||
| 118 | + | ||
| 119 | + }else { | ||
| 120 | + result.setCode(-1); | ||
| 121 | + result.setMsg("连接失败"); | ||
| 122 | + } | ||
| 123 | + return result; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + @ApiOperation("保存流媒体服务") | ||
| 127 | + @ApiImplicitParams({ | ||
| 128 | + @ApiImplicitParam(name="mediaServerItem", value = "流媒体信息", dataTypeClass = MediaServerItem.class) | ||
| 129 | + }) | ||
| 130 | + @PostMapping(value = "/media_server/save") | ||
| 131 | + @ResponseBody | ||
| 132 | + public WVPResult<String> checkMediaServer(@RequestBody MediaServerItem mediaServerItem){ | ||
| 133 | + if (mediaServerService.getOne(mediaServerItem.getId()) != null) { | ||
| 134 | + mediaServerService.update(mediaServerItem); | ||
| 135 | + }else { | ||
| 136 | + return mediaServerService.add(mediaServerItem); | ||
| 137 | + } | ||
| 138 | + WVPResult<String> result = new WVPResult<>(); | ||
| 139 | + result.setCode(0); | ||
| 140 | + result.setMsg("success"); | ||
| 141 | + return result; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + | ||
| 145 | + | ||
| 90 | @ApiOperation("重启服务") | 146 | @ApiOperation("重启服务") |
| 91 | @GetMapping(value = "/restart") | 147 | @GetMapping(value = "/restart") |
| 92 | @ResponseBody | 148 | @ResponseBody |
| @@ -155,6 +211,8 @@ public class ServerController { | @@ -155,6 +211,8 @@ public class ServerController { | ||
| 155 | case "base": | 211 | case "base": |
| 156 | jsonObject.put("base", userSetup); | 212 | jsonObject.put("base", userSetup); |
| 157 | break; | 213 | break; |
| 214 | + default: | ||
| 215 | + break; | ||
| 158 | } | 216 | } |
| 159 | } | 217 | } |
| 160 | result.setData(jsonObject); | 218 | result.setData(jsonObject); |
src/main/resources/all-application.yml
| @@ -119,6 +119,8 @@ media: | @@ -119,6 +119,8 @@ media: | ||
| 119 | enable: true | 119 | enable: true |
| 120 | # [可选] 在此范围内选择端口用于媒体流传输, | 120 | # [可选] 在此范围内选择端口用于媒体流传输, |
| 121 | port-range: 30000,30500 # 端口范围 | 121 | port-range: 30000,30500 # 端口范围 |
| 122 | + # [可选] 国标级联在此范围内选择端口发送媒体流, | ||
| 123 | + send-port-range: 30000,30500 # 端口范围 | ||
| 122 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 | 124 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 |
| 123 | record-assist-port: 0 | 125 | record-assist-port: 0 |
| 124 | 126 |
src/main/resources/application-dev.yml
| @@ -63,6 +63,8 @@ media: | @@ -63,6 +63,8 @@ media: | ||
| 63 | enable: true | 63 | enable: true |
| 64 | # [可选] 在此范围内选择端口用于媒体流传输, | 64 | # [可选] 在此范围内选择端口用于媒体流传输, |
| 65 | port-range: 30000,30500 # 端口范围 | 65 | port-range: 30000,30500 # 端口范围 |
| 66 | + # [可选] 国标级联在此范围内选择端口发送媒体流, | ||
| 67 | + send-port-range: 30000,30500 # 端口范围 | ||
| 66 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 | 68 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 |
| 67 | record-assist-port: 0 | 69 | record-assist-port: 0 |
| 68 | 70 |
src/main/resources/wvp.sqlite
No preview for this file type
web_src/build/webpack.base.conf.js
web_src/src/assets/zlm-log.png
0 → 100644
47.9 KB
web_src/src/components/CloudRecord.vue
| @@ -111,7 +111,7 @@ | @@ -111,7 +111,7 @@ | ||
| 111 | }, | 111 | }, |
| 112 | getMediaServerList: function (){ | 112 | getMediaServerList: function (){ |
| 113 | let that = this; | 113 | let that = this; |
| 114 | - that.mediaServerObj.getMediaServerList((data)=>{ | 114 | + that.mediaServerObj.getOnlineMediaServerList((data)=>{ |
| 115 | that.mediaServerList = data.data; | 115 | that.mediaServerList = data.data; |
| 116 | if (that.mediaServerList.length > 0) { | 116 | if (that.mediaServerList.length > 0) { |
| 117 | that.mediaServerId = that.mediaServerList[0].id | 117 | that.mediaServerId = that.mediaServerList[0].id |
web_src/src/components/DeviceList.vue
| @@ -60,7 +60,7 @@ | @@ -60,7 +60,7 @@ | ||
| 60 | <el-button-group> | 60 | <el-button-group> |
| 61 | <el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0" type="primary" @click="showChannelList(scope.row)">通道</el-button> | 61 | <el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0" type="primary" @click="showChannelList(scope.row)">通道</el-button> |
| 62 | <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button> | 62 | <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button> |
| 63 | - <el-button size="mini" icon="el-icon-delete" type="primary" @click="edit(scope.row)">编辑</el-button> | 63 | + <el-button size="mini" icon="el-icon-edit" type="primary" @click="edit(scope.row)">编辑</el-button> |
| 64 | <el-button size="mini" icon="el-icon-delete" type="danger" v-if="scope.row.online==0" @click="deleteDevice(scope.row)">删除</el-button> | 64 | <el-button size="mini" icon="el-icon-delete" type="danger" v-if="scope.row.online==0" @click="deleteDevice(scope.row)">删除</el-button> |
| 65 | </el-button-group> | 65 | </el-button-group> |
| 66 | </template> | 66 | </template> |
web_src/src/components/MediaServerManger.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div id="mediaServerManger"> | ||
| 3 | + <el-container> | ||
| 4 | + <el-header> | ||
| 5 | + <uiHeader></uiHeader> | ||
| 6 | + </el-header> | ||
| 7 | + <el-main id="msMain"> | ||
| 8 | + <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;"> | ||
| 9 | + <span style="font-size: 1rem; font-weight: bold;">节点列表</span> | ||
| 10 | + </div> | ||
| 11 | + <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;"> | ||
| 12 | + <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="add">添加节点</el-button> | ||
| 13 | + </div> | ||
| 14 | + | ||
| 15 | + <el-row :gutter="12"> | ||
| 16 | + <el-col :span="num" v-for="item in mediaServerList" :key="item.id"> | ||
| 17 | + <el-card shadow="hover" :body-style="{ padding: '0px'}" class="server-card"> | ||
| 18 | + <div class="card-img-zlm"></div> | ||
| 19 | + <div style="padding: 14px;text-align: left"> | ||
| 20 | + <span style="font-size: 16px">{{item.id}}</span> | ||
| 21 | + <div style="margin-top: 13px; line-height: 12px; "> | ||
| 22 | + <span style="font-size: 14px; color: #999; margin-top: 5px">创建时间: {{item.createTime}}</span> | ||
| 23 | + <el-button icon="el-icon-edit" style="padding: 0;float: right;" type="text" @click="edit(item)">编辑</el-button> | ||
| 24 | + </div> | ||
| 25 | + </div> | ||
| 26 | + <i v-if="item.status" class="iconfont icon-online server-card-status-online" title="在线"></i> | ||
| 27 | + <i v-if="!item.status" class="iconfont icon-online server-card-status-offline" title="离线"></i> | ||
| 28 | + </el-card> | ||
| 29 | + </el-col> | ||
| 30 | + </el-row> | ||
| 31 | + <mediaServerEdit ref="mediaServerEdit" ></mediaServerEdit> | ||
| 32 | + </el-main> | ||
| 33 | + </el-container> | ||
| 34 | + </div> | ||
| 35 | +</template> | ||
| 36 | + | ||
| 37 | +<script> | ||
| 38 | + import uiHeader from './UiHeader.vue' | ||
| 39 | + import MediaServer from './service/MediaServer' | ||
| 40 | + import mediaServerEdit from './dialog/MediaServerEdit' | ||
| 41 | + export default { | ||
| 42 | + name: 'mediaServerManger', | ||
| 43 | + components: { | ||
| 44 | + uiHeader,mediaServerEdit | ||
| 45 | + }, | ||
| 46 | + data() { | ||
| 47 | + return { | ||
| 48 | + mediaServerObj : new MediaServer(), | ||
| 49 | + mediaServerList: [], //设备列表 | ||
| 50 | + winHeight: window.innerHeight - 200, | ||
| 51 | + updateLooper: false, | ||
| 52 | + currentPage:1, | ||
| 53 | + count:15, | ||
| 54 | + num: this.getNumberByWidth(), | ||
| 55 | + total:0, | ||
| 56 | + }; | ||
| 57 | + }, | ||
| 58 | + computed: { | ||
| 59 | + | ||
| 60 | + }, | ||
| 61 | + mounted() { | ||
| 62 | + this.initData(); | ||
| 63 | + this.updateLooper = setInterval(this.initData, 2000); | ||
| 64 | + }, | ||
| 65 | + destroyed() { | ||
| 66 | + clearTimeout(this.updateLooper); | ||
| 67 | + }, | ||
| 68 | + methods: { | ||
| 69 | + initData: function() { | ||
| 70 | + this.getServerList() | ||
| 71 | + }, | ||
| 72 | + currentChange: function(val){ | ||
| 73 | + this.currentPage = val; | ||
| 74 | + this.getServerList(); | ||
| 75 | + }, | ||
| 76 | + handleSizeChange: function(val){ | ||
| 77 | + this.count = val; | ||
| 78 | + this.getServerList(); | ||
| 79 | + }, | ||
| 80 | + getServerList: function(){ | ||
| 81 | + this.mediaServerObj.getMediaServerList((data)=>{ | ||
| 82 | + this.mediaServerList = data.data; | ||
| 83 | + }) | ||
| 84 | + }, | ||
| 85 | + add: function (){ | ||
| 86 | + this.$refs.mediaServerEdit.openDialog(null, this.initData) | ||
| 87 | + }, | ||
| 88 | + edit: function (row){ | ||
| 89 | + this.$refs.mediaServerEdit.openDialog(row, this.initData) | ||
| 90 | + }, | ||
| 91 | + getNumberByWidth(){ | ||
| 92 | + let candidateNums = [1, 2, 3, 4, 6, 8, 12, 24] | ||
| 93 | + let clientWidth = window.innerWidth - 30; | ||
| 94 | + let interval = 20; | ||
| 95 | + let itemWidth = 360; | ||
| 96 | + let num = (clientWidth + interval)/(itemWidth + interval) | ||
| 97 | + let result = Math.ceil(24/num); | ||
| 98 | + let resultVal = 24; | ||
| 99 | + for (let i = 0; i < candidateNums.length; i++) { | ||
| 100 | + let value = candidateNums[i] | ||
| 101 | + if (i + 1 >= candidateNums.length) { | ||
| 102 | + return 24; | ||
| 103 | + } | ||
| 104 | + if (value <= result && candidateNums[i + 1] > result ) { | ||
| 105 | + return value; | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + console.log("aadada: "+ resultVal) | ||
| 110 | + return resultVal; | ||
| 111 | + }, | ||
| 112 | + dateFormat: function(/** timestamp=0 **/) { | ||
| 113 | + var ts = arguments[0] || 0; | ||
| 114 | + var t,y,m,d,h,i,s; | ||
| 115 | + t = ts ? new Date(ts*1000) : new Date(); | ||
| 116 | + y = t.getFullYear(); | ||
| 117 | + m = t.getMonth()+1; | ||
| 118 | + d = t.getDate(); | ||
| 119 | + h = t.getHours(); | ||
| 120 | + i = t.getMinutes(); | ||
| 121 | + s = t.getSeconds(); | ||
| 122 | + // 可根据需要在这里定义时间格式 | ||
| 123 | + return y+'-'+(m<10?'0'+m:m)+'-'+(d<10?'0'+d:d)+' '+(h<10?'0'+h:h)+':'+(i<10?'0'+i:i)+':'+(s<10?'0'+s:s); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + } | ||
| 127 | + }; | ||
| 128 | +</script> | ||
| 129 | + | ||
| 130 | +<style> | ||
| 131 | + .server-card{ | ||
| 132 | + position: relative; | ||
| 133 | + margin-bottom: 20px; | ||
| 134 | + } | ||
| 135 | + .card-img-zlm{ | ||
| 136 | + width: 200px; height: 200px; | ||
| 137 | + background: url('~@static/images/zlm-logo.png') no-repeat center; | ||
| 138 | + background-position: center; | ||
| 139 | + background-size: contain; | ||
| 140 | + margin: 0 auto; | ||
| 141 | + } | ||
| 142 | + .server-card-status-online{ | ||
| 143 | + position: absolute; | ||
| 144 | + right: 20px; | ||
| 145 | + top: 20px; | ||
| 146 | + color: #3caf36; | ||
| 147 | + font-size: 18px; | ||
| 148 | + } | ||
| 149 | + .server-card-status-offline{ | ||
| 150 | + position: absolute; | ||
| 151 | + right: 20px; | ||
| 152 | + top: 20px; | ||
| 153 | + color: #808080; | ||
| 154 | + font-size: 18px; | ||
| 155 | + } | ||
| 156 | + .server-card:hover { | ||
| 157 | + border: 1px solid #adadad; | ||
| 158 | + } | ||
| 159 | +</style> |
web_src/src/components/UiHeader.vue
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | <el-menu-item index="/pushVideoList">推流列表</el-menu-item> | 6 | <el-menu-item index="/pushVideoList">推流列表</el-menu-item> |
| 7 | <el-menu-item index="/streamProxyList">拉流代理</el-menu-item> | 7 | <el-menu-item index="/streamProxyList">拉流代理</el-menu-item> |
| 8 | <el-menu-item index="/cloudRecord">云端录像</el-menu-item> | 8 | <el-menu-item index="/cloudRecord">云端录像</el-menu-item> |
| 9 | + <el-menu-item index="/mediaServerManger">节点管理</el-menu-item> | ||
| 9 | <el-menu-item index="/parentPlatformList/15/1">国标级联</el-menu-item> | 10 | <el-menu-item index="/parentPlatformList/15/1">国标级联</el-menu-item> |
| 10 | <el-menu-item @click="openDoc">在线文档</el-menu-item> | 11 | <el-menu-item @click="openDoc">在线文档</el-menu-item> |
| 11 | <!-- <el-submenu index="/setting">--> | 12 | <!-- <el-submenu index="/setting">--> |
web_src/src/components/control.vue
| @@ -139,7 +139,7 @@ export default { | @@ -139,7 +139,7 @@ export default { | ||
| 139 | this.initTable(); | 139 | this.initTable(); |
| 140 | this.updateData(); | 140 | this.updateData(); |
| 141 | this.chartInterval = setInterval(this.updateData, 3000); | 141 | this.chartInterval = setInterval(this.updateData, 3000); |
| 142 | - this.mediaServer.getMediaServerList((data)=>{ | 142 | + this.mediaServer.getOnlineMediaServerList((data)=>{ |
| 143 | this.mediaServerList = data.data; | 143 | this.mediaServerList = data.data; |
| 144 | if (this.mediaServerList && this.mediaServerList.length > 0) { | 144 | if (this.mediaServerList && this.mediaServerList.length > 0) { |
| 145 | this.mediaServerChoose = this.mediaServerList[0].id | 145 | this.mediaServerChoose = this.mediaServerList[0].id |
web_src/src/components/dialog/MediaServerEdit.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div id="mediaServerEdit" v-loading="isLoging"> | ||
| 3 | + <el-dialog | ||
| 4 | + title="媒体节点" | ||
| 5 | + :width="dialogWidth" | ||
| 6 | + top="2rem" | ||
| 7 | + :close-on-click-modal="false" | ||
| 8 | + :visible.sync="showDialog" | ||
| 9 | + :destroy-on-close="true" | ||
| 10 | + @close="close()" | ||
| 11 | + > | ||
| 12 | + <div id="formStep" style="margin-top: 1rem; margin-right: 20px;"> | ||
| 13 | + <el-form v-if="currentStep == 1" ref="mediaServerForm" :rules="rules" :model="mediaServerForm" label-width="140px" > | ||
| 14 | + <el-form-item label="IP" prop="ip"> | ||
| 15 | + <el-input v-model="mediaServerForm.ip" placeholder="媒体服务IP" clearable></el-input> | ||
| 16 | + </el-form-item> | ||
| 17 | + <el-form-item label="HTTP端口" prop="port"> | ||
| 18 | + <el-input v-model="mediaServerForm.httpPort" placeholder="媒体服务HTTP端口" clearable></el-input> | ||
| 19 | + </el-form-item> | ||
| 20 | + <el-form-item label="SECRET" prop="secret"> | ||
| 21 | + <el-input v-model="mediaServerForm.secret" placeholder="媒体服务SECRET" clearable></el-input> | ||
| 22 | + </el-form-item> | ||
| 23 | + <el-form-item> | ||
| 24 | + <div style="float: right;"> | ||
| 25 | + <el-button type="primary" v-if="currentStep === 1 && serverCheck === 1" @click="next" >下一步</el-button> | ||
| 26 | + <el-button @click="close">取消</el-button> | ||
| 27 | + <el-button type="primary" @click="checkServer" >测试</el-button> | ||
| 28 | + <i v-if="serverCheck === 1" class="el-icon-success" style="color: #3caf36"></i> | ||
| 29 | + <i v-if="serverCheck === -1" class="el-icon-error" style="color: #c80000"></i> | ||
| 30 | + </div> | ||
| 31 | + </el-form-item> | ||
| 32 | + </el-form> | ||
| 33 | + <el-row :gutter="24"> | ||
| 34 | + <el-col :span="12"> | ||
| 35 | + <el-form v-if="currentStep === 2 || currentStep === 3" ref="mediaServerForm1" :rules="rules" :model="mediaServerForm" label-width="140px" > | ||
| 36 | + <el-form-item label="IP" prop="ip"> | ||
| 37 | + <el-input v-if="currentStep === 2" v-model="mediaServerForm.ip" disabled></el-input> | ||
| 38 | + <el-input v-if="currentStep === 3" v-model="mediaServerForm.ip"></el-input> | ||
| 39 | + </el-form-item> | ||
| 40 | + <el-form-item label="HTTP端口" prop="port"> | ||
| 41 | + <el-input v-if="currentStep === 2" v-model="mediaServerForm.httpPort" disabled></el-input> | ||
| 42 | + <el-input v-if="currentStep === 3" v-model="mediaServerForm.httpPort"></el-input> | ||
| 43 | + </el-form-item> | ||
| 44 | + <el-form-item label="SECRET" prop="secret"> | ||
| 45 | + <el-input v-if="currentStep === 2" v-model="mediaServerForm.secret" disabled></el-input> | ||
| 46 | + <el-input v-if="currentStep === 3" v-model="mediaServerForm.secret"></el-input> | ||
| 47 | + </el-form-item> | ||
| 48 | + <el-form-item label="HOOK IP" prop="ip"> | ||
| 49 | + <el-input v-model="mediaServerForm.hookIp" placeholder="媒体服务HOOK_IP" clearable></el-input> | ||
| 50 | + </el-form-item> | ||
| 51 | + <el-form-item label="SDP IP" prop="ip"> | ||
| 52 | + <el-input v-model="mediaServerForm.sdpIp" placeholder="媒体服务SDP_IP" clearable></el-input> | ||
| 53 | + </el-form-item> | ||
| 54 | + <el-form-item label="流IP" prop="ip"> | ||
| 55 | + <el-input v-model="mediaServerForm.streamIp" placeholder="媒体服务流IP" clearable></el-input> | ||
| 56 | + </el-form-item> | ||
| 57 | + <el-form-item label="HTTPS PORT" prop="port"> | ||
| 58 | + <el-input v-model="mediaServerForm.httpSSlPort" placeholder="媒体服务HTTPS_PORT" clearable></el-input> | ||
| 59 | + </el-form-item> | ||
| 60 | + <el-form-item label="RTSP PORT" prop="port"> | ||
| 61 | + <el-input v-model="mediaServerForm.rtspPort" placeholder="媒体服务RTSP_PORT" clearable></el-input> | ||
| 62 | + </el-form-item> | ||
| 63 | + <el-form-item label="RTSPS PORT" prop="port"> | ||
| 64 | + <el-input v-model="mediaServerForm.rtspSSLPort" placeholder="媒体服务RTSPS_PORT" clearable></el-input> | ||
| 65 | + </el-form-item> | ||
| 66 | + | ||
| 67 | + </el-form> | ||
| 68 | + </el-col> | ||
| 69 | + <el-col :span="12"> | ||
| 70 | + <el-form v-if="currentStep === 2 || currentStep === 3" ref="mediaServerForm2" :rules="rules" :model="mediaServerForm" label-width="180px" > | ||
| 71 | + <el-form-item label="RTMP PORT" prop="port"> | ||
| 72 | + <el-input v-model="mediaServerForm.rtmpPort" placeholder="媒体服务RTMP_PORT" clearable></el-input> | ||
| 73 | + </el-form-item> | ||
| 74 | + <el-form-item label="RTMPS PORT" prop="port"> | ||
| 75 | + <el-input v-model="mediaServerForm.rtmpSSlPort" placeholder="媒体服务RTMPS_PORT" clearable></el-input> | ||
| 76 | + </el-form-item> | ||
| 77 | + <el-form-item label="自动配置媒体服务" > | ||
| 78 | + <el-switch v-model="mediaServerForm.autoConfig"></el-switch> | ||
| 79 | + </el-form-item> | ||
| 80 | + <el-form-item label="收流端口模式" > | ||
| 81 | + <el-switch active-text="多端口" inactive-text="单端口" v-model="mediaServerForm.rtpEnable"></el-switch> | ||
| 82 | + </el-form-item> | ||
| 83 | + | ||
| 84 | + <el-form-item v-if="!mediaServerForm.rtpEnable" label="收流端口" prop="port"> | ||
| 85 | + <el-input v-model.number="mediaServerForm.rtpProxyPort" clearable></el-input> | ||
| 86 | + </el-form-item> | ||
| 87 | + <el-form-item v-if="mediaServerForm.rtpEnable" label="收流端口" prop="port"> | ||
| 88 | + <el-input v-model="mediaServerForm.rtpPortRange1" placeholder="起始" clearable style="width: 100px" prop="port"></el-input> | ||
| 89 | + - | ||
| 90 | + <el-input v-model="mediaServerForm.rtpPortRange2" placeholder="终止" clearable style="width: 100px" prop="port"></el-input> | ||
| 91 | + </el-form-item> | ||
| 92 | + <el-form-item label="推流端口" prop="port"> | ||
| 93 | + <el-input v-model="mediaServerForm.sendRtpPortRange1" placeholder="起始" clearable style="width: 100px" prop="port"></el-input> | ||
| 94 | + - | ||
| 95 | + <el-input v-model="mediaServerForm.sendRtpPortRange2" placeholder="终止" clearable style="width: 100px" prop="port"></el-input> | ||
| 96 | + </el-form-item> | ||
| 97 | + <el-form-item label="无人观看多久后停止拉流" > | ||
| 98 | + <el-input v-model.number="mediaServerForm.streamNoneReaderDelayMS" clearable></el-input> | ||
| 99 | + </el-form-item> | ||
| 100 | + <el-form-item label="录像管理服务端口" prop="port"> | ||
| 101 | + <el-input v-model.number="mediaServerForm.recordAssistPort"> | ||
| 102 | +<!-- <el-button v-if="mediaServerForm.recordAssistPort > 0" slot="append" type="primary" @click="checkRecordServer">测试</el-button>--> | ||
| 103 | + <el-button v-if="mediaServerForm.recordAssistPort > 0" class="el-icon-check" slot="append" type="primary" @click="checkRecordServer"></el-button> | ||
| 104 | + </el-input> | ||
| 105 | + <i v-if="recordServerCheck == 1" class="el-icon-success" style="color: #3caf36; position: absolute;top: 14px;"></i> | ||
| 106 | + <i v-if="recordServerCheck == 2" class="el-icon-loading" style="color: #3caf36; position: absolute;top: 14px;"></i> | ||
| 107 | + <i v-if="recordServerCheck === -1" class="el-icon-error" style="color: #c80000; position: absolute;top: 14px;"></i> | ||
| 108 | + </el-form-item> | ||
| 109 | + <el-form-item> | ||
| 110 | + <div style="float: right;"> | ||
| 111 | + <el-button type="primary" @click="onSubmit" >提交</el-button> | ||
| 112 | + <el-button @click="close">取消</el-button> | ||
| 113 | + </div> | ||
| 114 | + </el-form-item> | ||
| 115 | + </el-form> | ||
| 116 | + </el-col> | ||
| 117 | + </el-row> | ||
| 118 | + | ||
| 119 | + </div> | ||
| 120 | + </el-dialog> | ||
| 121 | + </div> | ||
| 122 | +</template> | ||
| 123 | + | ||
| 124 | +<script> | ||
| 125 | +import MediaServer from './../service/MediaServer' | ||
| 126 | + | ||
| 127 | +export default { | ||
| 128 | + name: "streamProxyEdit", | ||
| 129 | + props: {}, | ||
| 130 | + computed: {}, | ||
| 131 | + created() { | ||
| 132 | + this.setDialogWidth() | ||
| 133 | + }, | ||
| 134 | + data() { | ||
| 135 | + const isValidIp = (rule, value, callback) => { // 校验IP是否符合规则 | ||
| 136 | + var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/ | ||
| 137 | + console.log(this.mediaServerForm.ip) | ||
| 138 | + if (!reg.test(this.mediaServerForm.ip)) { | ||
| 139 | + return callback(new Error('请输入有效的IP地址')) | ||
| 140 | + } else { | ||
| 141 | + callback() | ||
| 142 | + } | ||
| 143 | + return true | ||
| 144 | + } | ||
| 145 | + const isValidPort = (rule, value, callback) => { // 校验IP是否符合规则 | ||
| 146 | + var reg = /^(([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5]))$/ | ||
| 147 | + if (!reg.test(this.mediaServerForm.httpPort)) { | ||
| 148 | + return callback(new Error('请输入有效的端口号')) | ||
| 149 | + } else { | ||
| 150 | + callback() | ||
| 151 | + } | ||
| 152 | + return true | ||
| 153 | + } | ||
| 154 | + return { | ||
| 155 | + dialogWidth: 0, | ||
| 156 | + defaultWidth: 1000, | ||
| 157 | + listChangeCallback: null, | ||
| 158 | + showDialog: false, | ||
| 159 | + isLoging: false, | ||
| 160 | + dialogLoading: false, | ||
| 161 | + | ||
| 162 | + currentStep: 1, | ||
| 163 | + platformList: [], | ||
| 164 | + mediaServer: new MediaServer(), | ||
| 165 | + serverCheck: 0, | ||
| 166 | + recordServerCheck: 0, | ||
| 167 | + mediaServerForm: { | ||
| 168 | + id: "", | ||
| 169 | + ip: "", | ||
| 170 | + autoConfig: true, | ||
| 171 | + hookIp: "", | ||
| 172 | + sdpIp: "", | ||
| 173 | + streamIp: "", | ||
| 174 | + streamNoneReaderDelayMS: "", | ||
| 175 | + secret: "035c73f7-bb6b-4889-a715-d9eb2d1925cc", | ||
| 176 | + httpPort: "", | ||
| 177 | + httpSSlPort: "", | ||
| 178 | + recordAssistPort: "", | ||
| 179 | + rtmpPort: "", | ||
| 180 | + rtmpSSlPort: "", | ||
| 181 | + rtpEnable: false, | ||
| 182 | + rtpPortRange: "", | ||
| 183 | + sendRtpPortRange: "", | ||
| 184 | + rtpPortRange1: "", | ||
| 185 | + rtpPortRange2: "", | ||
| 186 | + sendRtpPortRange1: "", | ||
| 187 | + sendRtpPortRange2: "", | ||
| 188 | + rtpProxyPort: "", | ||
| 189 | + rtspPort: "", | ||
| 190 | + rtspSSLPort: "", | ||
| 191 | + }, | ||
| 192 | + | ||
| 193 | + rules: { | ||
| 194 | + ip: [{ required: true, validator: isValidIp, message: '请输入有效的IP地址', trigger: 'blur' }], | ||
| 195 | + port: [{ required: true, validator: isValidPort, message: '请输入有效的端口号', trigger: 'blur' }], | ||
| 196 | + secret: [{ required: true, message: "请输入secret", trigger: "blur" }], | ||
| 197 | + timeout_ms: [{ required: true, message: "请输入FFmpeg推流成功超时时间", trigger: "blur" }], | ||
| 198 | + ffmpeg_cmd_key: [{ required: false, message: "请输入FFmpeg命令参数模板(可选)", trigger: "blur" }], | ||
| 199 | + }, | ||
| 200 | + }; | ||
| 201 | + }, | ||
| 202 | + methods: { | ||
| 203 | + setDialogWidth() { | ||
| 204 | + let val = document.body.clientWidth | ||
| 205 | + if (val < this.defaultWidth) { | ||
| 206 | + this.dialogWidth = '100%' | ||
| 207 | + } else { | ||
| 208 | + this.dialogWidth = this.defaultWidth + 'px' | ||
| 209 | + } | ||
| 210 | + }, | ||
| 211 | + openDialog: function (param, callback) { | ||
| 212 | + this.showDialog = true; | ||
| 213 | + this.listChangeCallback = callback; | ||
| 214 | + if (param != null) { | ||
| 215 | + this.mediaServerForm = param; | ||
| 216 | + this.currentStep = 3; | ||
| 217 | + if (param.rtpPortRange) { | ||
| 218 | + let rtpPortRange = this.mediaServerForm.rtpPortRange.split(","); | ||
| 219 | + if (rtpPortRange.length > 0) { | ||
| 220 | + this.mediaServerForm["rtpPortRange1"] = rtpPortRange[0] | ||
| 221 | + this.mediaServerForm["rtpPortRange2"] = rtpPortRange[1] | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + let sendRtpPortRange = this.mediaServerForm.sendRtpPortRange.split(","); | ||
| 225 | + this.mediaServerForm["sendRtpPortRange1"] = sendRtpPortRange[0] | ||
| 226 | + this.mediaServerForm["sendRtpPortRange2"] = sendRtpPortRange[1] | ||
| 227 | + } | ||
| 228 | + }, | ||
| 229 | + checkServer: function() { | ||
| 230 | + let that = this; | ||
| 231 | + that.serverCheck = 0; | ||
| 232 | + that.mediaServer.checkServer(that.mediaServerForm, data =>{ | ||
| 233 | + if (data.code === 0) { | ||
| 234 | + if (parseInt(that.mediaServerForm.httpPort) !== parseInt(data.data.httpPort)) { | ||
| 235 | + that.$message({ | ||
| 236 | + showClose: true, | ||
| 237 | + message: '如果你正在使用docker部署你的媒体服务,请注意的端口映射。', | ||
| 238 | + type: 'warning', | ||
| 239 | + duration: 0 | ||
| 240 | + }); | ||
| 241 | + } | ||
| 242 | + let httpPort = that.mediaServerForm.httpPort; | ||
| 243 | + that.mediaServerForm = data.data; | ||
| 244 | + that.mediaServerForm.httpPort = httpPort; | ||
| 245 | + that.mediaServerForm.autoConfig = true; | ||
| 246 | + that.mediaServerForm.sendRtpPortRange1 = 30000 | ||
| 247 | + that.mediaServerForm.sendRtpPortRange2 = 30500 | ||
| 248 | + that.mediaServerForm.rtpPortRange1 = 30000 | ||
| 249 | + that.mediaServerForm.rtpPortRange2 = 30500 | ||
| 250 | + that.serverCheck = 1; | ||
| 251 | + }else { | ||
| 252 | + that.serverCheck = -1; | ||
| 253 | + that.$message({ | ||
| 254 | + showClose: true, | ||
| 255 | + message: data.msg, | ||
| 256 | + type: "error", | ||
| 257 | + }); | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + }) | ||
| 261 | + }, | ||
| 262 | + next: function (){ | ||
| 263 | + this.currentStep = 2; | ||
| 264 | + this.defaultWidth = 900; | ||
| 265 | + this.setDialogWidth(); | ||
| 266 | + }, | ||
| 267 | + checkRecordServer: function (){ | ||
| 268 | + let that = this; | ||
| 269 | + that.recordServerCheck = 2; | ||
| 270 | + if (that.mediaServerForm.recordAssistPort <= 0 || that.mediaServerForm.recordAssistPort > 65535 ) { | ||
| 271 | + that.recordServerCheck = -1; | ||
| 272 | + that.$message({ | ||
| 273 | + showClose: true, | ||
| 274 | + message: "端口号应该在-65535之间", | ||
| 275 | + type: "error", | ||
| 276 | + }); | ||
| 277 | + return; | ||
| 278 | + } | ||
| 279 | + that.mediaServer.checkRecordServer(that.mediaServerForm, data =>{ | ||
| 280 | + if (data.code === 0) { | ||
| 281 | + that.recordServerCheck = 1; | ||
| 282 | + }else { | ||
| 283 | + that.recordServerCheck = -1; | ||
| 284 | + that.$message({ | ||
| 285 | + showClose: true, | ||
| 286 | + message: data.msg, | ||
| 287 | + type: "error", | ||
| 288 | + }); | ||
| 289 | + } | ||
| 290 | + }) | ||
| 291 | + }, | ||
| 292 | + onSubmit: function () { | ||
| 293 | + this.dialogLoading = true; | ||
| 294 | + let that = this; | ||
| 295 | + if (this.mediaServerForm.rtpEnable) { | ||
| 296 | + this.mediaServerForm.rtpPortRange = this.mediaServerForm.rtpPortRange1 + "," + this.mediaServerForm.rtpPortRange2; | ||
| 297 | + } | ||
| 298 | + this.mediaServerForm.sendRtpPortRange = this.mediaServerForm.sendRtpPortRange1 + "," + this.mediaServerForm.sendRtpPortRange2; | ||
| 299 | + that.mediaServer.addServer(this.mediaServerForm, data => { | ||
| 300 | + if (data.code === 0) { | ||
| 301 | + that.$message({ | ||
| 302 | + showClose: true, | ||
| 303 | + message: "保存成功", | ||
| 304 | + type: "success", | ||
| 305 | + }); | ||
| 306 | + if (this.listChangeCallback) this.listChangeCallback(); | ||
| 307 | + that.close() | ||
| 308 | + }else { | ||
| 309 | + that.$message({ | ||
| 310 | + showClose: true, | ||
| 311 | + message: data.msg, | ||
| 312 | + type: "error", | ||
| 313 | + }); | ||
| 314 | + } | ||
| 315 | + }) | ||
| 316 | + }, | ||
| 317 | + close: function () { | ||
| 318 | + this.showDialog = false; | ||
| 319 | + this.dialogLoading = false; | ||
| 320 | + this.mediaServerForm = { | ||
| 321 | + id: "", | ||
| 322 | + ip: "", | ||
| 323 | + autoConfig: true, | ||
| 324 | + hookIp: "", | ||
| 325 | + sdpIp: "", | ||
| 326 | + streamIp: "", | ||
| 327 | + streamNoneReaderDelayMS: "", | ||
| 328 | + secret: "035c73f7-bb6b-4889-a715-d9eb2d1925cc", | ||
| 329 | + httpPort: "", | ||
| 330 | + httpSSlPort: "", | ||
| 331 | + recordAssistPort: "", | ||
| 332 | + rtmpPort: "", | ||
| 333 | + rtmpSSlPort: "", | ||
| 334 | + rtpEnable: false, | ||
| 335 | + rtpPortRange: "", | ||
| 336 | + sendRtpPortRange: "", | ||
| 337 | + rtpPortRange1: "", | ||
| 338 | + rtpPortRange2: "", | ||
| 339 | + sendRtpPortRange1: "", | ||
| 340 | + sendRtpPortRange2: "", | ||
| 341 | + rtpProxyPort: "", | ||
| 342 | + rtspPort: "", | ||
| 343 | + rtspSSLPort: "", | ||
| 344 | + }; | ||
| 345 | + this.listChangeCallback = null | ||
| 346 | + this.currentStep = 1; | ||
| 347 | + }, | ||
| 348 | + deviceGBIdExit: async function (deviceGbId) { | ||
| 349 | + var result = false; | ||
| 350 | + var that = this; | ||
| 351 | + await that.$axios({ | ||
| 352 | + method: 'post', | ||
| 353 | + url:`/api/platform/exit/${deviceGbId}` | ||
| 354 | + }).then(function (res) { | ||
| 355 | + result = res.data; | ||
| 356 | + }).catch(function (error) { | ||
| 357 | + console.log(error); | ||
| 358 | + }); | ||
| 359 | + return result; | ||
| 360 | + }, | ||
| 361 | + checkExpires: function() { | ||
| 362 | + if (this.platform.enable && this.platform.expires == "0") { | ||
| 363 | + this.platform.expires = "300"; | ||
| 364 | + } | ||
| 365 | + } | ||
| 366 | + }, | ||
| 367 | +}; | ||
| 368 | +</script> |
web_src/src/components/dialog/StreamProxyEdit.vue
| @@ -203,7 +203,7 @@ export default { | @@ -203,7 +203,7 @@ export default { | ||
| 203 | }).catch(function (error) { | 203 | }).catch(function (error) { |
| 204 | console.log(error); | 204 | console.log(error); |
| 205 | }); | 205 | }); |
| 206 | - this.mediaServer.getMediaServerList((data)=>{ | 206 | + this.mediaServer.getOnlineMediaServerList((data)=>{ |
| 207 | this.mediaServerList = data; | 207 | this.mediaServerList = data; |
| 208 | }) | 208 | }) |
| 209 | }, | 209 | }, |
web_src/src/components/dialog/changePassword.vue
| @@ -89,7 +89,7 @@ export default { | @@ -89,7 +89,7 @@ export default { | ||
| 89 | method: 'post', | 89 | method: 'post', |
| 90 | url:"/api/user/changePassword", | 90 | url:"/api/user/changePassword", |
| 91 | params: { | 91 | params: { |
| 92 | - oldpassword: crypto.createHash('md5').update(this.oldPassword, "utf8").digest('hex'), | 92 | + oldPassword: crypto.createHash('md5').update(this.oldPassword, "utf8").digest('hex'), |
| 93 | password: this.newPassword | 93 | password: this.newPassword |
| 94 | } | 94 | } |
| 95 | }).then((res)=> { | 95 | }).then((res)=> { |
web_src/src/components/dialog/deviceEdit.vue
| @@ -82,7 +82,7 @@ export default { | @@ -82,7 +82,7 @@ export default { | ||
| 82 | }, | 82 | }, |
| 83 | getMediaServerList: function (){ | 83 | getMediaServerList: function (){ |
| 84 | let that = this; | 84 | let that = this; |
| 85 | - that.mediaServerObj.getMediaServerList((data)=>{ | 85 | + that.mediaServerObj.getOnlineMediaServerList((data)=>{ |
| 86 | that.mediaServerList = data.data; | 86 | that.mediaServerList = data.data; |
| 87 | }) | 87 | }) |
| 88 | }, | 88 | }, |
web_src/src/components/service/MediaServer.js
| @@ -6,7 +6,7 @@ class MediaServer{ | @@ -6,7 +6,7 @@ class MediaServer{ | ||
| 6 | this.$axios = axios; | 6 | this.$axios = axios; |
| 7 | } | 7 | } |
| 8 | 8 | ||
| 9 | - getMediaServerList(callback){ | 9 | + getOnlineMediaServerList(callback){ |
| 10 | this.$axios({ | 10 | this.$axios({ |
| 11 | method: 'get', | 11 | method: 'get', |
| 12 | url:`/api/server/media_server/online/list`, | 12 | url:`/api/server/media_server/online/list`, |
| @@ -16,6 +16,16 @@ class MediaServer{ | @@ -16,6 +16,16 @@ class MediaServer{ | ||
| 16 | console.log(error); | 16 | console.log(error); |
| 17 | }); | 17 | }); |
| 18 | } | 18 | } |
| 19 | + getMediaServerList(callback){ | ||
| 20 | + this.$axios({ | ||
| 21 | + method: 'get', | ||
| 22 | + url:`/api/server/media_server/list`, | ||
| 23 | + }).then(function (res) { | ||
| 24 | + if (typeof (callback) == "function") callback(res.data) | ||
| 25 | + }).catch(function (error) { | ||
| 26 | + console.log(error); | ||
| 27 | + }); | ||
| 28 | + } | ||
| 19 | 29 | ||
| 20 | getMediaServer(id, callback){ | 30 | getMediaServer(id, callback){ |
| 21 | this.$axios({ | 31 | this.$axios({ |
| @@ -27,6 +37,49 @@ class MediaServer{ | @@ -27,6 +37,49 @@ class MediaServer{ | ||
| 27 | console.log(error); | 37 | console.log(error); |
| 28 | }); | 38 | }); |
| 29 | } | 39 | } |
| 40 | + | ||
| 41 | + checkServer(param, callback){ | ||
| 42 | + this.$axios({ | ||
| 43 | + method: 'get', | ||
| 44 | + url:`/api/server/media_server/check`, | ||
| 45 | + params: { | ||
| 46 | + ip: param.ip, | ||
| 47 | + port: param.httpPort, | ||
| 48 | + secret: param.secret | ||
| 49 | + } | ||
| 50 | + }).then(function (res) { | ||
| 51 | + if (typeof (callback) == "function") callback(res.data) | ||
| 52 | + }).catch(function (error) { | ||
| 53 | + console.log(error); | ||
| 54 | + }); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + checkRecordServer(param, callback){ | ||
| 58 | + this.$axios({ | ||
| 59 | + method: 'get', | ||
| 60 | + url:`/api/server/media_server/record/check`, | ||
| 61 | + params: { | ||
| 62 | + ip: param.ip, | ||
| 63 | + port: param.recordAssistPort | ||
| 64 | + } | ||
| 65 | + }).then(function (res) { | ||
| 66 | + if (typeof (callback) == "function") callback(res.data) | ||
| 67 | + }).catch(function (error) { | ||
| 68 | + console.log(error); | ||
| 69 | + }); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + addServer(param, callback){ | ||
| 73 | + this.$axios({ | ||
| 74 | + method: 'post', | ||
| 75 | + url:`/api/server/media_server/save`, | ||
| 76 | + data: param | ||
| 77 | + }).then(function (res) { | ||
| 78 | + if (typeof (callback) == "function") callback(res.data) | ||
| 79 | + }).catch(function (error) { | ||
| 80 | + console.log(error); | ||
| 81 | + }); | ||
| 82 | + } | ||
| 30 | } | 83 | } |
| 31 | 84 | ||
| 32 | export default MediaServer; | 85 | export default MediaServer; |
web_src/src/router/index.js
| @@ -10,6 +10,7 @@ import devicePosition from '../components/devicePosition.vue' | @@ -10,6 +10,7 @@ import devicePosition from '../components/devicePosition.vue' | ||
| 10 | import login from '../components/Login.vue' | 10 | import login from '../components/Login.vue' |
| 11 | import parentPlatformList from '../components/ParentPlatformList.vue' | 11 | import parentPlatformList from '../components/ParentPlatformList.vue' |
| 12 | import cloudRecord from '../components/CloudRecord.vue' | 12 | import cloudRecord from '../components/CloudRecord.vue' |
| 13 | +import mediaServerManger from '../components/MediaServerManger.vue' | ||
| 13 | import test from '../components/test.vue' | 14 | import test from '../components/test.vue' |
| 14 | import web from '../components/setting/Web.vue' | 15 | import web from '../components/setting/Web.vue' |
| 15 | import sip from '../components/setting/Sip.vue' | 16 | import sip from '../components/setting/Sip.vue' |
| @@ -71,6 +72,11 @@ export default new VueRouter({ | @@ -71,6 +72,11 @@ export default new VueRouter({ | ||
| 71 | component: cloudRecord, | 72 | component: cloudRecord, |
| 72 | }, | 73 | }, |
| 73 | { | 74 | { |
| 75 | + path: '/mediaServerManger', | ||
| 76 | + name: 'mediaServerManger', | ||
| 77 | + component: mediaServerManger, | ||
| 78 | + }, | ||
| 79 | + { | ||
| 74 | path: '/setting/web', | 80 | path: '/setting/web', |
| 75 | name: 'web', | 81 | name: 'web', |
| 76 | component: web, | 82 | component: web, |
web_src/static/css/iconfont.css
| 1 | @font-face { | 1 | @font-face { |
| 2 | font-family: "iconfont"; /* Project id 1291092 */ | 2 | font-family: "iconfont"; /* Project id 1291092 */ |
| 3 | - src: url('iconfont.woff2?t=1626163621710') format('woff2'), | ||
| 4 | - url('iconfont.woff?t=1626163621710') format('woff'), | ||
| 5 | - url('iconfont.ttf?t=1626163621710') format('truetype'); | 3 | + src: url('iconfont.woff2?t=1631767887536') format('woff2'), |
| 4 | + url('iconfont.woff?t=1631767887536') format('woff'), | ||
| 5 | + url('iconfont.ttf?t=1631767887536') format('truetype'); | ||
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | .iconfont { | 8 | .iconfont { |
| @@ -13,6 +13,10 @@ | @@ -13,6 +13,10 @@ | ||
| 13 | -moz-osx-font-smoothing: grayscale; | 13 | -moz-osx-font-smoothing: grayscale; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | +.icon-online:before { | ||
| 17 | + content: "\e600"; | ||
| 18 | +} | ||
| 19 | + | ||
| 16 | .icon-xiangqing2:before { | 20 | .icon-xiangqing2:before { |
| 17 | content: "\e798"; | 21 | content: "\e798"; |
| 18 | } | 22 | } |
web_src/static/css/iconfont.woff2
No preview for this file type
web_src/static/images/zlm-logo.png
0 → 100644
47.9 KB