11#include "libmythbase/mythconfig.h"
15#include <QNetworkInterface>
16#include <QNetworkProxy>
50 LOG(VB_UPNP, LOG_INFO,
"MediaServer()");
55 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Init(): Begin");
57 int nPort =
GetMythDB()->GetNumSetting(
"BackendStatusPort", 6544);
58 int nSSLPort =
GetMythDB()->GetNumSetting(
"BackendSSLPort", nPort + 10);
59 int nWSPort = nPort + 5;
66 if (!pHttpServer->isListening())
68 pHttpServer->setProxy(QNetworkProxy::NoProxy);
70 if (!pHttpServer->listen(nPort))
72 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer Create Error");
74 pHttpServer =
nullptr;
80 if (!pHttpServer->listen(nSSLPort,
true,
kSSLServer))
82 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer failed to create SSL server");
93 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: WebSocketServer Create Error");
100 sFileName +=
"devicemaster.xml";
102 sFileName +=
"deviceslave.xml";
108 LOG(VB_UPNP, LOG_INFO,
109 "MediaServer: Loading UPnp Description " + sFileName);
117 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering Http Server Extensions.");
123 LOG(VB_GENERAL, LOG_NOTICE,
124 "*** The UPNP service has been DISABLED with the "
125 "--noupnp option ***");
130 if (IPAddrList.contains(QHostAddress(QHostAddress::AnyIPv4)))
132 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv4));
133 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv6));
134 IPAddrList.append(QNetworkInterface::allAddresses());
137 if (IPAddrList.isEmpty())
139 LOG(VB_GENERAL, LOG_ERR,
140 "MediaServer: No Listenable IP Addresses found - "
149 if (
Initialize( IPAddrList, nPort, pHttpServer ))
160 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering MS_MediaReceiverRegistrar Service.");
165 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ConnnectionManager Service.");
171 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ContentDirectory Service.");
180 LOG(VB_UPNP, LOG_INFO,
181 "MediaServer: Registering UPnpCDSTv Extension");
185 LOG(VB_UPNP, LOG_INFO,
186 "MediaServer: Registering UPnpCDSMusic Extension");
190 LOG(VB_UPNP, LOG_INFO,
191 "MediaServer: Registering UPnpCDSVideo Extension");
197 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Adding Context Listener");
211 QByteArray name(
"Mythbackend on ");
213 QByteArray txt(bIsMaster ?
"\x06master" :
"\x05slave");
214 m_bonjour->Register(nPort,
"_mythbackend._tcp", name, txt);
220 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Init(): End");
247void MediaServer::customEvent( QEvent *e )
249 if (MythEvent::Type(e->type()) == MythEvent::MythEventMessage)
252 QString message = me->
Message();
void RegisterExtension(HttpServerExtension *pExtension)
QString GetHostName(void)
This class is used as a container for messages.
const QString & Message() const
void addListener(QObject *listener)
Add a listener to the observable.
void removeListener(QObject *listener)
Remove a listener to the observable.
static QList< QHostAddress > DefaultListen(void)
bool listen(QList< QHostAddress > addrs, quint16 port, bool requireall=true, PoolServerType type=kTCPServer)
bool isListening(void) const
void RegisterExtension(UPnpCDSExtension *pExtension)
void UnregisterExtension(UPnpCDSExtension *pExtension)
bool Load(const QString &sFileName)
static UPnpDevice * RootDevice()
HttpServer * m_pHttpServer
bool Initialize(int nServicePort, HttpServer *pHttpServer)
static UPnpDeviceDesc g_UPnpDeviceDesc
The WebSocket server, which listens for connections.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
QString GetShareDir(void)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QStringList GetSourceProtocolInfos()
Return a QStringList containing the supported Source Protocols.