1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Modified the CAM API so that it is possible to implement CAMs that can be freely assigned to any devices

This commit is contained in:
Klaus Schmidinger 2015-01-15 09:28:37 +01:00
parent 555fe68a01
commit b3954aefd5
4 changed files with 32 additions and 22 deletions

View File

@ -3315,3 +3315,7 @@ Claus Muus <email@clausmuus.de>
Dieter Ferdinand <dieter.ferdinand@gmx.de> Dieter Ferdinand <dieter.ferdinand@gmx.de>
for reporting a problem with jumping to an absolute position via the Red key in for reporting a problem with jumping to an absolute position via the Red key in
case replay was paused case replay was paused
Jasmin Jessich <jasmin@anw.at>
for modifying the CAM API so that it is possible to implement CAMs that can be freely
assigned to any devices

View File

@ -8307,7 +8307,7 @@ Video Disk Recorder Revision History
- The APIVERSION has been increased to 2.0.6 due to the changes to pat.h, sdt.h and - The APIVERSION has been increased to 2.0.6 due to the changes to pat.h, sdt.h and
the functional modification to cFont::CreateFont(). the functional modification to cFont::CreateFont().
2015-01-14: Version 2.1.7 2015-01-15: Version 2.1.7
- No longer logging an error message in DirSizeMB() if the given directory doesn't - No longer logging an error message in DirSizeMB() if the given directory doesn't
exist. This avoids lots of log entries in case several VDRs use the same video exist. This avoids lots of log entries in case several VDRs use the same video
@ -8371,3 +8371,5 @@ Video Disk Recorder Revision History
want to do the same. want to do the same.
- Added the channel name to log messages that reference a channel (suggested by - Added the channel name to log messages that reference a channel (suggested by
Dietmar Spingler). Dietmar Spingler).
- Modified the CAM API so that it is possible to implement CAMs that can be freely
assigned to any devices (thanks to Jasmin Jessich).

