|
a/upmpd/avtransport.cxx |
|
b/upmpd/avtransport.cxx |
|
... |
|
... |
298 |
// http://192.168.4.4:8200/MediaItems/246.mp3
|
298 |
// http://192.168.4.4:8200/MediaItems/246.mp3
|
299 |
int UpMpdAVTransport::setAVTransportURI(const SoapArgs& sc, SoapData& data,
|
299 |
int UpMpdAVTransport::setAVTransportURI(const SoapArgs& sc, SoapData& data,
|
300 |
bool setnext)
|
300 |
bool setnext)
|
301 |
{
|
301 |
{
|
302 |
map<string, string>::const_iterator it;
|
302 |
map<string, string>::const_iterator it;
|
303 |
|
303 |
|
|
|
304 |
// pretend not to support setnext:
|
|
|
305 |
//if (setnext) return UPNP_E_INVALID_PARAM;
|
|
|
306 |
|
304 |
it = setnext? sc.args.find("NextURI") : sc.args.find("CurrentURI");
|
307 |
it = setnext? sc.args.find("NextURI") : sc.args.find("CurrentURI");
|
305 |
if (it == sc.args.end() || it->second.empty()) {
|
308 |
if (it == sc.args.end() || it->second.empty()) {
|
306 |
return UPNP_E_INVALID_PARAM;
|
309 |
return UPNP_E_INVALID_PARAM;
|
307 |
}
|
310 |
}
|
308 |
string uri = it->second;
|
311 |
string uri = it->second;
|
|
... |
|
... |
334 |
// play will use position 0, so it's actually equivalent to curpos == 0
|
337 |
// play will use position 0, so it's actually equivalent to curpos == 0
|
335 |
if (curpos == -1) {
|
338 |
if (curpos == -1) {
|
336 |
curpos = 0;
|
339 |
curpos = 0;
|
337 |
}
|
340 |
}
|
338 |
|
341 |
|
|
|
342 |
if (setnext) {
|
339 |
if (mpds.qlen == 0 && setnext) {
|
343 |
if (mpds.qlen == 0) {
|
340 |
LOGDEB("setNextAVTransportURI invoked but empty queue!" << endl);
|
344 |
LOGDEB("setNextAVTransportURI invoked but empty queue!" << endl);
|
341 |
return UPNP_E_INVALID_PARAM;
|
345 |
return UPNP_E_INVALID_PARAM;
|
342 |
}
|
346 |
}
|
|
|
347 |
if ((m_dev->m_options & UpMpd::upmpdOwnQueue) && mpds.qlen > 1) {
|
|
|
348 |
// If we own the queue, make sure we only keep 2 songs in it:
|
|
|
349 |
// guard against multiple setnext calls.
|
|
|
350 |
int posend;
|
|
|
351 |
for (posend = curpos + 1;; posend++) {
|
|
|
352 |
UpSong nsong;
|
|
|
353 |
if (!m_dev->m_mpdcli->statSong(nsong, posend))
|
|
|
354 |
break;
|
|
|
355 |
}
|
|
|
356 |
if (posend > curpos+1)
|
|
|
357 |
m_dev->m_mpdcli->deletePosRange(curpos + 1, posend);
|
|
|
358 |
}
|
|
|
359 |
}
|
|
|
360 |
|
343 |
int songid;
|
361 |
int songid;
|
344 |
if ((songid = m_dev->m_mpdcli->insert(uri, setnext?curpos+1:curpos)) < 0) {
|
362 |
if ((songid = m_dev->m_mpdcli->insert(uri, setnext?curpos+1:curpos)) < 0) {
|
345 |
return UPNP_E_INTERNAL_ERROR;
|
363 |
return UPNP_E_INTERNAL_ERROR;
|
346 |
}
|
364 |
}
|
347 |
|
365 |
|
|
... |
|
... |
349 |
m_nextUri = uri;
|
367 |
m_nextUri = uri;
|
350 |
m_nextMetadata = metadata;
|
368 |
m_nextMetadata = metadata;
|
351 |
} else {
|
369 |
} else {
|
352 |
m_uri = uri;
|
370 |
m_uri = uri;
|
353 |
m_curMetadata = metadata;
|
371 |
m_curMetadata = metadata;
|
|
|
372 |
m_nextUri.clear();
|
|
|
373 |
m_nextMetadata.clear();
|
354 |
}
|
374 |
}
|
355 |
|
375 |
|
356 |
if (!setnext) {
|
376 |
if (!setnext) {
|
357 |
MpdStatus::State st = mpds.state;
|
377 |
MpdStatus::State st = mpds.state;
|
358 |
// Have to tell mpd which track to play, else it will keep on
|
378 |
// Have to tell mpd which track to play, else it will keep on
|
359 |
// the previous despite of the insertion. The UPnP docs say
|
379 |
// the previous despite the insertion. The UPnP docs say
|
360 |
// that setAVTransportURI should not change the transport
|
380 |
// that setAVTransportURI should not change the transport
|
361 |
// state (pause/stop stay pause/stop) but it seems that some clients
|
381 |
// state (pause/stop stay pause/stop) but it seems that some clients
|
362 |
// expect that the track will start playing.
|
382 |
// expect that the track will start playing.
|
363 |
// Needs to be revisited after seeing more clients. For now try to
|
383 |
// Needs to be revisited after seeing more clients. For now try to
|
364 |
// preserve state as per standard.
|
384 |
// preserve state as per standard.
|