From 5e724cc0628554b949f0102bee6294db8a23c7f5 Mon Sep 17 00:00:00 2001
From: wangyimeng <421132955@qq.com>
Date: 星期三, 06 七月 2022 15:33:43 +0800
Subject: [PATCH] Merge branch 'wvp-28181-2.0' of https://github.com/mrjackwang/wvp-GB28181-pro into wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 72 +++++++++++++++++-------------------
1 files changed, 34 insertions(+), 38 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
index 811507d..041fdf0 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -123,36 +123,19 @@
result.onCompletion(()->{
// 鐐规挱缁撴潫鏃惰皟鐢ㄦ埅鍥炬帴鍙�
// TODO 搴旇鍦ㄤ笂娴佹椂璋冪敤鏇村ソ锛岀粨鏉熶篃鍙兘鏄敊璇粨鏉�
- try {
- String classPath = ResourceUtils.getURL("classpath:").getPath();
- // 鍏煎鎵撳寘涓簀ar鐨刢lass璺緞
- if(classPath.contains("jar")) {
- classPath = classPath.substring(0, classPath.lastIndexOf("."));
- classPath = classPath.substring(0, classPath.lastIndexOf("/") + 1);
+ String path = "snap";
+ String fileName = deviceId + "_" + channelId + ".jpg";
+ ResponseEntity responseEntity = (ResponseEntity)result.getResult();
+ if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
+ WVPResult wvpResult = (WVPResult)responseEntity.getBody();
+ if (Objects.requireNonNull(wvpResult).getCode() == 0) {
+ StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData();
+ MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
+ String streamUrl = streamInfoForSuccess.getFmp4();
+ // 璇锋眰鎴浘
+ logger.info("[璇锋眰鎴浘]: " + fileName);
+ zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName);
}
- if (classPath.startsWith("file:")) {
- classPath = classPath.substring(classPath.indexOf(":") + 1);
- }
- String path = classPath + "static/static/snap/";
- // 鍏煎Windows绯荤粺璺緞锛堝幓闄ゅ墠闈㈢殑鈥�/鈥濓級
- if(System.getProperty("os.name").contains("indows")) {
- path = path.substring(1);
- }
- String fileName = deviceId + "_" + channelId + ".jpg";
- ResponseEntity responseEntity = (ResponseEntity)result.getResult();
- if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
- WVPResult wvpResult = (WVPResult)responseEntity.getBody();
- if (Objects.requireNonNull(wvpResult).getCode() == 0) {
- StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData();
- MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
- String streamUrl = streamInfoForSuccess.getFmp4();
- // 璇锋眰鎴浘
- logger.info("[璇锋眰鎴浘]: " + fileName);
- zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName);
- }
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
}
});
if (streamInfo != null) {
@@ -169,22 +152,30 @@
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId);
- if (rtpInfo != null && rtpInfo.getBoolean("exist")) {
+ if(rtpInfo.getInteger("code") == 0){
+ if (rtpInfo.getBoolean("exist")) {
- WVPResult wvpResult = new WVPResult();
- wvpResult.setCode(0);
- wvpResult.setMsg("success");
- wvpResult.setData(streamInfo);
- msg.setData(wvpResult);
+ WVPResult wvpResult = new WVPResult();
+ wvpResult.setCode(0);
+ wvpResult.setMsg("success");
+ wvpResult.setData(streamInfo);
+ msg.setData(wvpResult);
- resultHolder.invokeAllResult(msg);
- if (hookEvent != null) {
- hookEvent.response(mediaServerItem, JSONObject.parseObject(JSON.toJSONString(streamInfo)));
+ resultHolder.invokeAllResult(msg);
+ if (hookEvent != null) {
+ hookEvent.response(mediaServerItem, JSONObject.parseObject(JSON.toJSONString(streamInfo)));
+ }
+ }else {
+ redisCatchStorage.stopPlay(streamInfo);
+ storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
+ streamInfo = null;
}
}else {
+ //zlm杩炴帴澶辫触
redisCatchStorage.stopPlay(streamInfo);
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
streamInfo = null;
+
}
}
@@ -261,6 +252,11 @@
}, userSetting.getPlayTimeout());
final String ssrc = ssrcInfo.getSsrc();
final String stream = ssrcInfo.getStream();
+ //绔彛鑾峰彇澶辫触鐨剆srcInfo 娌℃湁蹇呰鍙戦�佺偣鎾寚浠�
+ if(ssrcInfo.getPort() <= 0){
+ logger.info("[鐐规挱绔彛鍒嗛厤寮傚父]锛宒eviceId={},channelId={},ssrcInfo={}", device.getDeviceId(), channelId, ssrcInfo);
+ return;
+ }
cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> {
logger.info("鏀跺埌璁㈤槄娑堟伅锛� " + response.toJSONString());
dynamicTask.stop(timeOutTaskKey);
--
Gitblit v1.8.0