public void TestSource()
        {
            AtemMockServerWrapper.Each(_output, _pool, SourceCommandHandler, DeviceTestCases.All, helper =>
            {
                Dictionary <VideoSource, IBMDSwitcherInputAux> allAuxes = helper.GetSdkInputsOfType <IBMDSwitcherInputAux>();
                VideoSource[] chosenIds = VideoSourceUtil.TakeSelection(allAuxes.Keys.ToArray());

                foreach (VideoSource auxSource in chosenIds)
                {
                    uint auxId = AtemEnumMaps.GetAuxId(auxSource);
                    IBMDSwitcherInputAux aux = allAuxes[auxSource];

                    // GetInputAvailabilityMask is used when checking if another input can be used for this output.
                    // We track this another way
                    aux.GetInputAvailabilityMask(out _BMDSwitcherInputAvailability availabilityMask);
                    Assert.Equal(availabilityMask, (_BMDSwitcherInputAvailability)((int)SourceAvailability.Auxiliary << 2));

                    AtemState stateBefore = helper.Helper.BuildLibState();

                    VideoSource[] validSources = stateBefore.Settings.Inputs.Where(
                        i => i.Value.Properties.SourceAvailability.HasFlag(SourceAvailability.Auxiliary)
                        ).Select(i => i.Key).ToArray();
                    var sampleSources = VideoSourceUtil.TakeSelection(validSources);

                    foreach (VideoSource src in sampleSources)
                    {
                        stateBefore.Auxiliaries[(int)auxId].Source = src;
                        helper.SendAndWaitForChange(stateBefore, () =>
                        {
                            aux.SetInputSource((long)src);
                        });
                    }
                }
            });
        }
Exemplo n.º 2
0
        public void TestLockAndUnlock()
        {
            AtemMockServerWrapper.Each(_output, _pool, UploadJobWorker.LockCommandHandler, DeviceTestCases.MediaPlayerClips, helper =>
            {
                helper.DisposeSdkClient = true;

                int clipCount = helper.Helper.BuildLibState().MediaPool.Clips.Count;
                for (int index = 0; index < clipCount; index++)
                {
                    IBMDSwitcherClip clip = GetClip(helper, (uint)index);

                    AtemState stateBefore = helper.Helper.BuildLibState();

                    var cb = new LockCallback();
                    helper.SendAndWaitForChange(stateBefore, () => { clip.Lock(cb); });
                    Assert.True(cb.Wait.WaitOne(2000));

                    helper.Helper.CheckStateChanges(stateBefore);

                    uint timeBefore = helper.Server.CurrentTime;

                    helper.SendAndWaitForChange(stateBefore, () => { clip.Unlock(cb); });

                    // It should have sent a response, but we dont expect any comparable data
                    Assert.NotEqual(timeBefore, helper.Server.CurrentTime);

                    helper.Helper.CheckStateChanges(stateBefore);
                }
            });
        }
