1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef AUDIO_MUXER_H_
#define AUDIO_MUXER_H_
#include <libavformat/avformat.h>
#include <libavutil/frame.h>
/**
* 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_
|