private void OnDataReceivedFromSoundcard_Client(Byte[] data)
        {
            try
            {
                lock (this)
                {
                    if (IsClientConnected)
                    {
                        //Wenn gewünscht
                        if (m_Config.ClientNoSpeakAll == false)
                        {
                            //Sounddaten in kleinere Einzelteile zerlegen
                            int bytesPerInterval = WinSound.Utils.GetBytesPerInterval((uint)m_Config.SamplesPerSecondClient, m_Config.BitsPerSampleClient, m_Config.ChannelsClient);
                            int count            = data.Length / bytesPerInterval;
                            int currentPos       = 0;
                            for (int i = 0; i < count; i++)
                            {
                                //Teilstück in RTP Packet umwandeln
                                Byte[] partBytes = new Byte[bytesPerInterval];
                                Array.Copy(data, currentPos, partBytes, 0, bytesPerInterval);
                                currentPos += bytesPerInterval;
                                WinSound.RTPPacket rtp = ToRTPPacket(partBytes, m_Config.BitsPerSampleClient, m_Config.ChannelsClient);

                                //Wenn JitterBuffer
                                if (UseJitterBufferClientRecording)
                                {
                                    //In Buffer legen
                                    m_JitterBufferClientRecording.AddData(rtp);
                                }
                                else
                                {
                                    //Alles in RTP Packet umwandeln
                                    Byte[] rtpBytes = ToRTPData(data, m_Config.BitsPerSampleClient, m_Config.ChannelsClient);
                                    //Absenden
                                    m_Client.Send(m_PrototolClient.ToBytes(rtpBytes));
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Exemple #2
0
 /// <summary>
 /// OnDataReceivedFromSoundcard
 /// </summary>
 /// <param name="linearData"></param>
 private void OnDataReceivedFromSoundcard(Byte[] data)
 {
     try
     {
         lock (this)
         {
             if (IsServerRunning)
             {
                 //Wenn Form noch aktiv
                 if (m_IsFormMain)
                 {
                     //Wenn JitterBuffer
                     if (m_Config.IsTimeSyncClient)
                     {
                         //Sounddaten in kleinere Einzelteile zerlegen
                         int bytesPerInterval = WinSound.Utils.GetBytesPerInterval((uint)m_Config.SamplesPerSecondClient, m_Config.BitsPerSampleClient, m_Config.ChannelsClient);
                         int count            = data.Length / bytesPerInterval;
                         int currentPos       = 0;
                         for (int i = 0; i < count; i++)
                         {
                             //Teilstück in RTP Packet umwandeln
                             Byte[] partBytes = new Byte[bytesPerInterval];
                             Array.Copy(data, currentPos, partBytes, 0, bytesPerInterval);
                             currentPos += bytesPerInterval;
                             WinSound.RTPPacket rtp = ToRTPPacket(partBytes, m_Config.BitsPerSampleClient, m_Config.ChannelsClient);
                             //In Buffer legen
                             m_JitterBuffer.AddData(rtp);
                         }
                     }
                     else
                     {
                         Byte[] rtp = ToRTPData(data, m_Config.BitsPerSampleClient, m_Config.ChannelsClient);
                         //Absenden
                         m_Server.Send(m_PrototolClient.ToBytes(rtp));
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }