arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AudioSourceFTP< ClientType > Class Template Reference

An AudioSource that uses the https://github.com/pschatzmann/TinyFTPClient library to retrieve files from a FTP Server. You need to provide an FTPClient object to the constructor and make sure that you open it before you access the files. The storage of the expanded file names is done on the heap, so in order to limit the requested memory we can limit the number of files. More...

#include <AudioSourceFTP.h>

Inheritance diagram for AudioSourceFTP< ClientType >:
AudioSource

Public Member Functions

 AudioSourceFTP (FTPClient< ClientType > &client, const char *path, const char *ext, int files=0)
 Default constructor: Provide the client class as template argument e.g. AudioSourceFTP<WiFiClient> source(client, path, ext);.
 
bool addDirectory (const char *path)
 Adds all the files of a directory.
 
bool begin () override
 Resets the actual data.
 
void end ()
 Resets the actual data.
 
int index () override
 Retrieves all files and returns the actual index of the stream.
 
virtual bool isAutoNext ()
 Returns default setting go to the next.
 
StreamnextStream (int offset) override
 Returns next audio stream.
 
Streamoperator[] (int idx)
 access with array syntax
 
StreampreviousStream (int offset) override
 Returns previous audio stream.
 
StreamselectStream (const char *path) override
 Returns the FTPFile for the indicated path.
 
StreamselectStream (int index) override
 
virtual void setAutoNext (bool flag)
 
virtual StreamsetIndex (int index)
 same as selectStream - I just prefer this name
 
void setMaxFiles (int maxCount)
 Defines the max number of files (if value is >0)
 
virtual bool setMetadataCallback (void(*fn)(MetaDataType info, const char *str, int len), ID3TypeSelection sel=SELECT_ICY)
 
virtual void setTimeout (int millisec)
 Sets the timeout of Stream in milliseconds.
 
virtual void setTimeoutAutoNext (int millisec)
 
size_t size ()
 Returns the number of available files.
 
virtual int timeoutAutoNext ()
 Provides the timeout which is triggering to move to the next stream.
 
const chartoStr () override
 provides the actual stream (e.g. file) name or url
 

Protected Member Functions

void addFiles (FTPFile &dir, int level)
 Adds all files recursively.
 
bool endsWith (const char *file, const char *ext)
 
bool isValidIdx (int index)
 

Protected Attributes

FTPFile file
 
std::vector< FTPFilefiles
 
int idx = 0
 
bool is_auto_next = true
 
bool is_first = true
 
size_t max_files = 0
 
FTPClient< ClientType > * p_client = nullptr
 
const charp_ext = nullptr
 
const charp_path = "/"
 
int timeout_auto_next_value = 500
 

Detailed Description

template<class ClientType>
class audio_tools::AudioSourceFTP< ClientType >

An AudioSource that uses the https://github.com/pschatzmann/TinyFTPClient library to retrieve files from a FTP Server. You need to provide an FTPClient object to the constructor and make sure that you open it before you access the files. The storage of the expanded file names is done on the heap, so in order to limit the requested memory we can limit the number of files.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ AudioSourceFTP()

template<class ClientType >
AudioSourceFTP ( FTPClient< ClientType > &  client,
const char path,
const char ext,
int  files = 0 
)
inline

Default constructor: Provide the client class as template argument e.g. AudioSourceFTP<WiFiClient> source(client, path, ext);.

Member Function Documentation

◆ addDirectory()

template<class ClientType >
bool addDirectory ( const char path)
inline

Adds all the files of a directory.

◆ addFiles()

template<class ClientType >
void addFiles ( FTPFile dir,
int  level 
)
inlineprotected

Adds all files recursively.

◆ begin()

template<class ClientType >
bool begin ( )
inlineoverridevirtual

Resets the actual data.

Implements AudioSource.

◆ end()

template<class ClientType >
void end ( )
inline

Resets the actual data.

◆ endsWith()

template<class ClientType >
bool endsWith ( const char file,
const char ext 
)
inlineprotected

◆ index()

template<class ClientType >
int index ( )
inlineoverridevirtual

Retrieves all files and returns the actual index of the stream.

Reimplemented from AudioSource.

◆ isAutoNext()

virtual bool isAutoNext ( )
inlinevirtualinherited

◆ isValidIdx()

template<class ClientType >
bool isValidIdx ( int  index)
inlineprotected

◆ nextStream()

template<class ClientType >
Stream * nextStream ( int  offset)
inlineoverridevirtual

Returns next audio stream.

Implements AudioSource.

◆ operator[]()

Stream * operator[] ( int  idx)
inlineinherited

access with array syntax

◆ previousStream()

template<class ClientType >
Stream * previousStream ( int  offset)
inlineoverridevirtual

Returns previous audio stream.

Reimplemented from AudioSource.

◆ selectStream() [1/2]

template<class ClientType >
Stream * selectStream ( const char path)
inlineoverridevirtual

Returns the FTPFile for the indicated path.

Implements AudioSource.

◆ selectStream() [2/2]

template<class ClientType >
Stream * selectStream ( int  index)
inlineoverridevirtual

Returns audio stream at the indicated index (the index is zero based, so the first value is 0!)

Reimplemented from AudioSource.

◆ setAutoNext()

virtual void setAutoNext ( bool  flag)
inlinevirtualinherited

Reimplemented in AudioSourceCallback.

◆ setIndex()

virtual Stream * setIndex ( int  index)
inlinevirtualinherited

same as selectStream - I just prefer this name

◆ setMaxFiles()

template<class ClientType >
void setMaxFiles ( int  maxCount)
inline

Defines the max number of files (if value is >0)

◆ setMetadataCallback()

virtual bool setMetadataCallback ( void(*)(MetaDataType info, const char *str, int len)  fn,
ID3TypeSelection  sel = SELECT_ICY 
)
inlinevirtualinherited

Reimplemented in AudioSourceURL.

◆ setTimeout()

virtual void setTimeout ( int  millisec)
inlinevirtualinherited

Sets the timeout of Stream in milliseconds.

Reimplemented in AudioSourceURL, and AudioSourceSDFAT< AudioFs, AudioFile >.

◆ setTimeoutAutoNext()

virtual void setTimeoutAutoNext ( int  millisec)
inlinevirtualinherited

Sets the timeout which is triggering to move to the next stream. - the default value is 500 ms

◆ size()

template<class ClientType >
size_t size ( )
inline

Returns the number of available files.

◆ timeoutAutoNext()

virtual int timeoutAutoNext ( )
inlinevirtualinherited

Provides the timeout which is triggering to move to the next stream.

◆ toStr()

template<class ClientType >
const char * toStr ( )
inlineoverridevirtual

provides the actual stream (e.g. file) name or url

Reimplemented from AudioSource.

Member Data Documentation

◆ file

template<class ClientType >
FTPFile file
protected

◆ files

template<class ClientType >
std::vector<FTPFile> files
protected

◆ idx

template<class ClientType >
int idx = 0
protected

◆ is_auto_next

bool is_auto_next = true
protectedinherited

◆ is_first

template<class ClientType >
bool is_first = true
protected

◆ max_files

template<class ClientType >
size_t max_files = 0
protected

◆ p_client

template<class ClientType >
FTPClient<ClientType>* p_client = nullptr
protected

◆ p_ext

template<class ClientType >
const char* p_ext = nullptr
protected

◆ p_path

template<class ClientType >
const char* p_path = "/"
protected

◆ timeout_auto_next_value

int timeout_auto_next_value = 500
protectedinherited

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