Commit f82dd1bdf831288c769f54796e5cf8130edb993b

Authored by liujun001
1 parent fd94cb80

优化

src/main/java/com/genersoft/iot/vmp/conf/StreamProxyTask.java
@@ -26,7 +26,7 @@ public class StreamProxyTask { @@ -26,7 +26,7 @@ public class StreamProxyTask {
26 @Autowired 26 @Autowired
27 private IStreamProxyService streamProxyService; 27 private IStreamProxyService streamProxyService;
28 28
29 - @Scheduled(cron = "0 15 * * * ? ") 29 + @Scheduled(cron = "0 45 * * * ? ")
30 public void work() { 30 public void work() {
31 streamProxyService.choose1078Lister(); 31 streamProxyService.choose1078Lister();
32 32
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
@@ -423,6 +423,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -423,6 +423,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
423 updateStreamProxy(streamProxy); 423 updateStreamProxy(streamProxy);
424 } else if (jsonObject.getInteger("code") == -1) { 424 } else if (jsonObject.getInteger("code") == -1) {
425 redisTemplate.opsForValue().set("stream:status:" + stream, "1", 30, TimeUnit.SECONDS); 425 redisTemplate.opsForValue().set("stream:status:" + stream, "1", 30, TimeUnit.SECONDS);
  426 + if(StringUtils.equals(jsonObject.getString("msg"),"This stream already exists" )){
  427 + redisTemplate.opsForValue().set("stream:status:" + stream, "2", 30, TimeUnit.SECONDS);
  428 + }
426 } else { 429 } else {
427 logger.info("启用代理失败: {}/{}->{}({})", app, stream, jsonObject.getString("msg"), 430 logger.info("启用代理失败: {}/{}->{}({})", app, stream, jsonObject.getString("msg"),
428 streamProxy.getSrcUrl() == null ? streamProxy.getUrl() : streamProxy.getSrcUrl()); 431 streamProxy.getSrcUrl() == null ? streamProxy.getUrl() : streamProxy.getSrcUrl());
src/main/java/com/genersoft/iot/vmp/service/impl/StremProxyService1078Impl.java
@@ -58,14 +58,13 @@ public class StremProxyService1078Impl implements StremProxyService1078 { @@ -58,14 +58,13 @@ public class StremProxyService1078Impl implements StremProxyService1078 {
58 58
59 String url = null; 59 String url = null;
60 try { 60 try {
61 - url = StringUtils.replace(this.jt1078ConfigBean.getJt1078Url(), "{0}", this.jt1078ConfigBean.getJt1078SendPort()); 61 + url = StringUtils.replace(this.jt1078ConfigBean.getJt1078Url(), "{0}", this.jt1078ConfigBean.getStopSendPort());
62 HttpClientPostEntity entity = httpClientUtil.doPost(url, msg, null); 62 HttpClientPostEntity entity = httpClientUtil.doPost(url, msg, null);
63 63
64 url = jt1078ConfigBean.formatStopPushURL(stream, port, httpPort); 64 url = jt1078ConfigBean.formatStopPushURL(stream, port, httpPort);
65 httpClientUtil.doGet(url, null); 65 httpClientUtil.doGet(url, null);
66 66
67 67
68 -  
69 if (Objects.isNull(entity)) { 68 if (Objects.isNull(entity)) {
70 log.info("HttpClientPostEntity is null"); 69 log.info("HttpClientPostEntity is null");
71 } else { 70 } else {
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/Jt1078OfCarController.java
@@ -12,8 +12,10 @@ import com.alibaba.fastjson2.JSONObject; @@ -12,8 +12,10 @@ import com.alibaba.fastjson2.JSONObject;
12 import com.genersoft.iot.vmp.conf.MediaConfig; 12 import com.genersoft.iot.vmp.conf.MediaConfig;
13 import com.genersoft.iot.vmp.conf.StreamProxyTask; 13 import com.genersoft.iot.vmp.conf.StreamProxyTask;
14 import com.genersoft.iot.vmp.conf.exception.ControllerException; 14 import com.genersoft.iot.vmp.conf.exception.ControllerException;
  15 +import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
15 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; 16 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
16 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; 17 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
  18 +import com.genersoft.iot.vmp.service.IStreamProxyService;
17 import com.genersoft.iot.vmp.service.IStreamPushService; 19 import com.genersoft.iot.vmp.service.IStreamPushService;
18 import com.genersoft.iot.vmp.service.StremProxyService1078; 20 import com.genersoft.iot.vmp.service.StremProxyService1078;
19 import com.genersoft.iot.vmp.vmanager.bean.StreamContent; 21 import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
@@ -91,6 +93,8 @@ public class Jt1078OfCarController { @@ -91,6 +93,8 @@ public class Jt1078OfCarController {
91 private StremProxyService1078 stremProxyService1078; 93 private StremProxyService1078 stremProxyService1078;
92 private static final long TIME_COUNT = 300000L; 94 private static final long TIME_COUNT = 300000L;
93 private Date tokenDate; 95 private Date tokenDate;
  96 + @Autowired
  97 + private IStreamProxyService streamProxyService;
94 98
95 @Value("${spring.profiles.active}") 99 @Value("${spring.profiles.active}")
96 private String profilesActive; 100 private String profilesActive;
@@ -198,30 +202,27 @@ public class Jt1078OfCarController { @@ -198,30 +202,27 @@ public class Jt1078OfCarController {
198 this.redisTemplate.opsForValue().set("tag:history:httpPort:" + stream, entity.getHttpPort(), 2L, TimeUnit.DAYS); 202 this.redisTemplate.opsForValue().set("tag:history:httpPort:" + stream, entity.getHttpPort(), 2L, TimeUnit.DAYS);
199 this.redisTemplate.opsForValue().set("tag:history:httpPort:time:" + stream, (new Date()).getTime(), StreamProxyTask.TIME_OUT, TimeUnit.SECONDS); 203 this.redisTemplate.opsForValue().set("tag:history:httpPort:time:" + stream, (new Date()).getTime(), StreamProxyTask.TIME_OUT, TimeUnit.SECONDS);
200 msg = this.jt1078ConfigBean.formatMessageId(sim, channel, this.rtspConfigBean, entity.getPort()); 204 msg = this.jt1078ConfigBean.formatMessageId(sim, channel, this.rtspConfigBean, entity.getPort());
201 - entity = this.httpClientUtil.doPost(url, msg, (String) null); 205 + HttpClientPostEntity entity1 = this.httpClientUtil.doPost(url, msg, (String) null);
202 Map<String, Object> resultMap1 = this.chooseEntity(entity, url, false); 206 Map<String, Object> resultMap1 = this.chooseEntity(entity, url, false);
203 if (Objects.nonNull(resultMap1)) { 207 if (Objects.nonNull(resultMap1)) {
204 return resultMap1; 208 return resultMap1;
205 } 209 }
206 210
207 - log.info(entity.getResultStr());  
208 - Thread.sleep(2000L);  
209 - this.createStreamProxy(sim + "-" + channel);  
210 - Map<String, Object> resultMap2 = this.getStreamContent(stream); 211 + log.info(entity1.getResultStr());
  212 + this.createStreamProxy(sim + "-" + channel, entity.getHttpPort());
  213 + Map<String, Object> resultMap2 = this.getStreamContent(stream, entity.getHttpPort());
211 if (Objects.nonNull(resultMap2) && Objects.nonNull(resultMap2.get("code")) && !StringUtils.equals(resultMap2.get("code").toString(), "1")) { 214 if (Objects.nonNull(resultMap2) && Objects.nonNull(resultMap2.get("code")) && !StringUtils.equals(resultMap2.get("code").toString(), "1")) {
212 return resultMap2; 215 return resultMap2;
213 } 216 }
214 217
215 streamContent = (StreamContent) resultMap2.get("streamContent"); 218 streamContent = (StreamContent) resultMap2.get("streamContent");
216 - }else{  
217 - resultMap.put("port", redisTemplate.opsForValue().get("tag:history:port:"+stream));  
218 - resultMap.put("httpPort", redisTemplate.opsForValue().get("tag:history:httpPort:"+stream)); 219 + } else {
  220 + resultMap.put("port", redisTemplate.opsForValue().get("tag:history:port:" + stream));
  221 + resultMap.put("httpPort", redisTemplate.opsForValue().get("tag:history:httpPort:" + stream));
219 resultMap.put("stream", stream); 222 resultMap.put("stream", stream);
220 } 223 }
221 224
222 225
223 -  
224 -  
225 resultMap.put("code", "1"); 226 resultMap.put("code", "1");
226 resultMap.put("message", "OK"); 227 resultMap.put("message", "OK");
227 resultMap.put("data", streamContent); 228 resultMap.put("data", streamContent);
@@ -253,7 +254,7 @@ public class Jt1078OfCarController { @@ -253,7 +254,7 @@ public class Jt1078OfCarController {
253 return resultMap1; 254 return resultMap1;
254 } else { 255 } else {
255 try { 256 try {
256 - this.streamProxyController.del(stream, stream); 257 + this.streamProxyController.del("schedule", stream);
257 List<StreamPushItem> streamPushItems = this.streamPushService.getPushList(stream); 258 List<StreamPushItem> streamPushItems = this.streamPushService.getPushList(stream);
258 int count = CollectionUtils.size(streamPushItems); 259 int count = CollectionUtils.size(streamPushItems);
259 260
@@ -261,6 +262,60 @@ public class Jt1078OfCarController { @@ -261,6 +262,60 @@ public class Jt1078OfCarController {
261 StreamPushItem item = streamPushItems.get(i); 262 StreamPushItem item = streamPushItems.get(i);
262 263
263 try { 264 try {
  265 + this.streamProxyController.del(item.getApp(), item.getStream());
  266 + this.streamPushService.stop(item.getApp(), item.getStream());
  267 + } catch (Exception var13) {
  268 + Exception e = var13;
  269 + log.error("推流停止失败,[{}]", item, e);
  270 + }
  271 + }
  272 +
  273 + resultMap.put("code", "1");
  274 + resultMap.put("message", "OK");
  275 + return resultMap;
  276 + } catch (Exception var14) {
  277 + resultMap.put("code", "-20");
  278 + resultMap.put("msg", "发送停止推流指令异常");
  279 + return resultMap;
  280 + }
  281 + }
  282 + }
  283 + }
  284 +
  285 + @GetMapping({"/send/stop/io/{sim}/{channel}"})
  286 + public Map<String, Object> sendIORequestStop(@PathVariable String sim, @PathVariable String channel) {
  287 + Map<String, Object> resultMap = new HashMap();
  288 + if (StringUtils.isBlank(sim)) {
  289 + resultMap.put("code", "-100");
  290 + resultMap.put("msg", "sim 不能为空");
  291 + return resultMap;
  292 + } else if (StringUtils.isBlank(channel)) {
  293 + resultMap.put("code", "-100");
  294 + resultMap.put("msg", "channel 不能为空");
  295 + return resultMap;
  296 + } else {
  297 + String stream = StringUtils.join(new String[]{sim, "-", channel});
  298 + Integer port = (Integer) redisTemplate.opsForValue().get("tag:history:port:" + stream);
  299 + Integer httpPort = (Integer) redisTemplate.opsForValue().get("tag:history:httpPort:" + stream);
  300 + if (Objects.isNull(port) || Objects.isNull(httpPort)) {
  301 + resultMap.put("code", "1");
  302 + resultMap.put("message", "OK");
  303 + return resultMap;
  304 + }
  305 + Map<String, Object> resultMap1 = this.stremProxyService1078.sendIORequestStop(sim, channel, stream, port, httpPort);
  306 + if (Objects.nonNull(resultMap1) && Objects.nonNull(resultMap1.get("code")) && !StringUtils.equals(resultMap1.get("code").toString(), "1")) {
  307 + return resultMap1;
  308 + } else {
  309 + try {
  310 + this.streamProxyController.del("schedule", stream);
  311 + List<StreamPushItem> streamPushItems = this.streamPushService.getPushList(stream);
  312 + int count = CollectionUtils.size(streamPushItems);
  313 +
  314 + for (int i = 0; i < count; ++i) {
  315 + StreamPushItem item = streamPushItems.get(i);
  316 +
  317 + try {
  318 + this.streamProxyController.del(item.getApp(), item.getStream());
264 this.streamPushService.stop(item.getApp(), item.getStream()); 319 this.streamPushService.stop(item.getApp(), item.getStream());
265 } catch (Exception var13) { 320 } catch (Exception var13) {
266 Exception e = var13; 321 Exception e = var13;
@@ -324,12 +379,12 @@ public class Jt1078OfCarController { @@ -324,12 +379,12 @@ public class Jt1078OfCarController {
324 for (Object o : jsonArray) { 379 for (Object o : jsonArray) {
325 JSONObject jo = (JSONObject) o; 380 JSONObject jo = (JSONObject) o;
326 String startTimeStr = jo.getString("startTime"); 381 String startTimeStr = jo.getString("startTime");
327 - if(StringUtils.isEmpty(startTimeStr)){ 382 + if (StringUtils.isEmpty(startTimeStr)) {
328 startTimeStr = StringUtils.join(String.valueOf(System.currentTimeMillis()), "-", String.valueOf(RandomUtils.nextInt(1, 1000))); 383 startTimeStr = StringUtils.join(String.valueOf(System.currentTimeMillis()), "-", String.valueOf(RandomUtils.nextInt(1, 1000)));
329 - }else{  
330 - startTimeStr = StringUtils.replace(startTimeStr,"-","");  
331 - startTimeStr = StringUtils.replace(startTimeStr,":","");  
332 - startTimeStr = StringUtils.replace(startTimeStr," ",""); 384 + } else {
  385 + startTimeStr = StringUtils.replace(startTimeStr, "-", "");
  386 + startTimeStr = StringUtils.replace(startTimeStr, ":", "");
  387 + startTimeStr = StringUtils.replace(startTimeStr, " ", "");
333 } 388 }
334 String channelMapping = StringUtils.join(new String[]{sim, "-", startTimeStr, "-", channel}); 389 String channelMapping = StringUtils.join(new String[]{sim, "-", startTimeStr, "-", channel});
335 jo.put("channelMapping", channelMapping); 390 jo.put("channelMapping", channelMapping);
@@ -379,13 +434,13 @@ public class Jt1078OfCarController { @@ -379,13 +434,13 @@ public class Jt1078OfCarController {
379 return resultMap; 434 return resultMap;
380 } else { 435 } else {
381 StreamContent streamContent = this.getStreamContentPlayURL(StringUtils.join(new String[]{channelMapping})); 436 StreamContent streamContent = this.getStreamContentPlayURL(StringUtils.join(new String[]{channelMapping}));
382 - if(Objects.nonNull(streamContent) && StringUtils.isNotEmpty(streamContent.getWs_flv())){ 437 + if (Objects.nonNull(streamContent) && StringUtils.isNotEmpty(streamContent.getWs_flv())) {
383 resultMap.put("code", "1"); 438 resultMap.put("code", "1");
384 log.info("StreamContent:[{}]", streamContent); 439 log.info("StreamContent:[{}]", streamContent);
385 resultMap.put("data", streamContent); 440 resultMap.put("data", streamContent);
386 441
387 - resultMap.put("port", redisTemplate.opsForValue().get("tag:history:port:"+channelMapping));  
388 - resultMap.put("httpPort", redisTemplate.opsForValue().get("tag:history:httpPort:"+channelMapping)); 442 + resultMap.put("port", redisTemplate.opsForValue().get("tag:history:port:" + channelMapping));
  443 + resultMap.put("httpPort", redisTemplate.opsForValue().get("tag:history:httpPort:" + channelMapping));
389 resultMap.put("stream", channelMapping); 444 resultMap.put("stream", channelMapping);
390 return resultMap; 445 return resultMap;
391 } 446 }
@@ -415,21 +470,20 @@ public class Jt1078OfCarController { @@ -415,21 +470,20 @@ public class Jt1078OfCarController {
415 msg = this.jt1078ConfigBean.formatMessageHistoryPlayRTSP(sim, channel, startTime, endTime, this.rtspConfigBean, entity.getPort()); 470 msg = this.jt1078ConfigBean.formatMessageHistoryPlayRTSP(sim, channel, startTime, endTime, this.rtspConfigBean, entity.getPort());
416 471
417 log.info("获取推流"); 472 log.info("获取推流");
418 - this.createStreamProxy(sim + "-" + channel); 473 + this.createStreamProxy(sim + "-" + channel, entity.getHttpPort());
419 entity = this.httpClientUtil.doPost(url, msg, (String) null); 474 entity = this.httpClientUtil.doPost(url, msg, (String) null);
420 Map<String, Object> resultMap2 = this.chooseEntity(entity, url, true); 475 Map<String, Object> resultMap2 = this.chooseEntity(entity, url, true);
421 if (Objects.nonNull(resultMap2)) { 476 if (Objects.nonNull(resultMap2)) {
422 return resultMap2; 477 return resultMap2;
423 } else { 478 } else {
424 log.info(entity.getResultStr()); 479 log.info(entity.getResultStr());
425 - this.createStreamProxy(channelMapping); 480 + this.createStreamProxy(channelMapping, entity.getHttpPort());
426 resultMap.put("code", "1"); 481 resultMap.put("code", "1");
427 - Thread.sleep(2000L);  
428 - Map<String, Object> resultMap3 = this.getStreamContent(channelMapping); 482 + Map<String, Object> resultMap3 = this.getStreamContent(channelMapping, entity.getHttpPort());
429 if (Objects.nonNull(resultMap3) && Objects.nonNull(resultMap3.get("code")) && !StringUtils.equals(resultMap3.get("code").toString(), "1")) { 483 if (Objects.nonNull(resultMap3) && Objects.nonNull(resultMap3.get("code")) && !StringUtils.equals(resultMap3.get("code").toString(), "1")) {
430 return resultMap3; 484 return resultMap3;
431 } else { 485 } else {
432 - streamContent = (StreamContent) resultMap3.get("streamContent"); 486 + streamContent = (StreamContent) resultMap3.get("streamContent");
433 if (Objects.isNull(streamContent)) { 487 if (Objects.isNull(streamContent)) {
434 resultMap.put("code", "-20"); 488 resultMap.put("code", "-20");
435 resultMap.put("msg", "新建链接错误,请稍后再试"); 489 resultMap.put("msg", "新建链接错误,请稍后再试");
@@ -468,70 +522,85 @@ public class Jt1078OfCarController { @@ -468,70 +522,85 @@ public class Jt1078OfCarController {
468 } 522 }
469 523
470 @Nullable 524 @Nullable
471 - private Map<String, Object> getStreamContent(String stream) throws InterruptedException {  
472 - StreamContent streamContent = null; 525 + private Map<String, Object> getStreamContent(String stream, int httpPort) throws InterruptedException {
  526 +
473 Map<String, Object> datas = new HashMap(); 527 Map<String, Object> datas = new HashMap();
474 - int index = 0; 528 + StreamContent streamContent = requestStreamContent(1, stream, httpPort);
475 529
476 - Integer countTimeOut = 0; 530 + if (Objects.isNull(streamContent) || StringUtils.isEmpty(streamContent.getWs_flv())) {
  531 + streamContent = new StreamContent();
  532 + streamContent.setWs_flv(StringUtils.replace(this.jt1078ConfigBean.getWs(), "{stream}", stream));
  533 + streamContent.setWss_flv(StringUtils.replace(this.jt1078ConfigBean.getWss(), "{stream}", stream));
477 534
478 - do {  
479 - ++index;  
480 - streamContent = this.getStreamContentPlayURL(stream);  
481 - if (Objects.nonNull(streamContent) && StringUtils.isNotEmpty(streamContent.getWs_flv())) {  
482 - break;  
483 - }  
484 535
485 - Object valObj = redisTemplate.opsForValue().get("stream:status:" + stream);  
486 - if (Objects.nonNull(valObj) && StringUtils.equals(valObj.toString(), "1")) {  
487 - StreamProxyItem streamProxyItem = streamProxyController.one("schedule",stream);  
488 - if(Objects.nonNull(streamProxyItem) && StringUtils.isNotEmpty(streamProxyItem.getApp())){  
489 - try {  
490 - streamProxyController.start("schedule", stream);  
491 - } catch (Exception e) {  
492 - log.error(e.getMessage());  
493 - }  
494 - }else{  
495 - createStreamProxy(stream); 536 + new Thread(new Runnable() {
  537 + @Override
  538 + public void run() {
  539 + requestStreamContent(100, stream, httpPort);
496 } 540 }
  541 + }).start();
  542 + }
497 543
  544 + log.info("StreamContent:[{}]", streamContent);
  545 + datas.put("code", "1");
  546 + datas.put("streamContent", streamContent);
  547 + return datas;
  548 + }
498 549
499 - }else{  
500 - Object val = this.redisTemplate.opsForValue().get("timeout:" + stream);  
501 - if (Objects.nonNull(val) && StringUtils.equals(val.toString(), "1")) {  
502 -  
503 - countTimeOut++;  
504 - try {  
505 - streamProxyController.start("schedule", stream);  
506 - } catch (Exception e) {  
507 - log.error(e.getMessage());  
508 - } 550 + private StreamContent requestStreamContent(int count, String stream, int httpPort) {
  551 + int index = 0;
  552 + StreamContent streamContent = null;
  553 + try {
  554 + do {
  555 + ++index;
  556 + streamContent = this.getStreamContentPlayURL(stream);
  557 + if (Objects.nonNull(streamContent) && StringUtils.isNotEmpty(streamContent.getWs_flv())) {
  558 + break;
509 } 559 }
510 - }  
511 560
  561 + Object valObj = redisTemplate.opsForValue().get("stream:status:" + stream);
  562 + if (Objects.nonNull(valObj) && StringUtils.equals(valObj.toString(), "1")) {
  563 + StreamProxyItem streamProxyItem = streamProxyController.one("schedule", stream);
  564 + if (Objects.nonNull(streamProxyItem) && StringUtils.isNotEmpty(streamProxyItem.getApp())) {
  565 + try {
  566 + streamProxyController.start("schedule", stream);
  567 + } catch (Exception e) {
  568 + log.error(e.getMessage());
  569 + }
  570 + } else {
  571 + createStreamProxy(stream, httpPort);
  572 + }
512 573
513 574
514 - Thread.sleep(1000L);  
515 - log.info("===============>" + index);  
516 - } while (index < 20); 575 + } else if (Objects.nonNull(valObj) && StringUtils.equals(valObj.toString(), "2")) {
  576 +// streamProxyService.del("schedule", stream);
  577 +// redisTemplate.delete("stream:status:" + stream);
  578 +// createStreamProxy(stream,httpPort);
  579 + } else {
  580 + Object val = this.redisTemplate.opsForValue().get("timeout:" + stream);
  581 + if (Objects.nonNull(val) && StringUtils.equals(val.toString(), "1")) {
  582 + try {
  583 + streamProxyController.start("schedule", stream);
  584 + } catch (Exception e) {
  585 + log.error(e.getMessage());
  586 + }
  587 + }
  588 + }
  589 + if (index >= count) {
  590 + break;
  591 + }
517 592
518 - if (countTimeOut > 0) {  
519 - datas.put("code", "301");  
520 - datas.put("msg", "获取摄像头视频数据失败,请稍后再试");  
521 - return datas;  
522 - } 593 + try {
  594 + Thread.sleep(1000L);
  595 + } catch (InterruptedException e) {
  596 + log.info(e.getMessage());
  597 + }
  598 + } while (index < count);
523 599
524 - log.info("===============>" + index);  
525 - if (Objects.isNull(streamContent)) {  
526 - streamContent = new StreamContent();  
527 - streamContent.setWs_flv(StringUtils.replace(this.jt1078ConfigBean.getWs(), "{stream}", stream));  
528 - streamContent.setWss_flv(StringUtils.replace(this.jt1078ConfigBean.getWss(), "{stream}", stream)); 600 + } catch (Exception e) {
  601 + log.error(e.getMessage());
529 } 602 }
530 -  
531 - log.info("StreamContent:[{}]", streamContent);  
532 - datas.put("code", "1");  
533 - datas.put("streamContent", streamContent);  
534 - return datas; 603 + return streamContent;
535 } 604 }
536 605
537 private StreamContent getStreamContentPlayURL(String stream) { 606 private StreamContent getStreamContentPlayURL(String stream) {
@@ -632,8 +701,13 @@ public class Jt1078OfCarController { @@ -632,8 +701,13 @@ public class Jt1078OfCarController {
632 } 701 }
633 702
634 private HttpClientPostEntity createServerLister(String channelMapping) throws URISyntaxException, IOException { 703 private HttpClientPostEntity createServerLister(String channelMapping) throws URISyntaxException, IOException {
  704 +
635 Integer port = RandomUtils.nextInt(this.jt1078ConfigBean.getStart1078Port(), this.jt1078ConfigBean.getEnd1078Port()); 705 Integer port = RandomUtils.nextInt(this.jt1078ConfigBean.getStart1078Port(), this.jt1078ConfigBean.getEnd1078Port());
636 - Integer httPort = RandomUtils.nextInt(this.jt1078ConfigBean.getStart1078Port(), this.jt1078ConfigBean.getEnd1078Port()); 706 + while (port % 2 == 1 || port == jt1078ConfigBean.getStart1078Port()) {
  707 + port = RandomUtils.nextInt(this.jt1078ConfigBean.getStart1078Port(), this.jt1078ConfigBean.getEnd1078Port());
  708 + }
  709 + Integer httPort = 3333;
  710 +
637 String url; 711 String url;
638 if (!Objects.equals(port, httPort) && Objects.nonNull(port)) { 712 if (!Objects.equals(port, httPort) && Objects.nonNull(port)) {
639 url = "jt1078:server:port:" + port; 713 url = "jt1078:server:port:" + port;
@@ -710,23 +784,46 @@ public class Jt1078OfCarController { @@ -710,23 +784,46 @@ public class Jt1078OfCarController {
710 } 784 }
711 } 785 }
712 786
713 - private void createStreamProxy(String stream) {  
714 - String url = StringUtils.replace(this.jt1078ConfigBean.getGetURL(), "{stream}", stream);  
715 - StreamProxyItem item = new StreamProxyItem();  
716 - item.setApp("schedule");  
717 - item.setEnable(true);  
718 - item.setEnableAudio(true);  
719 - item.setRtpType("default");  
720 - item.setStream(stream);  
721 - item.setMediaServerId(this.mediaConfig.getId());  
722 - item.setUrl(url);  
723 - item.setFfmpegCmdKey("ffmpeg.cmd");  
724 - item.setEnable(true);  
725 - item.setEnableAudio(true);  
726 - item.setEnableMp4(false);  
727 - item.setEnableRemoveNoneReader(false);  
728 - item.setEnableDisableNoneReader(false);  
729 - item.setName(stream);  
730 - this.streamProxyController.save(item); 787 + private void createStreamProxy(String stream, Integer port) throws URISyntaxException, IOException {
  788 + new Thread(new Runnable() {
  789 + @Override
  790 + public void run() {
  791 + int index = 0;
  792 + while (index < 100) {
  793 + index++;
  794 + try {
  795 + boolean flag = httpClientUtil.doGetNoResult(jt1078ConfigBean.formatVideoURL(stream));
  796 + if (flag) {
  797 + String url = StringUtils.replace(jt1078ConfigBean.getGetURL(), "{stream}", stream);
  798 + url = StringUtils.replace(url, "{port}", port + "");
  799 + StreamProxyItem item = new StreamProxyItem();
  800 + item.setApp("schedule");
  801 + item.setEnable(true);
  802 + item.setEnableAudio(true);
  803 + item.setRtpType("default");
  804 + item.setStream(stream);
  805 + item.setMediaServerId(mediaConfig.getId());
  806 + item.setUrl(url);
  807 + item.setFfmpegCmdKey("ffmpeg.cmd");
  808 + item.setEnable(true);
  809 + item.setEnableAudio(true);
  810 + item.setEnableMp4(false);
  811 + item.setEnableRemoveNoneReader(false);
  812 + item.setEnableDisableNoneReader(false);
  813 + item.setName(stream);
  814 + streamProxyController.save(item);
  815 + break;
  816 + }
  817 + } catch (URISyntaxException e) {
  818 + log.info(e.getMessage());
  819 + } catch (IOException e) {
  820 + log.info(e.getMessage());
  821 + }
  822 +
  823 + }
  824 + }
  825 + }).start();
  826 +
  827 +
731 } 828 }
732 } 829 }
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/config/Jt1078ConfigBean.java
1 -package com.genersoft.iot.vmp.vmanager.jt1078.platform.config; import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.RtspConfigBean; import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class Jt1078ConfigBean { @Value("${tuohua.bsth.jt1078.url}") private String jt1078Url; @Value("${tuohua.bsth.jt1078.sendPort}") private String jt1078SendPort; @Value("${tuohua.bsth.jt1078.stopSendPort}") private String stopSendPort; @Value("${tuohua.bsth.jt1078.historyListPort}") private String historyListPort; @Value("${tuohua.bsth.jt1078.playHistoryPort}") private String playHistoryPort; @Value("${tuohua.bsth.jt1078.ports}") private String portsOf1078; @Value("${tuohua.bsth.jt1078.pushURL}") private String pushURL; @Value("${tuohua.bsth.jt1078.stopPushURL}") private String stopPUshURL; private Integer start1078Port; private Integer end1078Port; @Value("${tuohua.bsth.jt1078.get.url}") private String getURL; @Value("${tuohua.bsth.jt1078.addPortVal}") private Integer addPort; @Value("${tuohua.bsth.jt1078.ws}") private String ws; @Value("${tuohua.bsth.jt1078.wss}") private String wss; private static final String SEND_IO_MESSAGE_RTSP = "{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}"; private static final String SEND_IO_MESSAGE_RTSP_STOP = "{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}"; private static final String SEND_IO_HISTORY_RTSP = "{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"channelId\":{channelNo}}"; private static final String SEND_IO_PLAY_RTSP = "{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}"; public String formatMessageId(String sim, String channel, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}", "{clientId}", sim); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() + getAddPort().intValue()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getAddPort().intValue()) + ""); msg = StringUtils.replace(msg, "{channelNo}", channel); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageStop(String sim, String channel) { String msg = StringUtils.replace("{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}", "{clientId}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryListRTSP(String sim, String channel, String startTime, String endTime) { String msg = StringUtils.replace("{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"channelId\":{channelNo}}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryPlayRTSP(String sim, String channel, String startTime, String endTime, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); msg = StringUtils.replace(msg, "{channelNo}", channel); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() + getAddPort().intValue()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getAddPort().intValue()) + ""); msg = StringUtils.replace(msg, "{sim}", sim); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.pushURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatStopPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.stopPUshURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String getJt1078Url() { return this.jt1078Url; } public String getJt1078SendPort() { return this.jt1078SendPort; } public String getStopSendPort() { return this.stopSendPort; } public String getHistoryListPort() { return this.historyListPort; } public String getPlayHistoryPort() { return this.playHistoryPort; } public String getPushURL() { return this.pushURL; } public Integer getStart1078Port() { if (Objects.isNull(this.start1078Port)) this.start1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringBefore(this.portsOf1078, ","))); return this.start1078Port; } public Integer getEnd1078Port() { if (Objects.isNull(this.end1078Port)) this.end1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringAfter(this.portsOf1078, ","))); return this.end1078Port; } public String getStopPUshURL() { return this.stopPUshURL; } public String getGetURL() { return this.getURL; } public Integer getAddPort() { return this.addPort; } public String getWs() { return this.ws; } public String getWss() { return this.wss; } }  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +package com.genersoft.iot.vmp.vmanager.jt1078.platform.config; import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.RtspConfigBean; import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class Jt1078ConfigBean { @Value("${tuohua.bsth.jt1078.url}") private String jt1078Url; @Value("${tuohua.bsth.jt1078.sendPort}") private String jt1078SendPort; @Value("${tuohua.bsth.jt1078.stopSendPort}") private String stopSendPort; @Value("${tuohua.bsth.jt1078.historyListPort}") private String historyListPort; @Value("${tuohua.bsth.jt1078.playHistoryPort}") private String playHistoryPort; @Value("${tuohua.bsth.jt1078.ports}") private String portsOf1078; @Value("${tuohua.bsth.jt1078.pushURL}") private String pushURL; @Value("${tuohua.bsth.jt1078.stopPushURL}") private String stopPUshURL; private Integer start1078Port; private Integer end1078Port; @Value("${tuohua.bsth.jt1078.get.url}") private String getURL; @Value("${tuohua.bsth.jt1078.addPortVal}") private Integer addPort; @Value("${tuohua.bsth.jt1078.ws}") private String ws; @Value("${tuohua.bsth.jt1078.wss}") private String wss; @Value("${tuohua.bsth.jt1078.videoURL}") private String videoURL; private static final String SEND_IO_MESSAGE_RTSP = "{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}"; private static final String SEND_IO_MESSAGE_RTSP_STOP = "{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}"; private static final String SEND_IO_HISTORY_RTSP = "{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"channelId\":{channelNo}}"; private static final String SEND_IO_PLAY_RTSP = "{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}"; public String formatMessageId(String sim, String channel, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}", "{clientId}", sim); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() +getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() +getAddPort()) + ""); msg = StringUtils.replace(msg, "{channelNo}", channel); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageStop(String sim, String channel) { String msg = StringUtils.replace("{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}", "{clientId}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryListRTSP(String sim, String channel, String startTime, String endTime) { String msg = StringUtils.replace("{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"channelId\":{channelNo}}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryPlayRTSP(String sim, String channel, String startTime, String endTime, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); msg = StringUtils.replace(msg, "{channelNo}", channel); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() +getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() +getAddPort()) + ""); msg = StringUtils.replace(msg, "{sim}", sim); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.pushURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatStopPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.stopPUshURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatVideoURL(String stream){ return StringUtils.replace(videoURL,"{stream}",stream); } public String getJt1078Url() { return this.jt1078Url; } public String getJt1078SendPort() { return this.jt1078SendPort; } public String getStopSendPort() { return this.stopSendPort; } public String getHistoryListPort() { return this.historyListPort; } public String getPlayHistoryPort() { return this.playHistoryPort; } public String getPushURL() { return this.pushURL; } public Integer getStart1078Port() { if (Objects.isNull(this.start1078Port)) this.start1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringBefore(this.portsOf1078, ","))); return this.start1078Port; } public Integer getEnd1078Port() { if (Objects.isNull(this.end1078Port)) this.end1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringAfter(this.portsOf1078, ","))); return this.end1078Port; } public String getStopPUshURL() { return this.stopPUshURL; } public String getGetURL() { return this.getURL; } public Integer getAddPort() { return this.addPort; } public String getWs() { return this.ws; } public String getWss() { return this.wss; } public String getPortsOf1078() { return portsOf1078; } }
3 \ No newline at end of file 3 \ No newline at end of file
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/config/TuohuaConfigBean.java
@@ -256,7 +256,7 @@ public class TuohuaConfigBean { @@ -256,7 +256,7 @@ public class TuohuaConfigBean {
256 if (StringUtils.isEmpty(sim) || !optional.isPresent()) { 256 if (StringUtils.isEmpty(sim) || !optional.isPresent()) {
257 name = "<view style='color:red'>" + name + "</view>"; 257 name = "<view style='color:red'>" + name + "</view>";
258 abnormalStatus = 10; 258 abnormalStatus = 10;
259 - }else if(Objects.isNull(optional.get().get("timestamp")) || now- Convert.toLong(optional.get().get("timestamp"))<=120000){ 259 + }else if(Objects.isNull(optional.get().get("timestamp")) || now- Convert.toLong(optional.get().get("timestamp"))>120000){
260 name = "<view style='color:#ccc'>" + name + "</view>"; 260 name = "<view style='color:#ccc'>" + name + "</view>";
261 abnormalStatus =20; 261 abnormalStatus =20;
262 }else{ 262 }else{
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/handler/HttpClientUtil.java
@@ -162,6 +162,37 @@ public class HttpClientUtil { @@ -162,6 +162,37 @@ public class HttpClientUtil {
162 return null; 162 return null;
163 } 163 }
164 164
  165 + public boolean doGetNoResult(String url) throws URISyntaxException, IOException {
  166 + // 创建Httpclient对象
  167 + DefaultHttpClient httpclient = getHttpClient();
  168 + // 定义请求的参数
  169 +//
  170 +// httpclient.setCookieStore(cookieStore1);
  171 +
  172 + URIBuilder uriBuilder = new URIBuilder(url);
  173 + URI uri = uriBuilder.build();
  174 +
  175 + // 创建http GET请求
  176 + HttpGet httpGet = new HttpGet(uri);
  177 +
  178 + //response 对象
  179 + CloseableHttpResponse response = null;
  180 + try {
  181 + // 执行http get请求
  182 + response = httpclient.execute(httpGet);
  183 + // 判断返回状态是否为200
  184 + if (response.getStatusLine().getStatusCode() == 200) {
  185 + return true;
  186 + }
  187 + } finally {
  188 + if (response != null) {
  189 + response.close();
  190 + }
  191 + httpclient.close();
  192 + }
  193 + return false;
  194 + }
  195 +
165 196
166 @NotNull 197 @NotNull
167 private static HttpClientPostEntity combationReturnObj(CloseableHttpResponse response, DefaultHttpClient httpclient,String url,String requestBody) throws IOException { 198 private static HttpClientPostEntity combationReturnObj(CloseableHttpResponse response, DefaultHttpClient httpclient,String url,String requestBody) throws IOException {
src/main/resources/application-local.yml
@@ -13,11 +13,11 @@ spring: @@ -13,11 +13,11 @@ spring:
13 # REDIS数据库配置 13 # REDIS数据库配置
14 redis: 14 redis:
15 # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1 15 # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1
16 - host: 192.168.168.124 16 + host: 192.168.169.124
17 # [必须修改] 端口号 17 # [必须修改] 端口号
18 port: 6379 18 port: 6379
19 # [可选] 数据库 DB 19 # [可选] 数据库 DB
20 - database: 10 20 + database: 8
21 # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 21 # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接
22 # password: guzijian 22 # password: guzijian
23 # [可选] 超时时间 23 # [可选] 超时时间
@@ -152,7 +152,7 @@ tuohua: @@ -152,7 +152,7 @@ tuohua:
152 historyUdpPort: 9999 152 historyUdpPort: 9999
153 ip : 61.169.120.202 153 ip : 61.169.120.202
154 jt1078: 154 jt1078:
155 - ports: 9100,9600 155 + ports: 9000,9500
156 addPortVal: 30000 156 addPortVal: 30000
157 pushURL: http://192.169.1.92:3333/new/server/{pushKey}/{port}/{httpPort} 157 pushURL: http://192.169.1.92:3333/new/server/{pushKey}/{port}/{httpPort}
158 stopPushURL: http://192.169.1.92:3333/stop/channel/{pushKey}/{port}/{httpPort} 158 stopPushURL: http://192.169.1.92:3333/stop/channel/{pushKey}/{port}/{httpPort}
@@ -164,6 +164,7 @@ tuohua: @@ -164,6 +164,7 @@ tuohua:
164 ws: ws://192.168.169.100:1091/schedule/{stream}.live.flv 164 ws: ws://192.168.169.100:1091/schedule/{stream}.live.flv
165 wss: wss://192.168.169.100:443/schedule/{stream}.live.flv 165 wss: wss://192.168.169.100:443/schedule/{stream}.live.flv
166 get: 166 get:
  167 + #url: http://192.169.1.92:{port}/video/{stream}.flv
167 url: http://192.169.1.92:3333/video/{stream}.flv 168 url: http://192.169.1.92:3333/video/{stream}.flv
168 playURL: /play/wasm/ws%3A%2F%2F{ip}%3A{port}%2Fschedule%2F{sim}-{channel}.live.flv%3FcallId%{publickey} 169 playURL: /play/wasm/ws%3A%2F%2F{ip}%3A{port}%2Fschedule%2F{sim}-{channel}.live.flv%3FcallId%{publickey}
169 170
src/main/resources/application-localDev.yml
1 Binary files a/src/main/resources/application-localDev.yml and b/src/main/resources/application-localDev.yml differ 1 Binary files a/src/main/resources/application-localDev.yml and b/src/main/resources/application-localDev.yml differ
web_src/config/index.js
@@ -11,7 +11,7 @@ module.exports = { @@ -11,7 +11,7 @@ module.exports = {
11 assetsPublicPath: "/", 11 assetsPublicPath: "/",
12 proxyTable: { 12 proxyTable: {
13 "/debug": { 13 "/debug": {
14 - target: "http://118.113.164.50:18989", 14 + target: "http://127.0.0.1:28080",
15 changeOrigin: true, 15 changeOrigin: true,
16 pathRewrite: { 16 pathRewrite: {
17 "^/debug": "/", 17 "^/debug": "/",
web_src/src/components/DeviceList1078.vue
@@ -24,6 +24,8 @@ @@ -24,6 +24,8 @@
24 24
25 <button style="margin-left: 15px;" @click="openViewDIalog()">历史数据</button> 25 <button style="margin-left: 15px;" @click="openViewDIalog()">历史数据</button>
26 <button style="margin-left: 15px;" @click="OneClickPlayback()">一键播放车辆视频</button> 26 <button style="margin-left: 15px;" @click="OneClickPlayback()">一键播放车辆视频</button>
  27 + <button style="margin-left: 15px;" @click="closeSelectItem()">关闭选中画面流</button>
  28 + <button style="margin-left: 15px;" @click="closeSelectCarItem()">一键关闭选中车辆流</button>
27 </el-header> 29 </el-header>
28 30
29 31
@@ -248,7 +250,6 @@ export default { @@ -248,7 +250,6 @@ export default {
248 console.log("通知设备推流1:" + deviceId + " : " + channelId); 250 console.log("通知设备推流1:" + deviceId + " : " + channelId);
249 let idxTmp = this.playerIdx 251 let idxTmp = this.playerIdx
250 let that = this; 252 let that = this;
251 - this.loading = true  
252 253
253 this.$axios({ 254 this.$axios({
254 method: 'get', 255 method: 'get',
@@ -402,9 +403,6 @@ export default { @@ -402,9 +403,6 @@ export default {
402 sim = ""; 403 sim = "";
403 } 404 }
404 405
405 - console.log("abnormalStatus=====================>"+abnormalStatus);  
406 -  
407 -  
408 if(abnormalStatus >= 10 && abnormalStatus < 20){ 406 if(abnormalStatus >= 10 && abnormalStatus < 20){
409 name = "<view style='color:red'>" + name + "</view>"; 407 name = "<view style='color:red'>" + name + "</view>";
410 }else if(abnormalStatus >= 20 && abnormalStatus < 30){ 408 }else if(abnormalStatus >= 20 && abnormalStatus < 30){
@@ -446,8 +444,8 @@ export default { @@ -446,8 +444,8 @@ export default {
446 return; 444 return;
447 } 445 }
448 446
449 -  
450 - this.showLoading(); 447 + this.showLoading();
  448 +
451 if(treeNo.type == 401 || treeNo.type == '401'){ 449 if(treeNo.type == 401 || treeNo.type == '401'){
452 let device = new Object(); 450 let device = new Object();
453 if(this.isEmpty(treeNo.online)){ 451 if(this.isEmpty(treeNo.online)){
@@ -459,6 +457,8 @@ export default { @@ -459,6 +457,8 @@ export default {
459 this.videoUrl=[] 457 this.videoUrl=[]
460 } 458 }
461 459
  460 + this.closeLoading();
  461 +
462 let pageObj = this; 462 let pageObj = this;
463 463
464 if(!this.isEmpty(this.sim) && !this.channel && this.sim != treeNo.sim && this.channel != treeNo.id){ 464 if(!this.isEmpty(this.sim) && !this.channel && this.sim != treeNo.sim && this.channel != treeNo.id){
@@ -633,12 +633,31 @@ export default { @@ -633,12 +633,31 @@ export default {
633 return; 633 return;
634 } 634 }
635 635
636 - 636 + this.videoUrl=[''];
  637 + this.$axios({
  638 + method: 'get',
  639 + url:`/api/jt1078/query/send/stop/io/`+sim+"/"+channel+"/"+this.stream+"/"+this.port+"/"+this.httpPort,
  640 + }).then((res) => {
  641 + console.log(res);
  642 + if(fun){
  643 + fun();
  644 + }
  645 + });
  646 + },
  647 +
  648 + sendIORequestStop1(sim,channel,fun){
  649 + if(this.isEmpty(sim) || this.isEmpty(channel)){
  650 + console.log("sim:"+sim+";channel:"+channel);
  651 + if(fun){
  652 + fun();
  653 + }
  654 + return;
  655 + }
637 656
638 this.videoUrl=['']; 657 this.videoUrl=[''];
639 this.$axios({ 658 this.$axios({
640 method: 'get', 659 method: 'get',
641 - url:`/api/jt1078/query/send/stop/io/`+sim+"/"+channel+"/"+this.stream+"/"+this.port+"/"+this.httpPort+"/", 660 + url:`/api/jt1078/query/send/stop/io/`+sim+"/"+channel,
642 }).then((res) => { 661 }).then((res) => {
643 console.log(res); 662 console.log(res);
644 if(fun){ 663 if(fun){
@@ -646,6 +665,7 @@ export default { @@ -646,6 +665,7 @@ export default {
646 } 665 }
647 }); 666 });
648 }, 667 },
  668 +
649 isEmpty(val){ 669 isEmpty(val){
650 return null == val || undefined == val || "" == val; 670 return null == val || undefined == val || "" == val;
651 }, 671 },
@@ -771,7 +791,7 @@ export default { @@ -771,7 +791,7 @@ export default {
771 } 791 }
772 792
773 let pageObj = this; 793 let pageObj = this;
774 - this.showLoading(); 794 +
775 795
776 this.videoUrl =[]; 796 this.videoUrl =[];
777 797
@@ -780,7 +800,7 @@ export default { @@ -780,7 +800,7 @@ export default {
780 method: 'get', 800 method: 'get',
781 url: '/api/jt1078/query/send/request/io/history/' + pageObj.sim + '/' + pageObj.channel+"/"+e.target.getAttribute('startTime')+"/"+e.target.getAttribute('endTime')+"/"+e.target.getAttribute('channelMapping') 801 url: '/api/jt1078/query/send/request/io/history/' + pageObj.sim + '/' + pageObj.channel+"/"+e.target.getAttribute('startTime')+"/"+e.target.getAttribute('endTime')+"/"+e.target.getAttribute('channelMapping')
782 }).then(function (res) { 802 }).then(function (res) {
783 - console.log(res); 803 +
784 804
785 if (res.data && res.data.data && res.data.data.data) { 805 if (res.data && res.data.data && res.data.data.data) {
786 let videoUrl1; 806 let videoUrl1;
@@ -845,6 +865,17 @@ export default { @@ -845,6 +865,17 @@ export default {
845 this.$message.error('请选择车辆'); 865 this.$message.error('请选择车辆');
846 return; 866 return;
847 } 867 }
  868 +
  869 + if(this.isEmpty(this.carTreeNode.abnormalStatus)){
  870 + this.$message.error('请检查车辆状态');
  871 + return;
  872 + }
  873 +
  874 +
  875 + if(this.carTreeNode.abnormalStatus!=1){
  876 + this.$message.error('车辆设备离线,请检查设备');
  877 + return;
  878 + }
848 if(this.isEmpty(this.sim)){ 879 if(this.isEmpty(this.sim)){
849 this.$message.error('无法获取SIM卡信息,请检查设备'); 880 this.$message.error('无法获取SIM卡信息,请检查设备');
850 return; 881 return;
@@ -876,6 +907,23 @@ export default { @@ -876,6 +907,23 @@ export default {
876 } 907 }
877 908
878 window.open(this.downloadURL,"_download"); 909 window.open(this.downloadURL,"_download");
  910 + },
  911 + closeSelectItem(){
  912 + console.log("============================>"+this.playerIdx);
  913 + this.setPlayUrl(null,this.playerIdx)
  914 + // this.videoUrl[this.playerIdx]=null;
  915 + // this.sendIORequestStop1(this.sim,this.playerIdx+1);
  916 +
  917 + },
  918 + closeSelectCarItem(){
  919 + for (let index = 0; index < 9; index++) {
  920 + this.setPlayUrl(null,index)
  921 + // this.videoUrl[this.playerIdx]=null;
  922 + this.sendIORequestStop1(this.sim,index+1);
  923 +
  924 + }
  925 +
  926 +
879 } 927 }
880 } 928 }
881 }; 929 };
web_src/src/components/common/jessibuca.vue
@@ -105,6 +105,7 @@ export default { @@ -105,6 +105,7 @@ export default {
105 } 105 }
106 }, 106 },
107 create() { 107 create() {
  108 + this.loaded = true;
108 let options = { 109 let options = {
109 container: this.$refs.container, 110 container: this.$refs.container,
110 autoWasm: true, 111 autoWasm: true,
@@ -114,9 +115,9 @@ export default { @@ -114,9 +115,9 @@ export default {
114 decoder: "static/js/jessibuca/decoder.js", 115 decoder: "static/js/jessibuca/decoder.js",
115 forceNoOffscreen: false, 116 forceNoOffscreen: false,
116 hasAudio: typeof (this.hasAudio) == "undefined" ? true : this.hasAudio, 117 hasAudio: typeof (this.hasAudio) == "undefined" ? true : this.hasAudio,
117 - heartTimeout: 5, 118 + heartTimeout: 1500000,
118 heartTimeoutReplay: true, 119 heartTimeoutReplay: true,
119 - heartTimeoutReplayTimes: 3, 120 + heartTimeoutReplayTimes: -1,
120 hiddenAutoPause: false, 121 hiddenAutoPause: false,
121 hotKey: true, 122 hotKey: true,
122 isFlv: false, 123 isFlv: false,
@@ -125,9 +126,9 @@ export default { @@ -125,9 +126,9 @@ export default {
125 isResize: false, 126 isResize: false,
126 keepScreenOn: true, 127 keepScreenOn: true,
127 loadingText: "请稍等, 视频加载中......", 128 loadingText: "请稍等, 视频加载中......",
128 - loadingTimeout: 10, 129 + loadingTimeout: 100000,
129 loadingTimeoutReplay: true, 130 loadingTimeoutReplay: true,
130 - loadingTimeoutReplayTimes: 3, 131 + loadingTimeoutReplayTimes: -1,
131 openWebglAlignment: false, 132 openWebglAlignment: false,
132 operateBtns: { 133 operateBtns: {
133 fullscreen: false, 134 fullscreen: false,
@@ -140,7 +141,7 @@ export default { @@ -140,7 +141,7 @@ export default {
140 rotate: 0, 141 rotate: 0,
141 showBandwidth: false, 142 showBandwidth: false,
142 supportDblclickFullscreen: false, 143 supportDblclickFullscreen: false,
143 - timeout: 10, 144 + timeout: 1000000,
144 useMSE: true, 145 useMSE: true,
145 useWCS: location.hostname === "localhost" || location.protocol === "https:", 146 useWCS: location.hostname === "localhost" || location.protocol === "https:",
146 useWebFullScreen: true, 147 useWebFullScreen: true,
@@ -155,12 +156,13 @@ export default { @@ -155,12 +156,13 @@ export default {
155 let _this = this; 156 let _this = this;
156 jessibuca.on("pause", function () { 157 jessibuca.on("pause", function () {
157 _this.playing = false; 158 _this.playing = false;
  159 +
158 }); 160 });
159 jessibuca.on("play", function () { 161 jessibuca.on("play", function () {
160 _this.playing = true; 162 _this.playing = true;
161 }); 163 });
162 jessibuca.on("fullscreen", function (msg) { 164 jessibuca.on("fullscreen", function (msg) {
163 - _this.fullscreen = msg 165 + _this.fullscreen = msg;
164 }); 166 });
165 jessibuca.on("mute", function (msg) { 167 jessibuca.on("mute", function (msg) {
166 _this.isNotMute = !msg; 168 _this.isNotMute = !msg;
@@ -181,10 +183,10 @@ export default { @@ -181,10 +183,10 @@ export default {
181 console.log("Jessibuca -> videoInfo: ", msg); 183 console.log("Jessibuca -> videoInfo: ", msg);
182 }); 184 });
183 jessibuca.on("audioInfo", function (msg) { 185 jessibuca.on("audioInfo", function (msg) {
184 - console.log("Jessibuca -> audioInfo: ", msg);  
185 }); 186 });
186 jessibuca.on("error", function (msg) { 187 jessibuca.on("error", function (msg) {
187 console.log("Jessibuca -> error: ", msg); 188 console.log("Jessibuca -> error: ", msg);
  189 + _this.play(_this.videoUrl);
188 }); 190 });
189 jessibuca.on("timeout", function (msg) { 191 jessibuca.on("timeout", function (msg) {
190 console.log("Jessibuca -> timeout: ", msg); 192 console.log("Jessibuca -> timeout: ", msg);
web_src/static/js/config.js
1 -window.baseUrl = "http://118.113.164.50:18989"; 1 +window.baseUrl = "http://127.0.0.1:28080";
2 2
3 // map组件全局参数, 注释此内容可以关闭地图功能 3 // map组件全局参数, 注释此内容可以关闭地图功能
4 window.mapParam = { 4 window.mapParam = {