Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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}");
                });
            }
        }
Ejemplo n.º 3
0
 public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
 {
     if (command is DownstreamKeyPropertiesGetCommand propsCmd)
     {
         UpdaterUtil.TryForIndex(result, state.DownstreamKeyers, (int)propsCmd.Index, dsk =>
         {
             UpdaterUtil.CopyAllProperties(propsCmd, dsk.Properties, new [] { "Index" });
             result.SetSuccess($"DownstreamKeyers.{propsCmd.Index:D}.Properties");
         });
     }
     else if (command is DownstreamKeySourceGetCommand sourceCmd)
     {
         UpdaterUtil.TryForIndex(result, state.DownstreamKeyers, (int)sourceCmd.Index, dsk =>
         {
             UpdaterUtil.CopyAllProperties(sourceCmd, dsk.Sources, new [] { "Index" });
             result.SetSuccess($"DownstreamKeyers.{sourceCmd.Index:D}.Sources");
         });
     }
     else if (command is DownstreamKeyStateGetV8Command state8Cmd)
     {
         UpdaterUtil.TryForIndex(result, state.DownstreamKeyers, (int)state8Cmd.Index, dsk =>
         {
             UpdaterUtil.CopyAllProperties(state8Cmd, dsk.State, new[] { "Index" });
             result.SetSuccess($"DownstreamKeyers.{state8Cmd.Index:D}.State");
         });
     }
     else if (command is DownstreamKeyStateGetCommand stateCmd)
     {
         UpdaterUtil.TryForIndex(result, state.DownstreamKeyers, (int)stateCmd.Index, dsk =>
         {
             UpdaterUtil.CopyAllProperties(stateCmd, dsk.State, new[] { "Index" }, new[] { "IsTowardsOnAir" });
             result.SetSuccess($"DownstreamKeyers.{stateCmd.Index:D}.State");
         });
     }
 }
Ejemplo n.º 4
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is VersionCommand verCmd)
            {
                state.Info.Version = verCmd.ProtocolVersion;
                result.SetSuccess("Info.Version");
            }
            else if (command is TimeCodeLockedCommand lockedCmd)
            {
                state.Info.TimecodeLocked = lockedCmd.Locked;
                result.SetSuccess("Info.TimecodeLocked");
            }
            else if (command is TimeCodeCommand timecodeCmd)
            {
                state.Info.LastTimecode = new Timecode
                {
                    Hour      = timecodeCmd.Hour,
                    Minute    = timecodeCmd.Minute,
                    Second    = timecodeCmd.Second,
                    Frame     = timecodeCmd.Frame,
                    DropFrame = timecodeCmd.IsDropFrame,
                };
                result.SetSuccess("Info.LastTimecode");
            }
            else if (command is ProductIdentifierCommand pidCmd)
            {
                state.Info.Model       = pidCmd.Model;
                state.Info.ProductName = pidCmd.Name;
                result.SetSuccess("Info.Model");
            }
            else if (command is VideoMixerConfigCommand videoCmd)
            {
                var modes = new List <VideoModeInfo>();
                foreach (VideoMixerConfigCommand.Entry mode in videoCmd.Modes)
                {
                    modes.Add(new VideoModeInfo
                    {
                        Mode             = mode.Mode,
                        RequiresReconfig = mode.RequiresReconfig,
                        MultiviewModes   = mode.MultiviewModes.ToArray(),
                        DownConvertModes = mode.DownConvertModes.ToArray(),
                    });
                }

                state.Info.SupportedVideoModes = modes.OrderBy(s => s.Mode).ToList();
                result.SetSuccess("Info.SupportedVideoModes");
            }
            else if (command is DVEConfigCommand dveCmd)
            {
                state.Info.DVE = new InfoState.DveInfoState();

                UpdaterUtil.CopyAllProperties(dveCmd, state.Info.DVE);

                result.SetSuccess("Info.DVE");
            }
        }
Ejemplo n.º 5
0
 internal static void TryForKey <TK, TV>(UpdateResultImpl result, IDictionary <TK, TV> dict, TK key, Action <TV> func)
 {
     if (dict.TryGetValue(key, out TV obj))
     {
         func(obj);
     }
     else
     {
         result.AddError($"Update for unknown {typeof(TV).Name}: {key}");
     }
 }
Ejemplo n.º 6
0
 public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
 {
     if (command is ColorGeneratorGetCommand colCmd)
     {
         UpdaterUtil.TryForIndex(result, state.ColorGenerators, (int)colCmd.Index, col =>
         {
             UpdaterUtil.CopyAllProperties(colCmd, col, new [] { "Index" });
             result.SetSuccess($"ColorGenerators.{colCmd.Index:D}");
         });
     }
 }
Ejemplo n.º 7
0
 private static void UpdateInternal(AtemState state, UpdateResultImpl result, ICommand command)
 {
     if (IgnoredCommands.Contains(command.GetType()))
     {
         result.SetSuccess(new string[0]);
     }
     else if (command is TopologyCommand topCmd)
     {
         HandleTopologyCommand(state, result, new TopologyV811Command
         {
             MixEffectBlocks  = topCmd.MixEffectBlocks,
             VideoSources     = topCmd.VideoSources,
             DownstreamKeyers = topCmd.DownstreamKeyers,
             Auxiliaries      = topCmd.Auxiliaries,
             MixMinusOutputs  = topCmd.MixMinusOutputs,
             MediaPlayers     = topCmd.MediaPlayers,
             SerialPort       = topCmd.SerialPort,
             HyperDecks       = topCmd.HyperDecks,
             DVE         = topCmd.DVE,
             Stingers    = topCmd.Stingers,
             SuperSource = topCmd.SuperSource,
         });
     }
     else if (command is TopologyV811Command topCmd811)
     {
         HandleTopologyCommand(state, result, topCmd811);
     }
     else if (command is TopologyV8Command topCmd8)
     {
         HandleTopologyCommand(state, result, new TopologyV811Command
         {
             MixEffectBlocks  = topCmd8.MixEffectBlocks,
             VideoSources     = topCmd8.VideoSources,
             DownstreamKeyers = topCmd8.DownstreamKeyers,
             Auxiliaries      = topCmd8.Auxiliaries,
             MixMinusOutputs  = topCmd8.MixMinusOutputs,
             MediaPlayers     = topCmd8.MediaPlayers,
             SerialPort       = topCmd8.SerialPort,
             HyperDecks       = topCmd8.HyperDecks,
             DVE                     = topCmd8.DVE,
             Stingers                = topCmd8.Stingers,
             SuperSource             = topCmd8.SuperSource,
             CameraControl           = topCmd8.CameraControl,
             AdvancedChromaKeyers    = topCmd8.AdvancedChromaKeyers,
             OnlyConfigurableOutputs = topCmd8.OnlyConfigurableOutputs,
         });
     }
     else if (command is PowerStatusCommand powCmd)
     {
         // TODO - when do we have only one psu?
         state.Power = new[] { powCmd.Pin1, powCmd.Pin2 };
         result.SetSuccess("Power");
     }
 }
Ejemplo n.º 8
0
 public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
 {
     if (command is AuxSourceGetCommand sourceCmd)
     {
         UpdaterUtil.TryForIndex(result, state.Auxiliaries, (int)sourceCmd.Id, aux =>
         {
             aux.Source = sourceCmd.Source;
             result.SetSuccess($"Auxiliaries.{sourceCmd.Id:D}");
         });
     }
 }
Ejemplo n.º 9
0
        internal static void TryForIndex <T>(UpdateResultImpl result, IReadOnlyList <T> arr, int index, Action <T> func)
        {
            T obj = arr.ElementAtOrDefault(index);

            if (obj != null)
            {
                func(obj);
            }
            else
            {
                result.AddError($"Update for unknown {typeof(T).Name}: {index}");
            }
        }
Ejemplo n.º 10
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is HyperDeckSettingsGetCommand hyperdeckCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Hyperdecks, (int)hyperdeckCmd.Id, deck =>
                {
                    UpdaterUtil.CopyAllProperties(hyperdeckCmd, deck.Settings, new[] { "Id" });
                    result.SetSuccess($"Hyperdecks.{hyperdeckCmd.Id:D}.Settings");
                });
            }
            else if (command is HyperDeckPlayerGetCommand playerCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Hyperdecks, (int)playerCmd.Id, deck =>
                {
                    UpdaterUtil.CopyAllProperties(playerCmd, deck.Player, new[] { "Id" });
                    result.SetSuccess($"Hyperdecks.{playerCmd.Id:D}.Player");
                });
            }
            else if (command is HyperDeckStorageGetCommand storageCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Hyperdecks, (int)storageCmd.Id, deck =>
                {
                    UpdaterUtil.CopyAllProperties(storageCmd, deck.Storage, new[] { "Id" });
                    result.SetSuccess($"Hyperdecks.{storageCmd.Id:D}.Storage");
                });
            }
            else if (command is HyperDeckClipCountCommand clipCountCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Hyperdecks, (int)clipCountCmd.Id, deck =>
                {
                    deck.Clips = UpdaterUtil
                                 .CreateList(clipCountCmd.ClipCount, o => new HyperdeckState.ClipState());

                    result.SetSuccess($"Hyperdecks.{clipCountCmd.Id:D}.Clips");
                });
            }
            else if (command is HyperDeckClipInfoCommand clipCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Hyperdecks, (int)clipCmd.HyperdeckId, deck =>
                {
                    UpdaterUtil.TryForIndex(result, deck.Clips, (int)clipCmd.ClipId, clip =>
                    {
                        UpdaterUtil.CopyAllProperties(clipCmd, clip, new[] { "ClipId", "HyperdeckId" });
                        result.SetSuccess($"Hyperdecks.{clipCmd.HyperdeckId:D}.Clips.{clipCmd.ClipId:D}");
                    });
                });
            }
        }
