AudioPacketEncoder
AudioPacketEncoder
#include <icy/av/audiopacketencoder.h>class AudioPacketEncoderDefined in src/av/include/icy/av/audiopacketencoder.h:44
Inherits:
AudioEncoder,PacketProcessor
PacketProcessor that encodes raw audio samples (PlanarAudioPacket or AudioPacket) into compressed packets via AudioEncoder.
Drop this into a PacketStream between a source that emits raw audio (e.g. MediaCapture) and a sink that expects encoded data (e.g. WebRtcTrackSender or MultiplexPacketEncoder).
Example:
auto encoder = std::make_sharedav::AudioPacketEncoder(); encoder->oparams = av::AudioCodec("opus", "libopus", 2, 48000);
PacketStream stream; stream.attachSource(capture); stream.attach(encoder, 1, true); stream.attach(&webrtcSender, 5, false); stream.start();
List of all members
| Name | Kind | Owner |
|---|---|---|
PacketStream | friend | Declared here |
AudioPacketEncoder | function | Declared here |
~AudioPacketEncoder | function | Declared here |
AudioPacketEncoder | function | Declared here |
operator= | function | Declared here |
process | function | Declared here |
accepts | function | Declared here |
_initialized | variable | Declared here |
_mutex | variable | Declared here |
onStreamStateChange | function | Declared here |
fifo | variable | Inherited from AudioEncoder |
format | variable | Inherited from AudioEncoder |
nextOutputPts | variable | Inherited from AudioEncoder |
AudioEncoder | function | Inherited from AudioEncoder |
~AudioEncoder | function | Inherited from AudioEncoder |
create | function | Inherited from AudioEncoder |
close | function | Inherited from AudioEncoder |
encode | function | Inherited from AudioEncoder |
encode | function | Inherited from AudioEncoder |
encode | function | Inherited from AudioEncoder |
flush | function | Inherited from AudioEncoder |
emitter | variable | Inherited from AudioContext |
iparams | variable | Inherited from AudioContext |
oparams | variable | Inherited from AudioContext |
stream | variable | Inherited from AudioContext |
ctx | variable | Inherited from AudioContext |
codec | variable | Inherited from AudioContext |
frame | variable | Inherited from AudioContext |
resampler | variable | Inherited from AudioContext |
outputFrameSize | variable | Inherited from AudioContext |
time | variable | Inherited from AudioContext |
pts | variable | Inherited from AudioContext |
seconds | variable | Inherited from AudioContext |
error | variable | Inherited from AudioContext |
AudioContext | function | Inherited from AudioContext |
~AudioContext | function | Inherited from AudioContext |
AudioContext | function | Inherited from AudioContext |
operator= | function | Inherited from AudioContext |
AudioContext | function | Inherited from AudioContext |
operator= | function | Inherited from AudioContext |
create | function | Inherited from AudioContext |
open | function | Inherited from AudioContext |
close | function | Inherited from AudioContext |
decode | function | Inherited from AudioContext |
encode | function | Inherited from AudioContext |
encode | function | Inherited from AudioContext |
encode | function | Inherited from AudioContext |
flush | function | Inherited from AudioContext |
recreateResampler | function | Inherited from AudioContext |
PacketProcessor | function | Inherited from PacketProcessor |
process | function | Inherited from PacketProcessor |
accepts | function | Inherited from PacketProcessor |
operator<< | function | Inherited from PacketProcessor |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
~PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
getEmitter | function | Inherited from PacketStreamAdapter |
retention | function | Inherited from PacketStreamAdapter |
onStreamStateChange | function | Inherited from PacketStreamAdapter |
_emitter | variable | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
Inherited from AudioEncoder
| Kind | Name | Description |
|---|---|---|
variable | fifo | |
variable | format | |
variable | nextOutputPts | Running PTS counter for encoder output, in encoder time_base units. Anchored to the first input packet's PTS, then advanced by frame->nb_samples per encoded frame. AV_NOPTS_VALUE before anchoring. |
function | AudioEncoder | Construct an encoder, optionally tied to an existing muxer context. |
function | ~AudioEncoder noexcept override | |
function | create virtual override | Initialise the AVCodecContext using oparams. Adds an audio stream to format if one was provided at construction. |
function | close virtual override | Close and free the AVCodecContext, FIFO buffer, and associated resources. |
function | encode virtual override | Encode interleaved audio samples. |
function | encode virtual override | Encode planar audio samples. |
function | encode virtual override | Encode a single AVFrame (typically from a decoder or resampler). |
function | flush virtual override | Flush remaining packets to be encoded. This method should be called once before stream closure. |
Inherited from AudioContext
| Kind | Name | Description |
|---|---|---|
variable | emitter | |
variable | iparams | input parameters |
variable | oparams | output parameters |
variable | stream | encoder or decoder stream |
variable | ctx | encoder or decoder context |
variable | codec | encoder or decoder codec |
variable | frame | last encoded or decoded frame |
variable | resampler | audio resampler |
variable | outputFrameSize | encoder or decoder output frame size |
variable | time | stream time in codec time base |
variable | pts | last packet pts value |
variable | seconds | audio time in seconds |
variable | error | error message |
function | AudioContext | |
function | ~AudioContext virtual noexcept | |
function | AudioContext | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | AudioContext | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | create virtual | Initialise the AVCodecContext with codec-specific defaults. Implemented by AudioEncoder and AudioDecoder. |
function | 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. |
function | close virtual | Close the codec context, free the frame, and reset timestamps. |
function | decode virtual | Decode a compressed audio packet and emit the resulting samples. |
function | encode virtual | Encode a buffer of interleaved audio samples. |
function | encode virtual | Encode a buffer of planar audio samples. |
function | encode virtual | Encode a single AVFrame. |
function | flush virtual | Flush any frames buffered inside the codec and emit remaining output. |
function | recreateResampler virtual | Recreate the AudioResampler using the current iparams and oparams. Called automatically by open() when format conversion is required. |
Inherited from PacketProcessor
| Kind | Name | Description |
|---|---|---|
function | PacketProcessor inline | |
function | process virtual | This method performs processing on the given packet and emits the result. |
function | accepts virtual inline | This method ensures compatibility with the given packet type. Return false to reject the packet. |
function | operator<< virtual inline | Stream operator alias for process() |
Inherited from PacketStreamAdapter
| Kind | Name | Description |
|---|---|---|
function | PacketStreamAdapter | Construct the adapter, binding it to the given packet signal. |
function | ~PacketStreamAdapter virtual inline | |
function | emit virtual | Emit a mutable raw buffer as a packet. |
function | emit virtual | Emit a read-only raw buffer as a packet (data is copied internally). |
function | emit virtual | Emit a string as a packet (data is copied internally). |
function | emit virtual | Emit a flag-only packet carrying no payload data. |
function | emit virtual | Emit an existing packet directly onto the outgoing signal. |
function | getEmitter | Returns a reference to the outgoing packet signal. |
function | retention virtual const | Returns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph. |
function | onStreamStateChange virtual inline | Called by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios. |
variable | _emitter | |
function | PacketStreamAdapter | NonCopyable and NonMovable. |
function | operator= | Deleted assignment operator. |
function | PacketStreamAdapter | Deleted constructor. |
function | operator= | Deleted assignment operator. |
Friends
| Name | Description |
|---|---|
PacketStream |
PacketStream
friend class PacketStreamDefined in src/av/include/icy/av/audiopacketencoder.h:64
Public Methods
| Return | Name | Description |
|---|---|---|
AudioPacketEncoder | ||
AudioPacketEncoder | Deleted constructor. | |
void | process virtual override | Process an AudioPacket or PlanarAudioPacket from the stream. Encodes the samples and emits the resulting compressed packet. |
bool | accepts virtual override | Accept AudioPacket and PlanarAudioPacket types. |
AudioPacketEncoder
AudioPacketEncoder(AVFormatContext * format = nullptr)Defined in src/av/include/icy/av/audiopacketencoder.h:48
AudioPacketEncoder
AudioPacketEncoder(const AudioPacketEncoder &) = deleteDefined in src/av/include/icy/av/audiopacketencoder.h:51
Deleted constructor.
process
virtual override
virtual void process(IPacket & packet) overrideDefined in src/av/include/icy/av/audiopacketencoder.h:56
Process an AudioPacket or PlanarAudioPacket from the stream. Encodes the samples and emits the resulting compressed packet.
Reimplements
accepts
virtual override
virtual bool accepts(IPacket * packet) overrideDefined in src/av/include/icy/av/audiopacketencoder.h:59
Accept AudioPacket and PlanarAudioPacket types.
Reimplements
Protected Attributes
| Return | Name | Description |
|---|---|---|
bool | _initialized | |
std::mutex | _mutex |
_initialized
bool _initialized = falseDefined in src/av/include/icy/av/audiopacketencoder.h:66
_mutex
std::mutex _mutexDefined in src/av/include/icy/av/audiopacketencoder.h:67
Protected Methods
| Return | Name | Description |
|---|---|---|
void | onStreamStateChange virtual override | Called by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios. |
onStreamStateChange
virtual override
virtual void onStreamStateChange(const PacketStreamState &) overrideDefined in src/av/include/icy/av/audiopacketencoder.h:62
Called by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.
