|
a/src/main.cxx |
|
b/src/main.cxx |
|
... |
|
... |
79 |
"-q 0|1\t if set, we own the mpd queue, else avoid clearing it whenever we feel like it\n"
|
79 |
"-q 0|1\t if set, we own the mpd queue, else avoid clearing it whenever we feel like it\n"
|
80 |
"-i iface \t specify network interface name to be used for UPnP\n"
|
80 |
"-i iface \t specify network interface name to be used for UPnP\n"
|
81 |
"-P upport \t specify port number to be used for UPnP\n"
|
81 |
"-P upport \t specify port number to be used for UPnP\n"
|
82 |
"-O 0|1\t decide if we run and export the OpenHome services\n"
|
82 |
"-O 0|1\t decide if we run and export the OpenHome services\n"
|
83 |
"-v \tprint version info\n"
|
83 |
"-v \tprint version info\n"
|
84 |
"-m <0|1|2|3> media server mode "
|
84 |
"-m <0|1|2|3|4> media server mode "
|
85 |
"(default, forked|only renderer|only media|combined)\n"
|
85 |
"(default, forked|only renderer|only media|combined/embedded|combined/multidev)\n"
|
86 |
"\n"
|
86 |
"\n"
|
87 |
;
|
87 |
;
|
88 |
|
88 |
|
89 |
// We can implement a Media Server in addition to the Renderer, for
|
89 |
// We can implement a Media Server in addition to the Renderer, for
|
90 |
// accessing streaming services. This can happen in several modes. In
|
90 |
// accessing streaming services. This can happen in several modes. In
|
|
... |
|
... |
93 |
// All this complication is needed because libupnp does not support
|
93 |
// All this complication is needed because libupnp does not support
|
94 |
// having several root devices in a single process, and because many
|
94 |
// having several root devices in a single process, and because many
|
95 |
// control points are confused by embedded devices.
|
95 |
// control points are confused by embedded devices.
|
96 |
//
|
96 |
//
|
97 |
// - -m 0, default, Forked: this is for the main process, which will
|
97 |
// - -m 0, default, Forked: this is for the main process, which will
|
98 |
// implement a Media Renderer device, and, if needed, fork/exec the
|
98 |
// implement a Media Renderer device, and, if needed, fork/exec the
|
99 |
// Media Server (with option -m 2)
|
99 |
// Media Server (with option -m 2)
|
100 |
// - -m 1, RdrOnly: for the main instance: be a Renderer, do not start the
|
100 |
// - -m 1, RdrOnly: for the main instance: be a Renderer, do not start the
|
101 |
// Media Server even if the configuration indicates it is needed
|
101 |
// Media Server even if the configuration indicates it is needed
|
102 |
// (this is not used in normal situations, just edit the config
|
102 |
// (this is not used in normal situations, just edit the config
|
103 |
// instead!)
|
103 |
// instead!)
|
104 |
// - -m 2, MSOnly Media Server only, this is for the process forked/execed
|
104 |
// - -m 2, MSOnly Media Server only, this is for the process forked/execed
|
105 |
// by a main Renderer process, or a standalone Media Server.
|
105 |
// by a main Renderer process, or a standalone Media Server.
|
106 |
// - -m 3, Combined: for the main process: implement the Media Server
|
106 |
// - -m 3, Combined: for the main process: implement the Media Server
|
107 |
// as an embedded device. This works just fine with, for example,
|
107 |
// as an embedded device. This works just fine with, for example,
|
108 |
// upplay, but confuses most of the other Control Points.
|
108 |
// upplay, but confuses most of the other Control Points.
|
|
|
109 |
// - -m 4, Combined: for the main process: implement the Media Server
|
|
|
110 |
// as a separate root device. Only works with a modified libupnp.
|
109 |
enum MSMode {Forked, RdrOnly, MSOnly, Combined};
|
111 |
enum MSMode {Forked, RdrOnly, MSOnly, CombinedEmbedded, CombinedMultiDev};
|
110 |
|
112 |
|
111 |
static void
|
113 |
static void
|
112 |
versionInfo(FILE *fp)
|
114 |
versionInfo(FILE *fp)
|
113 |
{
|
115 |
{
|
114 |
fprintf(fp, "Upmpdcli %s %s\n",
|
116 |
fprintf(fp, "Upmpdcli %s %s\n",
|
|
... |
|
... |
255 |
string presentationhtml(DATADIR "/presentation.html");
|
257 |
string presentationhtml(DATADIR "/presentation.html");
|
256 |
string iface;
|
258 |
string iface;
|
257 |
unsigned short upport = 0;
|
259 |
unsigned short upport = 0;
|
258 |
string upnpip;
|
260 |
string upnpip;
|
259 |
int msm = 0;
|
261 |
int msm = 0;
|
260 |
bool inprocessms = false;
|
262 |
bool inprocessms{false};
|
261 |
bool msonly = false;
|
263 |
bool msonly{false};
|
|
|
264 |
bool msroot{false};
|
262 |
|
265 |
|
263 |
const char *cp;
|
266 |
const char *cp;
|
264 |
if ((cp = getenv("UPMPD_HOST")))
|
267 |
if ((cp = getenv("UPMPD_HOST")))
|
265 |
mpdhost = cp;
|
268 |
mpdhost = cp;
|
266 |
if ((cp = getenv("UPMPD_PORT")))
|
269 |
if ((cp = getenv("UPMPD_PORT")))
|
|
... |
|
... |
316 |
default: Usage(); break;
|
319 |
default: Usage(); break;
|
317 |
}
|
320 |
}
|
318 |
b1: argc--; argv++;
|
321 |
b1: argc--; argv++;
|
319 |
}
|
322 |
}
|
320 |
|
323 |
|
321 |
if (argc != 0 || msm < 0 || msm > 3) {
|
324 |
if (argc != 0 || msm < 0 || msm > 4) {
|
322 |
Usage();
|
325 |
Usage();
|
323 |
}
|
326 |
}
|
324 |
MSMode arg_msmode = MSMode(msm);
|
327 |
MSMode arg_msmode = MSMode(msm);
|
325 |
|
328 |
|
326 |
UpMpd::Options opts;
|
329 |
UpMpd::Options opts;
|
|
... |
|
... |
450 |
switch (arg_msmode) {
|
453 |
switch (arg_msmode) {
|
451 |
case MSOnly:
|
454 |
case MSOnly:
|
452 |
inprocessms = true;
|
455 |
inprocessms = true;
|
453 |
msonly = true;
|
456 |
msonly = true;
|
454 |
break;
|
457 |
break;
|
455 |
case Combined:
|
458 |
case CombinedEmbedded:
|
456 |
inprocessms = true;
|
459 |
inprocessms = true;
|
457 |
msonly = false;
|
460 |
msonly = false;
|
|
|
461 |
msroot = false;
|
|
|
462 |
break;
|
|
|
463 |
case CombinedMultiDev:
|
|
|
464 |
inprocessms = true;
|
|
|
465 |
msonly = false;
|
|
|
466 |
msroot = true;
|
458 |
break;
|
467 |
break;
|
459 |
case RdrOnly:
|
468 |
case RdrOnly:
|
460 |
case Forked:
|
469 |
case Forked:
|
461 |
default:
|
470 |
default:
|
462 |
inprocessms = false;
|
471 |
inprocessms = false;
|
|
... |
|
... |
747 |
}
|
756 |
}
|
748 |
|
757 |
|
749 |
MediaServer *mediaserver{nullptr};
|
758 |
MediaServer *mediaserver{nullptr};
|
750 |
|
759 |
|
751 |
if (inprocessms) {
|
760 |
if (inprocessms) {
|
752 |
// Create the Media Server device.
|
761 |
// Create the Media Server device. If msonly is set, both
|
|
|
762 |
// branches do the same thing and create a root device
|
|
|
763 |
// (mediarenderer is null).
|
|
|
764 |
// The multidev modified libupnp is needed for using 2 root devices
|
753 |
mediaserver = new MediaServer(mediarenderer, string("uuid:") +
|
765 |
mediaserver = new MediaServer(msroot?nullptr:mediarenderer, string("uuid:") +
|
754 |
ids.uuidMS,ids.fnameMS, enableMediaServer);
|
766 |
ids.uuidMS,ids.fnameMS, enableMediaServer);
|
755 |
devs.push_back(mediaserver);
|
767 |
devs.push_back(mediaserver);
|
756 |
LOGDEB("Media server event loop" << endl);
|
768 |
LOGDEB("Media server event loop" << endl);
|
757 |
} else if (enableMediaServer) {
|
769 |
} else if (enableMediaServer) {
|
758 |
startMsOnlyProcess();
|
770 |
startMsOnlyProcess();
|