|
Arduino DLNA Server
|
MediaRenderer DLNA Device. More...
#include <DLNAMediaRenderer.h>

Public Types | |
| typedef void(* | MediaEventHandler) (MediaEvent event, DLNAMediaRenderer &renderer) |
Public Member Functions | |
| DLNAMediaRenderer () | |
| Default constructor. | |
| DLNAMediaRenderer (HttpServer &server, IUDPService &udp) | |
| Recommended constructor Construct a MediaRenderer bound to an HttpServer and IUDPService. The provided references are stored and used when calling begin(). | |
| bool | begin () |
| Override to initialize the device. | |
| void | end () |
| Stops processing and releases resources. | |
| bool | loop () |
| Call this from Arduino loop() | |
| void | setHttpServer (HttpServer &server) |
| Set the http server instance the MediaRenderer should use. | |
| void | setUdpService (IUDPService &udp) |
| Set the UDP service instance the MediaRenderer should use. | |
| bool | isActive () |
| Query whether renderer is active (playing) | |
| void | setActive (bool active) |
| Set the active state (used by transport callbacks) | |
| const char * | getMime () |
| Provides the mime from the DIDL or nullptr. | |
| void | setMediaEventHandler (MediaEventHandler cb) |
| Register application event handler. | |
| uint8_t | getVolume () |
| Get current volume (0-255) | |
| void | setVolume (uint8_t vol) |
| Set volume and publish event. | |
| bool | isMuted () |
| Query mute state. | |
| void | setMuted (bool m) |
| Set mute state and publish event. | |
| const char * | getCurrentUri () |
| const char * | getTransportState () |
| Get textual transport state. | |
| DLNADevice & | device () |
| Provides access to the internal DLNA device instance. | |
| bool | play () |
| Start playback: same as setActive(true) | |
| bool | play (const char *urlStr) |
| Start playback of a network resource (returns true on success) | |
| bool | setPlaybackURL (const char *urlStr) |
| Defines the actual url to play. | |
| bool | stop () |
| Stop playback. | |
| void | setPlaybackCompleted () |
| Notify the renderer that playback completed. | |
| size_t | getRelativeTimePositionSec () |
| Get estimated playback position (seconds) | |
| void | publishGetRelativeTimePositionSec () |
| Publish the RelativeTimePosition property. | |
| const char * | getCurrentTransportActions () |
| Get a csv of the valid actions. | |
| void | setCustomActionRule (const char *suffix, bool(*handler)(DLNAMediaRenderer *, ActionRequest &, HttpServer &)) |
| Defines a custom action rule for the media renderer. | |
| void | print (Print &out) |
| renders the device xml | |
| void | setDeviceType (const char *st) |
| const char * | getDeviceType () |
| void | setUDN (const char *id) |
| Define the udn uuid. | |
| const char * | getUDN () |
| Provide the udn uuid. | |
| void | setBaseURL (const char *url) |
| Defines the base url. | |
| void | setBaseURL (IPAddress ip, int port, const char *path=nullptr) |
| Defines the base URL. | |
| const char * | getBaseURL () |
| Provides the base url. | |
| Url & | getDeviceURL () |
| This method returns base url/device.xml. | |
| void | setIPAddress (IPAddress address) |
| Defines the local IP address. | |
| IPAddress | getIPAddress () |
| Provides the local IP address. | |
| const char * | getIPStr () |
| Provides the local address as string. | |
| void | setNS (const char *ns) |
| const char * | getNS () |
| void | setFriendlyName (const char *name) |
| const char * | getFriendlyName () |
| void | setManufacturer (const char *man) |
| const char * | getManufacturer () |
| void | setManufacturerURL (const char *url) |
| const char * | getManufacturerURL () |
| void | setModelDescription (const char *descr) |
| const char * | getModelDescription () |
| void | setModelName (const char *name) |
| const char * | getModelName () |
| void | setModelNumber (const char *number) |
| const char * | getModelNumber () |
| void | setSerialNumber (const char *sn) |
| const char * | getSerialNumber () |
| void | setUniversalProductCode (const char *upc) |
| const char * | getUniversalProductCode () |
| void | addService (DLNAServiceInfo s) |
| Adds a service definition. | |
| DLNAServiceInfo & | getService (const char *id) |
| Finds a service definition by name. | |
| DLNAServiceInfo & | getServiceByAbbrev (const char *abbrev) |
| Finds a service definition by name. | |
| Vector< DLNAServiceInfo > & | getServices () |
| Provides all service definitions. | |
| void | clear () |
| Clears all device information. | |
| void | clearIcons () |
| Overwrite the default icon. | |
| void | addIcon (Icon icon) |
| adds an icon | |
| Icon | getIcon (int idx=0) |
| Provides the item at indix. | |
| operator bool () | |
| return true if active | |
Protected Member Functions | |
| void | publishProperty (const char *serviceAbbrev, const char *changeTag) |
| serviceAbbrev: AVT, RCS, CMS | |
| void | publishAVT () |
| void | publishRCS () |
| Publish the current RenderingControl state (Volume, Mute) | |
| void | publishCMS () |
| Publish a minimal ConnectionManager state (CurrentConnectionIDs) | |
| void | setMime (const char *mime) |
| Set MIME explicitly (used when DIDL-Lite metadata provides protocolInfo) | |
| void | setMimeFromDIDL (const char *didl) |
| void | setupTransportService (HttpServer *server) |
| void | setupConnectionManagerService (HttpServer *server) |
| void | setupRenderingControlService (HttpServer *server) |
| void | setupServicesImpl (HttpServer *server) |
| Register all services (called when HTTP server is set) | |
| bool | processAction (ActionRequest &action, HttpServer &server) |
| Process parsed SOAP ActionRequest and dispatch to appropriate handler. | |
| void | setupRules () |
| Setup the action handling rules. | |
| virtual void | setupServices (HttpServer &server, IUDPService &udp) |
| to be implemented by subclasses | |
| size_t | printRoot () |
| size_t | printDevice () |
| size_t | printSpecVersion () |
| size_t | printServiceList () |
| size_t | printService (void *srv) |
| size_t | printIconList () |
| size_t | printIconDlnaInfo (Icon &icon) |
Static Protected Member Functions | |
| static void | transportDescrCB (HttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
| static void | connmgrDescrCB (HttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
| static void | controlDescrCB (HttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
| static void | controlCB (HttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
| static void | eventSubscriptionHandler (HttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
| After the subscription we publish all relevant properties. | |
| static int | printReplyXML (Print &out, const char *replyName, const char *serviceId, const char *values=nullptr) |
| Builds a standard SOAP reply envelope. | |
| static size_t | replyPlay (Print &out) |
| static size_t | replyPause (Print &out) |
| static size_t | replyStop (Print &out) |
| static size_t | replySetAVTransportURI (Print &out) |
| static size_t | replySetVolume (Print &out) |
| static size_t | replySetMute (Print &out) |
| static size_t | replyGetMute (Print &out, bool isMuted) |
| static size_t | replyGetVolume (Print &out, uint8_t volume) |
Protected Attributes | |
| tiny_dlna::Str | current_uri |
| tiny_dlna::Str | current_mime |
| MediaEventHandler | event_cb = nullptr |
| uint8_t | current_volume = 50 |
| bool | is_muted = false |
| unsigned long | start_time = 0 |
| unsigned long | time_sum = 0 |
| tiny_dlna::Str | transport_state = "NO_MEDIA_PRESENT" |
| const char * | st = "urn:schemas-upnp-org:device:MediaRenderer:1" |
| const char * | usn = "uuid:09349455-2941-4cf7-9847-1dd5ab210e97" |
| DLNADevice | dlna_device |
| HttpServer * | p_server = nullptr |
| IUDPService * | p_udp_member = nullptr |
| void * | ref_ctx [1] = {nullptr} |
| Vector< ActionRule > | rules |
| bool | is_active = true |
| XMLPrinter | xml |
| Url | device_url |
| IPAddress | localhost |
| int | version_major = 1 |
| int | version_minor = 0 |
| const char * | base_url = "http://localhost:9876/dlna" |
| const char * | udn = "uuid:09349455-2941-4cf7-9847-0dd5ab210e97" |
| const char * | ns = "xmlns=\"urn:schemas-upnp-org:device-1-0\"" |
| const char * | device_type = nullptr |
| const char * | friendly_name = nullptr |
| const char * | manufacturer = nullptr |
| const char * | manufacturer_url = nullptr |
| const char * | model_description = nullptr |
| const char * | model_name = nullptr |
| const char * | model_url = nullptr |
| const char * | model_number = nullptr |
| const char * | serial_number = nullptr |
| const char * | universal_product_code = nullptr |
| Icon | icon |
| Vector< DLNAServiceInfo > | services |
| Vector< Icon > | icons |
| Str | url_str |
MediaRenderer DLNA Device.
MediaRenderer implements a simple UPnP/DLNA Media Renderer device. It receives stream URIs via UPnP AVTransport actions and delegates actual playback and rendering to the application through an event callback API. This removes any dependency on an internal audio stack: applications handle playback themselves by registering a handler with setMediaEventHandler(). The device still supports rendering controls (volume, mute) and transport controls (play/pause/stop) and provides helper accessors like getCurrentUri() and getMime().
Usage summary:
This class is intentionally small and Arduino-friendly: methods return bool for success/failure and avoid heavy dynamic memory allocations in the hot path.
Author: Phil Schatzmann
| typedef void(* tiny_dlna::DLNAMediaRenderer::MediaEventHandler) (MediaEvent event, DLNAMediaRenderer &renderer) |
|
inline |
Default constructor.
Initializes device metadata (friendly name, manufacturer, model) and sets default base URL and identifiers. It does not configure any audio pipeline components; use setOutput() and setDecoder() for that.
|
inline |
Recommended constructor Construct a MediaRenderer bound to an HttpServer and IUDPService. The provided references are stored and used when calling begin().
|
inlineinherited |
adds an icon
|
inlineinherited |
Adds a service definition.
|
inlinevirtual |
Override to initialize the device.
Reimplemented from tiny_dlna::DLNADeviceInfo.
|
inlineinherited |
Clears all device information.
|
inlineinherited |
Overwrite the default icon.
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inline |
Provides access to the internal DLNA device instance.
|
inline |
Stops processing and releases resources.
|
inlinestaticprotected |
After the subscription we publish all relevant properties.
|
inlineinherited |
Provides the base url.
|
inline |
Get a csv of the valid actions.
|
inline |
|
inlineinherited |
|
inlineinherited |
This method returns base url/device.xml.
|
inlineinherited |
|
inlineinherited |
Provides the item at indix.
|
inlineinherited |
Provides the local IP address.
|
inlineinherited |
Provides the local address as string.
|
inlineinherited |
|
inlineinherited |
|
inline |
Provides the mime from the DIDL or nullptr.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inline |
Get estimated playback position (seconds)
|
inlineinherited |
|
inlineinherited |
Finds a service definition by name.
|
inlineinherited |
Finds a service definition by name.
|
inlineinherited |
Provides all service definitions.
|
inline |
Get textual transport state.
|
inlineinherited |
Provide the udn uuid.
|
inlineinherited |
|
inline |
Get current volume (0-255)
|
inline |
Query whether renderer is active (playing)
|
inline |
Query mute state.
|
inlinevirtual |
Call this from Arduino loop()
Reimplemented from tiny_dlna::DLNADeviceInfo.
|
inlineinherited |
return true if active
|
inline |
Start playback: same as setActive(true)
|
inline |
Start playback of a network resource (returns true on success)
|
inlineinherited |
renders the device xml
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlinestaticprotected |
Builds a standard SOAP reply envelope.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineprotected |
Process parsed SOAP ActionRequest and dispatch to appropriate handler.
| action | Parsed ActionRequest |
| server | HttpServer for reply |
|
inlineprotected |
Publish the current AVTransport state (TransportState, CurrentTrackURI, RelativeTimePosition, CurrentTransportActions)
|
inlineprotected |
Publish a minimal ConnectionManager state (CurrentConnectionIDs)
|
inline |
Publish the RelativeTimePosition property.
|
inlineprotected |
serviceAbbrev: AVT, RCS, CMS
|
inlineprotected |
Publish the current RenderingControl state (Volume, Mute)
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inline |
Set the active state (used by transport callbacks)
|
inlineinherited |
Defines the base url.
|
inlineinherited |
Defines the base URL.
|
inline |
Defines a custom action rule for the media renderer.
|
inlineinherited |
|
inlineinherited |
|
inline |
Set the http server instance the MediaRenderer should use.
|
inlineinherited |
Defines the local IP address.
|
inlineinherited |
|
inlineinherited |
|
inline |
Register application event handler.
|
inlineprotected |
Set MIME explicitly (used when DIDL-Lite metadata provides protocolInfo)
|
inlineprotected |
Try to parse a DIDL-Lite snippet and extract the protocolInfo MIME from the <res> element. If found, set current_mime.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inline |
Set mute state and publish event.
|
inlineinherited |
|
inline |
Notify the renderer that playback completed.
This helper updates the internal transport state to "STOPPED", marks the renderer inactive, resets the start time, logs the event and notifies the application event handler with MediaEvent::STOP so the application can perform cleanup (release resources, update UI, etc.).
|
inline |
Defines the actual url to play.
|
inlineinherited |
|
inlineinherited |
Define the udn uuid.
|
inline |
Set the UDP service instance the MediaRenderer should use.
|
inlineinherited |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
Setup the action handling rules.
|
inlineprotectedvirtualinherited |
to be implemented by subclasses
|
inlineprotected |
Register all services (called when HTTP server is set)
|
inlineprotected |
|
inline |
Set volume and publish event.
|
inline |
Stop playback.
|
inlinestaticprotected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |