summaryrefslogtreecommitdiff
path: root/src/buffer/video.h
blob: 19dfd6e4129575eacf2fc69429cbf77ae279fc34 (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
#pragma once

//#define CAMU_VIDEO_BUFFER_REQUIRE_RGB

#include <al/types.h>

#include "../codec/codec.h"
#include "../render/renderer.h"
#include "../screen/view.h"

#include "frame_queue.h"
#include "clock.h"

struct camu_video_buffer {
    struct camu_codec_stream *stream;

    struct camu_clock *clock;
    f64 latency;
    atomic(f64) pts;
    f64 seek_pts;

    bool is_static;
    f64 avg_frame_duration;

    struct camu_scaler_format fmt;
    struct camu_scaler *scaler;

    struct camu_frame_queue *queue;
    bool buffered;
    // Need to manually trigger EOF in read().
    bool buffered_with_one_frame;
    // Flush the renderer on this read and don't allow it to set the clock.
    bool weighted_first_read;

    atomic(u32) flow;

#ifdef CAMU_SCREEN_THREADED
    atomic(bool) ref;
#endif

    // Previous view, set from screen::add_buffer_internal().
    struct camu_view view;

    void (*callback)(void *, u8);
    void *userdata;
};

bool camu_video_buffer_init(struct camu_video_buffer *buf, struct camu_clock *clock);
bool camu_video_buffer_configure(struct camu_video_buffer *buf, struct camu_codec_stream *stream,
    struct camu_renderer *renderer);
bool camu_video_buffer_configure_subtitles(struct camu_video_buffer *buf, struct camu_codec_stream *stream);
void camu_video_buffer_set_latency(struct camu_video_buffer *buf, f64 latency);
void camu_video_buffer_push(struct camu_video_buffer *buf, struct camu_codec_frame *frame);
void camu_video_buffer_push_subtitle(struct camu_video_buffer *buf, struct camu_codec_packet *packet);
void camu_video_buffer_flush(struct camu_video_buffer *buf, bool error);
void camu_video_buffer_reset(struct camu_video_buffer *buf, f64 pts);
bool camu_video_buffer_read(struct camu_video_buffer *buf, void *out, bool *weighted);
void camu_video_buffer_free(struct camu_video_buffer *buf);