1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_TYPES_H_
12 #define MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_TYPES_H_
13
14 #include <stdint.h>
15
16 namespace webrtc {
17
18 enum class CaptureType { kWindow, kScreen };
19
20 // Type used to identify windows on the desktop. Values are platform-specific:
21 // - On Windows: HWND cast to intptr_t.
22 // - On Linux (with X11): X11 Window (unsigned long) type cast to intptr_t.
23 // - On OSX: integer window number.
24 typedef intptr_t WindowId;
25
26 const WindowId kNullWindowId = 0;
27
28 const int64_t kInvalidDisplayId = -1;
29
30 // Type used to identify screens on the desktop. Values are platform-specific:
31 // - On Windows: integer display device index.
32 // - On OSX: CGDirectDisplayID cast to intptr_t.
33 // - On Linux (with X11): TBD.
34 // - On ChromeOS: display::Display::id() is an int64_t.
35 // On Windows, ScreenId is implementation dependent: sending a ScreenId from one
36 // implementation to another usually won't work correctly.
37 #if defined(CHROMEOS)
38 typedef int64_t ScreenId;
39 #else
40 typedef intptr_t ScreenId;
41 #endif
42
43 // The screen id corresponds to all screen combined together.
44 const ScreenId kFullDesktopScreenId = -1;
45
46 const ScreenId kInvalidScreenId = -2;
47
48 // Integers to attach to each DesktopFrame to differentiate the generator of
49 // the frame. The entries in this namespace should remain in sync with the
50 // SequentialDesktopCapturerId enum, which is logged via UMA.
51 // `kScreenCapturerWinGdi` and `kScreenCapturerWinDirectx` values are preserved
52 // to maintain compatibility
53 namespace DesktopCapturerId {
CreateFourCC(char a,char b,char c,char d)54 constexpr uint32_t CreateFourCC(char a, char b, char c, char d) {
55 return ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) |
56 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24));
57 }
58
59 constexpr uint32_t kUnknown = 0;
60 constexpr uint32_t kWgcCapturerWin = 1;
61 constexpr uint32_t kScreenCapturerWinMagnifier = 2;
62 constexpr uint32_t kWindowCapturerWinGdi = 3;
63 constexpr uint32_t kScreenCapturerWinGdi = CreateFourCC('G', 'D', 'I', ' ');
64 constexpr uint32_t kScreenCapturerWinDirectx = CreateFourCC('D', 'X', 'G', 'I');
65 constexpr uint32_t kX11CapturerLinux = CreateFourCC('X', '1', '1', ' ');
66 constexpr uint32_t kWaylandCapturerLinux = CreateFourCC('W', 'L', ' ', ' ');
67 } // namespace DesktopCapturerId
68
69 } // namespace webrtc
70
71 #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_TYPES_H_
72