Пример #1
0
        private void wave_source_DataAvailable(object sender, WaveInEventArgs e)
        {
            ushort[] ushorts = new ushort[e.Buffer.Length / 2];
            Buffer.BlockCopy(e.Buffer, 0, ushorts, 0, e.Buffer.Length);

            byte[] dest = new byte[65535];
            int    size = toxav.PrepareAudioFrame(CallIndex, dest, 65535, ushorts);

            ToxAvError error = toxav.SendAudio(CallIndex, dest, size);

            if (error != ToxAvError.None)
            {
                Console.WriteLine("Could not send audio: {0}", error);
            }
        }
Пример #2
0
        protected virtual void wave_source_DataAvailable(object sender, WaveInEventArgs e)
        {
            short[] shorts = BytesToShorts(e.Buffer);

            if (filterAudio != null && FilterAudio)
            {
                if (!filterAudio.Filter(shorts, shorts.Length / wave_source.WaveFormat.Channels))
                {
                    Debug.WriteLine("Could not filter audio");
                }
            }

            byte[] dest = new byte[(((int)ToxAv.DefaultCodecSettings.AudioFrameDuration * wave_source.WaveFormat.SampleRate) / 1000) * 2 * wave_source.WaveFormat.Channels];
            int    size = toxav.PrepareAudioFrame(callIndex, dest, dest.Length, shorts, ((int)wave_source.BufferMilliseconds * (int)wave_source.WaveFormat.SampleRate) / 1000);

            ToxAvError error = toxav.SendAudio(callIndex, dest, size);

            if (error != ToxAvError.None)
            {
                Debug.WriteLine(string.Format("Could not send audio: {0}", error));
            }
        }