예제 #1
0
        private void SetupStreamers()
        {
            int screenId = 0;

            foreach (Screen screen in Screen.AllScreens)
            {
                ScreenVideoSource videoSource = new ScreenVideoSource(screen, screenId++);
                MJPEGStreamer     streamer    = new MJPEGStreamer(videoSource, qualityDefinition);
                streamer.StreamStarted += (sender, e) => {
                    if (_isRunning)
                    {
                        AddStreamClient(GetClientStreamDescription(e.Stream));
                    }
                };
                streamer.StreamStopped += (sender, e) => {
                    if (_isRunning)
                    {
                        RemoveStreamClient(GetClientStreamDescription(e.Stream));
                    }
                };

                string streamName = $"screen{screenId}";

                _streamers[streamName] = streamer;

                _previewImageList.Images.Add(streamName, _blankImage);
                _screensListView.Items.Add(streamName, $"Screen {screenId}", streamName);
            }
        }
예제 #2
0
        private void UpdatePreviews()
        {
            foreach (MJPEGStreamer streamer in _streamers.Values)
            {
                ScreenVideoSource videoSource = (ScreenVideoSource)streamer.Source;

                if (!videoSource.IsCapturing)
                {
                    _previewImageList.Images[videoSource.ScreenId] = _blankImage;
                    continue;
                }

                using (Image previewImage = videoSource.QueryPreviewImage())
                    if (previewImage != null)
                    {
                        _previewImageList.Images[videoSource.ScreenId] = previewImage;
                    }
            }

            _screensListView.Refresh();
        }