2018-11-09 19:21:17 +08:00
|
|
|
#ifndef RECORDER_H
|
|
|
|
#define RECORDER_H
|
|
|
|
|
2019-03-03 06:52:22 +08:00
|
|
|
#include <stdbool.h>
|
2018-11-09 19:21:17 +08:00
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
2019-02-09 22:20:07 +08:00
|
|
|
enum recorder_format {
|
|
|
|
RECORDER_FORMAT_MP4 = 1,
|
|
|
|
RECORDER_FORMAT_MKV,
|
|
|
|
};
|
|
|
|
|
2018-11-09 19:21:17 +08:00
|
|
|
struct recorder {
|
|
|
|
char *filename;
|
2019-02-09 22:20:07 +08:00
|
|
|
enum recorder_format format;
|
2018-11-09 19:21:17 +08:00
|
|
|
AVFormatContext *ctx;
|
|
|
|
struct size declared_frame_size;
|
2019-03-03 06:52:22 +08:00
|
|
|
bool header_written;
|
2018-11-09 19:21:17 +08:00
|
|
|
};
|
|
|
|
|
2019-03-03 06:52:22 +08:00
|
|
|
bool
|
2019-03-03 03:09:56 +08:00
|
|
|
recorder_init(struct recorder *recoder, const char *filename,
|
|
|
|
enum recorder_format format, struct size declared_frame_size);
|
2019-02-09 22:20:07 +08:00
|
|
|
|
2019-03-03 03:09:56 +08:00
|
|
|
void
|
|
|
|
recorder_destroy(struct recorder *recorder);
|
2018-11-09 19:21:17 +08:00
|
|
|
|
2019-03-03 06:52:22 +08:00
|
|
|
bool
|
2019-03-03 03:09:56 +08:00
|
|
|
recorder_open(struct recorder *recorder, AVCodec *input_codec);
|
2018-11-09 19:21:17 +08:00
|
|
|
|
2019-03-03 03:09:56 +08:00
|
|
|
void
|
|
|
|
recorder_close(struct recorder *recorder);
|
|
|
|
|
2019-03-03 06:52:22 +08:00
|
|
|
bool
|
2019-03-03 03:09:56 +08:00
|
|
|
recorder_write(struct recorder *recorder, AVPacket *packet);
|
2018-11-09 19:21:17 +08:00
|
|
|
|
|
|
|
#endif
|