aboutsummaryrefslogtreecommitdiff
path: root/src/capture/capture.c
blob: 2a4a6890015773d37d99d06831a317504343a78f (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
#include "../../include/capture/capture.h"
#include <assert.h>

int gsr_capture_start(gsr_capture *cap, AVCodecContext *video_codec_context, AVFrame *frame) {
    assert(!cap->started);
    int res = cap->start(cap, video_codec_context, frame);
    if(res == 0)
        cap->started = true;

    return res;
}

void gsr_capture_tick(gsr_capture *cap) {
    assert(cap->started);
    if(cap->tick)
        cap->tick(cap);
}

void gsr_capture_on_event(gsr_capture *cap, gsr_egl *egl) {
    if(cap->on_event)
        cap->on_event(cap, egl);
}

bool gsr_capture_should_stop(gsr_capture *cap, bool *err) {
    assert(cap->started);
    if(cap->should_stop)
        return cap->should_stop(cap, err);
    else
        return false;
}

int gsr_capture_capture(gsr_capture *cap, AVFrame *frame, gsr_color_conversion *color_conversion) {
    assert(cap->started);
    return cap->capture(cap, frame, color_conversion);
}

bool gsr_capture_uses_external_image(gsr_capture *cap) {
    if(cap->uses_external_image)
        return cap->uses_external_image(cap);
    else
        return false;
}

bool gsr_capture_set_hdr_metadata(gsr_capture *cap, AVMasteringDisplayMetadata *mastering_display_metadata, AVContentLightMetadata *light_metadata) {
    if(cap->set_hdr_metadata)
        return cap->set_hdr_metadata(cap, mastering_display_metadata, light_metadata);
    else
        return false;
}

void gsr_capture_destroy(gsr_capture *cap, AVCodecContext *video_codec_context) {
    cap->destroy(cap, video_codec_context);
}