Arduino DLNA Server
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
tiny_dlna::DLNAControlPointMediaServer Class Reference

Helper class to control/query a MediaServer from a control point. More...

#include <DLNAControlPointMediaServer.h>

Public Types

typedef void(* XMLCallback) (const char *name, const char *test, const char *attributes)
 
typedef void(* NotificationCallback) (void *reference, const char *sid, const char *varName, const char *newValue)
 

Public Member Functions

 DLNAControlPointMediaServer ()=default
 Default constructor.
 
 DLNAControlPointMediaServer (DLNAControlPoint &mgr, DLNAHttpRequest &http, IUDPService &udp)
 Construct helper with references to control point manager and required transport instances (HTTP for subscribe callbacks and UDP for SSDP discovery)
 
void setDLNAControlPoint (DLNAControlPoint &m)
 Set the control point manager instance (required before using helper)
 
bool begin (uint32_t minWaitMs=3000, uint32_t maxWaitMs=60000)
 Begin discovery and processing (forwards to underlying control point)
 
void setHttp (DLNAHttpRequest &http)
 Setter for the HTTP wrapper used for subscriptions and callbacks.
 
void setUdp (IUDPService &udp)
 Setter for UDP service used for discovery (SSDP)
 
int getDeviceCount ()
 Return number of discovered devices known to the control point.
 
const ActionReplygetLastReply () const
 Return the ActionReply from the last synchronous request.
 
void setDeviceIndex (int idx)
 Select a device by index (0-based) for subsequent actions. By default 0 is used.
 
void setSubscribeNotificationsActive (bool flag)
 Activate/deactivate subscription notifications.
 
void setDeviceTypeFilter (const char *filter)
 Restrict this helper to devices of the given device type.
 
void setReference (void *ref)
 Attach an opaque reference pointer passed to callbacks.
 
bool browse (int startingIndex, int requestedCount, ContentQueryType queryType, XMLCallback XMLCallback, int &numberReturned, int &totalMatches, int &updateID)
 Browse the given object_id and invoke callback for each returned xml element.
 
bool search (int startingIndex, int requestedCount, XMLCallback XMLCallback, int &numberReturned, int &totalMatches, int &updateID, const char *searchCriteria="", const char *filter="", const char *sortCriteria="")
 Search the ContentDirectory using SearchCriteria and invoke callback for each returned xml element.
 
int getSystemUpdateID ()
 Get current SystemUpdateID for the ContentDirectory.
 
const char * getSearchCapabilities ()
 Get the ContentDirectory SearchCapabilities string.
 
const char * getSortCapabilities ()
 Get the ContentDirectory SortCapabilities string.
 
const char * getProtocolInfo ()
 Query ConnectionManager:GetProtocolInfo.
 
void setObjectID (const char *id)
 Set the object id used for browse operations (default: "0")
 
const char * getObjectID () const
 Return the current object id used for browse.
 

Protected Member Functions

DLNAServiceInfoselectService (const char *id)
 Select service by id.
 
ActionRequestcreateBrowseAction (DLNAServiceInfo &svc, ContentQueryType queryType, int startingIndex, int requestedCount)
 Build a Browse ActionRequest.
 
ActionRequestcreateSearchAction (DLNAServiceInfo &svc, const char *searchCriteria, const char *filter, int startingIndex, int requestedCount, const char *sortCriteria)
 Build a Search ActionRequest.
 
void parseNumericFields (ActionReply &reply, int &numberReturned, int &totalMatches, int &updateID)
 Parse numeric result fields from an ActionReply.
 

Static Protected Member Functions

static void processNotification (void *reference, const char *sid, const char *varName, const char *newValue)
 Notification callback: just log for now.
 

Protected Attributes

DLNAControlPointp_mgr = nullptr
 
const char * device_type_filter_default
 
const char * device_type_filter = device_type_filter_default
 
ActionReply last_reply
 
StringRegistry strings
 
void * reference = nullptr
 
const char * object_id = "0"
 
DLNAHttpRequestp_http = nullptr
 
IUDPServicep_udp = nullptr
 

Detailed Description

Helper class to control/query a MediaServer from a control point.

Provides convenient wrappers around common ContentDirectory and ConnectionManager actions (Browse, GetSystemUpdateID, GetSearchCapabilities, GetProtocolInfo). Methods are synchronous and return boolean success or populate output parameters.

Member Typedef Documentation

◆ NotificationCallback

typedef void(* tiny_dlna::DLNAControlPointMediaServer::NotificationCallback) (void *reference, const char *sid, const char *varName, const char *newValue)

