win: Consolidate on a single version checking API
No intended behavior change. Happens to remove one call to GetVersionEx. Bug: chromium:1255114 Change-Id: If4d1c57fa27ad4a7547f8f18c3abe38bc9b2a325 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234160 Reviewed-by: Joe Downing <joedow@chromium.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35146}
This commit is contained in:
parent
b251145e38
commit
79bd4f1bc3
@ -77,9 +77,6 @@ if (rtc_include_tests) {
|
|||||||
"window_finder_unittest.cc",
|
"window_finder_unittest.cc",
|
||||||
]
|
]
|
||||||
public_configs = [ ":x11_config" ]
|
public_configs = [ ":x11_config" ]
|
||||||
if (is_win) {
|
|
||||||
deps += [ "../../rtc_base:win32" ]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +512,10 @@ rtc_library("desktop_capture_generic") {
|
|||||||
"d3d11.lib",
|
"d3d11.lib",
|
||||||
"dxgi.lib",
|
"dxgi.lib",
|
||||||
]
|
]
|
||||||
deps += [ "../../rtc_base:win32" ]
|
deps += [
|
||||||
|
"../../rtc_base:rtc_base_approved",
|
||||||
|
"../../rtc_base:win32",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
absl_deps = [
|
absl_deps = [
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
#include "modules/desktop_capture/win/window_capture_utils.h"
|
#include "modules/desktop_capture/win/window_capture_utils.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/trace_event.h"
|
#include "rtc_base/trace_event.h"
|
||||||
#include "rtc_base/win32.h"
|
#include "rtc_base/win/windows_version.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -196,7 +196,8 @@ void CroppingWindowCapturerWin::CaptureFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CroppingWindowCapturerWin::ShouldUseScreenCapturer() {
|
bool CroppingWindowCapturerWin::ShouldUseScreenCapturer() {
|
||||||
if (!rtc::IsWindows8OrLater() && window_capture_helper_.IsAeroEnabled()) {
|
if (rtc::rtc_win::GetVersion() < rtc::rtc_win::Version::VERSION_WIN8 &&
|
||||||
|
window_capture_helper_.IsAeroEnabled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
#include "modules/desktop_capture/win/screen_capturer_win_directx.h"
|
#include "modules/desktop_capture/win/screen_capturer_win_directx.h"
|
||||||
#include "rtc_base/win32.h"
|
#include "rtc_base/win/windows_version.h"
|
||||||
#endif // defined(WEBRTC_WIN)
|
#endif // defined(WEBRTC_WIN)
|
||||||
|
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
@ -338,7 +338,7 @@ TEST_F(ScreenCapturerIntegrationTest,
|
|||||||
// Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
|
// Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
|
||||||
// TODO(zijiehe): Find the root cause of the border and failure, which cannot
|
// TODO(zijiehe): Find the root cause of the border and failure, which cannot
|
||||||
// reproduce on my dev machine.
|
// reproduce on my dev machine.
|
||||||
if (rtc::IsWindows8OrLater()) {
|
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN8) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CreateMagnifierCapturer();
|
CreateMagnifierCapturer();
|
||||||
@ -351,7 +351,7 @@ TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoMagnifierCapturers) {
|
|||||||
// Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
|
// Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
|
||||||
// TODO(zijiehe): Find the root cause of the border and failure, which cannot
|
// TODO(zijiehe): Find the root cause of the border and failure, which cannot
|
||||||
// reproduce on my dev machine.
|
// reproduce on my dev machine.
|
||||||
if (rtc::IsWindows8OrLater()) {
|
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN8) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CreateMagnifierCapturer();
|
CreateMagnifierCapturer();
|
||||||
@ -362,7 +362,7 @@ TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoMagnifierCapturers) {
|
|||||||
|
|
||||||
TEST_F(ScreenCapturerIntegrationTest,
|
TEST_F(ScreenCapturerIntegrationTest,
|
||||||
DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) {
|
DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) {
|
||||||
if (!rtc::IsWindows8OrLater()) {
|
if (rtc::rtc_win::GetVersion() < rtc::rtc_win::Version::VERSION_WIN8) {
|
||||||
// ScreenCapturerWinGdi randomly returns blank screen, the root cause is
|
// ScreenCapturerWinGdi randomly returns blank screen, the root cause is
|
||||||
// still unknown. Bug,
|
// still unknown. Bug,
|
||||||
// https://bugs.chromium.org/p/webrtc/issues/detail?id=6843.
|
// https://bugs.chromium.org/p/webrtc/issues/detail?id=6843.
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/string_utils.h"
|
#include "rtc_base/string_utils.h"
|
||||||
#include "rtc_base/win32.h"
|
#include "rtc_base/win/windows_version.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -179,7 +179,8 @@ bool GetCroppedWindowRect(HWND window,
|
|||||||
// As of Windows8, transparent resize borders are added by the OS at
|
// As of Windows8, transparent resize borders are added by the OS at
|
||||||
// left/bottom/right sides of a resizeable window. If the cropped window
|
// left/bottom/right sides of a resizeable window. If the cropped window
|
||||||
// doesn't remove these borders, the background will be exposed a bit.
|
// doesn't remove these borders, the background will be exposed a bit.
|
||||||
if (rtc::IsWindows8OrLater() || is_maximized) {
|
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN8 ||
|
||||||
|
is_maximized) {
|
||||||
// Only apply this cropping to windows with a resize border (otherwise,
|
// Only apply this cropping to windows with a resize border (otherwise,
|
||||||
// it'd clip the edges of captured pop-up windows without this border).
|
// it'd clip the edges of captured pop-up windows without this border).
|
||||||
LONG style = GetWindowLong(window, GWL_STYLE);
|
LONG style = GetWindowLong(window, GWL_STYLE);
|
||||||
@ -311,7 +312,7 @@ WindowCaptureHelperWin::WindowCaptureHelperWin() {
|
|||||||
GetProcAddress(dwmapi_library_, "DwmGetWindowAttribute"));
|
GetProcAddress(dwmapi_library_, "DwmGetWindowAttribute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtc::IsWindows10OrLater()) {
|
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10) {
|
||||||
if (FAILED(::CoCreateInstance(__uuidof(VirtualDesktopManager), nullptr,
|
if (FAILED(::CoCreateInstance(__uuidof(VirtualDesktopManager), nullptr,
|
||||||
CLSCTX_ALL,
|
CLSCTX_ALL,
|
||||||
IID_PPV_ARGS(&virtual_desktop_manager_)))) {
|
IID_PPV_ARGS(&virtual_desktop_manager_)))) {
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
#include "rtc_base/string_utils.h"
|
#include "rtc_base/string_utils.h"
|
||||||
#include "rtc_base/time_utils.h"
|
#include "rtc_base/time_utils.h"
|
||||||
#include "rtc_base/trace_event.h"
|
#include "rtc_base/trace_event.h"
|
||||||
#include "rtc_base/win32.h"
|
#include "rtc_base/win/windows_version.h"
|
||||||
#include "system_wrappers/include/metrics.h"
|
#include "system_wrappers/include/metrics.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -295,7 +295,7 @@ WindowCapturerWinGdi::CaptureResults WindowCapturerWinGdi::CaptureFrame(
|
|||||||
// on Windows 8.1 and later, PrintWindow is only used when the window is
|
// on Windows 8.1 and later, PrintWindow is only used when the window is
|
||||||
// occluded. When the window is not occluded, it is much faster to capture
|
// occluded. When the window is not occluded, it is much faster to capture
|
||||||
// the screen and to crop it to the window position and size.
|
// the screen and to crop it to the window position and size.
|
||||||
if (rtc::IsWindows8OrLater()) {
|
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN8) {
|
||||||
// Special flag that makes PrintWindow to work on Windows 8.1 and later.
|
// Special flag that makes PrintWindow to work on Windows 8.1 and later.
|
||||||
// Indeed certain apps (e.g. those using DirectComposition rendering) can't
|
// Indeed certain apps (e.g. those using DirectComposition rendering) can't
|
||||||
// be captured using BitBlt or PrintWindow without this flag. Note that on
|
// be captured using BitBlt or PrintWindow without this flag. Note that on
|
||||||
|
|||||||
@ -694,7 +694,10 @@ rtc_library("net_helpers") {
|
|||||||
deps += [ ":ifaddrs_android" ]
|
deps += [ ":ifaddrs_android" ]
|
||||||
}
|
}
|
||||||
if (is_win) {
|
if (is_win) {
|
||||||
deps += [ ":win32" ]
|
deps += [
|
||||||
|
":rtc_base_approved",
|
||||||
|
":win32",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1406,7 +1409,6 @@ if (rtc_include_tests) {
|
|||||||
":socket_server",
|
":socket_server",
|
||||||
":stringutils",
|
":stringutils",
|
||||||
":testclient",
|
":testclient",
|
||||||
"containers:flat_map",
|
|
||||||
":threading",
|
":threading",
|
||||||
"../api:array_view",
|
"../api:array_view",
|
||||||
"../api:scoped_refptr",
|
"../api:scoped_refptr",
|
||||||
@ -1416,6 +1418,7 @@ if (rtc_include_tests) {
|
|||||||
"../test:fileutils",
|
"../test:fileutils",
|
||||||
"../test:test_main",
|
"../test:test_main",
|
||||||
"../test:test_support",
|
"../test:test_support",
|
||||||
|
"containers:flat_map",
|
||||||
"containers:unittests",
|
"containers:unittests",
|
||||||
"memory:unittests",
|
"memory:unittests",
|
||||||
"synchronization:mutex",
|
"synchronization:mutex",
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
#include <ws2spi.h>
|
#include <ws2spi.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
#include "rtc_base/win32.h"
|
#include "rtc_base/win/windows_version.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined(WEBRTC_POSIX) && !defined(__native_client__)
|
#if defined(WEBRTC_POSIX) && !defined(__native_client__)
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@ -70,10 +70,10 @@ bool HasIPv6Enabled() {
|
|||||||
// WinUWP always has IPv6 capability.
|
// WinUWP always has IPv6 capability.
|
||||||
return true;
|
return true;
|
||||||
#elif defined(WEBRTC_WIN)
|
#elif defined(WEBRTC_WIN)
|
||||||
if (IsWindowsVistaOrLater()) {
|
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_VISTA) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!IsWindowsXpOrLater()) {
|
if (rtc::rtc_win::GetVersion() < rtc::rtc_win::Version::VERSION_XP) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DWORD protbuff_size = 4096;
|
DWORD protbuff_size = 4096;
|
||||||
|
|||||||
@ -20,11 +20,10 @@
|
|||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clang-format off
|
#include <winsock2.h>
|
||||||
// clang formating would change include order.
|
|
||||||
#include <winsock2.h> // must come first
|
// Must be after winsock2.h.
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
|
|
||||||
@ -39,66 +38,11 @@ typedef struct _TOKEN_MANDATORY_LABEL {
|
|||||||
|
|
||||||
#undef SetPort
|
#undef SetPort
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
const char* win32_inet_ntop(int af, const void* src, char* dst, socklen_t size);
|
const char* win32_inet_ntop(int af, const void* src, char* dst, socklen_t size);
|
||||||
int win32_inet_pton(int af, const char* src, void* dst);
|
int win32_inet_pton(int af, const char* src, void* dst);
|
||||||
|
|
||||||
enum WindowsMajorVersions {
|
|
||||||
kWindows2000 = 5,
|
|
||||||
kWindowsVista = 6,
|
|
||||||
kWindows10 = 10,
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined(WINUWP)
|
|
||||||
bool GetOsVersion(int* major, int* minor, int* build);
|
|
||||||
|
|
||||||
inline bool IsWindowsVistaOrLater() {
|
|
||||||
int major;
|
|
||||||
return (GetOsVersion(&major, nullptr, nullptr) && major >= kWindowsVista);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsWindowsXpOrLater() {
|
|
||||||
int major, minor;
|
|
||||||
return (GetOsVersion(&major, &minor, nullptr) &&
|
|
||||||
(major >= kWindowsVista || (major == kWindows2000 && minor >= 1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsWindows8OrLater() {
|
|
||||||
int major, minor;
|
|
||||||
return (GetOsVersion(&major, &minor, nullptr) &&
|
|
||||||
(major > kWindowsVista || (major == kWindowsVista && minor >= 2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsWindows10OrLater() {
|
|
||||||
int major;
|
|
||||||
return (GetOsVersion(&major, nullptr, nullptr) && (major >= kWindows10));
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// When targetting WinUWP the OS must be Windows 10 (or greater) as lesser
|
|
||||||
// Windows OS targets are not supported.
|
|
||||||
inline bool IsWindowsVistaOrLater() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsWindowsXpOrLater() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsWindows8OrLater() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsWindows10OrLater() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !defined(WINUWP)
|
|
||||||
|
|
||||||
} // namespace rtc
|
} // namespace rtc
|
||||||
|
|
||||||
#endif // RTC_BASE_WIN32_H_
|
#endif // RTC_BASE_WIN32_H_
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user