public void TestCurrentClipId()
        {
            var handler =
                CommandGenerator.CreateAutoCommandHandler <HyperDeckStorageSetCommand, HyperDeckStorageGetCommand>(
                    "CurrentClipId");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.HyperDecks, helper =>
            {
                foreach (IBMDSwitcherHyperDeck deck in GetHyperDecks(helper))
                {
                    deck.GetId(out long id);

                    AtemState stateBefore    = helper.Helper.BuildLibState();
                    HyperdeckState deckState = stateBefore.Hyperdecks[(int)id];

                    for (int i = 0; i < 5; i++)
                    {
                        deckState.Storage.CurrentClipId = Randomiser.RangeInt(-1, 3);

                        helper.SendAndWaitForChange(stateBefore,
                                                    () => { deck.SetCurrentClip(deckState.Storage.CurrentClipId); });
                    }
                }
            });
        }
        public void TestFillSource()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <TransitionDVESetCommand, TransitionDVEGetCommand>("FillSource");

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                VideoSource[] validSources = helper.Helper.BuildLibState().Settings.Inputs.Where(
                    i => i.Value.Properties.SourceAvailability.HasFlag(SourceAvailability.KeySource)
                    ).Select(i => i.Key).ToArray();
                var sampleSources = VideoSourceUtil.TakeSelection(validSources);

                EachMixEffect <IBMDSwitcherTransitionDVEParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;
                    Assert.NotNull(meBefore.Transition.DVE);

                    // sdk.GetFillInputAvailabilityMask(out _BMDSwitcherInputAvailability mask);
                    // Assert.Equal((long)SourceAvailability., (long)mask);

                    VideoSource target = sampleSources[i];
                    meBefore.Transition.DVE.FillSource = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetInputFill((long)target); });
                }, sampleSources.Length);
            });
            Assert.True(tested);
        }
Пример #3
0
        public void TestPreviewInput()
        {
            var ignorePortTypes = new HashSet <InternalPortType>
            {
                InternalPortType.Mask, InternalPortType.Auxiliary, InternalPortType.MEOutput
            };
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <PreviewInputSetCommand, PreviewInputGetCommand>("Source", true);

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                // TODO - this could be better and use the availabilitymask
                List <VideoSource> validSources = helper.Helper.BuildLibState().Settings.Inputs
                                                  .Where(s => !ignorePortTypes.Contains(s.Value.Properties.InternalPortType)).Select(s => s.Key)
                                                  .ToList();
                VideoSource[] sampleSources = Randomiser.SelectionOfGroup(validSources).ToArray();

                EachMixEffect <IBMDSwitcherMixEffectBlock>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;

                    VideoSource target       = sampleSources[i];
                    meBefore.Sources.Preview = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetPreviewInput((long)target); });
                }, sampleSources.Length);
            });
            Assert.True(tested);
        }
        public void TestMode()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <MixMinusOutputSetCommand, MixMinusOutputGetCommand>("Mode");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MixMinusOutputs, helper =>
            {
                bool tested = false;

                List <IBMDSwitcherMixMinusOutput> outputs = GetMixMinusOutputs(helper);
                for (int id = 0; id < outputs.Count; id++)
                {
                    IBMDSwitcherMixMinusOutput mixMinus = outputs[id];
                    tested = true;

                    AtemState stateBefore = helper.Helper.BuildLibState();
                    SettingsState.MixMinusOutputState mixMinusState = stateBefore.Settings.MixMinusOutputs[id];

                    for (int i = 0; i < 5; i++)
                    {
                        MixMinusMode newValue = Randomiser.EnumValue <MixMinusMode>();
                        mixMinusState.Mode    = newValue;

                        helper.SendAndWaitForChange(stateBefore,
                                                    () => { mixMinus.SetAudioMode(AtemEnumMaps.MixMinusModeMap[newValue]); });
                    }
                }
                Assert.True(tested);
            });
        }
        public void TestDiskRemoval()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <RecordingStatusSetCommand, RecordingStatusGetCommand>("IsRecording", true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Streaming, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherStreamRTMP;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                // Init a disk that will persit
                InitDisk(helper, stateBefore, 99);

                for (int i = 0; i < 10; i++)
                {
                    var id  = Randomiser.RangeInt(20);
                    var cmd = InitDisk(helper, stateBefore, id);

                    // Simulate removal
                    cmd.IsDelete = true;
                    stateBefore.Recording.Disks.Remove(id);
                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
        }
        public void TestInputTalkbackGain()
        {
            var  handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerMonitorSetCommand, FairlightMixerMonitorGetCommand>("InputTalkbackGain");
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightMain, helper =>
            {
                var monitor = GetMonitor(helper);
                if (monitor == null)
                {
                    return;
                }
                tested = true;

                AtemState stateBefore = helper.Helper.BuildLibState();
                FairlightAudioState.MonitorOutputState monState = stateBefore.Fairlight.Monitors.Single();

                for (int i = 0; i < 5; i++)
                {
                    var target = Randomiser.Range(-60, 0);
                    monState.InputTalkbackGain = target;
                    helper.SendAndWaitForChange(stateBefore, () => { monitor.SetInputTalkbackGain(target); });
                }
            });
            Assert.True(tested);
        }
        public void TestActiveConfiguration()
        {
            var  handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerInputSetCommand, FairlightMixerInputGetCommand>("ActiveConfiguration");
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightMain, helper =>
            {
                IEnumerable <long> useIds = Randomiser.SelectionOfGroup(helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList());
                foreach (long id in useIds)
                {
                    IBMDSwitcherFairlightAudioInput input = GetInput(helper, id);

                    AtemState stateBefore = helper.Helper.BuildLibState();
                    FairlightAudioState.InputState inputState = stateBefore.Fairlight.Inputs[id];

                    var testConfigs = AtemSDKConverter.GetFlagsValues(input.GetSupportedConfigurations,
                                                                      AtemEnumMaps.FairlightInputConfigurationMap);
                    // Need more than 1 config to allow for switching around
                    if (1 == testConfigs.Count)
                    {
                        continue;
                    }
                    tested = true;

                    for (int i = 0; i < 5; i++)
                    {
                        var target = testConfigs[i % testConfigs.Count];
                        inputState.ActiveConfiguration = target.Item2;
                        helper.SendAndWaitForChange(stateBefore, () => { input.SetConfiguration(target.Item1); });
                    }
                }
            });
            Assert.True(tested);
        }
