|
Arduino DLNA Server
|
Setup of a Basic DLNA Device service. The device registers itself to the network and answers to the DLNA queries and requests. A DLNA device uses UDP, Http, XML and Soap to discover and manage a service, so there is quite some complexity involved: More...
#include <DLNADevice.h>

Public Member Functions | |
| DLNADevice () | |
| bool | begin (DLNADeviceInfo &device, IUDPService &udp, IHttpServer &server) override |
| start the | |
| ISubscriptionMgrDevice & | getSubscriptionMgr () override |
| Get subscription manager for event handling. | |
| void | end () override |
| Stops the processing and releases the resources. | |
| bool | loop (int loopAction=RUN_ALL) override |
| int | loopPublishSubscriptions () |
| Publish pending subscription notifications. | |
| bool | loopServer () override |
| Process http server loop. | |
| int | loopUDPMessages () |
| Process incoming UDP and execute scheduled replies. | |
| DLNAServiceInfo & | getService (const char *id) override |
| Provide addess to the service information. | |
| DLNAServiceInfo & | getServiceByAbbrev (const char *abbrev) override |
| Get Service by subscription ns abbrev. | |
| DLNAServiceInfo * | getServiceByEventPath (const char *requestPath) override |
| void | addChange (const char *serviceAbbrev, std::function< size_t(Print &, void *)> changeWriter, void *ref) override |
| Record a state variable change for subscription notifications. | |
| DLNADeviceInfo & | getDeviceInfo () override |
| Provides the device. | |
| void | setSchedulerActive (bool flag) override |
| We can activate/deactivate the scheduler. | |
| bool | isSchedulerActive () override |
| Checks if the scheduler is active. | |
| void | setPostAliveRepeatMs (uint32_t ms) override |
| void | setSubscriptionsActive (bool flag) override |
| Enable or disable subscription notifications: call before begin. | |
| bool | isSubscriptionsActive () const override |
| Check if subscription notifications are active. | |
| void | setReference (void *ref) override |
| Sets a reference pointer that can be used to associate application. | |
| void * | getReference () override |
| Gets the reference pointer. | |
| void | logStatus () |
Static Public Member Functions | |
| static void | parseActionRequest (IHttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl, ActionRequest &action) |
| Parses the SOAP content of a DLNA action request. | |
| static size_t | printReplyXML (Print &out, const char *replyName, const char *serviceId, std::function< size_t(Print &, void *)> valuesWriter=nullptr, void *ref=nullptr) |
| Builds a standard SOAP reply envelope. | |
| static size_t | replyGetProtocolInfo (Print &out, const char *source="", const char *sink="") |
| static size_t | replyGetCurrentConnectionIDs (Print &out, const char *ids) |
| static size_t | replyGetCurrentConnectionInfo (Print &out, const char *protocolInfo, const char *connectionID, const char *direction) |
| static bool | handleSubscription (IHttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl, bool &is_subscribe) |
| Static handler for SUBSCRIBE/UNSUBSCRIBE requests on service event URLs. | |
Protected Member Functions | |
| void | setDeviceInfo (DLNADeviceInfo &device) |
| void | setSchedulerIntervalMs (uint32_t ms) |
| Set scheduler interval in milliseconds. | |
| uint32_t | getSchedulerIntervalMs () const |
| Get scheduler interval in milliseconds. | |
| void | setSubscriptionsIntervalMs (uint32_t ms) |
| Set subscription publish interval in milliseconds. | |
| uint32_t | getSubscriptionsIntervalMs () const |
| Get subscription publish interval in milliseconds. | |
| void | logScheduledStatus (bool runImmediately=false) |
| bool | setupParser () |
| bool | setupScheduler () |
| Schedule PostAlive messages. | |
| bool | validateServiceInfo (const DLNAServiceInfo &service) |
| Validates that all required service URLs and callbacks are defined. | |
| virtual bool | setupDLNAServer (IHttpServer &srv) |
| set up Web Server to handle Service Addresses | |
Static Protected Member Functions | |
| static void | deviceXMLCallback (IHttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
| callback to provide device XML | |
| static bool | handleSubscribe (IHttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
| Handle SUBSCRIBE requests. | |
| static bool | handleUnsubscribe (IHttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
| Handle UNSUBSCRIBE requests. | |
Protected Attributes | |
| bool | is_active = false |
| bool | is_subscriptions_active = true |
| uint32_t | post_alive_repeat_ms = 0 |
| Scheduler | scheduler |
| SubscriptionMgrDevice< ClientType > | subscription_mgr |
| DLNADeviceRequestParser | parser |
| DLNADeviceInfo * | p_device_info = nullptr |
| IUDPService * | p_udp = nullptr |
| IHttpServer * | p_server = nullptr |
| uint64_t | scheduler_interval_ms = (uint64_t)DLNA_RUN_SCHEDULER_EVERY_MS |
| uint64_t | subscriptions_interval_ms |
| uint64_t | next_scheduler_timeout_ms = 0 |
| uint64_t | next_subscriptions_timeout_ms = 0 |
| void * | reference = nullptr |
Setup of a Basic DLNA Device service. The device registers itself to the network and answers to the DLNA queries and requests. A DLNA device uses UDP, Http, XML and Soap to discover and manage a service, so there is quite some complexity involved:
The template parameter selects the HTTP client implementation (for example WiFiClient) that will be used by all internal helpers; choose the one that matches your platform.
| ClientType | Arduino Client implementation used for outbound HTTP traffic (e.g. WiFiClient, EthernetClient). |
|
inline |
|
inlineoverridevirtual |
Record a state variable change for subscription notifications.
Implements tiny_dlna::IDevice.
|
inlineoverridevirtual |
start the
Implements tiny_dlna::IDevice.
|
inlinestaticprotected |
callback to provide device XML
|
inlineoverridevirtual |
Stops the processing and releases the resources.
Implements tiny_dlna::IDevice.
|
inlineoverridevirtual |
Provides the device.
Implements tiny_dlna::IDevice.
|
inlineoverridevirtual |
Gets the reference pointer.
Implements tiny_dlna::IDevice.
|
inlineprotected |
Get scheduler interval in milliseconds.
|
inlineoverridevirtual |
Provide addess to the service information.
Implements tiny_dlna::IDevice.
|
inlineoverridevirtual |
Get Service by subscription ns abbrev.
Implements tiny_dlna::IDevice.
|
inlineoverridevirtual |
Find a service by its event subscription URL (returns nullptr if not found). This encapsulates the lookup that was previously done inline in the static subscription handler.
Implements tiny_dlna::IDevice.
|
inlineoverridevirtual |
Get subscription manager for event handling.
Implements tiny_dlna::IDevice.
|
inlineprotected |
Get subscription publish interval in milliseconds.
|
inlinestaticprotected |
Handle SUBSCRIBE requests.
|
inlinestatic |
Static handler for SUBSCRIBE/UNSUBSCRIBE requests on service event URLs.
|
inlinestaticprotected |
Handle UNSUBSCRIBE requests.
|
inlineoverridevirtual |
Checks if the scheduler is active.
Implements tiny_dlna::IDevice.
|
inlineoverridevirtual |
Check if subscription notifications are active.
Implements tiny_dlna::IDevice.
|
inlineprotected |
Periodic platform-specific diagnostics. Kept as a separate method so it can be tested or stubbed easily. Currently logs ESP32 heap/psram every 10s.
|
inline |
|
inlineoverridevirtual |
Call this method in the Arduino loop as often as possible. It calls loopServer, loopUDP and loopPublishSubscriptions in defined intervals..
Implements tiny_dlna::IDevice.
|
inline |
Publish pending subscription notifications.
|
inlineoverridevirtual |
Process http server loop.
Implements tiny_dlna::IDevice.
|
inline |
Process incoming UDP and execute scheduled replies.
|
inlinestatic |
Parses the SOAP content of a DLNA action request.
|
inlinestatic |
Builds a standard SOAP reply envelope.
This helper prints a SOAP envelope and calls the provided valuesWriter to emit the inner XML fragment. The valuesWriter receives the output Print and a void* ref for caller-provided context and shall return the number of bytes written.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Parameterized variants that allow callers to pass dynamic values from devices (e.g. source/sink protocol lists or current connection IDs).
|
inlineprotected |
|
inlineoverridevirtual |
Repeat the post-alive messages (default: 0 = no repeat). Call this method before calling begin!
Implements tiny_dlna::IDevice.
|
inlineoverridevirtual |
Sets a reference pointer that can be used to associate application.
Implements tiny_dlna::IDevice.
|
inlineoverridevirtual |
We can activate/deactivate the scheduler.
Implements tiny_dlna::IDevice.
|
inlineprotected |
Set scheduler interval in milliseconds.
|
inlineoverridevirtual |
Enable or disable subscription notifications: call before begin.
Implements tiny_dlna::IDevice.
|
inlineprotected |
Set subscription publish interval in milliseconds.
|
inlineprotectedvirtual |
set up Web Server to handle Service Addresses
|
inlineprotected |
MSearch requests reply to upnp:rootdevice and the device type defined in the device
|
inlineprotected |
Schedule PostAlive messages.
|
inlineprotected |
Validates that all required service URLs and callbacks are defined.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |