|
a/src/avtransport.cxx |
|
b/src/avtransport.cxx |
|
... |
|
... |
23 |
#include <iostream> // for operator<<, etc
|
23 |
#include <iostream> // for operator<<, etc
|
24 |
#include <map> // for map, map<>::const_iterator
|
24 |
#include <map> // for map, map<>::const_iterator
|
25 |
#include <utility> // for pair
|
25 |
#include <utility> // for pair
|
26 |
|
26 |
|
27 |
#include "libupnpp/log.hxx" // for LOGDEB, LOGDEB1, LOGERR
|
27 |
#include "libupnpp/log.hxx" // for LOGDEB, LOGDEB1, LOGERR
|
28 |
#include "libupnpp/soaphelp.hxx" // for SoapData, SoapArgs, etc
|
28 |
#include "libupnpp/soaphelp.hxx" // for SoapOutgoing, SoapIncoming, etc
|
29 |
#include "libupnpp/upnpavutils.hxx" // for upnpduration, etc
|
29 |
#include "libupnpp/upnpavutils.hxx" // for upnpduration, etc
|
30 |
|
30 |
|
31 |
#include "mpdcli.hxx" // for MpdStatus, MPDCli, etc
|
31 |
#include "mpdcli.hxx" // for MpdStatus, MPDCli, etc
|
32 |
#include "ohplaylist.hxx" // for OHPlaylist
|
32 |
#include "ohplaylist.hxx" // for OHPlaylist
|
33 |
#include "upmpd.hxx" // for UpMpd, etc
|
33 |
#include "upmpd.hxx" // for UpMpd, etc
|
|
... |
|
... |
288 |
LOGDEB1("UpMpdAVTransport::getEventDataTransport: " << chgdata << endl);
|
288 |
LOGDEB1("UpMpdAVTransport::getEventDataTransport: " << chgdata << endl);
|
289 |
return true;
|
289 |
return true;
|
290 |
}
|
290 |
}
|
291 |
|
291 |
|
292 |
// http://192.168.4.4:8200/MediaItems/246.mp3
|
292 |
// http://192.168.4.4:8200/MediaItems/246.mp3
|
293 |
int UpMpdAVTransport::setAVTransportURI(const SoapArgs& sc, SoapData& data,
|
293 |
int UpMpdAVTransport::setAVTransportURI(const SoapIncoming& sc, SoapOutgoing& data,
|
294 |
bool setnext)
|
294 |
bool setnext)
|
295 |
{
|
295 |
{
|
296 |
map<string, string>::const_iterator it;
|
|
|
297 |
|
|
|
298 |
// pretend not to support setnext:
|
296 |
// pretend not to support setnext:
|
299 |
//if (setnext) return UPNP_E_INVALID_PARAM;
|
297 |
//if (setnext) return UPNP_E_INVALID_PARAM;
|
300 |
|
298 |
string uri;
|
301 |
it = setnext? sc.args.find("NextURI") : sc.args.find("CurrentURI");
|
299 |
bool found = setnext? sc.get("NextURI", &uri) : sc.get("CurrentURI", &uri);
|
302 |
if (it == sc.args.end() || it->second.empty()) {
|
300 |
if (!found) {
|
303 |
return UPNP_E_INVALID_PARAM;
|
301 |
return UPNP_E_INVALID_PARAM;
|
304 |
}
|
302 |
}
|
305 |
string uri = it->second;
|
|
|
306 |
string metadata;
|
303 |
string metadata;
|
307 |
it = setnext? sc.args.find("NextURIMetaData") :
|
304 |
found = setnext ? sc.get("NextURIMetaData", &metadata) :
|
308 |
sc.args.find("CurrentURIMetaData");
|
305 |
sc.get("CurrentURIMetaData", &metadata);
|
309 |
if (it != sc.args.end())
|
|
|
310 |
metadata = it->second;
|
|
|
311 |
LOGDEB("Set(next)AVTransportURI: next " << setnext << " uri " << uri <<
|
306 |
LOGDEB("Set(next)AVTransportURI: next " << setnext << " uri " << uri <<
|
312 |
" metadata[" << metadata << "]" << endl);
|
307 |
" metadata[" << metadata << "]" << endl);
|
313 |
|
308 |
|
314 |
if ((m_dev->m_options & UpMpd::upmpdOwnQueue) && !setnext) {
|
309 |
if ((m_dev->m_options & UpMpd::upmpdOwnQueue) && !setnext) {
|
315 |
// If we own the queue, just clear it before setting the
|
310 |
// If we own the queue, just clear it before setting the
|
|
... |
|
... |
412 |
|
407 |
|
413 |
m_dev->loopWakeup();
|
408 |
m_dev->loopWakeup();
|
414 |
return UPNP_E_SUCCESS;
|
409 |
return UPNP_E_SUCCESS;
|
415 |
}
|
410 |
}
|
416 |
|
411 |
|
417 |
int UpMpdAVTransport::getPositionInfo(const SoapArgs& sc, SoapData& data)
|
412 |
int UpMpdAVTransport::getPositionInfo(const SoapIncoming& sc, SoapOutgoing& data)
|
418 |
{
|
413 |
{
|
419 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
414 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
420 |
//LOGDEB("UpMpdAVTransport::getPositionInfo. State: " << mpds.state <<endl);
|
415 |
//LOGDEB("UpMpdAVTransport::getPositionInfo. State: " << mpds.state <<endl);
|
421 |
|
416 |
|
422 |
bool is_song = (mpds.state == MpdStatus::MPDS_PLAY) ||
|
417 |
bool is_song = (mpds.state == MpdStatus::MPDS_PLAY) ||
|
|
... |
|
... |
465 |
data.addarg("RelCount", "0");
|
460 |
data.addarg("RelCount", "0");
|
466 |
data.addarg("AbsCount", "0");
|
461 |
data.addarg("AbsCount", "0");
|
467 |
return UPNP_E_SUCCESS;
|
462 |
return UPNP_E_SUCCESS;
|
468 |
}
|
463 |
}
|
469 |
|
464 |
|
470 |
int UpMpdAVTransport::getTransportInfo(const SoapArgs& sc, SoapData& data)
|
465 |
int UpMpdAVTransport::getTransportInfo(const SoapIncoming& sc, SoapOutgoing& data)
|
471 |
{
|
466 |
{
|
472 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
467 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
473 |
//LOGDEB("UpMpdAVTransport::getTransportInfo. State: " << mpds.state<<endl);
|
468 |
//LOGDEB("UpMpdAVTransport::getTransportInfo. State: " << mpds.state<<endl);
|
474 |
|
469 |
|
475 |
string tstate("STOPPED");
|
470 |
string tstate("STOPPED");
|
|
... |
|
... |
483 |
"ERROR_OCCURRED");
|
478 |
"ERROR_OCCURRED");
|
484 |
data.addarg("CurrentSpeed", "1");
|
479 |
data.addarg("CurrentSpeed", "1");
|
485 |
return UPNP_E_SUCCESS;
|
480 |
return UPNP_E_SUCCESS;
|
486 |
}
|
481 |
}
|
487 |
|
482 |
|
488 |
int UpMpdAVTransport::getDeviceCapabilities(const SoapArgs& sc, SoapData& data)
|
483 |
int UpMpdAVTransport::getDeviceCapabilities(const SoapIncoming& sc, SoapOutgoing& data)
|
489 |
{
|
484 |
{
|
490 |
data.addarg("PlayMedia", "NETWORK,HDD");
|
485 |
data.addarg("PlayMedia", "NETWORK,HDD");
|
491 |
data.addarg("RecMedia", "NOT_IMPLEMENTED");
|
486 |
data.addarg("RecMedia", "NOT_IMPLEMENTED");
|
492 |
data.addarg("RecQualityModes", "NOT_IMPLEMENTED");
|
487 |
data.addarg("RecQualityModes", "NOT_IMPLEMENTED");
|
493 |
return UPNP_E_SUCCESS;
|
488 |
return UPNP_E_SUCCESS;
|
494 |
}
|
489 |
}
|
495 |
|
490 |
|
496 |
int UpMpdAVTransport::getMediaInfo(const SoapArgs& sc, SoapData& data)
|
491 |
int UpMpdAVTransport::getMediaInfo(const SoapIncoming& sc, SoapOutgoing& data)
|
497 |
{
|
492 |
{
|
498 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
493 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
499 |
LOGDEB("UpMpdAVTransport::getMediaInfo. State: " << mpds.state << endl);
|
494 |
LOGDEB("UpMpdAVTransport::getMediaInfo. State: " << mpds.state << endl);
|
500 |
|
495 |
|
501 |
bool is_song = (mpds.state == MpdStatus::MPDS_PLAY) ||
|
496 |
bool is_song = (mpds.state == MpdStatus::MPDS_PLAY) ||
|
|
... |
|
... |
538 |
data.addarg("RecordMedium", "NOT_IMPLEMENTED");
|
533 |
data.addarg("RecordMedium", "NOT_IMPLEMENTED");
|
539 |
data.addarg("WriteStatus", "NOT_IMPLEMENTED");
|
534 |
data.addarg("WriteStatus", "NOT_IMPLEMENTED");
|
540 |
return UPNP_E_SUCCESS;
|
535 |
return UPNP_E_SUCCESS;
|
541 |
}
|
536 |
}
|
542 |
|
537 |
|
543 |
int UpMpdAVTransport::playcontrol(const SoapArgs& sc, SoapData& data, int what)
|
538 |
int UpMpdAVTransport::playcontrol(const SoapIncoming& sc, SoapOutgoing& data, int what)
|
544 |
{
|
539 |
{
|
545 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
540 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
546 |
LOGDEB("UpMpdAVTransport::playcontrol State: " << mpds.state <<
|
541 |
LOGDEB("UpMpdAVTransport::playcontrol State: " << mpds.state <<
|
547 |
" what "<<what<< endl);
|
542 |
" what "<<what<< endl);
|
548 |
|
543 |
|
|
... |
|
... |
579 |
|
574 |
|
580 |
m_dev->loopWakeup();
|
575 |
m_dev->loopWakeup();
|
581 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
576 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
582 |
}
|
577 |
}
|
583 |
|
578 |
|
584 |
int UpMpdAVTransport::seqcontrol(const SoapArgs& sc, SoapData& data, int what)
|
579 |
int UpMpdAVTransport::seqcontrol(const SoapIncoming& sc, SoapOutgoing& data, int what)
|
585 |
{
|
580 |
{
|
586 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
581 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
587 |
LOGDEB("UpMpdAVTransport::seqcontrol State: " << mpds.state << " what "
|
582 |
LOGDEB("UpMpdAVTransport::seqcontrol State: " << mpds.state << " what "
|
588 |
<<what<< endl);
|
583 |
<<what<< endl);
|
589 |
|
584 |
|
|
... |
|
... |
600 |
|
595 |
|
601 |
m_dev->loopWakeup();
|
596 |
m_dev->loopWakeup();
|
602 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
597 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
603 |
}
|
598 |
}
|
604 |
|
599 |
|
605 |
int UpMpdAVTransport::setPlayMode(const SoapArgs& sc, SoapData& data)
|
600 |
int UpMpdAVTransport::setPlayMode(const SoapIncoming& sc, SoapOutgoing& data)
|
606 |
{
|
601 |
{
|
607 |
map<string, string>::const_iterator it;
|
|
|
608 |
|
|
|
609 |
it = sc.args.find("NewPlayMode");
|
|
|
610 |
if (it == sc.args.end() || it->second.empty()) {
|
|
|
611 |
return UPNP_E_INVALID_PARAM;
|
|
|
612 |
}
|
|
|
613 |
string playmode(it->second);
|
602 |
string playmode;
|
|
|
603 |
if (!sc.get("NewPlayMode", &playmode)) {
|
|
|
604 |
return UPNP_E_INVALID_PARAM;
|
|
|
605 |
}
|
|
|
606 |
|
614 |
bool ok;
|
607 |
bool ok;
|
615 |
if (!playmode.compare("NORMAL")) {
|
608 |
if (!playmode.compare("NORMAL")) {
|
616 |
ok = m_dev->m_mpdcli->repeat(false) && m_dev->m_mpdcli->random(false) &&
|
609 |
ok = m_dev->m_mpdcli->repeat(false) && m_dev->m_mpdcli->random(false) &&
|
617 |
m_dev->m_mpdcli->single(false);
|
610 |
m_dev->m_mpdcli->single(false);
|
618 |
} else if (!playmode.compare("SHUFFLE")) {
|
611 |
} else if (!playmode.compare("SHUFFLE")) {
|
|
... |
|
... |
635 |
}
|
628 |
}
|
636 |
m_dev->loopWakeup();
|
629 |
m_dev->loopWakeup();
|
637 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
630 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
638 |
}
|
631 |
}
|
639 |
|
632 |
|
640 |
int UpMpdAVTransport::getTransportSettings(const SoapArgs& sc, SoapData& data)
|
633 |
int UpMpdAVTransport::getTransportSettings(const SoapIncoming& sc, SoapOutgoing& data)
|
641 |
{
|
634 |
{
|
642 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
635 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
643 |
string playmode = mpdsToPlaymode(mpds);
|
636 |
string playmode = mpdsToPlaymode(mpds);
|
644 |
data.addarg("PlayMode", playmode);
|
637 |
data.addarg("PlayMode", playmode);
|
645 |
data.addarg("RecQualityMode", "NOT_IMPLEMENTED");
|
638 |
data.addarg("RecQualityMode", "NOT_IMPLEMENTED");
|
646 |
return UPNP_E_SUCCESS;
|
639 |
return UPNP_E_SUCCESS;
|
647 |
}
|
640 |
}
|
648 |
|
641 |
|
649 |
int UpMpdAVTransport::getCurrentTransportActions(const SoapArgs& sc,
|
642 |
int UpMpdAVTransport::getCurrentTransportActions(const SoapIncoming& sc,
|
650 |
SoapData& data)
|
643 |
SoapOutgoing& data)
|
651 |
{
|
644 |
{
|
652 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
645 |
const MpdStatus &mpds = m_dev->getMpdStatus();
|
653 |
string tactions("Next,Previous");
|
646 |
string tactions("Next,Previous");
|
654 |
switch(mpds.state) {
|
647 |
switch(mpds.state) {
|
655 |
case MpdStatus::MPDS_PLAY:
|
648 |
case MpdStatus::MPDS_PLAY:
|
|
... |
|
... |
663 |
}
|
656 |
}
|
664 |
data.addarg("CurrentTransportActions", tactions);
|
657 |
data.addarg("CurrentTransportActions", tactions);
|
665 |
return UPNP_E_SUCCESS;
|
658 |
return UPNP_E_SUCCESS;
|
666 |
}
|
659 |
}
|
667 |
|
660 |
|
668 |
int UpMpdAVTransport::seek(const SoapArgs& sc, SoapData& data)
|
661 |
int UpMpdAVTransport::seek(const SoapIncoming& sc, SoapOutgoing& data)
|
669 |
{
|
662 |
{
|
670 |
map<string, string>::const_iterator it;
|
663 |
string unit;
|
671 |
|
664 |
if (!sc.get("Unit", &unit)) {
|
672 |
it = sc.args.find("Unit");
|
|
|
673 |
if (it == sc.args.end() || it->second.empty()) {
|
|
|
674 |
return UPNP_E_INVALID_PARAM;
|
665 |
return UPNP_E_INVALID_PARAM;
|
|
|
666 |
}
|
675 |
}
|
667 |
|
676 |
string unit(it->second);
|
|
|
677 |
|
|
|
678 |
it = sc.args.find("Target");
|
|
|
679 |
if (it == sc.args.end() || it->second.empty()) {
|
|
|
680 |
return UPNP_E_INVALID_PARAM;
|
|
|
681 |
}
|
|
|
682 |
string target(it->second);
|
668 |
string target;
|
|
|
669 |
if (!sc.get("Target", &target)) {
|
|
|
670 |
return UPNP_E_INVALID_PARAM;
|
|
|
671 |
}
|
683 |
|
672 |
|
684 |
//LOGDEB("UpMpdAVTransport::seek: unit " << unit << " target " << target <<
|
673 |
//LOGDEB("UpMpdAVTransport::seek: unit " << unit << " target " << target <<
|
685 |
// " current posisition " << mpds.songelapsedms / 1000 <<
|
674 |
// " current posisition " << mpds.songelapsedms / 1000 <<
|
686 |
// " seconds" << endl);
|
675 |
// " seconds" << endl);
|
687 |
|
676 |
|