summaryrefslogtreecommitdiff
path: root/ci.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2019-03-19 14:58:06 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2019-03-19 14:58:06 +0100
commitdd130702600da855d3a726c1612c25311bb741b5 (patch)
treef1ffba39af59ba596fc507c2608f5a6b62b7fc0c /ci.c
parentbd3b6f17e476d3da80283715fe8eef4665a2957a (diff)
downloadvdr-dd130702600da855d3a726c1612c25311bb741b5.tar.gz
vdr-dd130702600da855d3a726c1612c25311bb741b5.tar.bz2
Fixed handling shared CA pids
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);