2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_
14 #include <ApplicationServices/ApplicationServices.h>
18 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h"
19 #include "webrtc/system_wrappers/interface/atomic32.h"
20 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
26 // The class provides functions to synchronize capturing and display
27 // reconfiguring across threads, and the up-to-date MacDesktopConfiguration.
28 class DesktopConfigurationMonitor {
30 DesktopConfigurationMonitor();
31 // Acquires a lock on the current configuration.
33 // Releases the lock previously acquired.
35 // Returns the current desktop configuration. Should only be called when the
36 // lock has been acquired.
37 const MacDesktopConfiguration& desktop_configuration() {
38 return desktop_configuration_;
41 void AddRef() { ++ref_count_; }
43 if (--ref_count_ == 0)
48 static void DisplaysReconfiguredCallback(CGDirectDisplayID display,
49 CGDisplayChangeSummaryFlags flags,
50 void *user_parameter);
51 ~DesktopConfigurationMonitor();
53 void DisplaysReconfigured(CGDirectDisplayID display,
54 CGDisplayChangeSummaryFlags flags);
57 std::set<CGDirectDisplayID> reconfiguring_displays_;
58 MacDesktopConfiguration desktop_configuration_;
59 scoped_ptr<EventWrapper> display_configuration_capture_event_;
61 DISALLOW_COPY_AND_ASSIGN(DesktopConfigurationMonitor);
66 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_