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:
@ -77,9 +77,6 @@ if (rtc_include_tests) {
|
||||
"window_finder_unittest.cc",
|
||||
]
|
||||
public_configs = [ ":x11_config" ]
|
||||
if (is_win) {
|
||||
deps += [ "../../rtc_base:win32" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -515,7 +512,10 @@ rtc_library("desktop_capture_generic") {
|
||||
"d3d11.lib",
|
||||
"dxgi.lib",
|
||||
]
|
||||
deps += [ "../../rtc_base:win32" ]
|
||||
deps += [
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../rtc_base:win32",
|
||||
]
|
||||
}
|
||||
|
||||
absl_deps = [
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "modules/desktop_capture/win/window_capture_utils.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "rtc_base/win32.h"
|
||||
#include "rtc_base/win/windows_version.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -196,7 +196,8 @@ void CroppingWindowCapturerWin::CaptureFrame() {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
#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)
|
||||
|
||||
using ::testing::_;
|
||||
@ -338,7 +338,7 @@ TEST_F(ScreenCapturerIntegrationTest,
|
||||
// Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
|
||||
// TODO(zijiehe): Find the root cause of the border and failure, which cannot
|
||||
// reproduce on my dev machine.
|
||||
if (rtc::IsWindows8OrLater()) {
|
||||
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN8) {
|
||||
return;
|
||||
}
|
||||
CreateMagnifierCapturer();
|
||||
@ -351,7 +351,7 @@ TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoMagnifierCapturers) {
|
||||
// Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
|
||||
// TODO(zijiehe): Find the root cause of the border and failure, which cannot
|
||||
// reproduce on my dev machine.
|
||||
if (rtc::IsWindows8OrLater()) {
|
||||
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN8) {
|
||||
return;
|
||||
}
|
||||
CreateMagnifierCapturer();
|
||||
@ -362,7 +362,7 @@ TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoMagnifierCapturers) {
|
||||
|
||||
TEST_F(ScreenCapturerIntegrationTest,
|
||||
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
|
||||
// still unknown. Bug,
|
||||
// https://bugs.chromium.org/p/webrtc/issues/detail?id=6843.
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
#include "rtc_base/win32.h"
|
||||
#include "rtc_base/win/windows_version.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -179,7 +179,8 @@ bool GetCroppedWindowRect(HWND window,
|
||||
// As of Windows8, transparent resize borders are added by the OS at
|
||||
// left/bottom/right sides of a resizeable window. If the cropped window
|
||||
// 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,
|
||||
// it'd clip the edges of captured pop-up windows without this border).
|
||||
LONG style = GetWindowLong(window, GWL_STYLE);
|
||||
@ -311,7 +312,7 @@ WindowCaptureHelperWin::WindowCaptureHelperWin() {
|
||||
GetProcAddress(dwmapi_library_, "DwmGetWindowAttribute"));
|
||||
}
|
||||
|
||||
if (rtc::IsWindows10OrLater()) {
|
||||
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10) {
|
||||
if (FAILED(::CoCreateInstance(__uuidof(VirtualDesktopManager), nullptr,
|
||||
CLSCTX_ALL,
|
||||
IID_PPV_ARGS(&virtual_desktop_manager_)))) {
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "rtc_base/string_utils.h"
|
||||
#include "rtc_base/time_utils.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"
|
||||
|
||||
namespace webrtc {
|
||||
@ -295,7 +295,7 @@ WindowCapturerWinGdi::CaptureResults WindowCapturerWinGdi::CaptureFrame(
|
||||
// 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
|
||||
// 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.
|
||||
// Indeed certain apps (e.g. those using DirectComposition rendering) can't
|
||||
// be captured using BitBlt or PrintWindow without this flag. Note that on
|
||||
|
@ -694,7 +694,10 @@ rtc_library("net_helpers") {
|
||||
deps += [ ":ifaddrs_android" ]
|
||||
}
|
||||
if (is_win) {
|
||||
deps += [ ":win32" ]
|
||||
deps += [
|
||||
":rtc_base_approved",
|
||||
":win32",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1406,7 +1409,6 @@ if (rtc_include_tests) {
|
||||
":socket_server",
|
||||
":stringutils",
|
||||
":testclient",
|
||||
"containers:flat_map",
|
||||
":threading",
|
||||
"../api:array_view",
|
||||
"../api:scoped_refptr",
|
||||
@ -1416,6 +1418,7 @@ if (rtc_include_tests) {
|
||||
"../test:fileutils",
|
||||
"../test:test_main",
|
||||
"../test:test_support",
|
||||
"containers:flat_map",
|
||||
"containers:unittests",
|
||||
"memory:unittests",
|
||||
"synchronization:mutex",
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <ws2spi.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#include "rtc_base/win32.h"
|
||||
#include "rtc_base/win/windows_version.h"
|
||||
#endif
|
||||
#if defined(WEBRTC_POSIX) && !defined(__native_client__)
|
||||
#include <arpa/inet.h>
|
||||
@ -70,10 +70,10 @@ bool HasIPv6Enabled() {
|
||||
// WinUWP always has IPv6 capability.
|
||||
return true;
|
||||
#elif defined(WEBRTC_WIN)
|
||||
if (IsWindowsVistaOrLater()) {
|
||||
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_VISTA) {
|
||||
return true;
|
||||
}
|
||||
if (!IsWindowsXpOrLater()) {
|
||||
if (rtc::rtc_win::GetVersion() < rtc::rtc_win::Version::VERSION_XP) {
|
||||
return false;
|
||||
}
|
||||
DWORD protbuff_size = 4096;
|
||||
|
@ -20,11 +20,10 @@
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
// clang formating would change include order.
|
||||
#include <winsock2.h> // must come first
|
||||
#include <winsock2.h>
|
||||
|
||||
// Must be after winsock2.h.
|
||||
#include <windows.h>
|
||||
// clang-format on
|
||||
|
||||
typedef int socklen_t;
|
||||
|
||||
@ -39,66 +38,11 @@ typedef struct _TOKEN_MANDATORY_LABEL {
|
||||
|
||||
#undef SetPort
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
|
||||
#endif // RTC_BASE_WIN32_H_
|
||||
|
Reference in New Issue
Block a user