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" | 11 #include "webrtc/modules/desktop_capture/window_capturer.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 | 14 |
15 #include "webrtc/base/scoped_ptr.h" | 15 #include "webrtc/base/scoped_ptr.h" |
16 #include "webrtc/base/checks.h" | |
16 #include "webrtc/base/win32.h" | 17 #include "webrtc/base/win32.h" |
17 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" | 18 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" |
18 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" | 19 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" |
19 #include "webrtc/system_wrappers/interface/logging.h" | 20 #include "webrtc/system_wrappers/interface/logging.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
26 const int kMaxNameLength = 1024; | |
27 | |
25 BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) { | 28 BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) { |
26 WindowCapturer::WindowList* list = | 29 WindowCapturer::WindowList* list = |
27 reinterpret_cast<WindowCapturer::WindowList*>(param); | 30 reinterpret_cast<WindowCapturer::WindowList*>(param); |
28 | 31 |
29 // Skip windows that are invisible, minimized, have no title, or are owned, | 32 // Skip windows that are invisible, minimized, have no title, or are owned, |
30 // unless they have the app window style set. | 33 // unless they have the app window style set. |
31 int len = GetWindowTextLength(hwnd); | 34 int len = GetWindowTextLength(hwnd); |
32 HWND owner = GetWindow(hwnd, GW_OWNER); | 35 HWND owner = GetWindow(hwnd, GW_OWNER); |
33 LONG exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); | 36 LONG exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); |
34 if (len == 0 || IsIconic(hwnd) || !IsWindowVisible(hwnd) || | 37 if (len == 0 || IsIconic(hwnd) || !IsWindowVisible(hwnd) || |
(...skipping 17 matching lines...) Expand all Loading... | |
52 const size_t kTitleLength = 500; | 55 const size_t kTitleLength = 500; |
53 WCHAR window_title[kTitleLength]; | 56 WCHAR window_title[kTitleLength]; |
54 // Truncate the title if it's longer than kTitleLength. | 57 // Truncate the title if it's longer than kTitleLength. |
55 GetWindowText(hwnd, window_title, kTitleLength); | 58 GetWindowText(hwnd, window_title, kTitleLength); |
56 window.title = rtc::ToUtf8(window_title); | 59 window.title = rtc::ToUtf8(window_title); |
57 | 60 |
58 // Skip windows when we failed to convert the title or it is empty. | 61 // Skip windows when we failed to convert the title or it is empty. |
59 if (window.title.empty()) | 62 if (window.title.empty()) |
60 return TRUE; | 63 return TRUE; |
61 | 64 |
65 // Filter out windows modern apps' windows that cannot be captured. | |
66 // Issue 526883 | |
67 // Microsoft introduced modern app which can be used cross the Microsoft's | |
68 // platforms (Desktop, mobile phone and etc.) from Win8. | |
69 // Microsoft confirmed that those windows cannot be captured. | |
70 // Modern app's window class name will be ApplicationFrameWindow | |
71 // and/or windows.UI.Core.coreWindow. | |
mcasas
2015/10/01 21:59:17
Suggestion of rephrase:
// Windows 8 introduced
gyzhou
2015/10/02 18:30:34
Done.
| |
72 if (rtc::IsWindows8OrLater()) { | |
73 char class_name[kMaxNameLength]; | |
mcasas
2015/10/01 21:59:17
Why not reuse |kClassLength|? (l.43)
gyzhou
2015/10/02 18:30:34
Done.
Since GetClassName() called in lin45. It ma
| |
74 int class_name_length = GetClassNameA(hwnd, class_name, kMaxNameLength); | |
mcasas
2015/10/01 21:59:17
const
mcasas
2015/10/01 21:59:17
|class_name_length| or |classNameLength| ?
gyzhou
2015/10/02 18:30:35
Done.
gyzhou
2015/10/02 18:30:35
Done.
gyzhou
2015/10/02 18:30:35
class_name_length is consistent with other part of
| |
75 RTC_DCHECK(class_name_length) << | |
76 "Error retrieving the application's class name"; | |
77 if (strcmp(class_name, "ApplicationFrameWindow") == 0 || | |
78 strcmp(class_name, "Windows.UI.Core.CoreWindow") == 0) | |
79 return TRUE; | |
80 } | |
81 | |
62 list->push_back(window); | 82 list->push_back(window); |
63 | 83 |
64 return TRUE; | 84 return TRUE; |
65 } | 85 } |
66 | 86 |
67 class WindowCapturerWin : public WindowCapturer { | 87 class WindowCapturerWin : public WindowCapturer { |
68 public: | 88 public: |
69 WindowCapturerWin(); | 89 WindowCapturerWin(); |
70 virtual ~WindowCapturerWin(); | 90 virtual ~WindowCapturerWin(); |
71 | 91 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 } | 254 } |
235 | 255 |
236 } // namespace | 256 } // namespace |
237 | 257 |
238 // static | 258 // static |
239 WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) { | 259 WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) { |
240 return new WindowCapturerWin(); | 260 return new WindowCapturerWin(); |
241 } | 261 } |
242 | 262 |
243 } // namespace webrtc | 263 } // namespace webrtc |
OLD | NEW |