|
a/src/upmpdutils.cxx |
|
b/src/upmpdutils.cxx |
|
... |
|
... |
120 |
}
|
120 |
}
|
121 |
}
|
121 |
}
|
122 |
return out;
|
122 |
return out;
|
123 |
}
|
123 |
}
|
124 |
|
124 |
|
|
|
125 |
|
|
|
126 |
string UpSong::didl()
|
|
|
127 |
{
|
|
|
128 |
ostringstream ss;
|
|
|
129 |
string typetag;
|
|
|
130 |
if (iscontainer) {
|
|
|
131 |
typetag = "container";
|
|
|
132 |
} else {
|
|
|
133 |
typetag = "item";
|
|
|
134 |
}
|
|
|
135 |
ss << "<" << typetag << " id=\"" << id << "\" parentID=\"" <<
|
|
|
136 |
parentid << "\" restricted=\"1\" searchable=\"" <<
|
|
|
137 |
(searchable ? string("1") : string("0")) << "\">" <<
|
|
|
138 |
"<dc:title>" << SoapHelp::xmlQuote(title) << "</dc:title>";
|
|
|
139 |
if (iscontainer) {
|
|
|
140 |
ss << "<upnp:class>object.container</upnp:class>" <<
|
|
|
141 |
(artist.empty() ? string() :
|
|
|
142 |
string("<upnp:userAnnotation>" + SoapHelp::xmlQuote(artist) +
|
|
|
143 |
"</upnp:userAnnotation>"));
|
|
|
144 |
|
|
|
145 |
} else {
|
|
|
146 |
ss << "<upnp:class>object.item.audioItem.musicTrack</upnp:class>";
|
|
|
147 |
|
|
|
148 |
#define UPNPXML(FLD, TAG) \
|
|
|
149 |
if (!FLD.empty()) { \
|
|
|
150 |
ss << "<" #TAG ">" << SoapHelp::xmlQuote(FLD) << \
|
|
|
151 |
"</" #TAG ">"; \
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
UPNPXML(uri, uri);
|
|
|
155 |
UPNPXML(artist, dc:creator);
|
|
|
156 |
UPNPXML(artist, upnp:artist);
|
|
|
157 |
UPNPXML(genre, upnp:genre);
|
|
|
158 |
UPNPXML(tracknum, upnp:originalTrackNumber);
|
|
|
159 |
UPNPXML(artUri, upnp:albumArtURI);
|
|
|
160 |
|
|
|
161 |
ss << "<res " << "duration=\"" <<
|
|
|
162 |
upnpduration(duration_secs * 1000) << "\" " <<
|
|
|
163 |
"sampleFrequency=\"44100\" audioChannels=\"2\" " <<
|
|
|
164 |
"protocolInfo=\"http-get:*:audio/mpeg:*\">" <<
|
|
|
165 |
SoapHelp::xmlQuote(uri) <<
|
|
|
166 |
"</res>";
|
|
|
167 |
}
|
|
|
168 |
ss << "</" << typetag << ">";
|
|
|
169 |
return ss.str();
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
const string& headDIDL()
|
|
|
173 |
{
|
|
|
174 |
static const string head(
|
|
|
175 |
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
|
|
|
176 |
"<DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" "
|
|
|
177 |
"xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" "
|
|
|
178 |
"xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\" "
|
|
|
179 |
"xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0/\">");
|
|
|
180 |
return head;
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
const string& tailDIDL()
|
|
|
184 |
{
|
|
|
185 |
static const string tail("</DIDL-Lite>");
|
|
|
186 |
return tail;
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
string wrapDIDL(const std::string& data)
|
|
|
190 |
{
|
|
|
191 |
return headDIDL() + data + tailDIDL();
|
|
|
192 |
}
|
|
|
193 |
|
125 |
// Bogus didl fragment maker. We probably don't need a full-blown XML
|
194 |
// Bogus didl fragment maker. We probably don't need a full-blown XML
|
126 |
// helper here
|
195 |
// helper here
|
127 |
string didlmake(const UpSong& song)
|
196 |
string didlmake(const UpSong& song)
|
128 |
{
|
197 |
{
|
129 |
ostringstream ss;
|
198 |
ostringstream ss;
|