◆ XMLCallback

typedef void(* tiny_dlna::DLNAControlPointMediaServer::XMLCallback) (const char *name, const char *test, const char *attributes)

Constructor & Destructor Documentation

◆ DLNAControlPointMediaServer() [1/2]

tiny_dlna::DLNAControlPointMediaServer::DLNAControlPointMediaServer ( )
default

Default constructor.

◆ DLNAControlPointMediaServer() [2/2]

tiny_dlna::DLNAControlPointMediaServer::DLNAControlPointMediaServer ( DLNAControlPoint mgr,
DLNAHttpRequest http,
IUDPService udp 
)
inline

Construct helper with references to control point manager and required transport instances (HTTP for subscribe callbacks and UDP for SSDP discovery)

Parameters
mgrReference to DLNAControlPointMgr used to send actions and manage discovery/subscriptions
httpHttp server wrapper used for subscription callbacks
udpUDP service used for SSDP discovery

Member Function Documentation

◆ begin()

bool tiny_dlna::DLNAControlPointMediaServer::begin ( uint32_t  minWaitMs = 3000,
uint32_t  maxWaitMs = 60000 
)
inline

Begin discovery and processing (forwards to underlying control point)

Parameters
minWaitMsMinimum time in milliseconds to wait before returning
maxWaitMsMaximum time in milliseconds to wait for discovery
Returns
true on success, false on error

◆ browse()

bool tiny_dlna::DLNAControlPointMediaServer::browse ( int  startingIndex,
int  requestedCount,
ContentQueryType  queryType,
XMLCallback  XMLCallback,
int &  numberReturned,
int &  totalMatches,
int &  updateID 
)
inline

Browse the given object_id and invoke callback for each returned xml element.

Parameters
startingIndexStarting index for the browse request
requestedCountNumber of items requested
XMLCallbackCallback invoked per MediaItem result (may be nullptr)
numberReturnedOutput: number of items returned by server
totalMatchesOutput: total matches available on server
updateIDOutput: server UpdateID
browseFlagOptional BrowseFlag (defaults to BrowseDirectChildren)
Returns
true on success, false on error
Note
The raw DIDL-Lite XML result is available via getLastReply() -> "Result"

◆ createBrowseAction()

ActionRequest & tiny_dlna::DLNAControlPointMediaServer::createBrowseAction ( DLNAServiceInfo svc,
ContentQueryType  queryType,
int  startingIndex,
int  requestedCount 
)
inlineprotected

Build a Browse ActionRequest.

◆ createSearchAction()

ActionRequest & tiny_dlna::DLNAControlPointMediaServer::createSearchAction ( DLNAServiceInfo svc,
const char *  searchCriteria,
const char *  filter,
int  startingIndex,
int  requestedCount,
const char *  sortCriteria 
)
inlineprotected

Build a Search ActionRequest.

◆ getDeviceCount()

int tiny_dlna::DLNAControlPointMediaServer::getDeviceCount ( )
inline

Return number of discovered devices known to the control point.

Returns
number of devices matching the optional device type filter

◆ getLastReply()

const ActionReply & tiny_dlna::DLNAControlPointMediaServer::getLastReply ( ) const
inline

Return the ActionReply from the last synchronous request.

Returns
reference to the last ActionReply

◆ getObjectID()

const char * tiny_dlna::DLNAControlPointMediaServer::getObjectID ( ) const
inline

Return the current object id used for browse.

Returns
C-string object id

◆ getProtocolInfo()

const char * tiny_dlna::DLNAControlPointMediaServer::getProtocolInfo ( )
inline

Query ConnectionManager:GetProtocolInfo.

Returns
pointer to protocol info string (Source), or nullptr on error

◆ getSearchCapabilities()

const char * tiny_dlna::DLNAControlPointMediaServer::getSearchCapabilities ( )
inline

Get the ContentDirectory SearchCapabilities string.

Returns
pointer to capability string owned by reply, or nullptr on error

◆ getSortCapabilities()

const char * tiny_dlna::DLNAControlPointMediaServer::getSortCapabilities ( )
inline

Get the ContentDirectory SortCapabilities string.

Returns
pointer to sort capabilities, or nullptr on error

◆ getSystemUpdateID()

int tiny_dlna::DLNAControlPointMediaServer::getSystemUpdateID ( )
inline

Get current SystemUpdateID for the ContentDirectory.

Returns
numeric SystemUpdateID, or -1 on error

◆ parseNumericFields()

