|
a/src/ohinfo.cxx |
|
b/src/ohinfo.cxx |
|
... |
|
... |
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
|
17 |
|
18 |
#include "ohinfo.hxx"
|
18 |
#include "ohinfo.hxx"
|
19 |
|
19 |
|
20 |
#include <upnp/upnp.h> // for UPNP_E_SUCCESS
|
20 |
#include <upnp/upnp.h>
|
21 |
|
21 |
|
22 |
#include <functional> // for _Bind, bind, _1, _2
|
22 |
#include <functional>
|
23 |
#include <iostream> // for endl
|
23 |
#include <iostream>
|
24 |
#include <string> // for string
|
24 |
#include <string>
|
25 |
#include <unordered_map> // for unordered_map, etc
|
25 |
#include <unordered_map>
|
26 |
#include <utility> // for pair
|
26 |
#include <utility>
|
27 |
#include <vector> // for vector
|
27 |
#include <vector>
|
28 |
|
28 |
|
29 |
#include "libupnpp/log.hxx" // for LOGDEB
|
29 |
#include "libupnpp/log.hxx"
|
30 |
#include "libupnpp/soaphelp.hxx" // for SoapOutgoing, i2s, SoapIncoming
|
30 |
#include "libupnpp/soaphelp.hxx"
|
31 |
|
31 |
|
32 |
#include "mpdcli.hxx" // for MpdStatus, etc
|
32 |
#include "mpdcli.hxx"
|
33 |
#include "upmpd.hxx" // for UpMpd
|
33 |
#include "upmpd.hxx"
|
34 |
#include "upmpdutils.hxx" // for didlmake, diffmaps
|
34 |
#include "upmpdutils.hxx"
|
|
|
35 |
#include "ohplaylist.hxx"
|
35 |
|
36 |
|
36 |
using namespace std;
|
37 |
using namespace std;
|
37 |
using namespace std::placeholders;
|
38 |
using namespace std::placeholders;
|
38 |
|
39 |
|
39 |
static const string sTpProduct("urn:av-openhome-org:service:Info:1");
|
40 |
static const string sTpProduct("urn:av-openhome-org:service:Info:1");
|
40 |
static const string sIdProduct("urn:av-openhome-org:serviceId:Info");
|
41 |
static const string sIdProduct("urn:av-openhome-org:serviceId:Info");
|
41 |
|
42 |
|
42 |
OHInfo::OHInfo(UpMpd *dev)
|
43 |
OHInfo::OHInfo(UpMpd *dev)
|
43 |
: OHService(sTpProduct, sIdProduct, dev)
|
44 |
: OHService(sTpProduct, sIdProduct, dev), m_ohpl(0)
|
44 |
{
|
45 |
{
|
45 |
dev->addActionMapping(this, "Counters",
|
46 |
dev->addActionMapping(this, "Counters",
|
46 |
bind(&OHInfo::counters, this, _1, _2));
|
47 |
bind(&OHInfo::counters, this, _1, _2));
|
47 |
dev->addActionMapping(this, "Track",
|
48 |
dev->addActionMapping(this, "Track",
|
48 |
bind(&OHInfo::track, this, _1, _2));
|
49 |
bind(&OHInfo::track, this, _1, _2));
|
|
... |
|
... |
58 |
bool is_song = (mpds.state == MpdStatus::MPDS_PLAY) ||
|
59 |
bool is_song = (mpds.state == MpdStatus::MPDS_PLAY) ||
|
59 |
(mpds.state == MpdStatus::MPDS_PAUSE);
|
60 |
(mpds.state == MpdStatus::MPDS_PAUSE);
|
60 |
|
61 |
|
61 |
if (is_song) {
|
62 |
if (is_song) {
|
62 |
uri = mpds.currentsong.uri;
|
63 |
uri = mpds.currentsong.uri;
|
|
|
64 |
// Prefer metadata from cache (copy from media server) to
|
|
|
65 |
// whatever comes from mpd
|
|
|
66 |
if (m_ohpl && m_ohpl->cacheFind(uri, metadata)) {
|
|
|
67 |
return;
|
|
|
68 |
}
|
63 |
metadata = didlmake(mpds.currentsong);
|
69 |
metadata = didlmake(mpds.currentsong);
|
64 |
} else {
|
70 |
} else {
|
65 |
uri.clear();
|
71 |
uri.clear();
|
66 |
metadata.clear();
|
72 |
metadata.clear();
|
67 |
}
|
73 |
}
|