arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
RTSPMediaSourceMTS Class Reference

IMediaSource for an MPEG transport stream, e.g. live video and audio muxed by MuxerMTS: the muxer writes its output to this object (it is a Print), and an RTSPMediaStreamer sends it as one RTP track (MP2T, RFC 2250 - see RTSPFormatMTS) to the RTSP client, which demuxes video and audio itself. More...

#include <RTSPMediaSourceMTS.h>

Inheritance diagram for RTSPMediaSourceMTS:
Inheritance graph
[legend]
Collaboration diagram for RTSPMediaSourceMTS:
Collaboration graph
[legend]

Public Member Functions

 RTSPMediaSourceMTS (int bufferPackets=128, float sendRate=100)
 
virtual int availableForWrite ()
 
uint32_t droppedPackets ()
 Number of TS packets dropped because the buffer was full.
 
uint32_t droppedVideoPackets ()
 Number of video TS packets dropped to keep the audio going.
 
virtual void flush ()
 
RTSPFormat & getFormat () override
 Get the media format configuration.
 
int packetSize () override
 Size of the next RTP payload: up to kPacketsPerFragment TS packets.
 
int readBytes (void *dest, int maxBytes) override
 Provides whole TS packets only.
 
void start () override
 
void stop () override
 Called when the client stops streaming.
 
size_t write (const uint8_t *data, size_t len) override
 Accepts the transport stream, in any chunk sizes.
 
size_t write (uint8_t c) override
 

Static Public Attributes

static constexpr int kPacketSize = 188
 
static constexpr int kPacketsPerFragment = 7
 

Protected Member Functions

void addPacket ()
 
bool isVideoPes ()
 

Protected Attributes

int _timeout = 10
 
RingBufferSPSC< uint8_t > buffer
 
int capacity = 0
 
uint32_t dropped = 0
 
uint32_t dropped_video = 0
 
bool dropping_video = false
 
RTSPFormatMTS format
 
volatile bool is_active = false
 
uint8_t packet [kPacketSize]
 
size_t packet_len = 0
 
int video_pid = -1
 

Detailed Description

IMediaSource for an MPEG transport stream, e.g. live video and audio muxed by MuxerMTS: the muxer writes its output to this object (it is a Print), and an RTSPMediaStreamer sends it as one RTP track (MP2T, RFC 2250 - see RTSPFormatMTS) to the RTSP client, which demuxes video and audio itself.

Unlike RTSPOutput's generic byte stream, this source is meant for a live stream written from other tasks (e.g. by VideoMuxerWithTasks):

The data can be written from any task, but not from several tasks at the same time - e.g. by a MuxerMTS driven by VideoMuxerWithTasks, which serializes the writes of its audio and video task with its mutex.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ RTSPMediaSourceMTS()

RTSPMediaSourceMTS ( int  bufferPackets = 128,
float  sendRate = 100 
)
inline
Parameters
bufferPacketssize of the buffer in TS packets
sendRatenumber of times per second the queued packets are sent

Member Function Documentation

◆ addPacket()

void addPacket ( )
inlineprotected

◆ availableForWrite()

virtual int availableForWrite ( )
inlinevirtualinherited

◆ droppedPackets()

uint32_t droppedPackets ( )
inline

Number of TS packets dropped because the buffer was full.

◆ droppedVideoPackets()

uint32_t droppedVideoPackets ( )
inline

Number of video TS packets dropped to keep the audio going.

◆ flush()

virtual void flush ( )
inlinevirtualinherited

◆ getFormat()

RTSPFormat & getFormat ( )
inlineoverridevirtual

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.

◆ isVideoPes()

bool isVideoPes ( )
inlineprotected

True if the current packet starts a video PES packet (stream id 0xE0-0xEF)

◆ packetSize()

int packetSize ( )
inlineoverridevirtual

Size of the next RTP payload: up to kPacketsPerFragment TS packets.

Reimplemented from IMediaSource.

◆ readBytes()

int readBytes ( void *  dest,
int  maxBytes 
)
inlineoverridevirtual

Provides whole TS packets only.

Implements IMediaSource.

◆ start()

void start ( )
inlineoverridevirtual

Called when a client starts streaming, before the first readBytes(): discards the old data (on the consumer side - reset() would not be safe while the producer is writing)

Reimplemented from IMediaSource.

◆ stop()

void stop ( )
inlineoverridevirtual

Called when the client stops streaming.

Reimplemented from IMediaSource.

◆ write() [1/2]

size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Accepts the transport stream, in any chunk sizes.

Reimplemented from Print.

◆ write() [2/2]

size_t write ( uint8_t  c)
inlineoverride

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ buffer

RingBufferSPSC<uint8_t> buffer
protected

◆ capacity

int capacity = 0
protected

◆ dropped

uint32_t dropped = 0
protected

◆ dropped_video

uint32_t dropped_video = 0
protected

◆ dropping_video

bool dropping_video = false
protected

◆ format

RTSPFormatMTS format
protected

◆ is_active

volatile bool is_active = false
protected

◆ kPacketSize

constexpr int kPacketSize = 188
staticconstexpr

◆ kPacketsPerFragment

constexpr int kPacketsPerFragment = 7
staticconstexpr

◆ packet

uint8_t packet[kPacketSize]
protected

◆ packet_len

size_t packet_len = 0
protected

◆ video_pid

int video_pid = -1
protected

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