|
Arduino DLNA Server
|
Class to control a MediaRenderer device from a control point. More...
#include <DLNAControlPointMediaRenderer.h>
Public Types | |
| typedef void(* | NotificationCallback) (void *reference, const char *sid, const char *varName, const char *newValue) |
Public Member Functions | |
| DLNAControlPointMediaRenderer ()=default | |
| Default constructor. | |
| DLNAControlPointMediaRenderer (DLNAControlPoint &m, DLNAHttpRequest &http, IUDPService &udp) | |
| Construct helper with references to control point manager and transport instances. | |
| void | setDLNAControlPoint (DLNAControlPoint &m) |
| Set the control point manager instance (required before using helper) | |
| void | setDeviceTypeFilter (const char *filter) |
| Restrict this helper to devices of the given device type. | |
| bool | begin (uint32_t minWaitMs=3000, uint32_t maxWaitMs=60000) |
| Begin discovery and processing. | |
| int | getDeviceCount () |
| Return the number of discovered devices matching the renderer filter. | |
| void | setDeviceIndex (int idx) |
| Select the active renderer by index (0-based) | |
| 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) | |
| void | setSubscribeNotificationsActive (bool flag) |
| Activate/deactivate subscription notifications. | |
| void | setInstanceID (const char *id) |
| Set the InstanceID used for AVTransport and RenderingControl actions. | |
| bool | setMediaURI (const char *uri) |
| Set the media URI on the renderer. | |
| bool | play () |
| Start playback on the renderer. | |
| bool | play (const char *uri) |
| Set the media URI and start playback. | |
| bool | pause () |
| Pause playback. | |
| bool | stop () |
| Stop playback. | |
| bool | setVolume (int volumePercent) |
| Set renderer volume. | |
| bool | setMute (bool mute) |
| Set mute state on the renderer. | |
| int | getVolume (bool fromRemote=true) |
| Query the current volume from the renderer. | |
| int | getMute (bool fromRemote=true) |
| Query mute state. | |
| unsigned long | getPositionMs () |
| Query current playback position (RelTime) | |
| const char * | getTransportState (bool fromRemote=true) |
| Query transport state (e.g. STOPPED, PLAYING, PAUSED_PLAYBACK). | |
| const char * | getCurrentURI (bool fromRemote=true) |
| Get the current media URI from the renderer. | |
| int | getNrTracks () |
| Get number of tracks in the current media. | |
| unsigned long | getMediaDurationMs () |
| Get total media duration in milliseconds (from MediaDuration) | |
| int | getTrackIndex () |
| Get current track index (from GetPositionInfo) | |
| unsigned long | getTrackDurationMs () |
| Get current track duration in milliseconds (from TrackDuration) | |
| const ActionReply & | getLastReply () const |
| Return last ActionReply (from the most recent synchronous call) | |
| bool | isActive () |
| Query if the helper considers the renderer to be actively playing. | |
| void | setReference (void *ref) |
| Attach an opaque reference object that will be passed to callbacks. | |
| void | onActiveChanged (std::function< void(bool, void *)> cb) |
| Register a callback invoked when the active (playing) state changes. | |
| bool | getCurrentTransportActions (Str &out) |
Query the AVTransport service for the current transport actions and return the raw Actions list into out. | |
| bool | getProtocalInfo (std::function< void(const char *entry, ProtocolRole role)> cb) |
| Fetch protocol-info via SOAP GetProtocolInfo on the ConnectionManager service and invoke cb for each entry. | |
Protected Member Functions | |
| void | setActiveState (bool s) |
| DLNAServiceInfo & | selectService (const char *id) |
| Select service by id. | |
Static Protected Member Functions | |
| static void | processNotification (void *reference, const char *sid, const char *varName, const char *newValue) |
| Notification callback. | |
| static unsigned long | parseTimeToMs (const char *t) |
Protected Attributes | |
| DLNAControlPoint * | p_mgr = nullptr |
| bool | is_active = false |
| std::function< void(bool, void *)> | activeChangedCallback = nullptr |
| int | device_index = 0 |
| const char * | instance_id = "0" |
| const char * | device_type_filter_default |
| const char * | device_type_filter = device_type_filter_default |
| ActionReply | last_reply |
| void * | reference = nullptr |
| DLNAHttpRequest * | p_http = nullptr |
| IUDPService * | p_udp = nullptr |
| int | local_volume = 0 |
| int | local_mute = false |
| Str | local_url |
| const char * | local_transport_state = "STOPPED" |
Class to control a MediaRenderer device from a control point.
This lightweight implementation uses the DLNAControlPointMgr action API to send common AVTransport and RenderingControl actions to the first MediaRenderer service discovered. It is intentionally minimal and returns boolean success/failure for each operation. Some getters can be configured to provide the cached value quickly or by using a query to the MediaRenderer.
| typedef void(* tiny_dlna::DLNAControlPointMediaRenderer::NotificationCallback) (void *reference, const char *sid, const char *varName, const char *newValue) |
|
default |
Default constructor.
|
inline |
Construct helper with references to control point manager and transport instances.
This convenience constructor binds the underlying DLNAControlPoint manager as well as the HTTP wrapper (used for subscription callbacks) and the UDP service (used for SSDP discovery). It is equivalent to default-constructing the helper and then calling setDLNAControlPoint(), setHttp() and setUdp(), but more concise for callers that already have the instances available.
| m | Reference to the DLNAControlPoint manager |
| http | Reference to an HTTP request wrapper used for subscriptions |
| udp | Reference to a UDP service used for SSDP discovery |
|
inline |
Begin discovery and processing.
| http | Http server wrapper used for subscription callbacks |
| udp | UDP service used for SSDP discovery |
| minWaitMs | Minimum time in milliseconds to wait before returning |
| maxWaitMs | Maximum time in milliseconds to wait for discovery |
|
inline |
Query the AVTransport service for the current transport actions and return the raw Actions list into out.
| out | Str reference that will receive the Actions text on success |
|
inline |
Get the current media URI from the renderer.
| fromRemote | If true (default) query the renderer remotely for the current URI. If false, return the locally cached URI previously set by this helper. |
|
inline |
Return the number of discovered devices matching the renderer filter.
|
inline |
Return last ActionReply (from the most recent synchronous call)
|
inline |
Get total media duration in milliseconds (from MediaDuration)
|
inline |
Query mute state.
| fromRemote | If true (default) query the renderer for the current mute state; if false, return the locally cached mute value maintained by the helper. |
|
inline |
Get number of tracks in the current media.
|
inline |
Query current playback position (RelTime)
|
inline |
Fetch protocol-info via SOAP GetProtocolInfo on the ConnectionManager service and invoke cb for each entry.
| cb | callback invoked for each parsed entry with role (IsSource/IsSink) |
|
inline |
Get current track duration in milliseconds (from TrackDuration)
|
inline |
Get current track index (from GetPositionInfo)
|
inline |
Query transport state (e.g. STOPPED, PLAYING, PAUSED_PLAYBACK).
| fromRemote | If true (default) the helper will query the remote renderer for its current transport state. If false, the cached local transport state is returned. |
|
inline |
Query the current volume from the renderer.
| fromRemote | If true (default) the helper will perform an RPC query against the remote renderer to obtain the current volume. If false, the method returns the locally cached value maintained by the helper. |
|
inline |
Query if the helper considers the renderer to be actively playing.
|
inline |
Register a callback invoked when the active (playing) state changes.
| cb | Function taking (bool active, void* reference). 'reference' is the pointer set via setReference(). |
|
inlinestaticprotected |
|
inline |
Pause playback.
|
inline |
Start playback on the renderer.
|
inline |
Set the media URI and start playback.
| uri | URI to play |
|
inlinestaticprotected |
Notification callback.
|
inlineprotected |
Select service by id.
|
inlineprotected |
|
inline |
Select the active renderer by index (0-based)
| idx | Index of the device to select; defaults to 0 |
|
inline |
Restrict this helper to devices of the given device type.
| filter | Device type filter, e.g. "urn:schemas-upnp-org:device:MediaRenderer:1". Pass nullptr to use the default MediaRenderer filter. |
|
inline |
Set the control point manager instance (required before using helper)
|
inline |
Setter for the HTTP wrapper used for subscriptions and callbacks.
|
inline |
Set the InstanceID used for AVTransport and RenderingControl actions.
| id | C-string InstanceID (default is "0") |
|
inline |
Set the media URI on the renderer.
| uri | The media URI to play on the renderer |
|
inline |
Set mute state on the renderer.
| mute | true to mute, false to unmute |
|
inline |
Attach an opaque reference object that will be passed to callbacks.
| ref | Opaque pointer provided by the caller |
|
inline |
Activate/deactivate subscription notifications.
|
inline |
Setter for UDP service used for discovery (SSDP)
|
inline |
Set renderer volume.
| volumePercent | Desired volume 0..100 |
|
inline |
Stop playback.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |