Commit da14c7f24c61cf9027a02d8e566ab89116136f19

Authored by 648540858
1 parent 956fd47e

拆分redis中device与channel的存储方式

支持分页
接口直接返回播放地址
... ... @@ -143,6 +143,17 @@
143 143 <artifactId>jedis</artifactId>
144 144 <version>2.9.0</version>
145 145 </dependency>
  146 +
  147 + <dependency>
  148 + <groupId>org.mitre.dsmiley.httpproxy</groupId>
  149 + <artifactId>smiley-http-proxy-servlet</artifactId>
  150 + <version>1.7</version>
  151 + </dependency>
  152 + <dependency>
  153 + <groupId>com.google.guava</groupId>
  154 + <artifactId>guava</artifactId>
  155 + <version>18.0</version>
  156 + </dependency>
146 157  
147 158 </dependencies>
148 159  
... ...
src/main/java/com/genersoft/iot/vmp/common/PageResult.java 0 → 100644
  1 +package com.genersoft.iot.vmp.common;
  2 +
  3 +import java.util.List;
  4 +
  5 +public class PageResult<T> {
  6 +
  7 + private int page;
  8 + private int count;
  9 + private int total;
  10 +
  11 + private List<T> data;
  12 +
  13 + public List<T> getData() {
  14 + return data;
  15 + }
  16 +
  17 + public void setData(List<T> data) {
  18 + this.data = data;
  19 + }
  20 +
  21 + public int getPage() {
  22 + return page;
  23 + }
  24 +
  25 + public void setPage(int page) {
  26 + this.page = page;
  27 + }
  28 +
  29 + public int getCount() {
  30 + return count;
  31 + }
  32 +
  33 + public void setCount(int count) {
  34 + this.count = count;
  35 + }
  36 +
  37 + public int getTotal() {
  38 + return total;
  39 + }
  40 +
  41 + public void setTotal(int total) {
  42 + this.total = total;
  43 + }
  44 +}
... ...
src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java 0 → 100644
  1 +package com.genersoft.iot.vmp.common;
  2 +
  3 +public class StreamInfo {
  4 +
  5 + private String ssrc;
  6 + private String flv;
  7 + private String WS_FLV;
  8 + private String RTMP;
  9 + private String HLS;
  10 + private String RTSP;
  11 +
  12 + public String getSsrc() {
  13 + return ssrc;
  14 + }
  15 +
  16 + public void setSsrc(String ssrc) {
  17 + this.ssrc = ssrc;
  18 + }
  19 +
  20 + public String getFlv() {
  21 + return flv;
  22 + }
  23 +
  24 + public void setFlv(String flv) {
  25 + this.flv = flv;
  26 + }
  27 +
  28 + public String getWS_FLV() {
  29 + return WS_FLV;
  30 + }
  31 +
  32 + public void setWS_FLV(String WS_FLV) {
  33 + this.WS_FLV = WS_FLV;
  34 + }
  35 +
  36 + public String getRTMP() {
  37 + return RTMP;
  38 + }
  39 +
  40 + public void setRTMP(String RTMP) {
  41 + this.RTMP = RTMP;
  42 + }
  43 +
  44 + public String getHLS() {
  45 + return HLS;
  46 + }
  47 +
  48 + public void setHLS(String HLS) {
  49 + this.HLS = HLS;
  50 + }
  51 +
  52 + public String getRTSP() {
  53 + return RTSP;
  54 + }
  55 +
  56 + public void setRTSP(String RTSP) {
  57 + this.RTSP = RTSP;
  58 + }
  59 +}
