2017-12-12 15:12:07 +01:00
|
|
|
#ifndef FRAMES_H
|
|
|
|
#define FRAMES_H
|
|
|
|
|
2017-12-15 17:34:16 +01:00
|
|
|
#include <SDL2/SDL_mutex.h>
|
|
|
|
#include <SDL2/SDL_stdinc.h>
|
2017-12-12 15:12:07 +01:00
|
|
|
|
2018-02-07 12:25:52 +01:00
|
|
|
#include "config.h"
|
2018-08-15 17:01:54 +02:00
|
|
|
#include "fps_counter.h"
|
2018-02-07 12:25:52 +01:00
|
|
|
|
2017-12-12 15:12:07 +01:00
|
|
|
// forward declarations
|
|
|
|
typedef struct AVFrame AVFrame;
|
|
|
|
|
|
|
|
struct frames {
|
|
|
|
AVFrame *decoding_frame;
|
|
|
|
AVFrame *rendering_frame;
|
|
|
|
SDL_mutex *mutex;
|
2018-02-07 12:25:52 +01:00
|
|
|
#ifndef SKIP_FRAMES
|
2018-02-09 08:42:39 +01:00
|
|
|
SDL_bool stopped;
|
2017-12-12 15:12:07 +01:00
|
|
|
SDL_cond *rendering_frame_consumed_cond;
|
2018-02-07 12:25:52 +01:00
|
|
|
#endif
|
2017-12-12 15:12:07 +01:00
|
|
|
SDL_bool rendering_frame_consumed;
|
2018-02-15 11:10:58 +01:00
|
|
|
struct fps_counter fps_counter;
|
2017-12-12 15:12:07 +01:00
|
|
|
};
|
|
|
|
|
2017-12-15 11:27:11 +01:00
|
|
|
SDL_bool frames_init(struct frames *frames);
|
2017-12-12 15:12:07 +01:00
|
|
|
void frames_destroy(struct frames *frames);
|
|
|
|
|
2018-02-08 19:23:24 +01:00
|
|
|
// set the decoder frame as ready for rendering
|
|
|
|
// this function locks frames->mutex during its execution
|
|
|
|
// returns true if the previous frame had been consumed
|
|
|
|
SDL_bool frames_offer_decoded_frame(struct frames *frames);
|
|
|
|
|
|
|
|
// mark the rendering frame as consumed and return it
|
|
|
|
// MUST be called with frames->mutex locked!!!
|
|
|
|
// the caller is expected to render the returned frame to some texture before
|
|
|
|
// unlocking frames->mutex
|
|
|
|
const AVFrame *frames_consume_rendered_frame(struct frames *frames);
|
2017-12-12 15:12:07 +01:00
|
|
|
|
2018-02-09 08:42:39 +01:00
|
|
|
// wake up and avoid any blocking call
|
|
|
|
void frames_stop(struct frames *frames);
|
|
|
|
|
2017-12-12 15:12:07 +01:00
|
|
|
#endif
|