Ejemplo n.º 1
0
        private void OnProtocolClient_DataComplete(Object sender, Byte[] data)
        {
            try
            {
                //Wenn der Player gestartet wurde
                if (m_PlayerClient != null)
                {
                    if (m_PlayerClient.Opened)
                    {
                        //RTP Header auslesen
                        WinSound.RTPPacket rtp = new WinSound.RTPPacket(data);

                        //Wenn Header korrekt
                        if (rtp.Data != null)
                        {
                            //In JitterBuffer hinzufügen
                            if (m_JitterBufferClientPlaying != null)
                            {
                                m_JitterBufferClientPlaying.AddData(rtp);
                            }
                        }
                    }
                }
                else
                {
                    //Konfigurationsdaten erhalten
                    OnClientConfigReceived(sender, data);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// OnProtocolDataComplete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="data"></param>
        private void OnProtocolDataComplete(Object sender, Byte[] bytes)
        {
            //Wenn initialisiert
            if (IsInitialized)
            {
                if (ServerThread != null && Player != null)
                {
                    try
                    {
                        //Wenn der Player gestartet wurde
                        if (Player.Opened)
                        {
                            //RTP Header auslesen
                            WinSound.RTPPacket rtp = new WinSound.RTPPacket(bytes);

                            ////Wenn Anzeige
                            //if (IsDrawCurve)
                            //{
                            //    TimeMeasurement();
                            //    m_BytesToDraw = rtp.Data;
                            //}

                            //Wenn Header korrekt
                            if (rtp.Data != null)
                            {
                                //Wenn JitterBuffer verwendet werden soll
                                if (JitterBuffer != null && JitterBuffer.Maximum >= 2)
                                {
                                    JitterBuffer.AddData(rtp);
                                }
                                else
                                {
                                    //Nach Linear umwandeln
                                    Byte[] linearBytes = WinSound.Utils.MuLawToLinear(rtp.Data, this.BitsPerSample, this.Channels);
                                    //Abspielen
                                    Player.PlayData(linearBytes, false);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        IsInitialized = false;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
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);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// OnDataReceived
        /// </summary>
        /// <param name="strMessage"></param>
        public void OnDataReceived(List <Byte[]> audio)
        {
            audio.ForEach(bytes =>
            {
                try
                {
                    //Wenn der Player gestartet wurde
                    if (m_Player.Opened)
                    {
                        //RTP Header auslesen
                        WinSound.RTPPacket rtp = new WinSound.RTPPacket(bytes);

                        //Wenn Anzeige
                        if (IsDrawCurve)
                        {
                            TimeMeasurement();
                            m_BytesToDraw = rtp.Data;
                        }

                        //Wenn Header korrekt
                        if (rtp.Data != null)
                        {
                            //Wenn JitterBuffer verwendet werden soll
                            if (UseJitterBuffer)
                            {
                                m_JitterBuffer.AddData(rtp);
                            }
                            else
                            {
                                //Nach Linear umwandeln
                                Byte[] linearBytes = WinSound.Utils.MuLawToLinear(rtp.Data, Config.BitsPerSample, Config.Channels);
                                //Abspielen
                                m_Player.PlayData(linearBytes, false);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("FormMain.cs | OnDataReceived() | {0}", ex.Message));
                }
            });
        }
Ejemplo n.º 6
0
 /// <summary>
 /// OnDataReceivedFromSoundcard
 /// </summary>
 /// <param name="linearData"></param>
 private void OnDataReceivedFromSoundcard(Byte[] data)
 {
     try
     {
         lock (this)
         {
             if (_send != null)
             {
                 //Wenn JitterBuffer
                 if (Config.UseJitterBuffer)
                 {
                     //Sounddaten in kleinere Einzelteile zerlegen
                     int bytesPerInterval = WinSound.Utils.GetBytesPerInterval((uint)Config.SamplesPerSecond, Config.BitsPerSample, Config.Channels);
                     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, Config.BitsPerSample, Config.Channels);
                         //In Buffer legen
                         m_JitterBuffer.AddData(rtp);
                     }
                 }
                 else
                 {
                     //Alles in RTP Packet umwandeln
                     Byte[] rtp = ToRTPData(data, Config.BitsPerSample, Config.Channels);
                     //Absenden
                     _send(_room, rtp);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }