Go to the documentation of this file.
11 #include "libmythbase/mythconfig.h"
14 #include <QNetworkInterface>
15 #include <QNetworkProxy>
17 #include <QScriptEngine>
21 #ifdef USING_LIBDNS_SD
52 LOG(VB_UPNP, LOG_INFO,
"MediaServer()");
57 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Init(): Begin");
59 int nPort =
GetMythDB()->GetNumSetting(
"BackendStatusPort", 6544);
60 int nSSLPort =
GetMythDB()->GetNumSetting(
"BackendSSLPort", nPort + 10);
61 int nWSPort = nPort + 5;
68 if (!pHttpServer->isListening())
70 pHttpServer->setProxy(QNetworkProxy::NoProxy);
72 if (!pHttpServer->listen(nPort))
74 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer Create Error");
76 pHttpServer =
nullptr;
82 if (!pHttpServer->listen(nSSLPort,
true,
kSSLServer))
84 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer failed to create SSL server");
95 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: WebSocketServer Create Error");
102 sFileName +=
"devicemaster.xml";
104 sFileName +=
"deviceslave.xml";
110 LOG(VB_UPNP, LOG_INFO,
111 "MediaServer: Loading UPnp Description " + sFileName);
119 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering Http Server Extensions.");
123 pHttpServer->RegisterExtension( pHtmlServer );
124 pHttpServer->RegisterExtension(
new HttpConfig() );
139 LOG(VB_GENERAL, LOG_NOTICE,
140 "*** The UPNP service has been DISABLED with the "
141 "--noupnp option ***");
146 if (IPAddrList.contains(QHostAddress(QHostAddress::AnyIPv4)))
148 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv4));
149 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv6));
150 IPAddrList.append(QNetworkInterface::allAddresses());
153 if (IPAddrList.isEmpty())
155 LOG(VB_GENERAL, LOG_ERR,
156 "MediaServer: No Listenable IP Addresses found - "
165 if (
Initialize( IPAddrList, nPort, pHttpServer ))
176 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering MS_MediaReceiverRegistrar Service.");
181 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ConnnectionManager Service.");
187 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ContentDirectory Service.");
196 LOG(VB_UPNP, LOG_INFO,
197 "MediaServer: Registering UPnpCDSTv Extension");
201 LOG(VB_UPNP, LOG_INFO,
202 "MediaServer: Registering UPnpCDSMusic Extension");
206 LOG(VB_UPNP, LOG_INFO,
207 "MediaServer: Registering UPnpCDSVideo Extension");
213 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Adding Context Listener");
220 #ifdef USING_LIBDNS_SD
227 QByteArray name(
"Mythbackend on ");
229 QByteArray txt(bIsMaster ?
"\x06master" :
"\x05slave");
230 m_bonjour->Register(nPort,
"_mythbackend._tcp", name, txt);
236 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Init(): End");
254 #ifdef USING_LIBDNS_SD
263 void MediaServer::customEvent( QEvent *e )
265 if (MythEvent::Type(e->type()) == MythEvent::MythEventMessage)
268 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.