Expose screen as frame sink
Make screen implement the frame sink trait. This will allow the decoder to push frames without depending on the concrete sink type.
This commit is contained in:
parent
deab7da761
commit
08b3086ffc
2 changed files with 36 additions and 0 deletions
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#define DISPLAY_MARGINS 96
|
#define DISPLAY_MARGINS 96
|
||||||
|
|
||||||
|
#define DOWNCAST(SINK) container_of(SINK, struct screen, frame_sink)
|
||||||
|
|
||||||
static inline struct size
|
static inline struct size
|
||||||
get_rotated_size(struct size size, int rotation) {
|
get_rotated_size(struct size size, int rotation) {
|
||||||
struct size rotated_size;
|
struct size rotated_size;
|
||||||
|
@ -262,6 +264,29 @@ event_watcher(void *data, SDL_Event *event) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool
|
||||||
|
screen_frame_sink_open(struct sc_frame_sink *sink) {
|
||||||
|
struct screen *screen = DOWNCAST(sink);
|
||||||
|
(void) screen;
|
||||||
|
|
||||||
|
// nothing to do, the screen is already open on the main thread
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
screen_frame_sink_close(struct sc_frame_sink *sink) {
|
||||||
|
struct screen *screen = DOWNCAST(sink);
|
||||||
|
(void) screen;
|
||||||
|
|
||||||
|
// nothing to do, the screen lifecycle is not managed by the frame producer
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
screen_frame_sink_push(struct sc_frame_sink *sink, const AVFrame *frame) {
|
||||||
|
struct screen *screen = DOWNCAST(sink);
|
||||||
|
return video_buffer_push(screen->vb, frame);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
screen_init(struct screen *screen, struct video_buffer *vb,
|
screen_init(struct screen *screen, struct video_buffer *vb,
|
||||||
struct fps_counter *fps_counter,
|
struct fps_counter *fps_counter,
|
||||||
|
@ -402,6 +427,14 @@ screen_init(struct screen *screen, struct video_buffer *vb,
|
||||||
SDL_AddEventWatch(event_watcher, screen);
|
SDL_AddEventWatch(event_watcher, screen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const struct sc_frame_sink_ops ops = {
|
||||||
|
.open = screen_frame_sink_open,
|
||||||
|
.close = screen_frame_sink_close,
|
||||||
|
.push = screen_frame_sink_push,
|
||||||
|
};
|
||||||
|
|
||||||
|
screen->frame_sink.ops = &ops;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,13 @@
|
||||||
|
|
||||||
#include "coords.h"
|
#include "coords.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
|
#include "trait/frame_sink.h"
|
||||||
|
|
||||||
struct video_buffer;
|
struct video_buffer;
|
||||||
|
|
||||||
struct screen {
|
struct screen {
|
||||||
|
struct sc_frame_sink frame_sink; // frame sink trait
|
||||||
|
|
||||||
struct video_buffer *vb;
|
struct video_buffer *vb;
|
||||||
struct fps_counter *fps_counter;
|
struct fps_counter *fps_counter;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue