12#include <QCoreApplication>
20#include "libmythbase/mythconfig.h"
24#include "libmythbase/mythversion.h"
36#if CONFIG_SYSTEMD_NOTIFY
37#include <systemd/sd-daemon.h>
38static inline void ms_sd_notify(
const char *str) { sd_notify(0, str); };
43#define LOC QString("MythMediaServer: ")
44#define LOC_WARN QString("MythMediaServer, Warning: ")
45#define LOC_ERR QString("MythMediaServer, Error: ")
47int main(
int argc,
char *argv[])
68 QCoreApplication a(argc, argv);
76 QString mask(
"general");
83 if (!context.Init(
false))
85 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to init MythContext, exiting.");
91 LOG(VB_GENERAL, LOG_ERR,
"Exiting due to schema mismatch.");
101 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to connect to master server");
108 std::cerr <<
"No setting found for this machine's BackendServerIP.\n"
109 <<
"Please run setup on this machine and modify the first page\n"
110 <<
"of the general settings.\n";
116 if (!sockmanager->Listen(port))
118 LOG(VB_GENERAL, LOG_ERR,
119 "Mediaserver exiting, failed to bind to listen port.");
129 sockmanager->RegisterHandler(controlRequestHandler);
130 controlRequestHandler->ConnectToMaster();
138 int exitCode = QCoreApplication::exec();
141 delete sysEventHandler;
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
void ApplySettingsOverride(void)
Apply all overrides to the global context.
int Daemonize(void) const
Fork application into background, and detatch from terminal.
int ConfigureLogging(const QString &mask="general", bool progress=false)
Read in logging options and initialize the logging interface.
static void PrintVersion(void)
Print application version information.
void PrintHelp(void) const
Print command line option help.
Startup context for MythTV.
void SetAsBackend(bool backend)
int GetBackendServerPort(void)
Returns the locally defined backend control port.
bool ConnectToMasterServer(bool blockingClient=true, bool openEventSocket=true)
QString GetBackendServerIP(void)
Returns the IP address of the locally defined backend IP.
Handles incoming MythSystemEvent messages.
bool UpgradeTVDatabaseSchema(const bool upgradeAllowed, const bool upgradeIfNoUI, const bool informSystemd)
Called from outside dbcheck.cpp to update the schema.
@ GENERIC_EXIT_CONNECT_ERROR
Can't connect to master backend.
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
@ GENERIC_EXIT_DB_OUTOFDATE
Database needs upgrade.
@ GENERIC_EXIT_OK
Exited with no error.
@ GENERIC_EXIT_SETUP_ERROR
Incorrectly setup system.
@ GENERIC_EXIT_SOCKET_ERROR
Socket error.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
static constexpr const char * MYTH_APPNAME_MYTHMEDIASERVER
MythCommFlagCommandLineParser cmdline
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)