Rename video_buffer to sc_video_buffer

Add a scrcpy-specific prefix.
This commit is contained in:
Romain Vimont 2021-06-26 15:02:18 +02:00
parent 28bce48d47
commit 336248df08
6 changed files with 24 additions and 23 deletions

View file

@ -276,7 +276,7 @@ screen_frame_sink_push(struct sc_frame_sink *sink, const AVFrame *frame) {
struct screen *screen = DOWNCAST(sink); struct screen *screen = DOWNCAST(sink);
bool previous_frame_skipped; 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) { if (!ok) {
return false; return false;
} }
@ -304,7 +304,7 @@ screen_init(struct screen *screen, const struct screen_params *params) {
screen->fullscreen = false; screen->fullscreen = false;
screen->maximized = false; screen->maximized = false;
bool ok = video_buffer_init(&screen->vb); bool ok = sc_video_buffer_init(&screen->vb);
if (!ok) { if (!ok) {
LOGE("Could not initialize video buffer"); LOGE("Could not initialize video buffer");
return false; return false;
@ -454,7 +454,7 @@ error_destroy_window:
error_destroy_fps_counter: error_destroy_fps_counter:
fps_counter_destroy(&screen->fps_counter); fps_counter_destroy(&screen->fps_counter);
error_destroy_video_buffer: error_destroy_video_buffer:
video_buffer_destroy(&screen->vb); sc_video_buffer_destroy(&screen->vb);
return false; return false;
} }
@ -489,7 +489,7 @@ screen_destroy(struct screen *screen) {
SDL_DestroyRenderer(screen->renderer); SDL_DestroyRenderer(screen->renderer);
SDL_DestroyWindow(screen->window); SDL_DestroyWindow(screen->window);
fps_counter_destroy(&screen->fps_counter); fps_counter_destroy(&screen->fps_counter);
video_buffer_destroy(&screen->vb); sc_video_buffer_destroy(&screen->vb);
} }
static void static void
@ -595,7 +595,7 @@ update_texture(struct screen *screen, const AVFrame *frame) {
static bool static bool
screen_update_frame(struct screen *screen) { screen_update_frame(struct screen *screen) {
av_frame_unref(screen->frame); av_frame_unref(screen->frame);
video_buffer_consume(&screen->vb, screen->frame); sc_video_buffer_consume(&screen->vb, screen->frame);
AVFrame *frame = screen->frame; AVFrame *frame = screen->frame;
fps_counter_add_rendered_frame(&screen->fps_counter); fps_counter_add_rendered_frame(&screen->fps_counter);

View file

@ -20,7 +20,7 @@ struct screen {
bool open; // track the open/close state to assert correct behavior bool open; // track the open/close state to assert correct behavior
#endif #endif
struct video_buffer vb; struct sc_video_buffer vb;
struct fps_counter fps_counter; struct fps_counter fps_counter;
SDL_Window *window; SDL_Window *window;

View file

@ -124,7 +124,7 @@ run_v4l2_sink(void *data) {
vs->has_frame = false; vs->has_frame = false;
sc_mutex_unlock(&vs->mutex); 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); bool ok = encode_and_write_frame(vs, vs->frame);
av_frame_unref(vs->frame); av_frame_unref(vs->frame);
@ -141,7 +141,7 @@ run_v4l2_sink(void *data) {
static bool static bool
sc_v4l2_sink_open(struct sc_v4l2_sink *vs) { 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) { if (!ok) {
LOGE("Could not initialize video buffer"); LOGE("Could not initialize video buffer");
return false; return false;
@ -276,7 +276,7 @@ error_cond_destroy:
error_mutex_destroy: error_mutex_destroy:
sc_mutex_destroy(&vs->mutex); sc_mutex_destroy(&vs->mutex);
error_video_buffer_destroy: error_video_buffer_destroy:
video_buffer_destroy(&vs->vb); sc_video_buffer_destroy(&vs->vb);
return false; return false;
} }
@ -298,13 +298,13 @@ sc_v4l2_sink_close(struct sc_v4l2_sink *vs) {
avformat_free_context(vs->format_ctx); avformat_free_context(vs->format_ctx);
sc_cond_destroy(&vs->cond); sc_cond_destroy(&vs->cond);
sc_mutex_destroy(&vs->mutex); sc_mutex_destroy(&vs->mutex);
video_buffer_destroy(&vs->vb); sc_video_buffer_destroy(&vs->vb);
} }
static bool static bool
sc_v4l2_sink_push(struct sc_v4l2_sink *vs, const AVFrame *frame) { sc_v4l2_sink_push(struct sc_v4l2_sink *vs, const AVFrame *frame) {
bool previous_skipped; 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) { if (!ok) {
return false; return false;
} }

View file

@ -12,7 +12,7 @@
struct sc_v4l2_sink { struct sc_v4l2_sink {
struct sc_frame_sink frame_sink; // frame sink trait struct sc_frame_sink frame_sink; // frame sink trait
struct video_buffer vb; struct sc_video_buffer vb;
AVFormatContext *format_ctx; AVFormatContext *format_ctx;
AVCodecContext *encoder_ctx; AVCodecContext *encoder_ctx;

View file

@ -7,7 +7,7 @@
#include "util/log.h" #include "util/log.h"
bool bool
video_buffer_init(struct video_buffer *vb) { sc_video_buffer_init(struct sc_video_buffer *vb) {
vb->pending_frame = av_frame_alloc(); vb->pending_frame = av_frame_alloc();
if (!vb->pending_frame) { if (!vb->pending_frame) {
return false; return false;
@ -33,7 +33,7 @@ video_buffer_init(struct video_buffer *vb) {
} }
void void
video_buffer_destroy(struct video_buffer *vb) { sc_video_buffer_destroy(struct sc_video_buffer *vb) {
sc_mutex_destroy(&vb->mutex); sc_mutex_destroy(&vb->mutex);
av_frame_free(&vb->pending_frame); av_frame_free(&vb->pending_frame);
av_frame_free(&vb->tmp_frame); av_frame_free(&vb->tmp_frame);
@ -47,7 +47,7 @@ swap_frames(AVFrame **lhs, AVFrame **rhs) {
} }
bool 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) { bool *previous_frame_skipped) {
sc_mutex_lock(&vb->mutex); sc_mutex_lock(&vb->mutex);
@ -75,7 +75,7 @@ video_buffer_push(struct video_buffer *vb, const AVFrame *frame,
} }
void 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); sc_mutex_lock(&vb->mutex);
assert(!vb->pending_frame_consumed); assert(!vb->pending_frame_consumed);
vb->pending_frame_consumed = true; vb->pending_frame_consumed = true;

View file

@ -1,5 +1,5 @@
#ifndef VIDEO_BUFFER_H #ifndef SC_VIDEO_BUFFER_H
#define VIDEO_BUFFER_H #define SC_VIDEO_BUFFER_H
#include "common.h" #include "common.h"
@ -19,7 +19,7 @@ typedef struct AVFrame AVFrame;
* last frame to minimize latency. * last frame to minimize latency.
*/ */
struct video_buffer { struct sc_video_buffer {
AVFrame *pending_frame; AVFrame *pending_frame;
AVFrame *tmp_frame; // To preserve the pending frame on error AVFrame *tmp_frame; // To preserve the pending frame on error
@ -29,15 +29,16 @@ struct video_buffer {
}; };
bool bool
video_buffer_init(struct video_buffer *vb); sc_video_buffer_init(struct sc_video_buffer *vb);
void void
video_buffer_destroy(struct video_buffer *vb); sc_video_buffer_destroy(struct sc_video_buffer *vb);
bool 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 void
video_buffer_consume(struct video_buffer *vb, AVFrame *dst); sc_video_buffer_consume(struct sc_video_buffer *vb, AVFrame *dst);
#endif #endif