Пример #1
1
BOOL CSingleCamDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO: 在此添加额外的初始化代码
	//此处需要对SDK进行init初始化
	NET_DVR_Init();

	NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", TRUE);

	isLogin = FALSE;
	isPlaying = FALSE;

	hPlayWnd1 = GetDlgItem(IDC_ViewWindow)->m_hWnd;  //在程序初始化的时候就获取播放窗口的句柄
	hPlayWnd2 = GetDlgItem(IDC_ViewWindow2)->m_hWnd;
	m_ctrlDeviceIP1.SetAddress(192, 168, 3, 21);
	m_ctrlDeviceIP2.SetAddress(192, 168, 3, 22);
	GetDlgItem(IDC_BTN_PlayCam)->EnableWindow(FALSE); //初始状态,播放\停止和抓图按钮都是失能的 
	GetDlgItem(IDC_BTN_StopCam)->EnableWindow(FALSE); 
	GetDlgItem(IDC_BTN_SavePicture)->EnableWindow(FALSE);
	GetDlgItem(IDC_BTN_SavePicture2)->EnableWindow(FALSE);
	GetDlgItem(IDC_BTN_SaveRealData)->EnableWindow(FALSE);
	GetDlgItem(IDC_BTN_StopSave)->EnableWindow(FALSE);

	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
