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
39 int dmabufFd{-1};
40 uint32_t drmFormat{};
41 uint64_t drmModifier{};
42 int dmabufStride{};
43 int dmabufOffset{};
44
45 int width{};
46 int height{};
47};
48
50{
51 std::string title;
52 uint64_t id{};
53};
54
56{
57 std::string name;
58 uint64_t id{};
59 int x{}, y{}, width{}, height{};
60};
61
63{
64 CaptureMode mode{CaptureMode::Window};
65 uint64_t windowId{};
66 uint64_t screenId{};
67 int regionX{}, regionY{}, regionW{}, regionH{};
68};
69
71{
72 virtual ~WindowCaptureBackend() = default;
73 virtual bool available() const = 0;
74 virtual bool supportsMode(CaptureMode mode) const = 0;
75 virtual std::vector<CapturableWindow> enumerate() = 0;
76 virtual std::vector<CapturableScreen> enumerateScreens() = 0;
77 virtual bool start(const CaptureTarget& target) = 0;
78 virtual void stop() = 0;
79 virtual CapturedFrame grab() = 0;
80};
81
82// Returns the appropriate backend for the current platform and session type.
83std::unique_ptr<WindowCaptureBackend> createWindowCaptureBackend();
84
85}
Definition WindowCaptureBackend.hpp:56
Definition WindowCaptureBackend.hpp:50
Definition WindowCaptureBackend.hpp:63
Definition WindowCaptureBackend.hpp:19
Definition WindowCaptureBackend.hpp:71