Ejemplo n.º 11
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is MacroPoolConfigCommand macroCmd)
            {
                state.Macros.Pool = UpdaterUtil.CreateList(macroCmd.MacroCount, i => new MacroState.ItemState());
                result.SetSuccess("Macros.Pool");
            }
            else if (command is MacroPropertiesGetCommand propsCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Macros.Pool, (int)propsCmd.Index, item =>
                {
                    UpdaterUtil.CopyAllProperties(propsCmd, item, new [] { "Index" });
                    result.SetSuccess($"Macros.Pool.{propsCmd.Index:D}");
                });
            }
            else if (command is MacroRunStatusGetCommand runCmd)
            {
                state.Macros.RunStatus.RunIndex = runCmd.Index;
                state.Macros.RunStatus.Loop     = runCmd.Loop;

                if (runCmd.IsWaiting)
                {
                    state.Macros.RunStatus.RunStatus = MacroState.MacroRunStatus.UserWait;
                }
                else if (runCmd.IsRunning)
                {
                    state.Macros.RunStatus.RunStatus = MacroState.MacroRunStatus.Running;
                }
                else
                {
                    state.Macros.RunStatus.RunStatus = MacroState.MacroRunStatus.Idle;
                }

                result.SetSuccess("Macros.RunStatus");
            }
            else if (command is MacroRecordingStatusGetCommand recordCmd)
            {
                state.Macros.RecordStatus.RecordIndex = recordCmd.Index;
                state.Macros.RecordStatus.IsRecording = recordCmd.IsRecording;

                result.SetSuccess("Macros.RecordStatus");
            }
        }
Ejemplo n.º 12
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command, AtemStateBuilderSettings updateSettings)
        {
            if (command is MediaPlayerSourceGetCommand sourceCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MediaPlayers, (int)sourceCmd.Index, mp =>
                {
                    UpdaterUtil.CopyAllProperties(sourceCmd, mp.Source, new [] { "Index" });
                    result.SetSuccess($"MediaPlayers.{sourceCmd.Index:D}.Source");
                });
            }
            else if (command is MediaPlayerClipStatusGetCommand statusCmd)
            {
                if (state.MediaPool.Clips.Count > 0)
                {
                    UpdaterUtil.TryForIndex(result, state.MediaPlayers, (int)statusCmd.Index, mp =>
                    {
                        if (mp.ClipStatus == null)
                        {
                            mp.ClipStatus = new MediaPlayerState.ClipStatusState();
                        }

                        var skipProps = new List <string> {
                            "Index"
                        };
                        var ignoreDestProps = new List <string> {
                            "Index"
                        };
                        if (updateSettings != null && !updateSettings.TrackMediaClipFrames)
                        {
                            skipProps.Add("AtBeginning");
                            skipProps.Add("ClipFrame");
                            ignoreDestProps.Add("AtBeginning");
                            ignoreDestProps.Add("ClipFrame");
                        }

                        UpdaterUtil.CopyAllProperties(statusCmd, mp.ClipStatus, skipProps.ToArray(), ignoreDestProps.ToArray());
                        result.SetSuccess($"MediaPlayers.{statusCmd.Index:D}.ClipStatus");
                    });
                }
            }
        }
Ejemplo n.º 13
0
        private static void HandleTopologyCommand(AtemState state, UpdateResultImpl result, TopologyV811Command cmd)
        {
            state.Auxiliaries       = UpdaterUtil.CreateList(cmd.Auxiliaries, (i) => new AuxState());
            state.ColorGenerators   = UpdaterUtil.CreateList(2, (i) => new ColorState());
            state.DownstreamKeyers  = UpdaterUtil.CreateList(cmd.DownstreamKeyers, (i) => new DownstreamKeyerState());
            state.MediaPlayers      = UpdaterUtil.CreateList(cmd.MediaPlayers, (i) => new MediaPlayerState());
            state.SuperSources      = UpdaterUtil.CreateList(cmd.SuperSource, (i) => new SuperSourceState());
            state.Hyperdecks        = UpdaterUtil.CreateList(cmd.HyperDecks, i => new HyperdeckState());
            state.Settings.Talkback =
                UpdaterUtil.CreateList(cmd.TalkbackChannels, (i) => new SettingsState.TalkbackState());

            state.MixEffects = UpdaterUtil.CreateList(cmd.MixEffectBlocks, (i) =>
            {
                var me = new MixEffectState();
                if (cmd.Stingers > 0)
                {
                    me.Transition.Stinger = new MixEffectState.TransitionStingerState();
                }
                if (cmd.DVE > 0)
                {
                    me.Transition.DVE = new MixEffectState.TransitionDVEState();
                }

                return(me);
            });
            state.Settings.MultiViewers = UpdaterUtil.UpdateList(state.Settings.MultiViewers, cmd.Multiviewers, i => new MultiViewerState
            {
                Windows = new List <MultiViewerState.WindowState>(), // Size gets done in a second
            });

            state.Settings.MixMinusOutputs = UpdaterUtil.CreateList(cmd.MixMinusOutputs, i => new SettingsState.MixMinusOutputState());

            state.Info.AdvancedChromaKeyers    = cmd.AdvancedChromaKeyers;
            state.Info.OnlyConfigurableOutputs = cmd.OnlyConfigurableOutputs;
            state.Info.HasCameraControl        = cmd.CameraControl;

            // Everything has changed
            result.SetSuccess("");
        }
Ejemplo n.º 14
0
        private static void UpdateInputs(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is InputPropertiesGetCommand propsCmd)
            {
                if (!state.Settings.Inputs.ContainsKey(propsCmd.Id))
                {
                    state.Settings.Inputs[propsCmd.Id] = new InputState();
                }
                InputState props = state.Settings.Inputs[propsCmd.Id];

                props.Properties.AreNamesDefault = propsCmd.AreNamesDefault;
                props.Properties.LongName        = propsCmd.LongName;
                props.Properties.ShortName       = propsCmd.ShortName;

                //props.IsExternal = cmd.IsExternal;
                props.Properties.AvailableExternalPortTypes = propsCmd.AvailableExternalPorts.FindFlagComponents();
                props.Properties.CurrentExternalPortType    = propsCmd.ExternalPortType;
                props.Properties.InternalPortType           = propsCmd.InternalPortType;
                props.Properties.SourceAvailability         = propsCmd.SourceAvailability;
                props.Properties.MeAvailability             = propsCmd.MeAvailability;
                result.SetSuccess($"Settings.Inputs.{propsCmd.Id:D}.Properties");
            }
            else if (command is TallyBySourceCommand tallyCmd)
            {
                foreach (KeyValuePair <VideoSource, Tuple <bool, bool> > inp in tallyCmd.Tally)
                {
                    if (state.Settings.Inputs.TryGetValue(inp.Key, out InputState input))
                    {
                        InputState.TallyState inputTally = input.Tally;
                        if (inputTally.ProgramTally != inp.Value.Item1 || inputTally.PreviewTally != inp.Value.Item2)
                        {
                            inputTally.ProgramTally = inp.Value.Item1;
                            inputTally.PreviewTally = inp.Value.Item2;
                            result.SetSuccess($"Settings.Inputs.{inp.Key:D}.Tally");
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command, AtemStateBuilderSettings settings)
        {
            if (command is CameraControlSettingsGetCommand ccstCmd)
            {
                state.CameraControl.PeriodicFlushInterval = ccstCmd.Interval;
                result.SetSuccess("CameraControl.PeriodicFlushInterval");
            }
            else if (state.CameraControl != null)
            {
                if (command is CameraControlGetCommand camCmd)
                {
                    if (camCmd.Input != VideoSource.Black)
                    {
                        if (!state.CameraControl.Cameras.ContainsKey((int)camCmd.Input))
                        {
                            state.CameraControl.Cameras[(int)camCmd.Input] = new CameraControlState.CameraState();
                        }

                        UpdaterUtil.TryForKey(result, state.CameraControl.Cameras, (long)camCmd.Input, input =>
                        {
                            try
                            {
                                string[] path = CameraControlUtil.ApplyToState(input, camCmd,
                                                                               settings.IgnoreUnknownCameraControlProperties);
                                if (path.Length > 0)
                                {
                                    result.SetSuccess(path.Select(p => $"CameraControl.Cameras.{camCmd.Input:D}.p"));
                                }
                            }
                            catch (Exception e)
                            {
                                result.AddError(e.ToString());
                            }
                        });
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is ProgramInputGetCommand progCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)progCmd.Index, me => {
                    me.Sources.Program = progCmd.Source;
                    result.SetSuccess($"MixEffects.{progCmd.Index:D}.Sources");
                });
            }
            else if (command is PreviewInputGetCommand prevCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)prevCmd.Index, me => {
                    me.Sources.Preview = prevCmd.Source;
                    result.SetSuccess($"MixEffects.{prevCmd.Index:D}.Sources");
                });
            }
            else if (command is FadeToBlackPropertiesGetCommand ftbPropCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)ftbPropCmd.Index, me =>
                {
                    UpdaterUtil.CopyAllProperties(ftbPropCmd, me.FadeToBlack.Properties, new[] { "Index" });
                    result.SetSuccess($"MixEffects.{ftbPropCmd.Index:D}.FadeToBlack.Properties");
                });
            }
            else if (command is FadeToBlackStateCommand ftbCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)ftbCmd.Index, me =>
                {
                    UpdaterUtil.CopyAllProperties(ftbCmd, me.FadeToBlack.Status, new[] { "Index" });
                    result.SetSuccess($"MixEffects.{ftbCmd.Index:D}.FadeToBlack.Status");
                });
            }

            UpdateTransition(state, result, command);
            UpdateKeyers(state, result, command);
        }
