public static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Please include IP address for ATEM."); return; } string ipAddress = args[0]; var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); var log = LogManager.GetLogger(typeof(Program)); log.Info("Starting"); var currentStateCommands = new CommandQueue(); var unknownCommandId = 1; var upstream = new UpstreamConnection(ipAddress); var server = new AtemServer(currentStateCommands); server.Connections.OnReceive += (sender, pkt) => { log.InfoFormat("Got packet from {0}", sender); var acceptedCommands = new List <Tuple <ICommand, byte[]> >(); foreach (ParsedCommandSpec rawCmd in pkt.Commands) { var cmd = CommandParser.Parse(upstream.Version, rawCmd); if (cmd != null) { if (AtemProxyUtil.AudioLevelCommands.Contains(cmd.GetType())) { if (cmd is AudioMixerSendLevelsCommand sendLevels && server.Connections.SubscribeAudio(sender, sendLevels.SendLevels)) { log.InfoFormat("Changing legacy levels subscription: {0}", sendLevels.SendLevels); acceptedCommands.Add(Tuple.Create(cmd, AtemProxyUtil.ParsedCommandToBytes(rawCmd))); } else if (cmd is FairlightMixerSendLevelsCommand sendLevels2 && server.Connections.SubscribeAudio(sender, sendLevels2.SendLevels)) { log.InfoFormat("Changing fairlight levels subscription: {0}", sendLevels2.SendLevels); acceptedCommands.Add(Tuple.Create(cmd, AtemProxyUtil.ParsedCommandToBytes(rawCmd))); } } else if (AtemProxyUtil.LockCommands.Contains(cmd.GetType())) { } else if (AtemProxyUtil.TransferCommands.Contains(cmd.GetType())) { } else { acceptedCommands.Add(Tuple.Create(cmd, AtemProxyUtil.ParsedCommandToBytes(rawCmd))); } }
private void QueueDataDumps(AtemConnection conn) { try { var messages = AtemProxyUtil.CommandsToMessages(_state.Values()); foreach (var msg in messages) { conn.QueueMessage(msg); } } catch (Exception e) { Console.WriteLine(e.Message); } }