23 const char* newValue);
42 uint32_t maxWaitMs = 60000) {
44 "ControlPointMediaServer::begin device_type_filter='%s'",
57 const char* dt = d.getDeviceType();
126 int& numberReturned,
int& totalMatches,
int& updateID,
127 const char* browseFlag =
nullptr) {
131 if (!svc)
return false;
161 return v ? atoi(v) : -1;
171 if (!svc)
return nullptr;
186 if (!svc)
return nullptr;
201 if (!svc)
return nullptr;
225 "urn:schemas-upnp-org:device:MediaServer:1";
234 const char* varName,
const char* newValue) {
237 "processNotification sid='%s' var='%s' value='%s'",
238 sid ? sid :
"(null)", varName ? varName :
"(null)",
239 newValue ? newValue :
"(null)");
247 for (
auto& d : all) {
248 const char* dt = d.getDeviceType();
264 if (a.name !=
nullptr) {
266 if (nm == name)
return a.value.c_str();
274 int startingIndex,
int requestedCount) {
279 browseFlag ? browseFlag :
"BrowseDirectChildren");
282 snprintf(buf,
sizeof(buf),
"%d", startingIndex);
284 snprintf(buf,
sizeof(buf),
"%d", requestedCount);
292 int& totalMatches,
int& updateID) {
293 const char* nret =
findArgument(reply,
"NumberReturned");
294 const char* tmatch =
findArgument(reply,
"TotalMatches");
296 numberReturned = nret ? atoi(nret) : 0;
297 totalMatches = tmatch ? atoi(tmatch) : 0;
298 updateID = uid ? atoi(uid) : 0;
303 if (!resultXml)
return;
308 int itPos1 = res.
indexOf(
"<item", pos);
309 int itPos2 = res.
indexOf(
"<container", pos);
311 bool isContainer =
false;
312 if (itPos1 >= 0 && (itPos2 < 0 || itPos1 < itPos2)) {
315 }
else if (itPos2 >= 0) {
319 if (itPos < 0)
break;
320 int itEnd = isContainer ? res.
indexOf(
"</container>", itPos)
321 : res.
indexOf(
"</item>", itPos);
322 if (itEnd < 0)
break;
323 int headerEnd = res.
indexOf(
'>', itPos);
324 if (headerEnd < 0 || headerEnd >= itEnd)
break;
328 int idPos = res.
indexOf(
"id=\"", itPos);
329 if (idPos >= 0 && idPos < headerEnd) {
330 int valStart = idPos + 4;
331 int valEnd = res.
indexOf(
'"', valStart);
332 if (valEnd > valStart) {
340 int t1 = res.
indexOf(
"<dc:title>", headerEnd);
341 if (t1 >= 0 && t1 < itEnd) {
342 int t1s = t1 + strlen(
"<dc:title>");
343 int t1e = res.
indexOf(
"</dc:title>", t1s);
352 int r1 = res.
indexOf(
"<res", headerEnd);
353 if (r1 >= 0 && r1 < itEnd) {
354 int r1s = res.
indexOf(
'>', r1);
355 if (r1s >= 0 && r1s < itEnd) {
357 int r1e = res.
indexOf(
"</res>", r1s);
366 if (itemCallback) itemCallback(item,
reference);
Represents the result of invoking a DLNA service Action.
Definition: Action.h:42
Vector< Argument > arguments
Definition: Action.h:45
Represents a request to invoke a remote DLNA service action.
Definition: Action.h:79
void addArgument(Argument arg)
Definition: Action.h:88
Lightweight DLNA control point manager.
Definition: DLNAControlPoint.h:58
DLNADeviceInfo & getDevice(int deviceIdx=0)
Provides the device information by index.
Definition: DLNAControlPoint.h:313
ActionRequest & addAction(ActionRequest act)
Registers a method that will be called.
Definition: DLNAControlPoint.h:161
Vector< DLNADeviceInfo > & getDevices()
Definition: DLNAControlPoint.h:343
bool subscribeNotifications(DLNADeviceInfo &device, int timeoutSeconds=60)
Subscribe to changes for all device services.
Definition: DLNAControlPoint.h:184
bool begin(DLNAHttpRequest &http, IUDPService &udp, const char *searchTarget="ssdp:all", uint32_t minWaitMs=3000, uint32_t maxWaitMs=60000)
Start discovery by sending M-SEARCH requests and process replies.
Definition: DLNAControlPoint.h:89
ActionReply & executeActions()
Executes all registered methods.
Definition: DLNAControlPoint.h:168
DLNAServiceInfo & getService(const char *id)
Provide addess to the service information.
Definition: DLNAControlPoint.h:302
void setReference(void *ref)
Attach an opaque reference pointer (optional, for caller context)
Definition: DLNAControlPoint.h:250
void onNotification(std::function< void(void *reference, const char *sid, const char *varName, const char *newValue)> cb)
Register a callback that will be invoked for incoming event notification.
Definition: DLNAControlPoint.h:242
Attributes needed for the DLNA Service Definition.
Definition: DLNAServiceInfo.h:16
Simple API to process get, put, post, del http requests I tried to use Arduino HttpClient,...
Definition: HttpRequest.h:21
Abstract Interface for UDP API.
Definition: IUDPService.h:34
void log(DlnaLogLevel current_level, const char *fmt...)
Print log message.
Definition: Logger.h:40
A simple wrapper to provide string functions on char*. If the underlying char* is a const we do not a...
Definition: StrView.h:19
virtual const char * c_str()
provides the string value as const char*
Definition: StrView.h:376
virtual int indexOf(const char c, int start=0)
Definition: StrView.h:275
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
void copyFrom(const char *source, int len, int maxlen=0)
assigns a memory buffer
Definition: Str.h:93
Make sure that a string is stored only once.
Definition: StringRegistry.h:9
const char * add(char *in)
adds a string
Definition: StringRegistry.h:12
Vector implementation which provides the most important methods as defined by std::vector....
Definition: Vector.h:21
Definition: Allocator.h:6
LoggerClass DlnaLogger
Definition: Logger.cpp:5