OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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/win/screen_capturer_win_magnifier.h" | 11 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 | 14 |
15 #include <utility> | 15 #include <utility> |
16 | 16 |
| 17 #include "webrtc/base/timeutils.h" |
17 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" | 18 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" |
18 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 19 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
19 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" | 20 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" |
20 #include "webrtc/modules/desktop_capture/desktop_region.h" | 21 #include "webrtc/modules/desktop_capture/desktop_region.h" |
21 #include "webrtc/modules/desktop_capture/differ.h" | 22 #include "webrtc/modules/desktop_capture/differ.h" |
22 #include "webrtc/modules/desktop_capture/mouse_cursor.h" | 23 #include "webrtc/modules/desktop_capture/mouse_cursor.h" |
23 #include "webrtc/modules/desktop_capture/win/cursor.h" | 24 #include "webrtc/modules/desktop_capture/win/cursor.h" |
24 #include "webrtc/modules/desktop_capture/win/desktop.h" | 25 #include "webrtc/modules/desktop_capture/win/desktop.h" |
25 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h" | 26 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h" |
26 #include "webrtc/system_wrappers/include/logging.h" | 27 #include "webrtc/system_wrappers/include/logging.h" |
27 #include "webrtc/system_wrappers/include/tick_util.h" | |
28 | 28 |
29 namespace webrtc { | 29 namespace webrtc { |
30 | 30 |
31 // kMagnifierWindowClass has to be "Magnifier" according to the Magnification | 31 // kMagnifierWindowClass has to be "Magnifier" according to the Magnification |
32 // API. The other strings can be anything. | 32 // API. The other strings can be anything. |
33 static LPCTSTR kMagnifierHostClass = L"ScreenCapturerWinMagnifierHost"; | 33 static LPCTSTR kMagnifierHostClass = L"ScreenCapturerWinMagnifierHost"; |
34 static LPCTSTR kHostWindowName = L"MagnifierHost"; | 34 static LPCTSTR kHostWindowName = L"MagnifierHost"; |
35 static LPCTSTR kMagnifierWindowClass = L"Magnifier"; | 35 static LPCTSTR kMagnifierWindowClass = L"Magnifier"; |
36 static LPCTSTR kMagnifierWindowName = L"MagnifierWindow"; | 36 static LPCTSTR kMagnifierWindowName = L"MagnifierWindow"; |
37 | 37 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 InitializeMagnifier(); | 81 InitializeMagnifier(); |
82 } | 82 } |
83 | 83 |
84 void ScreenCapturerWinMagnifier::SetSharedMemoryFactory( | 84 void ScreenCapturerWinMagnifier::SetSharedMemoryFactory( |
85 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) { | 85 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) { |
86 shared_memory_factory_ = std::move(shared_memory_factory); | 86 shared_memory_factory_ = std::move(shared_memory_factory); |
87 } | 87 } |
88 | 88 |
89 void ScreenCapturerWinMagnifier::Capture(const DesktopRegion& region) { | 89 void ScreenCapturerWinMagnifier::Capture(const DesktopRegion& region) { |
90 TickTime capture_start_time = TickTime::Now(); | 90 int64_t capture_start_time_nanos = rtc::TimeNanos(); |
91 | 91 |
92 queue_.MoveToNextFrame(); | 92 queue_.MoveToNextFrame(); |
93 | 93 |
94 // Request that the system not power-down the system, or the display hardware. | 94 // Request that the system not power-down the system, or the display hardware. |
95 if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) { | 95 if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) { |
96 if (!set_thread_execution_state_failed_) { | 96 if (!set_thread_execution_state_failed_) { |
97 set_thread_execution_state_failed_ = true; | 97 set_thread_execution_state_failed_ = true; |
98 LOG_F(LS_WARNING) << "Failed to make system & display power assertion: " | 98 LOG_F(LS_WARNING) << "Failed to make system & display power assertion: " |
99 << GetLastError(); | 99 << GetLastError(); |
100 } | 100 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 helper_.set_size_most_recent(current_frame->size()); | 162 helper_.set_size_most_recent(current_frame->size()); |
163 | 163 |
164 // Emit the current frame. | 164 // Emit the current frame. |
165 DesktopFrame* frame = queue_.current_frame()->Share(); | 165 DesktopFrame* frame = queue_.current_frame()->Share(); |
166 frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX), | 166 frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX), |
167 GetDeviceCaps(desktop_dc_, LOGPIXELSY))); | 167 GetDeviceCaps(desktop_dc_, LOGPIXELSY))); |
168 frame->mutable_updated_region()->Clear(); | 168 frame->mutable_updated_region()->Clear(); |
169 helper_.TakeInvalidRegion(frame->mutable_updated_region()); | 169 helper_.TakeInvalidRegion(frame->mutable_updated_region()); |
170 frame->set_capture_time_ms( | 170 frame->set_capture_time_ms( |
171 (TickTime::Now() - capture_start_time).Milliseconds()); | 171 (rtc::TimeNanos() - capture_start_time_nanos) / |
| 172 rtc::kNumNanosecsPerMillisec); |
172 callback_->OnCaptureCompleted(frame); | 173 callback_->OnCaptureCompleted(frame); |
173 } | 174 } |
174 | 175 |
175 bool ScreenCapturerWinMagnifier::GetScreenList(ScreenList* screens) { | 176 bool ScreenCapturerWinMagnifier::GetScreenList(ScreenList* screens) { |
176 return webrtc::GetScreenList(screens); | 177 return webrtc::GetScreenList(screens); |
177 } | 178 } |
178 | 179 |
179 bool ScreenCapturerWinMagnifier::SelectScreen(ScreenId id) { | 180 bool ScreenCapturerWinMagnifier::SelectScreen(ScreenId id) { |
180 bool valid = IsScreenValid(id, ¤t_device_key_); | 181 bool valid = IsScreenValid(id, ¤t_device_key_); |
181 | 182 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 assert(fallback_capturer_); | 441 assert(fallback_capturer_); |
441 if (!fallback_capturer_started_) { | 442 if (!fallback_capturer_started_) { |
442 fallback_capturer_started_ = true; | 443 fallback_capturer_started_ = true; |
443 | 444 |
444 fallback_capturer_->Start(callback_); | 445 fallback_capturer_->Start(callback_); |
445 fallback_capturer_->SelectScreen(current_screen_id_); | 446 fallback_capturer_->SelectScreen(current_screen_id_); |
446 } | 447 } |
447 } | 448 } |
448 | 449 |
449 } // namespace webrtc | 450 } // namespace webrtc |
OLD | NEW |