Пример #8
0
        public void TestPlaying()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <MediaPlayerClipStatusSetCommand, MediaPlayerClipStatusGetCommand>("Playing");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MediaPlayerClips, helper =>
            {
                var tested  = false;
                var players = GetMediaPlayers(helper);

                foreach (Tuple <uint, IBMDSwitcherMediaPlayer> player in players)
                {
                    tested = true;

                    AtemState stateBefore        = helper.Helper.BuildLibState();
                    MediaPlayerState playerState = stateBefore.MediaPlayers[(int)player.Item1];

                    for (int i = 0; i < 5; i++)
                    {
                        bool playing = i % 2 == 0;
                        playerState.ClipStatus.Playing = playing;

                        helper.SendAndWaitForChange(stateBefore, () => { player.Item2.SetPlaying(playing ? 1 : 0); });
                    }
                }
                Assert.True(tested);
            });
        }
        public void TestVuMeterEnabled()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <MultiviewWindowVuMeterSetCommand, MultiviewWindowVuMeterGetCommand>("VuEnabled", true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MultiviewVuMeters, helper =>
            {
                foreach (Tuple <uint, IBMDSwitcherMultiView> mv in GetMultiviewers(helper))
                {
                    mv.Item2.SupportsVuMeters(out int supportsVu);
                    Assert.Equal(1, supportsVu);

                    mv.Item2.SupportsQuadrantLayout(out int supportsQuadrant);
                    int[] windows = Randomiser
                                    .SelectionOfGroup(Enumerable.Range(0, supportsQuadrant == 0 ? 10 : 16).ToList()).ToArray();

                    foreach (int window in windows)
                    {
                        AtemState stateBefore = helper.Helper.BuildLibState();
                        for (int i = 0; i < 5; i++)
                        {
                            bool newValue = i % 2 == 0;
                            stateBefore.Settings.MultiViewers[(int)mv.Item1].Windows[window].VuMeterEnabled = newValue;

                            helper.SendAndWaitForChange(stateBefore,
                                                        () => { mv.Item2.SetVuMeterEnabled((uint)window, newValue ? 1 : 0); });
                        }
                    }
                }
            });
        }
