Rename video_buffer to sc_video_buffer
Add a scrcpy-specific prefix.
This commit is contained in:
parent
28bce48d47
commit
336248df08
6 changed files with 24 additions and 23 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue