|
a/src/upmpd.cxx |
|
b/src/upmpd.cxx |
|
... |
|
... |
35 |
|
35 |
|
36 |
#include "libupnpp/device/device.hxx" // for UpnpDevice, UpnpService
|
36 |
#include "libupnpp/device/device.hxx" // for UpnpDevice, UpnpService
|
37 |
#include "libupnpp/log.hxx" // for LOGFAT, LOGERR, Logger, etc
|
37 |
#include "libupnpp/log.hxx" // for LOGFAT, LOGERR, Logger, etc
|
38 |
#include "libupnpp/upnpplib.hxx" // for LibUPnP
|
38 |
#include "libupnpp/upnpplib.hxx" // for LibUPnP
|
39 |
|
39 |
|
40 |
#include "avtransport.hxx" // for UpMpdAVTransport
|
40 |
#include "avtransport.hxx"
|
41 |
#include "conman.hxx" // for UpMpdConMan
|
41 |
#include "conman.hxx"
|
42 |
#include "mpdcli.hxx" // for MPDCli
|
42 |
#include "mpdcli.hxx"
|
43 |
#include "ohinfo.hxx" // for OHInfo
|
43 |
#include "ohinfo.hxx"
|
44 |
#include "ohplaylist.hxx" // for OHPlaylist
|
44 |
#include "ohplaylist.hxx"
|
45 |
#include "ohproduct.hxx" // for OHProduct
|
45 |
#include "ohradio.hxx"
|
|
|
46 |
#include "ohproduct.hxx"
|
46 |
#include "ohreceiver.hxx"
|
47 |
#include "ohreceiver.hxx"
|
47 |
#include "ohtime.hxx" // for OHTime
|
48 |
#include "ohtime.hxx"
|
48 |
#include "ohvolume.hxx" // for OHVolume
|
49 |
#include "ohvolume.hxx"
|
49 |
#include "renderctl.hxx" // for UpMpdRenderCtl
|
50 |
#include "renderctl.hxx"
|
50 |
#include "upmpdutils.hxx" // for path_cat, Pidfile, regsub1, etc
|
51 |
#include "upmpdutils.hxx"
|
51 |
#include "execmd.h"
|
52 |
#include "execmd.h"
|
52 |
#include "httpfs.hxx"
|
53 |
#include "httpfs.hxx"
|
53 |
#include "ohsndrcv.hxx"
|
54 |
#include "ohsndrcv.hxx"
|
54 |
|
55 |
|
55 |
using namespace std;
|
56 |
using namespace std;
|
|
... |
|
... |
81 |
m_services.push_back(new OHInfo(this));
|
82 |
m_services.push_back(new OHInfo(this));
|
82 |
m_services.push_back(new OHTime(this));
|
83 |
m_services.push_back(new OHTime(this));
|
83 |
m_services.push_back(new OHVolume(this));
|
84 |
m_services.push_back(new OHVolume(this));
|
84 |
m_ohpl = new OHPlaylist(this, opts.ohmetasleep);
|
85 |
m_ohpl = new OHPlaylist(this, opts.ohmetasleep);
|
85 |
m_services.push_back(m_ohpl);
|
86 |
m_services.push_back(m_ohpl);
|
|
|
87 |
m_ohrd = new OHRadio(this);
|
|
|
88 |
m_services.push_back(m_ohrd);
|
86 |
if (m_options & upmpdOhReceiver) {
|
89 |
if (m_options & upmpdOhReceiver) {
|
87 |
struct OHReceiverParams parms;
|
90 |
struct OHReceiverParams parms;
|
88 |
if (opts.schttpport)
|
91 |
if (opts.schttpport)
|
89 |
parms.httpport = opts.schttpport;
|
92 |
parms.httpport = opts.schttpport;
|
90 |
if (!opts.scplaymethod.empty()) {
|
93 |
if (!opts.scplaymethod.empty()) {
|
|
... |
|
... |
177 |
|
180 |
|
178 |
static string datadir(DATADIR "/");
|
181 |
static string datadir(DATADIR "/");
|
179 |
|
182 |
|
180 |
// Global
|
183 |
// Global
|
181 |
string g_configfilename(CONFIGDIR "/upmpdcli.conf");
|
184 |
string g_configfilename(CONFIGDIR "/upmpdcli.conf");
|
|
|
185 |
ConfSimple *g_config;
|
182 |
|
186 |
|
183 |
static void onsig(int)
|
187 |
static void onsig(int)
|
184 |
{
|
188 |
{
|
185 |
LOGDEB("Got sig" << endl);
|
189 |
LOGDEB("Got sig" << endl);
|
186 |
dev->shouldExit();
|
190 |
dev->shouldExit();
|
|
... |
|
... |
294 |
string cachedir;
|
298 |
string cachedir;
|
295 |
string onstart;
|
299 |
string onstart;
|
296 |
string onstop;
|
300 |
string onstop;
|
297 |
string onvolumechange;
|
301 |
string onvolumechange;
|
298 |
if (!g_configfilename.empty()) {
|
302 |
if (!g_configfilename.empty()) {
|
299 |
ConfSimple config(g_configfilename.c_str(), 1, true);
|
303 |
g_config = new ConfSimple(g_configfilename.c_str(), 1, true);
|
300 |
if (!config.ok()) {
|
304 |
if (!g_config || !g_config->ok()) {
|
301 |
cerr << "Could not open config: " << g_configfilename << endl;
|
305 |
cerr << "Could not open config: " << g_configfilename << endl;
|
302 |
return 1;
|
306 |
return 1;
|
303 |
}
|
307 |
}
|
|
|
308 |
|
304 |
string value;
|
309 |
string value;
|
305 |
if (!(op_flags & OPT_d))
|
310 |
if (!(op_flags & OPT_d))
|
306 |
config.get("logfilename", logfilename);
|
311 |
g_config->get("logfilename", logfilename);
|
307 |
if (!(op_flags & OPT_f))
|
312 |
if (!(op_flags & OPT_f))
|
308 |
config.get("friendlyname", friendlyname);
|
313 |
g_config->get("friendlyname", friendlyname);
|
309 |
if (!(op_flags & OPT_l) && config.get("loglevel", value))
|
314 |
if (!(op_flags & OPT_l) && g_config->get("loglevel", value))
|
310 |
loglevel = atoi(value.c_str());
|
315 |
loglevel = atoi(value.c_str());
|
311 |
if (!(op_flags & OPT_h))
|
316 |
if (!(op_flags & OPT_h))
|
312 |
config.get("mpdhost", mpdhost);
|
317 |
g_config->get("mpdhost", mpdhost);
|
313 |
if (!(op_flags & OPT_p) && config.get("mpdport", value)) {
|
318 |
if (!(op_flags & OPT_p) && g_config->get("mpdport", value)) {
|
314 |
mpdport = atoi(value.c_str());
|
319 |
mpdport = atoi(value.c_str());
|
315 |
}
|
320 |
}
|
316 |
config.get("mpdpassword", mpdpassword);
|
321 |
g_config->get("mpdpassword", mpdpassword);
|
317 |
if (!(op_flags & OPT_q) && config.get("ownqueue", value)) {
|
322 |
if (!(op_flags & OPT_q) && g_config->get("ownqueue", value)) {
|
318 |
ownqueue = atoi(value.c_str()) != 0;
|
323 |
ownqueue = atoi(value.c_str()) != 0;
|
319 |
}
|
324 |
}
|
320 |
if (config.get("openhome", value)) {
|
325 |
if (g_config->get("openhome", value)) {
|
321 |
enableOH = atoi(value.c_str()) != 0;
|
326 |
enableOH = atoi(value.c_str()) != 0;
|
322 |
}
|
327 |
}
|
323 |
if (config.get("upnpav", value)) {
|
328 |
if (g_config->get("upnpav", value)) {
|
324 |
enableAV = atoi(value.c_str()) != 0;
|
329 |
enableAV = atoi(value.c_str()) != 0;
|
325 |
}
|
330 |
}
|
326 |
if (config.get("ohmetapersist", value)) {
|
331 |
if (g_config->get("ohmetapersist", value)) {
|
327 |
ohmetapersist = atoi(value.c_str()) != 0;
|
332 |
ohmetapersist = atoi(value.c_str()) != 0;
|
328 |
}
|
333 |
}
|
329 |
config.get("iconpath", iconpath);
|
334 |
g_config->get("iconpath", iconpath);
|
330 |
config.get("presentationhtml", presentationhtml);
|
335 |
g_config->get("presentationhtml", presentationhtml);
|
331 |
config.get("cachedir", cachedir);
|
336 |
g_config->get("cachedir", cachedir);
|
332 |
config.get("onstart", onstart);
|
337 |
g_config->get("onstart", onstart);
|
333 |
config.get("onstop", onstop);
|
338 |
g_config->get("onstop", onstop);
|
334 |
config.get("onvolumechange", onvolumechange);
|
339 |
g_config->get("onvolumechange", onvolumechange);
|
335 |
if (!(op_flags & OPT_i)) {
|
340 |
if (!(op_flags & OPT_i)) {
|
336 |
config.get("upnpiface", iface);
|
341 |
g_config->get("upnpiface", iface);
|
337 |
if (iface.empty()) {
|
342 |
if (iface.empty()) {
|
338 |
config.get("upnpip", upnpip);
|
343 |
g_config->get("upnpip", upnpip);
|
339 |
}
|
|
|
340 |
}
|
344 |
}
|
|
|
345 |
}
|
341 |
if (!(op_flags & OPT_P) && config.get("upnpport", value)) {
|
346 |
if (!(op_flags & OPT_P) && g_config->get("upnpport", value)) {
|
342 |
upport = atoi(value.c_str());
|
347 |
upport = atoi(value.c_str());
|
343 |
}
|
348 |
}
|
344 |
if (config.get("schttpport", value))
|
349 |
if (g_config->get("schttpport", value))
|
345 |
opts.schttpport = atoi(value.c_str());
|
350 |
opts.schttpport = atoi(value.c_str());
|
346 |
config.get("scplaymethod", opts.scplaymethod);
|
351 |
g_config->get("scplaymethod", opts.scplaymethod);
|
347 |
config.get("sc2mpd", sc2mpdpath);
|
352 |
g_config->get("sc2mpd", sc2mpdpath);
|
348 |
if (config.get("ohmetasleep", value))
|
353 |
if (g_config->get("ohmetasleep", value))
|
349 |
opts.ohmetasleep = atoi(value.c_str());
|
354 |
opts.ohmetasleep = atoi(value.c_str());
|
350 |
|
355 |
|
351 |
config.get("scsenderpath", senderpath);
|
356 |
g_config->get("scsenderpath", senderpath);
|
352 |
if (config.get("scsendermpdport", value))
|
357 |
if (g_config->get("scsendermpdport", value))
|
353 |
sendermpdport = atoi(value.c_str());
|
358 |
sendermpdport = atoi(value.c_str());
|
354 |
}
|
359 |
}
|
355 |
if (Logger::getTheLog(logfilename) == 0) {
|
360 |
if (Logger::getTheLog(logfilename) == 0) {
|
356 |
cerr << "Can't initialize log" << endl;
|
361 |
cerr << "Can't initialize log" << endl;
|
357 |
return 1;
|
362 |
return 1;
|