vdr  2.4.0
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
cMtdCamSlot Class Reference

#include <mtd.h>

Collaboration diagram for cMtdCamSlot:
[legend]

Public Member Functions

 cMtdCamSlot (cCamSlot *MasterSlot, int Index)
 
virtual ~cMtdCamSlot ()
 
cMtdMapperMtdMapper (void)
 
virtual bool RepliesToQuery (void)
 
virtual bool ProvidesCa (const int *CaSystemIds)
 
virtual bool CanDecrypt (const cChannel *Channel, cMtdMapper *MtdMapper=NULL)
 
virtual void StartDecrypting (void)
 
virtual void StopDecrypting (void)
 
virtual ucharDecrypt (uchar *Data, int &Count)
 
virtual void InjectEit (int Sid)
 
int PutData (const uchar *Data, int Count)
 
int PutCat (const uchar *Data, int Count)
 
virtual cCamSlotSpawn (void)
 
virtual bool Reset (void)
 
virtual eModuleStatus ModuleStatus (void)
 
virtual const char * GetCamName (void)
 
virtual bool Ready (void)
 
virtual bool HasMMI (void)
 
virtual bool HasUserIO (void)
 
virtual bool EnterMenu (void)
 
virtual cCiMenuGetMenu (void)
 
virtual cCiEnquiryGetEnquiry (void)
 
- Public Member Functions inherited from cCamSlot
bool McdAvailable (void)
 
bool MtdAvailable (void)
 
bool MtdActive (void)
 
 cCamSlot (cCiAdapter *CiAdapter, bool WantsTsData=false, cCamSlot *MasterSlot=NULL)
 
virtual ~cCamSlot ()
 
bool IsMasterSlot (void)
 
cCamSlotMasterSlot (void)
 
cCamSlotMtdSpawn (void)
 
void TriggerResendPmt (void)
 
virtual bool Assign (cDevice *Device, bool Query=false)
 
cDeviceDevice (void)
 
bool Devices (cVector< int > &CardIndexes)
 
bool WantsTsData (void) const
 
int SlotIndex (void)
 
int SlotNumber (void)
 
int MasterSlotNumber (void)
 
virtual bool CanActivate (void)
 
virtual void StartActivation (void)
 
virtual void CancelActivation (void)
 
virtual bool IsActivating (void)
 
int Priority (void)
 
virtual void AddPid (int ProgramNumber, int Pid, int StreamType)
 
virtual void SetPid (int Pid, bool Active)
 
virtual void AddChannel (const cChannel *Channel)
 
virtual bool IsDecrypting (void)
 
virtual bool TsPostProcess (uchar *Data)
 
virtual bool Inject (uchar *Data, int Count)
 
- Public Member Functions inherited from cListObject
 cListObject (void)
 
virtual ~cListObject ()
 
virtual int Compare (const cListObject &ListObject) const
 
void Append (cListObject *Object)
 
void Insert (cListObject *Object)
 
void Unlink (void)
 
int Index (void) const
 
cListObjectPrev (void) const
 
cListObjectNext (void) const
 

Protected Member Functions

virtual const int * GetCaSystemIds (void)
 
virtual void SendCaPmt (uint8_t CmdId)
 
- Protected Member Functions inherited from cCamSlot
void BuildCaPmts (uint8_t CmdId, cCiCaPmtList &CaPmtList, cMtdMapper *MtdMapper=NULL)
 
void SendCaPmts (cCiCaPmtList &CaPmtList)
 
void MtdEnable (void)
 
int MtdPutData (uchar *Data, int Count)
 

Private Attributes

cMutex clearMutex
 
cMtdMappermtdMapper
 
cRingBufferLinearmtdBuffer
 
bool delivered
 

Detailed Description

Definition at line 154 of file mtd.h.

Constructor & Destructor Documentation

◆ cMtdCamSlot()

cMtdCamSlot::cMtdCamSlot ( cCamSlot MasterSlot,
int  Index 
)