void tiny_dlna::DLNAControlPointMediaServer::parseNumericFields ( ActionReply reply,
int &  numberReturned,
int &  totalMatches,
int &  updateID 
)
inlineprotected

Parse numeric result fields from an ActionReply.

◆ processNotification()

static void tiny_dlna::DLNAControlPointMediaServer::processNotification ( void *  reference,
const char *  sid,
const char *  varName,
const char *  newValue 
)
inlinestaticprotected

Notification callback: just log for now.

◆ search()

bool tiny_dlna::DLNAControlPointMediaServer::search ( int  startingIndex,
int  requestedCount,
XMLCallback  XMLCallback,
int &  numberReturned,
int &  totalMatches,
int &  updateID,
const char *  searchCriteria = "",
const char *  filter = "",
const char *  sortCriteria = "" 
)
inline

Search the ContentDirectory using SearchCriteria and invoke callback for each returned xml element.

Parameters
startingIndexStarting index for the search request
requestedCountNumber of items requested
XMLCallbackCallback invoked per MediaItem result (may be nullptr)
numberReturnedOutput: number of items returned by server
totalMatchesOutput: total matches available on server
updateIDOutput: server UpdateID
searchCriteriaSearch criteria string as defined by ContentDirectory
filterOptional Filter argument (defaults to empty string)
sortCriteriaOptional SortCriteria (defaults to empty string)
Returns
true on success, false on error

◆ selectService()

DLNAServiceInfo & tiny_dlna::DLNAControlPointMediaServer::selectService ( const char *  id)
inlineprotected

Select service by id.

◆ setDeviceIndex()

void tiny_dlna::DLNAControlPointMediaServer::setDeviceIndex ( int  idx)
inline

Select a device by index (0-based) for subsequent actions. By default 0 is used.

Parameters
idxDevice index

◆ setDeviceTypeFilter()

void tiny_dlna::DLNAControlPointMediaServer::setDeviceTypeFilter ( const char *  filter)
inline

Restrict this helper to devices of the given device type.

Parameters
filterDevice type string (e.g. "urn:schemas-upnp-org:device:MediaServer:1") Pass nullptr to restore the default filter

◆ setDLNAControlPoint()

void tiny_dlna::DLNAControlPointMediaServer::setDLNAControlPoint ( DLNAControlPoint m)
inline

Set the control point manager instance (required before using helper)

◆ setHttp()

void tiny_dlna::DLNAControlPointMediaServer::setHttp ( DLNAHttpRequest http)
inline

Setter for the HTTP wrapper used for subscriptions and callbacks.

◆ setObjectID()

void tiny_dlna::DLNAControlPointMediaServer::setObjectID ( const char *  id)
inline

Set the object id used for browse operations (default: "0")

Parameters
idC-string object id

◆ setReference()

void tiny_dlna::DLNAControlPointMediaServer::setReference ( void *  ref)
inline

Attach an opaque reference pointer passed to callbacks.

Parameters
refOpaque user pointer

◆ setSubscribeNotificationsActive()

void tiny_dlna::DLNAControlPointMediaServer::setSubscribeNotificationsActive ( bool  flag)
inline

Activate/deactivate subscription notifications.

◆ setUdp()

void tiny_dlna::DLNAControlPointMediaServer::setUdp ( IUDPService udp)
inline

Setter for UDP service used for discovery (SSDP)

Member Data Documentation

◆ device_type_filter

const char* tiny_dlna::DLNAControlPointMediaServer::device_type_filter = device_type_filter_default
protected

◆ device_type_filter_default

const char* tiny_dlna::DLNAControlPointMediaServer::device_type_filter_default
protected
Initial value:
=
"urn:schemas-upnp-org:device:MediaServer:1"

◆ last_reply

ActionReply tiny_dlna::DLNAControlPointMediaServer::last_reply
protected

◆ object_id

const char* tiny_dlna::DLNAControlPointMediaServer::object_id = "0"
protected

◆ p_http

DLNAHttpRequest* tiny_dlna::DLNAControlPointMediaServer::p_http = nullptr
protected

◆ p_mgr

DLNAControlPoint* tiny_dlna::DLNAControlPointMediaServer::p_mgr = nullptr
protected

◆ p_udp

IUDPService* tiny_dlna::DLNAControlPointMediaServer::p_udp = nullptr
protected

◆ reference

void* tiny_dlna::DLNAControlPointMediaServer::reference = nullptr
protected

◆ strings

StringRegistry tiny_dlna::DLNAControlPointMediaServer::strings
protected

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