Use a callback to notify frame skip

A skipped frame is detected when the producer offers a frame while the
current pending frame has not been consumed.

However, the producer (in practice the decoder) is not interested in the
fact that a frame has been skipped, only the consumer (the renderer) is.

Therefore, notify frame skip via a consumer callback. This allows to
manage the skipped and rendered frames count at the same place, and
remove fps_counter from decoder.
This commit is contained in:
Romain Vimont
2021-02-23 19:59:43 +01:00
parent fb9f9848bd
commit cb9c42bdcb
6 changed files with 24 additions and 29 deletions

View File

@@ -49,6 +49,10 @@ struct video_buffer_callbacks {
// video_buffer_consumer_take_frame(vb)
// This callback is mandatory (it must not be NULL).
void (*on_frame_available)(struct video_buffer *vb, void *userdata);
// Called when a pending frame has been overwritten by the producer
// This callback is optional (it may be NULL).
void (*on_frame_skipped)(struct video_buffer *vb, void *userdata);
};
bool
@@ -63,10 +67,8 @@ video_buffer_set_consumer_callbacks(struct video_buffer *vb,
void *cbs_userdata);
// set the producer frame as ready for consuming
// the output flag is set to report whether the previous frame has been skipped
void
video_buffer_producer_offer_frame(struct video_buffer *vb,
bool *previous_frame_skipped);
video_buffer_producer_offer_frame(struct video_buffer *vb);
// mark the consumer frame as consumed and return it
// the frame is valid until the next call to this function