mirror of
https://github.com/Genymobile/scrcpy
synced 2024-10-23 03:46:38 +00:00
1230149fdd
The components needing delayed frames (sc_screen and sc_v4l2_sink) managed a sc_video_buffer instance, which itself embedded a sc_frame_buffer instance (to keep only the most recent frame). In theory, these components should not be aware of delaying: they should just receive AVFrames later, and only handle a sc_frame_buffer. Therefore, refactor sc_delay_buffer as a frame source (it consumes) frames) and a frame sink (it produces frames, after some delay), and plug an instance in the pipeline only when a delay is requested. This also removes the need for a specific sc_video_buffer. PR #3757 <https://github.com/Genymobile/scrcpy/pull/3757>
43 lines
818 B
C
43 lines
818 B
C
#ifndef SC_V4L2_SINK_H
|
|
#define SC_V4L2_SINK_H
|
|
|
|
#include "common.h"
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
#include <libavformat/avformat.h>
|
|
|
|
#include "coords.h"
|
|
#include "trait/frame_sink.h"
|
|
#include "frame_buffer.h"
|
|
#include "util/tick.h"
|
|
|
|
struct sc_v4l2_sink {
|
|
struct sc_frame_sink frame_sink; // frame sink trait
|
|
|
|
struct sc_frame_buffer fb;
|
|
AVFormatContext *format_ctx;
|
|
AVCodecContext *encoder_ctx;
|
|
|
|
char *device_name;
|
|
struct sc_size frame_size;
|
|
|
|
sc_thread thread;
|
|
sc_mutex mutex;
|
|
sc_cond cond;
|
|
bool has_frame;
|
|
bool stopped;
|
|
bool header_written;
|
|
|
|
AVFrame *frame;
|
|
AVPacket *packet;
|
|
};
|
|
|
|
bool
|
|
sc_v4l2_sink_init(struct sc_v4l2_sink *vs, const char *device_name,
|
|
struct sc_size frame_size);
|
|
|
|
void
|
|
sc_v4l2_sink_destroy(struct sc_v4l2_sink *vs);
|
|
|
|
#endif
|