Introduction
Although I have learned VC + + Yinianbanzai, still feel stretched, fortunately have vckbase help, did learn a lot of things, www.vckbase.com also became every time I go to the People's Network (you do not know, I accept the most stringent management, on the civil network is to apply). Recently in doing a communication program, real-time voice and video communication is of course everyone likes. This article will show you a solution for real time voice communication in LAN environment (video This piece is doing, estimated soon to be able to be released), WinXP Environment Test effect is good, and have network congestion processing mechanism, you may as well see.
This paper is based on the 26th issue of Mr. Yi Yiming's "audio recorder program based on API", which is deeply appreciated. The similarities will no longer be discussed and the following developments are mainly made:
(1) The use of multithreading mechanism to achieve recording, network transmission, playback at the same time.
(2) Network congestion processing to ensure that data is not lost.
Example Program run Screen:
Below and look at me carefully:
(i) first defines a sound data "block"
struct CAudioData
{
PBYTE lpdata; //指向语音数据,注意这里内存区域是动态申请释放的
DWORD dwLength;//语音数据长度
}Next, declare two loops and related pointers.
//InBlocks,OutBlocks非别为两个常数
CAudioData m_AudioDataIn[InBlocks],m_AudioDataOut[OutBlocks];
int nAudioIn, nSend, //录入、发送指针
nAudioOut, nReceive;//接收、播放指针For recording and playback both exist and network synchronization problem, mainly rely on these pointers to coordinate