Пример #10
0
        public void TestMode()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <SerialPortModeCommand, SerialPortModeCommand>("SerialMode", true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.SerialPort, helper =>
            {
                IBMDSwitcherSerialPort port = GetSerialPorts(helper).Single().Item2;

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    SerialMode mode = Randomiser.EnumValue <SerialMode>();

                    // TODO - when are these not supported?
                    port.DoesSupportFunction(AtemEnumMaps.SerialModeMap[mode], out int supported);
                    Assert.Equal(1, supported);

                    stateBefore.Settings.SerialMode = mode;
                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        port.SetFunction(AtemEnumMaps.SerialModeMap[mode]);
                    });
                }
            });
        }
Пример #11
0
        public void TestClipFrame()
        {
            try
            {
                _pool.StateSettings.TrackMediaClipFrames = true;
                var handler = CommandGenerator.CreateAutoCommandHandler <MediaPlayerClipStatusSetCommand, MediaPlayerClipStatusGetCommand>("ClipFrame");
                AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MediaPlayerClips, helper =>
                {
                    var tested  = false;
                    var players = GetMediaPlayers(helper);

                    foreach (Tuple <uint, IBMDSwitcherMediaPlayer> player in players)
                    {
                        tested = true;

                        AtemState stateBefore        = helper.Helper.BuildLibState();
                        MediaPlayerState playerState = stateBefore.MediaPlayers[(int)player.Item1];

                        for (int i = 0; i < 5; i++)
                        {
                            uint frame = playerState.ClipStatus.ClipFrame = Randomiser.RangeInt(40);

                            helper.SendAndWaitForChange(stateBefore, () => { player.Item2.SetClipFrame(frame); });
                        }
                    }

                    Assert.True(tested);
                });
            }
            finally
            {
                _pool.StateSettings.TrackMediaClipFrames = false;
            }
        }
Пример #12
0
        public void TestMixOption()
        {
            var  handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerSourceSetCommand, FairlightMixerSourceGetCommand>("MixOption");
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightMain, helper =>
            {
                EachRandomSource(helper, (stateBefore, srcState, inputId, src, i) =>
                {
                    var testConfigs = AtemSDKConverter.GetFlagsValues(src.GetSupportedMixOptions,
                                                                      AtemEnumMaps.FairlightAudioMixOptionMap);
                    // Need more than 1 config to allow for switching around
                    if (1 == testConfigs.Count)
                    {
                        return;
                    }
                    tested     = true;
                    var target = testConfigs[i % testConfigs.Count];

                    srcState.MixOption = target.Item2;
                    helper.SendAndWaitForChange(stateBefore, () => { src.SetMixOption(target.Item1); });
                });
            });
            Assert.True(tested);
        }
Пример #13
0
        public void TestKeyType()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <MixEffectKeyTypeSetCommand, MixEffectKeyPropertiesGetCommand>("KeyType");

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                SelectionOfKeyers <IBMDSwitcherKey>(helper, (stateBefore, keyerBefore, sdkKeyer, meId, keyId, i) =>
                {
                    try
                    {
                        tested = true;

                        MixEffectKeyType target        = Randomiser.EnumValue <MixEffectKeyType>();
                        _BMDSwitcherKeyType target2    = AtemEnumMaps.MixEffectKeyTypeMap[target];
                        keyerBefore.Properties.KeyType = target;
                        helper.SendAndWaitForChange(stateBefore, () => { sdkKeyer.SetType(target2); });
                    }
                    finally
                    {
                        // Reset it back afterwards, so that the dve is available for use elsewhere
                        helper.SendAndWaitForChange(null, () =>
                        {
                            sdkKeyer.SetType(_BMDSwitcherKeyType.bmdSwitcherKeyTypeLuma);
                        });
                    }
                });
            });
            Assert.True(tested);
        }
        public void TestInput()
        {
            var handler =
                CommandGenerator.CreateAutoCommandHandler <HyperDeckSettingsSetCommand, HyperDeckSettingsGetCommand>(
                    "Input");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.HyperDecks, helper =>
            {
                var possibleValues = helper.Helper.BuildLibState().Settings.Inputs
                                     .Where(s => s.Value.Properties.InternalPortType == InternalPortType.External).Select(s => s.Key)
                                     .ToList();
                possibleValues.Add(VideoSource.Black);

                foreach (IBMDSwitcherHyperDeck deck in GetHyperDecks(helper))
                {
                    List <VideoSource> selectedValues = Randomiser.SelectionOfGroup(possibleValues).ToList();
                    foreach (VideoSource src in selectedValues)
                    {
                        deck.GetId(out long id);
                        AtemState stateBefore = helper.Helper.BuildLibState();

                        HyperdeckState hyperdeckState = stateBefore.Hyperdecks[(int)id];
                        hyperdeckState.Settings.Input = src;

                        helper.SendAndWaitForChange(stateBefore, () => { deck.SetSwitcherInput((long)src); });
                    }
                }
            });
        }
