Home
AV module

AudioCapture

Cross-platform audio capture device backed by FFmpeg input devices.

AudioCapture

#include <icy/av/audiocapture.h>
class AudioCapture

Defined in src/av/include/icy/av/audiocapture.h:26

Inherits: MediaCapture

Cross-platform audio capture device backed by FFmpeg input devices.

List of all members

NameKindOwner
AudioCapturefunctionDeclared here
AudioCapturefunctionDeclared here
AudioCapturefunctionDeclared here
~AudioCapturefunctionDeclared here
openAudiofunctionDeclared here
openAudiofunctionDeclared here
PtrtypedefDeclared here
ClosingvariableInherited from MediaCapture
MediaCapturefunctionInherited from MediaCapture
~MediaCapturefunctionInherited from MediaCapture
MediaCapturefunctionInherited from MediaCapture
operator=functionInherited from MediaCapture
MediaCapturefunctionInherited from MediaCapture
operator=functionInherited from MediaCapture
openFilefunctionInherited from MediaCapture
closefunctionInherited from MediaCapture
startfunctionInherited from MediaCapture
stopfunctionInherited from MediaCapture
runfunctionInherited from MediaCapture
getEncoderFormatfunctionInherited from MediaCapture
getEncoderAudioCodecfunctionInherited from MediaCapture
getEncoderVideoCodecfunctionInherited from MediaCapture
setLoopInputfunctionInherited from MediaCapture
setLimitFrameratefunctionInherited from MediaCapture
setRealtimePTSfunctionInherited from MediaCapture
setOpenOptionsfunctionInherited from MediaCapture
setPassthroughVideofunctionInherited from MediaCapture
formatCtxfunctionInherited from MediaCapture
videofunctionInherited from MediaCapture
audiofunctionInherited from MediaCapture
stoppingfunctionInherited from MediaCapture
errorfunctionInherited from MediaCapture
_mutexvariableInherited from MediaCapture
_threadvariableInherited from MediaCapture
_formatCtxvariableInherited from MediaCapture
_videovariableInherited from MediaCapture
_audiovariableInherited from MediaCapture
_errorvariableInherited from MediaCapture
_stoppingvariableInherited from MediaCapture
_loopingvariableInherited from MediaCapture
_realtimevariableInherited from MediaCapture
_ratelimitvariableInherited from MediaCapture
_passthroughVideovariableInherited from MediaCapture
_openOptionsvariableInherited from MediaCapture
_videoStreamvariableInherited from MediaCapture
openStreamfunctionInherited from MediaCapture
emitfunctionInherited from MediaCapture
PtrtypedefInherited from MediaCapture
emittervariableInherited from ICapture
ICapturefunctionInherited from ICapture
~ICapturefunctionInherited from ICapture
startfunctionInherited from ICapture
stopfunctionInherited from ICapture
openFilefunctionInherited from ICapture
closefunctionInherited from ICapture
getEncoderFormatfunctionInherited from ICapture
getEncoderAudioCodecfunctionInherited from ICapture
getEncoderVideoCodecfunctionInherited from ICapture
openAudiofunctionInherited from ICapture
openVideofunctionInherited from ICapture
onStreamStateChangefunctionInherited from ICapture
openStreamfunctionInherited from ICapture
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
~PacketStreamAdapterfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
getEmitterfunctionInherited from PacketStreamAdapter
retentionfunctionInherited from PacketStreamAdapter
onStreamStateChangefunctionInherited from PacketStreamAdapter
_emittervariableInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
startfunctionInherited from Startable
stopfunctionInherited from Startable
RunnablefunctionInherited from Runnable
~RunnablefunctionInherited from Runnable
runfunctionInherited from Runnable
cancelfunctionInherited from Runnable
cancelledfunctionInherited from Runnable
exitvariableInherited from Runnable

Inherited from MediaCapture

