public void LogReceivedVideoQualityTest_CommandedVideoQuality_NotController()
        {
            var remoteSessions = new Dictionary <ushort, VideoThreadData>();

            remoteSessions[1] = null;
            var controller = new VideoQualityController(2, remoteSessions);

            controller.LogReceivedVideoQuality(1, VideoQuality.Fallback, VideoQuality.High);
            Assert.AreEqual(VideoQuality.Fallback, controller.LocalVideoQuality);
            controller.LogReceivedVideoQuality(1, VideoQuality.High, VideoQuality.High);
            Assert.AreEqual(VideoQuality.High, controller.LocalVideoQuality);
            controller.LogReceivedVideoQuality(1, VideoQuality.NotSpecified, VideoQuality.High);
            Assert.AreEqual(VideoQuality.High, controller.LocalVideoQuality);
        }
        public void LogNetworkGlitchTest_Controller()
        {
            var remoteSessions = new Dictionary <ushort, VideoThreadData>();

            remoteSessions[1] = null;
            var controller = new VideoQualityController(1, remoteSessions);

            // This has the side-effect of setting IsController() to true.
            controller.LogReceivedVideoQuality(2, VideoQuality.NotSpecified, VideoQuality.Medium);
            Assert.AreEqual(VideoQuality.Medium, controller.LocalVideoQuality);

            controller.Now += controller.QualityHoldInterval + TimeSpan.FromSeconds(1);
            for (int i = 0; i < VideoQualityController.MaxGlitches; i++)
            {
                controller.LogGlitch(1);
            }
            Assert.AreEqual(VideoQuality.Low, controller.LocalVideoQuality);
            Assert.AreEqual(VideoQuality.Low, controller.ProposedVideoQuality);
            Assert.AreEqual(VideoQuality.Low, controller.CommandedVideoQuality);

            controller.Now += controller.QualityHoldInterval + TimeSpan.FromSeconds(1);
            for (int i = 0; i < VideoQualityController.MaxGlitches; i++)
            {
                controller.LogGlitch(1);
            }
            Assert.AreEqual(VideoQuality.Fallback, controller.LocalVideoQuality);
            Assert.AreEqual(VideoQuality.Fallback, controller.ProposedVideoQuality);
            Assert.AreEqual(VideoQuality.Fallback, controller.CommandedVideoQuality);
        }
        public void LogReceivedVideoQualityTest_SelectLowestProposedVideoQuality_Controller()
        {
            var remoteSessions = new Dictionary <ushort, VideoThreadData>();

            remoteSessions[1] = null;
            var controller = new VideoQualityController(1, remoteSessions);

            for (ushort i = 2; i < 60; i++)
            {
                controller.LogReceivedVideoQuality(i, VideoQuality.NotSpecified, VideoQuality.High);
                controller.Now += TimeSpan.FromSeconds(1);
            }
            Assert.AreEqual(VideoQuality.High, controller.LocalVideoQuality);
            Assert.AreEqual(VideoQuality.High, controller.CommandedVideoQuality);
            controller.Now += controller.QualityUpdateInterval;
            controller.LogReceivedVideoQuality(2, VideoQuality.NotSpecified, VideoQuality.Low);
            Assert.AreEqual(VideoQuality.Low, controller.LocalVideoQuality);
            Assert.AreEqual(VideoQuality.Low, controller.CommandedVideoQuality);
        }
        public void LogReceivedVideoQualityTest_LowerProposedVideoQuality_NotController()
        {
            var remoteSessions = new Dictionary <ushort, VideoThreadData>();

            remoteSessions[1] = null;
            var controller = new VideoQualityController(2, remoteSessions);

            controller.LogReceivedVideoQuality(1, VideoQuality.NotSpecified, VideoQuality.Low);
            Assert.AreEqual(VideoQuality.Medium, controller.LocalVideoQuality);
            Assert.AreEqual(VideoQuality.NotSpecified, controller.CommandedVideoQuality);
        }