display_configuration_monitor.h (2109B)
1 /* 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_DESKTOP_CAPTURE_WIN_DISPLAY_CONFIGURATION_MONITOR_H_ 12 #define MODULES_DESKTOP_CAPTURE_WIN_DISPLAY_CONFIGURATION_MONITOR_H_ 13 14 #include "modules/desktop_capture/desktop_capturer.h" 15 #include "modules/desktop_capture/desktop_geometry.h" 16 #include "rtc_base/containers/flat_map.h" 17 18 namespace webrtc { 19 20 // A passive monitor to detect the change of display configuration on a Windows 21 // system. 22 // TODO(zijiehe): Also check for pixel format changes. 23 class DisplayConfigurationMonitor { 24 public: 25 // Checks whether the display configuration has changed since the last time 26 // IsChanged() was called. |source_id| is used to observe changes for a 27 // specific display or all displays if kFullDesktopScreenId is passed in. 28 // Returns false if object was Reset() or if IsChanged() has not been called. 29 bool IsChanged(DesktopCapturer::SourceId source_id); 30 31 // Resets to the initial state. 32 void Reset(); 33 34 private: 35 DesktopVector GetDpiForSourceId(DesktopCapturer::SourceId source_id); 36 37 // Represents the size of the desktop which includes all displays. 38 DesktopRect rect_; 39 40 // Tracks the DPI for each display being captured. We need to track for each 41 // display as each one can be configured to use a different DPI which will not 42 // be reflected in calls to get the system DPI. 43 flat_map<DesktopCapturer::SourceId, DesktopVector> source_dpis_; 44 45 // Indicates whether |rect_| and |source_dpis_| have been initialized. This is 46 // used to prevent the monitor instance from signaling 'IsChanged()' before 47 // the initial values have been set. 48 bool initialized_ = false; 49 }; 50 51 } // namespace webrtc 52 53 #endif // MODULES_DESKTOP_CAPTURE_WIN_DISPLAY_CONFIGURATION_MONITOR_H_