20#define MAX_CAM_SLOTS_PER_ADAPTER 16
21#define MAX_CONNECTIONS_PER_CAM_SLOT 8
22#define CAM_READ_TIMEOUT 50
45 int GetTag(
int &Length,
const uint8_t **Data);
46 const uint8_t *
GetData(
const uint8_t *Data,
int &Length);
47 void SendData(
int Tag,
int Length = 0,
const uint8_t *Data = NULL);
56 virtual void Process(
int Length = 0,
const uint8_t *Data = NULL);
78 virtual void Process(
int Length = 0,
const uint8_t *Data = NULL);
163 void Reply(
const char *s);
183 virtual void Action(
void);
187 virtual int Read(uint8_t *Buffer,
int MaxLength) {
return 0; }
192 virtual void Write(
const uint8_t *Buffer,
int Length) {}
194 virtual bool Reset(
int Slot) {
return false; }
228 cCiCaPmt *
Add(uint8_t CmdId,
int Source,
int Transponder,
int ProgramNumber,
const int *CaSystemIds);
257 void KeepSharedCaPids(
int ProgramNumber,
const int *CaSystemIds,
int *CaPids);
350 virtual bool Reset(
void);
375 virtual bool Ready(
void);
377 virtual bool HasMMI(
void);
391 virtual bool ProvidesCa(
const int *CaSystemIds);
398 virtual void AddPid(
int ProgramNumber,
int Pid,
int StreamType);
401 virtual void SetPid(
int Pid,
bool Active);
520 void Reset(
int CamSlotNumber);
527 void Load(
const char *FileName);
533bool CamResponsesLoad(
const char *FileName,
bool AllowComments =
false,
bool MustExist =
false);
cChannelCamRelations ChannelCamRelations
cCiResourceHandlers CiResourceHandlers
#define MAX_CAM_SLOTS_PER_ADAPTER
bool CamResponsesLoad(const char *FileName, bool AllowComments=false, bool MustExist=false)
#define MAX_CONNECTIONS_PER_CAM_SLOT
bool Devices(cVector< int > &DeviceNumbers)
Adds the numbers of any devices that currently use this CAM to the given DeviceNumbers.
virtual bool RepliesToQuery(void)
Returns true if the CAM in this slot replies to queries and thus supports MCD ("Multi Channel Decrypt...
bool MtdActive(void)
Returns true if MTD is currently active.
virtual bool IsDecrypting(void)
Returns true if the CAM in this slot is currently used for decrypting.
virtual bool Ready(void)
Returns 'true' if the CAM in this slot is ready to decrypt.
virtual void InjectEit(int Sid)
Injects a generated EIT with a "present event" for the given Sid into the TS data stream sent to the ...
int Priority(void)
Returns the priority of the device this slot is currently assigned to, or IDLEPRIORITY if it is not a...
cCamSlot * MasterSlot(void)
Returns this CAM slot's master slot, or a pointer to itself if it is a master slot.
virtual const char * GetCamName(void)
Returns the name of the CAM in this slot, or NULL if there is no ready CAM in this slot.
void DeleteAllConnections(void)
cCiSession * GetSessionByResourceId(uint32_t ResourceId)
virtual bool CanDecrypt(const cChannel *Channel, cMtdMapper *MtdMapper=NULL)
Returns true if there is a CAM in this slot that is able to decrypt the given Channel (or at least cl...
void KeepSharedCaPids(int ProgramNumber, const int *CaSystemIds, int *CaPids)
void TriggerResendPmt(void)
Tells this CAM slot to resend the list of CA_PMTs to the CAM.
virtual bool Inject(uchar *Data, int Count)
Sends all Count bytes of the given Data to the CAM, and returns true if this was possible.
void MtdEnable(void)
Enables MTD support for this CAM.
bool McdAvailable(void)
Returns true if this CAM supports MCD ("Multi Channel Decyption").
virtual bool EnterMenu(void)
Requests the CAM in this slot to start its menu.
virtual uchar * Decrypt(uchar *Data, int &Count)
If this is a CAM slot that can be freely assigned to any device, but will not be directly inserted in...
virtual void AddPid(int ProgramNumber, int Pid, int StreamType)
Adds the given PID information to the list of PIDs.
int MasterSlotNumber(void)
Returns the number of this CAM's master slot within the whole system.
virtual cCiEnquiry * GetEnquiry(void)
Gets a pending enquiry, or NULL if there is no enquiry.
void Process(cTPDU *TPDU=NULL)
cCaActivationReceiver * caActivationReceiver
virtual eModuleStatus ModuleStatus(void)
Returns the status of the CAM in this slot.
void MtdActivate(bool On)
Activates (On == true) or deactivates (On == false) MTD.
eModuleStatus lastModuleStatus
cCaPidReceiver * caPidReceiver
virtual void AddChannel(const cChannel *Channel)
Adds all PIDs of the given Channel to the current list of PIDs.
virtual bool HasUserIO(void)
Returns true if there is a pending user interaction, which shall be retrieved via GetMenu() or GetEnq...
virtual const int * GetCaSystemIds(void)
bool WantsTsData(void) const
Returns true if this CAM slot wants to receive the TS data through its Decrypt() function.
virtual bool Assign(cDevice *Device, bool Query=false)
Assigns this CAM slot to the given Device, if this is possible.
virtual cCiMenu * GetMenu(void)
Gets a pending menu, or NULL if there is no menu.
virtual void SendCaPmt(uint8_t CmdId)
cDevice * Device(void)
Returns the device this CAM slot is currently assigned to.
virtual bool Reset(void)
Resets the CAM in this slot.
virtual void SetPid(int Pid, bool Active)
Sets the given Pid (which has previously been added through a call to AddPid()) to Active.
virtual void StartActivation(void)
Puts the CAM in this slot into a mode where an inserted smart card can be activated.
virtual void StartDecrypting(void)
Sends all CA_PMT entries to the CAM that have been modified since the last call to this function.
virtual bool IsActivating(void)
Returns true if this CAM slot is currently activating a smart card.
bool MtdAvailable(void)
Returns true if this CAM supports MTD ("Multi Transponder Decryption").
cCiTransportConnection * tc[MAX_CONNECTIONS_PER_CAM_SLOT+1]
virtual bool TsPostProcess(uchar *Data)
If there is a cCiSession that needs to do additional processing on TS packets (after the CAM has done...
int MtdPutData(uchar *Data, int Count)
Sends at most Count bytes of the given Data to the individual MTD CAM slots that are using this CAM.
int SlotIndex(void)
Returns the index of this CAM slot within its CI adapter.
cList< cCiCaProgramData > caProgramList
virtual void StopDecrypting(void)
Clears the list of CA_PMT entries and tells the CAM to stop decrypting.
void SendCaPmts(cCiCaPmtList &CaPmtList)
Sends the given list of CA_PMTs to the CAM.
virtual bool HasMMI(void)
Returns 'true' if the CAM in this slot has an active MMI.
virtual bool CanActivate(void)
Returns true if there is a CAM in this slot that can be put into activation mode.
cCamSlot(cCiAdapter *CiAdapter, bool WantsTsData=false, cCamSlot *MasterSlot=NULL)
Creates a new CAM slot for the given CiAdapter.
cCamSlot * MtdSpawn(void)
If this CAM slot can do MTD ("Multi Transponder Decryption"), a call to this function returns a cMtdC...
void BuildCaPmts(uint8_t CmdId, cCiCaPmtList &CaPmtList, cMtdMapper *MtdMapper=NULL)
Generates all CA_PMTs with the given CmdId and stores them in the given CaPmtList.
int SlotNumber(void)
Returns the number of this CAM slot within the whole system.
bool IsMasterSlot(void)
Returns true if this CAM slot itself is a master slot (which means that it doesn't have a pointer to ...
virtual void CancelActivation(void)
Cancels a previously started activation (if any).
virtual bool ProvidesCa(const int *CaSystemIds)
Returns true if the CAM in this slot provides one of the given CaSystemIds.
bool WaitForAllCamSlotsReady(int Timeout=0)
Waits until all CAM slots have become ready, or the given Timeout (seconds) has expired.
int NumReadyMasterSlots(void)
Returns the number of master CAM slots in the system that are ready to decrypt.
void ClrDecrypt(tChannelID ChannelID, int CamSlotNumber)
void Load(const char *FileName)
void SetChecked(tChannelID ChannelID, int CamSlotNumber)
bool CamDecrypt(tChannelID ChannelID, int CamSlotNumber)
cChannelCamRelations(void)
bool CamChecked(tChannelID ChannelID, int CamSlotNumber)
cChannelCamRelation * GetEntry(tChannelID ChannelID)
cChannelCamRelation * AddEntry(tChannelID ChannelID)
void SetDecrypt(tChannelID ChannelID, int CamSlotNumber)
void ClrChecked(tChannelID ChannelID, int CamSlotNumber)
void Reset(int CamSlotNumber)
virtual void Action(void)
Handles the attached CAM slots in a separate thread.
cCamSlot * camSlots[MAX_CAM_SLOTS_PER_ADAPTER]
virtual bool Reset(int Slot)
Resets the CAM in the given Slot.
virtual eModuleStatus ModuleStatus(int Slot)
Returns the status of the CAM in the given Slot.
cCamSlot * ItCamSlot(int &Iter)
Iterates over all added CAM slots of this adapter.
virtual bool Assign(cDevice *Device, bool Query=false)
Assigns this adapter to the given Device, if this is possible.
virtual ~cCiAdapter()
The derived class must call Cancel(3) in its destructor.
void AddCamSlot(cCamSlot *CamSlot)
Adds the given CamSlot to this CI adapter.
virtual void Write(const uint8_t *Buffer, int Length)
Writes Length bytes of the given Buffer.
virtual int Read(uint8_t *Buffer, int MaxLength)
Reads one chunk of data into the given Buffer, up to MaxLength bytes.
void Reply(const char *s)
cCiResourceHandler(void)
Creates a new resource handler, through which the available resources can be provides.
virtual const uint32_t * ResourceIds(void) const =0
Returns a pointer to an array of resource identifiers, where the last value is zero.
virtual ~cCiResourceHandler()
virtual cCiSession * GetNewCiSession(uint32_t ResourceId, uint16_t SessionId, cCiTransportConnection *Tc)=0
Returns a new cCiSession, according to the given ResourceId.
cCiResourceHandlers(void)
Creates the default list of resourceIds.
cVector< uint32_t > resourceIds
const uint32_t * Ids(void)
void Register(cCiResourceHandler *ResourceHandler)
Adds the given ResourceHandler to the list of resource handlers and appends its ResourceIds to the gl...
cCiSession * GetNewCiSession(uint32_t ResourceId, uint16_t SessionId, cCiTransportConnection *Tc)
int GetTag(int &Length, const uint8_t **Data)
void SendData(int Tag, int Length=0, const uint8_t *Data=NULL)
cCiTransportConnection * tc
cCiSession(uint16_t SessionId, uint32_t ResourceId, cCiTransportConnection *Tc)
void SetResourceId(uint32_t Id)
If this is a class that has been derived from an existing cCiSession class, but implements a differen...
uint32_t ResourceId(void)
virtual bool TsPostProcess(uint8_t *TsPacket)
If this cCiSession needs to do additional processing on TS packets (after the CAM has done the decryp...
const uint8_t * GetData(const uint8_t *Data, int &Length)
virtual bool HasUserIO(void)
void SetTsPostProcessor(void)
If this cCiSession implements the TsPostProcess() function, it shall call SetTsPostProcessor() to reg...
virtual void Process(int Length=0, const uint8_t *Data=NULL)
cCiTransportConnection * Tc(void)
void Del(cCiCaPmt *CaPmt)
cVector< cCiCaPmt * > caPmts
cCiCaPmt * Add(uint8_t CmdId, int Source, int Transponder, int ProgramNumber, const int *CaSystemIds)