Ejemplo n.º 17
0
        private static void UpdateKeyers(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is MixEffectBlockConfigCommand confCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)confCmd.Index, me =>
                {
                    me.Keyers = UpdaterUtil.CreateList(confCmd.KeyCount, i => new MixEffectState.KeyerState());
                    result.SetSuccess($"MixEffects.{confCmd.Index:D}.Keyers");
                });
            }
            else if (command is MixEffectKeyOnAirGetCommand onAirCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)onAirCmd.MixEffectIndex, me =>
                {
                    UpdaterUtil.TryForIndex(result, me.Keyers, (int)onAirCmd.KeyerIndex, keyer =>
                    {
                        keyer.OnAir = onAirCmd.OnAir;
                        result.SetSuccess($"MixEffects.{onAirCmd.MixEffectIndex:D}.Keyers.{onAirCmd.KeyerIndex:D}.OnAir");
                    });
                });
            }
            else if (command is MixEffectKeyPropertiesGetCommand propsCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)propsCmd.MixEffectIndex, me =>
                {
                    UpdaterUtil.TryForIndex(result, me.Keyers, (int)propsCmd.KeyerIndex, keyer =>
                    {
                        UpdaterUtil.CopyAllProperties(propsCmd, keyer.Properties, new [] { "MixEffectIndex", "KeyerIndex" });
                        result.SetSuccess($"MixEffects.{propsCmd.MixEffectIndex:D}.Keyers.{propsCmd.KeyerIndex:D}.Properties");
                    });
                });
            }
            else if (command is MixEffectKeyLumaGetCommand lumaCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)lumaCmd.MixEffectIndex, me =>
                {
                    UpdaterUtil.TryForIndex(result, me.Keyers, (int)lumaCmd.KeyerIndex, keyer =>
                    {
                        if (keyer.Luma == null)
                        {
                            keyer.Luma = new MixEffectState.KeyerLumaState();
                        }

                        UpdaterUtil.CopyAllProperties(lumaCmd, keyer.Luma, new [] { "MixEffectIndex", "KeyerIndex" });
                        result.SetSuccess($"MixEffects.{lumaCmd.MixEffectIndex:D}.Keyers.{lumaCmd.KeyerIndex:D}.Luma");
                    });
                });
            }
            else if (command is MixEffectKeyChromaGetCommand chromaCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)chromaCmd.MixEffectIndex, me =>
                {
                    UpdaterUtil.TryForIndex(result, me.Keyers, (int)chromaCmd.KeyerIndex, keyer =>
                    {
                        if (keyer.Chroma == null)
                        {
                            keyer.Chroma = new MixEffectState.KeyerChromaState();
                        }

                        UpdaterUtil.CopyAllProperties(chromaCmd, keyer.Chroma, new [] { "MixEffectIndex", "KeyerIndex" });
                        result.SetSuccess($"MixEffects.{chromaCmd.MixEffectIndex:D}.Keyers.{chromaCmd.KeyerIndex:D}.Chroma");
                    });
                });
            }
            else if (command is MixEffectKeyPatternGetCommand patternCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)patternCmd.MixEffectIndex, me =>
                {
                    UpdaterUtil.TryForIndex(result, me.Keyers, (int)patternCmd.KeyerIndex, keyer =>
                    {
                        if (keyer.Pattern == null)
                        {
                            keyer.Pattern = new MixEffectState.KeyerPatternState();
                        }

                        UpdaterUtil.CopyAllProperties(patternCmd, keyer.Pattern, new [] { "MixEffectIndex", "KeyerIndex" });
                        result.SetSuccess($"MixEffects.{patternCmd.MixEffectIndex:D}.Keyers.{patternCmd.KeyerIndex:D}.Pattern");
                    });
                });
            }
            else if (command is MixEffectKeyDVEGetCommand dveCmd)
            {
                if (state.Info.DVE != null)
                {
                    UpdaterUtil.TryForIndex(result, state.MixEffects, (int)dveCmd.MixEffectIndex, me =>
                    {
                        UpdaterUtil.TryForIndex(result, me.Keyers, (int)dveCmd.KeyerIndex, keyer =>
                        {
                            if (keyer.DVE == null)
                            {
                                keyer.DVE = new MixEffectState.KeyerDVEState();
                            }

                            UpdaterUtil.CopyAllProperties(dveCmd, keyer.DVE, new[] { "MixEffectIndex", "KeyerIndex" });
                            result.SetSuccess($"MixEffects.{dveCmd.MixEffectIndex:D}.Keyers.{dveCmd.KeyerIndex:D}.DVE");
                        });
                    });
                }
            }
            else if (command is MixEffectKeyFlyKeyframeGetCommand flyFrameCmd)
            {
                if (state.Info.DVE != null)
                {
                    UpdaterUtil.TryForIndex(result, state.MixEffects, (int)flyFrameCmd.MixEffectIndex, me =>
                    {
                        UpdaterUtil.TryForIndex(result, me.Keyers, (int)flyFrameCmd.KeyerIndex, keyer =>
                        {
                            if (keyer.FlyFrames == null)
                            {
                                keyer.FlyFrames = new List <MixEffectState.KeyerFlyFrameState>
                                {
                                    new MixEffectState.KeyerFlyFrameState(),
                                    new MixEffectState.KeyerFlyFrameState()
                                };
                            }

                            UpdaterUtil.TryForIndex(result, keyer.FlyFrames, (int)flyFrameCmd.KeyFrame - 1, frame =>
                            {
                                UpdaterUtil.CopyAllProperties(flyFrameCmd, frame,
                                                              new[] { "MixEffectIndex", "KeyerIndex", "KeyFrame" });
                                result.SetSuccess(
                                    $"MixEffects.{flyFrameCmd.MixEffectIndex:D}.Keyers.{flyFrameCmd.KeyerIndex:D}.FlyFrames.{(flyFrameCmd.KeyFrame - 1):D}");
                            });
                        });
                    });
                }
            }
            else if (command is MixEffectKeyFlyPropertiesGetCommand flyKeyCmd)
            {
                if (state.Info.DVE != null)
                {
                    UpdaterUtil.TryForIndex(result, state.MixEffects, (int)flyKeyCmd.MixEffectIndex, me =>
                    {
                        UpdaterUtil.TryForIndex(result, me.Keyers, (int)flyKeyCmd.KeyerIndex, keyer =>
                        {
                            if (keyer.FlyProperties == null)
                            {
                                keyer.FlyProperties = new MixEffectState.KeyerFlyProperties();
                            }

                            UpdaterUtil.CopyAllProperties(flyKeyCmd, keyer.FlyProperties,
                                                          new[] { "MixEffectIndex", "KeyerIndex" });
                            result.SetSuccess(
                                $"MixEffects.{flyKeyCmd.MixEffectIndex:D}.Keyers.{flyKeyCmd.KeyerIndex:D}.FlyProperties");
                        });
                    });
                }
            }
            else if (command is MixEffectKeyAdvancedChromaPropertiesGetCommand advChromaPropCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)advChromaPropCmd.MixEffectIndex, me =>
                {
                    UpdaterUtil.TryForIndex(result, me.Keyers, (int)advChromaPropCmd.KeyerIndex, keyer =>
                    {
                        if (keyer.AdvancedChroma == null)
                        {
                            keyer.AdvancedChroma = new MixEffectState.KeyerAdvancedChromaState();
                        }

                        UpdaterUtil.CopyAllProperties(advChromaPropCmd, keyer.AdvancedChroma.Properties, new[] { "MixEffectIndex", "KeyerIndex" });
                        result.SetSuccess($"MixEffects.{advChromaPropCmd.MixEffectIndex:D}.Keyers.{advChromaPropCmd.KeyerIndex:D}.AdvancedChroma.Properties");
                    });
                });
            }
            else if (command is MixEffectKeyAdvancedChromaSampleGetCommand advChromaSampleCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)advChromaSampleCmd.MixEffectIndex, me =>
                {
                    UpdaterUtil.TryForIndex(result, me.Keyers, (int)advChromaSampleCmd.KeyerIndex, keyer =>
                    {
                        if (keyer.AdvancedChroma == null)
                        {
                            keyer.AdvancedChroma = new MixEffectState.KeyerAdvancedChromaState();
                        }

                        UpdaterUtil.CopyAllProperties(advChromaSampleCmd, keyer.AdvancedChroma.Sample, new[] { "MixEffectIndex", "KeyerIndex" });
                        result.SetSuccess($"MixEffects.{advChromaSampleCmd.MixEffectIndex:D}.Keyers.{advChromaSampleCmd.KeyerIndex:D}.AdvancedChroma.Sample");
                    });
                });
            }
        }
