11 #include "libmythbase/mythconfig.h"
14 #include <QNetworkInterface>
15 #include <QNetworkProxy>
17 #include <QScriptEngine>
21 #ifdef USING_LIBDNS_SD
61 LOG(VB_UPNP, LOG_INFO,
"MediaServer()");
66 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Init(): Begin");
68 int nPort =
GetMythDB()->GetNumSetting(
"BackendStatusPort", 6544);
69 int nSSLPort =
GetMythDB()->GetNumSetting(
"BackendSSLPort", nPort + 10);
70 int nWSPort = nPort + 5;
77 if (!pHttpServer->isListening())
79 pHttpServer->setProxy(QNetworkProxy::NoProxy);
81 if (!pHttpServer->listen(nPort))
83 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer Create Error");
85 pHttpServer =
nullptr;
91 if (!pHttpServer->listen(nSSLPort,
true,
kSSLServer))
93 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer failed to create SSL server");
104 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: WebSocketServer Create Error");
111 sFileName +=
"devicemaster.xml";
113 sFileName +=
"deviceslave.xml";
119 LOG(VB_UPNP, LOG_INFO,
120 "MediaServer: Loading UPnp Description " + sFileName);
128 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering Http Server Extensions.");
132 pHttpServer->RegisterExtension( pHtmlServer );
133 pHttpServer->RegisterExtension(
new HttpConfig() );
157 QScriptEngine* pEngine = pHtmlServer->ScriptEngine();
159 pEngine->globalObject().setProperty(
"Myth" ,
160 pEngine->scriptValueFromQMetaObject< ScriptableMyth >() );
161 pEngine->globalObject().setProperty(
"Guide" ,
162 pEngine->scriptValueFromQMetaObject< ScriptableGuide >() );
163 pEngine->globalObject().setProperty(
"Content",
164 pEngine->scriptValueFromQMetaObject< ScriptableContent >() );
165 pEngine->globalObject().setProperty(
"Dvr" ,
166 pEngine->scriptValueFromQMetaObject< ScriptableDvr >() );
167 pEngine->globalObject().setProperty(
"Channel",
168 pEngine->scriptValueFromQMetaObject< ScriptableChannel >() );
169 pEngine->globalObject().setProperty(
"Video" ,
170 pEngine->scriptValueFromQMetaObject< ScriptableVideo >() );
171 pEngine->globalObject().setProperty(
"Music" ,
172 pEngine->scriptValueFromQMetaObject< ScriptableVideo >() );
173 pEngine->globalObject().setProperty(
"Capture" ,
174 pEngine->scriptValueFromQMetaObject< ScriptableCapture >() );
175 pEngine->globalObject().setProperty(
"Image" ,
176 pEngine->scriptValueFromQMetaObject< ScriptableImage >() );
183 LOG(VB_GENERAL, LOG_NOTICE,
184 "*** The UPNP service has been DISABLED with the "
185 "--noupnp option ***");
190 if (IPAddrList.contains(QHostAddress(QHostAddress::AnyIPv4)))
192 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv4));
193 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv6));
194 IPAddrList.append(QNetworkInterface::allAddresses());
197 if (IPAddrList.isEmpty())
199 LOG(VB_GENERAL, LOG_ERR,
200 "MediaServer: No Listenable IP Addresses found - "
209 if (
Initialize( IPAddrList, nPort, pHttpServer ))
220 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering MS_MediaReceiverRegistrar Service.");
225 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ConnnectionManager Service.");
231 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ContentDirectory Service.");
240 LOG(VB_UPNP, LOG_INFO,
241 "MediaServer: Registering UPnpCDSTv Extension");
245 LOG(VB_UPNP, LOG_INFO,
246 "MediaServer: Registering UPnpCDSMusic Extension");
250 LOG(VB_UPNP, LOG_INFO,
251 "MediaServer: Registering UPnpCDSVideo Extension");
257 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Adding Context Listener");
264 #ifdef USING_LIBDNS_SD
271 QByteArray name(
"Mythbackend on ");
273 QByteArray txt(bIsMaster ?
"\x06master" :
"\x05slave");
274 m_bonjour->Register(nPort,
"_mythbackend._tcp", name, txt);
280 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Init(): End");
298 #ifdef USING_LIBDNS_SD
307 void MediaServer::customEvent( QEvent *e )
309 if (MythEvent::Type(e->type()) == MythEvent::MythEventMessage)
312 QString message = me->
Message();