public void Run(string address, string filename) { _file = new StreamWriter(filename); _macros = new List <MacroPropertiesGetCommand>(); _client = new AtemClient(address, false); _client.OnReceive += OnCommand; _client.Connect(); Console.ReadLine(); }
public AtemMacroStore(string address) { _macros = new Dictionary <uint, MacroPropertiesGetCommand>(); _client = new AtemClient(address, false); _profile = new DeviceProfileHandler(); _dataTransferLock = new object(); _client.OnReceive += _profile.HandleCommands; _client.OnReceive += OnCommand; _client.Connect(); }
public void EnsureMediaIsDownloaded(AtemClient client, AtemState state) { // TODO - ensure clips and audio lock (_cache) { var usedHashes = new HashSet <string>(); // Ensure stills have entries in the cache state.MediaPool.Stills.ForEach((index, still) => { if (still.IsUsed) { string hashString = BitConverter.ToString(still.Hash).Replace("-", ""); usedHashes.Add(hashString); if (!_cache.ContainsKey(hashString)) { _cache.Add(hashString, new AtemMediaCacheItem((uint)index)); } } }); // Prune out old entries foreach (KeyValuePair <string, AtemMediaCacheItem> entry in _cache) { if (!usedHashes.Contains(entry.Key)) { lock (entry.Value.JobLock) { entry.Value.Job?.Invalidate(); } _cache.Remove(entry.Key); } } // Ensure each entry has been/is being loaded foreach (KeyValuePair <string, AtemMediaCacheItem> entry in _cache) { lock (entry.Value.JobLock) { if (entry.Value.RawFrame == null && entry.Value.Job == null) { // TODO - dynamic resolution entry.Value.Job = DownloadStillJob(entry.Value); client.DataTransfer.QueueJob(entry.Value.Job); } } } } }
static void Main(string[] args) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); var log = LogManager.GetLogger(typeof(Program)); log.Info("Starting"); var client = new AtemClient("10.42.13.99"); Console.WriteLine("Hello World!"); }
public AtemService( AtemSettings atemSettings, AtemStatus atemStatus, ILogger <AtemService> logger, IHubContext <TallyHub, ITallyClient> tallyHub) { Log = logger; AtemSettings = atemSettings; TallyHub = tallyHub; AtemStatus = atemStatus; Client = new AtemClient(AtemSettings.Mixer); Client.OnReceive += OnCommand; Client.OnConnection += OnConnect; Client.OnDisconnect += OnDisconnect; }
public static void Main(string[] args) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); var log = LogManager.GetLogger(typeof(Program)); log.Info("Starting"); Config config = JsonConvert.DeserializeObject <Config>(File.ReadAllText("config.json")); using (var client = new AtemClient(config.AtemAddress)) { new XplosionGraphicsLinker(config, client).Start(); Console.WriteLine("Press any key to terminate..."); Console.ReadKey(); // Pause until keypress } }
/* * [Fact] * public void TestStateReal() * { * var stateSettings = new AtemStateBuilderSettings(); * using var helper = new AtemSdkClientWrapper("10.42.13.95", stateSettings); * * var libAtemState = GetLibAtemState(stateSettings, "10.42.13.95"); * * List<string> before = AtemStateComparer.AreEqual(helper.State, libAtemState); * if (before.Count != 0 && _output != null) * { * _output.WriteLine("state mismatch:"); * before.ForEach(_output.WriteLine); * } * Assert.Empty(before); * } */ private AtemState GetLibAtemState(AtemStateBuilderSettings stateSettings, string address) { using var client = new AtemClient(address, false); var state = new AtemState(); AutoResetEvent handshakeEvent = new AutoResetEvent(false); bool handshakeFinished = false; client.OnReceive += (o, cmds) => { cmds.ForEach(cmd => AtemStateBuilder.Update(state, cmd, stateSettings)); if (!handshakeFinished && cmds.Any(c => c is InitializationCompleteCommand)) { handshakeEvent.Set(); handshakeFinished = true; } }; client.Connect(); Assert.True(handshakeEvent.WaitOne(5000)); return(state); }
public XplosionGraphicsLinker(Config config, AtemClient client) { Config = config; Client = client; }
public AtemClientExt(string deviceId, AtemClient client, IHubContext <DevicesHub> context, TransferJobMonitor transfers, HashSet <string> subscriptions) { _deviceId = deviceId; _profile = new DeviceProfileHandler(); _subscriptions = subscriptions; _state = new AtemState(); _context = context; _mediaCache = new AtemMediaCache(transfers); Client = client; Client.OnReceive += _profile.HandleCommands; Client.OnConnection += sender => { Connected = true; OnChange?.Invoke(this); SendState(GetState()); }; Client.OnDisconnect += sender => { Connected = false; OnChange?.Invoke(this); SendState(null); }; Client.OnReceive += (sender, commands) => { var changedPaths = new HashSet <string>(); var errors = new List <string>(); lock (_state) { foreach (var command in commands) { var res = AtemStateBuilder.Update(_state, command); changedPaths.AddRange(res.ChangedPaths); if (!res.Success) { if (res.Errors.Count > 0) { errors.AddRange(res.Errors); } else { errors.Add($"Failed to update state for {command.GetType().Name}"); } } } } AtemState newState = GetState(); /* * var diffs = new Dictionary<string, object>(); * foreach (string path in changedPaths) * { * diffs.Add(path, new object()); // TODO * }*/ SendStateDiff(GetState(), changedPaths); _mediaCache.EnsureMediaIsDownloaded(Client, newState); }; Client.DataTransfer.OnJobStarted += (sender, job) => transfers.JobStarted(deviceId, job); Client.DataTransfer.OnJobQueued += (sender, job) => transfers.JobQueued(deviceId, job); }
public static void Main(string[] args) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); var log = LogManager.GetLogger(typeof(Program)); log.Info("Starting"); Config config = JsonConvert.DeserializeObject <Config>(File.ReadAllText("config.json")); var client = new AtemClient(config.AtemAddress); ConsoleKeyInfo key; Console.WriteLine("Press escape to exit"); while ((key = Console.ReadKey()).Key != ConsoleKey.Escape) { if (config.MixEffect != null) { foreach (KeyValuePair <MixEffectBlockId, Config.MixEffectConfig> me in config.MixEffect) { if (me.Value.Program != null && me.Value.Program.TryGetValue(key.KeyChar, out VideoSource src)) { client.SendCommand(new ProgramInputSetCommand { Index = me.Key, Source = src }); } if (me.Value.Preview != null && me.Value.Preview.TryGetValue(key.KeyChar, out src)) { client.SendCommand(new PreviewInputSetCommand { Index = me.Key, Source = src }); } if (me.Value.Cut == key.KeyChar) { client.SendCommand(new MixEffectCutCommand { Index = me.Key }); } if (me.Value.Auto == key.KeyChar) { client.SendCommand(new MixEffectAutoCommand { Index = me.Key }); } } } if (config.Auxiliary != null) { foreach (KeyValuePair <AuxiliaryId, Dictionary <char, VideoSource> > aux in config.Auxiliary) { if (aux.Value == null) { continue; } if (aux.Value.TryGetValue(key.KeyChar, out VideoSource src)) { client.SendCommand(new AuxSourceSetCommand { Id = aux.Key, Source = src }); } } } if (config.SuperSource != null) { foreach (KeyValuePair <SuperSourceBoxId, Dictionary <char, VideoSource> > box in config.SuperSource) { if (box.Value == null) { continue; } if (box.Value.TryGetValue(key.KeyChar, out VideoSource src)) { client.SendCommand(new SuperSourceBoxSetCommand { Mask = SuperSourceBoxSetCommand.MaskFlags.Source, Index = box.Key, Source = src }); } } } } }