private void gpcst_BufferFull(byte[] buffer) { // Compress data. if (gpcst.Count > 0) { byte[] encodedData = null; if (m_Codec == 0) { encodedData = G711.Encode_aLaw(buffer, 0, buffer.Length); } else if (m_Codec == 1) { encodedData = G711.Encode_uLaw(buffer, 0, buffer.Length); } // We just sent buffer to target end point. foreach (IPEndPoint k in gpcst) { VUdpServer.SendPacket(encodedData, 0, encodedData.Length, k); } } else { VWaveIn.Stop(); VWaveIn = null; checkedListBox1.Items.Clear(); gpcst.Clear(); button10.Enabled = false; } }
private void audioWaveIn_BufferFull(byte[] buffer) { // Compress data. byte[] encodedData = null; if (m_Codec == 0) { encodedData = G711.Encode_aLaw(buffer, 0, buffer.Length); } else if (m_Codec == 1) { encodedData = G711.Encode_uLaw(buffer, 0, buffer.Length); } //Send to all other clients foreach (User usr in Main.Surgery.ConnectedClients) { if (!usr.MyName.Equals(Main.User.MyName)) { audioServer.SendPacket(encodedData, 0, encodedData.Length, new IPEndPoint(IPAddress.Parse(usr.MyIPAddress), audioPort)); } } //If client, send to master if (!Main.User.IsMaster) { audioServer.SendPacket(encodedData, 0, encodedData.Length, new IPEndPoint(IPAddress.Parse(Main.Surgery.Master.MyIPAddress), audioPort)); } }
/// <summary> /// This method is called when recording buffer is full and we need to process it. /// </summary> /// <param name="buffer">Recorded data.</param> private void m_pWaveIn_BufferFull(byte[] buffer) { // Compress data. byte[] encodedData = null; if (m_Codec == 0) { encodedData = G711.Encode_aLaw(buffer, 0, buffer.Length); } else if (m_Codec == 1) { encodedData = G711.Encode_uLaw(buffer, 0, buffer.Length); } // We just sent buffer to target end point. m_pUdpServer.SendPacket(encodedData, 0, encodedData.Length, m_pTargetEP); }
/// <summary> /// Sends test sound to target end point. /// </summary> private void SendTest() { try { using (FileStream fs = File.OpenRead(m_PlayFile)) { byte[] buffer = new byte[400]; int readedCount = fs.Read(buffer, 0, buffer.Length); long lastSendTime = DateTime.Now.Ticks; while (m_IsSendingTest && readedCount > 0) { // Compress data. byte[] encodedData = null; if (m_Codec == 0) { encodedData = G711.Encode_aLaw(buffer, 0, buffer.Length); } else if (m_Codec == 1) { encodedData = G711.Encode_uLaw(buffer, 0, buffer.Length); } // Send and read next. m_pUdpServer.SendPacket(encodedData, 0, encodedData.Length, m_pTargetEP); readedCount = fs.Read(buffer, 0, buffer.Length); Thread.Sleep(25); lastSendTime = DateTime.Now.Ticks; } } if (m_IsRunning) { this.Invoke(new MethodInvoker(this.OnAudioStopped)); } } catch (Exception x) { MessageBox.Show(null, "Error: " + x.ToString(), "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void audio_BufferFull(byte[] buffer) { // Compress data. byte[] encodedData = null; if (m_Codec == 0) { encodedData = G711.Encode_aLaw(buffer, 0, buffer.Length); } else if (m_Codec == 1) { encodedData = G711.Encode_uLaw(buffer, 0, buffer.Length); } // We just sent buffer to target end point. if (m_IsSendingTest) { byte[] decodedData = null; if (m_Codec == 0) { decodedData = G711.Decode_aLaw(encodedData, 0, encodedData.Length); } else if (m_Codec == 1) { decodedData = G711.Decode_uLaw(encodedData, 0, encodedData.Length); } // We just play received packet. VWaveOut.Play(decodedData, 0, decodedData.Length); /* * VWaveOut.Play(buffer, 0, buffer.Length); */ } else //sending to server { // We just sent buffer to target end point. VUdpServer.SendPacket(encodedData, 0, encodedData.Length, VTargetEP); } }