|
|
@@ -0,0 +1,236 @@
|
|
|
+package com.usky.api;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
|
|
+import com.hikvision.artemis.sdk.config.ArtemisConfig;
|
|
|
+import com.usky.utils.StringUtils;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 海康视频api
|
|
|
+ * @author han
|
|
|
+ * @date 2023/10/29 13:21
|
|
|
+ */
|
|
|
+
|
|
|
+public class HkVideoApi {
|
|
|
+ static {
|
|
|
+ /**
|
|
|
+ * 添加连接配置
|
|
|
+ */
|
|
|
+ ArtemisConfig.host = "172.20.10.2:443";
|
|
|
+ /**
|
|
|
+ * 密钥appkey
|
|
|
+ */
|
|
|
+ ArtemisConfig.appKey = "21491855";
|
|
|
+ /**
|
|
|
+ * 密钥appSecret
|
|
|
+ */
|
|
|
+ ArtemisConfig.appSecret = "VhhP8pf7vDRdKSKu9edi";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取监测点信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getCameraPreviewURL(Integer current,Integer size) {
|
|
|
+ /**
|
|
|
+ * 获取监控点资源接口
|
|
|
+ */
|
|
|
+ /**
|
|
|
+ * STEP2:设置OpenAPI接口的上下文
|
|
|
+ */
|
|
|
+ final String ARTEMIS_PATH = "/artemis";
|
|
|
+ final String url = ARTEMIS_PATH + "/api/resource/v1/cameras";
|
|
|
+ Map<String, String> path = new HashMap<String, String>(2) {
|
|
|
+ {
|
|
|
+ put("https://", url);//根据现场环境部署确认是http还是https
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加请求参数
|
|
|
+ */
|
|
|
+ JSONObject jsonBody = new JSONObject();
|
|
|
+ jsonBody.put("pageNo", current);
|
|
|
+ jsonBody.put("pageSize", size);
|
|
|
+ String body = jsonBody.toJSONString();
|
|
|
+ /**
|
|
|
+ * STEP4:设置参数提交方式
|
|
|
+ */
|
|
|
+ String contentType = "application/json";
|
|
|
+ return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取监测点信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getNodes(String name,String[] regionIndexCodes,Boolean isSubRegion,Integer pageNo,Integer pageSize,
|
|
|
+ String[] authCodes,Object[] expressions,String orderBy,String orderType) {
|
|
|
+ /**
|
|
|
+ * 获取监控点资源接口
|
|
|
+ */
|
|
|
+ /**
|
|
|
+ * STEP2:设置OpenAPI接口的上下文
|
|
|
+ */
|
|
|
+ final String ARTEMIS_PATH = "/artemis";
|
|
|
+ final String url = ARTEMIS_PATH + "/api/resource/v2/camera/search";
|
|
|
+ Map<String, String> path = new HashMap<String, String>(2) {
|
|
|
+ {
|
|
|
+ put("https://", url);//根据现场环境部署确认是http还是https
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加请求参数
|
|
|
+ */
|
|
|
+ JSONObject jsonBody = new JSONObject();
|
|
|
+ jsonBody.put("name", name);
|
|
|
+ jsonBody.put("regionIndexCodes", regionIndexCodes);
|
|
|
+ jsonBody.put("isSubRegion", isSubRegion);
|
|
|
+ jsonBody.put("pageNo", pageNo);
|
|
|
+ jsonBody.put("pageSize", pageSize);
|
|
|
+ jsonBody.put("authCodes", authCodes);
|
|
|
+ jsonBody.put("expressions", expressions);
|
|
|
+ jsonBody.put("orderBy", orderBy);
|
|
|
+ jsonBody.put("orderType", orderType);
|
|
|
+ String body = jsonBody.toJSONString();
|
|
|
+ /**
|
|
|
+ * STEP4:设置参数提交方式
|
|
|
+ */
|
|
|
+ String contentType = "application/json";
|
|
|
+ return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 实时视频
|
|
|
+ * @param cameraIndexCode
|
|
|
+ * @param streamType
|
|
|
+ * @param protocol
|
|
|
+ * @param transmode
|
|
|
+ * @param expand
|
|
|
+ * @param streamform
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getVideoUrl(String cameraIndexCode, Integer streamType,String protocol,Integer transmode,String expand,
|
|
|
+ String streamform){
|
|
|
+ /**
|
|
|
+ * 获取视频资源
|
|
|
+ */
|
|
|
+ /**
|
|
|
+ * STEP2:设置OpenAPI接口的上下文
|
|
|
+ */
|
|
|
+ final String ARTEMIS_PATH = "/artemis";
|
|
|
+ final String url = ARTEMIS_PATH+"/api/video/v1/cameras/previewURLs";
|
|
|
+ Map<String, String> path = new HashMap<String, String>(2) {
|
|
|
+ {
|
|
|
+ put("https://", url);//根据现场环境部署确认是http还是https
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * 添加请求参数
|
|
|
+ */
|
|
|
+ JSONObject jsonBody = new JSONObject();
|
|
|
+ if (StringUtils.isNotBlank(cameraIndexCode)){
|
|
|
+ jsonBody.put("cameraIndexCode", cameraIndexCode);
|
|
|
+ }
|
|
|
+ if (null != streamType){
|
|
|
+ jsonBody.put("streamType", streamType);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(protocol)){
|
|
|
+ jsonBody.put("protocol", protocol);
|
|
|
+ }
|
|
|
+ if (null != transmode){
|
|
|
+ jsonBody.put("transmode", transmode);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(expand)){
|
|
|
+ jsonBody.put("expand", expand);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(streamform)){
|
|
|
+ jsonBody.put("streamform", streamform);
|
|
|
+ }
|
|
|
+ String body = jsonBody.toJSONString();
|
|
|
+ /**
|
|
|
+ * STEP4:设置参数提交方式
|
|
|
+ */
|
|
|
+ String contentType = "application/json";
|
|
|
+ return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 视频回放
|
|
|
+ * @param cameraIndexCode
|
|
|
+ * @param recordLocation
|
|
|
+ * @param protocol
|
|
|
+ * @param transmode
|
|
|
+ * @param beginTime
|
|
|
+ * @param endTime
|
|
|
+ * @param uuid
|
|
|
+ * @param expand
|
|
|
+ * @param streamform
|
|
|
+ * @param lockType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getPlayBackUrl(String cameraIndexCode, Integer recordLocation,String protocol,
|
|
|
+ Integer transmode,String beginTime, String endTime,
|
|
|
+ String uuid,String expand,String streamform,Integer lockType){
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取视频资源
|
|
|
+ */
|
|
|
+ /**
|
|
|
+ * STEP2:设置OpenAPI接口的上下文
|
|
|
+ */
|
|
|
+ final String ARTEMIS_PATH = "/artemis";
|
|
|
+ final String url = ARTEMIS_PATH+"/api/video/v2/cameras/playbackURLs";
|
|
|
+ Map<String, String> path = new HashMap<String, String>(2) {
|
|
|
+ {
|
|
|
+ put("https://", url);//根据现场环境部署确认是http还是https
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * 添加请求参数
|
|
|
+ */
|
|
|
+ JSONObject jsonBody = new JSONObject();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(cameraIndexCode)){
|
|
|
+ jsonBody.put("cameraIndexCode", cameraIndexCode);
|
|
|
+ }
|
|
|
+ if (null != recordLocation){
|
|
|
+ jsonBody.put("recordLocation", recordLocation);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(protocol)){
|
|
|
+ jsonBody.put("protocol", protocol);
|
|
|
+ }
|
|
|
+ if (null != transmode){
|
|
|
+ jsonBody.put("transmode", transmode);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(beginTime)){
|
|
|
+ jsonBody.put("beginTime", beginTime);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(endTime)){
|
|
|
+ jsonBody.put("endTime", endTime);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(uuid)){
|
|
|
+ jsonBody.put("uuid", uuid);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(expand)){
|
|
|
+ jsonBody.put("expand", expand);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(streamform)){
|
|
|
+ jsonBody.put("streamform", streamform);
|
|
|
+ }
|
|
|
+ if (null != lockType){
|
|
|
+ jsonBody.put("lockType", lockType);
|
|
|
+ }
|
|
|
+ String body = jsonBody.toJSONString();
|
|
|
+ /**
|
|
|
+ * STEP4:设置参数提交方式
|
|
|
+ */
|
|
|
+ String contentType = "application/json";
|
|
|
+ return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);
|
|
|
+ }
|
|
|
+}
|