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 <utility> | 13 #include <utility> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/timeutils.h" | 16 #include "webrtc/base/timeutils.h" |
17 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" | 17 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" |
18 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 18 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
19 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" | 19 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" |
20 #include "webrtc/modules/desktop_capture/desktop_region.h" | 20 #include "webrtc/modules/desktop_capture/desktop_region.h" |
21 #include "webrtc/modules/desktop_capture/differ.h" | |
22 #include "webrtc/modules/desktop_capture/mouse_cursor.h" | 21 #include "webrtc/modules/desktop_capture/mouse_cursor.h" |
23 #include "webrtc/modules/desktop_capture/win/cursor.h" | 22 #include "webrtc/modules/desktop_capture/win/cursor.h" |
24 #include "webrtc/modules/desktop_capture/win/desktop.h" | 23 #include "webrtc/modules/desktop_capture/win/desktop.h" |
25 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h" | 24 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h" |
26 #include "webrtc/system_wrappers/include/logging.h" | 25 #include "webrtc/system_wrappers/include/logging.h" |
27 | 26 |
28 namespace webrtc { | 27 namespace webrtc { |
29 | 28 |
30 // kMagnifierWindowClass has to be "Magnifier" according to the Magnification | 29 // kMagnifierWindowClass has to be "Magnifier" according to the Magnification |
31 // API. The other strings can be anything. | 30 // API. The other strings can be anything. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 // CaptureImage may fail in some situations, e.g. windows8 metro mode. So | 108 // CaptureImage may fail in some situations, e.g. windows8 metro mode. So |
110 // defer to the fallback capturer if magnifier capturer did not work. | 109 // defer to the fallback capturer if magnifier capturer did not work. |
111 if (!CaptureImage(rect)) { | 110 if (!CaptureImage(rect)) { |
112 LOG_F(LS_WARNING) << "Switching to the fallback screen capturer because " | 111 LOG_F(LS_WARNING) << "Switching to the fallback screen capturer because " |
113 "last capture attempt failed."; | 112 "last capture attempt failed."; |
114 StartFallbackCapturer(); | 113 StartFallbackCapturer(); |
115 fallback_capturer_->Capture(region); | 114 fallback_capturer_->Capture(region); |
116 return; | 115 return; |
117 } | 116 } |
118 | 117 |
119 const DesktopFrame* current_frame = queue_.current_frame(); | |
120 const DesktopFrame* last_frame = queue_.previous_frame(); | |
121 DesktopRegion updated_region; | |
122 if (last_frame && last_frame->size().equals(current_frame->size())) { | |
123 // Make sure the differencer is set up correctly for these previous and | |
124 // current screens. | |
125 if (!differ_.get() || (differ_->width() != current_frame->size().width()) || | |
126 (differ_->height() != current_frame->size().height()) || | |
127 (differ_->bytes_per_row() != current_frame->stride())) { | |
128 differ_.reset(new Differ(current_frame->size().width(), | |
129 current_frame->size().height(), | |
130 DesktopFrame::kBytesPerPixel, | |
131 current_frame->stride())); | |
132 } | |
133 | |
134 // Calculate difference between the two last captured frames. | |
135 differ_->CalcDirtyRegion( | |
136 last_frame->data(), current_frame->data(), &updated_region); | |
137 } else { | |
138 updated_region.SetRect(DesktopRect::MakeSize(current_frame->size())); | |
139 } | |
140 | |
141 // Emit the current frame. | 118 // Emit the current frame. |
142 std::unique_ptr<DesktopFrame> frame = queue_.current_frame()->Share(); | 119 std::unique_ptr<DesktopFrame> frame = queue_.current_frame()->Share(); |
143 frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX), | 120 frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX), |
144 GetDeviceCaps(desktop_dc_, LOGPIXELSY))); | 121 GetDeviceCaps(desktop_dc_, LOGPIXELSY))); |
145 frame->mutable_updated_region()->Swap(&updated_region); | 122 // ScreenCapturerDifferWrapper will help to detect updated region if needed. |
Sergey Ulanov
2016/09/22 18:25:08
Same here. Add a comment in screen_capturer_win_ma
Hzj_jie
2016/09/22 21:01:34
Done.
| |
123 frame->mutable_updated_region()->SetRect( | |
124 DesktopRect::MakeSize(frame->size())); | |
146 frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / | 125 frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / |
147 rtc::kNumNanosecsPerMillisec); | 126 rtc::kNumNanosecsPerMillisec); |
148 callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); | 127 callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); |
149 } | 128 } |
150 | 129 |
151 bool ScreenCapturerWinMagnifier::GetScreenList(ScreenList* screens) { | 130 bool ScreenCapturerWinMagnifier::GetScreenList(ScreenList* screens) { |
152 return webrtc::GetScreenList(screens); | 131 return webrtc::GetScreenList(screens); |
153 } | 132 } |
154 | 133 |
155 bool ScreenCapturerWinMagnifier::SelectScreen(ScreenId id) { | 134 bool ScreenCapturerWinMagnifier::SelectScreen(ScreenId id) { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 RTC_DCHECK(fallback_capturer_); | 381 RTC_DCHECK(fallback_capturer_); |
403 if (!fallback_capturer_started_) { | 382 if (!fallback_capturer_started_) { |
404 fallback_capturer_started_ = true; | 383 fallback_capturer_started_ = true; |
405 | 384 |
406 fallback_capturer_->Start(callback_); | 385 fallback_capturer_->Start(callback_); |
407 fallback_capturer_->SelectScreen(current_screen_id_); | 386 fallback_capturer_->SelectScreen(current_screen_id_); |
408 } | 387 } |
409 } | 388 } |
410 | 389 |
411 } // namespace webrtc | 390 } // namespace webrtc |
OLD | NEW |