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_gdi.h" | 11 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.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 namespace { | 31 namespace { |
32 | 32 |
33 // Constants from dwmapi.h. | 33 // Constants from dwmapi.h. |
34 const UINT DWM_EC_DISABLECOMPOSITION = 0; | 34 const UINT DWM_EC_DISABLECOMPOSITION = 0; |
35 const UINT DWM_EC_ENABLECOMPOSITION = 1; | 35 const UINT DWM_EC_ENABLECOMPOSITION = 1; |
36 | 36 |
37 const wchar_t kDwmapiLibraryName[] = L"dwmapi.dll"; | 37 const wchar_t kDwmapiLibraryName[] = L"dwmapi.dll"; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 FreeLibrary(dwmapi_library_); | 88 FreeLibrary(dwmapi_library_); |
89 } | 89 } |
90 | 90 |
91 void ScreenCapturerWinGdi::SetSharedMemoryFactory( | 91 void ScreenCapturerWinGdi::SetSharedMemoryFactory( |
92 rtc::scoped_ptr<SharedMemoryFactory> shared_memory_factory) { | 92 rtc::scoped_ptr<SharedMemoryFactory> shared_memory_factory) { |
93 shared_memory_factory_ = | 93 shared_memory_factory_ = |
94 rtc::ScopedToUnique(std::move(shared_memory_factory)); | 94 rtc::ScopedToUnique(std::move(shared_memory_factory)); |
95 } | 95 } |
96 | 96 |
97 void ScreenCapturerWinGdi::Capture(const DesktopRegion& region) { | 97 void ScreenCapturerWinGdi::Capture(const DesktopRegion& region) { |
98 TickTime capture_start_time = TickTime::Now(); | 98 int64_t capture_start_time = rtc::TimeNanos(); |
stefan-webrtc
2016/04/19 09:19:12
_nanos
nisse-webrtc
2016/04/19 12:19:25
Done.
| |
99 | 99 |
100 queue_.MoveToNextFrame(); | 100 queue_.MoveToNextFrame(); |
101 | 101 |
102 // Request that the system not power-down the system, or the display hardware. | 102 // Request that the system not power-down the system, or the display hardware. |
103 if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) { | 103 if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) { |
104 if (!set_thread_execution_state_failed_) { | 104 if (!set_thread_execution_state_failed_) { |
105 set_thread_execution_state_failed_ = true; | 105 set_thread_execution_state_failed_ = true; |
106 LOG_F(LS_WARNING) << "Failed to make system & display power assertion: " | 106 LOG_F(LS_WARNING) << "Failed to make system & display power assertion: " |
107 << GetLastError(); | 107 << GetLastError(); |
108 } | 108 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 helper_.set_size_most_recent(current_frame->size()); | 145 helper_.set_size_most_recent(current_frame->size()); |
146 | 146 |
147 // Emit the current frame. | 147 // Emit the current frame. |
148 DesktopFrame* frame = queue_.current_frame()->Share(); | 148 DesktopFrame* frame = queue_.current_frame()->Share(); |
149 frame->set_dpi(DesktopVector( | 149 frame->set_dpi(DesktopVector( |
150 GetDeviceCaps(desktop_dc_, LOGPIXELSX), | 150 GetDeviceCaps(desktop_dc_, LOGPIXELSX), |
151 GetDeviceCaps(desktop_dc_, LOGPIXELSY))); | 151 GetDeviceCaps(desktop_dc_, LOGPIXELSY))); |
152 frame->mutable_updated_region()->Clear(); | 152 frame->mutable_updated_region()->Clear(); |
153 helper_.TakeInvalidRegion(frame->mutable_updated_region()); | 153 helper_.TakeInvalidRegion(frame->mutable_updated_region()); |
154 frame->set_capture_time_ms( | 154 frame->set_capture_time_ms( |
155 (TickTime::Now() - capture_start_time).Milliseconds()); | 155 (rtc::TimeNanos() - capture_start_time) / rtc::kNumNanosecsPerMillisec; |
156 callback_->OnCaptureCompleted(frame); | 156 callback_->OnCaptureCompleted(frame); |
157 } | 157 } |
158 | 158 |
159 bool ScreenCapturerWinGdi::GetScreenList(ScreenList* screens) { | 159 bool ScreenCapturerWinGdi::GetScreenList(ScreenList* screens) { |
160 return webrtc::GetScreenList(screens); | 160 return webrtc::GetScreenList(screens); |
161 } | 161 } |
162 | 162 |
163 bool ScreenCapturerWinGdi::SelectScreen(ScreenId id) { | 163 bool ScreenCapturerWinGdi::SelectScreen(ScreenId id) { |
164 bool valid = IsScreenValid(id, ¤t_device_key_); | 164 bool valid = IsScreenValid(id, ¤t_device_key_); |
165 if (valid) | 165 if (valid) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 SRCCOPY | CAPTUREBLT); | 283 SRCCOPY | CAPTUREBLT); |
284 | 284 |
285 // Select back the previously selected object to that the device contect | 285 // Select back the previously selected object to that the device contect |
286 // could be destroyed independently of the bitmap if needed. | 286 // could be destroyed independently of the bitmap if needed. |
287 SelectObject(memory_dc_, previous_object); | 287 SelectObject(memory_dc_, previous_object); |
288 } | 288 } |
289 return true; | 289 return true; |
290 } | 290 } |
291 | 291 |
292 } // namespace webrtc | 292 } // namespace webrtc |
OLD | NEW |