Unified RTSP Media Source - Works with both Stream and AudioStream.
More...
#include <RTSPMediaSource.h>
Unified RTSP Media Source - Works with both Stream and AudioStream.
This class can adapt any Arduino Stream or AudioTools AudioStream into an IMediaSource for RTSP streaming. It automatically detects AudioStream capabilities when available and falls back to manual configuration for generic Streams.
- Author
- Phil Schatzmann
- Copyright
- GPLv3
◆ RTSPMediaSource() [1/4]
◆ ~RTSPMediaSource()
Destructor - Clean up resources.
◆ RTSPMediaSource() [2/4]
Construct from AudioStream with automatic audio info detection.
- Parameters
-
| stream | AudioStream that provides audio configuration automatically |
◆ RTSPMediaSource() [3/4]
Construct from generic Stream with manual audio configuration.
- Parameters
-
| stream | Generic Stream to read audio data from |
| info | Audio configuration (sample rate, channels, bit depth) |
◆ RTSPMediaSource() [4/4]
Construct from generic Stream with format object.
- Parameters
-
| stream | Generic Stream to read audio data from |
| format | RTSPFormat configuration object |
◆ getFormat()
Get the media format configuration.
Returns the RTSPFormat object that describes the media 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 media characteristics
- Note
- Default format: 16-bit PCM, 16000 Hz, 1 channel
- See also
- setFormat(), RTSPFormatPCM
Implements IMediaSource.
◆ isActive()
Check if source is actively being read (AudioStream only)
- Returns
- true if recent read activity detected, false otherwise
◆ isStarted()
Returns true after start() has been called.
◆ packetSize()
| virtual int packetSize |
( |
| ) |
|
|
inlinevirtualinherited |
Size of the next queued, ready-to-send fragment, for sources that provide already RTP-payload-ready, self-delimited fragments (e.g. RFC 2435 JPEG) instead of a continuous byte stream. For these sources, readBytes() must always be called with exactly packetSize() as maxBytes, so each call retrieves exactly one complete fragment instead of the transport having to guess where one RTP payload ends and the next begins.
Call it once before each readBytes() to size that call, and again right after to tell whether the fragment just read was the last one currently available - a 0 result means the caller should set the RTP marker bit on the fragment it just sent (and may advance the timestamp for the next frame).
- Returns
- -1 if this source is not packetized (use the plain readBytes() stream instead), 0 if packetized but nothing is queued right now, otherwise the size in bytes of the next fragment
Reimplemented in H264RtpEncoder, JPEGRtpEncoder, and RTSPMediaCallbackSource.
◆ readBytes()
| int readBytes |
( |
void * |
dest, |
|
|
int |
byteCount |
|
) |
| |
|
inlineoverridevirtual |
Read audio data for RTSP streaming.
- Parameters
-
| dest | Buffer to receive audio data |
| byteCount | Number of bytes to read |
- Returns
- Actual number of bytes read
Implements IMediaSource.
◆ setAudioInfo()
Set audio configuration manually.
This is required when using generic Stream objects, but optional for AudioStream objects which can provide their own configuration.
- Parameters
-
| info | Audio configuration (sample rate, channels, bit depth) |
◆ setFormat()
◆ setFragmentSize()
| void setFragmentSize |
( |
int |
fragmentSize | ) |
|
|
inline |
Defines the fragment size.
◆ setInput() [1/3]
Set input from AudioStream (with auto-detection)
- Parameters
-
| stream | AudioStream that can provide its own audio configuration |
◆ setInput() [2/3]
| void setInput |
( |
Stream & |
stream | ) |
|
|
inline |
Set input from generic Stream (audio info must be set separately)
- Parameters
-
◆ setInput() [3/3]
Set input from generic Stream with explicit audio info.
- Parameters
-
| stream | Generic Arduino Stream |
| info | Audio configuration parameters |
◆ setTimeout()
| void setTimeout |
( |
uint16_t |
to | ) |
|
|
inline |
◆ setTimerPeriod()
| void setTimerPeriod |
( |
int |
period | ) |
|
|
inline |
Defines the timer period.
◆ start()
Start the audio source.
For AudioStreams, calls begin() to initialize the stream. For generic Streams, just sets the active flag.
Reimplemented from IMediaSource.
◆ stop()
Stop the audio source.
For AudioStreams, calls end() to cleanup the stream. For generic Streams, just clears the active flag.
Reimplemented from IMediaSource.
◆ default_format
◆ m_magic
◆ MAGIC_NUMBER
| const uint32_t MAGIC_NUMBER |
|
protected |
◆ p_audiostream
◆ p_format
◆ p_stream
◆ started
◆ time_of_last_read
| uint32_t time_of_last_read = 0 |
|
protected |
◆ timeout
The documentation for this class was generated from the following file: