22#ifndef FFTOOLS_FFMPEG_SCHED_H
23#define FFTOOLS_FFMPEG_SCHED_H
111#define SCH_DSTREAM(file, stream) \
112 (SchedulerNode){ .type = SCH_NODE_TYPE_DEMUX, \
113 .idx = file, .idx_stream = stream }
114#define SCH_MSTREAM(file, stream) \
115 (SchedulerNode){ .type = SCH_NODE_TYPE_MUX, \
116 .idx = file, .idx_stream = stream }
117#define SCH_DEC_IN(decoder) \
118 (SchedulerNode){ .type = SCH_NODE_TYPE_DEC, \
120#define SCH_DEC_OUT(decoder, out_idx) \
121 (SchedulerNode){ .type = SCH_NODE_TYPE_DEC, \
122 .idx = decoder, .idx_stream = out_idx }
123#define SCH_ENC(encoder) \
124 (SchedulerNode){ .type = SCH_NODE_TYPE_ENC, \
126#define SCH_FILTER_IN(filter, input) \
127 (SchedulerNode){ .type = SCH_NODE_TYPE_FILTER_IN, \
128 .idx = filter, .idx_stream = input }
129#define SCH_FILTER_OUT(filter, output) \
130 (SchedulerNode){ .type = SCH_NODE_TYPE_FILTER_OUT, \
131 .idx = filter, .idx_stream = output }
251 void *
ctx,
int sdp_auto,
unsigned thread_queue_size);
257#define DEFAULT_PACKET_THREAD_QUEUE_SIZE 8
262#define DEFAULT_FRAME_THREAD_QUEUE_SIZE 2
286 size_t data_threshold,
int max_packets);
318 int (*open_cb)(
void *func_arg,
const struct AVFrame *
frame));
331 int limiting, uint64_t max_frames);
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define flags(name, subs,...)
int(* init)(AVBSFContext *ctx)
int(* SchThreadFunc)(void *arg)
int sch_add_dec(Scheduler *sch, SchThreadFunc func, void *ctx, int send_end_ts)
Add a decoder to the scheduler.
int sch_dec_send(Scheduler *sch, unsigned dec_idx, unsigned out_idx, struct AVFrame *frame)
Called by decoder tasks to send a decoded frame downstream.
int sch_mux_receive(Scheduler *sch, unsigned mux_idx, struct AVPacket *pkt)
Called by muxer tasks to obtain packets for muxing.
Scheduler * sch_alloc(void)
int sch_add_filtergraph(Scheduler *sch, unsigned nb_inputs, unsigned nb_outputs, SchThreadFunc func, void *ctx)
Add a filtergraph to the scheduler.
void sch_filter_receive_finish(Scheduler *sch, unsigned fg_idx, unsigned in_idx)
Called by filter tasks to signal that a filter input will no longer accept input.
int sch_demux_send(Scheduler *sch, unsigned demux_idx, struct AVPacket *pkt, unsigned flags)
Called by demuxer tasks to communicate with their downstreams.
int sch_mux_sub_heartbeat_add(Scheduler *sch, unsigned mux_idx, unsigned stream_idx, unsigned dec_idx)
int sch_start(Scheduler *sch)
@ DEMUX_SEND_STREAMCOPY_EOF
Treat the packet as an EOF for SCH_NODE_TYPE_MUX destinations send normally to other types.
void sch_remove_filtergraph(Scheduler *sch, int idx)
int sch_add_dec_output(Scheduler *sch, unsigned dec_idx)
Add another output to decoder (e.g.
int sch_mux_stream_ready(Scheduler *sch, unsigned mux_idx, unsigned stream_idx)
Signal to the scheduler that the specified muxed stream is initialized and ready.
int sch_stop(Scheduler *sch, int64_t *finish_ts)
void sch_mux_receive_finish(Scheduler *sch, unsigned mux_idx, unsigned stream_idx)
Called by muxer tasks to signal that a stream will no longer accept input.
int sch_filter_command(Scheduler *sch, unsigned fg_idx, struct AVFrame *frame)
int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, struct AVFrame *frame)
Called by filtergraph tasks to send a filtered frame or EOF to consumers.
int sch_add_enc(Scheduler *sch, SchThreadFunc func, void *ctx, int(*open_cb)(void *func_arg, const struct AVFrame *frame))
Add an encoder to the scheduler.
int sch_add_sq_enc(Scheduler *sch, uint64_t buf_size_us, void *logctx)
Add an pre-encoding sync queue to the scheduler.
int sch_sq_add_enc(Scheduler *sch, unsigned sq_idx, unsigned enc_idx, int limiting, uint64_t max_frames)
int sch_wait(Scheduler *sch, uint64_t timeout_us, int64_t *transcode_ts)
Wait until transcoding terminates or the specified timeout elapses.
void sch_mux_stream_buffering(Scheduler *sch, unsigned mux_idx, unsigned stream_idx, size_t data_threshold, int max_packets)
Configure limits on packet buffering performed before the muxer task is started.
@ SCH_NODE_TYPE_FILTER_OUT
@ SCH_NODE_TYPE_FILTER_IN
int sch_enc_receive(Scheduler *sch, unsigned enc_idx, struct AVFrame *frame)
Called by encoder tasks to obtain frames for encoding.
int sch_sdp_filename(Scheduler *sch, const char *sdp_filename)
Set the file path for the SDP.
int sch_filter_receive(Scheduler *sch, unsigned fg_idx, unsigned *in_idx, struct AVFrame *frame)
Called by filtergraph tasks to obtain frames for filtering.
void sch_filter_choke_inputs(Scheduler *sch, unsigned fg_idx)
Called by filtergraph tasks to choke all filter inputs, preventing them from receiving more frames un...
int sch_add_demux_stream(Scheduler *sch, unsigned demux_idx)
Add a demuxed stream for a previously added demuxer.
void sch_free(Scheduler **sch)
int sch_connect(Scheduler *sch, SchedulerNode src, SchedulerNode dst)
int sch_add_demux(Scheduler *sch, SchThreadFunc func, void *ctx)
Add a demuxer to the scheduler.
int sch_mux_sub_heartbeat(Scheduler *sch, unsigned mux_idx, unsigned stream_idx, const AVPacket *pkt)
int sch_add_mux_stream(Scheduler *sch, unsigned mux_idx)
Add a muxed stream for a previously added muxer.
int sch_add_mux(Scheduler *sch, SchThreadFunc func, int(*init)(void *), void *ctx, int sdp_auto, unsigned thread_queue_size)
Add a muxer to the scheduler.
int sch_dec_receive(Scheduler *sch, unsigned dec_idx, struct AVPacket *pkt)
Called by decoder tasks to receive a packet for decoding.
int sch_enc_send(Scheduler *sch, unsigned enc_idx, struct AVPacket *pkt)
Called by encoder tasks to send encoded packets downstream.
int(* func)(AVBPrint *dst, const char *in, const char *arg)
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
enum SchedulerNodeType type
static AVFormatContext * ctx