a/src/upmpdutils.hxx b/src/upmpdutils.hxx
...
...
20
#include <string>
20
#include <string>
21
#include <unordered_map>
21
#include <unordered_map>
22
#include <vector>
22
#include <vector>
23
#include <unordered_set>
23
#include <unordered_set>
24
24
25
#include "libupnpp/control/cdircontent.hxx"
25
namespace UPnPClient {
26
    class UPnPDirObject;
27
};
26
28
29
// This was originally purely a translation of data from mpd. Extended
30
// to general purpose track/container descriptor
27
class UpSong;
31
class UpSong {
32
public:
33
    UpSong()
34
  : duration_secs(0), mpdid(0),
35
    iscontainer(false), searchable(false) {
36
    }
37
    void clear() {
38
  *this = UpSong();
39
    }
40
    std::string id;
41
    std::string parentid;
42
    std::string uri;
43
    std::string name; // only set for radios apparently. 
44
    std::string artist; // Reused as annot for containers
45
    std::string album;
46
    std::string title;
47
    std::string tracknum;
48
    std::string genre;
49
    std::string artUri; // This does not come from mpd, but we sometimes add it
50
51
    unsigned int duration_secs;
52
    int mpdid;
53
    bool iscontainer;
54
    bool searchable;
55
56
    std::string dump() {
57
        return std::string("Uri [") + uri + "] Artist [" + artist + "] Album ["
58
            +  album + "] Title [" + title + "] Tno [" + tracknum + "]";
59
    }
60
    // Format to DIDL fragment 
61
    std::string didl();
62
63
    static UpSong container(const std::string& i, const std::string& p,
64
              const std::string& t, bool s = true,
65
              const std::string& annot = std::string()) {
66
  UpSong song;
67
  song.iscontainer = true;
68
  song.id = i; song.parentid = p; song.title = t; song.searchable = s;
69
  song.artist = annot;
70
  return song;
71
    }
72
};
28
73
29
// Convert between db value to percent values (Get/Set Volume and VolumeDb)
74
// Convert between db value to percent values (Get/Set Volume and VolumeDb)
30
extern int percentodbvalue(int value);
75
extern int percentodbvalue(int value);
31
extern int dbvaluetopercent(int dbvalue);
76
extern int dbvaluetopercent(int dbvalue);
32
77
...
...
36
// null data are equivalent
81
// null data are equivalent
37
extern const std::string& mapget(
82
extern const std::string& mapget(
38
    const std::unordered_map<std::string, std::string>& im, 
83
    const std::unordered_map<std::string, std::string>& im, 
39
    const std::string& k);
84
    const std::string& k);
40
85
41
// Format a didl fragment from MPD status data
86
// Format a didl fragment from MPD status data. Used by the renderer
42
extern std::string didlmake(const UpSong& song);
87
extern std::string didlmake(const UpSong& song);
88
89
// Wrap DIDL entries in header / trailer
90
extern const std::string& headDIDL();
91
extern const std::string& tailDIDL();
92
extern std::string wrapDIDL(const std::string& data);
43
93
44
// Convert UPnP metadata to UpSong for mpdcli to use
94
// Convert UPnP metadata to UpSong for mpdcli to use
45
extern bool uMetaToUpSong(const std::string&, UpSong *ups);
95
extern bool uMetaToUpSong(const std::string&, UpSong *ups);
46
// Convert UPnP content directory entry object to UpSong
96
// Convert UPnP content directory entry object to UpSong
47
bool dirObjToUpSong(const UPnPClient::UPnPDirObject& dobj, UpSong *ups);
97
bool dirObjToUpSong(const UPnPClient::UPnPDirObject& dobj, UpSong *ups);