Introduction
This application allows any 2 persons on the LAN/Intranet (possibly Internet too) to have video conference. There are several video conference applications existing today. Each has its own performance enhancement techniques. The major problem in video conference is that the size of video frames is too big for transmission. Hence the performance is based on the codec used for encoding and decoding the frame. I am using Fast h263 Encoder library which gives better compression rate at high speed. This application can also be used on the Internet with little modification.
Recording and Playing Audio
I have used the same RecordSound
and PlaySound
classes which I have used in my previous voice conference application. Here, I will provide a brief overview of how to use this RecordSound
and PlaySound
classes.
record=new RecordSound(this);
record->CreateThread();
play=new PlaySound1(this);
play->CreateThread();
record->PostThreadMessage(WM_RECORDSOUND_STARTRECORDING,0,0);
play->PostThreadMessage(WM_PLAYSOUND_STARTPLAYING,0,0);
play->PostThreadMessage(WM_PLAYSOUND_PLAYBLOCK,size,(LPARAM)data);
record->PostThreadMessage(WM_RECORDSOUND_STOPRECORDING,0,0);
play->PostThreadMessage(WM_PLAYSOUND_STOPPLAYING,0,0);
record->PostThreadMessage(WM_RECORDSOUND_ENDTHREAD,0,0);
play->PostThreadMessage(WM_PLAYSOUND_ENDTHREAD,0,0);
Video Capture
Video capture is done using VFW (Video For Windows) API. It provides support for capturing the video from web cam. VideoCapture.h and VideoCapture.cpp are the files which contain the code for complete video capture process.
Here are the brief details of how to use this class....
vidcap=new VideoCapture();
vidcap->SetDialog(this);
vidcap->Initialize();
this->m_bmpinfo=&vidcap->m_bmpinfo;
vidcap->StartCapture();
vidcap->StopCapture();
vidcap->Destroy();
If you do this much work, your code will compile well....but linker will trouble you. You must link the suitable libraries....
#pragma comment(lib,"vfw32")
#pragma comment(lib,"winmm")
Displaying the Captured Video Frame
There are various methods and APIs for displaying the captured frame. You can use SetDIBitsToDevice()
method to directly display the frame. But this is quite slow as it is based on Graphics Device Interface (GDI) functions. The better method is to use DrawDib
API to draw the frame. The DrawDib
functions provide high performance image-drawing capabilities for device-independent bitmaps (DIBs). DrawDib
functions write directly to video memory, hence provide better performance.
Here is the brief view of how to use DrawDib
API to display frame:
HDRAWDIB hdib=::DrawDibOpen();
::DrawDibBegin(hdib,...);
::DrawDibDraw(hdib,...);
::DrawDibEnd(hdib);
::DrawDibClose(hdib);
Encoder and Decoder Library
Encoder
I have used fast h.263 encoder library for the encoding. This library was the modified version of Tmndecoder to make it more faster for real time encoding. I have converted this library from C to C++ so that it can be integrated into any Windows application easily. I have removed some of the unnecessary codes/files from the fast h263 library. Also moved definitions and declarations in their proper .h and .cpp files.
Brief view of usage of H263 Encoder library
CParam cparams;
cparams.format = CPARAM_QCIF;
InitH263Encoder(&cparams);
InitLookupTable();
WriteByteFunction = OwnWriteFunction;
ConvertRGB2YUV(IMAGE_WIDTH,IMAGE_HEIGHT,data,yuv);
cparams.format=CPARAM_QCIF;
cparams.inter = CPARAM_INTRA;
cparams.Q_intra = 8;
cparams.data=yuv;
CompressFrame(&cparams, &bits);
Decoder
This is the modified version of tmndecoder (H.263 decoder). It was in ANSI C. I have converted it into C++ so that it can be integrated into any Windows application. I have removed some of the files which had display and file storing functions. I have removed the unnecessary code and also added some new files.
Original library dealt with files. It was not suitable to use for real time decoding. I have done some major changes so that it can be easily integrated into the application for real time decoding process. Now one can use this library for decoding H263 frames. This library is quite fast and gives better performance.
Usage of Decoder .....
InitH263Decoder();
DecompressFrame(data,size,rgbdata,buffersize);
ExitH263Decoder();
How to run the application
Copy the executable file into 2 different machines A & B which are on LAN. Run both the applications. From machine A (or B), select Connect menu item, and in the popup dialog box, enter the name or IP Address of the other host (B), and press Connect button. In the other machine (B), Accept/Reject dialog box will appear. Press Accept button. In the machine A, notification dialog box will get displayed. Press OK to begin the conference.
That's it....Enjoy......!!!
Acknowledgement
I likes to thank Paul Cheffers for his audio recording and playing sound classes. You are seeing this videonet application here....it is because of Open Source libraries contributed by open minded persons. I am grateful to the developer Karl Lillevold of Tmndecoder and Roalt Aalmoes of h.263 fast encoder library for making it free.
If you have any queries or suggestions, please feel free to mail me at nsry2002@yahoo.co.in.