|
a/src/ohradio.cxx |
|
b/src/ohradio.cxx |
|
... |
|
... |
35 |
#include "ohmetacache.hxx"
|
35 |
#include "ohmetacache.hxx"
|
36 |
#include "mpdcli.hxx"
|
36 |
#include "mpdcli.hxx"
|
37 |
#include "upmpd.hxx"
|
37 |
#include "upmpd.hxx"
|
38 |
#include "upmpdutils.hxx"
|
38 |
#include "upmpdutils.hxx"
|
39 |
#include "conftree.hxx"
|
39 |
#include "conftree.hxx"
|
|
|
40 |
#include "execmd.h"
|
40 |
|
41 |
|
41 |
using namespace std;
|
42 |
using namespace std;
|
42 |
using namespace std::placeholders;
|
43 |
using namespace std::placeholders;
|
43 |
|
44 |
|
44 |
static const string sTpProduct("urn:av-openhome-org:service:Radio:1");
|
45 |
static const string sTpProduct("urn:av-openhome-org:service:Radio:1");
|
|
... |
|
... |
225 |
}
|
226 |
}
|
226 |
|
227 |
|
227 |
int OHRadio::play(const SoapIncoming& sc, SoapOutgoing& data)
|
228 |
int OHRadio::play(const SoapIncoming& sc, SoapOutgoing& data)
|
228 |
{
|
229 |
{
|
229 |
LOGDEB("OHRadio::play" << endl);
|
230 |
LOGDEB("OHRadio::play" << endl);
|
230 |
m_dev->m_mpdcli->consume(false);
|
|
|
231 |
m_dev->m_mpdcli->single(false);
|
|
|
232 |
bool ok = m_dev->m_mpdcli->play();
|
231 |
bool ok = m_dev->m_mpdcli->play();
|
233 |
maybeWakeUp(ok);
|
232 |
maybeWakeUp(ok);
|
234 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
233 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
235 |
}
|
234 |
}
|
236 |
|
235 |
|
|
... |
|
... |
322 |
int OHRadio::setId(const SoapIncoming& sc, SoapOutgoing& data)
|
321 |
int OHRadio::setId(const SoapIncoming& sc, SoapOutgoing& data)
|
323 |
{
|
322 |
{
|
324 |
LOGDEB("OHRadio::setId" << endl);
|
323 |
LOGDEB("OHRadio::setId" << endl);
|
325 |
int id;
|
324 |
int id;
|
326 |
bool ok = sc.get("Value", &id);
|
325 |
bool ok = sc.get("Value", &id);
|
327 |
if (ok) {
|
326 |
if (!ok) {
|
|
|
327 |
return UPNP_E_INTERNAL_ERROR;
|
|
|
328 |
}
|
|
|
329 |
if (id <= 0 || id > int(o_radios.size())) {
|
|
|
330 |
LOGDEB("OHRadio::setId: bad value " << id << endl);
|
|
|
331 |
return UPNP_E_INTERNAL_ERROR;
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
string uri = o_radios[id].uri;
|
|
|
335 |
|
|
|
336 |
string cmdpath = path_cat(g_datadir, "rdpl2stream");
|
|
|
337 |
cmdpath = path_cat(cmdpath, "fetchStream.py");
|
|
|
338 |
ExecCmd cmd;
|
|
|
339 |
vector<string> args;
|
|
|
340 |
args.push_back(uri);
|
|
|
341 |
LOGDEB("OHRadio::setId: EXECUTING: " <<
|
|
|
342 |
cmdpath << " " << args[0] << endl);
|
|
|
343 |
|
|
|
344 |
if (cmd.startExec(cmdpath, args, false, true) < 0) {
|
|
|
345 |
LOGDEB("OHRadio::setId: startExec failed for " <<
|
|
|
346 |
cmdpath << " " << args[0] << endl);
|
|
|
347 |
return UPNP_E_INTERNAL_ERROR;
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
string audiourl;
|
|
|
351 |
if (cmd.getline(audiourl, 10) < 0) {
|
|
|
352 |
LOGDEB("OHRadio::setId: could not get audio url\n");
|
|
|
353 |
return UPNP_E_INTERNAL_ERROR;
|
|
|
354 |
}
|
|
|
355 |
trimstring(audiourl, "\r\n");
|
|
|
356 |
if (audiourl.empty()) {
|
|
|
357 |
LOGDEB("OHRadio::setId: audio url empty\n");
|
|
|
358 |
return UPNP_E_INTERNAL_ERROR;
|
|
|
359 |
}
|
|
|
360 |
|
|
|
361 |
m_dev->m_mpdcli->clearQueue();
|
|
|
362 |
int curpos = 0;
|
|
|
363 |
UpSong song;
|
|
|
364 |
song.album = o_radios[m_id].title;
|
|
|
365 |
song.uri = o_radios[m_id].uri;
|
|
|
366 |
int songid = m_dev->m_mpdcli->insert(audiourl, curpos, song);
|
|
|
367 |
if (songid < 0) {
|
|
|
368 |
return UPNP_E_INTERNAL_ERROR;
|
|
|
369 |
}
|
|
|
370 |
m_dev->m_mpdcli->play(curpos);
|
|
|
371 |
|
328 |
m_id = id;
|
372 |
m_id = id;
|
329 |
maybeWakeUp(ok);
|
373 |
maybeWakeUp(ok);
|
330 |
}
|
|
|
331 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
374 |
return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
|
332 |
}
|
375 |
}
|
333 |
|
376 |
|
334 |
// Return current Id. Not the same as for playlist, this is our internal channel
|
377 |
// Return current Id. Not the same as for playlist, this is our
|
335 |
// id, nothing to do with mpd's
|
378 |
// internal channel id, nothing to do with mpd's
|
336 |
int OHRadio::id(const SoapIncoming& sc, SoapOutgoing& data)
|
379 |
int OHRadio::id(const SoapIncoming& sc, SoapOutgoing& data)
|
337 |
{
|
380 |
{
|
338 |
LOGDEB("OHRadio::id" << endl);
|
381 |
LOGDEB("OHRadio::id" << endl);
|
339 |
const MpdStatus& mpds = m_dev->getMpdStatusNoUpdate();
|
382 |
const MpdStatus& mpds = m_dev->getMpdStatusNoUpdate();
|
340 |
data.addarg("Value", mpds.songid == -1 ? "0" : SoapHelp::i2s(mpds.songid));
|
383 |
data.addarg("Value", mpds.songid == -1 ? "0" : SoapHelp::i2s(mpds.songid));
|