Go to the documentation of this file.
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 }
249 void *
ctx,
int sdp_auto,
unsigned thread_queue_size);
255 #define DEFAULT_PACKET_THREAD_QUEUE_SIZE 8
260 #define DEFAULT_FRAME_THREAD_QUEUE_SIZE 8
284 size_t data_threshold,
int max_packets);
316 int (*open_cb)(
void *func_arg,
const struct AVFrame *
frame));
329 int limiting, uint64_t max_frames);
int(* func)(AVBPrint *dst, const char *in, const char *arg)
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_stop(Scheduler *sch, int64_t *finish_ts)
This structure describes decoded (raw) audio or video data.
int sch_add_demux(Scheduler *sch, SchThreadFunc func, void *ctx)
Add a demuxer to the scheduler.
enum SchedulerNodeType type
void sch_free(Scheduler **sch)
int(* SchThreadFunc)(void *arg)
int sch_mux_receive(Scheduler *sch, unsigned mux_idx, struct AVPacket *pkt)
Called by muxer tasks to obtain packets for muxing.
int sch_enc_send(Scheduler *sch, unsigned enc_idx, struct AVPacket *pkt)
Called by encoder tasks to send encoded packets downstream.
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_sdp_filename(Scheduler *sch, const char *sdp_filename)
Set the file path for the SDP.
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_enc_receive(Scheduler *sch, unsigned enc_idx, struct AVFrame *frame)
Called by encoder tasks to obtain frames for encoding.
int sch_start(Scheduler *sch)
int sch_mux_sub_heartbeat(Scheduler *sch, unsigned mux_idx, unsigned stream_idx, const AVPacket *pkt)
int sch_connect(Scheduler *sch, SchedulerNode src, SchedulerNode dst)
int sch_filter_command(Scheduler *sch, unsigned fg_idx, struct AVFrame *frame)
Scheduler * sch_alloc(void)
@ DEMUX_SEND_STREAMCOPY_EOF
Treat the packet as an EOF for SCH_NODE_TYPE_MUX destinations send normally to other types.
int sch_add_demux_stream(Scheduler *sch, unsigned demux_idx)
Add a demuxed stream for a previously added demuxer.
int(* init)(AVBSFContext *ctx)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
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_add_dec_output(Scheduler *sch, unsigned dec_idx)
Add another output to decoder (e.g.
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.
@ SCH_NODE_TYPE_FILTER_OUT
int sch_add_dec(Scheduler *sch, SchThreadFunc func, void *ctx, int send_end_ts)
Add a decoder to the scheduler.
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_sq_enc(Scheduler *sch, uint64_t buf_size_us, void *logctx)
Add an pre-encoding sync queue to the scheduler.
@ SCH_NODE_TYPE_FILTER_IN
int sch_wait(Scheduler *sch, uint64_t timeout_us, int64_t *transcode_ts)
Wait until transcoding terminates or the specified timeout elapses.
int sch_add_mux_stream(Scheduler *sch, unsigned mux_idx)
Add a muxed stream for a previously added muxer.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int sch_add_filtergraph(Scheduler *sch, unsigned nb_inputs, unsigned nb_outputs, SchThreadFunc func, void *ctx)
Add a filtergraph to the scheduler.
int sch_filter_receive(Scheduler *sch, unsigned fg_idx, unsigned *in_idx, struct AVFrame *frame)
Called by filtergraph tasks to obtain frames for filtering.
int sch_sq_add_enc(Scheduler *sch, unsigned sq_idx, unsigned enc_idx, int limiting, uint64_t max_frames)
int sch_mux_sub_heartbeat_add(Scheduler *sch, unsigned mux_idx, unsigned stream_idx, unsigned dec_idx)
This structure stores compressed data.
int sch_dec_receive(Scheduler *sch, unsigned dec_idx, struct AVPacket *pkt)
Called by decoder tasks to receive a packet for decoding.
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.
#define flags(name, subs,...)
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.
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.