Creates a new "Multi Transponder Decryption" CAM slot, connected to the given physical MasterSlot, using the given Index for mapping PIDs.

Definition at line 239 of file mtd.c.

References cCamSlot::ciAdapter, delivered, cListObject::Index(), cCamSlot::MasterSlot(), MTD_BUFFER_SIZE, mtdBuffer, mtdMapper, cCamSlot::SlotNumber(), and TS_SIZE.

◆ ~cMtdCamSlot()

cMtdCamSlot::~cMtdCamSlot ( )
virtual

Definition at line 248 of file mtd.c.

References cCamSlot::Assign(), mtdBuffer, and mtdMapper.

Member Function Documentation

◆ CanDecrypt()

bool cMtdCamSlot::CanDecrypt ( const cChannel Channel,
cMtdMapper MtdMapper = NULL 
)
virtual

Returns true if there is a CAM in this slot that is able to decrypt the given Channel (or at least claims to be able to do so).

Since the QUERY/REPLY mechanism for CAMs is pretty unreliable (some CAMs don't reply to queries at all), we always return true if the CAM is currently not decrypting anything. If there is already a channel being decrypted, a call to CanDecrypt() checks whether the CAM can also decrypt the given channel. Only CAMs that have replied to the initial QUERY will perform this check at all. CAMs that never replied to the initial QUERY are assumed not to be able to handle more than one channel at a time. If MtdMapper is given, all SIDs and PIDs will be mapped accordingly.

Reimplemented from cCamSlot.

Definition at line 278 of file mtd.c.

References cCamSlot::CanDecrypt(), cCamSlot::MasterSlot(), and mtdMapper.

◆ Decrypt()

uchar * cMtdCamSlot::Decrypt ( uchar Data,
int &  Count 
)
virtual

If this is a CAM slot that can be freely assigned to any device, but will not be directly inserted into the full TS data stream in hardware, it can implement this function to be given access to the data in the device's TS buffer.

Data points to a buffer of Count bytes of TS data. The first byte in Data is guaranteed to be a TS_SYNC_BYTE, and Count is at least TS_SIZE. Note that Decrypt() may be called with Data == NULL! This is necessary to allow CAMs that copy the incoming data into a separate buffer to return previously received and decrypted TS packets. If Data is NULL, Count is 0 and must not be modified, and the return value shall point to the next available decrypted TS packet (if any). There are three possible ways a CAM can handle decryption:

  1. If the full TS data is physically routed through the CAM in hardware, there is no need to reimplement this function. The default implementation simply sets Count to TS_SIZE and returns Data.
  2. If the CAM works directly on Data and decrypts the TS "in place" it shall decrypt at least the very first TS packet in Data, set Count to TS_SIZE and return Data. It may decrypt as many TS packets in Data as it wants, but it must decrypt at least the very first TS packet (if at all possible - if, for whatever reasons, it can't decrypt the very first packet, it must return it regardless). Only this very first TS packet will be further processed after the call to this function. The next call will be done with Data pointing to the TS packet immediately following the previous one.
  3. If the CAM needs to copy the data into a buffer of its own, and/or send the data to some file handle for processing and later retrieval, it shall set Count to the number of bytes it has read from Data and return a pointer to the next available decrypted TS packet (which will not be in the memory area pointed to by Data, but rather in some buffer that is under the CAM's control). If no decrypted TS packet is currently available, NULL shall be returned. If no data from Data can currently be processed, Count shall be set to 0 and the same Data pointer will be offered in the next call to Decrypt(). See mtd.h for further requirements if this CAM can do MTD ("Multi Transponder Decryption"). A derived class that implements this function will also need to set the WantsTsData parameter in the call to the base class constructor to true in order to receive the TS data.

Reimplemented from cCamSlot.

Definition at line 300 of file mtd.c.

References clearMutex, cCamSlot::Decrypt(), cRingBufferLinear::Del(), delivered, cRingBufferLinear::Get(), cCamSlot::MasterSlot(), mtdBuffer, mtdMapper, cMtdMapper::RealToUniqPid(), TS_SIZE, TS_SYNC, TsPid(), TsSetPid(), and cMtdMapper::UniqToRealPid().

◆ EnterMenu()

virtual bool cMtdCamSlot::EnterMenu ( void  )
inlinevirtual

Requests the CAM in this slot to start its menu.

Reimplemented from cCamSlot.

Definition at line 186 of file mtd.h.

References MTD_DONT_CALL.

◆ GetCamName()

virtual const char* cMtdCamSlot::GetCamName ( void  )
inlinevirtual

Returns the name of the CAM in this slot, or NULL if there is no ready CAM in this slot.

Reimplemented from cCamSlot.

Definition at line 182 of file mtd.h.

References MTD_DONT_CALL.

◆ GetCaSystemIds()

const int * cMtdCamSlot::GetCaSystemIds ( void  )
protectedvirtual

Reimplemented from cCamSlot.

Definition at line 255 of file mtd.c.

References cCamSlot::GetCaSystemIds(), and cCamSlot::MasterSlot().

◆ GetEnquiry()

virtual cCiEnquiry* cMtdCamSlot::GetEnquiry ( void  )
inlinevirtual

Gets a pending enquiry, or NULL if there is no enquiry.

Reimplemented from cCamSlot.

Definition at line 188 of file mtd.h.

References MTD_DONT_CALL.

◆ GetMenu()

virtual cCiMenu* cMtdCamSlot::GetMenu ( void  )
inlinevirtual

Gets a pending menu, or NULL if there is no menu.

Reimplemented from cCamSlot.

Definition at line 187 of file mtd.h.

References MTD_DONT_CALL.

◆ HasMMI()

virtual bool cMtdCamSlot::HasMMI ( void  )
inlinevirtual

Returns 'true' if the CAM in this slot has an active MMI.

Reimplemented from cCamSlot.

Definition at line 184 of file mtd.h.

References MTD_DONT_CALL.

◆ HasUserIO()

virtual bool cMtdCamSlot::HasUserIO ( void  )
inlinevirtual

Returns true if there is a pending user interaction, which shall be retrieved via GetMenu() or GetEnquiry().

Reimplemented from cCamSlot.

Definition at line 185 of file mtd.h.

References MTD_DONT_CALL.

◆ InjectEit()

void cMtdCamSlot::InjectEit ( int  Sid)
virtual

Injects a generated EIT with a "present event" for the given Sid into the TS data stream sent to the CAM.

This only applies to CAM slots that have WantsTsData set to true in their constructor. The default implementation sends an EIT with the minimum event necessary to disable the CAMs parental rating prompt.

Reimplemented from cCamSlot.

Definition at line 337 of file mtd.c.

References cCamSlot::InjectEit(), cCamSlot::MasterSlot(), mtdMapper, and cMtdMapper::RealToUniqSid().

◆ ModuleStatus()

virtual eModuleStatus cMtdCamSlot::ModuleStatus ( void  )
inlinevirtual

Returns the status of the CAM in this slot.

Reimplemented from cCamSlot.

Definition at line 181 of file mtd.h.

References msNone, and MTD_DONT_CALL.

◆ MtdMapper()

cMtdMapper* cMtdCamSlot::MtdMapper ( void  )
inline

Definition at line 168 of file mtd.h.

References mtdMapper.

Referenced by cCaPidReceiver::Receive().

◆ ProvidesCa()

bool cMtdCamSlot::ProvidesCa ( const int *  CaSystemIds)
virtual

Returns true if the CAM in this slot provides one of the given CaSystemIds.

This doesn't necessarily mean that it will be possible to actually decrypt such a programme, since CAMs usually advertise several CA system ids, while the actual decryption is controlled by the smart card inserted into the CAM.

Reimplemented from cCamSlot.

Definition at line 273 of file mtd.c.

References cCamSlot::MasterSlot(), and cCamSlot::ProvidesCa().

◆ PutCat()

int cMtdCamSlot::PutCat ( const uchar Data,
int  Count 
)

Definition at line 353 of file mtd.c.

References cCamSlot::Decrypt(), and cCamSlot::MasterSlot().

Referenced by cCaPidReceiver::Receive().

◆ PutData()

int cMtdCamSlot::PutData ( const uchar Data,
int  Count 
)

Definition at line 342 of file mtd.c.

References cRingBufferLinear::Free(), mtdBuffer, cRingBufferLinear::Put(), and TS_SIZE.

◆ Ready()

virtual bool cMtdCamSlot::Ready ( void  )
inlinevirtual

Returns 'true' if the CAM in this slot is ready to decrypt.

Reimplemented from cCamSlot.

Definition at line 183 of file mtd.h.

References MTD_DONT_CALL.

◆ RepliesToQuery()

bool cMtdCamSlot::RepliesToQuery ( void  )
virtual

Returns true if the CAM in this slot replies to queries and thus supports MCD ("Multi Channel Decryption").

Reimplemented from cCamSlot.

Definition at line 268 of file mtd.c.

References cCamSlot::MasterSlot(), and cCamSlot::RepliesToQuery().

◆ Reset()

virtual bool cMtdCamSlot::Reset ( void  )
inlinevirtual

Resets the CAM in this slot.

Returns true if the operation was successful.

Reimplemented from cCamSlot.

Definition at line 180 of file mtd.h.

References MTD_DONT_CALL.

◆ SendCaPmt()

void cMtdCamSlot::SendCaPmt ( uint8_t  CmdId)
protectedvirtual

Reimplemented from cCamSlot.

Definition at line 260 of file mtd.c.

References cCamSlot::BuildCaPmts(), cCamSlot::MasterSlot(), mtdMapper, cCamSlot::mutex, and cCamSlot::SendCaPmts().

◆ Spawn()

virtual cCamSlot* cMtdCamSlot::Spawn ( void  )
inlinevirtual

Definition at line 179 of file mtd.h.

References MTD_DONT_CALL.

◆ StartDecrypting()

void cMtdCamSlot::StartDecrypting ( void  )
virtual

Sends all CA_PMT entries to the CAM that have been modified since the last call to this function.

This includes CA_PMTs that have been added or activated, as well as ones that have been deactivated. StartDecrypting() will be called whenever a PID is activated or deactivated.

Reimplemented from cCamSlot.

Definition at line 283 of file mtd.c.

References cCamSlot::MasterSlot(), and cCamSlot::StartDecrypting().

◆ StopDecrypting()

void cMtdCamSlot::StopDecrypting ( void  )
virtual

Clears the list of CA_PMT entries and tells the CAM to stop decrypting.

Note that this function is only called when there are no more PIDs for the CAM to decrypt. There is no symmetry between StartDecrypting() and StopDecrypting().

Reimplemented from cCamSlot.

Definition at line 289 of file mtd.c.

References cRingBufferLinear::Clear(), cMtdMapper::Clear(), clearMutex, delivered, cCamSlot::IsDecrypting(), cCamSlot::MasterSlot(), mtdBuffer, mtdMapper, and cCamSlot::StopDecrypting().

Member Data Documentation

◆ clearMutex

cMutex cMtdCamSlot::clearMutex
private

Definition at line 156 of file mtd.h.

Referenced by Decrypt(), and StopDecrypting().

◆ delivered

bool cMtdCamSlot::delivered
private

Definition at line 159 of file mtd.h.

Referenced by cMtdCamSlot(), Decrypt(), and StopDecrypting().

◆ mtdBuffer

cRingBufferLinear* cMtdCamSlot::mtdBuffer
private

Definition at line 158 of file mtd.h.

Referenced by cMtdCamSlot(), Decrypt(), PutData(), StopDecrypting(), and ~cMtdCamSlot().

◆ mtdMapper

cMtdMapper* cMtdCamSlot::mtdMapper
private

The documentation for this class was generated from the following files: