arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | List of all members
IAudioSource Class Referenceabstract

Audio Source Interface - Contract for Audio Data Providers. More...

#include <IAudioSource.h>

Inheritance diagram for IAudioSource:
RTSPAudioSource

Public Member Functions

virtual RTSPFormatgetFormat ()=0
 Get the audio format configuration.
 
virtual int readBytes (void *dest, int maxSamples)=0
 Read audio data into provided buffer.
 
virtual void start ()
 Initialize audio source for streaming.
 
virtual void stop ()
 Cleanup audio source after streaming.
 

Detailed Description

Audio Source Interface - Contract for Audio Data Providers.

Version
0.1.1

Member Function Documentation

◆ getFormat()

virtual RTSPFormat & getFormat ( )
pure virtual

Get the audio format configuration.

Returns the RTSPFormat object that describes the audio data characteristics including sample rate, bit depth, number of channels, and RTP packaging parameters. If no format has been explicitly set, creates a default 16-bit PCM format at 16kHz mono.

Returns
Pointer to RTSPFormat describing the audio characteristics
Note
Default format: 16-bit PCM, 16000 Hz, 1 channel
See also
setFormat(), RTSPFormatPCM

Implemented in RTSPAudioSource.

◆ readBytes()

virtual int readBytes ( void *  dest,
int  maxSamples 
)
pure virtual

Read audio data into provided buffer.

This is the core method that provides audio data to the streaming system. Implementation should fill the destination buffer with audio samples in the format specified by getFormat(). The method should be non-blocking and return available data immediately.

Parameters
destPointer to buffer where audio data should be written
maxBytesMaximum number of bytes that can be written to dest buffer
Returns
Actual number of bytes written to the buffer (0 if no data available)
Note
Data format must match the RTSPFormat returned by getFormat()
Should return 0 when no audio data is available (not block)
Called periodically by the streaming system at the rate specified by format

Implemented in RTSPAudioSource.

◆ start()

virtual void start ( )
inlinevirtual

Initialize audio source for streaming.

Called when streaming is about to begin. Implementations should use this to initialize hardware, allocate buffers, start audio capture, or perform any other setup required for audio data generation.

Note
Called by RTSPAudioStreamer.start()
Default implementation does nothing (suitable for sources that need no setup)

Reimplemented in RTSPAudioSource.

◆ stop()

virtual void stop ( )
inlinevirtual

Cleanup audio source after streaming.

Called when streaming has ended. Implementations should use this to release hardware resources, deallocate buffers, stop audio capture, or perform cleanup operations.

Note
Called by RTSPAudioStreamer.stop()
Default implementation does nothing (suitable for sources that need no cleanup)

Reimplemented in RTSPAudioSource.


The documentation for this class was generated from the following file: