AudioContext
AudioContext
#include <icy/av/audiocontext.h>Subclassed by:
AudioDecoder,AudioEncoder
Base context for audio encoding and decoding via FFmpeg.
Public Attributes
| Return | Name | Description |
|---|---|---|
PacketSignal | emitter | |
AudioCodec | iparams | input parameters |
AudioCodec | oparams | output parameters |
AVStream * | stream | encoder or decoder stream |
AVCodecContext * | ctx | encoder or decoder context |
const AVCodec * | codec | encoder or decoder codec |
AVFrame * | frame | last encoded or decoded frame |
std::unique_ptr< AudioResampler > | resampler | audio resampler |
int | outputFrameSize | encoder or decoder output frame size |
int64_t | time | stream time in codec time base |
int64_t | pts | last packet pts value |
double | seconds | audio time in seconds |
std::string | error | error message |
emitter
PacketSignal emitteriparams
AudioCodec iparamsinput parameters
oparams
AudioCodec oparamsoutput parameters
stream
AVStream * streamencoder or decoder stream
ctx
AVCodecContext * ctxencoder or decoder context
codec
const AVCodec * codecencoder or decoder codec
frame
AVFrame * framelast encoded or decoded frame
resampler
std::unique_ptr< AudioResampler > resampleraudio resampler
outputFrameSize
int outputFrameSizeencoder or decoder output frame size
time
int64_t timestream time in codec time base
pts
int64_t ptslast packet pts value
seconds
double secondsaudio time in seconds
error
std::string errorerror message
Public Methods
| Return | Name | Description |
|---|---|---|
AudioContext | ||
AudioContext | Deleted constructor. | |
AudioContext | Deleted constructor. | |
void | create | Initialise the AVCodecContext with codec-specific defaults. Implemented by AudioEncoder and AudioDecoder. |
void | open virtual | Open the codec and create the resampler if input/output parameters differ. Throws std::runtime_error if the codec context has not been created. |
void | close virtual | Close the codec context, free the frame, and reset timestamps. |
bool | decode virtual | Decode a compressed audio packet and emit the resulting samples. |
bool | encode virtual | Encode a buffer of interleaved audio samples. |
bool | encode virtual | Encode a buffer of planar audio samples. |
bool | encode virtual | Encode a single AVFrame. |
void | flush virtual | Flush any frames buffered inside the codec and emit remaining output. |
bool | recreateResampler virtual | Recreate the AudioResampler using the current iparams and oparams. Called automatically by open() when format conversion is required. |
AudioContext
AudioContext()AudioContext
AudioContext(const AudioContext &) = deleteDeleted constructor.
AudioContext
AudioContext(AudioContext &&) = deleteDeleted constructor.
create
void create()Initialise the AVCodecContext with codec-specific defaults. Implemented by AudioEncoder and AudioDecoder.
open
virtual
virtual void open()Open the codec and create the resampler if input/output parameters differ. Throws std::runtime_error if the codec context has not been created.
close
virtual
virtual void close()Close the codec context, free the frame, and reset timestamps.
decode
virtual
virtual bool decode(AVPacket & ipacket)Decode a compressed audio packet and emit the resulting samples.
Parameters
ipacketThe compressed audio packet to decode.
Returns
True if one or more decoded frames were emitted, false otherwise.
encode
virtual
virtual bool encode(uint8_t * samples, int numSamples, int64_t pts)Encode a buffer of interleaved audio samples.
Parameters
samplesPointer to the interleaved sample buffer.numSamplesNumber of samples per channel.ptsPresentation timestamp in stream time base units.
Returns
True if an encoded packet was produced and emitted.
encode
virtual
virtual bool encode(uint8_t * samples, int numSamples, int64_t pts)Encode a buffer of planar audio samples.
Parameters
samplesArray of per-channel sample buffers (up to 4 planes).numSamplesNumber of samples per channel.ptsPresentation timestamp in stream time base units.
Returns
True if an encoded packet was produced and emitted.
encode
virtual
virtual bool encode(AVFrame * iframe)Encode a single AVFrame.
Parameters
iframeThe source audio frame; must have all fields set correctly.
Returns
True if an encoded packet was produced and emitted.
flush
virtual
virtual void flush()Flush any frames buffered inside the codec and emit remaining output.
recreateResampler
virtual
virtual bool recreateResampler()Recreate the AudioResampler using the current iparams and oparams. Called automatically by open() when format conversion is required.
Returns
True if the resampler was successfully created.