Exemplo n.º 3
0
        public void TestClipSetValid()
        {
            AtemMockServerWrapper.Each(_output, _pool, SetValidCommandHandler, DeviceTestCases.MediaPlayerClips, helper =>
            {
                for (int i = 0; i < 3; i++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    uint index            = Randomiser.RangeInt((uint)stateBefore.MediaPool.Clips.Count);
                    IBMDSwitcherClip clip = GetClip(helper, index);

                    string name     = Guid.NewGuid().ToString();
                    uint frameCount = Randomiser.RangeInt(5) + 3;

                    var cb = new LockCallback();
                    helper.SendAndWaitForChange(stateBefore, () => { clip.Lock(cb); });
                    Assert.True(cb.Wait.WaitOne(2000));

                    var clipState        = stateBefore.MediaPool.Clips[(int)index];
                    clipState.IsUsed     = true;
                    clipState.Name       = name;
                    clipState.FrameCount = frameCount;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        clip.SetValid(name, frameCount);
                    });

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        clip.Unlock(cb);
                    });
                }
            });
        }
        public void TestRunStatus()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    uint index = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count);
                    var status = Randomiser.EnumValue <MacroState.MacroRunStatus>();

                    stateBefore.Macros.RunStatus.RunIndex  = index;
                    stateBefore.Macros.RunStatus.RunStatus = status;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        helper.Server.SendCommands(new MacroRunStatusGetCommand
                        {
                            Index     = index,
                            IsWaiting = status == MacroState.MacroRunStatus.UserWait,
                            IsRunning = status == MacroState.MacroRunStatus.Running,
                            Loop      = stateBefore.Macros.RunStatus.Loop,
                        });
                    });
                }
            });
        }
        public void TestStop()
        {
            var expectedCommand = RunThroughSerialize(new MacroActionCommand
            {
                Action = MacroActionCommand.MacroAction.Stop
            });
            var handler = CommandGenerator.MatchCommand(expectedCommand);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                uint timeBefore = helper.Server.CurrentTime;

                AtemState stateBefore = helper.Helper.BuildLibState();
                helper.SendAndWaitForChange(stateBefore, () =>
                {
                    control.StopRunning();
                });

                // It should have sent a response, but we dont expect any comparable data
                Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
            });
        }
        private static void MixMinusOutputs(AtemState state, IBMDSwitcher switcher)
        {
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherMixMinusOutputIterator>(switcher.CreateIterator);

            state.Settings.MixMinusOutputs = AtemSDKConverter.IterateList <IBMDSwitcherMixMinusOutput, SettingsState.MixMinusOutputState>(iterator.Next,
                                                                                                                                          (props, id) =>
            {
                props.GetAvailableAudioModes(out _BMDSwitcherMixMinusOutputAudioMode availableModes);
                props.GetAudioMode(out _BMDSwitcherMixMinusOutputAudioMode mode);
                props.HasMinusAudioInputId(out int hasInputId);

                long inputId = 0;
                if (hasInputId != 0)
                {
                    props.GetMinusAudioInputId(out inputId);
                }

                return(new SettingsState.MixMinusOutputState
                {
                    HasAudioInputId = hasInputId != 0,
                    AudioInputId = (AudioSource)inputId,
                    SupportedModes = AtemEnumMaps.MixMinusModeMap.FindFlagsByValue(availableModes),
                    Mode = AtemEnumMaps.MixMinusModeMap.FindByValue(mode),
                });
            });
        }
        public void TestRecordPause()
        {
            var expectedCommand = new MacroAddTimedPauseCommand();
            var handler         = CommandGenerator.MatchCommand(expectedCommand);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    uint frames = Randomiser.RangeInt(2500);

                    expectedCommand.Frames = frames;

                    uint timeBefore = helper.Server.CurrentTime;

                    helper.SendAndWaitForChange(stateBefore, () => { control.RecordPause(frames); });

                    // It should have sent a response, but we dont expect any comparable data
                    Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
                }
            });
        }
        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 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);
        }
        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 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);
        }
Exemplo n.º 12
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is TalkbackMixerPropertiesGetCommand talkbackCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Settings.Talkback, (int)talkbackCmd.Channel, channel =>
                {
                    channel.MuteSDI = talkbackCmd.MuteSDI;
                    result.SetSuccess($"Settings.Talkback.{talkbackCmd.Channel:D}");
                });
            }
            else if (command is TalkbackMixerInputPropertiesGetCommand inputCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Settings.Talkback, (int)inputCmd.Channel, channel =>
                {
                    if (!channel.Inputs.TryGetValue(inputCmd.Index, out SettingsState.TalkbackInputState input))
                    {
                        input = channel.Inputs[inputCmd.Index] = new SettingsState.TalkbackInputState();
                    }

                    UpdaterUtil.CopyAllProperties(inputCmd, input, new[] { "Channel", "Index" });

                    result.SetSuccess($"Settings.Talkback.{inputCmd.Channel:D}.Inputs.{inputCmd.Index:D}");
                });
            }
        }
        public void TestClone()
        {
            var state = new AtemState();

            // Simply ensure it can be cloned, as it relies on all classes having an attribute
            state.Clone();
        }