Ejemplo n.º 18
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is AudioMixerConfigCommand confCmd)
            {
                state.Audio = new AudioState
                {
                    MonitorOutputs   = UpdaterUtil.CreateList(confCmd.Monitors, i => new AudioState.MonitorOutputState()),
                    HeadphoneOutputs = UpdaterUtil.CreateList(confCmd.Headphones, i => new AudioState.HeadphoneOutputState())
                };
                result.SetSuccess("Audio.MonitorOutputs");
            }
            else if (state.Audio != null)
            {
                if (command is AudioMixerMasterGetCommand masterCmd)
                {
                    UpdaterUtil.CopyAllProperties(masterCmd, state.Audio.ProgramOut, null,
                                                  new[] { "Levels", "AudioFollowVideoCrossfadeTransitionEnabled" });
                    result.SetSuccess("Audio.ProgramOut");
                }
                else if (command is AudioMixerMonitorGetCommand monCmd)
                {
                    UpdaterUtil.TryForIndex(result, state.Audio.MonitorOutputs, 0, mon => // TODO - dynamic index
                    {
                        UpdaterUtil.CopyAllProperties(monCmd, mon);
                        result.SetSuccess("Audio.MonitorOutputs.0");
                    });
                }
                else if (command is AudioMixerHeadphoneGetCommand hpCmd)
                {
                    UpdaterUtil.TryForIndex(result, state.Audio.HeadphoneOutputs, 0, mon => // TODO - dynamic index
                    {
                        UpdaterUtil.CopyAllProperties(hpCmd, mon);
                        result.SetSuccess("Audio.HeadphoneOutputs.0");
                    });
                }
                else if (command is AudioMixerInputGetV8Command input8Cmd)
                {
                    if (!state.Audio.Inputs.ContainsKey((int)input8Cmd.Index))
                    {
                        state.Audio.Inputs[(int)input8Cmd.Index] = new AudioState.InputState();
                    }

                    UpdaterUtil.TryForKey(result, state.Audio.Inputs, (long)input8Cmd.Index, input =>
                    {
                        if (input8Cmd.SupportsRcaToXlrEnabled)
                        {
                            input.Analog = new AudioState.InputState.AnalogState
                            {
                                RcaToXlr = input8Cmd.RcaToXlrEnabled
                            };
                        }
                        else
                        {
                            input.Analog = null;
                        }

                        UpdaterUtil.CopyAllProperties(input8Cmd, input.Properties, new[] { "Index", "IndexOfSourceType", "SupportsRcaToXlrEnabled", "RcaToXlrEnabled" });
                        result.SetSuccess($"Audio.Inputs.{input8Cmd.Index:D}.Properties");
                    });
                }
                else if (command is AudioMixerInputGetCommand inputCmd)
                {
                    if (!state.Audio.Inputs.ContainsKey((int)inputCmd.Index))
                    {
                        state.Audio.Inputs[(int)inputCmd.Index] = new AudioState.InputState();
                    }

                    UpdaterUtil.TryForKey(result, state.Audio.Inputs, (long)inputCmd.Index, input =>
                    {
                        UpdaterUtil.CopyAllProperties(inputCmd, input.Properties, new[] { "Index", "IndexOfSourceType" });
                        result.SetSuccess($"Audio.Inputs.{inputCmd.Index:D}.Properties");
                    });
                }
                else if (command is AudioMixerLevelsCommand levelsCmd)
                {
                    var paths = new List <string>(new[] { "Audio.ProgramOut.Levels" });
                    state.Audio.ProgramOut.Levels = new AudioState.LevelsState
                    {
                        Levels = new[] { levelsCmd.MasterLeftLevel, levelsCmd.MasterRightLevel },
                        Peaks  = new[] { levelsCmd.MasterLeftPeak, levelsCmd.MasterRightPeak },
                    };

                    foreach (AudioMixerLevelInput inputLevels in levelsCmd.Inputs)
                    {
                        UpdaterUtil.TryForKey(result, state.Audio.Inputs, (long)inputLevels.Source, input =>
                        {
                            paths.Add($"Audio.Inputs.{inputLevels.Source:D}.Levels");
                            input.Levels = new AudioState.LevelsState
                            {
                                Levels = new[] { inputLevels.LeftLevel, inputLevels.RightLevel },
                                Peaks  = new[] { inputLevels.LeftPeak, inputLevels.RightPeak },
                            };
                        });
                    }

                    result.SetSuccess(paths);
                }
                else if (command is AudioMixerTallyCommand tallyCmd)
                {
                    state.Audio.Tally = tallyCmd.Inputs;
                    result.SetSuccess($"Audio.Tally");
                }
                else if (command is AudioMixerPropertiesGetCommand mixCmd)
                {
                    state.Audio.ProgramOut.AudioFollowVideoCrossfadeTransitionEnabled = mixCmd.AudioFollowVideo;
                    result.SetSuccess($"Audio.ProgramOut.AudioFollowVideoCrossfadeTransitionEnabled");
                }
            }
        }
Ejemplo n.º 19
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is SuperSourceConfigV8Command conf8Cmd)
            {
                UpdaterUtil.TryForIndex(result, state.SuperSources, (int)conf8Cmd.SSrcId, ssrc =>
                {
                    ssrc.Boxes = UpdaterUtil.CreateList(conf8Cmd.Boxes, (i) => new SuperSourceState.BoxState());
                    result.SetSuccess($"SuperSources.{conf8Cmd.SSrcId:D}.Boxes");
                });
            }
            else if (command is SuperSourceConfigCommand confCmd)
            {
                UpdaterUtil.TryForIndex(result, state.SuperSources, 0, ssrc =>
                {
                    ssrc.Boxes = UpdaterUtil.CreateList(confCmd.Boxes, (i) => new SuperSourceState.BoxState());
                    result.SetSuccess($"SuperSources.0.Boxes");
                });
            }
            else if (command is SuperSourceBoxGetV8Command box8Cmd)
            {
                UpdaterUtil.TryForIndex(result, state.SuperSources, (int)box8Cmd.SSrcId, ssrc =>
                {
                    UpdaterUtil.TryForIndex(result, ssrc.Boxes, (int)box8Cmd.BoxIndex, box =>
                    {
                        UpdaterUtil.CopyAllProperties(box8Cmd, box, new [] { "SSrcId", "BoxIndex" });
                        result.SetSuccess($"SuperSources.{box8Cmd.SSrcId:D}.Boxes.{box8Cmd.BoxIndex:D}");
                    });
                });
            }
            else if (command is SuperSourceBoxGetCommand boxCmd)
            {
                UpdaterUtil.TryForIndex(result, state.SuperSources, 0, ssrc =>
                {
                    UpdaterUtil.TryForIndex(result, ssrc.Boxes, (int)boxCmd.BoxIndex, box =>
                    {
                        UpdaterUtil.CopyAllProperties(boxCmd, box, new [] { "Index" });
                        result.SetSuccess($"SuperSources.0.Boxes.{boxCmd.BoxIndex:D}");
                    });
                });
            }
            else if (command is SuperSourcePropertiesGetV8Command prop8Cmd)
            {
                UpdaterUtil.TryForIndex(result, state.SuperSources, (int)prop8Cmd.SSrcId, ssrc =>
                {
                    UpdaterUtil.CopyAllProperties(prop8Cmd, ssrc.Properties, new [] { "SSrcId" });
                    result.SetSuccess($"SuperSources.{prop8Cmd.SSrcId:D}.Properties");
                });
            }
            else if (command is SuperSourceBorderGetCommand borderCmd)
            {
                UpdaterUtil.TryForIndex(result, state.SuperSources, (int)borderCmd.SSrcId, ssrc =>
                {
                    UpdaterUtil.CopyAllProperties(borderCmd, ssrc.Border, new [] { "SSrcId" });
                    result.SetSuccess($"SuperSources.{borderCmd.SSrcId:D}.Border");
                });
            }
            else if (command is SuperSourcePropertiesGetCommand propCmd)
            {
                UpdaterUtil.TryForIndex(result, state.SuperSources, 0, ssrc =>
                {
                    UpdaterUtil.CopyAllProperties(propCmd, ssrc.Properties, new[]
                    {
                        "BorderEnabled",
                        "BorderBevel",
                        "BorderOuterWidth",
                        "BorderInnerWidth",
                        "BorderOuterSoftness",
                        "BorderInnerSoftness",
                        "BorderBevelSoftness",
                        "BorderBevelPosition",
                        "BorderHue",
                        "BorderSaturation",
                        "BorderLuma",
                        "BorderLightSourceAltitude",
                        "BorderLightSourceDirection",
                    });

                    ssrc.Border.Enabled              = propCmd.BorderEnabled;
                    ssrc.Border.Bevel                = propCmd.BorderBevel;
                    ssrc.Border.OuterWidth           = propCmd.BorderOuterWidth;
                    ssrc.Border.InnerWidth           = propCmd.BorderInnerWidth;
                    ssrc.Border.OuterSoftness        = propCmd.BorderOuterSoftness;
                    ssrc.Border.InnerSoftness        = propCmd.BorderInnerSoftness;
                    ssrc.Border.BevelSoftness        = propCmd.BorderBevelSoftness;
                    ssrc.Border.BevelPosition        = propCmd.BorderBevelPosition;
                    ssrc.Border.Hue                  = propCmd.BorderHue;
                    ssrc.Border.Saturation           = propCmd.BorderSaturation;
                    ssrc.Border.Luma                 = propCmd.BorderLuma;
                    ssrc.Border.LightSourceDirection = propCmd.BorderLightSourceDirection;
                    ssrc.Border.LightSourceAltitude  = propCmd.BorderLightSourceDirection;

                    result.SetSuccess($"SuperSources.0.Properties");
                    result.SetSuccess($"SuperSources.0.Border");
                });
            }
        }
