91 if (volumePercent > 100) volumePercent = 100;
118 active ?
"true" :
"false");
152 const char*
st =
"urn:schemas-upnp-org:device:MediaRenderer:1";
153 const char*
usn =
"uuid:09349455-2941-4cf7-9847-1dd5ab210e97";
161 bool play(
const char* urlStr) {
162 if (urlStr ==
nullptr)
return false;
213 char mimeBuf[64] = {0};
215 didl,
"<res",
"protocolInfo=", 3, mimeBuf,
sizeof(mimeBuf))) {
221 static const char* result =
223 "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/"
225 "xmlns:u=\"urn:schemas-upnp-org:service:%2:"
226 "1\"></u:%1></s:Body></s:Envelope>";
239 reply_str.replaceAll(
"%2",
"AVTransport");
240 if (soap.
indexOf(
"Play") >= 0) {
242 reply_str.replaceAll(
"%1",
"PlayResponse");
243 server->
reply(
"text/xml", reply_str.c_str());
244 }
else if (soap.
indexOf(
"Pause") >= 0) {
246 reply_str.replaceAll(
"%1",
"PauseResponse");
247 server->
reply(
"text/xml", reply_str.c_str());
248 }
else if (soap.
indexOf(
"Stop") >= 0) {
250 reply_str.replaceAll(
"%1",
"StopResponse");
251 server->
reply(
"text/xml", reply_str.c_str());
252 }
else if (soap.
indexOf(
"SetAVTransportURI") >= 0) {
254 int urlTagStart = soap.
indexOf(
"<CurrentURI>");
255 int urlTagEnd = soap.
indexOf(
"</CurrentURI>");
256 if (urlTagStart >= 0 && urlTagEnd > urlTagStart) {
257 int urlStart = urlTagStart + (int)strlen(
"<CurrentURI>");
262 "SetAVTransportURI called with invalid SOAP payload");
264 reply_str.replaceAll(
"%1",
"SetAVTransportURIResponse");
265 server->
reply(
"text/xml", reply_str.c_str());
268 reply_str.replaceAll(
"%1",
"ActionResponse");
269 server->
reply(
"text/xml", reply_str.c_str());
281 reply_str.replaceAll(
"%2",
"RenderingControl");
283 if (soap.
indexOf(
"SetVolume") >= 0) {
285 int volTagStart = soap.
indexOf(
"<DesiredVolume>");
286 int volTagEnd = soap.
indexOf(
"</DesiredVolume>");
287 if (volTagStart >= 0 && volTagEnd > volTagStart) {
288 int volStart = volTagStart + (int)strlen(
"<DesiredVolume>");
293 "SetVolume called with invalid SOAP payload");
295 reply_str.replaceAll(
"%1",
"SetVolumeResponse");
296 server->
reply(
"text/xml", reply_str.c_str());
297 }
else if (soap.
indexOf(
"SetMute") >= 0) {
299 int muteTagStart = soap.
indexOf(
"<DesiredMute>");
300 int muteTagEnd = soap.
indexOf(
"</DesiredMute>");
301 if (muteTagStart >= 0 && muteTagEnd > muteTagStart) {
302 int muteStart = muteTagStart + (int)strlen(
"<DesiredMute>");
303 bool mute = (soap.
substring(muteStart, muteTagEnd) ==
"1");
307 "SetMute called with invalid SOAP payload");
309 reply_str.replaceAll(
"%1",
"SetMuteResponse");
310 server->
reply(
"text/xml", reply_str.c_str());
313 reply_str.replaceAll(
"%1",
"RenderingControl");
314 server->
reply(
"text/xml", reply_str.c_str());
321 auto transportCB = [](
HttpServer* server,
const char* requestPath,
323 server->
reply(
"text/xml", [](Print& out){ mr_connmgr_xml_printer(out); });
326 auto connmgrCB = [](
HttpServer* server,
const char* requestPath,
328 server->
reply(
"text/xml", [](Print& out){ mr_connmgr_xml_printer(out); });
331 auto controlCB = [](
HttpServer* server,
const char* requestPath,
333 server->
reply(
"text/xml", [](Print& out){ mr_control_xml_printer(out); });
338 avt.
setup(
"urn:schemas-upnp-org:service:AVTransport:1",
339 "urn:upnp-org:serviceId:AVTransport",
"/AVT/service.xml",
341 [](
HttpServer* server,
const char* requestPath,
345 "urn:schemas-upnp-org:service:ConnectionManager:1",
346 "urn:upnp-org:serviceId:ConnectionManager",
"/CM/service.xml",
347 connmgrCB,
"/CM/control",
348 [](
HttpServer* server,
const char* requestPath,
351 [](
HttpServer* server,
const char* requestPath,
354 rc.
setup(
"urn:schemas-upnp-org:service:RenderingControl:1",
355 "urn:upnp-org:serviceId:RenderingControl",
"/RC/service.xml",
357 [](
HttpServer* server,
const char* requestPath,
Device Attributes and generation of XML using urn:schemas-upnp-org:device-1-0. We could just return a...
Definition: DLNADeviceInfo.h:27
void setDeviceType(const char *st)
Definition: DLNADeviceInfo.h:48
void addService(DLNAServiceInfo s)
Adds a service definition.
Definition: DLNADeviceInfo.h:138
void setModelName(const char *name)
Definition: DLNADeviceInfo.h:127
void setSerialNumber(const char *sn)
Definition: DLNADeviceInfo.h:131
void setManufacturer(const char *man)
Definition: DLNADeviceInfo.h:121
void setFriendlyName(const char *name)
Definition: DLNADeviceInfo.h:119
void setModelNumber(const char *number)
Definition: DLNADeviceInfo.h:129
void setBaseURL(const char *url)
Defines the base url.
Definition: DLNADeviceInfo.h:59
static SubscriptionMgr * getSubscriptionMgr()
Definition: DLNADevice.h:83
Attributes needed for the DLNA Service Definition.
Definition: DLNAServiceInfo.h:16
void setup(const char *type, const char *id, const char *scp, http_callback cbScp, const char *control, http_callback cbControl, const char *event, http_callback cbEvent)
Definition: DLNAServiceInfo.h:19
Used to register and process callbacks.
Definition: HttpRequestHandlerLine.h:19
void ** context
Definition: HttpRequestHandlerLine.h:39
A Simple Header only implementation of Http Server that allows the registration of callback functions...
Definition: HttpServer.h:24
void replyOK()
write OK reply with 200 SUCCESS
Definition: HttpServer.h:363
Str contentStr()
converts the client content to a string
Definition: HttpServer.h:450
void reply(const char *contentType, Stream &inputStream, int size, int status=200, const char *msg=SUCCESS)
write reply - copies data from input stream with header size
Definition: HttpServer.h:293
Abstract Interface for UDP API.
Definition: IUDPService.h:34
void log(DlnaLogLevel current_level, const char *fmt...)
Print log message.
Definition: Logger.h:40
virtual bool isEmpty()
checks if the string is empty
Definition: StrView.h:383
virtual int indexOf(const char c, int start=0)
Definition: StrView.h:275
int toInt()
Converts the string to an int.
Definition: StrView.h:596
String implementation which keeps the data on the heap. We grow the allocated memory only if the copy...
Definition: Str.h:22
const char * c_str()
provides the string value as const char*
Definition: Str.h:187
Str substring(int start, int end)
copies a substring into the current string
Definition: Str.h:195
Manages event subscriptions and notification delivery.
Definition: SubscriptionMgr.h:45
void publishProperty(const char *serviceId, const char *varName, const char *value)
Definition: SubscriptionMgr.h:80
static bool extractAttributeToken(const char *xml, const char *tagName, const char *attrName, int n, char *outBuf, size_t bufSize)
Extract the nth (1-based) colon-separated token from an attribute value located on the first occurren...
Definition: XMLAttributeParser.h:94
Definition: Allocator.h:6
MediaEvent
Events emitted by the MediaRenderer to notify the application about playback and rendering control ch...
Definition: MediaRenderer.h:32
LoggerClass DlnaLogger
Definition: Logger.cpp:5