AudioPacketEncoder
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
| Return | Name | Description |
|---|---|---|
AudioPacketEncoder | ||
AudioPacketEncoder | Deleted constructor. | |
void | process virtual | Process an AudioPacket or PlanarAudioPacket from the stream. Encodes the samples and emits the resulting compressed packet. |
bool | accepts virtual | Accept AudioPacket and PlanarAudioPacket types. |
AudioPacketEncoder
AudioPacketEncoder(AVFormatContext * format)AudioPacketEncoder
AudioPacketEncoder(const AudioPacketEncoder &) = deleteDeleted 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
| Return | Name | Description |
|---|---|---|
bool | _initialized | |
std::mutex | _mutex |
_initialized
bool _initialized = false_mutex
std::mutex _mutexProtected Methods
| Return | Name | Description |
|---|---|---|
void | onStreamStateChange virtual | 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
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.
