From 2c0240e16f837aef6ce94aa48d862cc48e2c0cf0 Mon Sep 17 00:00:00 2001 From: lawrencehj <1934378145@qq.com> Date: 星期三, 23 六月 2021 16:01:28 +0800 Subject: [PATCH] 屏蔽测试代码 --- src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 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 49412ff..540a66e 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 @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.UserSetup; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; @@ -23,7 +24,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -31,13 +31,11 @@ import org.springframework.web.context.request.async.DeferredResult; import javax.sip.ClientTransaction; -import javax.sip.Dialog; -import javax.sip.header.CallIdHeader; import javax.sip.message.Response; -import java.io.File; import java.io.FileNotFoundException; import java.util.UUID; +@SuppressWarnings(value = {"rawtypes", "unchecked"}) @Service public class PlayServiceImpl implements IPlayService { @@ -64,8 +62,8 @@ @Autowired private VideoStreamSessionManager streamSession; - @Value("${userSettings.playTimeout}") - private long playTimeout; + @Autowired + private UserSetup userSetup; @Override @@ -76,7 +74,7 @@ playResult.setDevice(device); UUID uuid = UUID.randomUUID(); playResult.setUuid(uuid.toString()); - DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(playTimeout); + DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(userSetup.getPlayTimeout()); playResult.setResult(result); // 褰曞儚鏌ヨ浠hannelId浣滀负deviceId鏌ヨ resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid, result); @@ -96,7 +94,21 @@ result.onCompletion(()->{ // 鐐规挱缁撴潫鏃惰皟鐢ㄦ埅鍥炬帴鍙� try { - String path = ResourceUtils.getURL("classpath:").getPath()+"static/static/snap/"; + String classPath = ResourceUtils.getURL("classpath:").getPath(); + // System.out.println(classPath); + // 鍏煎鎵撳寘涓簀ar鐨刢lass璺緞 + if(classPath.contains("jar")) { + classPath = classPath.substring(0, classPath.lastIndexOf(".")); + classPath = classPath.substring(0, classPath.lastIndexOf("/") + 1); + } + if (classPath.startsWith("file:")) { + classPath = classPath.substring(classPath.indexOf(":") + 1, classPath.length()); + } + String path = classPath + "static/static/snap/"; + // 鍏煎Windows绯荤粺璺緞锛堝幓闄ゅ墠闈㈢殑鈥�/鈥濓級 + if(System.getProperty("os.name").contains("indows")) { + path = path.substring(1, path.length()); + } String fileName = deviceId + "_" + channelId + ".jpg"; ResponseEntity responseEntity = (ResponseEntity)result.getResult(); if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) { @@ -105,10 +117,9 @@ StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData(); String flvUrl = streamInfoForSuccess.getFlv(); // 璇锋眰鎴浘 - zlmresTfulUtils.getSnap(flvUrl, 5, 1, path, fileName); + zlmresTfulUtils.getSnap(flvUrl, 15, 1, path, fileName); } } - System.out.println(path); } catch (FileNotFoundException e) { e.printStackTrace(); -- Gitblit v1.8.0