KindNameDescription
variableClosingSignals that the capture thread is closing. This signal is emitted from the capture thread context.
functionMediaCapture
function~MediaCapture noexcept override
functionMediaCaptureDeleted constructor.
functionoperator=Deleted assignment operator.
functionMediaCaptureDeleted constructor.
functionoperator=Deleted assignment operator.
functionopenFile virtual overrideOpen a media file for decoding. Automatically detects video and audio streams.
functionclose virtual overrideStop the capture thread and close the media stream and all decoders.
functionstart virtual overrideStart the background capture and decode thread. Throws std::runtime_error if no media streams have been opened.
functionstop virtual overrideSignal the capture thread to stop and join it before returning.
functionrun virtual overrideEntry point for the background capture thread. Reads and decodes packets from the format context until EOF or stop() is called.
functiongetEncoderFormat virtual overrideFill format with the combined encoder-ready video and audio codec parameters.
functiongetEncoderAudioCodec virtual overrideFill params with the decoder's output audio codec parameters. Throws std::runtime_error if audio parameters have not been initialised.
functiongetEncoderVideoCodec virtual overrideFill params with the decoder's output video codec parameters. Throws std::runtime_error if video parameters have not been initialised.
functionsetLoopInputContinuously loop the input file when set.
functionsetLimitFramerateLimit playback to video FPS.
functionsetRealtimePTSSet to use realtime PTS calculation. This is preferred when using live captures as FFmpeg-provided values are not always reliable.
functionsetOpenOptionsSet demuxer options applied at the next openFile() call. Keys map to libavformat AVOption entries (e.g. "rtsp_transport", "fflags", "analyzeduration", "probesize"). Useful for live network sources that need low-latency hints. Pass an empty map to clear.
functionsetPassthroughVideoSkip the video decoder. Encoded video AVPackets from the input stream are emitted directly as [av::VideoPacket](icy-av-VideoPacket.html#videopacket) without decoding. The emitted packets carry the source's encoded payload and a time in microseconds rescaled from the stream's timebase. The iframe flag is set from AV_PKT_FLAG_KEY.
functionformatCtx const
functionvideo const
functionaudio const
functionstopping const
functionerror const
variable_mutex
variable_thread
variable_formatCtx
variable_video
variable_audio
variable_error
variable_stopping
variable_looping
variable_realtime
variable_ratelimit
variable_passthroughVideo
variable_openOptions
variable_videoStream
functionopenStream virtual overrideOpen the underlying media stream.
functionemit virtual overrideEmit an existing packet directly onto the outgoing signal.
typedefPtr

Inherited from ICapture

KindNameDescription
variableemitter
functionICapture inline
function~ICapture virtualDefaulted destructor.
functionstart virtual overrideStart capturing and emitting packets.
functionstop virtual overrideStop capturing and release device resources.
functionopenFile virtual inlineOpen a media file as the capture source.
functionclose virtual inlineRelease the capture source and any associated resources.
functiongetEncoderFormat virtualPopulate iformat with the encoder-ready format derived from this capture source.
functiongetEncoderAudioCodec virtual inlinePopulate params with the encoder-ready audio codec parameters.
functiongetEncoderVideoCodec virtual inlinePopulate params with the encoder-ready video codec parameters.
functionopenAudio virtual inlineOpen an audio capture device with the given parameters.
functionopenVideo virtual inlineOpen a video capture device with the given parameters.
functiononStreamStateChange virtual inline overrideReact to PacketStream state transitions by starting or stopping capture.
functionopenStream virtual inline

Inherited from PacketStreamAdapter

KindNameDescription
functionPacketStreamAdapterConstruct the adapter, binding it to the given packet signal.
function~PacketStreamAdapter virtual inline
functionemit virtualEmit a mutable raw buffer as a packet.
functionemit virtualEmit a read-only raw buffer as a packet (data is copied internally).
functionemit virtualEmit a string as a packet (data is copied internally).
functionemit virtualEmit a flag-only packet carrying no payload data.
functionemit virtualEmit an existing packet directly onto the outgoing signal.
functiongetEmitterReturns a reference to the outgoing packet signal.
functionretention virtual constReturns 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.
functiononStreamStateChange virtual inlineCalled 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
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

Inherited from Startable

KindNameDescription
functionstart virtualStarts the object (e.g. begins processing or listening).
functionstop virtualStops the object (e.g. halts processing or closes resources).

Inherited from Runnable

KindNameDescription
functionRunnable inline
function~Runnable virtualDefaulted destructor.
functionrun virtualThe run method will be called by the asynchronous context.
functioncancel virtual inlineCancel the current task. The run() method should return ASAP.
functioncancelled virtual const inlineReturns true when the task has been cancelled.
variableexit

Public Methods

ReturnNameDescription
AudioCaptureConstruct without opening a device. Call openAudio() before start().
AudioCaptureConstruct and immediately open the given audio device using an AudioCodec params struct.
AudioCaptureConstruct and immediately open the given audio device with individual parameters.
voidopenAudio virtual overrideOpen the given audio device using an AudioCodec params struct.
voidopenAudio virtualOpen the given audio device with individual parameters. Configures the FFmpeg input format and passes device options via AVDictionary. If the device cannot satisfy the requested parameters, resampling will be applied.

AudioCapture

AudioCapture()

Defined in src/av/include/icy/av/audiocapture.h:32

Construct without opening a device. Call openAudio() before start().


AudioCapture

AudioCapture(const std::string & device, const av::AudioCodec & params)

Defined in src/av/include/icy/av/audiocapture.h:37

Construct and immediately open the given audio device using an AudioCodec params struct.

Parameters

  • device The platform audio device identifier.

  • params The desired capture parameters (channels, sample rate, format).


AudioCapture

AudioCapture(const std::string & device, int channels = -1, int sampleRate = -1, const std::string & sampleFmt = "")

Defined in src/av/include/icy/av/audiocapture.h:44

Construct and immediately open the given audio device with individual parameters.

Parameters

  • device The platform audio device identifier.

  • channels The desired number of channels, or -1 for device default.

  • sampleRate The desired sample rate in Hz, or -1 for device default.

  • sampleFmt The desired sample format string, or "" for device default.


openAudio

virtual override

virtual void openAudio(const std::string & device, const av::AudioCodec & params) override

Defined in src/av/include/icy/av/audiocapture.h:51

Open the given audio device using an AudioCodec params struct.

Parameters

  • device The platform audio device identifier.

  • params The desired capture parameters.

Reimplements

openAudio

virtual

virtual void openAudio(const std::string & device, int channels = -1, int sampleRate = -1, const std::string & sampleFmt = "")

Defined in src/av/include/icy/av/audiocapture.h:60

Open the given audio device with individual parameters. Configures the FFmpeg input format and passes device options via AVDictionary. If the device cannot satisfy the requested parameters, resampling will be applied.

Parameters

  • device The platform audio device identifier.

  • channels The desired number of channels, or -1 for device default.

  • sampleRate The desired sample rate in Hz, or -1 for device default.

  • sampleFmt The desired sample format string, or "" for device default.

Public Types

NameDescription
Ptr

Ptr

using Ptr = std::shared_ptr< AudioCapture >

Defined in src/av/include/icy/av/audiocapture.h:29