OLD | NEW |
---|---|
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/macutils.h" | 25 #include "webrtc/base/macutils.h" |
26 #include "webrtc/base/timeutils.h" | |
26 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" | 27 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" |
27 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 28 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
28 #include "webrtc/modules/desktop_capture/desktop_geometry.h" | 29 #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
29 #include "webrtc/modules/desktop_capture/desktop_region.h" | 30 #include "webrtc/modules/desktop_capture/desktop_region.h" |
30 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" | 31 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" |
31 #include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h" | 32 #include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h" |
32 #include "webrtc/modules/desktop_capture/mac/scoped_pixel_buffer_object.h" | 33 #include "webrtc/modules/desktop_capture/mac/scoped_pixel_buffer_object.h" |
33 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" | 34 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" |
34 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" | 35 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" |
35 #include "webrtc/system_wrappers/include/logging.h" | 36 #include "webrtc/system_wrappers/include/logging.h" |
36 #include "webrtc/system_wrappers/include/tick_util.h" | |
37 | 37 |
38 namespace webrtc { | 38 namespace webrtc { |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 // Definitions used to dynamic-link to deprecated OS 10.6 functions. | 42 // Definitions used to dynamic-link to deprecated OS 10.6 functions. |
43 const char* kApplicationServicesLibraryName = | 43 const char* kApplicationServicesLibraryName = |
44 "/System/Library/Frameworks/ApplicationServices.framework/" | 44 "/System/Library/Frameworks/ApplicationServices.framework/" |
45 "ApplicationServices"; | 45 "ApplicationServices"; |
46 typedef void* (*CGDisplayBaseAddressFunc)(CGDirectDisplayID); | 46 typedef void* (*CGDisplayBaseAddressFunc)(CGDirectDisplayID); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 &power_assertion_id_display_); | 374 &power_assertion_id_display_); |
375 // This assertion ensures that the display is woken up if it already asleep | 375 // This assertion ensures that the display is woken up if it already asleep |
376 // (as used by Apple Remote Desktop). | 376 // (as used by Apple Remote Desktop). |
377 IOPMAssertionCreateWithName(CFSTR("UserIsActive"), | 377 IOPMAssertionCreateWithName(CFSTR("UserIsActive"), |
378 kIOPMAssertionLevelOn, | 378 kIOPMAssertionLevelOn, |
379 CFSTR("Chrome Remote Desktop connection active"), | 379 CFSTR("Chrome Remote Desktop connection active"), |
380 &power_assertion_id_user_); | 380 &power_assertion_id_user_); |
381 } | 381 } |
382 | 382 |
383 void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) { | 383 void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) { |
384 TickTime capture_start_time = TickTime::Now(); | 384 int64_t capture_start_time = rtc::TimeNanos(); |
stefan-webrtc
2016/04/19 09:19:12
capture_start_time_nanos
nisse-webrtc
2016/04/19 12:19:25
Done.
| |
385 | 385 |
386 queue_.MoveToNextFrame(); | 386 queue_.MoveToNextFrame(); |
387 | 387 |
388 desktop_config_monitor_->Lock(); | 388 desktop_config_monitor_->Lock(); |
389 MacDesktopConfiguration new_config = | 389 MacDesktopConfiguration new_config = |
390 desktop_config_monitor_->desktop_configuration(); | 390 desktop_config_monitor_->desktop_configuration(); |
391 if (!desktop_config_.Equals(new_config)) { | 391 if (!desktop_config_.Equals(new_config)) { |
392 desktop_config_ = new_config; | 392 desktop_config_ = new_config; |
393 // If the display configuraiton has changed then refresh capturer data | 393 // If the display configuraiton has changed then refresh capturer data |
394 // structures. Occasionally, the refresh and move handlers are lost when | 394 // structures. Occasionally, the refresh and move handlers are lost when |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 if (flip) | 437 if (flip) |
438 new_frame = new InvertedDesktopFrame(new_frame); | 438 new_frame = new InvertedDesktopFrame(new_frame); |
439 | 439 |
440 helper_.set_size_most_recent(new_frame->size()); | 440 helper_.set_size_most_recent(new_frame->size()); |
441 | 441 |
442 // Signal that we are done capturing data from the display framebuffer, | 442 // Signal that we are done capturing data from the display framebuffer, |
443 // and accessing display structures. | 443 // and accessing display structures. |
444 desktop_config_monitor_->Unlock(); | 444 desktop_config_monitor_->Unlock(); |
445 | 445 |
446 new_frame->set_capture_time_ms( | 446 new_frame->set_capture_time_ms( |
447 (TickTime::Now() - capture_start_time).Milliseconds()); | 447 (rtc::TimeNanos() - capture_start_time) / rtc::kNumNanosecsPerMillisec; |
448 callback_->OnCaptureCompleted(new_frame); | 448 callback_->OnCaptureCompleted(new_frame); |
449 } | 449 } |
450 | 450 |
451 void ScreenCapturerMac::SetExcludedWindow(WindowId window) { | 451 void ScreenCapturerMac::SetExcludedWindow(WindowId window) { |
452 excluded_window_ = window; | 452 excluded_window_ = window; |
453 } | 453 } |
454 | 454 |
455 bool ScreenCapturerMac::GetScreenList(ScreenList* screens) { | 455 bool ScreenCapturerMac::GetScreenList(ScreenList* screens) { |
456 assert(screens->size() == 0); | 456 assert(screens->size() == 0); |
457 if (rtc::GetOSVersionName() < rtc::kMacOSLion) { | 457 if (rtc::GetOSVersionName() < rtc::kMacOSLion) { |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
981 return NULL; | 981 return NULL; |
982 | 982 |
983 std::unique_ptr<ScreenCapturerMac> capturer( | 983 std::unique_ptr<ScreenCapturerMac> capturer( |
984 new ScreenCapturerMac(options.configuration_monitor())); | 984 new ScreenCapturerMac(options.configuration_monitor())); |
985 if (!capturer->Init()) | 985 if (!capturer->Init()) |
986 capturer.reset(); | 986 capturer.reset(); |
987 return capturer.release(); | 987 return capturer.release(); |
988 } | 988 } |
989 | 989 |
990 } // namespace webrtc | 990 } // namespace webrtc |
OLD | NEW |