我是语音流的初学者
我尝试构建一个语音聊天应用程序我得出结论:
- 我应该在套接字中使用 UPD 作为 ProtocolType
- 我应该使用 NAudio 流媒体
发送机制(伪代码):
private void but_Click(object sender, EventArgs e)
{
if (sourceList.SelectedItems.Count == 0) return;
int deviceNumber = sourceList.SelectedItems[0].Index;
NAudio.Wave.WaveIn sourceStream = new NAudio.Wave.WaveIn();
sourceStream.DeviceNumber = deviceNumber;
sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels);
sourceStream.DataAvailable += new EventHandler<NAudio.Wave.WaveInEventArgs>(sourceStream_DataAvailable);
sourceStream.StartRecording();
}
private void sourceStream_DataAvailable(object sender, NAudio.Wave.WaveInEventArgs e)
{
if (sourceStream== null) return;
send_UPD(e.Buffer, e.BytesRecorded);//sending data UPD
}
我认为发送将成功,接收者将恢复字节数组
发送机制(伪代码):
NAudio.Wave.DirectSoundOut waveOut = new NAudio.Wave.DirectSoundOut();
NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(/*my recived array of byte*/);
waveOut.Init(waveIn);
waveOut.Play();
我的问题
是上述是否属实,我可以用接收器中的字节数组做什么(我怎么玩它)???