Extract current video_buffer to frame_buffer

The current video buffer only stores one pending frame.

In order to add a new buffering feature, move this part to a separate
"frame buffer". Keep the video_buffer, which currently delegates all its
calls to the frame_buffer.
This commit is contained in:
Romain Vimont
2021-07-04 12:39:03 +02:00
parent 70a1b46e13
commit ed2ac27596
5 changed files with 139 additions and 80 deletions

View File

@@ -5,27 +5,13 @@
#include <stdbool.h>
#include "util/thread.h"
#include "frame_buffer.h"
// forward declarations
typedef struct AVFrame AVFrame;
/**
* A video buffer holds 1 pending frame, which is the last frame received from
* the producer (typically, the decoder).
*
* 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.
*/
struct sc_video_buffer {
AVFrame *pending_frame;
AVFrame *tmp_frame; // To preserve the pending frame on error
sc_mutex mutex;
bool pending_frame_consumed;
struct sc_frame_buffer fb;
};
bool