| 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_capture_utils.h" | 11 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h" |
| 12 | 12 |
| 13 #include <windows.h> | 13 #include <windows.h> |
| 14 | 14 |
| 15 #include "webrtc/rtc_base/checks.h" | 15 #include "webrtc/rtc_base/checks.h" |
| 16 #include "webrtc/rtc_base/win32.h" |
| 16 | 17 |
| 17 namespace webrtc { | 18 namespace webrtc { |
| 18 | 19 |
| 19 bool GetScreenList(DesktopCapturer::SourceList* screens) { | 20 bool GetScreenList(DesktopCapturer::SourceList* screens, |
| 20 RTC_DCHECK(screens->size() == 0); | 21 std::vector<std::string>* device_names /* = nullptr */) { |
| 22 RTC_DCHECK_EQ(screens->size(), 0U); |
| 23 if (device_names) { |
| 24 RTC_DCHECK_EQ(device_names->size(), 0U); |
| 25 } |
| 21 | 26 |
| 22 BOOL enum_result = TRUE; | 27 BOOL enum_result = TRUE; |
| 23 for (int device_index = 0;; ++device_index) { | 28 for (int device_index = 0;; ++device_index) { |
| 24 DISPLAY_DEVICE device; | 29 DISPLAY_DEVICE device; |
| 25 device.cb = sizeof(device); | 30 device.cb = sizeof(device); |
| 26 enum_result = EnumDisplayDevices(NULL, device_index, &device, 0); | 31 enum_result = EnumDisplayDevices(NULL, device_index, &device, 0); |
| 27 | 32 |
| 28 // |enum_result| is 0 if we have enumerated all devices. | 33 // |enum_result| is 0 if we have enumerated all devices. |
| 29 if (!enum_result) | 34 if (!enum_result) |
| 30 break; | 35 break; |
| 31 | 36 |
| 32 // We only care about active displays. | 37 // We only care about active displays. |
| 33 if (!(device.StateFlags & DISPLAY_DEVICE_ACTIVE)) | 38 if (!(device.StateFlags & DISPLAY_DEVICE_ACTIVE)) |
| 34 continue; | 39 continue; |
| 35 | 40 |
| 36 screens->push_back({device_index, std::string()}); | 41 screens->push_back({device_index, std::string()}); |
| 42 if (device_names) { |
| 43 device_names->push_back(rtc::ToUtf8(device.DeviceName)); |
| 44 } |
| 37 } | 45 } |
| 38 return true; | 46 return true; |
| 39 } | 47 } |
| 40 | 48 |
| 41 bool IsScreenValid(DesktopCapturer::SourceId screen, std::wstring* device_key) { | 49 bool IsScreenValid(DesktopCapturer::SourceId screen, std::wstring* device_key) { |
| 42 if (screen == kFullDesktopScreenId) { | 50 if (screen == kFullDesktopScreenId) { |
| 43 *device_key = L""; | 51 *device_key = L""; |
| 44 return true; | 52 return true; |
| 45 } | 53 } |
| 46 | 54 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (!result) | 91 if (!result) |
| 84 return DesktopRect(); | 92 return DesktopRect(); |
| 85 | 93 |
| 86 return DesktopRect::MakeXYWH(device_mode.dmPosition.x, | 94 return DesktopRect::MakeXYWH(device_mode.dmPosition.x, |
| 87 device_mode.dmPosition.y, | 95 device_mode.dmPosition.y, |
| 88 device_mode.dmPelsWidth, | 96 device_mode.dmPelsWidth, |
| 89 device_mode.dmPelsHeight); | 97 device_mode.dmPelsHeight); |
| 90 } | 98 } |
| 91 | 99 |
| 92 } // namespace webrtc | 100 } // namespace webrtc |
| OLD | NEW |