Point-to-Point Video Conferencing program: videonet (with source code)-http://www.chinavideo.org/index.php? Option = com_content & task = vie

Source: Internet
Author: User
Point-to-Point Video Conferencing program: videonet (including source code)
Author: nagareshwar talekar
2006-10-08

Source code download

This program can be used for two people to perform video conferences on the LAN/Intranet (or the Internet. There are many video conferencing programs, each of which has its own performance improvement technology. The main problem is that the size of video frames in video conferencing is too large for transmission. Therefore, the performance depends on the encoding/Decoding of frames. I used the quick h263 encoding library to increase the compression rate. This program can also be used on the Internet with some minor changes.

Recording and playing audio

I used the recordsound and playsound classes in my previous speech Conferencing program. Here I will provide a summary of the use of the recordsound and playsound classes.

// Create and Start Recorder Thread   record=new RecordSound(this);   record->CreateThread();// Create and Start Player Thread   play=new PlaySound1(this);   play->CreateThread();// Start Recording   record->PostThreadMessage(WM_RECORDSOUND_STARTRECORDING,0,0);// Start Playing   play->PostThreadMessage(WM_PLAYSOUND_STARTPLAYING,0,0);// During audio recording, data will be available in the OnSoundData// callback function of the RecordSound class. Here, you can place// your code to send the data to remote host...// To play the data received from the remote host   play->PostThreadMessage(WM_PLAYSOUND_PLAYBLOCK,size,(LPARAM)data);// Stop Recording   record->PostThreadMessage(WM_RECORDSOUND_STOPRECORDING,0,0);// Stop Playing   play->PostThreadMessage(WM_PLAYSOUND_STOPPLAYING,0,0);// At last, to Stop the Recording Thread   record->PostThreadMessage(WM_RECORDSOUND_ENDTHREAD,0,0);// To stop playing thread...   play->PostThreadMessage(WM_PLAYSOUND_ENDTHREAD,0,0);

Video Capture

You can use the VFW (video for Windows) API to capture videos. It allows you to use webcam to capture videos. Videocapture. h and videocapture. cpp contain the code used to process video capture.

The following code illustrates how to use this class:

// Create instance of Class   vidcap=new VideoCapture();// This is later used to call display function of the main// dialog class when the frame is captured...   vidcap->SetDialog(this);// This does lot of work, including connecting to the driver// and setting the desired video format. Returns TRUE if// successfully connected to videocapture device.   vidcap->Initialize();// If successfully connected, you can get the BITMAPINFO// structure associated with the video format. This is later// used to display the captured frame...   this->m_bmpinfo=&vidcap->m_bmpinfo;// Now you can start the capture....   vidcap->StartCapture();// Once capture is started, frames will arrive in the "OnCaptureVideo"// callback function of the VideoCapture class. Here you call the// display function to display the frame.// To stop the capture   vidcap->StopCapture();// If your job is over....just destroy it..   vidcap->Destroy();

To compile the above Code, you should link the appropriate Library:

#pragma comment(lib,"vfw32")#pragma comment(lib,"winmm")

Display captured video frames

There are many methods and APIs for displaying captured videos. You can use the setdibitstodevice () method for direct display, but the function given to GDI is very slow. A better way is to use the drawdib API for display. The drawdib function provides a high-performance graphical rendering capability for device-independent Bitmap (dibs. The drawdib function directly writes data to the video memory, so the performance is better.

The following code digest demonstrates the use of the drawdib API to display video frames.

// Initialize DIB for drawing...   HDRAWDIB hdib=::DrawDibOpen();// Then call this function with suitable parameters....   ::DrawDibBegin(hdib,...);// Now, if you are ready with the frame data, just invoke this// function to display the frame   ::DrawDibDraw(hdib,...);// Finally, termination...   ::DrawDibEnd(hdib);   ::DrawDibClose(hdib);

Codec Library

Encoder:
I use the quick H.263 encoding library for encoding. This library is a modified tmndecoder version that makes real-time Encoding faster. I have converted the library from C to C ++, which can be easily used in any windows application. I removed unnecessary code and files from the Quick h263 encoding library and removed some definitions and declarations in the. h and. cpp files.
The following describes how to use the h263 encoding library:

// Initialize the compressor   CParam cparams;   cparams.format = CPARAM_QCIF;   InitH263Encoder(&cparams);//If you need conversion from RGB24 to YUV420, call this   InitLookupTable();// Set up the callback function// OwnWriteFunction is the global function called during// encoding to return the encoded data...   WriteByteFunction = OwnWriteFunction;// For compression, data must be in the YUV420 format...// Hence, before compression, invoke this method   ConvertRGB2YUV(IMAGE_WIDTH,IMAGE_HEIGHT,data,yuv);// Compress the frame.....   cparams.format  = CPARAM_QCIF;   cparams.inter   = CPARAM_INTRA;   cparams.Q_intra = 8;   cparams.data=yuv;    //  Data in YUV format...   CompressFrame(&cparams, &bits);// You can get the compressed data from the callback function// that you have registerd at the begining...// Finally, terminate the encoder// ExitH263Encoder();

Decoder:

This is a modified version of the tmndecoder (H.263 decoder. I use ANSI C to convert it to C ++ so that it can be conveniently used in Windows applications. I removed some files for display and file processing, removed unnecessary code, and added some new files.

Some files in the original library are not suitable for real-time decoding. I have made changes to make it suitable for real-time decoding. Now, you can use this database to decode h263 frames. This database is very fast and has good performance.

Decoding Method:

//Initialize the decoder   InitH263Decoder();// Decompress the frame....// > rgbdata must be large enough to hold the output data...// > decoder produces the image data in YUV420 format. After//   decoding, it is converted into RGB24 format...   DecompressFrame(data,size,rgbdata,buffersize);// Finaly, terminate the decoder   ExitH263Decoder();

How to run a program
Copy executable files to two different machines on the LAN: A and B. Run them. In machine A (or B), select the connect menu bar, enter the name or IP address of machine B in the pop-up dialog box, and then press the connect button to go to another machine (B) the accept/reject dialog box is displayed. Press the accept button. In machine a, a notification dialog box is displayed. Press OK to start the meeting.

That ''' it... Enjoy ......!!!

Thanks:

I would like to thank Paul cheffers for providing his audio recording and playing class. Thanks to the open-source libraries provided by open-source people, you can see the videonet program. I am grateful to roalt aalmoes, a developer of tmndecoder's Karl lillevold and H.263 quick coding libraries, for free.

Last Updated)

Http://www.chinavideo.org/index.php? Option = com_content & task = view & id = 303 & Itemid = 5

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.