| | |
| | | |
| | | import com.sun.jna.Native; |
| | | import com.sun.jna.Pointer; |
| | | import com.sun.jna.Structure; |
| | | import com.sun.jna.ptr.IntByReference; |
| | | import com.ycl.api.DH.lib.NetSDKLib; |
| | | import com.ycl.api.DH.lib.NetSDKLib.LLong; |
| | |
| | | |
| | | import java.io.File; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import static com.ycl.api.DH.lib.NetSDKLib.CFG_CMD_VIDEOWIDGET; |
| | | import static com.ycl.api.DH.lib.NetSDKLib.NET_DEV_VIDEO_OSD_CFG; |
| | | import static com.ycl.api.DH.lib.NetSDKLib.NET_EM_OSD_BLEND_TYPE.NET_EM_OSD_BLEND_TYPE_MAIN; |
| | | import static com.ycl.api.DH.lib.enumeration.NET_EM_CFG_OPERATE_TYPE.NET_EM_CFG_CUSTOMTITLE; |
| | | import static com.ycl.api.DH.lib.enumeration.NET_EM_CFG_OPERATE_TYPE.NET_EM_CFG_GBMODE; |
| | |
| | | return bRet; |
| | | } |
| | | |
| | | public static OSDResult getOsd(String serialNumber,LLong loginId) { |
| | | public static OSDResult getOsd(String serialNumber, LLong loginId) { |
| | | OSDResult osdResult = new OSDResult(); |
| | | NetSDKLib.NET_TIME deviceTime = new NetSDKLib.NET_TIME(); |
| | | if (!netsdk.CLIENT_QueryDeviceTime(loginId, deviceTime, 3000)) { |
| | | // log.error("CLIENT_QueryDeviceTime Failed!" + ToolKits.getErrorCodePrint()); |
| | | return null; |
| | | } |
| | | log.info("OSD时间原始数据格式,{},toString格式{}",deviceTime,deviceTime.toStringTime()); |
| | | Date checkTime = new Date(); |
| | | osdResult.setCheckTime(checkTime); |
| | | String date = deviceTime.toStringTime(); |
| | |
| | | // log.error("时间解析失败"); |
| | | } |
| | | NET_CFG_GBMODE_INFO reserve = new NET_CFG_GBMODE_INFO(); |
| | | |
| | | NET_CFG_GBMODE_INFO osdInfo = new NET_CFG_GBMODE_INFO(); |
| | | osdInfo.write(); |
| | | boolean b = false; |
| | |
| | | * 对于大华来说: 国标倒7: 0/全景/通道1 1/细节/通道2 |
| | | * 宇视单通道不考虑 |
| | | */ |
| | | if(serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All ) { |
| | | if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All) { |
| | | b = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_GBMODE, 0, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer()); |
| | | }else if(serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail){ |
| | | } else if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail) { |
| | | b = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_GBMODE, 1, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer()); |
| | | } |
| | | |
| | |
| | | osdInfo.read(); |
| | | NET_GBMODE_CUSTOMTITLE_INFO[] stuCustomTitle = osdInfo.stuCustomTitle; |
| | | for (NET_GBMODE_CUSTOMTITLE_INFO title : stuCustomTitle) { |
| | | log.info("OSD原始数据格式{}",title); |
| | | String position = new String(title.szPositon, StandardCharsets.UTF_8).trim(); |
| | | if("LeftDown".equals(position)) { |
| | | if ("LeftDown".equals(position)) { |
| | | NET_TITLE_OSD_INFO[] stuOSD = title.stuOSD; |
| | | for (NET_TITLE_OSD_INFO osd : stuOSD) { |
| | | String osdStr = null; |
| | |
| | | osdResult.setOSD4(osdStr); |
| | | } |
| | | } |
| | | }else if("RightDown".equals(position)){ |
| | | } else if ("RightDown".equals(position)) { |
| | | NET_TITLE_OSD_INFO[] stuOSD = title.stuOSD; |
| | | int num = 0; |
| | | for (NET_TITLE_OSD_INFO osd : stuOSD) { |
| | |
| | | osdStr = new String(osd.szText, StandardCharsets.UTF_8).trim(); |
| | | // log.info("TEXT:"+osdStr); |
| | | if (!StringUtils.isEmpty(osdStr)) { |
| | | if(num ==0){ |
| | | if (num == 0) { |
| | | osdResult.setOSD1(osdStr); |
| | | }else if(num ==1){ |
| | | } else if (num == 1) { |
| | | osdResult.setOSD2(osdStr); |
| | | }else if(num ==2){ |
| | | } else if (num == 2) { |
| | | osdResult.setOSD3(osdStr); |
| | | }else if(num ==3){ |
| | | } else if (num == 3) { |
| | | osdResult.setName(osdStr); |
| | | } |
| | | } |
| | |
| | | return osdResult; |
| | | } |
| | | |
| | | /** |
| | | * 针对利旧设备获取OSD的方法 |
| | | * @param serialNumber |
| | | * @param loginId |
| | | * @return |
| | | */ |
| | | public static OSDResult getOsdOld(String serialNumber, LLong loginId) { |
| | | OSDResult result = new OSDResult(); |
| | | NetSDKLib.NET_OSD_CUSTOM_TITLE osdInfo4 = new NetSDKLib.NET_OSD_CUSTOM_TITLE(); |
| | | osdInfo4.emOsdBlendType = NetSDKLib.NET_EM_OSD_BLEND_TYPE.NET_EM_OSD_BLEND_TYPE_MAIN; |
| | | NetSDKLib.NET_OSD_CUSTOM_TITLE reserve4 = new NetSDKLib.NET_OSD_CUSTOM_TITLE(); |
| | | osdInfo4.write(); |
| | | boolean e = false; |
| | | e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 0, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer()); |
| | | if (!e) { |
| | | log.error("e为空,尝试另一个通道"); |
| | | e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 1, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer()); |
| | | } |
| | | if(e) { |
| | | osdInfo4.read(); |
| | | NetSDKLib.NET_CUSTOM_TITLE_INFO[] stuCustomTitle = osdInfo4.stuCustomTitle; |
| | | for (NetSDKLib.NET_CUSTOM_TITLE_INFO net_custom_title_info : stuCustomTitle) { |
| | | String name = new String(net_custom_title_info.szText, StandardCharsets.UTF_8).trim(); |
| | | log.info("name:{}",name); |
| | | if(StringUtils.isNotEmpty(name) && name.contains("|")){ |
| | | String[] osdNames = name.split("\\|"); |
| | | //剔除掉空串 |
| | | // List<String> nonEmptyList = new ArrayList<>(); |
| | | // for (String osd : osdNames) { |
| | | // if (StringUtils.isNotEmpty(osd)) { |
| | | // nonEmptyList.add(osd); |
| | | // } |
| | | // } |
| | | result.setOSD1(osdNames[0]); |
| | | result.setOSD2(osdNames[1]); |
| | | result.setOSD3(osdNames[2]); |
| | | result.setName(osdNames[3]); |
| | | } |
| | | } |
| | | }else { |
| | | log.error(serialNumber,"利旧osd为空"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取单个配置 |
| | | * @param hLoginHandle 登陆句柄 |
| | | * @param nChn 通道号,-1 表示全通道 |
| | | * @param strCmd 配置名称 |
| | | * @param cmdObject 配置对应的结构体对象 |
| | | * @return 成功返回 true |
| | | */ |
| | | public static boolean GetDevConfig(LLong hLoginHandle, int nChn, String strCmd, Structure cmdObject) { |
| | | boolean result = false; |
| | | IntByReference error = new IntByReference(0); |
| | | int nBufferLen = 2*1024*1024; |
| | | byte[] strBuffer = new byte[nBufferLen]; |
| | | |
| | | if(netsdk.CLIENT_GetNewDevConfig( hLoginHandle, strCmd , nChn, strBuffer, nBufferLen,error,3000,null)) { |
| | | cmdObject.write(); |
| | | if (netsdk.CLIENT_ParseData(strCmd, strBuffer, cmdObject.getPointer(), |
| | | cmdObject.size(), null)) { |
| | | cmdObject.read(); |
| | | result = true; |
| | | } else { |
| | | System.err.println("Parse " + strCmd + " Config Failed!" + ToolKits.getErrorCodePrint()); |
| | | result = false; |
| | | } |
| | | } else { |
| | | System.err.println("调用失败"); |
| | | result = false; |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | } |