Example #1
0
        public bool SendAudioFrame(int friendNumber, ToxAvAudioFrame frame)
        {
            ToxAvErrorSendFrame error;
            var retVal = _toxAv.SendAudioFrame(friendNumber, frame, out error);

            ToxErrorViewModel.Instance.RelayError(error);
            return(retVal);
        }
Example #2
0
        public void TestToxAvSendAudio()
        {
            var stopWatch = new System.Diagnostics.Stopwatch();
            int count     = 0;

            _toxAv2.OnAudioFrameReceived += (sender, e) =>
            {
                Console.WriteLine("Received frame, length: {0}, sampling rate: {1}", e.Frame.Data.Length, e.Frame.SamplingRate);
                count++;
            };

            for (int i = 0; i < 100; i++)
            {
                short[] frame = new short[1920];
                RandomShorts(frame);

                var  error  = ToxAvErrorSendFrame.Ok;
                bool result = _toxAv1.SendAudioFrame(0, new ToxAvAudioFrame(frame, 48000, 2), out error);

                if (!result || error != ToxAvErrorSendFrame.Ok)
                {
                    Assert.Fail("Failed to send audio frame, error: {0}, result: {1}", error, result);
                }

                DoIterate();
            }

            stopWatch.Start();

            while (stopWatch.Elapsed.TotalSeconds < 5)
            {
                //give the frames a bit less than 5 seconds to arrive
                DoIterate();
            }

            Console.WriteLine("Received a total of {0} audio frames", count);
        }