我目前正在建立用于实时视频通话的客户端-服务器网络。到目前为止,我可以无声流播视频:
private void connect_click(object sender, EventArgs e)
{
client = new TcpClient(SERVER_IP, PORT_NO);
nwStream = client.GetStream();
Thread thr = new Thread(new ThreadStart(SendImage));
thr.Start();
}
private void SendImage()
{
while (true) {
try
{
byte[] test = ImageToByte(ReduceQuality(bmp));
nwStream.Write(test, 0, test.Length);
}
catch (Exception) { }
}
}
如何实现语音部分?我曾想过要从麦克风读取另一个线程并将其发送,但是我不能确保语音和帧之间的同步吗?