2021-04-04 06:10:44 +08:00
|
|
|
#ifndef SC_V4L2_SINK_H
|
|
|
|
#define SC_V4L2_SINK_H
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
2022-01-16 08:45:36 +08:00
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
|
2021-04-04 06:10:44 +08:00
|
|
|
#include "coords.h"
|
|
|
|
#include "trait/frame_sink.h"
|
2023-03-03 04:30:24 +08:00
|
|
|
#include "frame_buffer.h"
|
2021-07-07 01:04:05 +08:00
|
|
|
#include "util/tick.h"
|
2021-04-04 06:10:44 +08:00
|
|
|
|
|
|
|
struct sc_v4l2_sink {
|
|
|
|
struct sc_frame_sink frame_sink; // frame sink trait
|
|
|
|
|
2023-03-03 04:30:24 +08:00
|
|
|
struct sc_frame_buffer fb;
|
2021-04-04 06:10:44 +08:00
|
|
|
AVFormatContext *format_ctx;
|
|
|
|
AVCodecContext *encoder_ctx;
|
|
|
|
|
|
|
|
char *device_name;
|
|
|
|
|
|
|
|
sc_thread thread;
|
|
|
|
sc_mutex mutex;
|
|
|
|
sc_cond cond;
|
2021-06-26 21:53:05 +08:00
|
|
|
bool has_frame;
|
2021-04-04 06:10:44 +08:00
|
|
|
bool stopped;
|
|
|
|
bool header_written;
|
|
|
|
|
|
|
|
AVFrame *frame;
|
2021-06-14 15:07:49 +08:00
|
|
|
AVPacket *packet;
|
2021-04-04 06:10:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
2023-03-11 16:21:49 +08:00
|
|
|
sc_v4l2_sink_init(struct sc_v4l2_sink *vs, const char *device_name);
|
2021-04-04 06:10:44 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
sc_v4l2_sink_destroy(struct sc_v4l2_sink *vs);
|
|
|
|
|
|
|
|
#endif
|