Skip to content

Commit

Permalink
Use new ServerPool capabilities, and only advertise AirPlay via Bonjo…
Browse files Browse the repository at this point in the history
…ur if the server creation was successful
  • Loading branch information
jyavenard committed May 2, 2012
1 parent f13eeb0 commit 29cd39b
Showing 1 changed file with 31 additions and 39 deletions.
70 changes: 31 additions & 39 deletions mythtv/libs/libmythtv/mythairplayserver.cpp
Expand Up @@ -327,51 +327,43 @@ void MythAirplayServer::Start(void)
// start listening for connections
// try a few ports in case the default is in use
int baseport = m_setupPort;
while (m_setupPort < baseport + AIRPLAY_PORT_RANGE)
m_setupPort = tryListeningPort(m_setupPort, AIRPLAY_PORT_RANGE);
if (m_setupPort < 0)
{
if (listen(QNetworkInterface::allAddresses(), m_setupPort, false))
{
LOG(VB_GENERAL, LOG_INFO, LOC +
QString("Listening for connections on port %1")
.arg(m_setupPort));
break;
}
m_setupPort++;
}

if (m_setupPort >= baseport + AIRPLAY_PORT_RANGE)
LOG(VB_GENERAL, LOG_ERR, LOC +
"Failed to find a port for incoming connections.");

// announce service
m_bonjour = new BonjourRegister(this);
if (!m_bonjour)
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create Bonjour object.");
return;
}

// give each frontend a unique name
int multiple = m_setupPort - baseport;
if (multiple > 0)
m_name += QString::number(multiple);

QByteArray name = m_name.toUtf8();
name.append(" on ");
name.append(gCoreContext->GetHostName());
QByteArray type = "_airplay._tcp";
QByteArray txt;
txt.append(26); txt.append("deviceid=00:00:00:00:00:00");
txt.append(13); txt.append("features=0x77");
txt.append(16); txt.append("model=AppleTV2,1");
txt.append(14); txt.append("srcvers=101.28");

if (!m_bonjour->Register(m_setupPort, type, name, txt))
else
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to register service.");
return;
}
// announce service
m_bonjour = new BonjourRegister(this);
if (!m_bonjour)
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create Bonjour object.");
return;
}

// give each frontend a unique name
int multiple = m_setupPort - baseport;
if (multiple > 0)
m_name += QString::number(multiple);

QByteArray name = m_name.toUtf8();
name.append(" on ");
name.append(gCoreContext->GetHostName());
QByteArray type = "_airplay._tcp";
QByteArray txt;
txt.append(26); txt.append("deviceid=00:00:00:00:00:00");
txt.append(13); txt.append("features=0x77");
txt.append(16); txt.append("model=AppleTV2,1");
txt.append(14); txt.append("srcvers=101.28");

if (!m_bonjour->Register(m_setupPort, type, name, txt))
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to register service.");
return;
}
}
m_valid = true;
return;
}
Expand Down

0 comments on commit 29cd39b

Please sign in to comment.