AV module

AudioPacketEncoder

[PacketProcessor]({#ref classicy_1_1PacketProcessor #}) that encodes raw audio samples ([PlanarAudioPacket]({#ref structicy_1_1av_1_1PlanarAudioPacket #}) or [AudioPacket]({#ref structicy_1_1av_1_1AudioPacket #})) into compressed packets via [AudioEncoder]({#ref structicy_1_1av_1_1AudioEncoder #}).

AudioPacketEncoder

#include <icy/av/audiopacketencoder.h>

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();

Public Methods

ReturnNameDescription
AudioPacketEncoder
AudioPacketEncoderDeleted constructor.
voidprocess virtualProcess an AudioPacket or PlanarAudioPacket from the stream. Encodes the samples and emits the resulting compressed packet.
boolaccepts virtualAccept AudioPacket and PlanarAudioPacket types.

AudioPacketEncoder

AudioPacketEncoder(AVFormatContext * format)

AudioPacketEncoder

AudioPacketEncoder(const AudioPacketEncoder &) = delete

Deleted constructor.


process

virtual

virtual void process(IPacket & packet)

Process an AudioPacket or PlanarAudioPacket from the stream. Encodes the samples and emits the resulting compressed packet.


accepts

virtual

virtual bool accepts(IPacket * packet)

Accept AudioPacket and PlanarAudioPacket types.

Protected Attributes

ReturnNameDescription
bool_initialized
std::mutex_mutex

_initialized

bool _initialized = false

_mutex

std::mutex _mutex

Protected Methods

ReturnNameDescription
voidonStreamStateChange virtualCalled 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

virtual void onStreamStateChange(const PacketStreamState &)

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.