|
@@ -1,5 +1,6 @@
|
|
package com.persagy.cameractl.service.windows;
|
|
package com.persagy.cameractl.service.windows;
|
|
|
|
|
|
|
|
+import cn.hutool.crypto.digest.MD5;
|
|
import com.persagy.cameractl.common.VideoExportProcessContext;
|
|
import com.persagy.cameractl.common.VideoExportProcessContext;
|
|
import com.persagy.cameractl.conf.AllStaticConfig;
|
|
import com.persagy.cameractl.conf.AllStaticConfig;
|
|
import com.persagy.cameractl.utils.*;
|
|
import com.persagy.cameractl.utils.*;
|
|
@@ -307,11 +308,17 @@ public class ZhaosMainWindows {
|
|
};
|
|
};
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 回放入口 synchronized关键字即把方法改为同步,两个线程同时调用该方法时,上一个线程执行完后下一个线程才会执行
|
|
|
|
|
|
+ * 回放入口
|
|
*/
|
|
*/
|
|
public ResultClass playBackMain() {
|
|
public ResultClass playBackMain() {
|
|
ResultClass returnResult = new ResultClass();
|
|
ResultClass returnResult = new ResultClass();
|
|
- String playBackFilePath = OtherTools.getVideoFilePath();
|
|
|
|
|
|
+
|
|
|
|
+ String token = OtherTools.generateFileToken(_camera);
|
|
|
|
+
|
|
|
|
+ String playBackFilePath = OtherTools.getVideoFilePathByT(
|
|
|
|
+ token,
|
|
|
|
+ _camera.transcoding ? "mp4" : "h264");
|
|
|
|
+
|
|
if (StringUtils.isEmpty(playBackFilePath)) {
|
|
if (StringUtils.isEmpty(playBackFilePath)) {
|
|
returnResult.name = false;
|
|
returnResult.name = false;
|
|
returnResult.reason = "回放文件名称生成失败";
|
|
returnResult.reason = "回放文件名称生成失败";
|
|
@@ -322,7 +329,6 @@ public class ZhaosMainWindows {
|
|
String playBackFileName = mp4File.getName();
|
|
String playBackFileName = mp4File.getName();
|
|
|
|
|
|
String tempPlayBackFilePath = playBackFilePath + ".tmp";
|
|
String tempPlayBackFilePath = playBackFilePath + ".tmp";
|
|
- String token = OtherTools.getMp4NamePrefix(playBackFileName);
|
|
|
|
|
|
|
|
String errPrefixStr = "回放失败";
|
|
String errPrefixStr = "回放失败";
|
|
// 初始化
|
|
// 初始化
|
|
@@ -336,12 +342,17 @@ public class ZhaosMainWindows {
|
|
WinDef.LPVOID pUser = new WinDef.LPVOID(pUserPointer);
|
|
WinDef.LPVOID pUser = new WinDef.LPVOID(pUserPointer);
|
|
|
|
|
|
VideoExportProcessContext context = new VideoExportProcessContext(
|
|
VideoExportProcessContext context = new VideoExportProcessContext(
|
|
- pUserPointer, playBackFilePath, tempPlayBackFilePath);
|
|
|
|
-
|
|
|
|
- // 保证在当前流程中不被GC回收掉
|
|
|
|
- EndPlayCallBackClass endPlayCallBackClass = new EndPlayCallBackClass(context);
|
|
|
|
|
|
+ pUserPointer, playBackFilePath, tempPlayBackFilePath, _camera);
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
+ // 视频已经存在就直接返回
|
|
|
|
+ if (context.videoExists()) {
|
|
|
|
+ return playBackSuccess(playBackFileName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 保证在当前流程中不被GC回收掉
|
|
|
|
+ EndPlayCallBackClass endPlayCallBackClass = new EndPlayCallBackClass(context);
|
|
|
|
+
|
|
// 回放开始
|
|
// 回放开始
|
|
String playBackResult = this.startPlayBack(pUser, endPlayCallBackClass, context);
|
|
String playBackResult = this.startPlayBack(pUser, endPlayCallBackClass, context);
|
|
if (!"true".equals(playBackResult))
|
|
if (!"true".equals(playBackResult))
|
|
@@ -353,10 +364,7 @@ public class ZhaosMainWindows {
|
|
return this.executeErr(true, "无可回放内容", errPrefixStr);
|
|
return this.executeErr(true, "无可回放内容", errPrefixStr);
|
|
}
|
|
}
|
|
|
|
|
|
- String url = OtherTools.playMp4RootUrl + token;
|
|
|
|
- Map<String, String> dataMap = new HashMap<>();
|
|
|
|
- dataMap.put("url", url);
|
|
|
|
- return this.executeSuccess(dataMap);
|
|
|
|
|
|
+ return playBackSuccess(playBackFileName);
|
|
}
|
|
}
|
|
|
|
|
|
log.info("errPrefixStr:" + errPrefixStr);
|
|
log.info("errPrefixStr:" + errPrefixStr);
|
|
@@ -368,7 +376,13 @@ public class ZhaosMainWindows {
|
|
context.clean();
|
|
context.clean();
|
|
}
|
|
}
|
|
|
|
|
|
- };
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private ResultClass playBackSuccess(String playBackFileName){
|
|
|
|
+ Map<String, String> dataMap = new HashMap<>();
|
|
|
|
+ dataMap.put("file", playBackFileName);
|
|
|
|
+ return this.executeSuccess(dataMap);
|
|
|
|
+ }
|
|
|
|
|
|
/** 查询日志入口 */
|
|
/** 查询日志入口 */
|
|
public ResultClass searchLogMain() {
|
|
public ResultClass searchLogMain() {
|