Display and control your Android device
Expose screen as frame sink
Romain Vimont08b3086ffc95
diff --git a/app/src/screen.c b/app/src/screen.cindex de734554..0aa0b832 100644--- a/app/src/screen.c+++ b/app/src/screen.c@@ -13,6 +13,8 @@#define DISPLAY_MARGINS 96+#define DOWNCAST(SINK) container_of(SINK, struct screen, frame_sink)+static inline struct sizeget_rotated_size(struct size size, int rotation) {struct size rotated_size;@@ -262,6 +264,29 @@ event_watcher(void *data, SDL_Event *event) {}#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);+}+boolscreen_init(struct screen *screen, struct video_buffer *vb,struct fps_counter *fps_counter,@@ -402,6 +427,14 @@ screen_init(struct screen *screen, struct video_buffer *vb,SDL_AddEventWatch(event_watcher, screen);#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;}diff --git a/app/src/screen.h b/app/src/screen.hindex cd849779..d57b7152 100644--- a/app/src/screen.h+++ b/app/src/screen.h@@ -9,10 +9,13 @@#include "coords.h"#include "opengl.h"+#include "trait/frame_sink.h"struct video_buffer;struct screen {+ struct sc_frame_sink frame_sink; // frame sink trait+struct video_buffer *vb;struct fps_counter *fps_counter;