Ejemplo n.º 20
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is StreamingServiceGetCommand srsuCmd)
            {
                if (state.Streaming == null)
                {
                    state.Streaming = new StreamingState();
                }

                state.Streaming.Settings.LowVideoBitrate  = srsuCmd.Bitrates[0];
                state.Streaming.Settings.HighVideoBitrate = srsuCmd.Bitrates[1];

                UpdaterUtil.CopyAllProperties(srsuCmd, state.Streaming.Settings,
                                              new List <string> {
                    "Bitrates"
                },
                                              new List <string> {
                    "LowVideoBitrate", "HighVideoBitrate", "LowAudioBitrate", "HighAudioBitrate"
                });
                result.SetSuccess("Streaming.Settings");
            }
            else if (command is StreamingAudioBitratesCommand audioCmd)
            {
                state.Streaming.Settings.LowAudioBitrate  = audioCmd.Bitrates[0];
                state.Streaming.Settings.HighAudioBitrate = audioCmd.Bitrates[1];
                result.SetSuccess("Streaming.Settings");
            }
            else if (command is StreamingTimecodeCommand timecodeCmd)
            {
                if (state.Streaming != null)
                {
                    state.Streaming.Status.Duration = new Timecode
                    {
                        Hour      = timecodeCmd.Hour,
                        Minute    = timecodeCmd.Minute,
                        Second    = timecodeCmd.Second,
                        Frame     = timecodeCmd.Frame,
                        DropFrame = timecodeCmd.IsDropFrame,
                    };
                    result.SetSuccess("Streaming.Status.Duration");
                }
            }
            else if (command is StreamingStatusGetCommand stateCmd)
            {
                if (state.Streaming != null)
                {
                    state.Streaming.Status.State = stateCmd.Status;
                    state.Streaming.Status.Error = stateCmd.Error;

                    result.SetSuccess("Streaming.Status.State");
                }
            }
            else if (command is StreamingAuthenticationCommand authCmd)
            {
                if (state.Streaming != null)
                {
                    UpdaterUtil.CopyAllProperties(authCmd, state.Streaming.Authentication);
                    result.SetSuccess("Streaming.Authentication");
                }
            }
            else if (command is StreamingStatsCommand srssCmd)
            {
                if (state.Streaming != null)
                {
                    state.Streaming.Stats.EncodingBitrate = srssCmd.EncodingBitrate;
                    state.Streaming.Stats.CacheUsed       = srssCmd.CacheUsed;
                    result.SetSuccess("Streaming.Stats");
                }
            }
        }
Ejemplo n.º 21
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is SerialPortModeCommand serialCmd)
            {
                state.Settings.SerialMode = serialCmd.SerialMode;
                result.SetSuccess($"Settings.SerialMode");
            }
            else if (command is VideoModeGetCommand videoCmd)
            {
                state.Settings.VideoMode = videoCmd.VideoMode;
                result.SetSuccess($"Settings.VideoMode");
            }
            else if (command is MultiviewVideoModeGetCommand mvCmd)
            {
                state.Settings.MultiviewVideoModes[mvCmd.CoreVideoMode] = mvCmd.MultiviewMode;
                result.SetSuccess($"Settings.MultiviewVideoModes.{mvCmd.CoreVideoMode:D}");
            }
            else if (command is DownConvertVideoModeGetCommand dcCmd)
            {
                state.Settings.DownConvertVideoModes[dcCmd.CoreVideoMode] = dcCmd.DownConvertedMode;
                result.SetSuccess($"Settings.DownConvertVideoModes.{dcCmd.CoreVideoMode:D}");
            }
            else if (command is AutoVideoModeCommand avmCmd)
            {
                var paths = new List <string> {
                    "Settings.AutoVideoMode"
                };
                state.Settings.AutoVideoMode     = avmCmd.Enabled;
                state.Settings.DetectedVideoMode = avmCmd.Detected;

                if (!state.Info.SupportsAutoVideoMode)
                {
                    state.Info.SupportsAutoVideoMode = true;
                    paths.Add("Info.SupportsAutoVideoMode");
                }

                result.SetSuccess(paths);
            }
            else if (command is DownConvertModeGetCommand dcModeCmd)
            {
                state.Settings.DownConvertMode = dcModeCmd.DownConvertMode;
                result.SetSuccess($"Settings.DownConvertVideoMode");
            }
            else if (command is SDI3GLevelOutputGetCommand sdiLevelCmd)
            {
                state.Settings.SDI3GLevel = sdiLevelCmd.SDI3GOutputLevel;
                result.SetSuccess("Settings.SDI3GLevel");
            }
            else if (command is SuperSourceCascadeCommand cascadeCmd)
            {
                state.Settings.SuperSourceCascade = cascadeCmd.Cascade;
                result.SetSuccess("Settings.SuperSourceCascade");
            }
            else if (command is MixMinusOutputGetCommand mmoCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Settings.MixMinusOutputs, (int)mmoCmd.Id, output =>
                {
                    UpdaterUtil.CopyAllProperties(mmoCmd, output, new[] { "Id" });
                    result.SetSuccess($"Settings.MixMinusOutputs.{mmoCmd.Id:D}");
                });
            }
            else if (command is TimeCodeConfigGetCommand tcCommand)
            {
                state.Settings.TimeCodeMode = tcCommand.Mode;
                result.SetSuccess("Settings.TimeCodeMode");
            }

            UpdateInputs(state, result, command);
            UpdateMultiViewers(state, result, command);
        }
Ejemplo n.º 22
0
        private static void UpdateMultiViewers(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is MultiviewerConfigV811Command multiviewer811Cmd)
            {
                state.Info.MultiViewers = new InfoState.MultiViewInfoState
                {
                    CanRouteInputs   = multiviewer811Cmd.CanRouteInputs,
                    SupportsVuMeters = multiviewer811Cmd.SupportsVuMeters,
                    SupportsProgramPreviewSwapped = multiviewer811Cmd.CanSwapPreviewProgram,
                    SupportsQuadrantLayout        = multiviewer811Cmd.SupportsQuadrants,
                    SupportsToggleSafeArea        = multiviewer811Cmd.CanToggleSafeArea,
                    CanChangeLayout = multiviewer811Cmd.CanChangeLayout,
                    //CanChangeVuMeterOpacity = multiviewer811Cmd.CanChangeVuMeterOpacity,
                };

                state.Settings.MultiViewers.ForEach(mv => mv.Windows = UpdaterUtil.UpdateList(mv.Windows,
                                                                                              multiviewer811Cmd.WindowCount,
                                                                                              w => new MultiViewerState.WindowState()));
                result.SetSuccess(new[] { $"Info.MultiViewers", $"Settings.MultiViewers" });
            }
            else if (command is MultiviewerConfigV8Command multiview8Cmd)
            {
                state.Info.MultiViewers = new InfoState.MultiViewInfoState
                {
                    CanRouteInputs   = multiview8Cmd.CanRouteInputs,
                    SupportsVuMeters = multiview8Cmd.SupportsVuMeters,
                    SupportsProgramPreviewSwapped = multiview8Cmd.CanSwapPreviewProgram,
                    SupportsQuadrantLayout        = multiview8Cmd.SupportsQuadrants,
                    SupportsToggleSafeArea        = multiview8Cmd.CanToggleSafeArea,
                };

                state.Settings.MultiViewers = UpdaterUtil.UpdateList(state.Settings.MultiViewers, multiview8Cmd.Count, i => new MultiViewerState
                {
                    Windows = new List <MultiViewerState.WindowState>(), // Size gets done in a second
                });
                state.Settings.MultiViewers.ForEach(mv => mv.Windows = UpdaterUtil.UpdateList(mv.Windows,
                                                                                              multiview8Cmd.WindowCount,
                                                                                              w => new MultiViewerState.WindowState()));
                result.SetSuccess(new[] { $"Info.MultiViewers", $"Settings.MultiViewers" });
            }
            else if (command is MultiviewerConfigCommand multiviewCmd)
            {
                state.Info.MultiViewers = new InfoState.MultiViewInfoState
                {
                    CanRouteInputs = multiviewCmd.CanRouteInputs,
                    SupportsProgramPreviewSwapped = multiviewCmd.CanSwapPreviewProgram
                };

                state.Settings.MultiViewers = UpdaterUtil.UpdateList(state.Settings.MultiViewers, multiviewCmd.Count, i => new MultiViewerState
                {
                    Windows = new List <MultiViewerState.WindowState>(), // Size gets done in a second
                });
                state.Settings.MultiViewers.ForEach(mv => mv.Windows = UpdaterUtil.UpdateList(mv.Windows,
                                                                                              multiviewCmd.WindowCount,
                                                                                              w => new MultiViewerState.WindowState()));
                result.SetSuccess(new[] { $"Info.MultiViewers", $"Settings.MultiViewers" });
            }
            else if (command is MultiviewVuOpacityCommand vuOpacityCmd)
            {
                // HACK - dont see a real property anywhere
                state.Info.MultiViewers.CanChangeVuMeterOpacity =
                    state.Info.Model != ModelId.MiniPro && state.Info.Model != ModelId.MiniProISO;

                UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)vuOpacityCmd.MultiviewIndex, mv =>
                {
                    mv.VuMeterOpacity = vuOpacityCmd.Opacity;
                    result.SetSuccess($"Settings.MultiViewers.{vuOpacityCmd.MultiviewIndex:D}.VuMeterOpacity");
                });
            }
            else if (command is MultiviewPropertiesGetV8Command props8Cmd)
            {
                UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)props8Cmd.MultiviewIndex, mv =>
                {
                    mv.Properties.Layout = props8Cmd.Layout;
                    mv.Properties.ProgramPreviewSwapped = props8Cmd.ProgramPreviewSwapped;

                    result.SetSuccess($"Settings.MultiViewers.{props8Cmd.MultiviewIndex:D}.Properties");
                });
            }
            else if (command is MultiviewPropertiesGetCommand propsCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)propsCmd.MultiviewIndex, mv =>
                {
                    if (!Enum.TryParse(propsCmd.Layout.ToString(), true, out MultiViewLayoutV8 layout))
                    {
                        layout = 0;
                    }
                    mv.Properties.Layout = layout;
                    mv.Properties.ProgramPreviewSwapped = propsCmd.ProgramPreviewSwapped;

                    result.SetSuccess($"Settings.MultiViewers.{propsCmd.MultiviewIndex:D}.Properties");
                });
            }
            else if (command is MultiviewWindowInputGetCommand winCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)winCmd.MultiviewIndex, mv =>
                {
                    UpdaterUtil.TryForIndex(result, mv.Windows, (int)winCmd.WindowIndex, win =>
                    {
                        win.Source           = winCmd.Source;
                        win.SupportsVuMeter  = winCmd.SupportVuMeter;
                        win.SupportsSafeArea = winCmd.SupportsSafeArea;

                        result.SetSuccess($"Settings.MultiViewers.{winCmd.MultiviewIndex:D}.Windows.{winCmd.WindowIndex:D}");
                    });
                });
            }
            else if (command is MultiviewWindowVuMeterGetCommand vuMeterCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)vuMeterCmd.MultiviewIndex, mv =>
                {
                    UpdaterUtil.TryForIndex(result, mv.Windows, (int)vuMeterCmd.WindowIndex, win =>
                    {
                        win.VuMeterEnabled = vuMeterCmd.VuEnabled;
                        result.SetSuccess($"Settings.MultiViewers.{vuMeterCmd.MultiviewIndex:D}.Windows.{vuMeterCmd.WindowIndex:D}");
                    });
                });
            }
            else if (command is MultiviewWindowSafeAreaCommand safeAreaCmd)
            {
                UpdaterUtil.TryForIndex(result, state.Settings.MultiViewers, (int)safeAreaCmd.MultiviewIndex, mv =>
                {
                    UpdaterUtil.TryForIndex(result, mv.Windows, (int)safeAreaCmd.WindowIndex, win =>
                    {
                        win.SafeAreaEnabled = safeAreaCmd.SafeAreaEnabled;
                        result.SetSuccess($"Settings.MultiViewers.{safeAreaCmd.MultiviewIndex:D}.SafeAreaEnabled");
                    });
                });
            }
        }