Exemplo n.º 14
0
        public void TestTally()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.ClassicAudioMain, helper =>
            {
                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    var cmd = new AudioMixerTallyCommand
                    {
                        Inputs = new Dictionary <AudioSource, bool>()
                    };

                    Assert.NotEmpty(stateBefore.Audio.Tally);

                    // the sdk is a bit picky about ids, so best to go with what it expects
                    foreach (KeyValuePair <AudioSource, bool> k in stateBefore.Audio.Tally)
                    {
                        bool isMixedIn    = Randomiser.Range(0, 1) > 0.7;
                        cmd.Inputs[k.Key] = isMixedIn;
                    }

                    stateBefore.Audio.Tally = cmd.Inputs;
                    helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(cmd); });
                }
            });
        }
Exemplo n.º 15
0
        public static IUpdateResult Update(AtemState state, ICommand command, AtemStateBuilderSettings settings = null)
        {
            var result = new UpdateResultImpl();

            UpdateInternal(state, result, command);
            AudioStateUpdater.Update(state, result, command);
            FairlightStateUpdater.Update(state, result, command);
            TalkbackStateUpdater.Update(state, result, command);
            AuxStateUpdater.Update(state, result, command);
            ColorStateUpdater.Update(state, result, command);
            DownstreamKeyerStateUpdater.Update(state, result, command);
            InfoStateUpdater.Update(state, result, command);
            MacroStateUpdater.Update(state, result, command);
            MediaPlayerStateUpdater.Update(state, result, command, settings);
            MediaPoolStateUpdater.Update(state, result, command);
            MixEffectStateUpdater.Update(state, result, command);
            SettingsStateUpdater.Update(state, result, command);
            HyperDeckStateUpdater.Update(state, result, command);
            SuperSourceStateUpdater.Update(state, result, command);
            StreamingStateUpdater.Update(state, result, command);
            RecordingStateUpdater.Update(state, result, command);
            CameraControllerUpdater.Update(state, result, command, settings);

            return(result);
        }
        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);
            });
        }
Exemplo n.º 17
0
 public void SendState(AtemState state)
 {
     _context.Clients.Clients(GetClientIds()).SendAsync("state", new AtemStateWrapped {
         State    = state,
         DeviceId = _deviceId
     });
 }
        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);
                }
            });
        }
Exemplo n.º 19
0
        public void TestHasUnsupportedOps()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.MacroTransfer, helper =>
            {
                var pool = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroPool;
                Assert.NotNull(pool);

                ImmutableList <ICommand> previousCommands = helper.Server.GetParsedDataDump();

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

                    uint index = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count);
                    MacroPropertiesGetCommand cmd = previousCommands.OfType <MacroPropertiesGetCommand>().Single(c => c.Index == index);
                    cmd.HasUnsupportedOps         = i % 2 == 0;

                    stateBefore.Macros.Pool[(int)index].HasUnsupportedOps = cmd.HasUnsupportedOps;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        helper.Server.SendCommands(cmd);
                    });
                }
            });
        }
        protected static void EachSuperSourceBox(AtemMockServerWrapper helper, Action <AtemState, SuperSourceState.BoxState, IBMDSwitcherSuperSourceBox, SuperSourceId, SuperSourceBoxId, int> fcn, int iterations = 5)
        {
            var allBoxes = new List <Tuple <SuperSourceId, SuperSourceBoxId, IBMDSwitcherSuperSourceBox> >();

            foreach (KeyValuePair <VideoSource, IBMDSwitcherInputSuperSource> ssrc in helper.GetSdkInputsOfType <IBMDSwitcherInputSuperSource>())
            {
                SuperSourceId id       = (SuperSourceId)(ssrc.Key - VideoSource.SuperSource);
                var           iterator = AtemSDKConverter.CastSdk <IBMDSwitcherSuperSourceBoxIterator>(ssrc.Value.CreateIterator);
                AtemSDKConverter.Iterate <IBMDSwitcherSuperSourceBox>(iterator.Next, (box, i) =>
                {
                    allBoxes.Add(Tuple.Create(id, (SuperSourceBoxId)i, box));
                });
            }

            var boxes = Randomiser.SelectionOfGroup(allBoxes);

            foreach (Tuple <SuperSourceId, SuperSourceBoxId, IBMDSwitcherSuperSourceBox> box in boxes)
            {
                AtemState stateBefore = helper.Helper.BuildLibState();

                SuperSourceState.BoxState boxBefore = stateBefore.SuperSources[(int)box.Item1].Boxes[(int)box.Item2];
                Assert.NotNull(boxBefore);

                for (int i = 0; i < iterations; i++)
                {
                    fcn(stateBefore, boxBefore, box.Item3, box.Item1, box.Item2, i);
                }
            }
        }
        public void TestRun()
        {
            var expectedCommand = RunThroughSerialize(new MacroActionCommand
            {
                Action = MacroActionCommand.MacroAction.Run
            });
            var handler = CommandGenerator.MatchCommand(expectedCommand);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    uint index            = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count);
                    expectedCommand.Index = index;

                    uint timeBefore = helper.Server.CurrentTime;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        control.Run(index);
                    });

                    // It should have sent a response, but we dont expect any comparable data
                    Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
                }
            });
        }
