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