summaryrefslogtreecommitdiff
path: root/ci.c
diff options
context:
space:
mode:
Diffstat (limited to 'ci.c')
-rw-r--r--ci.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/ci.c b/ci.c
index 3edfe12b..a8b065c5 100644
--- a/ci.c
+++ b/ci.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: ci.c 4.22 2018/09/23 10:17:20 kls Exp $
+ * $Id: ci.c 4.23 2019/03/19 14:58:06 kls Exp $
*/
#include "ci.h"
@@ -2505,8 +2505,10 @@ void cCamSlot::BuildCaPmts(uint8_t CmdId, cCiCaPmtList &CaPmtList, cMtdMapper *M
if (GetCaPids(source, transponder, p->programNumber, CaSystemIds, MAXRECEIVEPIDS + 1, CaPids) > 0) {
if (Active)
caPidReceiver->AddPids(CaPids);
- else
+ else {
+ KeepSharedCaPids(p->programNumber, CaSystemIds, CaPids);
caPidReceiver->DelPids(CaPids);
+ }
}
}
if (RepliesToQuery())
@@ -2522,6 +2524,43 @@ void cCamSlot::BuildCaPmts(uint8_t CmdId, cCiCaPmtList &CaPmtList, cMtdMapper *M
}
}
+void cCamSlot::KeepSharedCaPids(int ProgramNumber, const int *CaSystemIds, int *CaPids)
+{
+ int numPids = 0;
+ int *pCaPids = CaPids;
+ while (*pCaPids) {
+ numPids++;
+ pCaPids++;
+ }
+ if (numPids <= 0)
+ return;
+ int CaPids2[MAXRECEIVEPIDS + 1];
+ for (cCiCaProgramData *p = caProgramList.First(); p; p = caProgramList.Next(p)) {
+ if (p->programNumber != ProgramNumber) {
+ if (GetCaPids(source, transponder, p->programNumber, CaSystemIds, MAXRECEIVEPIDS + 1, CaPids2) > 0) {
+ int *pCaPids2 = CaPids2;
+ while (*pCaPids2) {
+ pCaPids = CaPids;
+ while (*pCaPids) {
+ if (*pCaPids == *pCaPids2) {
+ dsyslog("CAM %d: keeping shared CA pid %d", SlotNumber(), *pCaPids);
+ // To remove *pCaPids from CaPids we overwrite it with the last valie in the list, and then strip the last value:
+ *pCaPids = CaPids[numPids - 1];
+ numPids--;
+ CaPids[numPids] = 0;
+ if (numPids <= 0)
+ return;
+ }
+ else
+ pCaPids++;
+ }
+ pCaPids2++;
+ }
+ }
+ }
+ }
+}
+
void cCamSlot::SendCaPmts(cCiCaPmtList &CaPmtList)
{
cMutexLock MutexLock(&mutex);