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 <alcooper@chromium.org>
Reviewed-by: Jeroen Dhollander <jeroendh@google.com>
Commit-Queue: Joe Downing <joedow@google.com>
Cr-Commit-Position: refs/heads/main@{#35724}
diff --git a/modules/desktop_capture/desktop_capture_types.h b/modules/desktop_capture/desktop_capture_types.h
index 4dcfc82..bc26db7 100644
--- a/modules/desktop_capture/desktop_capture_types.h
+++ b/modules/desktop_capture/desktop_capture_types.h
@@ -27,9 +27,14 @@
// - 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 8a65e57..822a75d 100644
--- a/modules/desktop_capture/desktop_capturer.h
+++ b/modules/desktop_capture/desktop_capturer.h
@@ -59,7 +59,11 @@
virtual ~Callback() {}
};
+#if defined(CHROMEOS)
+ typedef int64_t SourceId;
+#else
typedef intptr_t SourceId;
+#endif
static_assert(std::is_same<SourceId, ScreenId>::value,
"SourceId should be a same type as ScreenId.");