|
a/src/mediaserver/cdplugins/plgwithslave.cxx |
|
b/src/mediaserver/cdplugins/plgwithslave.cxx |
|
... |
|
... |
284 |
PlgWithSlave::~PlgWithSlave()
|
284 |
PlgWithSlave::~PlgWithSlave()
|
285 |
{
|
285 |
{
|
286 |
delete m;
|
286 |
delete m;
|
287 |
}
|
287 |
}
|
288 |
|
288 |
|
|
|
289 |
static void catstring(string& dest, const string& s2)
|
|
|
290 |
{
|
|
|
291 |
if (s2.empty()) {
|
|
|
292 |
return;
|
|
|
293 |
}
|
|
|
294 |
if (dest.empty()) {
|
|
|
295 |
dest = s2;
|
|
|
296 |
} else {
|
|
|
297 |
dest += string(" ") + s2;
|
|
|
298 |
}
|
|
|
299 |
}
|
|
|
300 |
|
289 |
static int resultToEntries(const string& encoded, int stidx, int cnt,
|
301 |
static int resultToEntries(const string& encoded, int stidx, int cnt,
|
290 |
vector<UpSong>& entries)
|
302 |
vector<UpSong>& entries)
|
291 |
{
|
303 |
{
|
292 |
Json::Value decoded;
|
304 |
Json::Value decoded;
|
293 |
istringstream input(encoded);
|
305 |
istringstream input(encoded);
|
|
... |
|
... |
295 |
LOGDEB0("PlgWithSlave::results: got " << decoded.size() << " entries \n");
|
307 |
LOGDEB0("PlgWithSlave::results: got " << decoded.size() << " entries \n");
|
296 |
LOGDEB1("PlgWithSlave::results: undecoded: " << decoded.dump() << endl);
|
308 |
LOGDEB1("PlgWithSlave::results: undecoded: " << decoded.dump() << endl);
|
297 |
bool dolimit = cnt > 0;
|
309 |
bool dolimit = cnt > 0;
|
298 |
|
310 |
|
299 |
for (unsigned int i = stidx; i < decoded.size(); i++) {
|
311 |
for (unsigned int i = stidx; i < decoded.size(); i++) {
|
300 |
#define JSONTOUPS(fld, nm) {song.fld = decoded[i].get(#nm, "").asString();}
|
312 |
#define JSONTOUPS(fld, nm) {catstring(song.fld, \
|
|
|
313 |
decoded[i].get(#nm, "").asString());}
|
301 |
if (dolimit && --cnt < 0) {
|
314 |
if (dolimit && --cnt < 0) {
|
302 |
break;
|
315 |
break;
|
303 |
}
|
316 |
}
|
304 |
UpSong song;
|
317 |
UpSong song;
|
305 |
JSONTOUPS(id, id);
|
318 |
JSONTOUPS(id, id);
|
|
... |
|
... |
322 |
JSONTOUPS(artist, dc:creator);
|
335 |
JSONTOUPS(artist, dc:creator);
|
323 |
JSONTOUPS(genre, upnp:genre);
|
336 |
JSONTOUPS(genre, upnp:genre);
|
324 |
JSONTOUPS(album, upnp:album);
|
337 |
JSONTOUPS(album, upnp:album);
|
325 |
JSONTOUPS(tracknum, upnp:originalTrackNumber);
|
338 |
JSONTOUPS(tracknum, upnp:originalTrackNumber);
|
326 |
JSONTOUPS(mime, res:mime);
|
339 |
JSONTOUPS(mime, res:mime);
|
|
|
340 |
|
327 |
string srate = decoded[i].get("res:samplefreq", "").asString();
|
341 |
string ss = decoded[i].get("duration", "").asString();
|
328 |
if (!srate.empty()) {
|
342 |
if (!ss.empty()) {
|
329 |
song.samplefreq = atoi(srate.c_str());
|
343 |
song.duration_secs = atoi(ss.c_str());
|
330 |
}
|
344 |
}
|
331 |
string sdur = decoded[i].get("duration", "").asString();
|
345 |
ss = decoded[i].get("res:size", "").asString();
|
332 |
if (!sdur.empty()) {
|
346 |
if (!ss.empty()) {
|
|
|
347 |
song.size = atoll(ss.c_str());
|
|
|
348 |
}
|
|
|
349 |
ss = decoded[i].get("res:bitrate", "").asString();
|
|
|
350 |
if (!ss.empty()) {
|
333 |
song.duration_secs = atoi(sdur.c_str());
|
351 |
song.bitrate = atoi(ss.c_str());
|
|
|
352 |
}
|
|
|
353 |
ss = decoded[i].get("res:samplefreq", "").asString();
|
|
|
354 |
if (!ss.empty()) {
|
|
|
355 |
song.samplefreq = atoi(ss.c_str());
|
|
|
356 |
}
|
|
|
357 |
ss = decoded[i].get("res:channels", "").asString();
|
|
|
358 |
if (!ss.empty()) {
|
|
|
359 |
song.channels = atoi(ss.c_str());
|
334 |
}
|
360 |
}
|
335 |
} else {
|
361 |
} else {
|
336 |
LOGERR("PlgWithSlave::result: bad type in entry: " << stp <<
|
362 |
LOGERR("PlgWithSlave::result: bad type in entry: " << stp <<
|
337 |
"(title: " << song.title << ")\n");
|
363 |
"(title: " << song.title << ")\n");
|
338 |
continue;
|
364 |
continue;
|