36
ci.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: ci.c 3.16 2015/01/13 14:42:32 kls Exp $ * $Id: ci.c 3.17 2015/01/15 09:14:57 kls Exp $
*/ */
#include "ci.h" #include "ci.h"
@ -1631,7 +1631,6 @@ public:
cCiAdapter::cCiAdapter(void) cCiAdapter::cCiAdapter(void)
:cThread("CI adapter") :cThread("CI adapter")
{ {
assignedDevice = NULL;
for (int i = 0; i < MAX_CAM_SLOTS_PER_ADAPTER; i++) for (int i = 0; i < MAX_CAM_SLOTS_PER_ADAPTER; i++)
camSlots[i] = NULL; camSlots[i] = NULL;
} }
@ -1657,6 +1656,17 @@ void cCiAdapter::AddCamSlot(cCamSlot *CamSlot)
} }
} }
cCamSlot *cCiAdapter::ItCamSlot(int &Iter)
{
if (Iter >= 0) {
for (; Iter < MAX_CAM_SLOTS_PER_ADAPTER; ) {
if (cCamSlot *Found = camSlots[Iter++])
return Found;
}
}
return NULL;
}
void cCiAdapter::Action(void) void cCiAdapter::Action(void)
{ {
cTPDU TPDU; cTPDU TPDU;
@ -1684,6 +1694,7 @@ void cCiAdapter::Action(void)
cCamSlot::cCamSlot(cCiAdapter *CiAdapter, bool ReceiveCaPids) cCamSlot::cCamSlot(cCiAdapter *CiAdapter, bool ReceiveCaPids)
{ {
ciAdapter = CiAdapter; ciAdapter = CiAdapter;
assignedDevice = NULL;
caPidReceiver = ReceiveCaPids ? new cCaPidReceiver : NULL; caPidReceiver = ReceiveCaPids ? new cCaPidReceiver : NULL;
slotIndex = -1; slotIndex = -1;
lastModuleStatus = msReset; // avoids initial reset log message lastModuleStatus = msReset; // avoids initial reset log message
@ -1701,8 +1712,8 @@ cCamSlot::cCamSlot(cCiAdapter *CiAdapter, bool ReceiveCaPids)
cCamSlot::~cCamSlot() cCamSlot::~cCamSlot()
{ {
if (ciAdapter && ciAdapter->assignedDevice) if (assignedDevice)
ciAdapter->assignedDevice->SetCamSlot(NULL); assignedDevice->SetCamSlot(NULL);
delete caPidReceiver; delete caPidReceiver;
CamSlots.Del(this, false); CamSlots.Del(this, false);
DeleteAllConnections(); DeleteAllConnections();
@ -1713,13 +1724,13 @@ bool cCamSlot::Assign(cDevice *Device, bool Query)
cMutexLock MutexLock(&mutex); cMutexLock MutexLock(&mutex);
if (ciAdapter) { if (ciAdapter) {
if (ciAdapter->Assign(Device, true)) { if (ciAdapter->Assign(Device, true)) {
if (!Device && ciAdapter->assignedDevice) if (!Device && assignedDevice)
ciAdapter->assignedDevice->SetCamSlot(NULL); assignedDevice->SetCamSlot(NULL);
if (!Query) { if (!Query) {
StopDecrypting(); StopDecrypting();
source = transponder = 0; source = transponder = 0;
if (ciAdapter->Assign(Device)) { if (ciAdapter->Assign(Device)) {
ciAdapter->assignedDevice = Device; assignedDevice = Device;
if (Device) { if (Device) {
Device->SetCamSlot(this); Device->SetCamSlot(this);
dsyslog("CAM %d: assigned to device %d", slotNumber, Device->DeviceNumber() + 1); dsyslog("CAM %d: assigned to device %d", slotNumber, Device->DeviceNumber() + 1);
@ -1736,17 +1747,6 @@ bool cCamSlot::Assign(cDevice *Device, bool Query)
return false; return false;
} }
cDevice *cCamSlot::Device(void)
{
cMutexLock MutexLock(&mutex);
if (ciAdapter) {
cDevice *d = ciAdapter->assignedDevice;
if (d && d->CamSlot() == this)
return d;
}
return NULL;
}
void cCamSlot::NewConnection(void) void cCamSlot::NewConnection(void)
{ {
cMutexLock MutexLock(&mutex); cMutexLock MutexLock(&mutex);

10
ci.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: ci.h 3.8 2014/03/26 11:42:17 kls Exp $ * $Id: ci.h 3.9 2015/01/15 09:18:09 kls Exp $
*/ */
#ifndef __CI_H #ifndef __CI_H
@ -79,11 +79,14 @@ enum eModuleStatus { msNone, msReset, msPresent, msReady };
class cCiAdapter : public cThread { class cCiAdapter : public cThread {
friend class cCamSlot; friend class cCamSlot;
private: private:
cDevice *assignedDevice;
cCamSlot *camSlots[MAX_CAM_SLOTS_PER_ADAPTER]; cCamSlot *camSlots[MAX_CAM_SLOTS_PER_ADAPTER];
void AddCamSlot(cCamSlot *CamSlot); void AddCamSlot(cCamSlot *CamSlot);
///< Adds the given CamSlot to this CI adapter. ///< Adds the given CamSlot to this CI adapter.
protected: protected:
cCamSlot *ItCamSlot(int &Iter);
///< Iterates over all added CAM slots of this adapter. Iter has to be
///< initialized to 0 and is required to store the iteration state.
///< Returns NULL if no further CAM slot is found.
virtual void Action(void); virtual void Action(void);
///< Handles the attached CAM slots in a separate thread. ///< Handles the attached CAM slots in a separate thread.
///< The derived class must call the Start() function to ///< The derived class must call the Start() function to
@ -128,6 +131,7 @@ private:
cMutex mutex; cMutex mutex;
cCondVar processed; cCondVar processed;
cCiAdapter *ciAdapter; cCiAdapter *ciAdapter;
cDevice *assignedDevice;
cCaPidReceiver *caPidReceiver; cCaPidReceiver *caPidReceiver;
int slotIndex; int slotIndex;
int slotNumber; int slotNumber;
@ -164,7 +168,7 @@ public:
///< device it was previously assigned to. The value of Query ///< device it was previously assigned to. The value of Query
///< is ignored in that case, and this function always returns ///< is ignored in that case, and this function always returns
///< 'true'. ///< 'true'.
cDevice *Device(void); cDevice *Device(void) { return assignedDevice; }
///< Returns the device this CAM slot is currently assigned to. ///< Returns the device this CAM slot is currently assigned to.
bool WantsTsData(void) const { return caPidReceiver != NULL; } bool WantsTsData(void) const { return caPidReceiver != NULL; }
///< Returns true if this CAM slot wants to receive the TS data through ///< Returns true if this CAM slot wants to receive the TS data through