package com.SDK.HCNetSDK;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import cc.eguid.FFmpegCommandManager.FFmpegManager;
import cc.eguid.FFmpegCommandManager.FFmpegManagerImpl;
import com.dfzx.common.util.CommonKit;
import com.sun.jna.examples.win32.W32API.HWND;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
import java.util.HashMap;
import java.util.Map;
import javafx.scene.Camera;
import org.apache.commons.lang.StringUtils;
/**
* Created by Hanlex.Liu on 2018/9/22 11:55.
*/
public class HCNetTools {
static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo;//设备信息
HCNetSDK.NET_DVR_IPPARACFG m_strIpparaCfg;//IP参数
HCNetSDK.NET_DVR_CLIENTINFO m_strClientInfo;//用户参数
boolean bRealPlay;//是否在预览.
String m_sDeviceIP;//已登录设备的IP地址
NativeLong lUserID;//用户句柄
NativeLong lPreviewHandle;//预览句柄
NativeLongByReference m_lPort;//回调预览时播放库端口指针
FFmpegManager manager;//rstp转rmtp工具
//FRealDataCallBack fRealDataCallBack;//预览回调函数实现
public HCNetTools()
{
JPopupMenu.setDefaultLightWeightPopupEnabled(false);//防止被播放窗口(AWT组件)覆盖
lUserID = new NativeLong(-1);
lPreviewHandle = new NativeLong(-1);
m_lPort = new NativeLongByReference(new NativeLong(-1));
//fRealDataCallBack= new FRealDataCallBack();
}
/**
* 初始化资源配置
*/
public int initDevices(){
if(!hCNetSDK.NET_DVR_Init()) return 1;//初始化失败
return 0;
}
/**
* 设备注册
* @param name 设备用户名
* @param password 设备登录密码
* @param ip IP地址
* @param port 端口
* @return 结果
*/
public int deviceRegist(String name,String password,String ip,String port){
if (bRealPlay){//判断当前是否在预览
return 2;//"注册新用户请先停止当前预览";
}
if (lUserID.longValue() > -1){//先注销,在登录
hCNetSDK.NET_DVR_Logout_V30(lUserID);
lUserID = new NativeLong(-1);
}
//注册(既登录设备)开始
m_sDeviceIP = ip;
m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V30();//获取设备参数结构
lUserID = hCNetSDK.NET_DVR_Login_V30(m_sDeviceIP,(short)Integer.parseInt("8000"),name,password, m_strDeviceInfo);//登录设备
long userID = lUserID.longValue();
if (userID == -1){
m_sDeviceIP = "";//登录未成功,IP置为空
return 3;//"注册失败";
}
return 0;
}
/**
* 获取设备通道
*/
public int getChannelNumber(){
IntByReference ibrBytesReturned = new IntByReference(0);//获取IP接入配置参数
boolean bRet = false;
int iChannelNum = -1;
m_strIpparaCfg = new HCNetSDK.NET_DVR_IPPARACFG();
m_strIpparaCfg.write();
Pointer lpIpParaConfig = m_strIpparaCfg.getPointer();
bRet = hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_IPPARACFG, new NativeLong(0), lpIpParaConfig, m_strIpparaCfg.size(), ibrBytesReturned);
m_strIpparaCfg.read();
String devices = "";
if (!bRet){
//设备不支持,则表示没有IP通道
for (int iChannum = 0; iChannum < m_strDeviceInfo.byChanNum; iChannum++){
devices = "Camera" + (iChannum + m_strDeviceInfo.byStartChan);
}
}else{
for(int iChannum =0; iChannum < HCNetSDK.MAX_IP_CHANNEL; iChannum++) {
if (m_strIpparaCfg.struIPChanInfo[iChannum].byEnable == 1) {
devices = "IPCamera" + (iChannum + m_strDeviceInfo.byStartChan);
}
}
}
if(StringUtils.isNotEmpty(devices)){
if(devices.charAt(0) == 'C'){//Camara开头表示模拟通道
//子字符串中获取通道号
iChannelNum = Integer.parseInt(devices.substring(6));
}else{
if(devices.charAt(0) == 'I'){//IPCamara开头表示IP通道
//子字符创中获取通道号,IP通道号要加32
iChannelNum = Integer.parseInt(devices.substring(8)) + 32;
}else{
return 4;
}
}
}
return iChannelNum;
}
public void shutDownDev(){
//如果已经注册,注销
if (lUserID.longValue() > -1){
hCNetSDK.NET_DVR_Logout_V30(lUserID);
}
hCNetSDK.NET_DVR_Cleanup();
}
public static void main(String[] args) {
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/ZIP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/ZIP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/ZIP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/EXE.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 24 条
- 1
![avatar](https://profile-avatar.csdnimg.cn/9be1921cc92e4ff09d65e42381df62da_qq_36720088.jpg!1)
Hanlex-Liu
- 粉丝: 62
- 资源: 5
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
- 1
- 2
前往页