|
arduino-audio-tools
|
Callback-based RTSP Media Source. More...
#include <RTSPMediaCallbackSource.h>
Public Types | |
| typedef void(* | lifecycle_callback_t) (void *userData) |
| typedef int(* | packet_size_callback_t) (void *userData) |
| typedef int(* | read_callback_t) (uint8_t *buffer, int maxBytes, void *userData) |
Public Member Functions | |
| RTSPMediaCallbackSource () | |
| Default constructor. | |
| RTSPMediaCallbackSource (read_callback_t callback, void *userData=nullptr) | |
| Constructor with read callback. | |
| RTSPMediaCallbackSource (RTSPFormat &format, read_callback_t callback, void *userData=nullptr) | |
| Constructor with format and read callback. | |
| virtual | ~RTSPMediaCallbackSource () |
| RTSPFormat & | getFormat () override |
| Get the current RTSP format configuration. | |
| void * | getUserData () const |
| Get the user data pointer. | |
| bool | isActive () const |
| Check if the source is active. | |
| int | packetSize () override |
| Report the size of the next queued fragment via the configured packet-size callback (packetized/video sources only) | |
| int | readBytes (void *dest, int maxBytes) override |
| Read media data using the configured callback. | |
| void | setFormat (RTSPFormat &format) |
| Set the RTSP format configuration. | |
| void | setPacketSizeCallback (packet_size_callback_t callback) |
| Set the callback reporting the size of the next already- fragmented, ready-to-send packet. Configuring this switches packetSize() from the default "not packetized" (-1) to forwarding the callback's result, which in turn switches RTSPMediaStreamer to the packetized send path (see IMediaSource::packetSize()) - use this for video sources whose fragmentation/RTP payload framing is done externally (e.g. by an H264RtpEncoder/JPEGRtpEncoder that the read callback pulls from). | |
| void | setReadCallback (read_callback_t callback, void *userData=nullptr) |
| Set the callback function for reading media data. | |
| void | setStartCallback (lifecycle_callback_t callback) |
| Set optional start callback (called when streaming begins) | |
| void | setStopCallback (lifecycle_callback_t callback) |
| Set optional stop callback (called when streaming ends) | |
| void | start () override |
| Start the media source Calls the optional start callback if configured. | |
| void | stop () override |
| Stop the media source Calls the optional stop callback if configured. | |
Callback-based RTSP Media Source.
RTSPMediaCallbackSource provides a flexible way to stream custom media data over RTSP by using user-provided callback functions. This is ideal for:
The callback approach allows maximum flexibility while maintaining compatibility with the RTSP streaming framework.
| typedef void(* lifecycle_callback_t) (void *userData) |
Callback function type for source lifecycle management
| userData | Optional user data pointer passed to callback |
| typedef int(* packet_size_callback_t) (void *userData) |
Callback function type for reporting the size of the next queued, ready-to-send fragment - only needed for packetized (video) sources that hand out already RTP-payload-ready fragments (e.g. H264RtpEncoder, JPEGRtpEncoder) instead of a plain byte stream. See IMediaSource::packetSize() for the exact contract.
| userData | Optional user data pointer passed to callback |
| typedef int(* read_callback_t) (uint8_t *buffer, int maxBytes, void *userData) |
Callback function type for reading media data
| buffer | Buffer to write media data to |
| maxBytes | Maximum number of bytes to write |
| userData | Optional user data pointer passed to callback |
|
inline |
Default constructor.
|
inline |
Constructor with read callback.
| callback | Function to call for reading media data |
| userData | Optional pointer passed to callbacks |
|
inline |
Constructor with format and read callback.
| format | RTSPFormat configuration for the media stream |
| callback | Function to call for reading media data |
| userData | Optional pointer passed to callbacks |
|
inlinevirtual |
|
inlineoverridevirtual |
Get the current RTSP format configuration.
Implements IMediaSource.
|
inline |
Get the user data pointer.
|
inline |
Check if the source is active.
|
inlineoverridevirtual |
Report the size of the next queued fragment via the configured packet-size callback (packetized/video sources only)
Reimplemented from IMediaSource.
|
inlineoverridevirtual |
Read media data using the configured callback.
| dest | Buffer to receive media data |
| maxBytes | Maximum number of bytes to read |
Implements IMediaSource.
|
inline |
Set the RTSP format configuration.
| format | Format configuration for the media stream |
|
inline |
Set the callback reporting the size of the next already- fragmented, ready-to-send packet. Configuring this switches packetSize() from the default "not packetized" (-1) to forwarding the callback's result, which in turn switches RTSPMediaStreamer to the packetized send path (see IMediaSource::packetSize()) - use this for video sources whose fragmentation/RTP payload framing is done externally (e.g. by an H264RtpEncoder/JPEGRtpEncoder that the read callback pulls from).
| callback | Function that reports the next fragment's size |
|
inline |
Set the callback function for reading media data.
| callback | Function that provides media data |
| userData | Optional pointer passed to the callback |
|
inline |
Set optional start callback (called when streaming begins)
| callback | Function called during start() |
|
inline |
Set optional stop callback (called when streaming ends)
| callback | Function called during stop() |
|
inlineoverridevirtual |
Start the media source Calls the optional start callback if configured.
Reimplemented from IMediaSource.
|
inlineoverridevirtual |
Stop the media source Calls the optional stop callback if configured.
Reimplemented from IMediaSource.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |