Notify new frames via callbacks

Currently, a frame is available to the consumer as soon as it is pushed
by the producer (which can detect if the previous frame is skipped).

Notify the new frames (and frame skipped) via callbacks instead.

This paves the way to add (optional) buffering, which will introduce a
delay between the time when the frame is produced and the time it is
available to be consumed.
This commit is contained in:
Romain Vimont
2021-07-04 12:42:22 +02:00
parent 4d8bcfc68a
commit 408a301201
4 changed files with 68 additions and 32 deletions

View File

@@ -12,17 +12,26 @@ typedef struct AVFrame AVFrame;
struct sc_video_buffer {
struct sc_frame_buffer fb;
const struct sc_video_buffer_callbacks *cbs;
void *cbs_userdata;
};
struct sc_video_buffer_callbacks {
void (*on_new_frame)(struct sc_video_buffer *vb, bool previous_skipped,
void *userdata);
};
bool
sc_video_buffer_init(struct sc_video_buffer *vb);
sc_video_buffer_init(struct sc_video_buffer *vb,
const struct sc_video_buffer_callbacks *cbs,
void *cbs_userdata);
void
sc_video_buffer_destroy(struct sc_video_buffer *vb);
bool
sc_video_buffer_push(struct sc_video_buffer *vb, const AVFrame *frame,
bool *skipped);
sc_video_buffer_push(struct sc_video_buffer *vb, const AVFrame *frame);
void
sc_video_buffer_consume(struct sc_video_buffer *vb, AVFrame *dst);