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;
74 if (!pHttpServer->isListening())
76 pHttpServer->setProxy(QNetworkProxy::NoProxy);
78 if (!pHttpServer->listen(nPort))
80 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer Create Error");
82 pHttpServer =
nullptr;
88 if (!pHttpServer->listen(nSSLPort,
true,
kSSLServer))
90 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: HttpServer failed to create SSL server");
101 LOG(VB_GENERAL, LOG_ERR,
"MediaServer: WebSocketServer Create Error");
108 sFileName +=
"devicemaster.xml";
110 sFileName +=
"deviceslave.xml";
116 LOG(VB_UPNP, LOG_INFO,
117 "MediaServer: Loading UPnp Description " + sFileName);
125 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering Http Server Extensions.");
129 pHttpServer->RegisterExtension( pHtmlServer );
130 pHttpServer->RegisterExtension(
new HttpConfig() );
154 QScriptEngine* pEngine = pHtmlServer->ScriptEngine();
156 pEngine->globalObject().setProperty(
"Myth" ,
157 pEngine->scriptValueFromQMetaObject< ScriptableMyth >() );
158 pEngine->globalObject().setProperty(
"Guide" ,
159 pEngine->scriptValueFromQMetaObject< ScriptableGuide >() );
160 pEngine->globalObject().setProperty(
"Content",
161 pEngine->scriptValueFromQMetaObject< ScriptableContent >() );
162 pEngine->globalObject().setProperty(
"Dvr" ,
163 pEngine->scriptValueFromQMetaObject< ScriptableDvr >() );
164 pEngine->globalObject().setProperty(
"Channel",
165 pEngine->scriptValueFromQMetaObject< ScriptableChannel >() );
166 pEngine->globalObject().setProperty(
"Video" ,
167 pEngine->scriptValueFromQMetaObject< ScriptableVideo >() );
168 pEngine->globalObject().setProperty(
"Music" ,
169 pEngine->scriptValueFromQMetaObject< ScriptableVideo >() );
170 pEngine->globalObject().setProperty(
"Capture" ,
171 pEngine->scriptValueFromQMetaObject< ScriptableCapture >() );
172 pEngine->globalObject().setProperty(
"Image" ,
173 pEngine->scriptValueFromQMetaObject< ScriptableImage >() );
180 LOG(VB_GENERAL, LOG_NOTICE,
181 "*** The UPNP service has been DISABLED with the "
182 "--noupnp option ***");
187 if (IPAddrList.contains(QHostAddress(QHostAddress::AnyIPv4)))
189 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv4));
190 IPAddrList.removeAll(QHostAddress(QHostAddress::AnyIPv6));
191 IPAddrList.append(QNetworkInterface::allAddresses());
194 if (IPAddrList.isEmpty())
196 LOG(VB_GENERAL, LOG_ERR,
197 "MediaServer: No Listenable IP Addresses found - "
206 if (
Initialize( IPAddrList, nPort, pHttpServer ))
217 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering MS_MediaReceiverRegistrar Service.");
222 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ConnnectionManager Service.");
228 LOG(VB_UPNP, LOG_INFO,
"MediaServer: Registering ContentDirectory Service.");
237 LOG(VB_UPNP, LOG_INFO,
238 "MediaServer: Registering UPnpCDSTv Extension");
242 LOG(VB_UPNP, LOG_INFO,
243 "MediaServer: Registering UPnpCDSMusic Extension");
247 LOG(VB_UPNP, LOG_INFO,
248 "MediaServer: Registering UPnpCDSVideo Extension");
254 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Adding Context Listener");
261 #ifdef USING_LIBDNS_SD
268 QByteArray name(
"Mythbackend on ");
270 QByteArray txt(bIsMaster ?
"\x06master" :
"\x05slave");
271 m_bonjour->Register(nPort,
"_mythbackend._tcp", name, txt);
277 LOG(VB_UPNP, LOG_INFO,
"MediaServer::Init(): End");
295 #ifdef USING_LIBDNS_SD
304 void MediaServer::customEvent( QEvent *e )
309 QString message = me->
Message();