public ScreenCaptureWorker(IScreenCaptureService screenCaptureService, Size canvasBounds, int captureFps, int idleTimeout) : base(idleTimeout) { _screenCaptureService = screenCaptureService; CaptureInterval = CalculateHaltInterval(captureFps); CanvasBounds = canvasBounds; ProgressHandler = new Progress <ScreenCaptureProgressArgs>(progressArgs => { ProgressChanged.Invoke(this, progressArgs); }); }
public ScreenCaptureWorker(IScreenCaptureService screenCaptureService, int captureInterval) { _screenCaptureService = screenCaptureService; CaptureInterval = captureInterval; _progressHandler = new Progress <ScreenCaptureProgressArgs>(progressArgs => { ProgressChanged.Invoke(this, progressArgs); }); }
private void SystemEventsOnDisplaySettingsChanged(object sender, EventArgs e) { if (_brushProvider.Instance == null || !_brushProvider.Instance.IsEnabled) { _logger?.Debug("Display settings changed, but ambilight feature is disabled"); } else { _logger?.Debug("Display settings changed, restarting ambilight feature"); _managementService.DisablePluginFeature(_brushProvider.Instance, false); ScreenCaptureService?.Dispose(); ScreenCaptureService = new AmbilightScreenCaptureService(new DX11ScreenCaptureService()); _managementService.EnablePluginFeature(_brushProvider.Instance, false); } }
public override void Initialize() { base.Initialize(); var captureCommandLine = MazeContext.Request.Headers["capture"]; var encoderCommandLine = MazeContext.Request.Headers[HeaderNames.AcceptEncoding]; var captureOptions = ComponentOptions.Parse(captureCommandLine); var encoderOptions = ComponentOptions.Parse(encoderCommandLine); _captureService = ResolveService(captureOptions, _captureServices); _streamEncoder = ResolveService(encoderOptions, _streamEncoders); var screenInfo = _captureService.Initialize(captureOptions); _streamEncoder.Initialize(screenInfo, this, encoderOptions); }
private void InitializeStreamingComponents(CaptureType captureType, int monitor, int quality, IConnectionInfo connectionInfo, bool drawCursor, ImageCompressionType compressionType) { var oldScreenCaptureService = _screenCaptureService; _screenCaptureService = _screenCaptureServices[captureType](); try { _screenCaptureService.Initialize(monitor); } catch (Exception ex) { _screenCaptureService = oldScreenCaptureService; ResponseBytes((byte)RemoteDesktopCommunication.ResponseInitializationFailed, Encoding.UTF8.GetBytes(ex.Message), connectionInfo); return; } Program.WriteLine($"InitializeStreamingComponents: oldScreenCaptureService == null: {oldScreenCaptureService == null} (else dispose)"); oldScreenCaptureService?.Dispose(); Program.WriteLine("Dispose other stuff in InitializeStreamingComponents"); _unsafeCodec?.Dispose(); _cursorStreamCodec?.Dispose(); _unsafeCodec = new UnsafeStreamCodec(GetImageCompression(compressionType), UnsafeStreamCodecParameters.DontDisposeImageCompressor | UnsafeStreamCodecParameters.UpdateImageEveryTwoSeconds); _currentImageCompression.Quality = quality; if (drawCursor) { _cursorStreamCodec = new CursorStreamCodec(); } _compressionType = compressionType; _currentMonitor = monitor; _drawCursor = drawCursor; ResponseByte((byte)RemoteDesktopCommunication.ResponseInitializationSucceeded, connectionInfo); Debug.Print("Initialized"); }
public ConfigForm() { InitializeComponent(); var captureServiceProvider = new ScreenCaptureServiceProvider(); _captureService = captureServiceProvider.Provide(false); _updateImageTimer = new Timer(); _updateImageTimer.Interval = 100; _updateImageTimer.Tick += UpdatePictureBox; _updateImageTimer.Start(); screenList.DataSource = Screen.AllScreens; screenList.DisplayMember = "DeviceName"; Screen primaryScreen = Screen.PrimaryScreen; screenList.SelectedItem = primaryScreen; _selectedScreen = primaryScreen; SetScreenClickMode(ScreenClickMode.None); }
private void ApplyConfig(AmbiLightConfig config) { if (_screenCaptureService != null) { _screenCaptureService.Dispose(); } _screenCaptureService = _screenCaptureServiceProvider.Provide(true); List <IOutputPlugin> plugins = OutputPlugins.GetAvailablePlugins(); List <ScreenRegionOutput> regions = config.RegionsToOutput; if (_regionConfigurations != null) { foreach (RegionConfiguration regionConfiguration in _regionConfigurations) { regionConfiguration.Dispose(); } } _regionConfigurations = new List <RegionConfiguration>(); var regionConfigId = 0; foreach (ScreenRegionOutput region in regions) { var regionConfig = new RegionConfiguration(regionConfigId++) { ScreenRegion = region.ScreenRegion, ColorAveragingService = _colorAveragingServiceProvider.Provide(region.ColorAveragingConfig), OutputConfigs = new List <OutputConfiguration>() }; var outputId = 0; foreach (Output output in region.Outputs) { IOutputInfo outputInfo = output.OutputInfo; IOutputPlugin plugin = plugins.FirstOrDefault(y => y.Name == outputInfo.PluginName); if (plugin == null) { throw new InvalidOperationException(string.Format("Missing OutputPlugin {0}", outputInfo.PluginName)); } OutputService outputService = _regionConfigurations.SelectMany(x => x.OutputConfigs).Select(x => x.OutputService).FirstOrDefault(x => x.IsReusableFor(outputInfo)) ?? plugin.GetNewOutputService(); outputService.Initialize(outputInfo); IList <ColorTransformerConfig> colorTransformerConfigs = output.ColorTransformerConfigs; if (colorTransformerConfigs == null) { colorTransformerConfigs = new List <ColorTransformerConfig> { new ColorTransformerConfig { Type = typeof(HysteresisColorTransformer), Config = new Dictionary <string, object> { { "hysteresis", "0.01" } } }, new ColorTransformerConfig { Type = typeof(BrightnessColorTransformer), Config = new Dictionary <string, object> { { "factorR", "1" }, { "factorG", "1" }, { "factorB", "0.9" } } }, //new ColorTransformerConfig //{ // Type = typeof (GammaColorTransformer), // Config = new Dictionary<string, object> // { // {"gammaR", "1"}, // {"gammaG", "1.2"}, // {"gammaB", "1.2"} // } //}, new ColorTransformerConfig { Type = typeof(ThresholdColorTransformer), Config = new Dictionary <string, object> { { "threshold", "0.01" } } } }; } var outputConfig = new OutputConfiguration(regionConfig.Id, outputId++) { ColorTransformerContexts = colorTransformerConfigs.Select(x => new ColorTransformerContext(x)).ToList(), OutputService = outputService, ResendIntervalFunc = outputService.GetResendInterval, OutputInfo = outputInfo }; regionConfig.OutputConfigs.Add(outputConfig); } _regionConfigurations.Add(regionConfig); } _screenRegions = _regionConfigurations.Select(x => x.ScreenRegion).ToList(); }
public FeedbackViewModel(IScreenCaptureService screenCaptureService, IDialogService dialogService) { _screenCaptureService = screenCaptureService; _dialogService = dialogService; }
public override void OnPluginDisabled(Plugin plugin) { ScreenCaptureService?.Dispose(); ScreenCaptureService = null; SystemEvents.DisplaySettingsChanged -= SystemEventsOnDisplaySettingsChanged; }