From 336248df08873e904574f6246ff636822bf6bb69 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 26 Jun 2021 15:02:18 +0200 Subject: [PATCH] Rename video_buffer to sc_video_buffer Add a scrcpy-specific prefix. --- app/src/screen.c | 10 +++++----- app/src/screen.h | 2 +- app/src/v4l2_sink.c | 10 +++++----- app/src/v4l2_sink.h | 2 +- app/src/video_buffer.c | 8 ++++---- app/src/video_buffer.h | 15 ++++++++------- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/app/src/screen.c b/app/src/screen.c index 99327b3b..a11235c9 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -276,7 +276,7 @@ screen_frame_sink_push(struct sc_frame_sink *sink, const AVFrame *frame) { struct screen *screen = DOWNCAST(sink); bool previous_frame_skipped; - bool ok = video_buffer_push(&screen->vb, frame, &previous_frame_skipped); + bool ok = sc_video_buffer_push(&screen->vb, frame, &previous_frame_skipped); if (!ok) { return false; } @@ -304,7 +304,7 @@ screen_init(struct screen *screen, const struct screen_params *params) { screen->fullscreen = false; screen->maximized = false; - bool ok = video_buffer_init(&screen->vb); + bool ok = sc_video_buffer_init(&screen->vb); if (!ok) { LOGE("Could not initialize video buffer"); return false; @@ -454,7 +454,7 @@ error_destroy_window: error_destroy_fps_counter: fps_counter_destroy(&screen->fps_counter); error_destroy_video_buffer: - video_buffer_destroy(&screen->vb); + sc_video_buffer_destroy(&screen->vb); return false; } @@ -489,7 +489,7 @@ screen_destroy(struct screen *screen) { SDL_DestroyRenderer(screen->renderer); SDL_DestroyWindow(screen->window); fps_counter_destroy(&screen->fps_counter); - video_buffer_destroy(&screen->vb); + sc_video_buffer_destroy(&screen->vb); } static void @@ -595,7 +595,7 @@ update_texture(struct screen *screen, const AVFrame *frame) { static bool screen_update_frame(struct screen *screen) { av_frame_unref(screen->frame); - video_buffer_consume(&screen->vb, screen->frame); + sc_video_buffer_consume(&screen->vb, screen->frame); AVFrame *frame = screen->frame; fps_counter_add_rendered_frame(&screen->fps_counter); diff --git a/app/src/screen.h b/app/src/screen.h index 8acabebe..e38d65bc 100644 --- a/app/src/screen.h +++ b/app/src/screen.h @@ -20,7 +20,7 @@ struct screen { bool open; // track the open/close state to assert correct behavior #endif - struct video_buffer vb; + struct sc_video_buffer vb; struct fps_counter fps_counter; SDL_Window *window; diff --git a/app/src/v4l2_sink.c b/app/src/v4l2_sink.c index 7904b450..4b8ea043 100644 --- a/app/src/v4l2_sink.c +++ b/app/src/v4l2_sink.c @@ -124,7 +124,7 @@ run_v4l2_sink(void *data) { vs->has_frame = false; sc_mutex_unlock(&vs->mutex); - video_buffer_consume(&vs->vb, vs->frame); + sc_video_buffer_consume(&vs->vb, vs->frame); bool ok = encode_and_write_frame(vs, vs->frame); av_frame_unref(vs->frame); @@ -141,7 +141,7 @@ run_v4l2_sink(void *data) { static bool sc_v4l2_sink_open(struct sc_v4l2_sink *vs) { - bool ok = video_buffer_init(&vs->vb); + bool ok = sc_video_buffer_init(&vs->vb); if (!ok) { LOGE("Could not initialize video buffer"); return false; @@ -276,7 +276,7 @@ error_cond_destroy: error_mutex_destroy: sc_mutex_destroy(&vs->mutex); error_video_buffer_destroy: - video_buffer_destroy(&vs->vb); + sc_video_buffer_destroy(&vs->vb); return false; } @@ -298,13 +298,13 @@ sc_v4l2_sink_close(struct sc_v4l2_sink *vs) { avformat_free_context(vs->format_ctx); sc_cond_destroy(&vs->cond); sc_mutex_destroy(&vs->mutex); - video_buffer_destroy(&vs->vb); + sc_video_buffer_destroy(&vs->vb); } static bool sc_v4l2_sink_push(struct sc_v4l2_sink *vs, const AVFrame *frame) { bool previous_skipped; - bool ok = video_buffer_push(&vs->vb, frame, &previous_skipped); + bool ok = sc_video_buffer_push(&vs->vb, frame, &previous_skipped); if (!ok) { return false; } diff --git a/app/src/v4l2_sink.h b/app/src/v4l2_sink.h index aad25926..cf3fdddc 100644 --- a/app/src/v4l2_sink.h +++ b/app/src/v4l2_sink.h @@ -12,7 +12,7 @@ struct sc_v4l2_sink { struct sc_frame_sink frame_sink; // frame sink trait - struct video_buffer vb; + struct sc_video_buffer vb; AVFormatContext *format_ctx; AVCodecContext *encoder_ctx; diff --git a/app/src/video_buffer.c b/app/src/video_buffer.c index 7adf098b..a1d09cb8 100644 --- a/app/src/video_buffer.c +++ b/app/src/video_buffer.c @@ -7,7 +7,7 @@ #include "util/log.h" bool -video_buffer_init(struct video_buffer *vb) { +sc_video_buffer_init(struct sc_video_buffer *vb) { vb->pending_frame = av_frame_alloc(); if (!vb->pending_frame) { return false; @@ -33,7 +33,7 @@ video_buffer_init(struct video_buffer *vb) { } void -video_buffer_destroy(struct video_buffer *vb) { +sc_video_buffer_destroy(struct sc_video_buffer *vb) { sc_mutex_destroy(&vb->mutex); av_frame_free(&vb->pending_frame); av_frame_free(&vb->tmp_frame); @@ -47,7 +47,7 @@ swap_frames(AVFrame **lhs, AVFrame **rhs) { } bool -video_buffer_push(struct video_buffer *vb, const AVFrame *frame, +sc_video_buffer_push(struct sc_video_buffer *vb, const AVFrame *frame, bool *previous_frame_skipped) { sc_mutex_lock(&vb->mutex); @@ -75,7 +75,7 @@ video_buffer_push(struct video_buffer *vb, const AVFrame *frame, } void -video_buffer_consume(struct video_buffer *vb, AVFrame *dst) { +sc_video_buffer_consume(struct sc_video_buffer *vb, AVFrame *dst) { sc_mutex_lock(&vb->mutex); assert(!vb->pending_frame_consumed); vb->pending_frame_consumed = true; diff --git a/app/src/video_buffer.h b/app/src/video_buffer.h index c4d1d1a4..f4364e08 100644 --- a/app/src/video_buffer.h +++ b/app/src/video_buffer.h @@ -1,5 +1,5 @@ -#ifndef VIDEO_BUFFER_H -#define VIDEO_BUFFER_H +#ifndef SC_VIDEO_BUFFER_H +#define SC_VIDEO_BUFFER_H #include "common.h" @@ -19,7 +19,7 @@ typedef struct AVFrame AVFrame; * last frame to minimize latency. */ -struct video_buffer { +struct sc_video_buffer { AVFrame *pending_frame; AVFrame *tmp_frame; // To preserve the pending frame on error @@ -29,15 +29,16 @@ struct video_buffer { }; bool -video_buffer_init(struct video_buffer *vb); +sc_video_buffer_init(struct sc_video_buffer *vb); void -video_buffer_destroy(struct video_buffer *vb); +sc_video_buffer_destroy(struct sc_video_buffer *vb); bool -video_buffer_push(struct video_buffer *vb, const AVFrame *frame, bool *skipped); +sc_video_buffer_push(struct sc_video_buffer *vb, const AVFrame *frame, + bool *skipped); void -video_buffer_consume(struct video_buffer *vb, AVFrame *dst); +sc_video_buffer_consume(struct sc_video_buffer *vb, AVFrame *dst); #endif