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/window_capturer.h" | |
12 | |
13 #include <assert.h> | 11 #include <assert.h> |
14 | 12 |
15 #include <memory> | 13 #include <memory> |
16 | 14 |
17 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/constructormagic.h" | 16 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/base/win32.h" | 17 #include "webrtc/base/win32.h" |
| 18 #include "webrtc/modules/desktop_capture/desktop_capturer.h" |
20 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" | 19 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" |
21 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" | 20 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" |
22 #include "webrtc/system_wrappers/include/logging.h" | 21 #include "webrtc/system_wrappers/include/logging.h" |
23 | 22 |
24 namespace webrtc { | 23 namespace webrtc { |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) { | 27 BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) { |
29 DesktopCapturer::SourceList* list = | 28 DesktopCapturer::SourceList* list = |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 72 |
74 // Skip windows when we failed to convert the title or it is empty. | 73 // Skip windows when we failed to convert the title or it is empty. |
75 if (window.title.empty()) | 74 if (window.title.empty()) |
76 return TRUE; | 75 return TRUE; |
77 | 76 |
78 list->push_back(window); | 77 list->push_back(window); |
79 | 78 |
80 return TRUE; | 79 return TRUE; |
81 } | 80 } |
82 | 81 |
83 class WindowCapturerWin : public WindowCapturer { | 82 class WindowCapturerWin : public DesktopCapturer { |
84 public: | 83 public: |
85 WindowCapturerWin(); | 84 WindowCapturerWin(); |
86 ~WindowCapturerWin() override; | 85 ~WindowCapturerWin() override; |
87 | 86 |
88 // DesktopCapturer interface. | 87 // DesktopCapturer interface. |
89 void Start(Callback* callback) override; | 88 void Start(Callback* callback) override; |
90 void CaptureFrame() override; | 89 void CaptureFrame() override; |
91 bool GetSourceList(SourceList* sources) override; | 90 bool GetSourceList(SourceList* sources) override; |
92 bool SelectSource(SourceId id) override; | 91 bool SelectSource(SourceId id) override; |
93 bool FocusOnSelectedSource() override; | 92 bool FocusOnSelectedSource() override; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 LOG(LS_ERROR) << "Both PrintWindow() and BitBlt() failed."; | 256 LOG(LS_ERROR) << "Both PrintWindow() and BitBlt() failed."; |
258 frame.reset(); | 257 frame.reset(); |
259 } | 258 } |
260 | 259 |
261 callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); | 260 callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); |
262 } | 261 } |
263 | 262 |
264 } // namespace | 263 } // namespace |
265 | 264 |
266 // static | 265 // static |
267 WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) { | |
268 return new WindowCapturerWin(); | |
269 } | |
270 | |
271 // static | |
272 std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer( | 266 std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer( |
273 const DesktopCaptureOptions& options) { | 267 const DesktopCaptureOptions& options) { |
274 return std::unique_ptr<DesktopCapturer>(new WindowCapturerWin()); | 268 return std::unique_ptr<DesktopCapturer>(new WindowCapturerWin()); |
275 } | 269 } |
276 | 270 |
277 } // namespace webrtc | 271 } // namespace webrtc |
OLD | NEW |