From 1d99f49cda836815d326e43e4d09031af0ae884d Mon Sep 17 00:00:00 2001 From: Joe Downing Date: Thu, 13 Jan 2022 07:10:16 -0800 Subject: [PATCH] Use int64_t for desktop_capture Source and Screen IDs on ChromeOS ChromeOS uses int64_t for its IDs (see display::Display::id()) so there is a potential for errors if casting (or attempting to hash and translate the larger ID to a smaller ID and vice versa). Instead we should update the desktop_capture component to use int64_t natively. Bug: webrtc:13571 Change-Id: I78b3456ce11b75755b90863a02f8c6455c63acf9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/246240 Reviewed-by: Alexander Cooper Reviewed-by: Jeroen Dhollander Commit-Queue: Joe Downing Cr-Commit-Position: refs/heads/main@{#35724} --- modules/desktop_capture/desktop_capture_types.h | 7 ++++++- modules/desktop_capture/desktop_capturer.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/desktop_capture/desktop_capture_types.h b/modules/desktop_capture/desktop_capture_types.h index 4dcfc82708..bc26db7cc4 100644 --- a/modules/desktop_capture/desktop_capture_types.h +++ b/modules/desktop_capture/desktop_capture_types.h @@ -27,9 +27,14 @@ const WindowId kNullWindowId = 0; // - On Windows: integer display device index. // - On OSX: CGDirectDisplayID cast to intptr_t. // - On Linux (with X11): TBD. +// - On ChromeOS: display::Display::id() is an int64_t. // On Windows, ScreenId is implementation dependent: sending a ScreenId from one // implementation to another usually won't work correctly. -typedef intptr_t ScreenId; +#if defined(CHROMEOS) + typedef int64_t ScreenId; +#else + typedef intptr_t ScreenId; +#endif // The screen id corresponds to all screen combined together. const ScreenId kFullDesktopScreenId = -1; diff --git a/modules/desktop_capture/desktop_capturer.h b/modules/desktop_capture/desktop_capturer.h index 8a65e5759c..822a75d947 100644 --- a/modules/desktop_capture/desktop_capturer.h +++ b/modules/desktop_capture/desktop_capturer.h @@ -59,7 +59,11 @@ class RTC_EXPORT DesktopCapturer { virtual ~Callback() {} }; +#if defined(CHROMEOS) + typedef int64_t SourceId; +#else typedef intptr_t SourceId; +#endif static_assert(std::is_same::value, "SourceId should be a same type as ScreenId.");