Пример #15
0
        public void TestInputCanMuteSDI()
        {
            var handler =
                CommandGenerator
                .CreateAutoCommandHandler <TalkbackMixerInputPropertiesSetCommand,
                                           TalkbackMixerInputPropertiesGetCommand>("MuteSDI");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Talkback, helper =>
            {
                var allCommands = helper.Server.GetParsedDataDump().OfType <TalkbackMixerInputPropertiesGetCommand>()
                                  .ToList();
                EachTalkback(helper, (stateBefore, tbState, talkback, index) =>
                {
                    foreach (long inputId in SampleOfInputs(tbState))
                    {
                        stateBefore    = helper.Helper.BuildLibState();
                        var inputState = stateBefore.Settings.Talkback[(int)index].Inputs[(VideoSource)inputId];

                        var cmd = allCommands.Single(
                            c => c.Channel == (TalkbackChannel)index && c.Index == (VideoSource)inputId);

                        for (int i = 0; i < 5; i++)
                        {
                            cmd.InputCanMuteSDI = inputState.InputCanMuteSDI = !inputState.InputCanMuteSDI;
                            helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                        }
                    }
                });
            });
        }
        public void TestLayout()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <MultiviewPropertiesSetV8Command, MultiviewPropertiesGetV8Command>("Layout");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Multiview, helper =>
            {
                foreach (Tuple <uint, IBMDSwitcherMultiView> mv in GetMultiviewers(helper))
                {
                    mv.Item2.SupportsQuadrantLayout(out int supportsQuadrant);

                    MultiViewLayoutV8[] possibles = supportsQuadrant != 0
                        ? Enum.GetValues(typeof(MultiViewLayoutV8)).OfType <MultiViewLayoutV8>().ToArray()
                        : new[]
                    {
                        MultiViewLayoutV8.ProgramLeft, MultiViewLayoutV8.ProgramBottom,
                        MultiViewLayoutV8.ProgramTop, MultiViewLayoutV8.ProgramRight
                    };

                    AtemState stateBefore = helper.Helper.BuildLibState();

                    for (int i = 0; i < 5; i++)
                    {
                        MultiViewLayoutV8 newValue = possibles[i % possibles.Length];
                        stateBefore.Settings.MultiViewers[(int)mv.Item1].Properties.Layout = newValue;
                        helper.SendAndWaitForChange(stateBefore, () =>
                        {
                            mv.Item2.SetLayout((_BMDSwitcherMultiViewLayout)newValue);
                        });
                    }
                }
            });
        }
        public void TestPeriodicFlushInterval()
        {
            var handler =
                CommandGenerator.CreateAutoCommandHandler <CameraControlSettingsSetCommand, CameraControlSettingsGetCommand>("Interval", true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.CameraControl, helper =>
            {
                helper.Helper.StateSettings.IgnoreUnknownCameraControlProperties = true;
                IBMDSwitcherCameraControl camera = helper.SdkClient.SdkSwitcher as IBMDSwitcherCameraControl;
                Assert.NotNull(camera);

                for (int i = 0; i < 5; i++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();

                    uint interval = Randomiser.RangeInt(int.MaxValue);
                    stateBefore.CameraControl.PeriodicFlushInterval = interval;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        camera.SetPeriodicFlushInterval(interval);
                    });
                }
            });
        }
        public void TestSwapProgramPreview()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <MultiviewPropertiesSetV8Command, MultiviewPropertiesGetV8Command>("ProgramPreviewSwapped");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MultiviewSwapProgramPreview, helper =>
            {
                foreach (Tuple <uint, IBMDSwitcherMultiView> mv in GetMultiviewers(helper))
                {
                    mv.Item2.SupportsProgramPreviewSwap(out int supportsSwap);
                    Assert.Equal(1, supportsSwap);

                    AtemState stateBefore    = helper.Helper.BuildLibState();
                    MultiViewerState mvState = stateBefore.Settings.MultiViewers[(int)mv.Item1];

                    for (int i = 0; i < 5; i++)
                    {
                        bool newValue = i % 2 != 0;
                        mvState.Properties.ProgramPreviewSwapped = newValue;

                        /*
                         * bool tmp = mvState.Windows[0].SupportsVuMeter;
                         * mvState.Windows[0].SupportsVuMeter = mvState.Windows[1].SupportsVuMeter;
                         * mvState.Windows[1].SupportsVuMeter = tmp;
                         */
                        // mvState.Windows[0]

                        helper.SendAndWaitForChange(stateBefore, () =>
                        {
                            mv.Item2.SetProgramPreviewSwapped(newValue ? 1 : 0);
                        });
                    }
                }
            });
        }
        public void TestRcaToXlrEnabled()
        {
            var  handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerInputSetCommand, FairlightMixerInputGetCommand>("RcaToXlrEnabled");
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightXLR, helper =>
            {
                IEnumerable <long> useIds = helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList();
                foreach (long id in useIds)
                {
                    IBMDSwitcherFairlightAudioInput input = GetInput(helper, id);
                    if (input is IBMDSwitcherFairlightAudioInputXLR xlrInput)
                    {
                        AtemState stateBefore = helper.Helper.BuildLibState();
                        FairlightAudioState.InputState inputState = stateBefore.Fairlight.Inputs[id];

                        xlrInput.HasRCAToXLR(out int isAvailable);
                        Assert.Equal(1, isAvailable);
                        tested = true;

                        for (int i = 0; i < 5; i++)
                        {
                            inputState.Analog.InputLevel = i % 2 != 0
                                ? FairlightAnalogInputLevel.ConsumerLine
                                : FairlightAnalogInputLevel.ProLine;
                            helper.SendAndWaitForChange(stateBefore, () => { xlrInput.SetRCAToXLREnabled(i % 2); });
                        }
                    }
                }
            });
            Assert.True(tested);
        }
        public void TestAutoVideoModeDetected()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <AutoVideoModeCommand, AutoVideoModeCommand>("Detected", true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.AutoVideoMode, helper =>
            {
                IBMDSwitcher switcher = helper.SdkClient.SdkSwitcher;

                AutoVideoModeCommand cmd = helper.Server.GetParsedDataDump().OfType <AutoVideoModeCommand>().Single();

                switcher.DoesSupportAutoVideoMode(out int supported);
                Assert.Equal(1, supported);
                tested = true;

                for (int i = 0; i < 5; i++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    stateBefore.Settings.DetectedVideoMode = cmd.Detected = !stateBefore.Settings.DetectedVideoMode;

                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
            Assert.True(tested);
        }
Пример #21
0
        public void TestSource()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <TransitionStingerSetCommand, TransitionStingerGetCommand>("Source");

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                int mpCount = helper.Helper.BuildLibState().MediaPlayers.Count;
                List <StingerSource> sources = Enum.GetValues(typeof(StingerSource)).OfType <StingerSource>().Where(s => ((int)s) < mpCount).ToList();
                if (sources.Count <= 1)
                {
                    return;
                }

                EachMixEffect <IBMDSwitcherTransitionStingerParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;
                    Assert.NotNull(meBefore.Transition.Stinger);

                    StingerSource target = sources[i];
                    _BMDSwitcherStingerTransitionSource target2 = AtemEnumMaps.StingerSourceMap[target];
                    meBefore.Transition.Stinger.Source          = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetSource(target2); });
                }, sources.Count);
            });
            Assert.True(tested);
        }
