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"
|
|
|
|
#include "video_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
|
|
|
|
|
2021-06-26 21:02:18 +08:00
|
|
|
struct sc_video_buffer vb;
|
2021-04-04 06:10:44 +08:00
|
|
|
AVFormatContext *format_ctx;
|
|
|
|
AVCodecContext *encoder_ctx;
|
|
|
|
|
|
|
|
char *device_name;
|
2021-10-30 21:20:39 +08:00
|
|
|
struct sc_size frame_size;
|
2021-07-07 01:04:05 +08:00
|
|
|
sc_tick buffering_time;
|
2021-04-04 06:10:44 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
sc_v4l2_sink_init(struct sc_v4l2_sink *vs, const char *device_name,
|
2021-10-30 21:20:39 +08:00
|
|
|
struct sc_size frame_size, sc_tick buffering_time);
|
2021-04-04 06:10:44 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
sc_v4l2_sink_destroy(struct sc_v4l2_sink *vs);
|
|
|
|
|
|
|
|
#endif
|