Exemple #1
0
        public async Task Run(CancellationToken canceller)
        {
            var runningAverage = new Queue <(double, int)>();

            double bps(double time, int length)
            {
                runningAverage.Enqueue((time, length));
                if (runningAverage.Count > 50)
                {
                    runningAverage.Dequeue();
                }
                return(runningAverage.Sum(x => x.Item2) / (runningAverage.Max(x => x.Item1) - runningAverage.Min(x => x.Item1)));
            }

            while (!canceller.IsCancellationRequested)
            {
                var controls = await Controller.Run().ConfigureAwait(false);

                var videoConstants = VideoConstants.Get(controls.VideoStandard);
                var frame          = new VideoFrame(videoConstants, Screen.Content).Get();
                if (controls.EnableOutput)
                {
                    Output.Send(frame, sampleRate: videoConstants.Timing.BandwidthFreq);
                }
                var _bps = bps(controls.CurrentTime, frame.Length);
                Console.Write($"\r {_bps / 1e6:F3} Mb/s, {_bps / frame.Length:F0} fps, command --> ");
            }
        }
 public VideoFrame(VideoConstants constants, Content content)
 {
     VideoConstants = constants;
     Content        = content;
     SampleTimePs   = (long)((long)1e12 * VideoConstants.Timing.DotTime);
 }