package com.yzvideo.controller;
|
|
|
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
import com.hikvision.artemis.sdk.config.ArtemisConfig;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
@CrossOrigin
|
@RestController
|
public class cameras {
|
private static final String ARTEMIS_PATH = "/artemis";
|
private static final String host = "10.117.5.21:443";
|
private static final String appKey = "20380928";
|
private static final String appSecret = "YDnfZJjj1EyD4297r7CU";
|
|
@RequestMapping(value = "/getCamerasInfo",params = {"cameraIndexCode"})
|
public String getCamerasInfo(String cameraIndexCode){
|
/**
|
* https://ip:port/artemis/api/resource/v1/org/orgList
|
* 通过查阅AI Cloud开放平台文档或网关门户的文档可以看到获取组织列表的接口定义,该接口为POST请求的Rest接口, 入参为JSON字符串,接口协议为https。
|
* ArtemisHttpUtil工具类提供了doPostStringArtemis调用POST请求的方法,入参可传JSON字符串, 请阅读开发指南了解方法入参,没有的参数可传null
|
*/
|
ArtemisConfig config = new ArtemisConfig();
|
config.setHost(host); // 代理API网关nginx服务器ip端口10.206.31.254http://10.10.4.116/
|
config.setAppKey(appKey); // 秘钥appkey
|
config.setAppSecret(appSecret);// 秘钥appSecret
|
String getCamsApi = ARTEMIS_PATH + "/api/video/v1/cameras/previewURLs";
|
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
|
paramMap.put("cameraIndexCode", cameraIndexCode);
|
paramMap.put("protocol", "ws");
|
// paramMap.put("protocol", "hls");
|
String body = JSON.toJSON(paramMap).toString();
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);
|
}
|
};
|
String result = "{state:'error'}";
|
try {
|
result = ArtemisHttpUtil.doPostStringArtemis(config, path, body, null, null, "application/json");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return result;
|
}
|
|
@RequestMapping(value = "/getCamerasInfoHls",params = {"cameraIndexCode"})
|
public String getCamerasInfoHls(String cameraIndexCode){
|
/**
|
* https://ip:port/artemis/api/resource/v1/org/orgList
|
* 通过查阅AI Cloud开放平台文档或网关门户的文档可以看到获取组织列表的接口定义,该接口为POST请求的Rest接口, 入参为JSON字符串,接口协议为https。
|
* ArtemisHttpUtil工具类提供了doPostStringArtemis调用POST请求的方法,入参可传JSON字符串, 请阅读开发指南了解方法入参,没有的参数可传null
|
*/
|
ArtemisConfig config = new ArtemisConfig();
|
config.setHost(host); // 代理API网关nginx服务器ip端口10.206.31.254http://10.10.4.116/
|
config.setAppKey(appKey); // 秘钥appkey
|
config.setAppSecret(appSecret);// 秘钥appSecret
|
String getCamsApi = ARTEMIS_PATH + "/api/video/v1/cameras/previewURLs";
|
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
|
paramMap.put("cameraIndexCode", cameraIndexCode);
|
// paramMap.put("protocol", "ws");
|
paramMap.put("protocol", "hls");
|
String body = JSON.toJSON(paramMap).toString();
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);
|
}
|
};
|
String result = "{state:'error'}";
|
try {
|
result = ArtemisHttpUtil.doPostStringArtemis(config, path, body, null, null, "application/json");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return result;
|
}
|
|
|
|
}
|