#ifndef AUDIO_MUXER_H_ #define AUDIO_MUXER_H_ #include #include /** * An AudioMuxer is responsible for attaching and managing an audio stream to an * FFMPEG AVFormatContext instance. Ultimately, AudioMuxer allows users to pass * amorphous FFMPEG audio packets to an AvFormatContext without worrying about * encoding or sample count, and to enable silent streaming. */ typedef struct AudioMuxer AudioMuxer; struct AudioMuxerOpt { int sample_rate; enum AVSampleFormat sample_format; enum AVCodecID codec_id; AVChannelLayout ch_layout; AVDictionary **opts_muxer; AVDictionary **opts_encoder; }; #define AUDIO_MUXER_OPT_DEFAULTS\ .sample_rate = 44100,\ .sample_format = 0,\ .codec_id = 0,\ .ch_layout = 0,\ .opts_muxer = NULL,\ .opts_encoder = NULL /** * Initialize **pmuxer using the parameters passed by *opts and attach an audio * stream to *avctx. This function mearly configures the output front of the * remuxer (i.e. a stream, an encoder, and part of a resmapler), and a second * call to audiomuxer_conf must be dispatched before sending in packets. Return * 0 on success, or a negative AVERROR on failure. */ int audiomuxer_init(AudioMuxer **pmuxer, AVFormatContext *avctx, const struct AudioMuxerOpt *opts); /** * Configure *muxer to process input from a given *input stream. Internally, * this function allocate a decoder and configure the remuxer's resampler to * suite *input's codec and sample rate. Return 0 on success, or a negative * AVERROR on failure. */ int audiomuxer_conf(AudioMuxer *muxer, const AVStream *input); int audiomuxer_send_packet (AudioMuxer *muxer, const AVPacket *pkt_in); int audiomuxer_send_silence (AudioMuxer *muxer, unsigned int microsec); uint64_t audiomuxer_get_runtime (const AudioMuxer *muxer); void audiomuxer_free (AudioMuxer *muxer); #endif // AUDIO_MUXER_H_