Пример #2
0
_XBool _XHIKCamera::init(_XCameraData &data)
{
	if(m_isInited) return XTrue;
	m_cameraWidth = data.w;
	m_cameraHeight = data.h;
	//width = &m_cameraWidth;
	//height = & m_cameraHeight;
	m_buffSize = m_cameraWidth * m_cameraHeight * 3;

	m_cameraTexWidth = m_cameraWidth;
	m_cameraTexHeight = m_cameraHeight;
	//初始化摄像头并连接设备
	NET_DVR_Init();	//初始化
	m_lUserID = NET_DVR_Login_V30(data.ipAddress,data.port,data.userName,data.pwd,&m_structDeviceInfo);
	if(m_lUserID < 0)	
	{//连接设备失败
		printf("Login error, %d\n", NET_DVR_GetLastError());
		NET_DVR_Cleanup();
		return XFalse;
	}
	//下面开始连接回调函数并分配内存空间
	m_dataRGB = createArrayMem<unsigned char>(m_buffSize);	//分配内存空间
	if(m_dataRGB == NULL) return XFalse;
	memset(m_dataRGB,0,m_buffSize);
	m_dataRGBOut = createArrayMem<unsigned char>(m_buffSize);
	if(m_dataRGBOut == NULL) return XFalse;

	haveNewFrame = &m_haveNewFrame;
	pOutRGB = m_dataRGB;

	NET_DVR_SetExceptionCallBack_V30(0,NULL,g_ExceptionCallBack,NULL);

	NET_DVR_CLIENTINFO ClientInfo = {0};
	ClientInfo.hPlayWnd = NULL;         //需要SDK解码时句柄设为有效值,仅取流不解码时可设为空
	ClientInfo.lChannel = 0;			//预览通道号
	ClientInfo.lLinkMode = 0;			//最高位(31)为0表示主码流,为1表示子码流0~30位表示连接方式:0-TCP方式;1-UDP方式;2-多播方式;3-RTP方式;
	ClientInfo.sMultiCastIP = NULL;		//多播地址,需要多播预览时配置

	//BOOL bPreviewBlock = XFalse;			//请求码流过程是否阻塞,0:否,1:是
	m_lRealPlayHandle = NET_DVR_RealPlay_V30(m_lUserID,&ClientInfo,NULL,NULL,XFalse);
	if(m_lRealPlayHandle < 0)
	{
		printf("NET_DVR_RealPlay_V30 error\n");
		NET_DVR_Logout(m_lUserID);
		NET_DVR_Cleanup();
		return XFalse;
	}

	if(!NET_DVR_SetRealDataCallBack(m_lRealPlayHandle,g_RealDataCallBack_V30,0))
	{
		printf("NET_DVR_SetRealDataCallBack error\n");
	}

	m_cameraTex.createTexture(m_cameraWidth,m_cameraHeight,COLOR_RGB);	//不允许进行2的n次方扩展,这回造成不兼容
	m_cameraSprite.init(m_cameraWidth,m_cameraHeight,0);

	m_haveNewFrame = XFalse;
	m_isInited = XTrue;
	return XTrue;
}
Пример #3
0
/*******************************************************************
      Function:   Demo_Capture
   Description:   Capture picture.
     Parameter:   (IN)   none 
        Return:   0--success£¬-1--fail.   
**********************************************************************/
int Demo_Capture()
{
    NET_DVR_Init();
    long lUserID;
    //login
    NET_DVR_DEVICEINFO_V30 struDeviceInfo;
    lUserID = NET_DVR_Login_V30("172.4.1.162", 8000, "admin", "12345", &struDeviceInfo);
    if (lUserID < 0)
    {
        printf("pyd1---Login error, %d\n", NET_DVR_GetLastError());
        return HPR_ERROR;
    }

    //
    NET_DVR_JPEGPARA strPicPara = {0};
    strPicPara.wPicQuality = 2;
    strPicPara.wPicSize = 0;
    int iRet;
    iRet = NET_DVR_CaptureJPEGPicture(lUserID, struDeviceInfo.byStartChan, &strPicPara, "./ssss.jpeg");
    if (!iRet)
    {
        printf("pyd1---NET_DVR_CaptureJPEGPicture error, %d\n", NET_DVR_GetLastError());
        return HPR_ERROR;
    }

    //logout
    NET_DVR_Logout_V30(lUserID);
    NET_DVR_Cleanup();

    return HPR_OK;

}
Пример #4
0
void CHaikangSDK::SDKInit()
{
	// 初始化
	NET_DVR_Init();
	//设置连接时间与重连时间
	NET_DVR_SetConnectTime(2000, 5);
	NET_DVR_SetReconnect(10000, true);
}
Пример #5
0
FYCameraLogin::FYCameraLogin(void)
{
	// 初始化
	NET_DVR_Init();
	//设置连接时间与重连时间
	NET_DVR_SetConnectTime(2000, 1);
	NET_DVR_SetReconnect(10000, true);

}
Пример #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    NET_DVR_Init();
    NET_DVR_SetConnectTime(2000, 1);
    NET_DVR_SetReconnect(10000, true);
}
Пример #7
0
int cgiMain(void)
{
	char *ip;
	ip = (char *) calloc(32, sizeof(char));

	//初始化
	NET_DVR_Init();

	NET_DVR_SetLogToFile(3,"./sdkLog");

	//设置链接时间与重连时间
	NET_DVR_SetConnectTime(2000,1);
	NET_DVR_SetReconnect(10000,true);

	//注册设备
	LONG lUserID;
	NET_DVR_DEVICEINFO_V30 struDevice;
	//strcpy(ip,GetIP());
	lUserID = NET_DVR_Login_V30("192.168.1.64""",8000,"admin","12345",&struDevice);
	if(lUserID < 0)
	{
		printf("Login in ERROR:%d\n",NET_DVR_GetLastError());
		NET_DVR_Cleanup();
		return 1;
	}
	printf("login success!\n");
	free(ip);
	
	cgiHeaderContentType("Text/html");
	//while(1){
		if(cgiFormSubmitClicked("reboot") == cgiFormSuccess)
		{
			TestRebootDVR(lUserID);
		}

		if(cgiFormSubmitClicked("Alarm") == cgiFormSuccess)
		{
			if(Demo_Alarm() == HPR_ERROR)
				goto EXIT;
		}
		
		if(cgiFormSubmitClicked("record") == cgiFormSuccess)
		{
			if(record() == HPR_ERROR)
				goto EXIT;
		}
	//}
	
EXIT:
	NET_DVR_Logout_V30(lUserID);
	NET_DVR_Cleanup();

	return 0;
}
Пример #8
0
DeviceHK::DeviceHK() {
	InfoL << endl;
	static onceToken token( []() {
		NET_DVR_Init();
		NET_DVR_SetDVRMessageCallBack_V31([](LONG lCommand,NET_DVR_ALARMER *pAlarmer,char *pAlarmInfo,DWORD dwBufLen,void* pUser){
			WarnL<<pAlarmInfo;
			return TRUE;
		},NULL);
	}, []() {
		NET_DVR_Cleanup();
	});
}
Пример #9
0
BOOL CVideoIntecomSrvApp::InitInstance()
{
    m_Mutex = new CMutex(FALSE,"VedioIntercomSrv030407",NULL);
    if(m_Mutex->Lock(1) == 0)
    {
        AfxMessageBox("已经有另外一个实例在运行");
        return FALSE;
    }
    if (!AfxSocketInit())
    {
        AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
        return FALSE;
    }

    AfxEnableControlContainer();

    // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.

#ifdef _AFXDLL
    Enable3dControls();			// Call this when using MFC in a shared DLL
#else
    Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
    NET_DVR_Init();
    SetDialogBkColor(RGB(233,233,233),RGB(0,0,0));
    CVideoIntecomSrvDlg dlg;
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
        // TODO: Place code here to handle when the dialog is
        //  dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
        // TODO: Place code here to handle when the dialog is
        //  dismissed with Cancel
    }

    // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
}
Пример #10
0
VideoWidget::VideoWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::VideoWidget)
{
    ui->setupUi(this);

    NET_DVR_Init();
    //设置连接时间与重连时间
//    NET_DVR_SetConnectTime(2000, 1);
//    NET_DVR_SetReconnect(10000, true);
    m_realplay =new RealPlay();
    ui->gridLayout->addWidget(m_realplay);
    m_realplay->play();

    //m_realplay->show();

}
Пример #11
0
void CPlayer::Init(HWND hNotifyWnd)
{
	m_hRenderWnd = NULL;
    m_exit       = TRUE;
    memset(m_buffer, 0x00, sizeof(m_buffer));
    ResetEvent(m_hExitEvent);
    m_hNotifyWnd  = hNotifyWnd;
	NAME(PlayM4_GetPort)(&m_index);
    //m_index = index_MTManager;
	m_hEventKill = NULL; 
	m_hEventInput = NULL;
	m_hThread = NULL;
	m_bStreamType = TRUE;
    m_streamParser.ClearBuf();
	memset(&m_rcRenderRect, 0, sizeof(RECT));

	NET_DVR_Init();//初始化DVR
	m_hkDVRUserID = -1;
	m_lPlayHandle = -1;
	m_hkLogout = FALSE;
	m_hkStopMonitor = FALSE;
}
Пример #12
0
void * HK_Store_Thread(void * para){

    /*info to login HK camera*/
    char HK_userName[] = "admin";
    char HK_password[] = "12345";
    int stopResult = 0;

    LONG lUserID = 0;

    LONG streamHandle = 0;
    //unsigned int NVR_recordHandle = 0;

    NET_DVR_DEVICEINFO_V30 struDeviceInfo;
    NET_DVR_CLIENTINFO ClientInfo = {0};
    //ClientInfo.hPlayWnd = NULL;
    ClientInfo.lChannel = 1;
    ClientInfo.lLinkMode = 0;
    ClientInfo.sMultiCastIP = NULL;


    RecordParas *t_para = (RecordParas *)para;
    HKcameraArgs hkargs;

    //hkargs.NVR_LoginID = t_para->NVR_LoginID;//nvr server loginID
    strcpy(hkargs.NAR_cameraID, t_para->cameraID);//the VolID in nvr server
    hkargs.block_flag = 0;
    hkargs.NAR_recordHandle = 0;
    hkargs.HK_streamHandle = &streamHandle;

    while(1){
    	//-----------Init
    	NET_DVR_Init();
        hkargs.block_flag = 0;

    	//------------Set Connecttime and ReconnectTime
    	NET_DVR_SetConnectTime(2000,1);
    	NET_DVR_SetReconnect(10000,TRUE);

    	//-------------HKLogin
    	lUserID = NET_DVR_Login_V30(t_para->cameraIP, t_para->cameraPort, HK_userName, HK_password, &struDeviceInfo);
    	if(lUserID < 0){
    	    syslog(LOG_ERR,"connect HK IPC %s failed! errorCode: %d\n", t_para->cameraIP, NET_DVR_GetLastError());
    	    NET_DVR_Cleanup();//clear all the info
            continue;
    	}
        syslog(LOG_ERR,"connect HK IPC %s sucess!\n", t_para->cameraIP);

	//set exception callback function
    	NET_DVR_SetExceptionCallBack_V30(0, NULL, HK_RP_Exp_Callback, &hkargs);

	//get data stream and store
   	streamHandle = NET_DVR_RealPlay_V30(lUserID, &ClientInfo, HK_Store_CallBack, &hkargs, 0);
        if(streamHandle < 0){
            NET_DVR_Logout(lUserID);//get wrong handle ,logout
            NET_DVR_Cleanup();
            continue;
    	}
    	while(!hkargs.block_flag){ 
    	}
        stopResult = NET_DVR_StopRealPlay(streamHandle);
        syslog(LOG_INFO,"(InHKTransdata) stoped real play ? result:%d\n", stopResult);
        NET_DVR_Logout_V30(lUserID);
        syslog(LOG_INFO,"(InHKTransdata) HKcamera Logout(loginID was %d)\n",lUserID);
        NET_DVR_Cleanup();
        if(hkargs.block_flag == 1){
			break;
		}
    }
	return NULL;
}
Пример #13
0
void HikNetHelper::initLibrary() {
    if(_referenceLib <= 0) {
        NET_DVR_Init();
    }
    _referenceLib++;
}