海康获取监控点回放取流URLv2
This commit is contained in:
parent
37e9401572
commit
b607f844d3
@ -223,7 +223,7 @@ public class HikVideoUtil {
|
||||
* @param speed 云台速度
|
||||
* @param Ip 海康服务接口IP地址
|
||||
* @param port 海康服务接口端口
|
||||
* @param appke 海康APPkey
|
||||
* @param appkey 海康APPkey
|
||||
* @param appSecret 海康appSecret
|
||||
* @return
|
||||
*/
|
||||
@ -257,6 +257,7 @@ public class HikVideoUtil {
|
||||
}
|
||||
|
||||
public static String doPostStringArtemis(String host, Map<String, String> path, String body, Map<String, String> querys, String accept, String contentType, String appKey, String appSecret) {
|
||||
log.info("海康isc调用http开始>>>>>>>>> host:{},path:{},body:{}", host, JSON.toJSONString(path), body);
|
||||
String httpSchema = (String) path.keySet().toArray()[0];
|
||||
if (httpSchema != null && !StringUtils.isEmpty(httpSchema)) {
|
||||
String responseStr = null;
|
||||
@ -282,9 +283,9 @@ public class HikVideoUtil {
|
||||
Response response = Client.execute(request);
|
||||
responseStr = getResponseResult(response);
|
||||
} catch (Exception var10) {
|
||||
var10.printStackTrace();
|
||||
log.error("海康isc调用http错误>>>>>>>" + var10);
|
||||
}
|
||||
|
||||
log.info("海康isc调用http结果>>>>> {}", responseStr);
|
||||
return responseStr;
|
||||
} else {
|
||||
throw new RuntimeException("http和https参数错误httpSchema: " + httpSchema);
|
||||
@ -446,6 +447,70 @@ public class HikVideoUtil {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取监控点回放取流URL V2
|
||||
* cameraIndexCode string True 监控点唯一标识,分页获取监控点资源接口获取返回参数cameraIndexCode
|
||||
* recordLocation number False 存储类型,0:中心存储
|
||||
* 1:设备存储
|
||||
* 默认为中心存储
|
||||
* protocol string False 取流协议(应用层协议),
|
||||
* “hik”:HIK私有协议,使用视频SDK进行播放时,传入此类型;
|
||||
* “rtsp”:RTSP协议;
|
||||
* “rtmp”:RTMP协议(RTMP协议只支持海康SDK协议、EHOME协议、ONVIF协议接入的设备;只支持H264视频编码和AAC音频编码;RTMP回放要求录像片段连续,需要在URL后自行拼接beginTime=20190902T100303&endTime=20190902T100400,其中20190902T100303至20190902T100400为查询出有连续录像的时间段。对于不连续的录像,需要分段查询分段播放);
|
||||
* “hls”:HLS协议(HLS协议只支持海康SDK协议、EHOME协议、ONVIF协议接入的设备;只支持H264视频编码和AAC音频编码;hls协议只支持云存储,不支持设备存储,云存储版本要求v2.2.4及以上的2.x版本,或v3.0.5及以上的3.x版本;ISC版本要求v1.2.0版本及以上,需在运管中心-视频联网共享中切换成启动平台外置VOD),
|
||||
* “ws”:Websocket协议(一般用于H5视频播放器取流播放)。
|
||||
* 参数不填,默认为HIK协议
|
||||
* transmode integer False 传输协议(传输层协议)0:UDP
|
||||
* 1:TCP
|
||||
* 默认为TCP,在protocol设置为rtsp或者rtmp时有效
|
||||
* 注:EHOME设备回放只支持TCP传输
|
||||
* GB28181 2011及以前版本只支持UDP传输
|
||||
* beginTime string True 开始查询时间(IOS8601格式:yyyy-MM-dd’T’HH:mm:ss.SSSXXX)
|
||||
* 例如北京时间:
|
||||
* 2017-06-14T00:00:00.000+08:00,参考附录B ISO8601时间格式说明
|
||||
* endTime string True 结束查询时间,开始时间和结束时间相差不超过三天;
|
||||
* (IOS8601格式:yyyy-MM-dd’T’HH:mm:ss.SSSXXX)例如北京时间:
|
||||
* 2017-06-15T00:00:00.000+08:00,参考附录B ISO8601时间格式说明
|
||||
* uuid string False 分页查询id,上一次查询返回的uuid,用于继续查询剩余片段,默认为空字符串。当存储类型为设备存储时,该字段生效,中心存储会一次性返回全部片段。
|
||||
* expand string False 扩展内容,格式:key=value,
|
||||
* 调用方根据其播放控件支持的解码格式选择相应的封装类型;
|
||||
* 多个扩展时,以“&”隔开;
|
||||
* 支持的内容详见附录F expand扩展内容说明
|
||||
* streamform string False 输出码流转封装格式,“ps”:PS封装格式、“rtp”:RTP封装协议。当protocol=rtsp时生效,且不传值时默认为RTP封装协议
|
||||
* lockType integer False 查询录像的锁定类型,0-查询全部录像;1-查询未锁定录像;2-查询已锁定录像,不传默认值为0。通过录像锁定与解锁接口来进行录像锁定与解锁。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject callPostPlaybackURLsV2(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, Date beginTime, Date endTime, String uuid, String expand, String streamform, String lockType, String Ip, String port, String appke, String appSecret) {
|
||||
final String playbackURLs = ARTEMIS_PATH + "/api/video/v2/cameras/playbackURLs";
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>();// post请求Form表单参数
|
||||
paramMap.put("cameraIndexCode", cameraIndexCode);
|
||||
paramMap.put("recordLocation", 1);
|
||||
paramMap.put("protocol", "rtsp");
|
||||
paramMap.put("transmode", 0);
|
||||
paramMap.put("beginTime", DateUtils.getISO8601StrWithMs(beginTime));
|
||||
paramMap.put("endTime", DateUtils.getISO8601StrWithMs(endTime));
|
||||
//paramMap.put("uuid", uuid);
|
||||
paramMap.put("expand", "streamform=rtp");
|
||||
//paramMap.put("streamform", streamform);
|
||||
//paramMap.put("lockType", lockType);
|
||||
String body = JSON.toJSON(paramMap).toString();
|
||||
Map<String, String> path = new HashMap<String, String>(2) {
|
||||
{
|
||||
put("https://", playbackURLs);
|
||||
}
|
||||
};
|
||||
String host = Ip + ":" + port;
|
||||
log.info("调用获取监控点回放取流URLv2>>>监控点唯一标识(cameraIndexCode):{}", cameraIndexCode);
|
||||
String result = doPostStringArtemis(host, path, body, null, null, "application/json", appke, appSecret);
|
||||
JSONObject json = JSONObject.parseObject(result);
|
||||
if ("0".equals((String) json.get("code"))) {
|
||||
return JSONObject.parseObject(json.getString("data"));
|
||||
} else {
|
||||
throw new OpenAlertException(json.toJSONString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//String cameraIndexCode,String type,Integer streamType,String Ip,String port,String appke,String appSecret
|
||||
// public static void main(String[] args) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user