Ejemplo n.º 23
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is RecordingSettingsGetCommand rmsuCmd)
            {
                if (state.Recording == null)
                {
                    state.Recording = new RecordingState();
                }

                UpdaterUtil.CopyAllProperties(rmsuCmd, state.Recording.Properties);
                result.SetSuccess($"Recording.Properties");
            }
            else if (command is RecordingISOCommand isoCmd)
            {
                if (state.Recording != null)
                {
                    state.Recording.CanISORecordAllInputs = true;
                    state.Recording.ISORecordAllInputs    = isoCmd.ISORecordAllInputs;
                    result.SetSuccess($"Recording.ISORecordAllInputs");
                }
            }
            else if (command is RecordingStatusGetCommand statusCmd)
            {
                if (state.Recording != null)
                {
                    state.Recording.Status.State = statusCmd.Status;
                    state.Recording.Status.Error = statusCmd.Error;

                    state.Recording.Status.TotalRecordingTimeAvailable = statusCmd.TotalRecordingTimeAvailable;
                    result.SetSuccess($"Recording.Status");
                }
            }
            else if (command is RecordingDiskInfoCommand diskCmd)
            {
                if (state.Recording != null)
                {
                    if (diskCmd.Status == RecordingDiskStatus.Removed)
                    {
                        state.Recording.Disks.Remove(diskCmd.DiskId);
                    }
                    else
                    {
                        if (!state.Recording.Disks.TryGetValue(diskCmd.DiskId,
                                                               out RecordingState.RecordingDiskState disk))
                        {
                            disk = new RecordingState.RecordingDiskState();
                            state.Recording.Disks.Add(diskCmd.DiskId, disk);
                        }

                        UpdaterUtil.CopyAllProperties(diskCmd, disk); //, new []{"DiskId"});
                        result.SetSuccess($"Recording.Disks.{diskCmd.DiskId:D}");
                    }
                }
            }
            else if (command is RecordingDurationCommand timecodeCmd)
            {
                if (state.Recording != null)
                {
                    state.Recording.Status.Duration = new Timecode
                    {
                        Hour      = timecodeCmd.Hour,
                        Minute    = timecodeCmd.Minute,
                        Second    = timecodeCmd.Second,
                        Frame     = timecodeCmd.Frame,
                        DropFrame = timecodeCmd.IsDropFrame,
                    };
                    result.SetSuccess("Recording.Status.Duration");
                }
            }
        }