Exemplo n.º 22
0
        public void CheckStateChanges(AtemState expected, Action <AtemState, AtemState> mutateStates = null)
        {
            AtemState sdkState = BuildSdkState();
            AtemState libState = BuildLibState();

            mutateStates?.Invoke(sdkState, libState);

            List <string> sdk = AtemStateComparer.AreEqual(expected, sdkState);
            List <string> lib = AtemStateComparer.AreEqual(expected, libState);

            if (sdk.Count > 0 || lib.Count > 0)
            {
                if (sdk.Count > 0)
                {
                    Output.WriteLine("SDK wrong");
                    sdk.ForEach(Output.WriteLine);
                }

                if (lib.Count > 0)
                {
                    Output.WriteLine("Lib wrong");
                    lib.ForEach(Output.WriteLine);
                }

                TestResult = false;
            }
        }
        public void TestRecordStatus()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.All, helper =>
            {
                var control = helper.SdkClient.SdkSwitcher as IBMDSwitcherMacroControl;
                Assert.NotNull(control);

                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    uint index     = Randomiser.RangeInt((uint)stateBefore.Macros.Pool.Count);
                    bool recording = Randomiser.RangeInt(1) == 1;

                    stateBefore.Macros.RecordStatus.RecordIndex = index;
                    stateBefore.Macros.RecordStatus.IsRecording = recording;

                    helper.SendAndWaitForChange(stateBefore, () =>
                    {
                        helper.Server.SendCommands(new MacroRecordingStatusGetCommand()
                        {
                            Index       = index,
                            IsRecording = recording,
                        });
                    });
                }
            });
        }
Exemplo n.º 24
0
 public void SyncStates()
 {
     lock (_libAtemStateLock)
     {
         _libAtemState = SdkClient.BuildState();
     }
 }