Пример #22
0
        public void TestStreamingState()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <StreamingStatusSetCommand, StreamingStatusGetCommand>("IsStreaming", true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Streaming, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherStreamRTMP;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 10; i++)
                {
                    stateBefore.Streaming.Status.State = Randomiser.EnumValue <StreamingStatus>();
                    stateBefore.Streaming.Status.Error = Randomiser.EnumValue <StreamingError>();
                    var cmd = new StreamingStatusGetCommand
                    {
                        Status = stateBefore.Streaming.Status.State,
                        Error  = stateBefore.Streaming.Status.Error,
                    };

                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
        }
        public void TestAudioInputId()
        {
            var handler = CommandGenerator.CreateAutoCommandHandler <MixMinusOutputSetCommand, MixMinusOutputGetCommand>("Mode");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MixMinusOutputs, helper =>
            {
                var previousCommands = helper.Server.GetParsedDataDump().OfType <MixMinusOutputGetCommand>().ToList();

                for (int i = 0; i < 10; i++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    uint id = Randomiser.RangeInt((uint)stateBefore.Settings.MixMinusOutputs.Count - 1);
                    SettingsState.MixMinusOutputState mixMinusState = stateBefore.Settings.MixMinusOutputs[(int)id];

                    MixMinusOutputGetCommand cmd = previousCommands.Single(c => c.Id == id);
                    uint newValue       = Randomiser.RangeInt(9) + 1;
                    cmd.HasAudioInputId = i % 2 == 0;
                    cmd.AudioInputId    = cmd.HasAudioInputId ? (AudioSource)newValue : 0;

                    mixMinusState.HasAudioInputId = cmd.HasAudioInputId;
                    mixMinusState.AudioInputId    = cmd.AudioInputId;

                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
        }
Пример #24
0
        public void TestAuthentication()
        {
            var handler =
                CommandGenerator
                .CreateAutoCommandHandler <StreamingAuthenticationCommand, StreamingAuthenticationCommand>(
                    new[] { "Username", "Password" }, true);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Streaming, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherStreamRTMP;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    string target1 = Randomiser.String(64);
                    string target2 = Randomiser.String(64);
                    stateBefore.Streaming.Authentication.Username = target1;
                    stateBefore.Streaming.Authentication.Password = target2;

                    helper.SendAndWaitForChange(stateBefore, () => { switcher.SetAuthentication(target1, target2); });
                }
            });
        }
        public void TestStyle()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <TransitionDVESetCommand, TransitionDVEGetCommand>("Style");

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                EachMixEffect <IBMDSwitcherTransitionDVEParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    if (stateBefore.Info.DVE != null && stateBefore.Info.DVE.SupportedTransitions.Count > 0)
                    {
                        var selection = Randomiser
                                        .SelectionOfGroup(stateBefore.Info.DVE.SupportedTransitions.ToList(), 3).ToList();

                        tested = true;
                        Assert.NotNull(meBefore.Transition.DVE);

                        foreach (DVEEffect style in selection)
                        {
                            meBefore.Transition.DVE.Style = style;
                            helper.SendAndWaitForChange(stateBefore,
                                                        () => { sdk.SetStyle(AtemEnumMaps.DVEStyleMap[style]); });
                        }
                    }
                });
            });
            Assert.True(tested);
        }
        public void TestRcaToXlr()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <AudioMixerInputSetCommand, AudioMixerInputGetV8Command>("RcaToXlrEnabled");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.ClassicAudioXLRLevel, helper =>
            {
                IEnumerable <long> useIds = helper.Helper.BuildLibState().Audio.Inputs.Keys.ToList();
                foreach (long id in useIds)
                {
                    if (GetInput(helper, id) is IBMDSwitcherAudioInputXLR input)
                    {
                        input.HasRCAToXLR(out int isAvailable);
                        Assert.Equal(1, isAvailable);

                        tested = true;

                        AtemState stateBefore            = helper.Helper.BuildLibState();
                        AudioState.InputState inputState = stateBefore.Audio.Inputs[id];
                        Assert.NotNull(inputState.Analog);

                        for (int i = 0; i < 5; i++)
                        {
                            bool newValue = i % 2 == 0;
                            inputState.Analog.RcaToXlr = newValue;

                            helper.SendAndWaitForChange(null, () => { input.SetRCAToXLREnabled(newValue ? 1 : 0); });
                        }
                    }
                }
            });
            Assert.True(tested);
        }
        public void TestArtKeyInput()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <SuperSourcePropertiesSetV8Command, SuperSourcePropertiesGetV8Command>("ArtCutSource");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.SuperSource, helper =>
            {
                VideoSource[] validSources = helper.Helper.BuildLibState().Settings.Inputs.Where(
                    i => i.Value.Properties.SourceAvailability.HasFlag(SourceAvailability.SuperSourceArt)
                    ).Select(i => i.Key).ToArray();
                var sampleSources = VideoSourceUtil.TakeSelection(validSources);

                EachSuperSource(helper, (stateBefore, ssrcBefore, sdk, ssrcId, i) =>
                {
                    tested = true;

                    // TODO GetCutInputAvailabilityMask

                    VideoSource target = sampleSources[i];
                    ssrcBefore.Properties.ArtCutSource = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetInputCut((long)target); });
                }, sampleSources.Length);
            });
            Assert.True(tested);
        }
