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

We can build a input or an output chain: an input chain starts with setInput(); followed by add() an output chain consinsts of add() and ends with setOutput();. More...

#include <Pipeline.h>

Inheritance diagram for Pipeline:
AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

Classes

struct  ModifyingStreamAdapter
 Support for ModifyingOutput. More...
 

Public Member Functions

 Pipeline ()=default
 
 ~Pipeline ()
 
bool add (ModifyingOutput &out)
 adds a component
 
bool add (ModifyingStream &io)
 adds a component
 
void addNotifyAudioChange (AudioInfoSupport &bi) override
 Subscribes to notifications on last component of the chain.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
AudioInfo audioInfoOut () override
 Provides the resulting AudioInfo from the last node.
 
int available () override
 
int availableForWrite () override
 
bool begin () override
 Optional method: Calls begin on all components.
 
bool begin (AudioInfo info)
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
void end () override
 Calls end on all components.
 
virtual void flush () override
 
bool hasComponents ()
 Returns true if we have at least 1 component.
 
bool isActive ()
 Determines if the pipeline is active.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
bool isOK ()
 Returns true if pipeline is correctly set up.
 
ModifyingStreamlast ()
 Provides the last component.
 
 operator bool () override
 Returns true if pipeline is correctly set up and is active.
 
ModifyingStreamoperator[] (int idx)
 Access to the components by index.
 
size_t readBytes (uint8_t *data, size_t len) override
 
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 setActive (bool flag)
 Activates/deactivates the pipeline (default is active)
 
void setAudioInfo (AudioInfo newInfo) override
 Defines the AudioInfo for the first node.
 
bool setInput (AudioStream &in)
 Defines the input for an input pipeline: must be first call before add()
 
bool setInput (Stream &in)
 Defines the input for an input pipeline: must be first call before add()
 
void setNotifyActive (bool flag)
 Activates/deactivates notifications.
 
bool setOutput (AudioOutput &out)
 Defines the output for an output pipeline: must be last call after add()
 
bool setOutput (AudioStream &out)
 Defines the output for an output pipeline: must be last call after add()
 
bool setOutput (Print &out)
 Defines the output for an output pipeline: must be last call after add()
 
void setWriteBufferSize (int size)
 
int size ()
 Provides the number of components.
 
size_t write (const uint8_t *data, size_t len) override
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

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

Protected Attributes

int _timeout = 10
 
Vector< ModifyingStream * > cleanup {0}
 
Vector< ModifyingStream * > components {0}
 
bool has_input = false
 
bool has_output = false
 
AudioInfo info
 
bool is_active = true
 
bool is_notify_active = true
 
bool is_ok = true
 
Vector< AudioInfoSupport * > notify_vector
 
AudioStreamp_ai_input = nullptr
 
AudioInfoSourcep_ai_source = nullptr
 
AudioOutputp_out_print = nullptr
 
AudioStreamp_out_stream = nullptr
 
Printp_print = nullptr
 
Streamp_stream = nullptr
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

We can build a input or an output chain: an input chain starts with setInput(); followed by add() an output chain consinsts of add() and ends with setOutput();.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ Pipeline()

Pipeline ( )
default

◆ ~Pipeline()

~Pipeline ( )
inline

Member Function Documentation

◆ add() [1/2]

bool add ( ModifyingOutput out)
inline

adds a component

◆ add() [2/2]

bool add ( ModifyingStream io)
inline

adds a component

◆ addNotifyAudioChange()

void addNotifyAudioChange ( AudioInfoSupport bi)
inlineoverridevirtual

Subscribes to notifications on last component of the chain.

Reimplemented from AudioInfoSource.

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

AudioInfo audioInfoOut ( )
inlineoverridevirtual

Provides the resulting AudioInfo from the last node.

Reimplemented from AudioInfoSupport.

◆ available()

int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [1/2]

bool begin ( )
inlineoverridevirtual

Optional method: Calls begin on all components.

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( AudioInfo  info)
inline

Optional method: Calls begin on all components and setAudioInfo on first coponent to update the full chain

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ end()

void end ( )
inlineoverridevirtual

Calls end on all components.

Reimplemented from BaseStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ getInput()

Stream * getInput ( )
inlineprotected

we read from the last node or the defined input: null if no input is available

◆ hasComponents()

bool hasComponents ( )
inline

Returns true if we have at least 1 component.

◆ isActive()

bool isActive ( )
inline

Determines if the pipeline is active.

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isOK()

bool isOK ( )
inline

Returns true if pipeline is correctly set up.

◆ last()

ModifyingStream & last ( )
inline

Provides the last component.

◆ not_supported()

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

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

operator bool ( )
inlineoverridevirtual

Returns true if pipeline is correctly set up and is active.

Reimplemented from AudioStream.

◆ operator[]()

ModifyingStream & operator[] ( int  idx)
inline

Access to the components by index.

◆ readBytes()

size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtual

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 >.

◆ setActive()

void setActive ( bool  flag)
inline

Activates/deactivates the pipeline (default is active)

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  newInfo)
inlineoverridevirtual

Defines the AudioInfo for the first node.

Reimplemented from AudioStream.

◆ setInput() [1/2]

bool setInput ( AudioStream in)
inline

Defines the input for an input pipeline: must be first call before add()

◆ setInput() [2/2]

bool setInput ( Stream in)
inline

Defines the input for an input pipeline: must be first call before add()

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inline

Activates/deactivates notifications.

◆ setOutput() [1/3]

bool setOutput ( AudioOutput out)
inline

Defines the output for an output pipeline: must be last call after add()

◆ setOutput() [2/3]

bool setOutput ( AudioStream out)
inline

Defines the output for an output pipeline: must be last call after add()

◆ setOutput() [3/3]

bool setOutput ( Print out)
inline

Defines the output for an output pipeline: must be last call after add()

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ size()

int size ( )
inline

Provides the number of components.

◆ write() [1/2]

size_t write ( const uint8_t data,
size_t  len 
)
inlineoverridevirtual

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

◆ cleanup

Vector<ModifyingStream*> cleanup {0}
protected

◆ components

Vector<ModifyingStream*> components {0}
protected

◆ has_input

bool has_input = false
protected

◆ has_output

bool has_output = false
protected

◆ info

AudioInfo info
protectedinherited

◆ is_active

bool is_active = true
protected

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ is_ok

bool is_ok = true
protected

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_ai_input

AudioStream* p_ai_input = nullptr
protected

◆ p_ai_source

AudioInfoSource* p_ai_source = nullptr
protected

◆ p_out_print

AudioOutput* p_out_print = nullptr
protected

◆ p_out_stream

AudioStream* p_out_stream = nullptr
protected

◆ p_print

Print* p_print = nullptr
protected

◆ p_stream

Stream* p_stream = nullptr
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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