Helper class to control a MediaRenderer device from a control point.
More...
#include <ControlPointMediaRenderer.h>
|
| | ControlPointMediaRenderer (DLNAControlPointMgr &mgr) |
| | Construct the helper with a reference to the control point mgr.
|
| |
| void | setDeviceTypeFilter (const char *filter) |
| | Restrict this helper to devices of the given device type.
|
| |
| bool | begin (DLNAHttpRequest &http, IUDPService &udp, 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)
|
| |
| bool | subscribeNotifications (int timeoutSeconds=60, NotificationCallback cb=nullptr) |
| | Subscribe to event notifications for the selected renderer.
|
| |
| 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 () |
| | Query the current volume from the renderer.
|
| |
| int | getMute () |
| | Query mute state.
|
| |
| unsigned long | getPositionMs () |
| | Query current playback position (RelTime)
|
| |
| const char * | getTransportState () |
| | Query transport state (e.g. STOPPED, PLAYING, PAUSED_PLAYBACK)
|
| |
| const char * | getCurrentURI () |
| | 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.
|
| |
Helper class to control a MediaRenderer device from a control point.
This lightweight helper 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.
◆ NotificationCallback
| typedef void(* tiny_dlna::ControlPointMediaRenderer::NotificationCallback) (void *reference, const char *sid, const char *varName, const char *newValue) |
◆ ControlPointMediaRenderer()
Construct the helper with a reference to the control point mgr.
- Parameters
-
| mgr | Reference to the underlying DLNAControlPointMgr used to send actions and manage discovery/subscriptions |
◆ begin()
| bool tiny_dlna::ControlPointMediaRenderer::begin |
( |
DLNAHttpRequest & |
http, |
|
|
IUDPService & |
udp, |
|
|
uint32_t |
minWaitMs = 3000, |
|
|
uint32_t |
maxWaitMs = 60000 |
|
) |
| |
|
inline |
Begin discovery and processing.
- Parameters
-
| 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 |
- Returns
- true on success, false on error
◆ findArgument()
| const char * tiny_dlna::ControlPointMediaRenderer::findArgument |
( |
ActionReply & |
r, |
|
|
const char * |
name |
|
) |
| |
|
inlineprotected |
◆ getCurrentURI()
| const char * tiny_dlna::ControlPointMediaRenderer::getCurrentURI |
( |
| ) |
|
|
inline |
Get the current media URI from the renderer.
- Returns
- pointer to URI string (owned by reply registry) or nullptr
◆ getDeviceCount()
| int tiny_dlna::ControlPointMediaRenderer::getDeviceCount |
( |
| ) |
|
|
inline |
Return the number of discovered devices matching the renderer filter.
- Returns
- number of matching devices
◆ getLastReply()
| const ActionReply & tiny_dlna::ControlPointMediaRenderer::getLastReply |
( |
| ) |
const |
|
inline |
◆ getMediaDurationMs()
| unsigned long tiny_dlna::ControlPointMediaRenderer::getMediaDurationMs |
( |
| ) |
|
|
inline |
Get total media duration in milliseconds (from MediaDuration)
- Returns
- milliseconds or 0 on error/unknown
◆ getMute()
| int tiny_dlna::ControlPointMediaRenderer::getMute |
( |
| ) |
|
|
inline |
Query mute state.
- Returns
- 0 = unmuted, 1 = muted, -1 = error/unknown
◆ getNrTracks()
| int tiny_dlna::ControlPointMediaRenderer::getNrTracks |
( |
| ) |
|
|
inline |
Get number of tracks in the current media.
- Returns
- number of tracks or -1 on error
◆ getPositionMs()
| unsigned long tiny_dlna::ControlPointMediaRenderer::getPositionMs |
( |
| ) |
|
|
inline |
Query current playback position (RelTime)
- Returns
- position in milliseconds, or 0 if unknown/error
◆ getTrackDurationMs()
| unsigned long tiny_dlna::ControlPointMediaRenderer::getTrackDurationMs |
( |
| ) |
|
|
inline |
Get current track duration in milliseconds (from TrackDuration)
- Returns
- milliseconds or 0 on error
◆ getTrackIndex()
| int tiny_dlna::ControlPointMediaRenderer::getTrackIndex |
( |
| ) |
|
|
inline |
Get current track index (from GetPositionInfo)
- Returns
- track index (numeric) or -1 on error
◆ getTransportState()
| const char * tiny_dlna::ControlPointMediaRenderer::getTransportState |
( |
| ) |
|
|
inline |
Query transport state (e.g. STOPPED, PLAYING, PAUSED_PLAYBACK)
- Returns
- pointer to a string owned by the helper's registry, or nullptr on error
◆ getVolume()
| int tiny_dlna::ControlPointMediaRenderer::getVolume |
( |
| ) |
|
|
inline |
Query the current volume from the renderer.
- Returns
- current volume 0..100, or -1 on error
◆ isActive()
| bool tiny_dlna::ControlPointMediaRenderer::isActive |
( |
| ) |
|
|
inline |
Query if the helper considers the renderer to be actively playing.
- Returns
- true if playing, false otherwise
◆ onActiveChanged()
| void tiny_dlna::ControlPointMediaRenderer::onActiveChanged |
( |
std::function< void(bool, void *)> |
cb | ) |
|
|
inline |
Register a callback invoked when the active (playing) state changes.
- Parameters
-
| cb | Function taking (bool active, void* reference). 'reference' is the pointer set via setReference(). |
◆ parseTimeToMs()
| static unsigned long tiny_dlna::ControlPointMediaRenderer::parseTimeToMs |
( |
const char * |
t | ) |
|
|
inlinestaticprotected |
◆ pause()
| bool tiny_dlna::ControlPointMediaRenderer::pause |
( |
| ) |
|
|
inline |
Pause playback.
- Returns
- true on success, false on error
◆ play() [1/2]
| bool tiny_dlna::ControlPointMediaRenderer::play |
( |
| ) |
|
|
inline |
Start playback on the renderer.
- Returns
- true on success, false on error
◆ play() [2/2]
| bool tiny_dlna::ControlPointMediaRenderer::play |
( |
const char * |
uri | ) |
|
|
inline |
Set the media URI and start playback.
- Parameters
-
- Returns
- true on success, false on error
◆ processNotification()
| static void tiny_dlna::ControlPointMediaRenderer::processNotification |
( |
void * |
reference, |
|
|
const char * |
sid, |
|
|
const char * |
varName, |
|
|
const char * |
newValue |
|
) |
| |
|
inlinestaticprotected |
◆ selectService()
| DLNAServiceInfo & tiny_dlna::ControlPointMediaRenderer::selectService |
( |
const char * |
id | ) |
|
|
inlineprotected |
◆ setActiveState()
| void tiny_dlna::ControlPointMediaRenderer::setActiveState |
( |
bool |
s | ) |
|
|
inlineprotected |
◆ setDeviceIndex()
| void tiny_dlna::ControlPointMediaRenderer::setDeviceIndex |
( |
int |
idx | ) |
|
|
inline |
Select the active renderer by index (0-based)
- Parameters
-
| idx | Index of the device to select; defaults to 0 |
◆ setDeviceTypeFilter()
| void tiny_dlna::ControlPointMediaRenderer::setDeviceTypeFilter |
( |
const char * |
filter | ) |
|
|
inline |
Restrict this helper to devices of the given device type.
- Parameters
-
| filter | Device type filter, e.g. "urn:schemas-upnp-org:device:MediaRenderer:1". Pass nullptr to use the default MediaRenderer filter. |
◆ setInstanceID()
| void tiny_dlna::ControlPointMediaRenderer::setInstanceID |
( |
const char * |
id | ) |
|
|
inline |
Set the InstanceID used for AVTransport and RenderingControl actions.
- Parameters
-
| id | C-string InstanceID (default is "0") |
◆ setMediaURI()
| bool tiny_dlna::ControlPointMediaRenderer::setMediaURI |
( |
const char * |
uri | ) |
|
|
inline |
Set the media URI on the renderer.
- Parameters
-
| uri | The media URI to play on the renderer |
- Returns
- true on success, false on error
◆ setMute()
| bool tiny_dlna::ControlPointMediaRenderer::setMute |
( |
bool |
mute | ) |
|
|
inline |
Set mute state on the renderer.
- Parameters
-
| mute | true to mute, false to unmute |
- Returns
- true on success, false on error
◆ setReference()
| void tiny_dlna::ControlPointMediaRenderer::setReference |
( |
void * |
ref | ) |
|
|
inline |
Attach an opaque reference object that will be passed to callbacks.
- Parameters
-
| ref | Opaque pointer provided by the caller |
◆ setVolume()
| bool tiny_dlna::ControlPointMediaRenderer::setVolume |
( |
int |
volumePercent | ) |
|
|
inline |
Set renderer volume.
- Parameters
-
| volumePercent | Desired volume 0..100 |
- Returns
- true on success, false on error
◆ stop()
| bool tiny_dlna::ControlPointMediaRenderer::stop |
( |
| ) |
|
|
inline |
Stop playback.
- Returns
- true on success, false on error
◆ subscribeNotifications()
| bool tiny_dlna::ControlPointMediaRenderer::subscribeNotifications |
( |
int |
timeoutSeconds = 60, |
|
|
NotificationCallback |
cb = nullptr |
|
) |
| |
|
inline |
Subscribe to event notifications for the selected renderer.
- Parameters
-
| timeoutSeconds | Subscription timeout in seconds (suggested default: 60) |
| cb | Optional callback to invoke for incoming notifications. If nullptr the helper's default processNotification will be used. |
- Returns
- true on successful SUBSCRIBE, false otherwise
◆ activeChangedCallback
| std::function<void(bool, void*)> tiny_dlna::ControlPointMediaRenderer::activeChangedCallback = nullptr |
|
protected |
◆ device_index
| int tiny_dlna::ControlPointMediaRenderer::device_index = 0 |
|
protected |
◆ device_type_filter
◆ device_type_filter_default
| const char* tiny_dlna::ControlPointMediaRenderer::device_type_filter_default |
|
protected |
Initial value:=
"urn:schemas-upnp-org:device:MediaRenderer:1"
◆ instance_id
| const char* tiny_dlna::ControlPointMediaRenderer::instance_id = "0" |
|
protected |
◆ is_active
| bool tiny_dlna::ControlPointMediaRenderer::is_active = false |
|
protected |
◆ last_reply
| ActionReply tiny_dlna::ControlPointMediaRenderer::last_reply |
|
protected |
◆ mgr
◆ reference
| void* tiny_dlna::ControlPointMediaRenderer::reference = nullptr |
|
protected |
The documentation for this class was generated from the following file: