Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions lib/dvb/cahandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ bool ePMTClient::processServerInfoPacket()
eDebug("[ePMTClient] ServerInfo: Protocol %u, Info: %s", serverProtocolVersion, receivedData + fixDataLength);

m_serverInfoReceived = true;
if (parent) parent->m_protocol3_established = true;
if (m_capmt_buffer_len > 0)
{
writeCAPMTObject(m_capmt_buffer, m_capmt_buffer_len);
Expand Down Expand Up @@ -345,6 +346,8 @@ eDVBCAHandler::eDVBCAHandler()
: eServerSocket(PMT_SERVER_SOCKET, eApp), serviceLeft(eTimer::create(eApp))
{
serviceIdCounter = 1;
m_protocol3_established = false;
m_handshake_attempted = false;
if (instance == NULL)
{
instance = this;
Expand Down Expand Up @@ -378,14 +381,23 @@ void eDVBCAHandler::newConnection(int socket)
ePMTClient *client = new ePMTClient(this, client_fd);
clients.push_back(client);

/* First distribute current CAPMTs in legacy format (works for all clients),
* then send CLIENT_INFO to initiate Protocol-3 handshake.
* - Protocol-3 softcams: receive legacy CAPMTs, then CLIENT_INFO,
* respond with SERVER_INFO -> Protocol 3 for all subsequent CAPMTs.
* - Legacy softcams: receive legacy CAPMTs (works!), then CLIENT_INFO
* causes disconnect, but CAPMTs were already delivered. */
/* Always distribute current CAPMTs first (legacy format, works for all clients) */
distributeCAPMT();
client->sendClientInfo();

/* Send CLIENT_INFO only when appropriate:
* - Protocol-3 already established (OSCam reconnect): always send
* - First connection ever: send to probe for Protocol-3 support
* - Legacy client detected (no SERVER_INFO after first attempt): skip
* to avoid unnecessary errors in legacy softcam logs */
if (m_protocol3_established)
{
client->sendClientInfo();
}
else if (!m_handshake_attempted)
{
client->sendClientInfo();
m_handshake_attempted = true;
}
}

void eDVBCAHandler::connectionLost(ePMTClient *client)
Expand Down
2 changes: 2 additions & 0 deletions lib/dvb/cahandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ DECLARE_REF(eDVBCAHandler);
std::map<eServiceReferenceDVB, ePtr<eTable<ProgramMapSection> > > pmtCache;
std::map<uint32_t, uint16_t> m_service_caid; // serviceId -> CAID (from softcam ECM_INFO)
uint32_t serviceIdCounter;
bool m_protocol3_established; // SERVER_INFO received from at least one client
bool m_handshake_attempted; // CLIENT_INFO sent at least once

void newConnection(int socket);
void processPMTForService(eDVBCAService *service, eTable<ProgramMapSection> *ptr);
Expand Down
Loading