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


Public Types | |
| typedef void(* | MediaEventHandler) (MediaEvent event, MediaRenderer &renderer) |
Public Member Functions | |
| MediaRenderer () | |
| Default constructor. | |
| void | setMediaEventHandler (MediaEventHandler cb) |
| Register a media event handler callback. | |
| bool | setVolume (uint8_t volumePercent) |
| Set the renderer volume (0..100 percent) | |
| uint8_t | getVolume () |
| Get current volume (0..100 percent) | |
| bool | setMute (bool mute) |
| Enable or disable mute. | |
| bool | isMuted () |
| Query mute state. | |
| bool | isActive () |
| Query whether renderer is active (playing or ready) | |
| void | setActive (bool active) |
| Set the active state (used by transport callbacks) | |
| unsigned long | getPosition () |
| Get estimated playback position (ms) | |
| const char * | getMime () |
| Provides the mime from the DIDL or nullptr. | |
| const char * | getCurrentUri () |
| const char * | getTransportState () |
| Get textual transport state. | |
Public Member Functions inherited from tiny_dlna::DLNADeviceInfo | |
| DLNADeviceInfo (bool ok=true) | |
| ~DLNADeviceInfo () | |
| virtual bool | begin () |
| Override to initialize the device. | |
| void | print (Print &out) |
| renderes 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="") |
| 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 | setUniveralProductCode (const char *upc) |
| const char * | getUniveralProductCode () |
| void | addService (DLNAServiceInfo s) |
| Adds a service defintion. | |
| DLNAServiceInfo & | getService (const char *id) |
| Finds a service definition by name. | |
| Vector< DLNAServiceInfo > & | getServices () |
| void | clear () |
| void | clearIcons () |
| Overwrite the default icon. | |
| void | addIcon (Icon icon) |
| Icon | getIcon (int idx=0) |
| operator bool () | |
| void | updateTimestamp () |
| Update the timestamp. | |
| uint32_t | getTimestamp () |
| Returns the time when this object has been updated. | |
| void | setActive (bool flag) |
| virtual void | loop () |
Protected Member Functions | |
| void | setupServices (HttpServer &server, IUDPService &udp) |
| Setup the HTTP and UDP services. | |
| bool | play (const char *urlStr) |
| Start playback of a network resource (returns true on success) | |
| void | setMime (const char *mime) |
| Set MIME explicitly (used when DIDL-Lite metadata provides protocolInfo) | |
| void | playbackCompleted () |
| Notify the renderer that playback completed. | |
| void | setMimeFromDIDL (const char *didl) |
| void | setupServicesImpl (HttpServer *server) |
Protected Member Functions inherited from tiny_dlna::DLNADeviceInfo | |
| 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 const char * | reply () |
| static void | transportControlCB (HttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
| static void | renderingControlCB (HttpServer *server, const char *requestPath, HttpRequestHandlerLine *hl) |
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 |
| bool | is_active = false |
| unsigned long | start_time = 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" |
Protected Attributes inherited from tiny_dlna::DLNADeviceInfo | |
| uint64_t | timestamp = 0 |
| 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::MediaRenderer::MediaEventHandler) (MediaEvent event, MediaRenderer &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 |
|
inline |
Provides the mime from the DIDL or nullptr.
|
inline |
Get estimated playback position (ms)
|
inline |
Get textual transport state.
|
inline |
Get current volume (0..100 percent)
|
inline |
Query whether renderer is active (playing or ready)
|
inline |
Query mute state.
|
inlineprotected |
Start playback of a network resource (returns true on success)
|
inlineprotected |
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.).
|
inlinestaticprotected |
|
inlinestaticprotected |
|
inline |
Set the active state (used by transport callbacks)
|
inline |
Register a media event handler callback.
|
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.
|
inline |
Enable or disable mute.
|
inlineprotectedvirtual |
Setup the HTTP and UDP services.
Reimplemented from tiny_dlna::DLNADeviceInfo.
|
inlineprotected |
|
inline |
Set the renderer volume (0..100 percent)
|
inlinestaticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |