31 lines
696 B
C
31 lines
696 B
C
|
|
#ifndef FRAME_QUEUE_H
|
||
|
|
#define FRAME_QUEUE_H
|
||
|
|
|
||
|
|
#include <SDL2/SDL.h>
|
||
|
|
|
||
|
|
#define FRAME_QUEUE_CAPACITY 4
|
||
|
|
|
||
|
|
typedef struct FrameData {
|
||
|
|
unsigned char *pixels;
|
||
|
|
int width;
|
||
|
|
int height;
|
||
|
|
int stride;
|
||
|
|
double pts_seconds;
|
||
|
|
} FrameData;
|
||
|
|
|
||
|
|
typedef struct FrameQueue {
|
||
|
|
FrameData frames[FRAME_QUEUE_CAPACITY];
|
||
|
|
int head;
|
||
|
|
int count;
|
||
|
|
SDL_mutex *mutex;
|
||
|
|
SDL_cond *cond;
|
||
|
|
} FrameQueue;
|
||
|
|
|
||
|
|
int frame_queue_init(FrameQueue *queue);
|
||
|
|
void frame_queue_destroy(FrameQueue *queue);
|
||
|
|
void frame_queue_clear(FrameQueue *queue);
|
||
|
|
int frame_queue_push(FrameQueue *queue, FrameData *frame);
|
||
|
|
int frame_queue_pop_latest(FrameQueue *queue, FrameData *out);
|
||
|
|
void frame_data_free(FrameData *frame);
|
||
|
|
|
||
|
|
#endif
|