C # Video Monitoring series (5): client-send strings and videos (data capture) to the server)

Source: Internet
Author: User

 

Preface

Over the past few days, I have been eager to write server programs. All series of articles have been updated slowly. Sorry :)

 

Note:

This series of articles is limited to learning and communication and focus on the process. Due to the involvement of companies, source code download is not provided. Sorry !! But please rest assured that I will post the core, implementation, and other codes that can be pasted out, and strive to answer every question in the message as much as possible. Thank you for your attention and welcome to the discussion.

 

Series

1. C # Video Monitoring series (1): Preparation

2. C # Video Monitoring series (2): client-encapsulation API

3. C # Video Monitoring series (3): client-connection Server

4. C # Video Monitoring series (4): client-audio receiving and capturing

5. C # Video Monitoring series (5): client-send strings and videos (data capture) to the server)

 

Body

1. Send a string to the server

It is very simple to implement this function and is not very practical.

1. VC ++ Code:

MP4_ClientCommandtoServer (LPCTSTR) ctemp, sendcont, 400 );

2. C # Code:

PcHikClient. MP4_ClientCommandtoServer ("192.168.0.188", "Hello Server :)", 14 );

The description of this method can be found in the API documentation: the first parameter is the Server IP address, the second is the string to be sent, and the third parameter is the string length.

Ii. client-side Video Recording

Client video recording can be achieved through the MP4_ClientStartCapture or MP4_ClientStartCaptureFile functions in the API documentation (Hikvision Network Development Kit Programming Manual V4.7, from the source code of VC ++, we can see that it is implemented by the latter, which is simple and easy, but the server end does not have this function -_-#. However, MP4_ClientStartCapture is more flexible to write and store code by calling the callback, and can implement additional functions such as statistical information. Here, only the MP4_ClientStartCaptureFile of C # corresponding to VC ++ is provided.

1. VC ++ Code:

// Start recording
If (nn1> = 0)
{
Sprintf (filename, "d: \ mp4test1_d.mp4", capcount );
MP4_ClientStartCaptureFile (nn1, filename );
// MP4_ClientStartCapture (nn1 );
}
// Disable Video Recording
If (nn1> = 0)
MP4_ClientStopCapture (nn1 );

2. C # Code:

/// <Summary>
/// Start recording
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Private void btnStartCap_Click (object sender, EventArgs e)
{
PcHikClient. MP4_ClientStartCaptureFile (cs, "D :\\ mp4test00000.mp4 ");
}

/// <Summary>
/// Stop the video
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Private void btnStopCap_Click (object sender, EventArgs e)
{
PcHikClient. MP4_ClientStopCapture (cs );
}

The method is simple, but pay attention to the error corresponding to the MP4_ClientStartCaptureFile parameter in the previous post. Otherwise, the file cannot be created and false is always returned. Now, the previous SDK encapsulation API article has been updated. The specific error is as follows:

VC ++ prototype:

BOOL _ stdcall MP4_ClientStartCaptureFile (LONG StockHandle, LPTSTR FileName );

Previous versions:

Public static extern bool MP4_ClientStartCaptureFile (long StockHandle, string FileName );

Version after modification:

Public static extern bool MP4_ClientStartCaptureFile (int StockHandle, string FileName );

Pay attention to the Data Type Change of the StockHandle parameter. The MP4_ClientStopCapture parameter is also of the long data type, but it does not affect it. It doesn't matter if it is changed to int.

 

Legacy problems

The total playback time displayed for the saved mp4 file is three seconds different from the actual playback time. For example, the total playback time is 48 seconds, but the playback time is no longer 45. This is strange, but it does not affect the playback time much :)

 

End

The content in this chapter is still simple, and errors still occur in the corresponding data types. Therefore, you should pay attention to the following :)

 

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.