Exemplo n.º 25
0
        public void TestIsUsed()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.MediaPlayerClips, helper =>
            {
                ImmutableList <ICommand> previousCommands = helper.Server.GetParsedDataDump();

                int clipCount = helper.Helper.BuildLibState().MediaPool.Clips.Count;
                for (int index = 0; index < clipCount; index++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();

                    for (int i = 0; i < 5; i++)
                    {
                        MediaPoolClipDescriptionCommand cmd = previousCommands.OfType <MediaPoolClipDescriptionCommand>().Single(c => c.Index == index);
                        cmd.IsUsed = i % 2 == 0;
                        cmd.Name   = cmd.IsUsed ? "abc" : "";

                        stateBefore.MediaPool.Clips[index].IsUsed = cmd.IsUsed;
                        stateBefore.MediaPool.Clips[index].Name   = cmd.Name;

                        helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                    }
                }
            });
        }
        public void TestRecordingState()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.Recording, helper =>
            {
                var switcher = helper.SdkClient.SdkSwitcher as IBMDSwitcherRecordAV;
                Assert.NotNull(switcher);

                AtemState stateBefore = helper.Helper.BuildLibState();

                InitDisk(helper, stateBefore);
                InitRecording(helper, stateBefore);

                stateBefore.Recording.Status.TotalRecordingTimeAvailable = 0;

                for (int i = 0; i < 10; i++)
                {
                    stateBefore.Recording.Status.State = Randomiser.EnumValue <RecordingStatus>();
                    stateBefore.Recording.Status.Error = Randomiser.EnumValue <RecordingError>();
                    var cmd = new RecordingStatusGetCommand()
                    {
                        Status = stateBefore.Recording.Status.State,
                        Error  = stateBefore.Recording.Status.Error,
                    };
                    helper.SendFromServerAndWaitForChange(stateBefore, cmd);
                }
            });
        }
Exemplo n.º 27
0
        public void TestSetAudioInvalid()
        {
            AtemMockServerWrapper.Each(_output, _pool, ClearAudioCommandHandler, DeviceTestCases.MediaPlayerClips, helper =>
            {
                ImmutableList <ICommand> previousCommands = helper.Server.GetParsedDataDump();

                int clipCount = helper.Helper.BuildLibState().MediaPool.Clips.Count;
                for (int index = 0; index < clipCount; index++)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();

                    IBMDSwitcherClip clip = GetClip(helper, (uint)index);

                    for (int i = 0; i < 5; i++)
                    {
                        MediaPoolAudioDescriptionCommand cmd = previousCommands
                                                               .OfType <MediaPoolAudioDescriptionCommand>().Single(c => c.Index == index + 1);
                        cmd.IsUsed = true;

                        // Set it to true first
                        stateBefore.MediaPool.Clips[index].Audio.IsUsed = true;
                        helper.SendFromServerAndWaitForChange(stateBefore, cmd);

                        // Now set invalid
                        stateBefore.MediaPool.Clips[index].Audio.IsUsed = false;
                        helper.SendAndWaitForChange(stateBefore, () => { clip.SetAudioInvalid(); });
                    }
                }
            });
        }
        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 TestTally()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.FairlightMain, helper =>
            {
                IBMDSwitcherFairlightAudioMixer mixer = GetFairlightMixer(helper);
                AtemState stateBefore = helper.Helper.BuildLibState();

                for (int i = 0; i < 5; i++)
                {
                    var cmd = new FairlightMixerTallyCommand
                    {
                        Tally = new Dictionary <Tuple <AudioSource, long>, bool>()
                    };

                    Assert.NotEmpty(stateBefore.Fairlight.Tally);

                    // the sdk is a bit picky about ids, so best to go with what it expects
                    foreach (KeyValuePair <Tuple <AudioSource, long>, bool> k in stateBefore.Fairlight.Tally)
                    {
                        bool isMixedIn   = Randomiser.Range(0, 1) > 0.7;
                        cmd.Tally[k.Key] = isMixedIn;
                    }

                    stateBefore.Fairlight.Tally = cmd.Tally;
                    helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(cmd); });
                }
            });
        }
        public void TestBalance()
        {
            var  handler = CreateAutoCommandHandler("Balance");
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.ClassicAudioMain, helper =>
            {
                IEnumerable <long> useIds = helper.Helper.BuildLibState().Audio.Inputs.Keys.ToList();
                foreach (long id in useIds)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    var inputState        = stateBefore.Audio.Inputs[id].Properties;

                    IBMDSwitcherAudioInput input = GetInput(helper, id);
                    tested = true;

                    for (int i = 0; i < 5; i++)
                    {
                        var target         = Randomiser.Range(-50, 50);
                        inputState.Balance = target;
                        helper.SendAndWaitForChange(stateBefore, () => { input.SetBalance(target / 50); });
                    }
                }
            });
            Assert.True(tested);
        }