Loading...
Searching...
No Matches
WindowCaptureBackend.hpp
1#pragma once
2#include <cstdint>
3#include <memory>
4#include <string>
5#include <vector>
6
7namespace Gfx::WindowCapture
8{
9
10enum class CaptureMode : int
11{
12 Window = 0,
13 AllScreens = 1,
14 SingleScreen = 2,
15 Region = 3
16};
17
19{
20 enum Type
21 {
22 None,
23 CPU_RGBA,
24 CPU_BGRA,
25 D3D11_Texture,
26 IOSurface_Ref,
27 DMA_BUF_FD
28 };
29 Type type{None};
30
31 // CPU path
32 const uint8_t* data{};
33 int stride{};
34
35 // GPU path: D3D11 ID3D11Texture2D*, or IOSurfaceRef
36 void* nativeHandle{};
37
38 // PipeWire DMA-BUF path. When ownsDmabufFd is set, dmabufFd is a dup
39 // handed to the consumer, which must close it after import.
40 int dmabufFd{-1};
41 bool ownsDmabufFd{false};
42 uint32_t drmFormat{};
43 uint64_t drmModifier{};
44 int dmabufStride{};
45 int dmabufOffset{};
46
47 int width{};
48 int height{};
49};
50
52{
53 std::string title;
54 uint64_t id{};
55};
56
58{
59 std::string name;
60 uint64_t id{};
61 int x{}, y{}, width{}, height{};
62};
63
65{
66 CaptureMode mode{CaptureMode::Window};
67 uint64_t windowId{};
68 uint64_t screenId{};
69 int regionX{}, regionY{}, regionW{}, regionH{};
70};
71
73{
74 virtual ~WindowCaptureBackend() = default;
75 virtual bool available() const = 0;
76 virtual bool supportsMode(CaptureMode mode) const = 0;
77 virtual std::vector<CapturableWindow> enumerate() = 0;
78 virtual std::vector<CapturableScreen> enumerateScreens() = 0;
79 virtual bool start(const CaptureTarget& target) = 0;
80 virtual void stop() = 0;
81 virtual CapturedFrame grab() = 0;
82};
83
84// Returns the appropriate backend for the current platform and session type.
85std::unique_ptr<WindowCaptureBackend> createWindowCaptureBackend();
86
87}
@ Window
A separate top-level window.
Definition WindowCaptureBackend.hpp:58
Definition WindowCaptureBackend.hpp:52
Definition WindowCaptureBackend.hpp:65
Definition WindowCaptureBackend.hpp:19
Definition WindowCaptureBackend.hpp:73