Inline packet_sink impl in recorder
Remove useless wrappers.
This commit is contained in:
parent
fb29135591
commit
6b5dfef923
1 changed files with 14 additions and 25 deletions
|
@ -247,7 +247,11 @@ run_recorder(void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
sc_recorder_open(struct sc_recorder *recorder, const AVCodec *input_codec) {
|
sc_recorder_packet_sink_open(struct sc_packet_sink *sink,
|
||||||
|
const AVCodec *codec) {
|
||||||
|
struct sc_recorder *recorder = DOWNCAST(sink);
|
||||||
|
assert(codec);
|
||||||
|
|
||||||
const char *format_name = sc_recorder_get_format_name(recorder->format);
|
const char *format_name = sc_recorder_get_format_name(recorder->format);
|
||||||
assert(format_name);
|
assert(format_name);
|
||||||
const AVOutputFormat *format = find_muxer(format_name);
|
const AVOutputFormat *format = find_muxer(format_name);
|
||||||
|
@ -271,13 +275,13 @@ sc_recorder_open(struct sc_recorder *recorder, const AVCodec *input_codec) {
|
||||||
av_dict_set(&recorder->ctx->metadata, "comment",
|
av_dict_set(&recorder->ctx->metadata, "comment",
|
||||||
"Recorded by scrcpy " SCRCPY_VERSION, 0);
|
"Recorded by scrcpy " SCRCPY_VERSION, 0);
|
||||||
|
|
||||||
AVStream *ostream = avformat_new_stream(recorder->ctx, input_codec);
|
AVStream *ostream = avformat_new_stream(recorder->ctx, codec);
|
||||||
if (!ostream) {
|
if (!ostream) {
|
||||||
goto error_avformat_free_context;
|
goto error_avformat_free_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
ostream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
ostream->codecpar->codec_id = input_codec->id;
|
ostream->codecpar->codec_id = codec->id;
|
||||||
ostream->codecpar->format = AV_PIX_FMT_YUV420P;
|
ostream->codecpar->format = AV_PIX_FMT_YUV420P;
|
||||||
ostream->codecpar->width = recorder->declared_frame_size.width;
|
ostream->codecpar->width = recorder->declared_frame_size.width;
|
||||||
ostream->codecpar->height = recorder->declared_frame_size.height;
|
ostream->codecpar->height = recorder->declared_frame_size.height;
|
||||||
|
@ -311,7 +315,9 @@ error_avformat_free_context:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sc_recorder_close(struct sc_recorder *recorder) {
|
sc_recorder_packet_sink_close(struct sc_packet_sink *sink) {
|
||||||
|
struct sc_recorder *recorder = DOWNCAST(sink);
|
||||||
|
|
||||||
sc_mutex_lock(&recorder->mutex);
|
sc_mutex_lock(&recorder->mutex);
|
||||||
recorder->stopped = true;
|
recorder->stopped = true;
|
||||||
sc_cond_signal(&recorder->queue_cond);
|
sc_cond_signal(&recorder->queue_cond);
|
||||||
|
@ -324,7 +330,10 @@ sc_recorder_close(struct sc_recorder *recorder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
sc_recorder_push(struct sc_recorder *recorder, const AVPacket *packet) {
|
sc_recorder_packet_sink_push(struct sc_packet_sink *sink,
|
||||||
|
const AVPacket *packet) {
|
||||||
|
struct sc_recorder *recorder = DOWNCAST(sink);
|
||||||
|
|
||||||
sc_mutex_lock(&recorder->mutex);
|
sc_mutex_lock(&recorder->mutex);
|
||||||
assert(!recorder->stopped);
|
assert(!recorder->stopped);
|
||||||
|
|
||||||
|
@ -348,26 +357,6 @@ sc_recorder_push(struct sc_recorder *recorder, const AVPacket *packet) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
sc_recorder_packet_sink_open(struct sc_packet_sink *sink,
|
|
||||||
const AVCodec *codec) {
|
|
||||||
struct sc_recorder *recorder = DOWNCAST(sink);
|
|
||||||
return sc_recorder_open(recorder, codec);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
sc_recorder_packet_sink_close(struct sc_packet_sink *sink) {
|
|
||||||
struct sc_recorder *recorder = DOWNCAST(sink);
|
|
||||||
sc_recorder_close(recorder);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
sc_recorder_packet_sink_push(struct sc_packet_sink *sink,
|
|
||||||
const AVPacket *packet) {
|
|
||||||
struct sc_recorder *recorder = DOWNCAST(sink);
|
|
||||||
return sc_recorder_push(recorder, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
sc_recorder_init(struct sc_recorder *recorder, const char *filename,
|
sc_recorder_init(struct sc_recorder *recorder, const char *filename,
|
||||||
enum sc_record_format format,
|
enum sc_record_format format,
|
||||||
|
|
Loading…
Reference in a new issue