... ...
src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
... ... @@ -8,10 +8,16 @@ package com.genersoft.iot.vmp.common;
8 8 */
9 9 public class VideoManagerConstants {
10 10  
11   - public static final String CACHEKEY_PREFIX = "VMP_deviceId_";
  11 + public static final String MEDIA_SERVER_PREFIX = "VMP_media_server";
  12 +
  13 + public static final String DEVICE_PREFIX = "VMP_device_";
  14 +
  15 + public static final String CACHEKEY_PREFIX = "VMP_channel_";
12 16  
13 17 public static final String KEEPLIVEKEY_PREFIX = "VMP_keeplive_";
14   -
  18 +
  19 + public static final String PLAYER_PREFIX = "VMP_player_";
  20 +
15 21 public static final String EVENT_ONLINE_REGISTER = "1";
16 22  
17 23 public static final String EVENT_ONLINE_KEEPLIVE = "2";
... ...
src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java 0 → 100644
  1 +package com.genersoft.iot.vmp.conf;
  2 +
  3 +import com.alibaba.fastjson.annotation.JSONField;
  4 +
  5 +public class MediaServerConfig {
  6 +
  7 + @JSONField(name = "api.apiDebug")
  8 + private String apiDebug;
  9 +
  10 + @JSONField(name = "api.secret")
  11 + private String apiSecret;
  12 +
  13 + @JSONField(name = "ffmpeg.bin")
  14 + private String ffmpegBin;
  15 +
  16 + @JSONField(name = "ffmpeg.cmd")
  17 + private String ffmpegCmd;
  18 +
  19 + @JSONField(name = "ffmpeg.log")
  20 + private String ffmpegLog;
  21 +
  22 + @JSONField(name = "general.enableVhost")
  23 + private String generalEnableVhost;
  24 +
  25 + @JSONField(name = "general.flowThreshold")
  26 + private String generalFlowThreshold;
  27 +
  28 + @JSONField(name = "general.maxStreamWaitMS")
  29 + private String generalMaxStreamWaitMS;
  30 +
  31 + @JSONField(name = "general.streamNoneReaderDelayMS")
  32 + private String generalStreamNoneReaderDelayMS;
  33 +
  34 + @JSONField(name = "hls.fileBufSize")
  35 + private String hlsFileBufSize;
  36 +
  37 + @JSONField(name = "hls.filePath")
  38 + private String hlsFilePath;
  39 +
  40 + @JSONField(name = "hls.segDur")
  41 + private String hlsSegDur;
  42 +
  43 + @JSONField(name = "hls.segNum")
  44 + private String hlsSegNum;
  45 +
  46 + @JSONField(name = "hook.access_file_except_hls")
  47 + private String hookAccessFileExceptHLS;
  48 +
  49 + @JSONField(name = "hook.admin_params")
  50 + private String hookAdminParams;
  51 +
  52 + @JSONField(name = "hook.enable")
  53 + private String hookEnable;
  54 +
  55 + @JSONField(name = "hook.on_flow_report")
  56 + private String hookOnFlowReport;
  57 +
  58 + @JSONField(name = "hook.on_http_access")
  59 + private String hookOnHttpAccess;
  60 +
  61 + @JSONField(name = "hook.on_play")
  62 + private String hookOnPlay;
  63 +
  64 + @JSONField(name = "hook.on_publish")
  65 + private String hookOnPublish;
  66 +
  67 + @JSONField(name = "hook.on_record_mp4")
  68 + private String hookOnRecordMp4;
  69 +
  70 + @JSONField(name = "hook.on_rtsp_auth")
  71 + private String hookOnRtspAuth;
  72 +
  73 + @JSONField(name = "hook.on_rtsp_realm")
  74 + private String hookOnRtspRealm;
  75 +
  76 + @JSONField(name = "hook.on_shell_login")
  77 + private String hookOnShellLogin;
  78 +
  79 + @JSONField(name = "hook.on_stream_changed")
  80 + private String hookOnStreamChanged;
  81 +
  82 + @JSONField(name = "hook.on_stream_none_reader")
  83 + private String hookOnStreamNoneReader;
  84 +
  85 + @JSONField(name = "hook.on_stream_not_found")
  86 + private String hookOnStreamNotFound;
  87 +
  88 + @JSONField(name = "hook.timeoutSec")
  89 + private String hookTimeoutSec;
  90 +
  91 + @JSONField(name = "http.charSet")
  92 + private String httpCharSet;
  93 +
  94 + @JSONField(name = "http.keepAliveSecond")
  95 + private String httpKeepAliveSecond;
  96 +
  97 + @JSONField(name = "http.maxReqCount")
  98 + private String httpMaxReqCount;
  99 +
  100 + @JSONField(name = "http.maxReqSize")
  101 + private String httpMaxReqSize;
  102 +
  103 + @JSONField(name = "http.notFound")
  104 + private String httpNotFound;
  105 +
  106 + @JSONField(name = "http.port")
  107 + private String httpPort;
  108 +
  109 + @JSONField(name = "http.rootPath")
  110 + private String httpRootPath;
  111 +
  112 + @JSONField(name = "http.sendBufSize")
  113 + private String httpSendBufSize;
  114 +
  115 + @JSONField(name = "http.sslport")
  116 + private String httpSSLport;
  117 +
  118 + @JSONField(name = "multicast.addrMax")
  119 + private String multicastAddrMax;
  120 +
  121 + @JSONField(name = "multicast.addrMin")
  122 + private String multicastAddrMin;
  123 +
  124 + @JSONField(name = "multicast.udpTTL")
  125 + private String multicastUdpTTL;
  126 +
  127 + @JSONField(name = "record.appName")
  128 + private String recordAppName;
  129 +
  130 + @JSONField(name = "record.filePath")
  131 + private String recordFilePath;
  132 +
  133 + @JSONField(name = "record.fileSecond")
  134 + private String recordFileSecond;
  135 +
  136 + @JSONField(name = "record.sampleMS")
  137 + private String recordFileSampleMS;
  138 +
  139 + @JSONField(name = "rtmp.handshakeSecond")
  140 + private String rtmpHandshakeSecond;
  141 +
  142 + @JSONField(name = "rtmp.keepAliveSecond")
  143 + private String rtmpKeepAliveSecond;
  144 +
  145 + @JSONField(name = "rtmp.modifyStamp")
  146 + private String rtmpModifyStamp;
  147 +
  148 + @JSONField(name = "rtmp.port")
  149 + private String rtmpPort;
  150 +
  151 + @JSONField(name = "rtp.audioMtuSize")
  152 + private String rtpAudioMtuSize;
  153 +
  154 + @JSONField(name = "rtp.clearCount")
  155 + private String rtpClearCount;
  156 +
  157 + @JSONField(name = "rtp.cycleMS")
  158 + private String rtpCycleMS;
  159 +
  160 + @JSONField(name = "rtp.maxRtpCount")
  161 + private String rtpMaxRtpCount;
  162 +
  163 + @JSONField(name = "rtp.videoMtuSize")
  164 + private String rtpVideoMtuSize;
  165 +
  166 + @JSONField(name = "rtsp.authBasic")
  167 + private String rtspAuthBasic;
  168 +
  169 + @JSONField(name = "rtsp.handshakeSecond")
  170 + private String rtspHandshakeSecond;
  171 +
  172 + @JSONField(name = "rtsp.keepAliveSecond")
  173 + private String rtspKeepAliveSecond;
  174 +
  175 + @JSONField(name = "rtsp.port")
  176 + private String rtspPort;
  177 +
  178 + @JSONField(name = "rtsp.sslport")
  179 + private String rtspSSlport;
  180 +
  181 + @JSONField(name = "shell.maxReqSize")
  182 + private String shellMaxReqSize;
  183 +
  184 + @JSONField(name = "shell.shell")
  185 + private String shellPhell;
  186 +
  187 +
  188 + public String getApiDebug() {
  189 + return apiDebug;
  190 + }
  191 +
  192 + public void setApiDebug(String apiDebug) {
  193 + this.apiDebug = apiDebug;
  194 + }
  195 +
  196 + public String getApiSecret() {
  197 + return apiSecret;
  198 + }
  199 +
  200 + public void setApiSecret(String apiSecret) {
  201 + this.apiSecret = apiSecret;
  202 + }
  203 +
  204 + public String getFfmpegBin() {
  205 + return ffmpegBin;
  206 + }
  207 +
  208 + public void setFfmpegBin(String ffmpegBin) {
  209 + this.ffmpegBin = ffmpegBin;
  210 + }
  211 +
  212 + public String getFfmpegCmd() {
  213 + return ffmpegCmd;
  214 + }
  215 +
  216 + public void setFfmpegCmd(String ffmpegCmd) {
  217 + this.ffmpegCmd = ffmpegCmd;
  218 + }
  219 +
  220 + public String getFfmpegLog() {
  221 + return ffmpegLog;
  222 + }
  223 +
  224 + public void setFfmpegLog(String ffmpegLog) {
  225 + this.ffmpegLog = ffmpegLog;
  226 + }
  227 +
  228 + public String getGeneralEnableVhost() {
  229 + return generalEnableVhost;
  230 + }
  231 +
  232 + public void setGeneralEnableVhost(String generalEnableVhost) {
  233 + this.generalEnableVhost = generalEnableVhost;
  234 + }
  235 +
  236 + public String getGeneralFlowThreshold() {
  237 + return generalFlowThreshold;
  238 + }
  239 +
  240 + public void setGeneralFlowThreshold(String generalFlowThreshold) {
  241 + this.generalFlowThreshold = generalFlowThreshold;
  242 + }
  243 +
  244 + public String getGeneralMaxStreamWaitMS() {
  245 + return generalMaxStreamWaitMS;
  246 + }
  247 +
  248 + public void setGeneralMaxStreamWaitMS(String generalMaxStreamWaitMS) {
  249 + this.generalMaxStreamWaitMS = generalMaxStreamWaitMS;
  250 + }
  251 +
  252 + public String getGeneralStreamNoneReaderDelayMS() {
  253 + return generalStreamNoneReaderDelayMS;
  254 + }
  255 +
  256 + public void setGeneralStreamNoneReaderDelayMS(String generalStreamNoneReaderDelayMS) {
  257 + this.generalStreamNoneReaderDelayMS = generalStreamNoneReaderDelayMS;
  258 + }
  259 +
  260 + public String getHlsFileBufSize() {
  261 + return hlsFileBufSize;
  262 + }
  263 +
  264 + public void setHlsFileBufSize(String hlsFileBufSize) {
  265 + this.hlsFileBufSize = hlsFileBufSize;
  266 + }
  267 +
  268 + public String getHlsFilePath() {
  269 + return hlsFilePath;
  270 + }
  271 +
  272 + public void setHlsFilePath(String hlsFilePath) {
  273 + this.hlsFilePath = hlsFilePath;
  274 + }
  275 +
  276 + public String getHlsSegDur() {
  277 + return hlsSegDur;
  278 + }
  279 +
  280 + public void setHlsSegDur(String hlsSegDur) {
  281 + this.hlsSegDur = hlsSegDur;
  282 + }
  283 +
  284 + public String getHlsSegNum() {
  285 + return hlsSegNum;
  286 + }
  287 +
  288 + public void setHlsSegNum(String hlsSegNum) {
  289 + this.hlsSegNum = hlsSegNum;
  290 + }
  291 +
  292 + public String getHookAccessFileExceptHLS() {
  293 + return hookAccessFileExceptHLS;
  294 + }
  295 +
  296 + public void setHookAccessFileExceptHLS(String hookAccessFileExceptHLS) {
  297 + this.hookAccessFileExceptHLS = hookAccessFileExceptHLS;
  298 + }
  299 +
  300 + public String getHookAdminParams() {
  301 + return hookAdminParams;
  302 + }
  303 +
  304 + public void setHookAdminParams(String hookAdminParams) {
  305 + this.hookAdminParams = hookAdminParams;
  306 + }
  307 +
  308 + public String getHookEnable() {
  309 + return hookEnable;
  310 + }
  311 +
  312 + public void setHookEnable(String hookEnable) {
  313 + this.hookEnable = hookEnable;
  314 + }
  315 +
  316 + public String getHookOnFlowReport() {
  317 + return hookOnFlowReport;
  318 + }
  319 +
  320 + public void setHookOnFlowReport(String hookOnFlowReport) {
  321 + this.hookOnFlowReport = hookOnFlowReport;
  322 + }
  323 +
  324 + public String getHookOnHttpAccess() {
  325 + return hookOnHttpAccess;
  326 + }
  327 +
  328 + public void setHookOnHttpAccess(String hookOnHttpAccess) {
  329 + this.hookOnHttpAccess = hookOnHttpAccess;
  330 + }
  331 +
  332 + public String getHookOnPlay() {
  333 + return hookOnPlay;
  334 + }
  335 +
  336 + public void setHookOnPlay(String hookOnPlay) {
  337 + this.hookOnPlay = hookOnPlay;
  338 + }
  339 +
  340 + public String getHookOnPublish() {
  341 + return hookOnPublish;
  342 + }
  343 +
  344 + public void setHookOnPublish(String hookOnPublish) {
  345 + this.hookOnPublish = hookOnPublish;
  346 + }
  347 +
  348 + public String getHookOnRecordMp4() {
  349 + return hookOnRecordMp4;
  350 + }
  351 +
  352 + public void setHookOnRecordMp4(String hookOnRecordMp4) {
  353 + this.hookOnRecordMp4 = hookOnRecordMp4;
  354 + }
  355 +
  356 + public String getHookOnRtspAuth() {
  357 + return hookOnRtspAuth;
  358 + }
  359 +
  360 + public void setHookOnRtspAuth(String hookOnRtspAuth) {
  361 + this.hookOnRtspAuth = hookOnRtspAuth;
  362 + }
  363 +
  364 + public String getHookOnRtspRealm() {
  365 + return hookOnRtspRealm;
  366 + }
  367 +
  368 + public void setHookOnRtspRealm(String hookOnRtspRealm) {
  369 + this.hookOnRtspRealm = hookOnRtspRealm;
  370 + }
  371 +
  372 + public String getHookOnShellLogin() {
  373 + return hookOnShellLogin;
  374 + }
  375 +
  376 + public void setHookOnShellLogin(String hookOnShellLogin) {
  377 + this.hookOnShellLogin = hookOnShellLogin;
  378 + }
  379 +
  380 + public String getHookOnStreamChanged() {
  381 + return hookOnStreamChanged;
  382 + }
  383 +
  384 + public void setHookOnStreamChanged(String hookOnStreamChanged) {
  385 + this.hookOnStreamChanged = hookOnStreamChanged;
  386 + }
  387 +
  388 + public String getHookOnStreamNoneReader() {
  389 + return hookOnStreamNoneReader;
  390 + }
  391 +
  392 + public void setHookOnStreamNoneReader(String hookOnStreamNoneReader) {
  393 + this.hookOnStreamNoneReader = hookOnStreamNoneReader;
  394 + }
  395 +
  396 + public String getHookOnStreamNotFound() {
  397 + return hookOnStreamNotFound;
  398 + }
  399 +
  400 + public void setHookOnStreamNotFound(String hookOnStreamNotFound) {
  401 + this.hookOnStreamNotFound = hookOnStreamNotFound;
  402 + }
  403 +
  404 + public String getHookTimeoutSec() {
  405 + return hookTimeoutSec;
  406 + }
  407 +
  408 + public void setHookTimeoutSec(String hookTimeoutSec) {
  409 + this.hookTimeoutSec = hookTimeoutSec;
  410 + }
  411 +
  412 + public String getHttpCharSet() {
  413 + return httpCharSet;
  414 + }
  415 +
  416 + public void setHttpCharSet(String httpCharSet) {
  417 + this.httpCharSet = httpCharSet;
  418 + }
  419 +
  420 + public String getHttpKeepAliveSecond() {
  421 + return httpKeepAliveSecond;
  422 + }
  423 +
  424 + public void setHttpKeepAliveSecond(String httpKeepAliveSecond) {
  425 + this.httpKeepAliveSecond = httpKeepAliveSecond;
  426 + }
  427 +
  428 + public String getHttpMaxReqCount() {
  429 + return httpMaxReqCount;
  430 + }
  431 +
  432 + public void setHttpMaxReqCount(String httpMaxReqCount) {
  433 + this.httpMaxReqCount = httpMaxReqCount;
  434 + }
  435 +
  436 + public String getHttpMaxReqSize() {
  437 + return httpMaxReqSize;
  438 + }
  439 +
  440 + public void setHttpMaxReqSize(String httpMaxReqSize) {
  441 + this.httpMaxReqSize = httpMaxReqSize;
  442 + }
  443 +
  444 + public String getHttpNotFound() {
  445 + return httpNotFound;
  446 + }
  447 +
  448 + public void setHttpNotFound(String httpNotFound) {
  449 + this.httpNotFound = httpNotFound;
  450 + }
  451 +
  452 + public String getHttpPort() {
  453 + return httpPort;
  454 + }
  455 +
  456 + public void setHttpPort(String httpPort) {
  457 + this.httpPort = httpPort;
  458 + }
  459 +
  460 + public String getHttpRootPath() {
  461 + return httpRootPath;
  462 + }
  463 +
  464 + public void setHttpRootPath(String httpRootPath) {
  465 + this.httpRootPath = httpRootPath;
  466 + }
  467 +
  468 + public String getHttpSendBufSize() {
  469 + return httpSendBufSize;
  470 + }
  471 +
  472 + public void setHttpSendBufSize(String httpSendBufSize) {
  473 + this.httpSendBufSize = httpSendBufSize;
  474 + }
  475 +
  476 + public String getHttpSSLport() {
  477 + return httpSSLport;
  478 + }
  479 +
  480 + public void setHttpSSLport(String httpSSLport) {
  481 + this.httpSSLport = httpSSLport;
  482 + }
  483 +
  484 + public String getMulticastAddrMax() {
  485 + return multicastAddrMax;
  486 + }
  487 +
  488 + public void setMulticastAddrMax(String multicastAddrMax) {
  489 + this.multicastAddrMax = multicastAddrMax;
  490 + }
  491 +
  492 + public String getMulticastAddrMin() {
  493 + return multicastAddrMin;
  494 + }
  495 +
  496 + public void setMulticastAddrMin(String multicastAddrMin) {
  497 + this.multicastAddrMin = multicastAddrMin;
  498 + }
  499 +
  500 + public String getMulticastUdpTTL() {
  501 + return multicastUdpTTL;
  502 + }
  503 +
  504 + public void setMulticastUdpTTL(String multicastUdpTTL) {
  505 + this.multicastUdpTTL = multicastUdpTTL;
  506 + }
  507 +
  508 + public String getRecordAppName() {
  509 + return recordAppName;
  510 + }
  511 +
  512 + public void setRecordAppName(String recordAppName) {
  513 + this.recordAppName = recordAppName;
  514 + }
  515 +
  516 + public String getRecordFilePath() {
  517 + return recordFilePath;
  518 + }
  519 +
  520 + public void setRecordFilePath(String recordFilePath) {
  521 + this.recordFilePath = recordFilePath;
  522 + }
  523 +
  524 + public String getRecordFileSecond() {
  525 + return recordFileSecond;
  526 + }
  527 +
  528 + public void setRecordFileSecond(String recordFileSecond) {
  529 + this.recordFileSecond = recordFileSecond;
  530 + }
  531 +
  532 + public String getRecordFileSampleMS() {
  533 + return recordFileSampleMS;
  534 + }
  535 +
  536 + public void setRecordFileSampleMS(String recordFileSampleMS) {
  537 + this.recordFileSampleMS = recordFileSampleMS;
  538 + }
  539 +
  540 + public String getRtmpHandshakeSecond() {
  541 + return rtmpHandshakeSecond;
  542 + }
  543 +
  544 + public void setRtmpHandshakeSecond(String rtmpHandshakeSecond) {
  545 + this.rtmpHandshakeSecond = rtmpHandshakeSecond;
  546 + }
  547 +
  548 + public String getRtmpKeepAliveSecond() {
  549 + return rtmpKeepAliveSecond;
  550 + }
  551 +
  552 + public void setRtmpKeepAliveSecond(String rtmpKeepAliveSecond) {
  553 + this.rtmpKeepAliveSecond = rtmpKeepAliveSecond;
  554 + }
  555 +
  556 + public String getRtmpModifyStamp() {
  557 + return rtmpModifyStamp;
  558 + }
  559 +
  560 + public void setRtmpModifyStamp(String rtmpModifyStamp) {
  561 + this.rtmpModifyStamp = rtmpModifyStamp;
  562 + }
  563 +
  564 + public String getRtmpPort() {
  565 + return rtmpPort;
  566 + }
  567 +
  568 + public void setRtmpPort(String rtmpPort) {
  569 + this.rtmpPort = rtmpPort;
  570 + }
  571 +
  572 + public String getRtpAudioMtuSize() {
  573 + return rtpAudioMtuSize;
  574 + }
  575 +
  576 + public void setRtpAudioMtuSize(String rtpAudioMtuSize) {
  577 + this.rtpAudioMtuSize = rtpAudioMtuSize;
  578 + }
  579 +
  580 + public String getRtpClearCount() {
  581 + return rtpClearCount;
  582 + }
  583 +
  584 + public void setRtpClearCount(String rtpClearCount) {
  585 + this.rtpClearCount = rtpClearCount;
  586 + }
  587 +
  588 + public String getRtpCycleMS() {
  589 + return rtpCycleMS;
  590 + }
  591 +
  592 + public void setRtpCycleMS(String rtpCycleMS) {
  593 + this.rtpCycleMS = rtpCycleMS;
  594 + }
  595 +
  596 + public String getRtpMaxRtpCount() {
  597 + return rtpMaxRtpCount;
  598 + }
  599 +
  600 + public void setRtpMaxRtpCount(String rtpMaxRtpCount) {
  601 + this.rtpMaxRtpCount = rtpMaxRtpCount;
  602 + }
  603 +
  604 + public String getRtpVideoMtuSize() {
  605 + return rtpVideoMtuSize;
  606 + }
  607 +
  608 + public void setRtpVideoMtuSize(String rtpVideoMtuSize) {
  609 + this.rtpVideoMtuSize = rtpVideoMtuSize;
  610 + }
  611 +
  612 + public String getRtspAuthBasic() {
  613 + return rtspAuthBasic;
  614 + }
  615 +
  616 + public void setRtspAuthBasic(String rtspAuthBasic) {
  617 + this.rtspAuthBasic = rtspAuthBasic;
  618 + }
  619 +
  620 + public String getRtspHandshakeSecond() {
  621 + return rtspHandshakeSecond;
  622 + }
  623 +
  624 + public void setRtspHandshakeSecond(String rtspHandshakeSecond) {
  625 + this.rtspHandshakeSecond = rtspHandshakeSecond;
  626 + }
  627 +
  628 + public String getRtspKeepAliveSecond() {
  629 + return rtspKeepAliveSecond;
  630 + }
  631 +
  632 + public void setRtspKeepAliveSecond(String rtspKeepAliveSecond) {
  633 + this.rtspKeepAliveSecond = rtspKeepAliveSecond;
  634 + }
  635 +
  636 + public String getRtspPort() {
  637 + return rtspPort;
  638 + }
  639 +
  640 + public void setRtspPort(String rtspPort) {
  641 + this.rtspPort = rtspPort;
  642 + }
  643 +
  644 + public String getRtspSSlport() {
  645 + return rtspSSlport;
  646 + }
  647 +
  648 + public void setRtspSSlport(String rtspSSlport) {
  649 + this.rtspSSlport = rtspSSlport;
  650 + }
  651 +
  652 + public String getShellMaxReqSize() {
  653 + return shellMaxReqSize;
  654 + }
  655 +
  656 + public void setShellMaxReqSize(String shellMaxReqSize) {
  657 + this.shellMaxReqSize = shellMaxReqSize;
  658 + }
  659 +
  660 + public String getShellPhell() {
  661 + return shellPhell;
  662 + }
  663 +
  664 + public void setShellPhell(String shellPhell) {
  665 + this.shellPhell = shellPhell;
  666 + }
  667 +}
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
... ... @@ -49,7 +49,9 @@ public class Device {
49 49 /**
50 50 * 通道列表
51 51 */
52   - private Map<String,DeviceChannel> channelMap;
  52 +// private Map<String,DeviceChannel> channelMap;
  53 +
  54 + private int channelCount;
53 55  
54 56  
55 57 public String getDeviceId() {
... ... @@ -84,13 +86,13 @@ public class Device {
84 86 this.host = host;
85 87 }
86 88  
87   - public Map<String, DeviceChannel> getChannelMap() {
88   - return channelMap;
89   - }
90   -
91   - public void setChannelMap(Map<String, DeviceChannel> channelMap) {
92   - this.channelMap = channelMap;
93   - }
  89 +// public Map<String, DeviceChannel> getChannelMap() {
  90 +// return channelMap;
  91 +// }
  92 +//
  93 +// public void setChannelMap(Map<String, DeviceChannel> channelMap) {
  94 +// this.channelMap = channelMap;
  95 +// }
94 96  
95 97 public String getManufacturer() {
96 98 return manufacturer;
... ... @@ -123,4 +125,12 @@ public class Device {
123 125 public void setOnline(int online) {
124 126 this.online = online;
125 127 }
  128 +
  129 + public int getChannelCount() {
  130 + return channelCount;
  131 + }
  132 +
  133 + public void setChannelCount(int channelCount) {
  134 + this.channelCount = channelCount;
  135 + }
126 136 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java
... ... @@ -100,7 +100,12 @@ public class DeviceChannel {
100 100 /**
101 101 * 密码
102 102 */
103   - private String password;
  103 + private String password;
  104 +
  105 + /**
  106 + * 云台控制
  107 + */
  108 + private int PTZType;
104 109  
105 110 /**
106 111 * 在线/离线
... ... @@ -123,6 +128,11 @@ public class DeviceChannel {
123 128 */
124 129 private double latitude;
125 130  
  131 + /**
  132 + * 流唯一编号,存在表示正在直播
  133 + */
  134 + private String ssrc;
  135 +
126 136 public String getChannelId() {
127 137 return channelId;
128 138 }
... ... @@ -306,4 +316,20 @@ public class DeviceChannel {
306 316 public void setLatitude(double latitude) {
307 317 this.latitude = latitude;
308 318 }
  319 +
  320 + public int getPTZType() {
  321 + return PTZType;
  322 + }
  323 +
  324 + public void setPTZType(int PTZType) {
  325 + this.PTZType = PTZType;
  326 + }
  327 +
  328 + public String getSsrc() {
  329 + return ssrc;
  330 + }
  331 +
  332 + public void setSsrc(String ssrc) {
  333 + this.ssrc = ssrc;
  334 + }
309 335 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
1 1 package com.genersoft.iot.vmp.gb28181.transmit.cmd;
2 2  
  3 +import com.genersoft.iot.vmp.common.StreamInfo;
3 4 import com.genersoft.iot.vmp.gb28181.bean.Device;
4 5  
5 6 /**
... ... @@ -69,7 +70,7 @@ public interface ISIPCommander {
69 70 * @param device 视频设备
70 71 * @param channelId 预览通道
71 72 */
72   - public String playStreamCmd(Device device,String channelId);
  73 + public StreamInfo playStreamCmd(Device device, String channelId);
73 74  
74 75 /**
75 76 * 请求回放视频流
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
... ... @@ -15,8 +15,14 @@ import javax.sip.address.SipURI;
15 15 import javax.sip.header.ViaHeader;
16 16 import javax.sip.message.Request;
17 17  
  18 +import com.alibaba.fastjson.JSONObject;
  19 +import com.genersoft.iot.vmp.common.StreamInfo;
  20 +import com.genersoft.iot.vmp.conf.MediaServerConfig;
  21 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
  22 +import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
18 23 import org.springframework.beans.factory.annotation.Autowired;
19 24 import org.springframework.beans.factory.annotation.Qualifier;
  25 +import org.springframework.beans.factory.annotation.Value;
20 26 import org.springframework.stereotype.Component;
21 27  
22 28 import com.genersoft.iot.vmp.conf.SipConfig;
... ... @@ -42,6 +48,9 @@ public class SIPCommander implements ISIPCommander {
42 48  
43 49 @Autowired
44 50 private VideoStreamSessionManager streamSession;
  51 +
  52 + @Autowired
  53 + private IVideoManagerStorager storager;
45 54  
46 55 @Autowired
47 56 @Qualifier(value="tcpSipProvider")
... ... @@ -50,6 +59,9 @@ public class SIPCommander implements ISIPCommander {
50 59 @Autowired
51 60 @Qualifier(value="udpSipProvider")
52 61 private SipProvider udpSipProvider;
  62 +
  63 + @Value("${media.ip}")
  64 + private String mediaIp;
53 65  
54 66 /**
55 67 * 云台方向放控制,使用配置文件中的默认镜头移动速度
... ... @@ -58,7 +70,6 @@ public class SIPCommander implements ISIPCommander {
58 70 * @param channelId 预览通道
59 71 * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
60 72 * @param upDown 镜头上移下移 0:停止 1:上移 2:下移
61   - * @param moveSpeed 镜头移动速度
62 73 */
63 74 @Override
64 75 public boolean ptzdirectCmd(Device device, String channelId, int leftRight, int upDown) {
... ... @@ -191,7 +202,7 @@ public class SIPCommander implements ISIPCommander {
191 202 * @param channelId 预览通道
192 203 */
193 204 @Override
194   - public String playStreamCmd(Device device, String channelId) {
  205 + public StreamInfo playStreamCmd(Device device, String channelId) {
195 206 try {
196 207  
197 208 String ssrc = streamSession.createPlaySsrc();
... ... @@ -223,7 +234,24 @@ public class SIPCommander implements ISIPCommander {
223 234  
224 235 ClientTransaction transaction = transmitRequest(device, request);
225 236 streamSession.put(ssrc, transaction);
226   - return ssrc;
  237 + DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId);
  238 + if (deviceChannel != null) {
  239 + deviceChannel.setSsrc(ssrc);
  240 + storager.updateChannel(device.getDeviceId(), deviceChannel);
  241 + }
  242 + MediaServerConfig mediaInfo = storager.getMediaInfo();
  243 + StreamInfo streamInfo = new StreamInfo();
  244 + streamInfo.setSsrc(ssrc);
  245 +// String streamId = Integer.toHexString(Integer.parseInt(streamInfo.getSsrc()));
  246 + String streamId = String.format("%08x", Integer.parseInt(streamInfo.getSsrc())).toUpperCase(); // ZLM 要求大写且首位补零
  247 + streamInfo.setFlv(String.format("http://%s:%s/rtp/%s.flv", mediaIp, mediaInfo.getHttpPort(), streamId));
  248 + streamInfo.setWS_FLV(String.format("ws://%s:%s/rtp/%s.flv", mediaIp, mediaInfo.getHttpPort(), streamId));
  249 + streamInfo.setRTMP(String.format("rtmp://%s:%s/rtp/%s", mediaIp, mediaInfo.getRtmpPort(), streamId));
  250 + streamInfo.setHLS(String.format("http://%s:%s/rtp/%s/hls.m3u8", mediaIp, mediaInfo.getHttpPort(), streamId));
  251 + streamInfo.setRTSP(String.format("rtsp://%s:%s/rtp/%s", mediaIp, mediaInfo.getRtspPort(), streamId));
  252 +
  253 + storager.startPlay(device.getDeviceId(), channelId, streamInfo);
  254 + return streamInfo;
227 255 } catch ( SipException | ParseException | InvalidArgumentException e) {
228 256 e.printStackTrace();
229 257 return null;
... ... @@ -281,8 +309,6 @@ public class SIPCommander implements ISIPCommander {
281 309 /**
282 310 * 视频流停止
283 311 *
284   - * @param device 视频设备
285   - * @param channelId 预览通道
286 312 */
287 313 @Override
288 314 public void streamByeCmd(String ssrc) {
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
... ... @@ -76,8 +76,6 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
76 76 * 处理MESSAGE请求
77 77 *
78 78 * @param evt
79   - * @param layer
80   - * @param transaction
81 79 */
82 80 @Override
83 81 public void process(RequestEvent evt) {
... ... @@ -127,7 +125,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
127 125 device.setManufacturer(XmlUtil.getText(rootElement,"Manufacturer"));
128 126 device.setModel(XmlUtil.getText(rootElement,"Model"));
129 127 device.setFirmware(XmlUtil.getText(rootElement,"Firmware"));
130   - storager.update(device);
  128 + storager.updateDevice(device);
131 129  
132 130 RequestMessage msg = new RequestMessage();
133 131 msg.setDeviceId(deviceId);
... ... @@ -158,11 +156,6 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
158 156 if (device == null) {
159 157 return;
160 158 }
161   - Map<String, DeviceChannel> channelMap = device.getChannelMap();
162   - if (channelMap == null) {
163   - channelMap = new HashMap<String, DeviceChannel>(5);
164   - device.setChannelMap(channelMap);
165   - }
166 159 // 遍历DeviceList
167 160 while (deviceListIterator.hasNext()) {
168 161 Element itemDevice = deviceListIterator.next();
... ... @@ -175,7 +168,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
175 168 String channelName = channdelNameElement != null ? channdelNameElement.getText().toString() : "";
176 169 Element statusElement = itemDevice.element("Status");
177 170 String status = statusElement != null ? statusElement.getText().toString() : "ON";
178   - DeviceChannel deviceChannel = channelMap.containsKey(channelDeviceId) ? channelMap.get(channelDeviceId) : new DeviceChannel();
  171 + DeviceChannel deviceChannel = new DeviceChannel();
179 172 deviceChannel.setName(channelName);
180 173 deviceChannel.setChannelId(channelDeviceId);
181 174 if(status.equals("ON")) {
... ... @@ -205,10 +198,12 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
205 198 deviceChannel.setPassword(XmlUtil.getText(itemDevice,"Password"));
206 199 deviceChannel.setLongitude(itemDevice.element("Longitude") == null? 0.00:Double.parseDouble(XmlUtil.getText(itemDevice,"Longitude")));
207 200 deviceChannel.setLatitude(itemDevice.element("Latitude") == null? 0.00:Double.parseDouble(XmlUtil.getText(itemDevice,"Latitude")));
208   - channelMap.put(channelDeviceId, deviceChannel);
  201 + deviceChannel.setPTZType(itemDevice.element("PTZType") == null? 0:Integer.parseInt(XmlUtil.getText(itemDevice,"PTZType")));
  202 + storager.updateChannel(device.getDeviceId(), deviceChannel);
209 203 }
210 204 // 更新
211   - storager.update(device);
  205 + storager.updateDevice(device);
  206 +
212 207 RequestMessage msg = new RequestMessage();
213 208 msg.setDeviceId(deviceId);
214 209 msg.setType(DeferredResultHolder.CALLBACK_CMD_CATALOG);
... ... @@ -232,13 +227,15 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
232 227  
233 228 Device device = storager.queryVideoDevice(deviceId);
234 229 if (device == null) {
  230 + // TODO 也可能是通道
  231 +// storager.queryChannel(deviceId)
235 232 return;
236 233 }
237 234 device.setName(XmlUtil.getText(rootElement,"DeviceName"));
238 235 device.setManufacturer(XmlUtil.getText(rootElement,"Manufacturer"));
239 236 device.setModel(XmlUtil.getText(rootElement,"Model"));
240 237 device.setFirmware(XmlUtil.getText(rootElement,"Firmware"));
241   - storager.update(device);
  238 + storager.updateDevice(device);
242 239 cmder.catalogQuery(device);
243 240 } catch (DocumentException e) {
244 241 e.printStackTrace();
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
... ... @@ -138,7 +138,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
138 138 // 下发catelog查询目录
139 139 if (registerFlag == 1 && device != null) {
140 140 System.out.println("注册成功! deviceId:" + device.getDeviceId());
141   - storager.update(device);
  141 + storager.updateDevice(device);
142 142 publisher.onlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_ONLINE_REGISTER);
143 143 handler.onRegister(device);
144 144 } else if (registerFlag == 2) {
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/SolrProxyServletConfiguration.java 0 → 100644
  1 +package com.genersoft.iot.vmp.media.zlm;
  2 +
  3 +import com.google.common.collect.ImmutableMap;
  4 +import org.mitre.dsmiley.httpproxy.ProxyServlet;
  5 +import org.springframework.beans.factory.annotation.Value;
  6 +import org.springframework.boot.web.servlet.ServletRegistrationBean;
  7 +import org.springframework.context.annotation.Bean;
  8 +import org.springframework.context.annotation.Configuration;
  9 +
  10 +import javax.servlet.Servlet;
  11 +import java.util.Map;
  12 +
  13 +/**
  14 + * 对查询流媒体信息的请求进行反向代理
  15 + */
  16 +@Configuration
  17 +public class SolrProxyServletConfiguration {
  18 +
  19 + // 读取配置文件中路由设置
  20 + @Value("${proxy.servlet_url}")
  21 + private String servlet_url;
  22 + // 读取配置中代理目标地址
  23 + @Value("${proxy.target_url}")
  24 + private String target_url;
  25 +
  26 +
  27 +
  28 + @Bean
  29 + public Servlet createProxyServlet(){
  30 + // 创建新的ProxyServlet
  31 + return new ProxyServlet();
  32 + }
  33 + @Bean
  34 + public ServletRegistrationBean proxyServletRegistration(){
  35 + ServletRegistrationBean registrationBean = new ServletRegistrationBean(createProxyServlet(), servlet_url);
  36 + //设置网址以及参数
  37 + Map<String, String> params = ImmutableMap.of(
  38 + "targetUri", target_url,
  39 + "log", "true");
  40 + registrationBean.setInitParameters(params);
  41 + return registrationBean;
  42 + }
  43 +}
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
1 1 package com.genersoft.iot.vmp.media.zlm;
2 2  
3 3 import java.math.BigInteger;
  4 +import java.util.ArrayList;
  5 +import java.util.List;
4 6  
  7 +import com.alibaba.fastjson.JSON;
  8 +import com.alibaba.fastjson.JSONArray;
  9 +import com.genersoft.iot.vmp.conf.MediaServerConfig;
  10 +import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
5 11 import org.slf4j.Logger;
6 12 import org.slf4j.LoggerFactory;
7 13 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -29,6 +35,9 @@ public class ZLMHttpHookListener {
29 35  
30 36 @Autowired
31 37 private SIPCommander cmder;
  38 +
  39 + @Autowired
  40 + private IVideoManagerStorager storager;
32 41  
33 42 /**
34 43 * 流量统计事件,播放器或推流器断开时并且耗用流量超过特定阈值时会触发此事件,阈值通过配置文件general.flowThreshold配置;此事件对回复不敏感。
... ... @@ -263,6 +272,12 @@ public class ZLMHttpHookListener {
263 272 if (logger.isDebugEnabled()) {
264 273 logger.debug("ZLM HOOK on_server_started API调用,参数:" + json.toString());
265 274 }
  275 +
  276 +// String data = json.getString("data");
  277 +// List<MediaServerConfig> mediaServerConfigs = JSON.parseArray(JSON.toJSONString(json), MediaServerConfig.class);
  278 +// MediaServerConfig mediaServerConfig = mediaServerConfigs.get(0);
  279 + MediaServerConfig mediaServerConfig = JSON.toJavaObject(json, MediaServerConfig.class);
  280 + storager.updateMediaInfo(mediaServerConfig);
266 281 // TODO Auto-generated method stub
267 282  
268 283 JSONObject ret = new JSONObject();
... ...
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
... ... @@ -2,7 +2,12 @@ package com.genersoft.iot.vmp.storager;
2 2  
3 3 import java.util.List;
4 4  
  5 +import com.alibaba.fastjson.JSONObject;
  6 +import com.genersoft.iot.vmp.common.PageResult;
  7 +import com.genersoft.iot.vmp.common.StreamInfo;
  8 +import com.genersoft.iot.vmp.conf.MediaServerConfig;
5 9 import com.genersoft.iot.vmp.gb28181.bean.Device;
  10 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
6 11  
7 12 /**
8 13 * @Description:视频设备数据存储接口
... ... @@ -10,7 +15,20 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
10 15 * @date: 2020年5月6日 下午2:14:31
11 16 */
12 17 public interface IVideoManagerStorager {
13   -
  18 +
  19 + /**
  20 + * 更新流媒体信息
  21 + * @param mediaServerConfig
  22 + * @return
  23 + */
  24 + public boolean updateMediaInfo(MediaServerConfig mediaServerConfig);
  25 +
  26 + /**
  27 + * 获取流媒体信息
  28 + * @return
  29 + */
  30 + public MediaServerConfig getMediaInfo();
  31 +
14 32 /**
15 33 * 根据设备ID判断设备是否存在
16 34 *
... ... @@ -33,7 +51,15 @@ public interface IVideoManagerStorager {
33 51 * @param device 设备对象
34 52 * @return true:创建成功 false:创建失败
35 53 */
36   - public boolean update(Device device);
  54 + public boolean updateDevice(Device device);
  55 +
  56 + /**
  57 + * 添加设备通道
  58 + *
  59 + * @param deviceId 设备id
  60 + * @param channel 通道
  61 + */
  62 + public void updateChannel(String deviceId, DeviceChannel channel);
37 63  
38 64 /**
39 65 * 获取设备
... ... @@ -42,15 +68,47 @@ public interface IVideoManagerStorager {
42 68 * @return DShadow 设备对象
43 69 */
44 70 public Device queryVideoDevice(String deviceId);
45   -
  71 +
  72 + /**
  73 + * 获取某个设备的通道列表
  74 + *
  75 + * @param deviceId 设备ID
  76 + * @param page 分页 当前页
  77 + * @param count 每页数量
  78 + * @return
  79 + */
  80 + public PageResult queryChannelsByDeviceId(String deviceId, int page, int count);
  81 +
  82 + /**
  83 + * 获取某个设备的通道列表
  84 + *
  85 + * @param deviceId 设备ID
  86 + * @return
  87 + */
  88 + public List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
  89 + /**
  90 + * 获取某个设备的通道
  91 + * @param deviceId 设备ID
  92 + * @param channelId 通道ID
  93 + */
  94 + public DeviceChannel queryChannel(String deviceId, String channelId);
  95 +
46 96 /**
47 97 * 获取多个设备
48 98 *
49 99 * @param deviceIds 设备ID数组
50 100 * @return List<Device> 设备对象数组
51 101 */
  102 + public PageResult<Device> queryVideoDeviceList(String[] deviceIds, int page, int count);
  103 +
  104 + /**
  105 + * 获取多个设备
  106 + *
  107 + * @param deviceIds 设备ID数组
  108 + * @return List<Device> 设备对象数组
  109 + */
52 110 public List<Device> queryVideoDeviceList(String[] deviceIds);
53   -
  111 +
54 112 /**
55 113 * 删除设备
56 114 *
... ... @@ -74,4 +132,35 @@ public interface IVideoManagerStorager {
74 132 * @return true:更新成功 false:更新失败
75 133 */
76 134 public boolean outline(String deviceId);
  135 +
  136 + /**
  137 + * 开始播放时将流存入
  138 + *
  139 + * @param deviceId 设备ID
  140 + * @param channelId 通道ID
  141 + * @param stream 流信息
  142 + * @return
  143 + */
  144 + public boolean startPlay(String deviceId, String channelId, StreamInfo stream);
  145 +
  146 + /**
  147 + * 停止播放时删除
  148 + *
  149 + * @param deviceId 设备ID
  150 + * @param channelId 通道ID
  151 + * @return
  152 + */
  153 + public boolean stopPlay(String deviceId, String channelId);
  154 +
  155 + /**
  156 + * 查找视频流
  157 + *
  158 + * @param deviceId 设备ID
  159 + * @param channelId 通道ID
  160 + * @return
  161 + */
  162 + public StreamInfo queryPlay(String deviceId, String channelId);
  163 +
  164 +
  165 +
77 166 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/jdbc/VideoManagerJdbcStoragerImpl.java
... ... @@ -2,6 +2,10 @@ package com.genersoft.iot.vmp.storager.jdbc;
2 2  
3 3 import java.util.List;
4 4  
  5 +import com.genersoft.iot.vmp.common.PageResult;
  6 +import com.genersoft.iot.vmp.common.StreamInfo;
  7 +import com.genersoft.iot.vmp.conf.MediaServerConfig;
  8 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
5 9 import org.springframework.stereotype.Component;
6 10 import org.springframework.stereotype.Service;
7 11  
... ... @@ -17,7 +21,17 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
17 21 @Component("jdbcStorager")
18 22 public class VideoManagerJdbcStoragerImpl implements IVideoManagerStorager {
19 23  
20   - /**
  24 + @Override
  25 + public boolean updateMediaInfo(MediaServerConfig mediaServerConfig) {
  26 + return false;
  27 + }
  28 +
  29 + @Override
  30 + public MediaServerConfig getMediaInfo() {
  31 + return null;
  32 + }
  33 +
  34 + /**
21 35 * 根据设备ID判断设备是否存在
22 36 *
23 37 * @param deviceId 设备ID
... ... @@ -40,19 +54,18 @@ public class VideoManagerJdbcStoragerImpl implements IVideoManagerStorager {
40 54 // TODO Auto-generated method stub
41 55 return false;
42 56 }
43   -
44   - /**
45   - * 视频设备更新
46   - *
47   - * @param device 设备对象
48   - * @return true:更新成功 false:更新失败
49   - */
  57 +
50 58 @Override
51   - public boolean update(Device device) {
52   - // TODO Auto-generated method stub
  59 + public boolean updateDevice(Device device) {
53 60 return false;
54 61 }
55 62  
  63 + @Override
  64 + public void updateChannel(String deviceId, DeviceChannel channel) {
  65 +
  66 + }
  67 +
  68 +
56 69 /**
57 70 * 获取设备
58 71 *
... ... @@ -65,6 +78,26 @@ public class VideoManagerJdbcStoragerImpl implements IVideoManagerStorager {
65 78 return null;
66 79 }
67 80  
  81 + @Override
  82 + public PageResult queryChannelsByDeviceId(String deviceId, int page, int count) {
  83 + return null;
  84 + }
  85 +
  86 + @Override
  87 + public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
  88 + return null;
  89 + }
  90 +
  91 + @Override
  92 + public DeviceChannel queryChannel(String deviceId, String channelId) {
  93 + return null;
  94 + }
  95 +
  96 + @Override
  97 + public PageResult<Device> queryVideoDeviceList(String[] deviceIds, int page, int count) {
  98 + return null;
  99 + }
  100 +
68 101 /**
69 102 * 获取多个设备
70 103 *
... ... @@ -113,4 +146,19 @@ public class VideoManagerJdbcStoragerImpl implements IVideoManagerStorager {
113 146 return false;
114 147 }
115 148  
  149 + @Override
  150 + public boolean startPlay(String deviceId, String channelId, StreamInfo stream) {
  151 + return false;
  152 + }
  153 +
  154 + @Override
  155 + public boolean stopPlay(String deviceId, String channelId) {
  156 + return false;
  157 + }
  158 +
  159 + @Override
  160 + public StreamInfo queryPlay(String deviceId, String channelId) {
  161 + return null;
  162 + }
  163 +
116 164 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java
... ... @@ -3,6 +3,12 @@ package com.genersoft.iot.vmp.storager.redis;
3 3 import java.util.ArrayList;
4 4 import java.util.List;
5 5  
  6 +import com.alibaba.fastjson.JSON;
  7 +import com.alibaba.fastjson.JSONObject;
  8 +import com.genersoft.iot.vmp.common.PageResult;
  9 +import com.genersoft.iot.vmp.common.StreamInfo;
  10 +import com.genersoft.iot.vmp.conf.MediaServerConfig;
  11 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
6 12 import org.springframework.beans.factory.annotation.Autowired;
7 13 import org.springframework.stereotype.Component;
8 14  
... ... @@ -21,7 +27,8 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
21 27  
22 28 @Autowired
23 29 private RedisUtil redis;
24   -
  30 +
  31 +
25 32 /**
26 33 * 根据设备ID判断设备是否存在
27 34 *
... ... @@ -30,7 +37,7 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
30 37 */
31 38 @Override
32 39 public boolean exists(String deviceId) {
33   - return redis.hasKey(VideoManagerConstants.CACHEKEY_PREFIX+deviceId);
  40 + return redis.hasKey(VideoManagerConstants.DEVICE_PREFIX+deviceId);
34 41 }
35 42  
36 43 /**
... ... @@ -41,9 +48,11 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
41 48 */
42 49 @Override
43 50 public boolean create(Device device) {
44   - return redis.set(VideoManagerConstants.CACHEKEY_PREFIX+device.getDeviceId(), device);
  51 + return redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
45 52 }
46   -
  53 +
  54 +
  55 +
47 56 /**
48 57 * 视频设备更新
49 58 *
... ... @@ -51,8 +60,26 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
51 60 * @return true:更新成功 false:更新失败
52 61 */
53 62 @Override
54   - public boolean update(Device device) {
55   - return redis.set(VideoManagerConstants.CACHEKEY_PREFIX+device.getDeviceId(), device);
  63 + public boolean updateDevice(Device device) {
  64 + List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + device.getDeviceId() + "_" + "*");
  65 + // 更新device中的通道数量
  66 + device.setChannelCount(deviceChannelList.size());
  67 + // 存储device
  68 + return redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
  69 +
  70 +
  71 + }
  72 +
  73 + @Override
  74 + public void updateChannel(String deviceId, DeviceChannel channel) {
  75 + // 存储通道
  76 + redis.set(VideoManagerConstants.CACHEKEY_PREFIX+deviceId + "_" + channel.getChannelId(),
  77 + channel);
  78 + List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
  79 + // 更新device中的通道数量
  80 + Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId);
  81 + device.setChannelCount(deviceChannelList.size());
  82 + redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
56 83 }
57 84  
58 85 /**
... ... @@ -63,26 +90,94 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
63 90 */
64 91 @Override
65 92 public Device queryVideoDevice(String deviceId) {
66   - return (Device)redis.get(VideoManagerConstants.CACHEKEY_PREFIX+deviceId);
  93 + return (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId);
67 94 }
68 95  
69   - /**
  96 + @Override
  97 + public PageResult queryChannelsByDeviceId(String deviceId, int page, int count) {
  98 + List<DeviceChannel> result = new ArrayList<>();
  99 + PageResult pageResult = new PageResult<DeviceChannel>();
  100 + List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
  101 + pageResult.setPage(page);
  102 + pageResult.setCount(count);
  103 + pageResult.setTotal(deviceChannelList.size());
  104 + int maxCount = (page + 1 ) * count;
  105 + if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
  106 + for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) {
  107 + result.add((DeviceChannel)redis.get((String)deviceChannelList.get(i)));
  108 + }
  109 + pageResult.setData(result);
  110 + }
  111 +
  112 + return pageResult;
  113 + }
  114 +
  115 + @Override
  116 + public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
  117 + List<DeviceChannel> result = new ArrayList<>();
  118 + List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
  119 + if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
  120 + for (int i = 0; i < deviceChannelList.size(); i++) {
  121 + result.add((DeviceChannel)redis.get((String)deviceChannelList.get(i)));
  122 + }
  123 + }
  124 + return result;
  125 + }
  126 +
  127 + @Override
  128 + public DeviceChannel queryChannel(String deviceId, String channelId) {
  129 + return (DeviceChannel)redis.get(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + channelId);
  130 + }
  131 +
  132 +
  133 + /**
70 134 * 获取多个设备
71 135 *
72 136 * @param deviceIds 设备ID数组
73 137 * @return List<Device> 设备对象数组
74 138 */
75 139 @Override
  140 + public PageResult<Device> queryVideoDeviceList(String[] deviceIds, int page, int count) {
  141 + List<Device> devices = new ArrayList<>();
  142 + PageResult pageResult = new PageResult<Device>();
  143 + pageResult.setPage(page);
  144 + pageResult.setCount(count);
  145 +
  146 + if (deviceIds == null || deviceIds.length == 0) {
  147 +
  148 + List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*");
  149 + pageResult.setTotal(deviceIdList.size());
  150 + int maxCount = (page + 1)* count;
  151 + for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) {
  152 + devices.add((Device)redis.get((String)deviceIdList.get(i)));
  153 + }
  154 + } else {
  155 + for (int i = 0; i < deviceIds.length; i++) {
  156 + devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]));
  157 + }
  158 + }
  159 + pageResult.setData(devices);
  160 + return pageResult;
  161 + }
  162 +
  163 + /**
  164 + * 获取多个设备
  165 + *
  166 + * @param deviceIds 设备ID数组
  167 + * @return List<Device> 设备对象数组
  168 + */
  169 + @Override
76 170 public List<Device> queryVideoDeviceList(String[] deviceIds) {
77 171 List<Device> devices = new ArrayList<>();
  172 +
78 173 if (deviceIds == null || deviceIds.length == 0) {
79   - List<Object> deviceIdList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX+"*");
  174 + List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*");
80 175 for (int i = 0; i < deviceIdList.size(); i++) {
81 176 devices.add((Device)redis.get((String)deviceIdList.get(i)));
82 177 }
83 178 } else {
84 179 for (int i = 0; i < deviceIds.length; i++) {
85   - devices.add((Device)redis.get(VideoManagerConstants.CACHEKEY_PREFIX+deviceIds[i]));
  180 + devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]));
86 181 }
87 182 }
88 183 return devices;
... ... @@ -96,7 +191,7 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
96 191 */
97 192 @Override
98 193 public boolean delete(String deviceId) {
99   - return redis.del(VideoManagerConstants.CACHEKEY_PREFIX+deviceId);
  194 + return redis.del(VideoManagerConstants.DEVICE_PREFIX+deviceId);
100 195 }
101 196  
102 197 /**
... ... @@ -107,9 +202,9 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
107 202 */
108 203 @Override
109 204 public boolean online(String deviceId) {
110   - Device device = (Device)redis.get(VideoManagerConstants.CACHEKEY_PREFIX+deviceId);
  205 + Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId);
111 206 device.setOnline(1);
112   - return redis.set(VideoManagerConstants.CACHEKEY_PREFIX+device.getDeviceId(), device);
  207 + return redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
113 208 }
114 209  
115 210 /**
... ... @@ -120,9 +215,64 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
120 215 */
121 216 @Override
122 217 public boolean outline(String deviceId) {
123   - Device device = (Device)redis.get(VideoManagerConstants.CACHEKEY_PREFIX+deviceId);
  218 + Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId);
  219 + if (device == null) return false;
124 220 device.setOnline(0);
125   - return redis.set(VideoManagerConstants.CACHEKEY_PREFIX+device.getDeviceId(), device);
  221 + return redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
  222 + }
  223 +
  224 + /**
  225 + * 开始播放时将流存入redis
  226 + *
  227 + * @param deviceId 设备ID
  228 + * @param channelId 通道ID
  229 + * @return
  230 + */
  231 + @Override
  232 + public boolean startPlay(String deviceId, String channelId, StreamInfo stream) {
  233 + return redis.set(String.format("%S_%s_%s", VideoManagerConstants.PLAYER_PREFIX, deviceId, channelId),
  234 + stream);
  235 + }
  236 +
  237 + /**
  238 + * 停止播放时从redis删除
  239 + *
  240 + * @param deviceId 设备ID
  241 + * @param channelId 通道ID
  242 + * @return
  243 + */
  244 + @Override
  245 + public boolean stopPlay(String deviceId, String channelId) {
  246 + return redis.del(String.format("%S_%s_%s", VideoManagerConstants.PLAYER_PREFIX, deviceId, channelId));
  247 + }
  248 +
  249 + /**
  250 + * 查询播放列表
  251 + * @param deviceId 设备ID
  252 + * @param channelId 通道ID
  253 + * @return
  254 + */
  255 + @Override
  256 + public StreamInfo queryPlay(String deviceId, String channelId) {
  257 + return (StreamInfo)redis.get(String.format("%S_%s_%s", VideoManagerConstants.PLAYER_PREFIX, deviceId, channelId));
  258 + }
  259 +
  260 + /**
  261 + * 更新流媒体信息
  262 + * @param mediaServerConfig
  263 + * @return
  264 + */
  265 + @Override
  266 + public boolean updateMediaInfo(MediaServerConfig mediaServerConfig) {
  267 + return redis.set(VideoManagerConstants.MEDIA_SERVER_PREFIX,mediaServerConfig);
  268 + }
  269 +
  270 + /**
  271 + * 获取流媒体信息
  272 + * @return
  273 + */
  274 + @Override
  275 + public MediaServerConfig getMediaInfo() {
  276 + return (MediaServerConfig)redis.get(VideoManagerConstants.MEDIA_SERVER_PREFIX);
126 277 }
127   -
128 278 }
... ...
src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java
... ... @@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
8 8  
9 9 import org.springframework.beans.factory.annotation.Autowired;
10 10 import org.springframework.data.redis.core.RedisTemplate;
  11 +import org.springframework.data.redis.core.ZSetOperations;
11 12 import org.springframework.stereotype.Component;
12 13 import org.springframework.util.CollectionUtils;
13 14  
... ... @@ -389,6 +390,121 @@ public class RedisUtil {
389 390 return 0;
390 391 }
391 392 }
  393 +// ============================== ZSet ==============================
  394 +
  395 + /**
  396 + * 添加一个元素, zset与set最大的区别就是每个元素都有一个score,因此有个排序的辅助功能; zadd
  397 + *
  398 + * @param key
  399 + * @param value
  400 + * @param score
  401 + */
  402 + public void zAdd(String key, String value, double score) {
  403 + redisTemplate.opsForZSet().add(key, value, score);
  404 + }
  405 +
  406 + /**
  407 + * 删除元素 zrem
  408 + *
  409 + * @param key
  410 + * @param value
  411 + */
  412 + public void zRemove(String key, String value) {
  413 + redisTemplate.opsForZSet().remove(key, value);
  414 + }
  415 +
  416 + /**
  417 + * score的增加or减少 zincrby
  418 + *
  419 + * @param key
  420 + * @param value
  421 + * @param score
  422 + */
  423 + public Double zIncrScore(String key, String value, double score) {
  424 + return redisTemplate.opsForZSet().incrementScore(key, value, score);
  425 + }
  426 +
  427 + /**
  428 + * 查询value对应的score zscore
  429 + *
  430 + * @param key
  431 + * @param value
  432 + * @return
  433 + */
  434 + public Double zScore(String key, String value) {
  435 + return redisTemplate.opsForZSet().score(key, value);
  436 + }
  437 +
  438 + /**
  439 + * 判断value在zset中的排名 zrank
  440 + *
  441 + * @param key
  442 + * @param value
  443 + * @return
  444 + */
  445 + public Long zRank(String key, String value) {
  446 + return redisTemplate.opsForZSet().rank(key, value);
  447 + }
  448 +
  449 + /**
  450 + * 返回集合的长度
  451 + *
  452 + * @param key
  453 + * @return
  454 + */
  455 + public Long zSize(String key) {
  456 + return redisTemplate.opsForZSet().zCard(key);
  457 + }
  458 +
  459 + /**
  460 + * 查询集合中指定顺序的值, 0 -1 表示获取全部的集合内容 zrange
  461 + *
  462 + * 返回有序的集合,score小的在前面
  463 + *
  464 + * @param key
  465 + * @param start
  466 + * @param end
  467 + * @return
  468 + */
  469 + public Set<String> ZRange(String key, int start, int end) {
  470 + return redisTemplate.opsForZSet().range(key, start, end);
  471 + }
  472 + /**
  473 + * 查询集合中指定顺序的值和score,0, -1 表示获取全部的集合内容
  474 + *
  475 + * @param key
  476 + * @param start
  477 + * @param end
  478 + * @return
  479 + */
  480 + public Set<ZSetOperations.TypedTuple<String>> zRangeWithScore(String key, int start, int end) {
  481 + return redisTemplate.opsForZSet().rangeWithScores(key, start, end);
  482 + }
  483 + /**
  484 + * 查询集合中指定顺序的值 zrevrange
  485 + *
  486 + * 返回有序的集合中,score大的在前面
  487 + *
  488 + * @param key
  489 + * @param start
  490 + * @param end
  491 + * @return
  492 + */
  493 + public Set<String> zRevRange(String key, int start, int end) {
  494 + return redisTemplate.opsForZSet().reverseRange(key, start, end);
  495 + }
  496 + /**
  497 + * 根据score的值,来获取满足条件的集合 zrangebyscore
  498 + *
  499 + * @param key
  500 + * @param min
  501 + * @param max
  502 + * @return
  503 + */
  504 + public Set<String> zSortRange(String key, int min, int max) {
  505 + return redisTemplate.opsForZSet().rangeByScore(key, min, max);
  506 + }
  507 +
392 508  
393 509 // ============================== List ==============================
394 510  
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java
... ... @@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.vmanager.device;
2 2  
3 3 import java.util.List;
4 4  
  5 +import com.genersoft.iot.vmp.common.PageResult;
  6 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
5 7 import org.slf4j.Logger;
6 8 import org.slf4j.LoggerFactory;
7 9 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -53,14 +55,30 @@ public class DeviceController {
53 55 }
54 56  
55 57 @GetMapping("/devices")
56   - public ResponseEntity<List<Device>> devices(){
  58 + public PageResult<Device> devices(int page, int count){
57 59  
58 60 if (logger.isDebugEnabled()) {
59 61 logger.debug("查询所有视频设备API调用");
60 62 }
61 63  
62   - List<Device> deviceList = storager.queryVideoDeviceList(null);
63   - return new ResponseEntity<>(deviceList,HttpStatus.OK);
  64 + return storager.queryVideoDeviceList(null, page, count);
  65 + }
  66 +
  67 + /**
  68 + * 分页查询通道数
  69 + * @param deviceId 设备id
  70 + * @param page 当前页
  71 + * @param count 每页条数
  72 + * @return 通道列表
  73 + */
  74 + @GetMapping("devices/{deviceId}/channels")
  75 + public ResponseEntity<PageResult> channels(@PathVariable String deviceId, int page, int count){
  76 +
  77 + if (logger.isDebugEnabled()) {
  78 + logger.debug("查询所有视频设备API调用");
  79 + }
  80 + PageResult pageResult = storager.queryChannelsByDeviceId(deviceId, page, count);
  81 + return new ResponseEntity<>(pageResult,HttpStatus.OK);
64 82 }
65 83  
66 84 @PostMapping("/devices/{deviceId}/sync")
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
1 1 package com.genersoft.iot.vmp.vmanager.play;
2 2  
  3 +import com.genersoft.iot.vmp.common.StreamInfo;
3 4 import org.slf4j.Logger;
4 5 import org.slf4j.LoggerFactory;
5 6 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -34,16 +35,16 @@ public class PlayController {
34 35 public ResponseEntity<String> play(@PathVariable String deviceId,@PathVariable String channelId){
35 36  
36 37 Device device = storager.queryVideoDevice(deviceId);
37   - String ssrc = cmder.playStreamCmd(device, channelId);
  38 + StreamInfo streamInfo = cmder.playStreamCmd(device, channelId);
38 39  
39 40 if (logger.isDebugEnabled()) {
40 41 logger.debug(String.format("设备预览 API调用,deviceId:%s ,channelId:%s",deviceId, channelId));
41   - logger.debug("设备预览 API调用,ssrc:"+ssrc+",ZLMedia streamId:"+Integer.toHexString(Integer.parseInt(ssrc)));
  42 + logger.debug("设备预览 API调用,ssrc:"+streamInfo.getSsrc()+",ZLMedia streamId:"+Integer.toHexString(Integer.parseInt(streamInfo.getSsrc())));
42 43 }
43 44  
44   - if(ssrc!=null) {
  45 + if(streamInfo!=null) {
45 46 JSONObject json = new JSONObject();
46   - json.put("ssrc", ssrc);
  47 + json.put("ssrc", streamInfo.getSsrc());
47 48 return new ResponseEntity<String>(json.toString(),HttpStatus.OK);
48 49 } else {
49 50 logger.warn("设备预览API调用失败!");
... ...
src/main/java/com/genersoft/iot/vmp/web/AuthController.java 0 → 100644
  1 +package com.genersoft.iot.vmp.web;
  2 +
  3 +import com.genersoft.iot.vmp.gb28181.bean.Device;
  4 +import org.springframework.beans.factory.annotation.Value;
  5 +import org.springframework.http.ResponseEntity;
  6 +import org.springframework.stereotype.Controller;
  7 +import org.springframework.util.StringUtils;
  8 +import org.springframework.web.bind.annotation.*;
  9 +
  10 +@CrossOrigin
  11 +@RestController
  12 +@RequestMapping(value = "/auth")
  13 +public class AuthController {
  14 +
  15 + @Value("${auth.username}")
  16 + private String username;
  17 +
  18 + @Value("${auth.password}")
  19 + private String password;
  20 +
  21 + @RequestMapping("/login")
  22 + public Object devices(String username, String password){
  23 + if (!StringUtils.isEmpty(username) && username.equals(username)
  24 + && !StringUtils.isEmpty(password) && password.equals(password)) {
  25 + return "success";
  26 + }else {
  27 + return "fait";
  28 + }
  29 + }
  30 +}
... ...
src/main/resources/application.yml
... ... @@ -7,27 +7,26 @@ spring:
7 7 communicate: http
8 8 redis:
9 9 # Redis服务器IP
10   - #host: 10.24.20.63
11   - host: 127.0.0.1
  10 + host: 192.168.1.141
12 11 #端口号
13 12 port: 6379
14   - datebase: 0
  13 + database: 6
15 14 #访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接
16   - password:
  15 + password: 4767cb971b40a1300fa09b7f87b09d1c
17 16 #超时时间
18 17 timeout: 10000
19 18 datasource:
20 19 name: eiot
21   - url: jdbc:mysql://10.24.20.63:3306/eiot?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true
  20 + url: jdbc:mysql://192.168.1.141:3306/eiot?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true
22 21 username: root
23   - password: 123456
  22 + password: root
24 23 type: com.alibaba.druid.pool.DruidDataSource
25 24 driver-class-name: com.mysql.jdbc.Driver
26 25 server:
27   - port: 8080
  26 + port: 18080
28 27 sip:
29 28 # ip: 10.200.64.63
30   - ip: 192.168.0.102
  29 + ip: 192.168.1.20
31 30 port: 5060
32 31 # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007)
33 32 # 后两位为行业编码,定义参照附录D.3
... ... @@ -35,8 +34,19 @@ sip:
35 34 domain: 3701020049
36 35 id: 37010200492000000001
37 36 # 默认设备认证密码,后续扩展使用设备单独密码
38   - password: admin123
  37 + password: 12345678
39 38 media:
40 39 # ip: 10.200.64.88
41   - ip: 192.168.0.102
42   - port: 10000
43 40 \ No newline at end of file
  41 + ip: 192.168.1.20
  42 + port: 10000
  43 +
  44 +# 自定义代理相关配置
  45 +# 代理的本地路由
  46 +proxy:
  47 + servlet_url: /media/*
  48 + # 要代理的地址
  49 + target_url: http://127.0.0.1:10080
  50 +
  51 +auth: #32位小写md5加密(默认密码为admin)
  52 + username: admin
  53 + password: 21232f297a57a5a743894a0e4a801fc3
44 54 \ No newline at end of file
... ...