|
a/upmpd/ohplaylist.cxx |
|
b/upmpd/ohplaylist.cxx |
|
... |
|
... |
99 |
dev->m_mpdcli->consume(false);
|
99 |
dev->m_mpdcli->consume(false);
|
100 |
}
|
100 |
}
|
101 |
|
101 |
|
102 |
static const int tracksmax = 16384;
|
102 |
static const int tracksmax = 16384;
|
103 |
|
103 |
|
104 |
// Yes inefficient. whatever...
|
|
|
105 |
static string makesint(int val)
|
|
|
106 |
{
|
|
|
107 |
char cbuf[30];
|
|
|
108 |
sprintf(cbuf, "%d", val);
|
|
|
109 |
return string(cbuf);
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
static string mpdstatusToTransportState(MpdStatus::State st)
|
104 |
static string mpdstatusToTransportState(MpdStatus::State st)
|
113 |
{
|
105 |
{
|
114 |
string tstate;
|
106 |
string tstate;
|
115 |
switch(st) {
|
107 |
switch(st) {
|
116 |
case MpdStatus::MPDS_PLAY:
|
108 |
case MpdStatus::MPDS_PLAY:
|
|
... |
|
... |
134 |
for (auto val : in) {
|
126 |
for (auto val : in) {
|
135 |
out1 += (unsigned char) ((val & 0xff000000) >> 24);
|
127 |
out1 += (unsigned char) ((val & 0xff000000) >> 24);
|
136 |
out1 += (unsigned char) ((val & 0x00ff0000) >> 16);
|
128 |
out1 += (unsigned char) ((val & 0x00ff0000) >> 16);
|
137 |
out1 += (unsigned char) ((val & 0x0000ff00) >> 8);
|
129 |
out1 += (unsigned char) ((val & 0x0000ff00) >> 8);
|
138 |
out1 += (unsigned char) ((val & 0x000000ff));
|
130 |
out1 += (unsigned char) ((val & 0x000000ff));
|
139 |
//sdeb += makesint(val) + " ";
|
131 |
//sdeb += SoapArgs::i2s(val) + " ";
|
140 |
}
|
132 |
}
|
141 |
//LOGDEB("OHPlaylist: current ids: " << sdeb << endl);
|
133 |
//LOGDEB("OHPlaylist: current ids: " << sdeb << endl);
|
142 |
return base64_encode(out1);
|
134 |
return base64_encode(out1);
|
143 |
}
|
135 |
}
|
144 |
string OHPlaylist::makeIdArray()
|
136 |
string OHPlaylist::makeIdArray()
|
|
... |
|
... |
169 |
st.clear();
|
161 |
st.clear();
|
170 |
|
162 |
|
171 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
163 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
172 |
|
164 |
|
173 |
st["TransportState"] = mpdstatusToTransportState(mpds.state);
|
165 |
st["TransportState"] = mpdstatusToTransportState(mpds.state);
|
174 |
st["Repeat"] = makesint(mpds.rept);
|
166 |
st["Repeat"] = SoapArgs::i2s(mpds.rept);
|
175 |
st["Shuffle"] = makesint(mpds.random);
|
167 |
st["Shuffle"] = SoapArgs::i2s(mpds.random);
|
176 |
st["Id"] = makesint(mpds.songid);
|
168 |
st["Id"] = SoapArgs::i2s(mpds.songid);
|
177 |
st["TracksMax"] = makesint(tracksmax);
|
169 |
st["TracksMax"] = SoapArgs::i2s(tracksmax);
|
178 |
st["ProtocolInfo"] = upmpdProtocolInfo;
|
170 |
st["ProtocolInfo"] = upmpdProtocolInfo;
|
179 |
st["IdArray"] = makeIdArray();
|
171 |
st["IdArray"] = makeIdArray();
|
180 |
|
172 |
|
181 |
return true;
|
173 |
return true;
|
182 |
}
|
174 |
}
|
|
... |
|
... |
374 |
// Return current Id
|
366 |
// Return current Id
|
375 |
int OHPlaylist::id(const SoapArgs& sc, SoapData& data)
|
367 |
int OHPlaylist::id(const SoapArgs& sc, SoapData& data)
|
376 |
{
|
368 |
{
|
377 |
LOGDEB("OHPlaylist::id" << endl);
|
369 |
LOGDEB("OHPlaylist::id" << endl);
|
378 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
370 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
379 |
data.addarg("Value", makesint(mpds.songid));
|
371 |
data.addarg("Value", SoapArgs::i2s(mpds.songid));
|
380 |
return UPNP_E_SUCCESS;
|
372 |
return UPNP_E_SUCCESS;
|
381 |
}
|
373 |
}
|
382 |
|
374 |
|
383 |
// Report the uri and metadata for a given track id.
|
375 |
// Report the uri and metadata for a given track id.
|
384 |
// Returns a 800 fault code if the given id is not in the playlist.
|
376 |
// Returns a 800 fault code if the given id is not in the playlist.
|
|
... |
|
... |
473 |
uri << " Metadata " << metadata << endl);
|
465 |
uri << " Metadata " << metadata << endl);
|
474 |
if (ok) {
|
466 |
if (ok) {
|
475 |
int id = m_dev->m_mpdcli->insertAfterId(uri, afterid);
|
467 |
int id = m_dev->m_mpdcli->insertAfterId(uri, afterid);
|
476 |
if ((ok = (id != -1))) {
|
468 |
if ((ok = (id != -1))) {
|
477 |
m_metacache[id] = metadata;
|
469 |
m_metacache[id] = metadata;
|
478 |
data.addarg("NewId", makesint(id));
|
470 |
data.addarg("NewId", SoapArgs::i2s(id));
|
479 |
}
|
471 |
}
|
480 |
}
|
472 |
}
|
481 |
maybeWakeUp(ok);
|
473 |
maybeWakeUp(ok);
|
482 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
474 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
483 |
}
|
475 |
}
|
|
... |
|
... |
503 |
}
|
495 |
}
|
504 |
|
496 |
|
505 |
int OHPlaylist::tracksMax(const SoapArgs& sc, SoapData& data)
|
497 |
int OHPlaylist::tracksMax(const SoapArgs& sc, SoapData& data)
|
506 |
{
|
498 |
{
|
507 |
LOGDEB("OHPlaylist::tracksMax" << endl);
|
499 |
LOGDEB("OHPlaylist::tracksMax" << endl);
|
508 |
data.addarg("Value", makesint(tracksmax));
|
500 |
data.addarg("Value", SoapArgs::i2s(tracksmax));
|
509 |
return UPNP_E_SUCCESS;
|
501 |
return UPNP_E_SUCCESS;
|
510 |
}
|
502 |
}
|
511 |
|
503 |
|
512 |
// Returns current list of id as array of big endian 32bits integers,
|
504 |
// Returns current list of id as array of big endian 32bits integers,
|
513 |
// base-64-encoded.
|
505 |
// base-64-encoded.
|