Ejemplo n.º 24
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is FairlightAudioMixerConfigCommand confCmd)
            {
                state.Fairlight = new FairlightAudioState
                {
                    Monitors = UpdaterUtil.CreateList(confCmd.Monitors,
                                                      i => new FairlightAudioState.MonitorOutputState()),
                };
                result.SetSuccess("Fairlight.Monitors");
            }
            else if (state.Fairlight != null)
            {
                if (command is FairlightMixerMasterGetCommand masterCmd)
                {
                    var pgmState = state.Fairlight.ProgramOut;
                    UpdaterUtil.CopyAllProperties(masterCmd, pgmState,
                                                  new[] { "EqualizerGain", "EqualizerEnabled", "MakeUpGain", "EqualizerBands" },
                                                  new[] { "Dynamics", "Equalizer", "AudioFollowVideoCrossfadeTransitionEnabled", "Levels", "Peaks" });

                    pgmState.Dynamics.MakeUpGain = masterCmd.MakeUpGain;
                    pgmState.Equalizer.Enabled   = masterCmd.EqualizerEnabled;
                    pgmState.Equalizer.Gain      = masterCmd.EqualizerGain;
                    if (masterCmd.EqualizerBands != pgmState.Equalizer.Bands.Count)
                    {
                        pgmState.Equalizer.Bands = pgmState.Equalizer.Bands.RebuildToLength(masterCmd.EqualizerBands,
                                                                                            (i) => new FairlightAudioState.EqualizerBandState());
                    }

                    result.SetSuccess(new[]
                    {
                        "Fairlight.ProgramOut",
                        "Fairlight.ProgramOut.Dynamics",
                        "Fairlight.ProgramOut.Equalizer"
                    });
                }
                else if (command is FairlightMixerMasterLimiterGetCommand masterLimCmd)
                {
                    var pgmDynamics = state.Fairlight.ProgramOut.Dynamics;
                    if (pgmDynamics.Limiter == null)
                    {
                        pgmDynamics.Limiter = new FairlightAudioState.LimiterState();
                    }

                    UpdaterUtil.CopyAllProperties(masterLimCmd, pgmDynamics.Limiter, null, new[] { "GainReductionLevel" });
                    result.SetSuccess("Fairlight.ProgramOut.Dynamics.Limiter");
                }
                else if (command is FairlightMixerMasterCompressorGetCommand masterCompCmd)
                {
                    var pgmDynamics = state.Fairlight.ProgramOut.Dynamics;
                    if (pgmDynamics.Compressor == null)
                    {
                        pgmDynamics.Compressor = new FairlightAudioState.CompressorState();
                    }

                    UpdaterUtil.CopyAllProperties(masterCompCmd, pgmDynamics.Compressor, null, new[] { "GainReductionLevel" });
                    result.SetSuccess("Fairlight.ProgramOut.Dynamics.Compressor");
                }
                else if (command is FairlightMixerInputGetCommand inpCmd)
                {
                    if (!state.Fairlight.Inputs.TryGetValue((long)inpCmd.Index, out var inputState))
                    {
                        inputState = state.Fairlight.Inputs[(long)inpCmd.Index] = new FairlightAudioState.InputState();
                    }

                    if (inpCmd.SupportsRcaToXlr)
                    {
                        inputState.Analog = new FairlightAudioState.AnalogState
                        {
                            SupportedInputLevel =
                                FairlightAnalogInputLevel.ConsumerLine | FairlightAnalogInputLevel.ProLine,
                            InputLevel = inpCmd.RcaToXlrEnabled
                                ? FairlightAnalogInputLevel.ConsumerLine
                                : FairlightAnalogInputLevel.ProLine
                        };
                    }

                    UpdaterUtil.CopyAllProperties(inpCmd, inputState, new[] { "Index", "SupportsRcaToXlr", "RcaToXlrEnabled" },
                                                  new[] { "Sources", "Analog", "Xlr" });
                    result.SetSuccess(new[]
                    {
                        $"Fairlight.Inputs.{inpCmd.Index:D}.ExternalPortType",
                        $"Fairlight.Inputs.{inpCmd.Index:D}.ActiveConfiguration",
                        $"Fairlight.Inputs.{inpCmd.Index:D}.Analog"
                    });
                }
                else if (command is FairlightMixerInputGetV811Command inp811Cmd)
                {
                    if (!state.Fairlight.Inputs.TryGetValue((long)inp811Cmd.Index, out var inputState))
                    {
                        inputState = state.Fairlight.Inputs[(long)inp811Cmd.Index] = new FairlightAudioState.InputState();
                    }

                    UpdaterUtil.CopyAllProperties(inp811Cmd, inputState, new[] { "Index", "SupportedInputLevels", "ActiveInputLevel" },
                                                  new[] { "Sources", "Analog", "Xlr" });

                    if (inp811Cmd.SupportedInputLevels != 0)
                    {
                        inputState.Analog = new FairlightAudioState.AnalogState
                        {
                            SupportedInputLevel = inp811Cmd.SupportedInputLevels,
                            InputLevel          = inp811Cmd.ActiveInputLevel
                        };
                    }

                    result.SetSuccess(new[]
                    {
                        $"Fairlight.Inputs.{inp811Cmd.Index:D}.ExternalPortType",
                        $"Fairlight.Inputs.{inp811Cmd.Index:D}.ActiveConfiguration",
                        $"Fairlight.Inputs.{inp811Cmd.Index:D}.Analog"
                    });
                }
                else if (command is FairlightMixerSourceGetCommand srcCmd)
                {
                    UpdaterUtil.TryForKey(result, state.Fairlight.Inputs, (long)srcCmd.Index, inputState =>
                    {
                        FairlightAudioState.InputSourceState srcState = inputState.Sources.FirstOrDefault(s => s.SourceId == srcCmd.SourceId);
                        if (srcState == null)
                        {
                            srcState = new FairlightAudioState.InputSourceState();
                            inputState.Sources.Add(srcState);
                        }

                        srcState.Dynamics.MakeUpGain = srcCmd.MakeUpGain;
                        srcState.Equalizer.Enabled   = srcCmd.EqualizerEnabled;
                        srcState.Equalizer.Gain      = srcCmd.EqualizerGain;
                        if (srcCmd.EqualizerBands != srcState.Equalizer.Bands.Count)
                        {
                            srcState.Equalizer.Bands = srcState.Equalizer.Bands.RebuildToLength(srcCmd.EqualizerBands,
                                                                                                (i) => new FairlightAudioState.EqualizerBandState());
                        }

                        UpdaterUtil.CopyAllProperties(srcCmd, srcState,
                                                      new[] { "Index", "EqualizerBands", "EqualizerEnabled", "EqualizerGain", "MakeUpGain" },
                                                      new[] { "Dynamics", "Equalizer", "Levels" });
                        result.SetSuccess($"Fairlight.Inputs.{srcCmd.Index:D}.Sources.{srcCmd.SourceId:D}");
                    });
                }
                else if (command is FairlightMixerSourceDeleteCommand delCmd)
                {
                    UpdaterUtil.TryForKey(result, state.Fairlight.Inputs, (long)delCmd.Index, inputState =>
                    {
                        inputState.Sources.RemoveAll(src => src.SourceId == delCmd.SourceId);
                        result.SetSuccess($"Fairlight.Inputs.{delCmd.Index:D}.Sources.{delCmd.SourceId:D}");
                    });
                }
                else if (command is FairlightMixerSourceCompressorGetCommand compCmd)
                {
                    UpdaterUtil.TryForKey(result, state.Fairlight.Inputs, (long)compCmd.Index, inputState =>
                    {
                        FairlightAudioState.InputSourceState srcState = inputState.Sources.FirstOrDefault(s => s.SourceId == compCmd.SourceId);
                        if (srcState != null)
                        {
                            if (srcState.Dynamics.Compressor == null)
                            {
                                srcState.Dynamics.Compressor = new FairlightAudioState.CompressorState();
                            }

                            UpdaterUtil.CopyAllProperties(compCmd, srcState.Dynamics.Compressor, new[] { "Index", "SourceId" }, new[] { "GainReductionLevel" });
                            result.SetSuccess($"Fairlight.Inputs.{compCmd.Index:D}.Sources.{compCmd.SourceId:D}.Dynamics.Compressor");
                        }
                    });
                }
                else if (command is FairlightMixerSourceLimiterGetCommand limCmd)
                {
                    UpdaterUtil.TryForKey(result, state.Fairlight.Inputs, (long)limCmd.Index, inputState =>
                    {
                        FairlightAudioState.InputSourceState srcState = inputState.Sources.FirstOrDefault(s => s.SourceId == limCmd.SourceId);
                        if (srcState != null)
                        {
                            if (srcState.Dynamics.Limiter == null)
                            {
                                srcState.Dynamics.Limiter = new FairlightAudioState.LimiterState();
                            }

                            UpdaterUtil.CopyAllProperties(limCmd, srcState.Dynamics.Limiter, new[] { "Index", "SourceId" }, new[] { "GainReductionLevel" });
                            result.SetSuccess($"Fairlight.Inputs.{limCmd.Index:D}.Sources.{limCmd.SourceId:D}.Dynamics.Limiter");
                        }
                    });
                }
                else if (command is FairlightMixerSourceExpanderGetCommand expandCmd)
                {
                    UpdaterUtil.TryForKey(result, state.Fairlight.Inputs, (long)expandCmd.Index, inputState =>
                    {
                        FairlightAudioState.InputSourceState srcState = inputState.Sources.FirstOrDefault(s => s.SourceId == expandCmd.SourceId);
                        if (srcState != null)
                        {
                            if (srcState.Dynamics.Expander == null)
                            {
                                srcState.Dynamics.Expander = new FairlightAudioState.ExpanderState();
                            }

                            UpdaterUtil.CopyAllProperties(expandCmd, srcState.Dynamics.Expander, new[] { "Index", "SourceId" }, new[] { "GainReductionLevel" });
                            result.SetSuccess($"Fairlight.Inputs.{expandCmd.Index:D}.Sources.{expandCmd.SourceId:D}.Dynamics.Expander");
                        }
                    });
                }
                else if (command is FairlightMixerAnalogAudioGetCommand analogCmd)
                {
                    UpdaterUtil.TryForKey(result, state.Fairlight.Inputs, (long)analogCmd.Index, inputState =>
                    {
                        if (inputState.Analog == null)
                        {
                            inputState.Analog = new FairlightAudioState.AnalogState();
                        }

                        UpdaterUtil.CopyAllProperties(analogCmd, inputState.Analog, new[] { "Index" });
                        result.SetSuccess($"Fairlight.Inputs.{analogCmd.Index:D}.Analog");
                    });
                }
                else if (command is FairlightMixerMonitorGetCommand monCmd)
                {
                    UpdaterUtil.TryForIndex(result, state.Fairlight.Monitors, 0, monState =>
                    {
                        UpdaterUtil.CopyAllProperties(monCmd, monState, new[] { "Index" });
                        result.SetSuccess($"Fairlight.Monitors.{0:D}");
                    });
                }
                else if (command is FairlightMixerMasterPropertiesGetCommand master2Cmd)
                {
                    state.Fairlight.ProgramOut.AudioFollowVideoCrossfadeTransitionEnabled =
                        master2Cmd.AudioFollowVideoCrossfadeTransitionEnabled;
                    result.SetSuccess($"Fairlight.ProgramOut");
                }
                else if (command is FairlightMixerMasterLevelsCommand pgmLevelCmd)
                {
                    FairlightAudioState.ProgramOutState pgmOutState = state.Fairlight.ProgramOut;
                    pgmOutState.Levels = new FairlightAudioState.LevelsState
                    {
                        Levels = new[] { pgmLevelCmd.LeftLevel, pgmLevelCmd.RightLevel },
                        Peaks  = new[] { pgmLevelCmd.LeftPeak, pgmLevelCmd.RightPeak },

                        DynamicsInputLevels  = new[] { pgmLevelCmd.InputLeftLevel, pgmLevelCmd.InputRightLevel },
                        DynamicsInputPeaks   = new[] { pgmLevelCmd.InputLeftPeak, pgmLevelCmd.InputRightPeak },
                        DynamicsOutputLevels = new[] { pgmLevelCmd.OutputLeftLevel, pgmLevelCmd.OutputRightLevel },
                        DynamicsOutputPeaks  = new[] { pgmLevelCmd.OutputLeftPeak, pgmLevelCmd.OutputRightPeak },

                        CompressorGainReductionLevel = pgmLevelCmd.CompressorGainReduction,
                        LimiterGainReductionLevel    = pgmLevelCmd.LimiterGainReduction,
                    };

                    result.SetSuccess($"Fairlight.ProgramOut.Levels");
                }
                else if (command is FairlightMixerSourceLevelsCommand srcLevelCmd)
                {
                    UpdaterUtil.TryForKey(result, state.Fairlight.Inputs, (long)srcLevelCmd.Index, inputState =>
                    {
                        FairlightAudioState.InputSourceState srcState = inputState.Sources.FirstOrDefault(s => s.SourceId == srcLevelCmd.SourceId);
                        if (srcState != null)
                        {
                            srcState.Levels = new FairlightAudioState.LevelsState
                            {
                                Levels = new[] { srcLevelCmd.LeftLevel, srcLevelCmd.RightLevel },
                                Peaks  = new[] { srcLevelCmd.LeftPeak, srcLevelCmd.RightPeak },

                                DynamicsInputLevels  = new[] { srcLevelCmd.InputLeftLevel, srcLevelCmd.InputRightLevel },
                                DynamicsInputPeaks   = new[] { srcLevelCmd.InputLeftPeak, srcLevelCmd.InputRightPeak },
                                DynamicsOutputLevels = new[] { srcLevelCmd.OutputLeftLevel, srcLevelCmd.OutputRightLevel },
                                DynamicsOutputPeaks  = new[] { srcLevelCmd.OutputLeftPeak, srcLevelCmd.OutputRightPeak },

                                CompressorGainReductionLevel = srcLevelCmd.CompressorGainReduction,
                                LimiterGainReductionLevel    = srcLevelCmd.LimiterGainReduction,
                                ExpanderGainReductionLevel   = srcLevelCmd.ExpanderGainReduction,
                            };

                            result.SetSuccess($"Fairlight.Inputs.{srcLevelCmd.Index:D}.Sources.{srcLevelCmd.SourceId:D}.Levels");
                        }
                    });
                }
                else if (command is FairlightMixerTallyCommand tallyCmd)
                {
                    state.Fairlight.Tally = tallyCmd.Tally;
                    result.SetSuccess("Fairlight.Tally");
                }
                else if (command is FairlightMixerSourceEqualizerBandGetCommand srcBandCmd)
                {
                    UpdaterUtil.TryForKey(result, state.Fairlight.Inputs, (long)srcBandCmd.Index, inputState =>
                    {
                        FairlightAudioState.InputSourceState srcState =
                            inputState.Sources.FirstOrDefault(s => s.SourceId == srcBandCmd.SourceId);
                        if (srcState != null)
                        {
                            UpdaterUtil.TryForIndex(result, srcState.Equalizer.Bands, (int)srcBandCmd.Band, band =>
                            {
                                UpdaterUtil.CopyAllProperties(srcBandCmd, band, new[] { "Index", "SourceId", "Band" });
                                result.SetSuccess($"Fairlight.Inputs.{srcBandCmd.Index:D}.Sources.{srcBandCmd.SourceId:D}.Equalizer.Bands.{srcBandCmd.Band:D}");
                            });
                        }
                    });
                }
                else if (command is FairlightMixerMasterEqualizerBandGetCommand pgmBandCmd)
                {
                    UpdaterUtil.TryForIndex(result, state.Fairlight.ProgramOut.Equalizer.Bands, (int)pgmBandCmd.Band, band =>
                    {
                        UpdaterUtil.CopyAllProperties(pgmBandCmd, band, new[] { "Band" });
                        result.SetSuccess($"Fairlight.ProgramOut.Equalizer.Bands.{pgmBandCmd.Band:D}");
                    });
                }
            }
        }
