aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gsr-info.h
blob: 8ce10d0a6091fc0e47a3fb0b3664c0a6a4683238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once

#include <stdbool.h>

#include <glib.h>

G_BEGIN_DECLS

/* ── Enums ───────────────────────────────────────────────────────── */

typedef enum {
    GSR_DISPLAY_SERVER_UNKNOWN,
    GSR_DISPLAY_SERVER_X11,
    GSR_DISPLAY_SERVER_WAYLAND,
} GsrDisplayServer;

typedef enum {
    GSR_GPU_VENDOR_UNKNOWN,
    GSR_GPU_VENDOR_AMD,
    GSR_GPU_VENDOR_INTEL,
    GSR_GPU_VENDOR_NVIDIA,
    GSR_GPU_VENDOR_BROADCOM,
} GsrGpuVendor;

typedef enum {
    GSR_INFO_EXIT_OK,
    GSR_INFO_EXIT_FAILED_TO_RUN,
    GSR_INFO_EXIT_OPENGL_FAILED,
    GSR_INFO_EXIT_NO_DRM_CARD,
} GsrInfoExitStatus;

/* ── Data structures ─────────────────────────────────────────────── */

typedef struct {
    GsrDisplayServer display_server;
    bool             supports_app_audio;
    bool             is_steam_deck;
} GsrSystemInfo;

typedef struct {
    GsrGpuVendor vendor;
} GsrGpuInfo;

typedef struct {
    bool h264;
    bool h264_software;
    bool hevc;
    bool hevc_hdr;
    bool hevc_10bit;
    bool av1;
    bool av1_hdr;
    bool av1_10bit;
    bool vp8;
    bool vp9;
} GsrSupportedVideoCodecs;

typedef struct {
    char *name;       /* owned */
    int   width;
    int   height;
} GsrMonitor;

typedef struct {
    bool         window;
    bool         focused;
    bool         portal;
    GsrMonitor  *monitors;    /* owned array */
    int          n_monitors;
} GsrSupportedCaptureOptions;

typedef struct {
    GsrSystemInfo               system_info;
    GsrGpuInfo                  gpu_info;
    GsrSupportedVideoCodecs     supported_video_codecs;
    GsrSupportedCaptureOptions  supported_capture_options;
} GsrInfo;

/* ── Audio devices ───────────────────────────────────────────────── */

typedef struct {
    char *name;         /* PulseAudio/PipeWire ID, owned */
    char *description;  /* human-readable label, owned */
} GsrAudioDevice;

/* ── Functions ───────────────────────────────────────────────────── */

GsrInfoExitStatus  gsr_info_load          (GsrInfo *info);
void               gsr_info_clear         (GsrInfo *info);

bool               gsr_info_is_codec_supported
                                           (const GsrInfo *info,
                                            const char    *codec_id);

bool               gsr_info_is_capture_option_enabled
                                           (const GsrInfo *info,
                                            const char    *option_id);

/**
 * Returns the first usable HW video codec name (h264 > hevc > av1 > vp8 > vp9),
 * or NULL if none supported.
 */
const char        *gsr_info_get_first_usable_hw_video_codec(const GsrInfo *info);

/* Audio device / application queries (separate commands) */
GsrAudioDevice    *gsr_audio_devices_get  (int *n_devices);
void               gsr_audio_devices_free (GsrAudioDevice *devices,
                                           int              n_devices);

char             **gsr_application_audio_get (int *n_apps);
void               gsr_application_audio_free(char **apps, int n_apps);

G_END_DECLS