2021-06-26 13:02:18 +00:00
|
|
|
#ifndef SC_VIDEO_BUFFER_H
|
|
|
|
#define SC_VIDEO_BUFFER_H
|
2017-12-12 14:12:07 +00:00
|
|
|
|
2021-01-08 18:24:51 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2019-03-02 22:52:22 +00:00
|
|
|
#include <stdbool.h>
|
2017-12-12 14:12:07 +00:00
|
|
|
|
2021-01-31 17:24:35 +00:00
|
|
|
#include "util/thread.h"
|
2018-02-07 11:25:52 +00:00
|
|
|
|
2017-12-12 14:12:07 +00:00
|
|
|
// forward declarations
|
|
|
|
typedef struct AVFrame AVFrame;
|
|
|
|
|
2021-02-01 08:38:11 +00:00
|
|
|
/**
|
2021-04-11 13:01:05 +00:00
|
|
|
* A video buffer holds 1 pending frame, which is the last frame received from
|
|
|
|
* the producer (typically, the decoder).
|
2021-02-01 08:38:11 +00:00
|
|
|
*
|
2021-04-11 13:01:05 +00:00
|
|
|
* If a pending frame has not been consumed when the producer pushes a new
|
|
|
|
* frame, then it is lost. The intent is to always provide access to the very
|
|
|
|
* last frame to minimize latency.
|
2021-02-01 08:38:11 +00:00
|
|
|
*/
|
|
|
|
|
2021-06-26 13:02:18 +00:00
|
|
|
struct sc_video_buffer {
|
2021-02-01 08:38:11 +00:00
|
|
|
AVFrame *pending_frame;
|
2021-04-11 13:01:05 +00:00
|
|
|
AVFrame *tmp_frame; // To preserve the pending frame on error
|
2021-02-01 08:38:11 +00:00
|
|
|
|
2021-01-31 17:24:35 +00:00
|
|
|
sc_mutex mutex;
|
2021-02-01 08:38:11 +00:00
|
|
|
|
|
|
|
bool pending_frame_consumed;
|
2017-12-12 14:12:07 +00:00
|
|
|
};
|
|
|
|
|
2019-03-02 22:52:22 +00:00
|
|
|
bool
|
2021-06-26 13:02:18 +00:00
|
|
|
sc_video_buffer_init(struct sc_video_buffer *vb);
|
2019-03-02 19:09:56 +00:00
|
|
|
|
|
|
|
void
|
2021-06-26 13:02:18 +00:00
|
|
|
sc_video_buffer_destroy(struct sc_video_buffer *vb);
|
2017-12-12 14:12:07 +00:00
|
|
|
|
2021-04-11 13:01:05 +00:00
|
|
|
bool
|
2021-06-26 13:02:18 +00:00
|
|
|
sc_video_buffer_push(struct sc_video_buffer *vb, const AVFrame *frame,
|
|
|
|
bool *skipped);
|
2018-02-08 18:23:24 +00:00
|
|
|
|
2021-04-11 13:01:05 +00:00
|
|
|
void
|
2021-06-26 13:02:18 +00:00
|
|
|
sc_video_buffer_consume(struct sc_video_buffer *vb, AVFrame *dst);
|
2017-12-12 14:12:07 +00:00
|
|
|
|
|
|
|
#endif
|