Arduino DLNA Server
MediaRenderer.h
Go to the documentation of this file.
1 #include "conmgr.h"
2 #include "control.h"
3 #include "dlna/DLNADeviceMgr.h"
4 #include "transport.h"
5 
6 namespace tiny_dlna {
7 
12 class MediaRenderer : public DLNADeviceMgr {
13  public:
14  protected:
15  // Renderer, Player or Server
16  const char* st = "urn:schemas-upnp-org:device:MediaRenderer:1";
17  const char* usn = "uuid:09349455-2941-4cf7-9847-1dd5ab210e97";
18 
19  void setupServices(DLNADevice& device) override {
20  DlnaLogger.log(DlnaInfo, "MediaRenderer::setupServices");
21  device.clear();
22  device.setUDN(usn);
23  device.setDeviceType(st);
24 
25  auto dummyCB = [](HttpServer* server, const char* requestPath,
27  DlnaLogger.log(DlnaError, "Unhandled request: %s", requestPath);
28  server->reply("text/xml", "<test/>");
29  };
30 
31  auto transportCB = [](HttpServer* server, const char* requestPath,
33  server->reply("text/xml", transport_xml);
34  };
35 
36  auto connmgrCB = [](HttpServer* server, const char* requestPath,
38  server->reply("text/xml", connmgr_xml);
39  };
40 
41  auto controlCB = [](HttpServer* server, const char* requestPath,
43  server->reply("text/xml", control_xml);
44  };
45 
46  // define services
47  DLNAServiceInfo rc, cm, avt;
48  avt.setup("urn:schemas-upnp-org:service:AVTransport:1",
49  "urn:upnp-org:serviceId:AVTransport", "/AVT/service.xml",
50  transportCB, "/AVT/control", dummyCB, "/AVT/event", dummyCB);
51  cm.setup("urn:schemas-upnporg:service:ConnectionManager:1",
52  "urn:upnp-org:serviceId:ConnectionManager", "/CM/service.xml",
53  connmgrCB, "/CM/control", dummyCB, "/CM/event", dummyCB);
54  rc.setup("urn:schemas-upnporg:service:RenderingControl:1",
55  "urn:upnp-org:serviceId:RenderingControl", "/RC/service.xml",
56  controlCB, "/RC/control", dummyCB, "/RC/event", dummyCB);
57 
58  device.addService(rc);
59  device.addService(cm);
60  device.addService(avt);
61  }
62 };
63 
64 } // namespace tiny_dlna
Setup of a Basic DLNA Device service. The device registers itself to the network and answers to the D...
Definition: DLNADeviceMgr.h:23
Device Attributes and generation of XML using urn:schemas-upnp-org:device-1-0. We could just return a...
Definition: DLNADevice.h:27
void setDeviceType(const char *st)
Definition: DLNADevice.h:42
void clear()
Definition: DLNADevice.h:127
void addService(DLNAServiceInfo s)
Adds a service defintion.
Definition: DLNADevice.h:112
void setUDN(const char *id)
Define the udn uuid.
Definition: DLNADevice.h:47
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
A Simple Header only implementation of Http Server that allows the registration of callback functions...
Definition: HttpServer.h:24
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
void log(DlnaLogLevel current_level, const char *fmt...)
Print log message.
Definition: Logger.h:40
MediaRenderer DLNA Device.
Definition: MediaRenderer.h:12
void setupServices(DLNADevice &device) override
Definition: MediaRenderer.h:19
const char * st
Definition: MediaRenderer.h:16
const char * usn
Definition: MediaRenderer.h:17
const char connmgr_xml[]
Definition: conmgr.h:1
const char control_xml[]
Definition: control.h:1
Definition: Allocator.h:6
@ DlnaInfo
Definition: Logger.h:16
@ DlnaError
Definition: Logger.h:16
LoggerClass DlnaLogger
Definition: Logger.cpp:5
const char transport_xml[]
Definition: transport.h:1