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

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

Issue 1888593004: Delete all use of tick_util.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 7 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
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> 21 #include <IOKit/pwr_mgt/IOPMLib.h>
22 #include <OpenGL/CGLMacro.h> 22 #include <OpenGL/CGLMacro.h>
23 #include <OpenGL/OpenGL.h> 23 #include <OpenGL/OpenGL.h>
24 24
25 #include "webrtc/base/checks.h" 25 #include "webrtc/base/checks.h"
26 #include "webrtc/base/constructormagic.h" 26 #include "webrtc/base/constructormagic.h"
27 #include "webrtc/base/macutils.h" 27 #include "webrtc/base/macutils.h"
28 #include "webrtc/base/timeutils.h"
28 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 29 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
29 #include "webrtc/modules/desktop_capture/desktop_frame.h" 30 #include "webrtc/modules/desktop_capture/desktop_frame.h"
30 #include "webrtc/modules/desktop_capture/desktop_geometry.h" 31 #include "webrtc/modules/desktop_capture/desktop_geometry.h"
31 #include "webrtc/modules/desktop_capture/desktop_region.h" 32 #include "webrtc/modules/desktop_capture/desktop_region.h"
32 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" 33 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h"
33 #include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h" 34 #include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h"
34 #include "webrtc/modules/desktop_capture/mac/scoped_pixel_buffer_object.h" 35 #include "webrtc/modules/desktop_capture/mac/scoped_pixel_buffer_object.h"
35 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" 36 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
36 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" 37 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h"
37 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h" 38 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
38 #include "webrtc/system_wrappers/include/logging.h" 39 #include "webrtc/system_wrappers/include/logging.h"
39 #include "webrtc/system_wrappers/include/tick_util.h"
40 40
41 namespace webrtc { 41 namespace webrtc {
42 42
43 namespace { 43 namespace {
44 44
45 // Definitions used to dynamic-link to deprecated OS 10.6 functions. 45 // Definitions used to dynamic-link to deprecated OS 10.6 functions.
46 const char* kApplicationServicesLibraryName = 46 const char* kApplicationServicesLibraryName =
47 "/System/Library/Frameworks/ApplicationServices.framework/" 47 "/System/Library/Frameworks/ApplicationServices.framework/"
48 "ApplicationServices"; 48 "ApplicationServices";
49 typedef void* (*CGDisplayBaseAddressFunc)(CGDirectDisplayID); 49 typedef void* (*CGDisplayBaseAddressFunc)(CGDirectDisplayID);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 &power_assertion_id_display_); 377 &power_assertion_id_display_);
378 // This assertion ensures that the display is woken up if it already asleep 378 // This assertion ensures that the display is woken up if it already asleep
379 // (as used by Apple Remote Desktop). 379 // (as used by Apple Remote Desktop).
380 IOPMAssertionCreateWithName(CFSTR("UserIsActive"), 380 IOPMAssertionCreateWithName(CFSTR("UserIsActive"),
381 kIOPMAssertionLevelOn, 381 kIOPMAssertionLevelOn,
382 CFSTR("Chrome Remote Desktop connection active"), 382 CFSTR("Chrome Remote Desktop connection active"),
383 &power_assertion_id_user_); 383 &power_assertion_id_user_);
384 } 384 }
385 385
386 void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) { 386 void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) {
387 TickTime capture_start_time = TickTime::Now(); 387 int64_t capture_start_time_nanos = rtc::TimeNanos();
388 388
389 queue_.MoveToNextFrame(); 389 queue_.MoveToNextFrame();
390 RTC_DCHECK(!queue_.current_frame() || !queue_.current_frame()->IsShared()); 390 RTC_DCHECK(!queue_.current_frame() || !queue_.current_frame()->IsShared());
391 391
392 desktop_config_monitor_->Lock(); 392 desktop_config_monitor_->Lock();
393 MacDesktopConfiguration new_config = 393 MacDesktopConfiguration new_config =
394 desktop_config_monitor_->desktop_configuration(); 394 desktop_config_monitor_->desktop_configuration();
395 if (!desktop_config_.Equals(new_config)) { 395 if (!desktop_config_.Equals(new_config)) {
396 desktop_config_ = new_config; 396 desktop_config_ = new_config;
397 // If the display configuraiton has changed then refresh capturer data 397 // If the display configuraiton has changed then refresh capturer data
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (flip) 441 if (flip)
442 new_frame = new InvertedDesktopFrame(new_frame); 442 new_frame = new InvertedDesktopFrame(new_frame);
443 443
444 helper_.set_size_most_recent(new_frame->size()); 444 helper_.set_size_most_recent(new_frame->size());
445 445
446 // Signal that we are done capturing data from the display framebuffer, 446 // Signal that we are done capturing data from the display framebuffer,
447 // and accessing display structures. 447 // and accessing display structures.
448 desktop_config_monitor_->Unlock(); 448 desktop_config_monitor_->Unlock();
449 449
450 new_frame->set_capture_time_ms( 450 new_frame->set_capture_time_ms(
451 (TickTime::Now() - capture_start_time).Milliseconds()); 451 (rtc::TimeNanos() - capture_start_time_nanos) /
452 rtc::kNumNanosecsPerMillisec);
452 callback_->OnCaptureCompleted(new_frame); 453 callback_->OnCaptureCompleted(new_frame);
453 } 454 }
454 455
455 void ScreenCapturerMac::SetExcludedWindow(WindowId window) { 456 void ScreenCapturerMac::SetExcludedWindow(WindowId window) {
456 excluded_window_ = window; 457 excluded_window_ = window;
457 } 458 }
458 459
459 bool ScreenCapturerMac::GetScreenList(ScreenList* screens) { 460 bool ScreenCapturerMac::GetScreenList(ScreenList* screens) {
460 assert(screens->size() == 0); 461 assert(screens->size() == 0);
461 if (rtc::GetOSVersionName() < rtc::kMacOSLion) { 462 if (rtc::GetOSVersionName() < rtc::kMacOSLion) {
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 return NULL; 986 return NULL;
986 987
987 std::unique_ptr<ScreenCapturerMac> capturer( 988 std::unique_ptr<ScreenCapturerMac> capturer(
988 new ScreenCapturerMac(options.configuration_monitor())); 989 new ScreenCapturerMac(options.configuration_monitor()));
989 if (!capturer->Init()) 990 if (!capturer->Init())
990 capturer.reset(); 991 capturer.reset();
991 return capturer.release(); 992 return capturer.release();
992 } 993 }
993 994
994 } // namespace webrtc 995 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698