public class HC_DVRManager {
private final static String TAG = “HC_DEBUG”;
public final static String ACTION_START_RENDERING = “action_start_rendering”;
public final static String ACTION_DVR_OUTLINE = “action_dvr_outline”;
/**
* 设备信息
* 模拟通道数bychannum
* 数字通道数byipchanum
*/
private NET_DVR_DEVICEINFO_V30 deviceInfo_V30 = null;
/**
* 登入标记 -1未登入,0已登入
*/
private int m_iLogID = -1;
/**
* 播放标记 -1未播放,0正在播放
*/
private int m_iPlayID = -1;
private int m_iPort = -1;
private String ip;
private int port;
private String username;
private String password;
private int channel;
private SurfaceHolder holder;
/**
* 用于发广播的上下文
*/
private Context context;
private static HC_DVRManager manager = null;
private HC_DVRManager() {
}
public static synchronized HC_DVRManager getInstance() {
if (manager == null) {
manager = new HC_DVRManager();
}
return manager;
}
/**
* 设置播放设备信息
*
* @param bean
*/
public void setDeviceBean(DeviceBean bean) {
this.ip = bean.getIP();
this.port = Integer.parseInt(bean.getPort());
this.username = bean.getUserName();
this.password = bean.getPassWord();
this.channel = Integer.parseInt(bean.getChannel());
}
/**
* 设置播放视口
* @param holder
*/
public void setSurfaceHolder(SurfaceHolder holder) {
this.holder = holder;
}
/**
* 用于发送广播的上下文
* @param context
*/
public void setContext(Context context) {
this.context = context;
}
public void initSDK() {
if (m_iPlayID >= 0) {
stopPlay();
}
if (HCNetSDK.getInstance().NET_DVR_Init()) {
Log.i(TAG, “初始化SDK成功!”);
} else {
Log.e(TAG, “初始化SDK失败!”);
}
}
public void loginDevice() {
deviceInfo_V30 = new NET_DVR_DEVICEINFO_V30();
m_iLogID = HCNetSDK.getInstance().NET_DVR_Login_V30(ip, port, username, password, deviceInfo_V30);
System.out.println(“下面是设备信息************************”);
System.out.println(“userId=” + m_iLogID);
System.out.println(“通道开始=” + deviceInfo_V30.byStartChan);
System.out.println(“通道个数=” + deviceInfo_V30.byChanNum);
System.out.println(“设备类型=” + deviceInfo_V30.byDVRType);
System.out.println(“ip通道个数=” + deviceInfo_V30.byIPChanNum);
if (m_iLogID < 0) {
Log.e(TAG, “登入设备失败!” + getErrorMsg(HCNetSDK.getInstance().NET_DVR_GetLastError()));
} else {
Log.i(TAG, “登入设备成功!”);
}
}
先发到这 ,原因是到这本人就连接不上了 ,假如连接上了userId应该不等于-1 但是本人的一直为-1 并且跳入if,显示log失败,求指导释什么问题,本人添加联网权限了,本人用的android studio
40
private boolean initeSdk() { // get an instance and init net sdk m_oHCNetSDK = new HCNetSDK(); if (null == m_oHCNetSDK) { return false; } if (!m_oHCNetSDK.NET_DVR_Init()) { return false; } // init player m_oPlayerSDK = Player.getInstance(); if (m_oPlayerSDK == null) { return false; } return true; }