Arduino DLNA Server
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tiny_dlna::SdFatContentProvider< FS > Class Template Reference

Content provider for DLNA media server using SdFat filesystem. More...

#include <SdFatContentProvider.h>

Public Member Functions

bool begin (FS &fs, const char *rootPath)
 Initializes the content provider and scans the filesystem.
 
void end ()
 Releases all resources and clears the directory tree.
 
size_t size ()
 
void prepareData (const char *objectID, ContentQueryType queryType, const char *filter, int startingIndex, int requestedCount, const char *sortCriteria, int &numberReturned, int &totalMatches, int &updateID, void *reference)
 Prepares data for a DLNA content query.
 
bool isHidden (TreeNode *node) const
 Returns true if the node is hidden (file or directory name starts with '.')
 
bool getData (int index, MediaItem &item, void *reference=nullptr)
 Retrieves a single media item by index.
 
const char * getPath ()
 Provides the path prefix for resource URIs.
 
void setPath (const char *p)
 Sets the path prefix for resource URIs.
 
TreeNodegetTreeNodeById (uint32_t id)
 Returns the full file path by node ID.
 

Protected Member Functions

TreeNodefindNodeByObjectID (const char *objectID)
 Finds a tree node by its object ID string.
 

Protected Attributes

SdFatDirectoryTree< FS > directoryTree
 
const char * path = "/file"
 
const char * objectID_ = nullptr
 
ContentQueryType queryType_
 
const char * filter_ = nullptr
 
int startingIndex_ = 0
 
int requestedCount_ = 0
 
const char * sortCriteria_ = nullptr
 
void * reference_ = nullptr
 
std::vector< TreeNode *, AllocatorPSRAM< TreeNode * > > resultNodes_
 
stringPSRAM currentId_
 Current item ID string.
 
stringPSRAM currentParentId_
 Current parent ID string.
 
stringPSRAM currentPath_
 Current resource path string.
 
stringPSRAM currentMime_
 Current MIME type string.
 

Detailed Description

template<typename FS>
class tiny_dlna::SdFatContentProvider< FS >

Content provider for DLNA media server using SdFat filesystem.

This class bridges the SdFat filesystem with DLNA's content browsing/searching interface. It builds an in-memory directory tree from the filesystem and provides DLNA-compliant metadata for media files and folders.

The provider supports three query types:

Usage pattern:

  1. Call begin() to initialize and scan the filesystem
  2. prepareData() is called by DLNA to set up a query
  3. getData() is called repeatedly to retrieve individual items
Template Parameters
FSFilesystem type compatible with SdFat API (e.g., SdFs, SdFat32).

Member Function Documentation

◆ begin()

template<typename FS >
bool tiny_dlna::SdFatContentProvider< FS >::begin ( FS &  fs,
const char *  rootPath 
)
inline

Initializes the content provider and scans the filesystem.

Parameters
fsFilesystem instance (e.g., SdFs)
rootPathRoot directory path to scan (defaults to "/")
Returns
true on success

◆ end()

template<typename FS >
void tiny_dlna::SdFatContentProvider< FS >::end ( )
inline

Releases all resources and clears the directory tree.

◆ findNodeByObjectID()

template<typename FS >
TreeNode * tiny_dlna::SdFatContentProvider< FS >::findNodeByObjectID ( const char *  objectID)
inlineprotected

Finds a tree node by its object ID string.

Parameters
objectIDObject ID as string (node's numeric id)
Returns
Pointer to the node, or nullptr if not found or invalid

◆ getData()

template<typename FS >
bool tiny_dlna::SdFatContentProvider< FS >::getData ( int  index,
MediaItem item,
void *  reference = nullptr 
)
inline

Retrieves a single media item by index.

Called repeatedly by DLNA after prepareData() to fetch individual items. Uses the cached resultNodes_ populated during prepareData().

Parameters
indexZero-based index relative to startingIndex
itemOutput: MediaItem populated with metadata
referenceUser-defined reference pointer
Returns
true if successful, false if index out of range

◆ getPath()

template<typename FS >
const char * tiny_dlna::SdFatContentProvider< FS >::getPath ( )
inline

Provides the path prefix for resource URIs.

◆ getTreeNodeById()

template<typename FS >
TreeNode & tiny_dlna::SdFatContentProvider< FS >::getTreeNodeById ( uint32_t  id)
inline

Returns the full file path by node ID.

◆ isHidden()

template<typename FS >
bool tiny_dlna::SdFatContentProvider< FS >::isHidden ( TreeNode node) const
inline

Returns true if the node is hidden (file or directory name starts with '.')

Parameters
nodePointer to TreeNode
Returns
true if hidden, false otherwise

◆ prepareData()

template<typename FS >
void tiny_dlna::SdFatContentProvider< FS >::prepareData ( const char *  objectID,
ContentQueryType  queryType,
const char *  filter,
int  startingIndex,
int  requestedCount,
const char *  sortCriteria,
int &  numberReturned,
int &  totalMatches,
int &  updateID,
void *  reference 
)
inline

Prepares data for a DLNA content query.

Collects all matching nodes from the directory tree and stores them in resultNodes_. Calculates pagination and total match counts based on the query type and parameters.

Parameters
objectIDObject ID to query (nullptr or "0" for root)
queryTypeType of query (BrowseMetadata/BrowseChildren/Search)
filterContent filter (not currently used)
startingIndexZero-based index of first item to return
requestedCountNumber of items requested (0 = all)
sortCriteriaSort criteria (not currently used)
numberReturnedOutput: number of items available to return
totalMatchesOutput: total matching items
updateIDOutput: content version ID
referenceUser pointer

◆ setPath()

template<typename FS >
void tiny_dlna::SdFatContentProvider< FS >::setPath ( const char *  p)
inline

Sets the path prefix for resource URIs.

◆ size()

template<typename FS >
size_t tiny_dlna::SdFatContentProvider< FS >::size ( )
inline

Member Data Documentation

◆ currentId_

template<typename FS >
stringPSRAM tiny_dlna::SdFatContentProvider< FS >::currentId_
protected

Current item ID string.

◆ currentMime_

template<typename FS >
stringPSRAM tiny_dlna::SdFatContentProvider< FS >::currentMime_
protected

Current MIME type string.

◆ currentParentId_

template<typename FS >
stringPSRAM tiny_dlna::SdFatContentProvider< FS >::currentParentId_
protected

Current parent ID string.

◆ currentPath_

template<typename FS >
stringPSRAM tiny_dlna::SdFatContentProvider< FS >::currentPath_
protected

Current resource path string.

◆ directoryTree

template<typename FS >
SdFatDirectoryTree<FS> tiny_dlna::SdFatContentProvider< FS >::directoryTree
protected

◆ filter_

template<typename FS >
const char* tiny_dlna::SdFatContentProvider< FS >::filter_ = nullptr
protected

◆ objectID_

template<typename FS >
const char* tiny_dlna::SdFatContentProvider< FS >::objectID_ = nullptr
protected

◆ path

template<typename FS >
const char* tiny_dlna::SdFatContentProvider< FS >::path = "/file"
protected

◆ queryType_

template<typename FS >
ContentQueryType tiny_dlna::SdFatContentProvider< FS >::queryType_
protected

◆ reference_

template<typename FS >
void* tiny_dlna::SdFatContentProvider< FS >::reference_ = nullptr
protected

◆ requestedCount_

template<typename FS >
int tiny_dlna::SdFatContentProvider< FS >::requestedCount_ = 0
protected

◆ resultNodes_

template<typename FS >
std::vector<TreeNode*, AllocatorPSRAM<TreeNode*> > tiny_dlna::SdFatContentProvider< FS >::resultNodes_
protected

◆ sortCriteria_

template<typename FS >
const char* tiny_dlna::SdFatContentProvider< FS >::sortCriteria_ = nullptr
protected

◆ startingIndex_

template<typename FS >
int tiny_dlna::SdFatContentProvider< FS >::startingIndex_ = 0
protected

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