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::ControlPointMediaServer Class Reference

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

#include <ControlPointMediaServer.h>

Collaboration diagram for tiny_dlna::ControlPointMediaServer:
Collaboration graph
[legend]

Public Types

typedef void(* ItemCallback) (const MediaItem &item, void *ref)
 
typedef void(* NotificationCallback) (void *reference, const char *sid, const char *varName, const char *newValue)
 

Public Member Functions

 ControlPointMediaServer (DLNAControlPointMgr &mgr)
 Construct helper with reference to control point manager.
 
bool begin (DLNAHttpRequest &http, IUDPService &udp, uint32_t minWaitMs=3000, uint32_t maxWaitMs=60000)
 Begin discovery and processing (forwards to underlying control point)
 
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.
 
bool subscribeNotifications (int timeoutSeconds=60, NotificationCallback cb=nullptr)
 Subscribe to event notifications for the selected server/device.
 
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, ItemCallback itemCallback, int &numberReturned, int &totalMatches, int &updateID, const char *browseFlag=nullptr)
 Browse the given object_id and invoke callback for each returned item.
 
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.
 
const char * findArgument (ActionReply &r, const char *name)
 
ActionRequestcreateBrowseAction (DLNAServiceInfo &svc, const char *browseFlag, int startingIndex, int requestedCount)
 Build a Browse ActionRequest.
 
void parseNumericFields (ActionReply &reply, int &numberReturned, int &totalMatches, int &updateID)
 Parse numeric result fields from an ActionReply.
 
void processResult (const char *resultXml, ItemCallback itemCallback)
 Parse DIDL-Lite Result and invoke callback for each item.
 

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

DLNAControlPointMgrmgr
 
int device_index = 0
 
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"
 

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

◆ ItemCallback

typedef void(* tiny_dlna::ControlPointMediaServer::ItemCallback) (const MediaItem &item, void *ref)

◆ NotificationCallback

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

Constructor & Destructor Documentation

◆ ControlPointMediaServer()

tiny_dlna::ControlPointMediaServer::ControlPointMediaServer ( DLNAControlPointMgr mgr)
inline

Construct helper with reference to control point manager.

Parameters
mgrReference to DLNAControlPointMgr used to send actions and manage discovery/subscriptions

Member Function Documentation

◆ begin()

bool tiny_dlna::ControlPointMediaServer::begin ( DLNAHttpRequest http,
IUDPService udp,
uint32_t  minWaitMs = 3000,
uint32_t  maxWaitMs = 60000 
)
inline

Begin discovery and processing (forwards to underlying control point)

Parameters
httpHttp server wrapper used for subscription callbacks
udpUDP service used for SSDP discovery
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::ControlPointMediaServer::browse ( int  startingIndex,
int  requestedCount,
ItemCallback  itemCallback,
int &  numberReturned,
int &  totalMatches,
int &  updateID,
const char *  browseFlag = nullptr 
)
inline

Browse the given object_id and invoke callback for each returned item.

Parameters
startingIndexStarting index for the browse request
requestedCountNumber of items requested
itemCallbackCallback 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::ControlPointMediaServer::createBrowseAction ( DLNAServiceInfo svc,
const char *  browseFlag,
int  startingIndex,
int  requestedCount 
)
inlineprotected

Build a Browse ActionRequest.

◆ findArgument()

const char * tiny_dlna::ControlPointMediaServer::findArgument ( ActionReply r,
const char *  name 
)
inlineprotected

◆ getDeviceCount()

int tiny_dlna::ControlPointMediaServer::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::ControlPointMediaServer::getLastReply ( ) const
inline

Return the ActionReply from the last synchronous request.

Returns
reference to the last ActionReply

◆ getObjectID()

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

Return the current object id used for browse.

Returns
C-string object id

◆ getProtocolInfo()

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

Query ConnectionManager:GetProtocolInfo.

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

◆ getSearchCapabilities()

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

Get the ContentDirectory SearchCapabilities string.

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

◆ getSortCapabilities()

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

Get the ContentDirectory SortCapabilities string.

Returns
pointer to sort capabilities, or nullptr on error

◆ getSystemUpdateID()

int tiny_dlna::ControlPointMediaServer::getSystemUpdateID ( )
inline

Get current SystemUpdateID for the ContentDirectory.

Returns
numeric SystemUpdateID, or -1 on error

◆ parseNumericFields()

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

Parse numeric result fields from an ActionReply.

◆ processNotification()

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

Notification callback: just log for now.

◆ processResult()

void tiny_dlna::ControlPointMediaServer::processResult ( const char *  resultXml,
ItemCallback  itemCallback 
)
inlineprotected

Parse DIDL-Lite Result and invoke callback for each item.

◆ selectService()

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

Select service by id.

◆ setDeviceIndex()

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

Select a device by index (0-based) for subsequent actions.

Parameters
idxDevice index

◆ setDeviceTypeFilter()

void tiny_dlna::ControlPointMediaServer::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

◆ setObjectID()

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

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

Parameters
idC-string object id

◆ setReference()

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

Attach an opaque reference pointer passed to callbacks.

Parameters
refOpaque user pointer

◆ subscribeNotifications()

bool tiny_dlna::ControlPointMediaServer::subscribeNotifications ( int  timeoutSeconds = 60,
NotificationCallback  cb = nullptr 
)
inline

Subscribe to event notifications for the selected server/device.

Parameters
timeoutSecondsSubscription timeout in seconds (default: 60)
cbOptional notification callback; if nullptr the default processNotification will be used
Returns
true on successful SUBSCRIBE, false otherwise

Member Data Documentation

◆ device_index

int tiny_dlna::ControlPointMediaServer::device_index = 0
protected

◆ device_type_filter

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

◆ device_type_filter_default

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

◆ last_reply

ActionReply tiny_dlna::ControlPointMediaServer::last_reply
protected

◆ mgr

DLNAControlPointMgr& tiny_dlna::ControlPointMediaServer::mgr
protected

◆ object_id

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

◆ reference

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

◆ strings

StringRegistry tiny_dlna::ControlPointMediaServer::strings
protected

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