|
Arduino DLNA Server
|
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. | |
| TreeNode & | getTreeNodeById (uint32_t id) |
| Returns the full file path by node ID. | |
Protected Member Functions | |
| TreeNode * | findNodeByObjectID (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. | |
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:
| FS | Filesystem type compatible with SdFat API (e.g., SdFs, SdFat32). |
|
inline |
Initializes the content provider and scans the filesystem.
| fs | Filesystem instance (e.g., SdFs) |
| rootPath | Root directory path to scan (defaults to "/") |
|
inline |
Releases all resources and clears the directory tree.
|
inlineprotected |
Finds a tree node by its object ID string.
| objectID | Object ID as string (node's numeric id) |
|
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().
| index | Zero-based index relative to startingIndex |
| item | Output: MediaItem populated with metadata |
| reference | User-defined reference pointer |
|
inline |
Provides the path prefix for resource URIs.
|
inline |
Returns the full file path by node ID.
|
inline |
Returns true if the node is hidden (file or directory name starts with '.')
| node | Pointer to TreeNode |
|
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.
| objectID | Object ID to query (nullptr or "0" for root) |
| queryType | Type of query (BrowseMetadata/BrowseChildren/Search) |
| filter | Content filter (not currently used) |
| startingIndex | Zero-based index of first item to return |
| requestedCount | Number of items requested (0 = all) |
| sortCriteria | Sort criteria (not currently used) |
| numberReturned | Output: number of items available to return |
| totalMatches | Output: total matching items |
| updateID | Output: content version ID |
| reference | User pointer |
|
inline |
Sets the path prefix for resource URIs.
|
inline |
|
protected |
Current item ID string.
|
protected |
Current MIME type string.
|
protected |
Current parent ID string.
|
protected |
Current resource path string.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |