|
arduino-audio-tools
|
Efficient RTSP client for UDP/RTP audio with decoder pipeline. More...
#include <RTSPClient.h>
Public Member Functions | |
| RTSPClient () | |
| RTSPClient (AudioOutput &out) | |
| Construct with an AudioOutput as decoding sink. | |
| RTSPClient (AudioStream &out) | |
| Construct with an AudioStream as decoding sink. | |
| RTSPClient (Print &out) | |
| Construct with a generic Print sink. | |
| void | addDecoder (const char *mimeType, AudioDecoder &decoder) |
| Register a decoder to be auto-selected for the given MIME. | |
| void | addNotifyAudioChange (AudioInfoSupport &bi) override |
| Adds target to be notified about audio changes. | |
| AudioInfo | audioInfo () override |
| Audio info parsed from SDP for raw PCM encodings. | |
| virtual AudioInfo | audioInfoOut () |
| int | available () |
| Returns buffered RTP payload bytes available for copy(). | |
| bool | begin (IPAddress addr, uint16_t port, const char *path=nullptr) |
| Start RTSP session and UDP RTP reception. | |
| void | clearNotifyAudioChange () override |
| Deletes all change notify subscriptions. | |
| size_t | copy () |
| Copy the next buffered RTP payload into the decoder pipeline. Performs initial decoder selection based on SDP MIME. | |
| void | end () |
| Stop streaming and close RTSP/UDP sockets. | |
| bool | isNotifyActive () |
| const char * | mime () const |
| Best-effort MIME derived from SDP (e.g. audio/L16, audio/aac). | |
| operator bool () | |
| uint8_t | payloadType () const |
| RTP payload type from SDP (0xFF if unknown). | |
| bool | removeNotifyAudioChange (AudioInfoSupport &bi) override |
| Removes a target in order not to be notified about audio changes. | |
| bool | setActive (bool active) |
| Pause or resume playback via RTSP PAUSE/PLAY. | |
| void | setAudioInfo (AudioInfo info) override |
| Defines the input AudioInfo. | |
| void | setConnectRetries (uint8_t retries) |
| Set number of TCP connect retries (default 2). | |
| void | setConnectRetryDelayMs (uint32_t ms) |
| Set delay between connect retries in ms (default 500ms). | |
| void | setHeaderTimeoutMs (uint32_t ms) |
| Set timeout (ms) for reading RTSP response headers. Increase if your server responds slowly. Default 3000ms. | |
| void | setIdleDelay (uint32_t ms) |
| Set idle backoff delay (ms) for zero-return cases. Used in available() and copy() to avoid busy loops. | |
| void | setNotifyActive (bool flag) |
| void | setOutput (AudioOutput &out) |
| Define decoding sink as AudioOutput. | |
| void | setOutput (AudioStream &out) |
| Define decoding sink as AudioStream. | |
| void | setOutput (Print &out) |
| Define decoding sink as Print. | |
| void | setPayloadOffset (uint8_t bytes) |
| Set additional RTP payload offset in bytes. Some payloads embed a small header before the actual audio data (e.g., RFC2250 4-byte header for MP3). This offset is added after the RTP header and any CSRC entries. | |
| void | setResampleFactor (float factor) |
| Set resampling factor to stabilize buffers and playback. 1.0 means no resampling. factor > 1.0 speeds up (upsamples), factor < 1.0 slows down (downsamples). Useful to compensate clock drift between sender and receiver to prevent buffer overflows/underflows. Internally mapped to step size as step = 1.0 / factor. | |
Protected Member Functions | |
| void | buildTrackUrlFromBaseAndControl () |
| void | buildUrls (const char *path) |
| size_t | computeRtpPayloadOffset (const uint8_t *data, size_t length) |
| bool | fail (const char *msg) |
| bool | isAbsoluteRtspUrl (const char *url) |
| void | maybeKeepalive () |
| void | notifyAudioChange (AudioInfo info) |
| bool | openUdpPorts () |
| void | parseContentBaseFromHeaders (const char *headers) |
| void | parseControlFromSdp (const char *sdp) |
| void | parseSdp (const char *sdp) |
| void | parseServerPortsFromHeaders (const char *headers) |
| void | parseSessionFromHeaders (const char *headers) |
| void | primeUdpPath () |
| int | readExact (uint8_t *out, int len, uint32_t timeoutMs) |
| bool | readUntilDoubleCRLF (char *buf, size_t buflen, int &used, uint32_t timeoutMs=3000) |
| void | resetState () |
| bool | sendSimpleRequest (const char *method, const char *url, const char *extraHeaders, size_t extraLen, char *outHeaders, size_t outHeadersLen, char *outBody, size_t outBodyLen, bool quiet=false) |
| void | serviceUdp () |
| bool | sniffUdpFor (uint32_t ms) |
| bool | tcpCommit () |
| size_t | tcpWrite (const uint8_t *data, size_t len) |
Static Protected Member Functions | |
| static int | parseContentLength (const char *headers) |
Efficient RTSP client for UDP/RTP audio with decoder pipeline.
Establishes an RTSP session (OPTIONS, DESCRIBE, SETUP/UDP, PLAY), binds a local UDP RTP port and receives RTP audio packets. The payload of each RTP packet is forwarded to an internal MultiDecoder. For raw PCM over RTP (e.g. L16) a DecoderNetworkFormat is used to convert network byte order into host format before writing to the configured output. For compressed formats, register decoders with addDecoder().
Usage:
Template parameters:
|
inline |
|
inline |
Construct with an AudioOutput as decoding sink.
|
inline |
Construct with an AudioStream as decoding sink.
|
inline |
Construct with a generic Print sink.
|
inline |
Register a decoder to be auto-selected for the given MIME.
| mimeType | MIME to match |
| decoder | AudioDecoder instance handling that MIME |
|
inlineoverridevirtual |
Adds target to be notified about audio changes.
Reimplemented from AudioInfoSource.
|
inlineoverridevirtual |
Audio info parsed from SDP for raw PCM encodings.
Implements AudioInfoSupport.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in MP3EncoderShine, PureDataStream, PWMAudioOutput< PWMDriverT >, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inline |
Returns buffered RTP payload bytes available for copy().
|
inline |
Start RTSP session and UDP RTP reception.
| addr | RTSP server IP address |
| port | RTSP server port (typically 554) |
| path | Optional path appended to the RTSP URL (e.g. "stream1"). If provided, the base URL becomes rtsp://<ip>:<port>/<path>/ |
|
inlineprotected |
|
inlineprotected |
|
inlineoverridevirtual |
Deletes all change notify subscriptions.
Reimplemented from AudioInfoSource.
|
inlineprotected |
|
inline |
Copy the next buffered RTP payload into the decoder pipeline. Performs initial decoder selection based on SDP MIME.
|
inline |
Stop streaming and close RTSP/UDP sockets.
|
inlineprotected |
|
inlineprotected |
|
inline |
|
inlineprotected |
|
inline |
Best-effort MIME derived from SDP (e.g. audio/L16, audio/aac).
|
inlineprotectedinherited |
|
inlineprotected |
|
inline |
returns true when streaming is active and a decoder is configured and we have data
|
inlineprotected |
|
inlinestaticprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inline |
RTP payload type from SDP (0xFF if unknown).
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineoverridevirtual |
Removes a target in order not to be notified about audio changes.
Reimplemented from AudioInfoSource.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inline |
Pause or resume playback via RTSP PAUSE/PLAY.
| active | true to PLAY, false to PAUSE |
|
inlineoverridevirtual |
Defines the input AudioInfo.
Implements AudioInfoSupport.
|
inline |
Set number of TCP connect retries (default 2).
|
inline |
Set delay between connect retries in ms (default 500ms).
|
inline |
Set timeout (ms) for reading RTSP response headers. Increase if your server responds slowly. Default 3000ms.
|
inline |
Set idle backoff delay (ms) for zero-return cases. Used in available() and copy() to avoid busy loops.
|
inline |
|
inline |
Define decoding sink as AudioOutput.
|
inline |
Define decoding sink as AudioStream.
|
inline |
Define decoding sink as Print.
|
inline |
Set additional RTP payload offset in bytes. Some payloads embed a small header before the actual audio data (e.g., RFC2250 4-byte header for MP3). This offset is added after the RTP header and any CSRC entries.
|
inline |
Set resampling factor to stabilize buffers and playback. 1.0 means no resampling. factor > 1.0 speeds up (upsamples), factor < 1.0 slows down (downsamples). Useful to compensate clock drift between sender and receiver to prevent buffer overflows/underflows. Internally mapped to step size as step = 1.0 / factor.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |