1 #include "AudioToolsConfig.h"
2 #include "AudioTools/CoreAudio/AudioStreams.h"
3 #include "AudioTools/CoreAudio/AudioOutput.h"
4 #include "AudioTools/AudioCodecs/AudioEncoded.h"
5 #include "AudioTools/CoreAudio/StreamCopy.h"
6 #include "AudioTools/CoreAudio/Pipeline.h"
7 #include "AudioTools/CoreAudio/VolumeStream.h"
8 #include "AudioTools/CoreAudio/AudioHttp/URLStream.h"
52 void setLogin(
const char* ssid,
const char* password) {
53 url.setPassword(password);
97 bool play(
const char* urlStr) {
98 if (urlStr ==
nullptr)
return false;
105 if (!
url.begin(urlStr)) {
133 if (volumePercent > 100) volumePercent = 100;
134 float volumeFloat = volumePercent / 100.0;
135 volume.setVolume(volumeFloat);
159 bool seek(
unsigned long position) {
211 const char*
st =
"urn:schemas-upnp-org:device:MediaRenderer:1";
212 const char*
usn =
"uuid:09349455-2941-4cf7-9847-1dd5ab210e97";
215 static const char* result =
217 "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/"
219 "xmlns:u=\"urn:schemas-upnp-org:service:%2:"
220 "1\"></u:%1></s:Body></s:Envelope>";
233 reply_str.replaceAll(
"%2",
"AVTransport");
234 if (soap.
indexOf(
"Play") >= 0) {
236 reply_str.replaceAll(
"%1",
"PlayResponse");
237 server->
reply(
"text/xml", reply_str.c_str());
238 }
else if (soap.
indexOf(
"Pause") >= 0) {
239 media_renderer.
pause();
240 reply_str.replaceAll(
"%1",
"PauseResponse");
241 server->
reply(
"text/xml", reply_str.c_str());
242 }
else if (soap.
indexOf(
"Stop") >= 0) {
243 media_renderer.
stop();
244 reply_str.replaceAll(
"%1",
"StopResponse");
245 server->
reply(
"text/xml", reply_str.c_str());
246 }
else if (soap.
indexOf(
"SetAVTransportURI") >= 0) {
248 int urlStart = soap.
indexOf(
"<CurrentURI>") + 12;
249 int urlEnd = soap.
indexOf(
"</CurrentURI>");
251 media_renderer.
play(
url.c_str());
252 reply_str.replaceAll(
"%1",
"SetAVTransportURIResponse");
253 server->
reply(
"text/xml", reply_str.c_str());
256 reply_str.replaceAll(
"%1",
"ActionResponse");
257 server->
reply(
"text/xml", reply_str.c_str());
269 reply_str.replaceAll(
"%2",
"RenderingControl");
271 if (soap.
indexOf(
"SetVolume") >= 0) {
273 int volStart = soap.
indexOf(
"<DesiredVolume>") + 15;
274 int volEnd = soap.
indexOf(
"</DesiredVolume>");
277 reply_str.replaceAll(
"%1",
"SetVolumeResponse");
278 server->
reply(
"text/xml", reply_str.c_str());
279 }
else if (soap.
indexOf(
"SetMute") >= 0) {
281 int muteStart = soap.
indexOf(
"<DesiredMute>") + 13;
282 int muteEnd = soap.
indexOf(
"</DesiredMute>");
283 bool mute = (soap.
substring(muteStart, muteEnd) ==
"1");
285 reply_str.replaceAll(
"%1",
"SetMuteResponse");
286 server->
reply(
"text/xml", reply_str.c_str());
289 reply_str.replaceAll(
"%1",
"RenderingControl");
290 server->
reply(
"text/xml", reply_str.c_str());
297 auto transportCB = [](
HttpServer* server,
const char* requestPath,
302 auto connmgrCB = [](
HttpServer* server,
const char* requestPath,
307 auto controlCB = [](
HttpServer* server,
const char* requestPath,
314 avt.
setup(
"urn:schemas-upnp-org:service:AVTransport:1",
315 "urn:upnp-org:serviceId:AVTransport",
"/AVT/service.xml",
317 [](
HttpServer* server,
const char* requestPath,
321 "urn:schemas-upnporg:service:ConnectionManager:1",
322 "urn:upnp-org:serviceId:ConnectionManager",
"/CM/service.xml",
323 connmgrCB,
"/CM/control",
324 [](
HttpServer* server,
const char* requestPath,
327 [](
HttpServer* server,
const char* requestPath,
330 rc.
setup(
"urn:schemas-upnporg:service:RenderingControl:1",
331 "urn:upnp-org:serviceId:RenderingControl",
"/RC/service.xml",
333 [](
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: DLNADevice.h:27
void setDeviceType(const char *st)
Definition: DLNADevice.h:44
void setSerialNumber(const char *sn)
Definition: DLNADevice.h:104
void setBaseURL(const char *url)
Defines the base url.
Definition: DLNADevice.h:55
void setFriendlyName(const char *name)
Definition: DLNADevice.h:92
void setManufacturer(const char *man)
Definition: DLNADevice.h:94
void setModelNumber(const char *number)
Definition: DLNADevice.h:102
void addService(DLNAServiceInfo s)
Adds a service defintion.
Definition: DLNADevice.h:110
void setModelName(const char *name)
Definition: DLNADevice.h:100
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:452
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 int indexOf(const char c, int start=0)
Definition: StrView.h:269
int toInt()
Converts the string to an int.
Definition: StrView.h:589
String implementation which keeps the data on the heap. We grow the allocated memory only if the copy...
Definition: Str.h:22
Str substring(int start, int end)
copies a substring into the current string
Definition: Str.h:196
const char * c_str()
provides the string value as const char*
Definition: Str.h:188
const char connmgr_xml[]
Definition: conmgr.h:1
const char * control_xml
Rendering control, controls volume, mute, and other rendering settings.
Definition: control.h:2
Definition: Allocator.h:6
@ DlnaInfo
Definition: Logger.h:16
@ DlnaWarning
Definition: Logger.h:16
@ DlnaError
Definition: Logger.h:16
LoggerClass DlnaLogger
Definition: Logger.cpp:5
const char transport_xml[]
Definition: transport.h:3