AV module
Namespaces
| Name | Description |
|---|---|
v4l2 | Linux V4L2 device enumeration helpers. |
coreaudio | Apple CoreAudio device enumeration helpers. |
legacy | Legacy timing helpers kept for compatibility with older media pipelines. |
avfoundation | Apple AVFoundation device enumeration helpers. |
mediafoundation | Windows Media Foundation device enumeration helpers. |
wasapi | Windows WASAPI device enumeration helpers. |
Classes
| Name | Description |
|---|---|
LinuxDeviceWatcher | Monitors device add/remove events via libudev. |
ICapture | Abstract interface for audio and video capture devices. |
IEncoder | This is the abstract class for all encoders. |
AppleDeviceWatcher | Monitors device add/remove events via AVFoundation notifications and CoreAudio property listeners. |
FPSCounter | FPS counter based on the simple moving average (SMA) algorithm. |
FPSLimiter | PacketStream processor that caps packet throughput to a maximum FPS. |
AudioCapture | Cross-platform audio capture device backed by FFmpeg input devices. |
MediaCapture | Unified capture and decode source for files and live media devices. |
VideoCapture | Cross-platform video device capturer backed by FFmpeg avdevice. |
DeviceWatcher | Base class for platform-specific device change monitors. |
DeviceManager | Enumerates and manages system audio and video devices. |
FormatRegistry | Singleton registry of available media container formats for encoding and decoding. |
WindowsDeviceWatcher | Monitors device add/remove events via IMMNotificationClient (audio) and RegisterDeviceNotification (video). |
MultiplexEncoder | Multiplexing encoder that writes synchronized audio and video streams. |
AudioPacketEncoder | PacketProcessor that encodes raw audio samples (PlanarAudioPacket or AudioPacket) into compressed packets via AudioEncoder. |
VideoPacketEncoder | PacketProcessor that encodes raw video frames (PlanarVideoPacket or VideoPacket) into compressed packets via VideoEncoder. |
RealtimePacketQueue | Queue that emits media packets in presentation-timestamp order relative to a realtime clock. |
MultiplexPacketEncoder | Encodes and multiplexes a realtime video stream form audio / video capture sources. FFmpeg is used for encoding. |
Codec | Codec for encoding/decoding media. |
AudioCodec | Audio codec parameters including channels, sample rate, and sample format. |
VideoCodec | Video codec parameters including resolution, frame rate, and pixel format. |
Deleter | RAII helpers for owning FFmpeg allocation types. |
Deleterp | Deleter adaptor for functions like av_freep that take a pointer to a pointer. |
Format | Defines a media container format which is available through the FormatRegistry for encoding or decoding. |
EncoderState | State machine states for the encoder pipeline. |
EncoderOptions | Configuration options for audio and video encoders. |
AudioBuffer | FIFO buffer for queuing audio samples between encoding stages. |
AudioContext | Base context for audio encoding and decoding via FFmpeg. |
AudioDecoder | Decodes compressed audio packets into raw sample frames. |
AudioEncoder | Encodes raw audio samples into a compressed format. |
VideoContext | Base video context from which all video encoders and decoders derive. |
VideoDecoder | Decodes compressed video packets into raw frames. |
VideoEncoder | Encodes raw video frames into a compressed format. |
Device | Represents a system audio, video or render device. |
AudioResampler | Converts audio samples between different formats, sample rates, and channel layouts. |
VideoConverter | Converts video frames between pixel formats and resolutions. |
MediaPacket | Timestamped media packet carrying raw audio or video data. |
VideoPacket | Video packet for interleaved formats. |
PlanarVideoPacket | Video packet for planar formats. |
AudioPacket | Audio packet for interleaved formats. |
PlanarAudioPacket | Audio packet for planar formats. |
Macros
| Name | Description |
|---|---|
MAX_VIDEO_PACKET_SIZE | |
MAX_AUDIO_PACKET_SIZE | 1 second of 48khz 32bit audio |
MAX_ENCODE_DURATION | 3 hours |
INT64_C | |
UINT64_C | |
AV_API | |
DEFAULT_AUDIO_SAMPLE_RATE | |
DEFAULT_AUDIO_BIT_RATE | |
DEFAULT_AUDIO_CHANNELS | |
DEFAULT_AUDIO_SAMPLE_FMT | |
DEFAULT_VIDEO_SAMPLE_RATE | |
DEFAULT_VIDEO_BIT_RATE | |
DEFAULT_VIDEO_PIXEL_FMT |
MAX_VIDEO_PACKET_SIZE
#define MAX_VIDEO_PACKET_SIZE (3 * 1024 * 1024)Defined in src/av/include/icy/av/av.h:20
MAX_AUDIO_PACKET_SIZE
#define MAX_AUDIO_PACKET_SIZE (128 * 1500)Defined in src/av/include/icy/av/av.h:21
1 second of 48khz 32bit audio
MAX_ENCODE_DURATION
#define MAX_ENCODE_DURATION (3 * 60 * 60 * 1000)Defined in src/av/include/icy/av/av.h:22
3 hours
INT64_C
#define INT64_C(c) (c##LL)Defined in src/av/include/icy/av/av.h:32
UINT64_C
#define UINT64_C(c) (c##ULL)Defined in src/av/include/icy/av/av.h:35
AV_API
#define AV_API ICY_IMPORTDefined in src/av/include/icy/av/av.h:43
DEFAULT_AUDIO_SAMPLE_RATE
#define DEFAULT_AUDIO_SAMPLE_RATE 44100Defined in src/av/include/icy/av/codec.h:95
DEFAULT_AUDIO_BIT_RATE
#define DEFAULT_AUDIO_BIT_RATE 64000Defined in src/av/include/icy/av/codec.h:96
DEFAULT_AUDIO_CHANNELS
#define DEFAULT_AUDIO_CHANNELS 2Defined in src/av/include/icy/av/codec.h:97
DEFAULT_AUDIO_SAMPLE_FMT
#define DEFAULT_AUDIO_SAMPLE_FMT "s16"Defined in src/av/include/icy/av/codec.h:98
DEFAULT_VIDEO_SAMPLE_RATE
#define DEFAULT_VIDEO_SAMPLE_RATE 384000Defined in src/av/include/icy/av/codec.h:163
DEFAULT_VIDEO_BIT_RATE
#define DEFAULT_VIDEO_BIT_RATE 400000Defined in src/av/include/icy/av/codec.h:164
DEFAULT_VIDEO_PIXEL_FMT
#define DEFAULT_VIDEO_PIXEL_FMT "yuv420p"Defined in src/av/include/icy/av/codec.h:165
Enumerations
| Name | Description |
|---|---|
MediaCapabilities | Bitmask of media capabilities detected on this system. |
MediaCapabilities
enum MediaCapabilitiesDefined in src/av/include/icy/av/devicemanager.h:177
Bitmask of media capabilities detected on this system.
| Value | Description |
|---|---|
AUDIO_RECV | Audio capture or decode is available. |
AUDIO_SEND | Audio playback or encode is available. |
VIDEO_RECV | Video capture or decode is available. |
VIDEO_SEND | Video render or encode is available. |
Typedefs
| Return | Name | Description |
|---|---|---|
std::list< Codec > | CodecList | List of codec value objects. |
std::list< Codec * > | CodecPList | List of codec pointers. |
std::unique_ptr< AVFrame, Deleterp< AVFrame, void, av_frame_free > > | AVFrameHolder | Owning AVFrame pointer released with av_frame_free(). |
std::unique_ptr< AVFormatContext, Deleter< AVFormatContext, void, avformat_free_context > > | AVFormatContextHolder | Owning AVFormatContext pointer released with avformat_free_context(). |
std::unique_ptr< AVCodecContext, Deleterp< AVCodecContext, void, avcodec_free_context > > | AVCodecContextHolder | Owning AVCodecContext pointer released with avcodec_free_context(). |
std::unique_ptr< AVDictionary *, Deleter< AVDictionary *, void, av_dict_free > > | AVDictionaryCleanup | Cleanup wrapper for AVDictionary* values freed with av_dict_free(). |
std::unique_ptr< AVPacket, Deleterp< AVPacket, void, av_packet_free > > | AVPacketHolder | Owning AVPacket pointer released with av_packet_free(). |
std::vector< Format > | FormatList | List of container format value objects. |
std::vector< Format * > | FormatPList | List of container format pointers. |
IEncoder | IPacketEncoder | Legacy alias for IEncoder kept for 0.8.x compatibility. |
CodecList
using CodecList = std::list< Codec >Type: std::list< Codec >
Defined in src/av/include/icy/av/codec.h:231
List of codec value objects.
CodecPList
using CodecPList = std::list< Codec * >Type: std::list< Codec * >
Defined in src/av/include/icy/av/codec.h:232
List of codec pointers.
AVFrameHolder
using AVFrameHolder = std::unique_ptr< AVFrame, Deleterp< AVFrame, void, av_frame_free > >Type: std::unique_ptr< AVFrame, Deleterp< AVFrame, void, av_frame_free > >
Defined in src/av/include/icy/av/ffmpeg.h:90
Owning AVFrame pointer released with av_frame_free().
AVFormatContextHolder
using AVFormatContextHolder = std::unique_ptr< AVFormatContext, Deleter< AVFormatContext, void, avformat_free_context > >Type: std::unique_ptr< AVFormatContext, Deleter< AVFormatContext, void, avformat_free_context > >
Defined in src/av/include/icy/av/ffmpeg.h:94
Owning AVFormatContext pointer released with avformat_free_context().
AVCodecContextHolder
using AVCodecContextHolder = std::unique_ptr< AVCodecContext, Deleterp< AVCodecContext, void, avcodec_free_context > >Type: std::unique_ptr< AVCodecContext, Deleterp< AVCodecContext, void, avcodec_free_context > >
Defined in src/av/include/icy/av/ffmpeg.h:98
Owning AVCodecContext pointer released with avcodec_free_context().
AVDictionaryCleanup
using AVDictionaryCleanup = std::unique_ptr< AVDictionary *, Deleter< AVDictionary *, void, av_dict_free > >Type: std::unique_ptr< AVDictionary *, Deleter< AVDictionary *, void, av_dict_free > >
Defined in src/av/include/icy/av/ffmpeg.h:102
Cleanup wrapper for AVDictionary* values freed with av_dict_free().
AVPacketHolder
using AVPacketHolder = std::unique_ptr< AVPacket, Deleterp< AVPacket, void, av_packet_free > >Type: std::unique_ptr< AVPacket, Deleterp< AVPacket, void, av_packet_free > >
Defined in src/av/include/icy/av/ffmpeg.h:106
Owning AVPacket pointer released with av_packet_free().
FormatList
using FormatList = std::vector< Format >Type: std::vector< Format >
Defined in src/av/include/icy/av/format.h:113
List of container format value objects.
FormatPList
using FormatPList = std::vector< Format * >Type: std::vector< Format * >
Defined in src/av/include/icy/av/format.h:114
List of container format pointers.
IPacketEncoder
using IPacketEncoder = IEncoderType: IEncoder
Defined in src/av/include/icy/av/iencoder.h:144
Legacy alias for IEncoder kept for 0.8.x compatibility.
Functions
| Return | Name | Description |
|---|---|---|
int64_t | fpsToInterval inline | Convert a frame rate to a nanosecond frame interval. |
int | intervalToFps inline | Convert a nanosecond frame interval to a frame rate. |
float | intervalToFpsFloat inline | Convert a nanosecond frame interval to a floating-point frame rate. |
void | initializeFFmpeg | Initialize the FFmpeg library. |
void | uninitializeFFmpeg | Uninitializes the FFmpeg library. |
std::string | averror | Get an error string for the given error code. |
void | printInputFormats | Print all available FFmpeg demuxer (input) format names to the given stream. |
void | printOutputFormats | Print all available FFmpeg muxer (output) format names to the given stream. |
void | printEncoders | Print all available FFmpeg encoder names to the given stream. |
AVPacketHolder | makeOwnedPacket | Allocate an owning AVPacket with FFmpeg-required padding and timestamp metadata. The packet payload is copied into FFmpeg-managed storage, which is required by decoders such as H.264 that may overread AV_INPUT_BUFFER_PADDING_SIZE bytes. |
void | initAudioCodecFromContext | Populate an AudioCodec from an open AVCodecContext. |
AVSampleFormat | selectSampleFormat | Select the best supported sample format for a codec given the requested parameters. Returns the requested format if supported, otherwise the first format with the same planarity. |
bool | isSampleFormatSupported | Check whether a specific sample format is in the codec's supported list. |
bool | formatIsPlanar | Return true if the named sample format is planar (e.g. "fltp", "s16p"). |
bool | formatIsPlanar | Return true if the given AVSampleFormat is planar. |
AVFrame * | createVideoFrame | Allocate a new AVFrame with the given pixel format and dimensions. Uses av_frame_get_buffer for reference-counted allocation with 16-byte alignment. |
AVFrame * | cloneVideoFrame | Perform a deep copy of an AVFrame including its buffer data and properties. |
void | initVideoCodecFromContext | Populate a VideoCodec from an open AVStream and AVCodecContext. |
AVPixelFormat | selectPixelFormat | Select the best supported pixel format for a codec given the requested parameters. Returns the requested format if supported, otherwise the first format with the same plane count. |
std::optional< std::pair< const AVInputFormat *, std::string > > | parseDeviceUrl | Parse a libavdevice URL scheme. |
fpsToInterval
inline
inline int64_t fpsToInterval(int fps)Defined in src/av/include/icy/av/codec.h:241
Convert a frame rate to a nanosecond frame interval.
Returns
The interval in nanoseconds between frames, or the minimum interval if fps is zero.
Parameters
| Parameter | Type | Description |
|---|---|---|
fps | int | The frame rate in frames per second. |
intervalToFps
inline
inline int intervalToFps(int64_t interval)Defined in src/av/include/icy/av/codec.h:251
Convert a nanosecond frame interval to a frame rate.
Returns
The frame rate in frames per second, or zero if interval is zero.
Parameters
| Parameter | Type | Description |
|---|---|---|
interval | int64_t | The nanosecond interval between frames. |
intervalToFpsFloat
inline
inline float intervalToFpsFloat(int64_t interval)Defined in src/av/include/icy/av/codec.h:263
Convert a nanosecond frame interval to a floating-point frame rate.
Returns
The frame rate in frames per second as a float, or 0.0f if interval is zero.
Parameters
| Parameter | Type | Description |
|---|---|---|
interval | int64_t | The nanosecond interval between frames. |
initializeFFmpeg
void initializeFFmpeg()Defined in src/av/include/icy/av/ffmpeg.h:39
Initialize the FFmpeg library.
uninitializeFFmpeg
void uninitializeFFmpeg()Defined in src/av/include/icy/av/ffmpeg.h:42
Uninitializes the FFmpeg library.
averror
std::string averror(const int error)Defined in src/av/include/icy/av/ffmpeg.h:45
Get an error string for the given error code.
printInputFormats
void printInputFormats(std::ostream & ost, const char * delim = " ")Defined in src/av/include/icy/av/ffmpeg.h:50
Print all available FFmpeg demuxer (input) format names to the given stream.
Parameters
| Parameter | Type | Description |
|---|---|---|
ost | std::ostream & | The output stream to write to. |
delim | const char * | Delimiter inserted between each name. |
printOutputFormats
void printOutputFormats(std::ostream & ost, const char * delim = " ")Defined in src/av/include/icy/av/ffmpeg.h:55
Print all available FFmpeg muxer (output) format names to the given stream.
Parameters
| Parameter | Type | Description |
|---|---|---|
ost | std::ostream & | The output stream to write to. |
delim | const char * | Delimiter inserted between each name. |
printEncoders
void printEncoders(std::ostream & ost, const char * delim = " ")Defined in src/av/include/icy/av/ffmpeg.h:60
Print all available FFmpeg encoder names to the given stream.
Parameters
| Parameter | Type | Description |
|---|---|---|
ost | std::ostream & | The output stream to write to. |
delim | const char * | Delimiter inserted between each name. |
makeOwnedPacket
AVPacketHolder makeOwnedPacket(const MediaPacket & packet, int streamIndex, AVRational timeBase)Defined in src/av/include/icy/av/ffmpeg.h:113
Allocate an owning AVPacket with FFmpeg-required padding and timestamp metadata. The packet payload is copied into FFmpeg-managed storage, which is required by decoders such as H.264 that may overread AV_INPUT_BUFFER_PADDING_SIZE bytes.
initAudioCodecFromContext
void initAudioCodecFromContext(const AVCodecContext * ctx, AudioCodec & params)Defined in src/av/include/icy/av/audiocontext.h:112
Populate an AudioCodec from an open AVCodecContext.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | const AVCodecContext * | The FFmpeg codec context to read from. |
params | AudioCodec & | The AudioCodec struct to fill with codec, channel, sample rate, and format info. |
selectSampleFormat
AVSampleFormat selectSampleFormat(const AVCodec * codec, av::AudioCodec & params)Defined in src/av/include/icy/av/audiocontext.h:119
Select the best supported sample format for a codec given the requested parameters. Returns the requested format if supported, otherwise the first format with the same planarity.
Returns
The chosen AVSampleFormat, or AV_SAMPLE_FMT_NONE if none is compatible.
Parameters
| Parameter | Type | Description |
|---|---|---|
codec | const AVCodec * | The FFmpeg codec whose supported formats are queried. |
params | av::AudioCodec & | The audio codec parameters specifying the desired sample format. |
isSampleFormatSupported
bool isSampleFormatSupported(const AVCodec * codec, enum AVSampleFormat sampleFormat)Defined in src/av/include/icy/av/audiocontext.h:125
Check whether a specific sample format is in the codec's supported list.
Returns
True if the format is supported.
Parameters
| Parameter | Type | Description |
|---|---|---|
codec | const AVCodec * | The FFmpeg codec to query. |
sampleFormat | enum AVSampleFormat | The AVSampleFormat to look up. |
formatIsPlanar
bool formatIsPlanar(const std::string & pixfmt)Defined in src/av/include/icy/av/audiocontext.h:129
Return true if the named sample format is planar (e.g. "fltp", "s16p").
Parameters
| Parameter | Type | Description |
|---|---|---|
pixfmt | const std::string & | The sample format name string. |
formatIsPlanar
bool formatIsPlanar(AVSampleFormat format)Defined in src/av/include/icy/av/audiocontext.h:133
Return true if the given AVSampleFormat is planar.
Parameters
| Parameter | Type | Description |
|---|---|---|
format | AVSampleFormat | The AVSampleFormat to check. |
createVideoFrame
AVFrame * createVideoFrame(AVPixelFormat pixelFmt, int width, int height)Defined in src/av/include/icy/av/videocontext.h:130
Allocate a new AVFrame with the given pixel format and dimensions. Uses av_frame_get_buffer for reference-counted allocation with 16-byte alignment.
Returns
A newly allocated AVFrame, or nullptr on failure.
Parameters
| Parameter | Type | Description |
|---|---|---|
pixelFmt | AVPixelFormat | The pixel format for the frame. |
width | int | The frame width in pixels. |
height | int | The frame height in pixels. |
cloneVideoFrame
AVFrame * cloneVideoFrame(AVFrame * source)Defined in src/av/include/icy/av/videocontext.h:135
Perform a deep copy of an AVFrame including its buffer data and properties.
Returns
A newly allocated AVFrame with copied data. Caller owns the result.
Parameters
| Parameter | Type | Description |
|---|---|---|
source | AVFrame * | The source frame to copy. |
initVideoCodecFromContext
void initVideoCodecFromContext(const AVStream * stream, const AVCodecContext * ctx, VideoCodec & params)Defined in src/av/include/icy/av/videocontext.h:141
Populate a VideoCodec from an open AVStream and AVCodecContext.
Parameters
| Parameter | Type | Description |
|---|---|---|
stream | const AVStream * | The AVStream for frame rate information (may be null). |
ctx | const AVCodecContext * | The FFmpeg codec context to read from. |
params | VideoCodec & | The VideoCodec struct to fill with codec, dimension, and format info. |
selectPixelFormat
AVPixelFormat selectPixelFormat(const AVCodec * codec, VideoCodec & params)Defined in src/av/include/icy/av/videocontext.h:148
Select the best supported pixel format for a codec given the requested parameters. Returns the requested format if supported, otherwise the first format with the same plane count.
Returns
The chosen AVPixelFormat.
Parameters
| Parameter | Type | Description |
|---|---|---|
codec | const AVCodec * | The FFmpeg codec whose supported formats are queried. |
params | VideoCodec & | The video codec parameters specifying the desired pixel format. |
parseDeviceUrl
std::optional< std::pair< const AVInputFormat *, std::string > > parseDeviceUrl(std::string_view source)Defined in src/av/include/icy/av/devicemanager.h:358
Parse a libavdevice URL scheme.
Recognises: avfoundation: (macOS, e.g. "0:0", "0:none") v4l2:
On match returns the libavformat input format (looked up via av_find_input_format) and the portion of source after the scheme prefix. Returns std::nullopt for non-device sources (file paths, rtsp://, rtmp://, etc.), leaving the caller to use FFmpeg's auto-detection.
Throws std::runtime_error if a recognised scheme has no matching input format on this build (libavdevice not linked, or the backend is not compiled in on this platform).
Variables
| Return | Name | Description |
|---|---|---|
constexpr int | kMaxPlanarAudioPlanes static constexpr |
kMaxPlanarAudioPlanes
static constexpr
constexpr int kMaxPlanarAudioPlanes = 8