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

Class which measures the thruput. More...

#include <AudioStreams.h>

Inheritance diagram for MeasuringStream:
ModifyingStream AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

Public Member Functions

 MeasuringStream (int count=10, Print *logOut=nullptr)
 
 MeasuringStream (Print &print, int count=10, Print *logOut=nullptr)
 
 MeasuringStream (Stream &stream, int count=10, Print *logOut=nullptr)
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
int available () override
 
virtual int availableForWrite () override
 Provides the nubmer of bytes we can write.
 
bool begin () override
 
bool begin (AudioInfo info)
 
int bytesPerSecond ()
 Returns the actual thrughput in bytes per second.
 
uint32_t bytesSinceBegin ()
 Provides the total processed bytes since the last call of begin()
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
virtual void end ()
 
uint32_t estimatedOpenTimeFor (uint32_t totalBytes)
 Provides the estimated time from now to the end in ms.
 
uint32_t estimatedTotalTimeFor (uint32_t totalBytes)
 Provides the estimated runtime in milliseconds for the indicated total.
 
virtual void flush () override
 
int framesPerSecond ()
 Returns the actual thrughput in frames (samples) per second.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
size_t readBytes (uint8_t *data, size_t len) override
 Provides the data from all streams mixed together.
 
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
void setAudioInfo (AudioInfo info) override
 Defines the input AudioInfo.
 
void setFrameSize (int size)
 Trigger reporting in frames (=samples) per second.
 
void setLogOutput (Print &out)
 Defines the logging output.
 
void setName (const char *name)
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
void setOutput (Print &out) override
 Defines/Changes the output target.
 
bool setProcessedBytes (uint32_t pos)
 
void setReportBytes (bool flag)
 Report in bytes instead of samples.
 
void setStream (Stream &io) override
 Defines/Changes the input & output.
 
void setWriteBufferSize (int size)
 
uint32_t startTime ()
 Provides the time when the last measurement was started.
 
uint32_t timeSinceBegin ()
 Provides the time in ms since the last call of begin()
 
virtual size_t write (const uint8_t *data, size_t len) override
 Writes raw PCM audio data, which will be the input for the volume control.
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

size_t measure (size_t len)
 
virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void printResult ()
 
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 

Protected Attributes

int _timeout = 10
 
int bytes_per_second = 0
 
int count = 0
 
int frame_size = 0
 
AudioInfo info
 
bool is_notify_active = true
 
int max_count = 0
 
uint32_t ms_at_begin = 0
 
const charname = ""
 
Vector< AudioInfoSupport * > notify_vector
 
NullStream null
 
Printp_logout = nullptr
 
Printp_print = nullptr
 
Streamp_stream = nullptr
 
bool report_bytes = false
 
uint32_t start_time
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
int total_bytes = 0
 
uint32_t total_bytes_since_begin = 0
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

Class which measures the thruput.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ MeasuringStream() [1/3]

MeasuringStream ( int  count = 10,
Print logOut = nullptr 
)
inline

◆ MeasuringStream() [2/3]

MeasuringStream ( Print print,
int  count = 10,
Print logOut = nullptr 
)
inline

◆ MeasuringStream() [3/3]

MeasuringStream ( Stream stream,
int  count = 10,
Print logOut = nullptr 
)
inline

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtual

Provides the nubmer of bytes we can write.

Reimplemented from BaseStream.

◆ begin() [1/2]

bool begin ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( AudioInfo  info)
inline

◆ bytesPerSecond()

int bytesPerSecond ( )
inline

Returns the actual thrughput in bytes per second.

◆ bytesSinceBegin()

uint32_t bytesSinceBegin ( )
inline

Provides the total processed bytes since the last call of begin()

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ end()

virtual void end ( )
inlinevirtualinherited

◆ estimatedOpenTimeFor()

uint32_t estimatedOpenTimeFor ( uint32_t  totalBytes)
inline

Provides the estimated time from now to the end in ms.

◆ estimatedTotalTimeFor()

uint32_t estimatedTotalTimeFor ( uint32_t  totalBytes)
inline

Provides the estimated runtime in milliseconds for the indicated total.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ framesPerSecond()

int framesPerSecond ( )
inline

Returns the actual thrughput in frames (samples) per second.

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ measure()

size_t measure ( size_t  len)
inlineprotected

◆ not_supported()

virtual int not_supported ( int  out,
const char msg = "" 
)
inlineprotectedvirtualinherited

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ printResult()

void printResult ( )
inlineprotected

◆ readBytes()

size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtual

Provides the data from all streams mixed together.

Reimplemented from AudioStream.

◆ readSilence()

virtual size_t readSilence ( uint8_t buffer,
size_t  length 
)
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  info)
inlineoverridevirtual

Defines the input AudioInfo.

Reimplemented from AudioStream.

◆ setFrameSize()

void setFrameSize ( int  size)
inline

Trigger reporting in frames (=samples) per second.

◆ setLogOutput()

void setLogOutput ( Print out)
inline

Defines the logging output.

◆ setName()

void setName ( const char name)
inline

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active)

◆ setOutput()

void setOutput ( Print out)
inlineoverridevirtual

Defines/Changes the output target.

Implements ModifyingStream.

◆ setProcessedBytes()

bool setProcessedBytes ( uint32_t  pos)
inline

Alternative update method: e.g report actual file positon: returns true if the file position was increased

◆ setReportBytes()

void setReportBytes ( bool  flag)
inline

Report in bytes instead of samples.

◆ setStream()

void setStream ( Stream io)
inlineoverridevirtual

Defines/Changes the input & output.

Implements ModifyingStream.

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ startTime()

uint32_t startTime ( )
inline

Provides the time when the last measurement was started.

◆ timeSinceBegin()

uint32_t timeSinceBegin ( )
inline

Provides the time in ms since the last call of begin()

◆ write() [1/2]

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

Writes raw PCM audio data, which will be the input for the volume control.

Reimplemented from AudioStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes len bytes of silence (=0).

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ bytes_per_second

int bytes_per_second = 0
protected

◆ count

int count = 0
protected

◆ frame_size

int frame_size = 0
protected

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ max_count

int max_count = 0
protected

◆ ms_at_begin

uint32_t ms_at_begin = 0
protected

◆ name

const char* name = ""
protected

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ null

NullStream null
protected

◆ p_logout

Print* p_logout = nullptr
protected

◆ p_print

Print* p_print = nullptr
protected

◆ p_stream

Stream* p_stream = nullptr
protected

◆ report_bytes

bool report_bytes = false
protected

◆ start_time

uint32_t start_time
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ total_bytes

int total_bytes = 0
protected

◆ total_bytes_since_begin

uint32_t total_bytes_since_begin = 0
protected

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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