Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: webrtc/modules/desktop_capture/screen_capturer_mac.mm

Issue 2155813003: [Chromoting] Remove screen saver logic out of ScreenCapturer implementations (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/desktop_capture/screen_capturer.h" 11 #include "webrtc/modules/desktop_capture/screen_capturer.h"
12 12
13 #include <stddef.h> 13 #include <stddef.h>
14 14
15 #include <memory> 15 #include <memory>
16 #include <set> 16 #include <set>
17 17
18 #include <ApplicationServices/ApplicationServices.h> 18 #include <ApplicationServices/ApplicationServices.h>
19 #include <Cocoa/Cocoa.h> 19 #include <Cocoa/Cocoa.h>
20 #include <dlfcn.h> 20 #include <dlfcn.h>
21 #include <IOKit/pwr_mgt/IOPMLib.h>
22 #include <OpenGL/CGLMacro.h> 21 #include <OpenGL/CGLMacro.h>
23 #include <OpenGL/OpenGL.h> 22 #include <OpenGL/OpenGL.h>
24 23
25 #include "webrtc/base/checks.h" 24 #include "webrtc/base/checks.h"
26 #include "webrtc/base/constructormagic.h" 25 #include "webrtc/base/constructormagic.h"
27 #include "webrtc/base/macutils.h" 26 #include "webrtc/base/macutils.h"
28 #include "webrtc/base/timeutils.h" 27 #include "webrtc/base/timeutils.h"
29 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 28 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
30 #include "webrtc/modules/desktop_capture/desktop_frame.h" 29 #include "webrtc/modules/desktop_capture/desktop_frame.h"
31 #include "webrtc/modules/desktop_capture/desktop_geometry.h" 30 #include "webrtc/modules/desktop_capture/desktop_geometry.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // A thread-safe list of invalid rectangles, and the size of the most 254 // A thread-safe list of invalid rectangles, and the size of the most
256 // recently captured screen. 255 // recently captured screen.
257 ScreenCapturerHelper helper_; 256 ScreenCapturerHelper helper_;
258 257
259 // Contains an invalid region from the previous capture. 258 // Contains an invalid region from the previous capture.
260 DesktopRegion last_invalid_region_; 259 DesktopRegion last_invalid_region_;
261 260
262 // Monitoring display reconfiguration. 261 // Monitoring display reconfiguration.
263 rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor_; 262 rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor_;
264 263
265 // Power management assertion to prevent the screen from sleeping.
266 IOPMAssertionID power_assertion_id_display_ = kIOPMNullAssertionID;
267
268 // Power management assertion to indicate that the user is active.
269 IOPMAssertionID power_assertion_id_user_ = kIOPMNullAssertionID;
270
271 // Dynamically link to deprecated APIs for Mac OS X 10.6 support. 264 // Dynamically link to deprecated APIs for Mac OS X 10.6 support.
272 void* app_services_library_ = nullptr; 265 void* app_services_library_ = nullptr;
273 CGDisplayBaseAddressFunc cg_display_base_address_ = nullptr; 266 CGDisplayBaseAddressFunc cg_display_base_address_ = nullptr;
274 CGDisplayBytesPerRowFunc cg_display_bytes_per_row_ = nullptr; 267 CGDisplayBytesPerRowFunc cg_display_bytes_per_row_ = nullptr;
275 CGDisplayBitsPerPixelFunc cg_display_bits_per_pixel_ = nullptr; 268 CGDisplayBitsPerPixelFunc cg_display_bits_per_pixel_ = nullptr;
276 void* opengl_library_ = nullptr; 269 void* opengl_library_ = nullptr;
277 CGLSetFullScreenFunc cgl_set_full_screen_ = nullptr; 270 CGLSetFullScreenFunc cgl_set_full_screen_ = nullptr;
278 271
279 CGWindowID excluded_window_ = 0; 272 CGWindowID excluded_window_ = 0;
280 273
(...skipping 21 matching lines...) Expand all
302 std::unique_ptr<DesktopFrame> original_frame_; 295 std::unique_ptr<DesktopFrame> original_frame_;
303 296
304 RTC_DISALLOW_COPY_AND_ASSIGN(InvertedDesktopFrame); 297 RTC_DISALLOW_COPY_AND_ASSIGN(InvertedDesktopFrame);
305 }; 298 };
306 299
307 ScreenCapturerMac::ScreenCapturerMac( 300 ScreenCapturerMac::ScreenCapturerMac(
308 rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor) 301 rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor)
309 : desktop_config_monitor_(desktop_config_monitor) {} 302 : desktop_config_monitor_(desktop_config_monitor) {}
310 303
311 ScreenCapturerMac::~ScreenCapturerMac() { 304 ScreenCapturerMac::~ScreenCapturerMac() {
312 if (power_assertion_id_display_ != kIOPMNullAssertionID) {
313 IOPMAssertionRelease(power_assertion_id_display_);
314 power_assertion_id_display_ = kIOPMNullAssertionID;
315 }
316 if (power_assertion_id_user_ != kIOPMNullAssertionID) {
317 IOPMAssertionRelease(power_assertion_id_user_);
318 power_assertion_id_user_ = kIOPMNullAssertionID;
319 }
320
321 ReleaseBuffers(); 305 ReleaseBuffers();
322 UnregisterRefreshAndMoveHandlers(); 306 UnregisterRefreshAndMoveHandlers();
323 dlclose(app_services_library_); 307 dlclose(app_services_library_);
324 dlclose(opengl_library_); 308 dlclose(opengl_library_);
325 } 309 }
326 310
327 bool ScreenCapturerMac::Init() { 311 bool ScreenCapturerMac::Init() {
328 if (!RegisterRefreshAndMoveHandlers()) { 312 if (!RegisterRefreshAndMoveHandlers()) {
329 return false; 313 return false;
330 } 314 }
(...skipping 14 matching lines...) Expand all
345 // Instead, mark them as "needs update"; next time the buffers are used by 329 // Instead, mark them as "needs update"; next time the buffers are used by
346 // the capturer, they will be recreated if necessary. 330 // the capturer, they will be recreated if necessary.
347 queue_.Reset(); 331 queue_.Reset();
348 } 332 }
349 333
350 void ScreenCapturerMac::Start(Callback* callback) { 334 void ScreenCapturerMac::Start(Callback* callback) {
351 assert(!callback_); 335 assert(!callback_);
352 assert(callback); 336 assert(callback);
353 337
354 callback_ = callback; 338 callback_ = callback;
355
356 // Create power management assertions to wake the display and prevent it from
357 // going to sleep on user idle.
358 // TODO(jamiewalch): Use IOPMAssertionDeclareUserActivity on 10.7.3 and above
359 // instead of the following two assertions.
360 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep,
361 kIOPMAssertionLevelOn,
362 CFSTR("Chrome Remote Desktop connection active"),
363 &power_assertion_id_display_);
364 // This assertion ensures that the display is woken up if it already asleep
365 // (as used by Apple Remote Desktop).
366 IOPMAssertionCreateWithName(CFSTR("UserIsActive"),
367 kIOPMAssertionLevelOn,
368 CFSTR("Chrome Remote Desktop connection active"),
369 &power_assertion_id_user_);
370 } 339 }
371 340
372 void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) { 341 void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) {
373 int64_t capture_start_time_nanos = rtc::TimeNanos(); 342 int64_t capture_start_time_nanos = rtc::TimeNanos();
374 343
375 queue_.MoveToNextFrame(); 344 queue_.MoveToNextFrame();
376 RTC_DCHECK(!queue_.current_frame() || !queue_.current_frame()->IsShared()); 345 RTC_DCHECK(!queue_.current_frame() || !queue_.current_frame()->IsShared());
377 346
378 desktop_config_monitor_->Lock(); 347 desktop_config_monitor_->Lock();
379 MacDesktopConfiguration new_config = 348 MacDesktopConfiguration new_config =
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 return nullptr; 938 return nullptr;
970 939
971 std::unique_ptr<ScreenCapturerMac> capturer( 940 std::unique_ptr<ScreenCapturerMac> capturer(
972 new ScreenCapturerMac(options.configuration_monitor())); 941 new ScreenCapturerMac(options.configuration_monitor()));
973 if (!capturer->Init()) 942 if (!capturer->Init())
974 capturer.reset(); 943 capturer.reset();
975 return capturer.release(); 944 return capturer.release();
976 } 945 }
977 946
978 } // namespace webrtc 947 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698