1 /* 2 * Copyright (c) 2014 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_MAC_DESKTOP_CONFIGURATION_MONITOR_H_ 12 #define MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_ 13 14 #include <ApplicationServices/ApplicationServices.h> 15 16 #include <memory> 17 #include <set> 18 19 #include "api/ref_counted_base.h" 20 #include "modules/desktop_capture/mac/desktop_configuration.h" 21 #include "rtc_base/constructor_magic.h" 22 #include "rtc_base/synchronization/mutex.h" 23 24 namespace webrtc { 25 26 // The class provides functions to synchronize capturing and display 27 // reconfiguring across threads, and the up-to-date MacDesktopConfiguration. 28 class DesktopConfigurationMonitor : public rtc::RefCountedBase { 29 public: 30 DesktopConfigurationMonitor(); 31 // Returns the current desktop configuration. 32 MacDesktopConfiguration desktop_configuration(); 33 34 protected: 35 ~DesktopConfigurationMonitor() override; 36 37 private: 38 static void DisplaysReconfiguredCallback(CGDirectDisplayID display, 39 CGDisplayChangeSummaryFlags flags, 40 void* user_parameter); 41 void DisplaysReconfigured(CGDirectDisplayID display, 42 CGDisplayChangeSummaryFlags flags); 43 44 Mutex desktop_configuration_lock_; 45 MacDesktopConfiguration desktop_configuration_ 46 RTC_GUARDED_BY(&desktop_configuration_lock_); 47 std::set<CGDirectDisplayID> reconfiguring_displays_; 48 49 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopConfigurationMonitor); 50 }; 51 52 } // namespace webrtc 53 54 #endif // MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_ 55