package com.ld.igds.camera;
|
|
import com.ld.igds.sec.dto.SecCameraDto;
|
import org.apache.commons.lang3.StringUtils;
|
import java.io.UnsupportedEncodingException;
|
import java.net.URLEncoder;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* @author: andy.jia
|
* @description:
|
* @version:
|
* @data:2020年6月12日
|
*/
|
public class CameraUtil {
|
|
|
/**
|
* 流媒体中摄像头的在线状态,key = 流媒体通道ID value= ON/OFF
|
*/
|
public static Map<String, String> contextCameraStatus = new HashMap<>();
|
|
public static Map<String, Integer> contextOrderId = new HashMap<>();
|
|
|
public static final String STATUS_ON = "ON";
|
|
public static final String STATUS_OFF = "OFF";
|
|
|
//播放方式
|
public static final String PLAY_TYPE_DEFAULT = "DEFAULT";//默认其他
|
public static final String PLAY_TYPE_VLC = "VLC"; //VLC播放方式
|
public static final String PLAY_TYPE_FZZY_GB = "FZZY_GB"; //FZZY-GB服务器
|
public static final String PLAY_TYPE_EASY_GBS = "EASY_GBS";//EASY-GBS服务器
|
public static final String PLAY_TYPE_EASY_DSS = "EASY_DSS";//EASY-DSS服务器
|
public static final String PLAY_TYPE_MEDIA_HIK = "MEDIA_HIK";//海康流媒体-综合安防管理平台
|
public static final String PLAY_TYPE_MEDIA_HIK_INFOVISION_IOT_161 = "MEDIA_HIK_INFOVISION_IOT_161";//海康流媒体-智能应用平台V1.6.1
|
public static final String PLAY_TYPE_HIK_YS = "HIK_YS";//海康-萤石云
|
public static final String PLAY_TYPE_HIK_WEB4 = "HIK_WEB4";//海康-WEB4.0插件
|
public static final String PLAY_TYPE_IMOU = "IMOU";//乐橙云
|
|
//抓拍方式
|
public static final String SNAP_TYPE_FZZY_PLUGIN = "FZZY-PLUGIN";//风正致远插件
|
public static final String SNAP_TYPE_MEDIA = "MEDIA";//流媒体
|
|
|
public static final String buildOrderId() {
|
Integer start = contextOrderId.get("ORDER_ID") == null ? 1000 : contextOrderId.get("ORDER_ID");
|
contextOrderId.put("ORDER_ID", start + 1);
|
return start + "";
|
}
|
|
|
/**
|
* {0} = 用户名
|
* {1} = 密码
|
* {2} = IP
|
* {3} = PORT
|
* {4} = 通道号
|
*
|
* @param dto
|
* @param isEncode
|
* @return
|
*/
|
public static String updateMediaAddr2(SecCameraDto dto, boolean isEncode) {
|
|
// 替换表达式中的值
|
String mediaAddr = dto.getMediaAddr();
|
if (StringUtils.isEmpty(mediaAddr)) return null;
|
mediaAddr = mediaAddr.replace("{0}", dto.getLoginId());
|
mediaAddr = mediaAddr.replace("{1}", dto.getPwd());
|
mediaAddr = mediaAddr.replace("{2}", dto.getIpIn());
|
mediaAddr = mediaAddr.replace("{3}", dto.getPortInC() + "");
|
mediaAddr = mediaAddr.replace("{4}", dto.getChanNum() + "");
|
|
if (isEncode) {
|
try {
|
mediaAddr = URLEncoder.encode(mediaAddr, "UTF-8");
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
}
|
}
|
return mediaAddr;
|
}
|
|
|
/**
|
* {0} = 用户名
|
* {1} = 密码
|
* {2} = IP
|
* {3} = PORT 控制端口
|
* {4} = 通道号
|
*
|
* @return
|
*/
|
public static String updateMediaAddr(String mediaAddr, String loginId, String pwd, String ip, int portCtr, int chanNum) {
|
|
// 替换表达式中的值
|
if (StringUtils.isEmpty(mediaAddr)) return null;
|
|
mediaAddr = mediaAddr.replace("{0}", null == loginId ? "" : loginId);
|
mediaAddr = mediaAddr.replace("{1}", null == pwd ? "" : pwd);
|
mediaAddr = mediaAddr.replace("{2}", null == ip ? "" : ip);
|
mediaAddr = mediaAddr.replace("{3}", portCtr == 0 ? "" : portCtr + "");
|
mediaAddr = mediaAddr.replace("{4}", chanNum == 0 ? "" : chanNum + "");
|
|
return mediaAddr;
|
}
|
|
public static void updateMediaStatus(String sn, String status) {
|
contextCameraStatus.put(sn, status);
|
}
|
|
public static String getCameraStatus(String sn) {
|
return contextCameraStatus.get(sn);
|
}
|
}
|