C # video Surveillance series (3): Client--Connect to server and preview

Source: Internet
Author: User
Tags win32 root directory

1. Copy the following four DLLs to the System32 directory, which are all in the bin directory of the root directory

DS40xxSDK.dll

Hikclient.dll

HikPlayM4.dll

HikServer.dll

2. First with the client net clients with a Demo (Soft Decdoe) run under the confirmation no problem and then according to VC + + Client example to write the corresponding C # code.

3. It is best to install a Microsoft Visual C + + 6.0 so that you can run the VC + + example and debug it. Note that he is Win32 release, you need to switch to Win32 debug mode in order to break the debug!!

4. Open API document Hikvision Card Network Development Package Programming manual V4.7, in the doc directory.

5. Code analysis and writing the corresponding C # code

5.1 Chapter II programming instructions in the sixth, we can see the order of the API in turn, can be based on the function name directly in the code search call order, it is not difficult to find, in the HKVisionDlg.cpp OnInitDialog method can see the following two lines of code:

MP4_ClientSetNetPort(5050,6050);

    MP4_ClientStartup(WM_MYCOMMAND,this->m_hWnd);

Obviously this is called the API, the other code does not care, then I translate this code into the C # WinForm Form1_Load event, and also call the API (packaged SDK please see article):

PcHikClient.MP4_ClientSetNetPort(5050, 6050);
            PcHikClient.MP4_ClientStartup(PcHikClient.WM_USER + 1, this.Handle);

5.2 Depending on the Start button event on the interface to find the key connection to the server, as follows:

if (M_showmode = 0)
{
Mp4_clientsetshowmode (normalmode,0);
}
Else
{
Mp4_clientsetshowmode (Overlaymode,colorref (0XFF00FF));
}

NN1=NN2=NN3=NN4 =-1;

int itemp = M_shownum;
Char ips[256];

sprintf (IPs, "%s", M_ipadd);

   
HWnd5 = M_video5. GetSafeHwnd ()//
Aa5.m_bremotechannel = 0;
Switch (m_linktype)
{
Case 0:
Aa5.m_bsendmode = Tcpmode;
Break
Case 1:
Aa5.m_bsendmode = Udpmode;
Break
Case 2:
Aa5.m_bsendmode = multimode;
Break
Case 3:
Aa5.m_bsendmode = dialing;
Break
Case 4:
Aa5.m_bsendmode = Audiodetach;
Break
Default
Aa5.m_bsendmode = Tcpmode;
Break
}

aa5.m_sipaddress = IPs;
2003.12.2
If you want to record only, without decoding, you can set M_hshowvideo to null
If you are just want to record without decode on client side,
Please set M_hshowvideo as NULL
#if defined Record_only
Aa5.m_hshowvideo = NULL;
#else
Aa5.m_hshowvideo = HWnd5;
#endif

Add 2003.12.2
M_nimgformat indicates the image format you want to get
relies on server-side settings. If not set, gets the default format for the server
M_nimgformat indicates the "picture format" on the client side,
It depends on the setting of Server side.
Aa5.m_nimgformat = 0; Request CIF Format
Aa5.m_nimgformat = 1; Request QCIF Format

Aa5.m_susername = "123";
Aa5.m_suserpassword= "W";
Aa5.m_busercheck = TRUE;

Mp4_clientsetttl (64);
NN1 = Mp4_clientstart (&aa5,readdatacallback);
if (nn1 = = 1)
{
MessageBox ("error");
Return
}
//
BOOL Breturn;
Breturn = Mp4_clientrigisterdrawfun (nn1,drawfun,0);
Switch (m_delaytype)
{
Case 0:
Mp4_clientsetbuffernum (nn1,40);
Mp4_clientsetplaydelay (nn1,580);
Break
Case 1:
Mp4_clientsetbuffernum (nn1,15);
Mp4_clientsetplaydelay (nn1,40);
Break
Case 2:
Mp4_clientsetbuffernum (nn1,15);
Mp4_clientsetplaydelay (nn1,0);
Break
Case 3:
Mp4_clientsetbuffernum (nn1,0);
Mp4_clientsetplaydelay (nn1,0);
Break
}


Mp4_clientthrowbframe (Nn1,m_bframenum);
Mp4_clientsetcappiccallback (Nn1,cappicfun);

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.