You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

77 lines
2.8 KiB

package com.inspect.nvr.service.impl;
import com.inspect.nvr.domain.device.*;
import com.inspect.nvr.service.IvsCameraService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Service
public class IvsCameraServiceImpl implements IvsCameraService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Value("${test-mode:false}")
private boolean testMode;
@Override
public PtzControlResult ptzControl(PtzControlParam param) {
PtzControlResult ptzControlResult = PtzControlResult.builder()
.resultCode("0")
.build();
return ptzControlResult;
}
@Override
public SnapshotCommandResult platformSnapshot(String cameraCode, String domainCode, SnapshotCommandParam param) {
SnapshotCommandResult snapshotCommandResult =
SnapshotCommandResult.builder()
.taskID("0123456789")
.build();
return snapshotCommandResult;
}
@Override
public SnapshotInfoListResult getSnapshotList(SnapshotInfoListParam param) {
SnapshotInfoListResult.SnapshotInfoList snapshotInfoList = new SnapshotInfoListResult.SnapshotInfoList();
List<SnapshotInfoListResult.SnapshotInfo> infoList = new ArrayList<>();
infoList.add(
SnapshotInfoListResult.SnapshotInfo.builder()
.pictureUrl("http://192.168.1.172:18539/downloadfile?filesessionid=HQ3HLF98QI6T645DSNVO4S066S00")
.cameraCode("01969538357008970118")
.build());
snapshotInfoList.setTotal(1);
snapshotInfoList.setSnapshotInfos(infoList);
SnapshotInfoListResult snapshotInfoListResult =
SnapshotInfoListResult.builder()
.snapshotInfoList(snapshotInfoList)
.build();
return snapshotInfoListResult;
}
@Override
public ByteArrayInputStream downloadFile(String fileSessionId) {
if (testMode) {
try {
return new ByteArrayInputStream(loadDefaultImage());
} catch (IOException e) {
throw new RuntimeException("测试环境生成错误图片失败", e);
}
}
// 从nvr或者camera下载图片, 开发中
return null;
}
public byte[] loadDefaultImage() throws IOException {
ClassPathResource imgFile = new ClassPathResource("images/infrared_default.jpg");
return StreamUtils.copyToByteArray(imgFile.getInputStream());
}
}