aboutsummaryrefslogtreecommitdiff
path: root/include/capture/kms.h
blob: 0ad7ee6068c9e2aed7b3a12c989aee3326a888ad (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
#ifndef GSR_CAPTURE_KMS_H
#define GSR_CAPTURE_KMS_H

#include "capture.h"
#include "../../kms/client/kms_client.h"
#include "../color_conversion.h"
#include "../vec2.h"
#include "../defs.h"
#include <stdbool.h>

typedef struct AVCodecContext AVCodecContext;
typedef struct AVMasteringDisplayMetadata AVMasteringDisplayMetadata;
typedef struct AVContentLightMetadata AVContentLightMetadata;
typedef struct gsr_capture_kms gsr_capture_kms;
typedef struct gsr_egl gsr_egl;
typedef struct AVFrame AVFrame;

#define MAX_CONNECTOR_IDS 32

typedef struct {
    uint32_t connector_ids[MAX_CONNECTOR_IDS];
    int num_connector_ids;
} MonitorId;

struct gsr_capture_kms {
    gsr_capture_base base;

    bool should_stop;
    bool stop_is_error;
    
    gsr_kms_client kms_client;
    gsr_kms_response kms_response;

    vec2i capture_pos;
    vec2i capture_size;
    MonitorId monitor_id;

    AVMasteringDisplayMetadata *mastering_display_metadata;
    AVContentLightMetadata *light_metadata;

    gsr_monitor_rotation monitor_rotation;
};

/* Returns 0 on success */
int gsr_capture_kms_start(gsr_capture_kms *self, const char *display_to_capture, gsr_egl *egl, AVCodecContext *video_codec_context, AVFrame *frame);
void gsr_capture_kms_stop(gsr_capture_kms *self);
bool gsr_capture_kms_capture(gsr_capture_kms *self, AVFrame *frame, bool hdr, bool cursor_texture_is_external, bool record_cursor);
void gsr_capture_kms_cleanup_kms_fds(gsr_capture_kms *self);

#endif /* GSR_CAPTURE_KMS_H */