Skip to content

Commit

Permalink
MythFrontend status: Add details on slave backends and other frontends.
Browse files Browse the repository at this point in the history
- perform full SSDP discovery when starting the frontend and UPnP is
enabled. This ensures the frontend knows of all other UPnP devices on
the network (currently it will notify all existing devices of its
existance when starting but will not be aware of those devices).

- add information on other known frontends and slave backends to the
staus page. As noted, the filtering out of the current frontend may not
always work (but is harmless) and only one frontend will ever be
displayed per IP address (currently, UPnP will fail to start after the
fist frontend as it fails to bind to the desired port).
  • Loading branch information
Mark Kendall committed May 16, 2011
1 parent 4938c83 commit bf0d172
Showing 1 changed file with 65 additions and 5 deletions.
70 changes: 65 additions & 5 deletions mythtv/programs/mythfrontend/mediarenderer.cpp
Expand Up @@ -35,6 +35,11 @@ class MythFrontendStatus : public HttpServerExtension
pRequest->m_eResponseType = ResponseTypeHTML;
pRequest->m_mapRespHeaders[ "Cache-Control" ] = "no-cache=\"Ext\", max-age = 5000";

SSDPCacheEntries* cache = NULL;
QString ipaddress = QString();
if (!UPnp::g_IPAddrList.isEmpty())
ipaddress = UPnp::g_IPAddrList.at(0);

QString shortdateformat = gCoreContext->GetSetting("ShortDateFormat", "M/d");
QString timeformat = gCoreContext->GetSetting("TimeFormat", "h:mm AP");
QString hostname = gCoreContext->GetHostName();
Expand Down Expand Up @@ -64,19 +69,73 @@ class MythFrontendStatus : public HttpServerExtension
<< "<body>\r\n\r\n"
<< " <h1 class=\"status\">MythFrontend Status</h1>\r\n";

// This frontend
stream
<< " <div class=\"content\">\r\n"
<< " <h2 class=\"status\">This Frontend</h2>\r\n"
<< "Name : " << hostname << "<br />\r\n"
<< "Version : " << MYTH_BINARY_VERSION << "\r\n"
<< " </div>\r\n";

// Other frontends

// This will not work with multiple frontends on the same machine (upnp
// setup will fail on a second frontend anyway) and the ip address
// filtering of the current frontend may not work in all situations

cache = SSDP::Find("urn:schemas-mythtv-org:service:MythFrontend:1");
if (cache)
{
stream
<< " <div class=\"content\">\r\n"
<< " <h2 class=\"status\">Other Frontends</h2>\r\n";
cache->AddRef();
cache->Lock();
EntryMap* map = cache->GetEntryMap();
QMapIterator< QString, DeviceLocation * > i(*map);
while (i.hasNext())
{
i.next();
QUrl url(i.value()->m_sLocation);
if (url.host() != ipaddress)
{
stream << "<br />" << url.host() << "&nbsp(<a href=\""
<< url.toString(QUrl::RemovePath) << "\">Status page</a>)\r\n";
}
}
cache->Unlock();
cache->Release();
stream << " </div>\r\n";
}

// Master backend
stream
<< " <div class=\"content\">\r\n"
<< " <h2 class=\"status\">Master Backend</h2>\r\n"
<< masterhost << "&nbsp(<a href=\"http://"
<< " <h2 class=\"status\">MythTV Backends</h2>\r\n"
<< "Master: " << masterhost << "&nbsp(<a href=\"http://"
<< masterip << ":" << masterport
<< "\">Status page</a>)\r\n"
<< "\">Status page</a>)\r\n";

// Slave backends
cache = SSDP::Find("urn:schemas-mythtv-org:device:SlaveMediaServer:1");
if (cache)
{
cache->AddRef();
cache->Lock();
EntryMap* map = cache->GetEntryMap();
QMapIterator< QString, DeviceLocation * > i(*map);
while (i.hasNext())
{
i.next();
QUrl url(i.value()->m_sLocation);
stream << "<br />" << "Slave: " << url.host() << "&nbsp(<a href=\""
<< url.toString(QUrl::RemovePath) << "\">Status page</a>)\r\n";
}
cache->Unlock();
cache->Release();
}

stream
<< " </div>\r\n";

stream
Expand Down Expand Up @@ -212,14 +271,15 @@ MediaRenderer::MediaRenderer()

Start();

// ensure the frontend is aware of all backends (slave and master) and
// other frontends
SSDP::Instance()->PerformSearch("ssdp:all");
}
else
{
VERBOSE(VB_IMPORTANT, "MediaRenderer::Unable to Initialize UPnp Stack");
}



VERBOSE(VB_UPNP, QString( "MediaRenderer::End" ));
}

Expand Down

0 comments on commit bf0d172

Please sign in to comment.