Skip to content

Commit 0396cff

Browse files
authored
Merge pull request #3704 from WXbet/fix-softcsa
Finally fix CI module case and invoke deletion of ecm.info file when no encrypted channels is present
2 parents cacd89c + cc0646c commit 0396cff

File tree

7 files changed

+53
-14
lines changed

7 files changed

+53
-14
lines changed

lib/dvb/cahandler.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,25 @@ int eDVBCAHandler::unregisterService(const eServiceReferenceDVB &ref, int adapte
546546
{
547547
if (!used_demux_slots) // no more used.. so we remove it
548548
{
549+
/*
550+
* Send CMD_NOT_SELECTED to tell the softcam to stop
551+
* descrambling this service before we delete it.
552+
* Without this, switching from an encrypted channel
553+
* to FTA/IPTV would leave the softcam in descrambling
554+
* state (e.g. ecm.info not removed).
555+
*/
556+
if (m_protocol3_established && caservice->getCAPMTVersion() >= 0)
557+
{
558+
for (ePtrList<ePMTClient>::iterator client_it = clients.begin(); client_it != clients.end(); ++client_it)
559+
{
560+
if (client_it->state() == eSocket::Connection)
561+
{
562+
eDebug("[eDVBCAHandler] sending CMD_NOT_SELECTED for service %s", caservice->toString().c_str());
563+
caservice->writeCAPMTObject(*client_it, LIST_UPDATE, CMD_NOT_SELECTED);
564+
}
565+
}
566+
}
567+
549568
delete it->second;
550569
services.erase(it);
551570

lib/dvb/csasession.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,18 @@ void eDVBCSASession::startECMMonitor(iDVBDemux *demux, uint16_t ecm_pid, uint16_
141141

142142
if (info.is_csa_alt && !m_active)
143143
{
144-
eDebug("[eDVBCSASession] ECM Monitor: Activating from cache (CSA-ALT)");
145144
m_ecm_analyzed = true;
146145
m_csa_alt = true;
147-
setActive(true);
146+
if (shouldSuppressActivation && shouldSuppressActivation())
147+
{
148+
eDebug("[eDVBCSASession] ECM Monitor: CSA-ALT cached but activation suppressed (CI module)");
149+
stopECMMonitor();
150+
}
151+
else
152+
{
153+
eDebug("[eDVBCSASession] ECM Monitor: Activating from cache (CSA-ALT)");
154+
setActive(true);
155+
}
148156
}
149157
}
150158

@@ -235,7 +243,15 @@ void eDVBCSASession::ecmDataReceived(const uint8_t *data)
235243
eDebug("[eDVBCSASession] CSA-ALT detected from ECM! Activating software descrambling");
236244
if (!m_active)
237245
{
238-
setActive(true);
246+
if (shouldSuppressActivation && shouldSuppressActivation())
247+
{
248+
eDebug("[eDVBCSASession] Activation suppressed (CI module handles decryption)");
249+
stopECMMonitor();
250+
}
251+
else
252+
{
253+
setActive(true);
254+
}
239255
}
240256
}
241257
else

lib/dvb/csasession.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <lib/dvb/idvb.h>
66
#include <lib/base/ebase.h>
77
#include <sigc++/sigc++.h>
8+
#include <functional>
89

910
class eDVBCSAEngine;
1011
class eDVBCAHandler;
@@ -91,6 +92,10 @@ class eDVBCSASession : public iServiceScrambled, public sigc::trackable
9192
// Signal when first CW is received (for decoder start timing)
9293
sigc::signal<void()> firstCwReceived;
9394

95+
// Optional callback to check if activation should be suppressed
96+
// (e.g. CI module handles decryption). Return true to suppress.
97+
std::function<bool()> shouldSuppressActivation;
98+
9499
private:
95100
eServiceReferenceDVB m_service_ref;
96101
ePtr<eDVBCSAEngine> m_engine;

lib/dvb/pmt.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ void eDVBServicePMTHandler::PMTready(int error)
203203
{
204204
eDVBCIInterfaces::getInstance()->recheckPMTHandlers();
205205
eDVBCIInterfaces::getInstance()->gotPMT(this);
206-
if (isCiConnected())
207-
serviceEvent(eventCIConnected);
208206
}
209207
}
210208
if (m_ca_servicePtr)

lib/dvb/pmt.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ class eDVBServicePMTHandler: public eDVBPMTParser
145145
eventStartPvrDescramble, // start PVR Descramble Convert
146146
eventChannelAllocated,
147147
eventStreamCorrupt,
148-
eventCIConnected, // a CI slot was assigned to this service after recheckPMTHandlers
149148
};
150149
#ifndef SWIG
151150
sigc::signal<void(int)> serviceEvent;

lib/service/servicedvb.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,14 +1384,6 @@ void eDVBServicePlay::serviceEvent(int event)
13841384
case eDVBServicePMTHandler::eventHBBTVInfo:
13851385
m_event((iPlayableService*)this, evHBBTVInfo);
13861386
break;
1387-
case eDVBServicePMTHandler::eventCIConnected:
1388-
if (m_csa_session && m_csa_session->isActive())
1389-
{
1390-
eDebug("[eDVBServicePlay] CI module connected - deactivating SoftCSA to save resources");
1391-
m_csa_session->stopECMMonitor();
1392-
m_csa_session->forceDeactivate();
1393-
}
1394-
break;
13951387
}
13961388
}
13971389

@@ -4379,6 +4371,11 @@ void eDVBServicePlay::setupSpeculativeDescrambling()
43794371
m_soft_decoder->m_audio_pid_selected.connect(
43804372
sigc::mem_fun(*this, &eDVBServicePlay::onSoftDecoderAudioPidSelected));
43814373

4374+
// Suppress SoftCSA activation when CI module handles decryption
4375+
m_csa_session->shouldSuppressActivation = [this]() {
4376+
return m_service_handler.isCiConnected();
4377+
};
4378+
43824379
// Connect to session's activated signal for decoder handover
43834380
m_csa_session->activated.connect(
43844381
sigc::mem_fun(*this, &eDVBServicePlay::onSessionActivated));

lib/service/servicedvbfcc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,11 @@ void eDVBServiceFCCPlay::setupSpeculativeDescrambling()
592592
m_soft_decoder->m_audio_pid_selected.connect(
593593
[this](int pid) { this->onSoftDecoderAudioPidSelected(pid); });
594594

595+
// Suppress SoftCSA activation when CI module handles decryption
596+
m_csa_session->shouldSuppressActivation = [this]() {
597+
return m_service_handler.isCiConnected();
598+
};
599+
595600
// Connect to session's activated signal - use FCC-specific callback!
596601
// This is the key difference from base class: we use onFCCSessionActivated
597602
// which handles FCC decoder stop/start properly

0 commit comments

Comments
 (0)