You can also use C # As a video monitoring client.

Source: Internet
Author: User

A few days ago, I saw yuanyouFarmer's uncleThe C # Video Monitoring series has been written to encapsulate hikvision boards. The projects involved in these days have entered the subsequent stages, and performance testing is now underway. test the stability and concurrency of the Streaming Media Server. Let's take a look at the effects of-concurrent video processing. The Department does not have so many computers for testing and simply writes a simulated Client AccessProgramTo test the server program performance. streaming media is implemented in the C ++ language. Now I want to use C # To communicate with it, which involves the following aspects. for example, I want to view a video on the DVR/DVS OF THE frontend Dahua. Here we use streaming media to connect to the video monitoring device, instead of directly connecting the client to the device, streaming Media receives the data and forwards it to the client that wants to preview the video one by one. The client uses Dahua's playsdk to decode and play the video. (For devices directly connected through Dahua netsdk, you can download the SDK package from the Dahua website. The latest version is 3.4, which provides encapsulated C # access to the demo program; streaming Media supports the access of monitoring devices from multiple vendors, including haikang and Dahua)

Client video preview process

1) if the current screen is being previewed, send the Stop command to preview the screen to the server and close the video.

Generally, play_stopsound, play_stop, and play_closestream functions are called to stop this video preview.

2) Send a video preview request

Open the video input stream play_openstream, play_play, play_playsound (enable audio at the same time). Then, you can enable a video data receiving thread to provide the received video data to the function play_inputdata for decoding and playing.

Generally, in C ++, we develop the network transmission module and use struct to encapsulate and organize communication packets. Then, the streaming media client program developed by C # needs to communicate with streaming media on the server, you will see how to convert a struct into a byte array, and how to restore the received byte array data to a struct object. here we are involved in the interoperability between C # and other languages, that is, the so-called P/invoke technology, mainly system. runtime. use of the marshal class in the interopservices namespace. (For more information, see tuyile006.ArticleStruct and byte [] are converted to each other (implemented using the marshal class), and there is a data type conversion between C ++ and C #, such as unsigned char --> byte, char * --> string, hwnd --> intptr, lOng/DWORD --> int, pass NULL pointer using intptr. zero and so on (farmer's uncle in his C # Video Monitoring series (14): Summary post -- VC ++ code into C # The summary is also introduced, the C # encapsulated hikvision DVR client SDK can be used for reference)

Next we will implementCode, Compiled, run it. A prompt is displayed, indicating that the entry address of a function cannot be found in the specified DLL file. Check the code. It turns out that play_openstream is too careless to define play_openstream as play_openstream, pay attention to writing programs later. (The function call is unsuccessful. This is generally caused by a function definition error. For example, if the function name or parameter data type is incorrect, refer to the bughunter article and refer to C # calling the DLL of C ++ and cannot find the entry point) the final effect is poor. Don't laugh. Picture 1 is a file stream and picture 2 is a real-time video stream data.

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.