Go to the documentation of this file.
11 #include "libmythbase/mythconfig.h"
14 #include <QNetworkInterface>
15 #include <QNetworkProxy>
51 LOG(VB_UPNP, LOG_INFO,
"MediaServer()");
56 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Init(): Begin");
58 int nPort =
GetMythDB()->GetNumSetting(
"BackendStatusPort", 6544);
59 int nSSLPort =
GetMythDB()->GetNumSetting(
"BackendSSLPort", nPort + 10);
60 int nWSPort = nPort + 5;
67 if (!pHttpServer->isListening())
69 pHttpServer->setProxy(QNetworkProxy::NoProxy);
71 if (!pHttpServer->listen(nPort))
73 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer Create Error");
75 pHttpServer =
nullptr;
81 if (!pHttpServer->listen(nSSLPort,
true,
kSSLServer))
83 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer failed to create SSL server");
94 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: WebSocketServer Create Error");
101 sFileName +=
"devicemaster.xml";
103 sFileName +=
"deviceslave.xml";
109 LOG(VB_UPNP, LOG_INFO,
110 "MediaServer: Loading UPnp Description " + sFileName);
118 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering Http Server Extensions.");
122 pHttpServer->RegisterExtension( pHtmlServer );
123 pHttpServer->RegisterExtension(
new HttpConfig() );
138 LOG(VB_GENERAL, LOG_NOTICE,
139 "*** The UPNP service has been DISABLED with the "
140 "--noupnp option ***");
145 if (IPAddrList.contains(QHostAddress(QHostAddress::AnyIPv4)))
147 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv4));
148 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv6));
149 IPAddrList.append(QNetworkInterface::allAddresses());
152 if (IPAddrList.isEmpty())
154 LOG(VB_GENERAL, LOG_ERR,
155 "MediaServer: No Listenable IP Addresses found - "
164 if (
Initialize( IPAddrList, nPort, pHttpServer ))
175 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering MS_MediaReceiverRegistrar Service.");
180 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ConnnectionManager Service.");
186 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ContentDirectory Service.");
195 LOG(VB_UPNP, LOG_INFO,
196 "MediaServer: Registering UPnpCDSTv Extension");
200 LOG(VB_UPNP, LOG_INFO,
201 "MediaServer: Registering UPnpCDSMusic Extension");
205 LOG(VB_UPNP, LOG_INFO,
206 "MediaServer: Registering UPnpCDSVideo Extension");
212 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Adding Context Listener");
226 QByteArray name(
"Mythbackend on ");
228 QByteArray txt(bIsMaster ?
"\x06master" :
"\x05slave");
229 m_bonjour->Register(nPort,
"_mythbackend._tcp", name, txt);
235 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Init(): End");
262 void MediaServer::customEvent( QEvent *e )
264 if (MythEvent::Type(e->type()) == MythEvent::MythEventMessage)
267 QString message = me->
Message();
QStringList GetSourceProtocolInfos()
Return a QStringList containing the supported Source Protocols.
void RegisterExtension(HttpServerExtension *pExtension)
bool isListening(void) const
This class is used as a container for messages.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
const QString & Message() const
bool Initialize(int nServicePort, HttpServer *pHttpServer)
void addListener(QObject *listener)
Add a listener to the observable.
void UnregisterExtension(UPnpCDSExtension *pExtension)
QString GetShareDir(void)
static QList< QHostAddress > DefaultListen(void)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static UPnpDevice * RootDevice()
bool Load(const QString &sFileName)
bool listen(QList< QHostAddress > addrs, quint16 port, bool requireall=true, PoolServerType type=kTCPServer)
QString GetHostName(void)
HttpServer * m_pHttpServer
The WebSocket server, which listens for connections.
void RegisterExtension(UPnpCDSExtension *pExtension)
static UPnpDeviceDesc g_UPnpDeviceDesc
void removeListener(QObject *listener)
Remove a listener to the observable.