49 const char* objectID,
const char* browseFlag,
const char* filter,
50 int startingIndex,
int requestedCount,
const char* sortCriteria,
51 int& numberReturned,
int& totalMatches,
int& updateID,
void* reference);
92 const char*
st =
"urn:schemas-upnp-org:device:MediaServer:1";
93 const char*
usn =
"uuid:media-server-0000-0000-0000-000000000001";
111 auto contentDescCB = [](
HttpServer* server,
const char* requestPath,
113 server->
reply(
"text/xml",
114 [](Print& out) { ms_content_dir_xml_printer(out); });
116 auto connDescCB = [](
HttpServer* server,
const char* requestPath,
118 server->
reply(
"text/xml",
119 [](Print& out) { ms_connmgr_xml_printer(out); });
123 cd.
setup(
"urn:schemas-upnp-org:service:ContentDirectory:1",
124 "urn:upnp-org:serviceId:ContentDirectory",
"/CD/service.xml",
127 [](
HttpServer* server,
const char* requestPath,
131 cm.
setup(
"urn:schemas-upnp-org:service:ConnectionManager:1",
132 "urn:upnp-org:serviceId:ConnectionManager",
"/CM/service.xml",
134 [](
HttpServer* server,
const char* requestPath,
144 static const char* tpl =
145 "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\""
146 " s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
148 "xmlns:u=\"urn:schemas-upnp-org:service:%2:1\">%3</u:%1></s:Body></"
155 const char* requestPath,
161 reply_str.replaceAll(
"%2",
"ContentDirectory");
164 if (soap.
indexOf(
"Browse") < 0) {
165 reply_str.replaceAll(
"%1",
"ActionResponse");
166 reply_str.replaceAll(
"%3",
"");
167 server->
reply(
"text/xml", reply_str.c_str());
172 auto extractArg = [&](
const char* tag) ->
Str {
176 int start = soap.
indexOf(
'>', pos);
186 Str obj = extractArg(
"ObjectID");
187 Str flag = extractArg(
"BrowseFlag");
188 Str filter = extractArg(
"Filter");
189 Str startIdx = extractArg(
"StartingIndex");
190 Str reqCount = extractArg(
"RequestedCount");
191 Str sort = extractArg(
"SortCriteria");
193 int startingIndex = startIdx.
isEmpty() ? 0 : startIdx.
toInt();
194 int requestedCount = reqCount.
isEmpty() ? 0 : reqCount.
toInt();
200 int numberReturned = 0;
201 int totalMatches = 0;
205 startingIndex, requestedCount, sort.
c_str(),
206 numberReturned, totalMatches, updateID,
233 for (
const char* p = s; *p; ++p) {
241 out.write((
const uint8_t)*p);
250 const char* envAttrs =
251 "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
252 "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"";
257 const char* brAttrs =
258 "xmlns:u=\"urn:schemas-upnp-org:service:ContentDirectory:1\"";
283 const char* didlAttrs =
284 "xmlns:dc=\"http://purl.org/dc/elements/1.1/\" "
285 "xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" "
286 "xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"";
290 for (
int i = 0; i < count; ++i) {
294 snprintf(itemAttr,
sizeof(itemAttr),
295 "id=\"%s\" parentID=\"%s\" restricted=\"%d\"",
306 snprintf(resAttr,
sizeof(resAttr),
"protocolInfo=\"%s\"",
324 reply_str.replaceAll(
"%2",
"ConnectionManager");
325 reply_str.replaceAll(
"%1",
"ActionResponse");
326 reply_str.replaceAll(
"%3",
"");
327 server->
reply(
"text/xml", reply_str.c_str());
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
XMLPrinter xml
Definition: DLNADeviceInfo.h:195
void setModelNumber(const char *number)
Definition: DLNADeviceInfo.h:129
void setBaseURL(const char *url)
Defines the base url.
Definition: DLNADeviceInfo.h:59
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
Definition: Allocator.h:6
LoggerClass DlnaLogger
Definition: Logger.cpp:5
Print wrapper that escapes & < > while forwarding to an underlying Print.
Definition: EscapingPrint.h:7
Functions to efficiently output XML. XML data contains a lot of redundancy so it is more memory effic...
Definition: XMLPrinter.h:31
size_t printNodeBegin(const char *node, const char *attributes=nullptr, const char *ns=nullptr)
Definition: XMLPrinter.h:97
size_t printNodeBeginNl(const char *node, const char *attributes=nullptr, const char *ns=nullptr)
Definition: XMLPrinter.h:115
size_t printNode(XMLNode node)
Definition: XMLPrinter.h:43
size_t printNodeEnd(const char *node, const char *ns=nullptr)
Definition: XMLPrinter.h:122