void SetSourceWithSettings(CaptureSettings settings, DeviceEntry source, DeviceEntry audioSource) { activeSource = source; activeAudio = audioSource; captureView.Play(source?.Filter, audioSource?.Filter); if (settings.SourceSettings != null && settings.SourceSettings.TryGetValue(source?.Name, out var sourceSettings)) { ApplySettings(sourceSettings, captureView.AudioSettings); } if (settings.AudioSettings != null && settings.AudioSettings.TryGetValue(audioSource?.Name, out var audioSettings)) { ApplySettings(captureView.SourceSettings, audioSettings); } if (activeSource != null) { Program.State.SetSourceDevice(activeSource.Name); } if (activeAudio != null) { Program.State.SetAudioDevice(activeAudio.Name); } Program.State.SaveSettings(); }
public void SetAudioDevice(string deciceName) { var settings = Settings; settings.AudioName = deciceName; Settings = settings; }
public void SetSourceDevice(string deciceName) { var settings = Settings; settings.SourceName = deciceName; Settings = settings; }
public GlobalState() { SettingsPath = Application.LocalUserAppDataPath; SettingsFilePath = Path.Combine(SettingsPath, SettingsFileName); SourceList = new VideoInputDeviceList(); AudioList = new AudioInputDeviceList(); Settings = new CaptureSettings(); /*{ * //SourceName = "3", * //SourceName = "CY", * //SourceName = "Unknown (3)", * * SourceSettings = new Dictionary<string, SourceSettings> * { * { "CY3014 USB, Analog 01 Capture", new SourceSettings * { * SourceAspectFit = SourceAspectFit.LetterBox, * FixedResolution = true, * * ResolutionWidth = 1024, * ResolutionHeight = 768, * * MultiplyerHeight = 1, * MultiplyerWidth = 1, * } * }, * }, * * //AudioName = "Line In", * };*/ }
public void SaveSettings() { try { var json = JsonConvert.SerializeObject(Settings, JsonOptions); File.WriteAllText(SettingsFilePath, json); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); Settings = new CaptureSettings(); } }
public void LoadSettings() { try { if (File.Exists(SettingsFilePath)) { var json = File.ReadAllText(SettingsFilePath); Settings = JsonConvert.DeserializeObject <CaptureSettings>(json, JsonOptions); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); Settings = new CaptureSettings(); } }
void LoadSettings(CaptureSettings settings) { var sourceName = settings; if (Program.State.SourceList.TryGetByName(settings.SourceName, out var source) && Program.State.AudioList.TryGetByName(settings.AudioName, out var audioSource)) { SetSourceWithSettings(settings, source, audioSource); return; } foreach (var entry in Program.State.SourceList.List) { try { SetSourceWithSettings(settings, entry, activeAudio); return; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); } } foreach (var entry in Program.State.AudioList.List) { try { SetSourceWithSettings(settings, activeSource, entry); return; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); } } }
public void SetSettings(string deviceName, IDeviceSettings deviceSettings) { var settings = Settings; if (deviceSettings is SourceSettings) { if (settings.SourceSettings == null) { settings.SourceSettings = new Dictionary <string, SourceSettings>(); } settings.SourceSettings[deviceName] = (SourceSettings)deviceSettings; } else if (deviceSettings is AudioSettings) { if (settings.AudioSettings == null) { settings.AudioSettings = new Dictionary <string, AudioSettings>(); } settings.AudioSettings[deviceName] = (AudioSettings)deviceSettings; } Settings = settings; }