Ejemplo n.º 25
0
        private static void UpdateTransition(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is TransitionPropertiesGetCommand transCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)transCmd.Index, me =>
                {
                    UpdaterUtil.CopyAllProperties(transCmd, me.Transition.Properties, new[] { "Index" }, new[] { "PreviewTransition", "IsPreviewInProgram" });
                    result.SetSuccess($"MixEffects.{transCmd.Index:D}.Transition.Properties");
                });
            }
            else if (command is TransitionPositionGetCommand transPosCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)transPosCmd.Index, me =>
                {
                    UpdaterUtil.CopyAllProperties(transPosCmd, me.Transition.Position, new[] { "Index" });
                    result.SetSuccess($"MixEffects.{transPosCmd.Index:D}.Transition.Position");
                });
            }
            else if (command is TransitionPreviewGetCommand prevCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)prevCmd.Index, me =>
                {
                    me.Transition.Properties.PreviewTransition = prevCmd.PreviewTransition;
                    result.SetSuccess($"MixEffects.{prevCmd.Index:D}.Transition.Properties");
                });
            }
            else if (command is TransitionMixGetCommand mixCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)mixCmd.Index, me =>
                {
                    if (me.Transition.Mix == null)
                    {
                        me.Transition.Mix = new MixEffectState.TransitionMixState();
                    }

                    me.Transition.Mix.Rate = mixCmd.Rate;
                    result.SetSuccess($"MixEffects.{mixCmd.Index:D}.Transition.Mix");
                });
            }
            else if (command is TransitionDipGetCommand dipCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)dipCmd.Index, me =>
                {
                    if (me.Transition.Dip == null)
                    {
                        me.Transition.Dip = new MixEffectState.TransitionDipState();
                    }

                    UpdaterUtil.CopyAllProperties(dipCmd, me.Transition.Dip, new [] { "Index" });
                    result.SetSuccess($"MixEffects.{dipCmd.Index:D}.Transition.Dip");
                });
            }
            else if (command is TransitionWipeGetCommand wipeCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)wipeCmd.Index, me =>
                {
                    if (me.Transition.Wipe == null)
                    {
                        me.Transition.Wipe = new MixEffectState.TransitionWipeState();
                    }

                    UpdaterUtil.CopyAllProperties(wipeCmd, me.Transition.Wipe, new [] { "Index" });
                    result.SetSuccess($"MixEffects.{wipeCmd.Index:D}.Transition.Wipe");
                });
            }
            else if (command is TransitionStingerGetCommand stingerCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MixEffects, (int)stingerCmd.Index, me =>
                {
                    if (me.Transition.Stinger != null)
                    {
                        UpdaterUtil.CopyAllProperties(stingerCmd, me.Transition.Stinger, new[] { "Index" });
                        result.SetSuccess($"MixEffects.{stingerCmd.Index:D}.Transition.Stinger");
                    }
                });
            }
            else if (command is TransitionDVEGetCommand dveCmd)
            {
                if (state.Info.DVE != null)
                {
                    UpdaterUtil.TryForIndex(result, state.MixEffects, (int)dveCmd.Index, me =>
                    {
                        if (me.Transition.DVE == null)
                        {
                            me.Transition.DVE = new MixEffectState.TransitionDVEState();
                        }

                        UpdaterUtil.CopyAllProperties(dveCmd, me.Transition.DVE, new[] { "Index" });
                        result.SetSuccess($"MixEffects.{dveCmd.Index:D}.Transition.DVE");
                    });
                }
            }
        }
Ejemplo n.º 26
0
        public static void Update(AtemState state, UpdateResultImpl result, ICommand command)
        {
            if (command is MediaPoolConfigCommand confCmd)
            {
                state.MediaPool.Clips  = UpdaterUtil.CreateList(confCmd.ClipCount, i => new MediaPoolState.ClipState());
                state.MediaPool.Stills = UpdaterUtil.CreateList(confCmd.StillCount, i => new MediaPoolState.StillState());
                result.SetSuccess($"MediaPool");
            }
            else if (command is MediaPoolFrameDescriptionCommand frameCmd)
            {
                switch (frameCmd.Bank)
                {
                case MediaPoolFileType.Still:
                    UpdaterUtil.TryForIndex(result, state.MediaPool.Stills, (int)frameCmd.Index, still =>
                    {
                        UpdaterUtil.CopyAllProperties(frameCmd, still, new[] { "Index", "Bank" });
                        result.SetSuccess($"MediaPool.Stills.{frameCmd.Index:D}");
                    });
                    break;

                case MediaPoolFileType.Clip1:
                case MediaPoolFileType.Clip2:
                case MediaPoolFileType.Clip3:
                case MediaPoolFileType.Clip4:
                    int bankId = (int)frameCmd.Bank - 1;
                    UpdaterUtil.TryForIndex(result, state.MediaPool.Clips, bankId, clip =>
                    {
                        UpdaterUtil.TryForIndex(result, clip.Frames, (int)frameCmd.Index, frame =>
                        {
                            UpdaterUtil.CopyAllProperties(frameCmd, frame, new[] { "Index", "Bank", "Filename" });
                            result.SetSuccess($"MediaPool.Clips.{bankId:D}.Frames.{frameCmd.Index:D}");
                        });
                    });
                    break;
                }
            }
            else if (command is MediaPoolAudioDescriptionCommand audioCmd)
            {
                uint index = audioCmd.Index - 1;
                UpdaterUtil.TryForIndex(result, state.MediaPool.Clips, (int)index, clip =>
                {
                    UpdaterUtil.CopyAllProperties(audioCmd, clip.Audio, new[] { "Index" });
                    result.SetSuccess($"MediaPool.Clips.{index:D}.Audio");
                });
            }
            else if (command is MediaPoolClipDescriptionCommand clipCmd)
            {
                UpdaterUtil.TryForIndex(result, state.MediaPool.Clips, (int)clipCmd.Index, clip =>
                {
                    clip.IsUsed     = clipCmd.IsUsed;
                    clip.Name       = clipCmd.Name;
                    clip.FrameCount = clipCmd.FrameCount;

                    result.SetSuccess($"MediaPool.Clips.{clipCmd.Index:D}");
                });
            }
            else if (command is MediaPoolSettingsGetCommand settingsCmd)
            {
                state.MediaPool.Clips.ForEach((i, clip) =>
                {
                    clip.MaxFrames = settingsCmd.MaxFrames[i];
                    clip.Frames    = UpdaterUtil.UpdateList(clip.Frames, settingsCmd.MaxFrames[i],
                                                            o => new MediaPoolState.FrameState());
                });
                state.MediaPool.UnassignedFrames = settingsCmd.UnassignedFrames;
                result.SetSuccess(new[] { $"MediaPool.Clips", $"MediaPool.UnassignedFrames" });
            }
        }