Пример #28
0
        public void TestInputMuteSDI()
        {
            var handler =
                CommandGenerator
                .CreateAutoCommandHandler <TalkbackMixerInputPropertiesSetCommand,
                                           TalkbackMixerInputPropertiesGetCommand>("MuteSDI");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.Talkback, helper =>
            {
                EachTalkback(helper, (stateBefore, tbState, talkback, index) =>
                {
                    foreach (long inputId in SampleOfInputs(tbState))
                    {
                        var inputState = stateBefore.Settings.Talkback[(int)index].Inputs[(VideoSource)inputId];
                        Assert.True(inputState.InputCanMuteSDI);
                        Assert.True(inputState.CurrentInputSupportsMuteSDI);

                        for (int i = 0; i < 5; i++)
                        {
                            inputState.MuteSDI = !inputState.MuteSDI;
                            helper.SendAndWaitForChange(stateBefore, () =>
                            {
                                talkback.SetInputMuteSDI(inputId, inputState.MuteSDI ? 1 : 0);
                            });
                        }
                    }
                });
            });
        }
        public void TestNextStyle()
        {
            bool tested  = false;
            var  handler = CommandGenerator.CreateAutoCommandHandler <TransitionPropertiesSetCommand, TransitionPropertiesGetCommand>("NextStyle");

            AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper =>
            {
                EachMixEffect <IBMDSwitcherTransitionParameters>(helper, (stateBefore, meBefore, sdk, meId, i) =>
                {
                    tested = true;

                    var omitStyles = new List <TransitionStyle>();
                    if (stateBefore.Info.DVE == null)
                    {
                        omitStyles.Add(TransitionStyle.DVE);
                    }
                    if (stateBefore.MediaPool.Clips.Count == 0)
                    {
                        omitStyles.Add(TransitionStyle.Stinger);
                    }

                    TransitionStyle target = Randomiser.EnumValue(omitStyles.ToArray());
                    _BMDSwitcherTransitionStyle target2      = AtemEnumMaps.TransitionStyleMap[target];
                    meBefore.Transition.Properties.NextStyle = target;
                    helper.SendAndWaitForChange(stateBefore, () => { sdk.SetNextTransitionStyle(target2); });
                });
            });
            Assert.True(tested);
        }
        public void TestNetworkAddress()
        {
            var handler =
                CommandGenerator.CreateAutoCommandHandler <HyperDeckSettingsSetCommand, HyperDeckSettingsGetCommand>(
                    "NetworkAddress");

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.HyperDecks, helper =>
            {
                foreach (IBMDSwitcherHyperDeck deck in GetHyperDecks(helper))
                {
                    for (int i = 0; i < 5; i++)
                    {
                        deck.GetId(out long id);
                        AtemState stateBefore = helper.Helper.BuildLibState();

                        HyperdeckState hyperdeckState = stateBefore.Hyperdecks[(int)id];
                        byte[] randomIp = RandomIP();
                        hyperdeckState.Settings.NetworkAddress = IPUtil.IPToString(randomIp);
                        uint ipVal = BitConverter.ToUInt32(randomIp.Reverse().ToArray());

                        helper.SendAndWaitForChange(stateBefore,
                                                    () => { deck.SetNetworkAddress(ipVal); });
                    }
                }
            });
        }