vdr  2.2.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
cCamSlot Class Reference

#include <ci.h>

Public Member Functions

 cCamSlot (cCiAdapter *CiAdapter, bool WantsTsData=false)
 
virtual ~cCamSlot ()
 
bool Assign (cDevice *Device, bool Query=false)
 
cDeviceDevice (void)
 
bool WantsTsData (void) const
 
int SlotIndex (void)
 
int SlotNumber (void)
 
virtual bool Reset (void)
 
virtual bool CanActivate (void)
 
virtual void StartActivation (void)
 
virtual void CancelActivation (void)
 
virtual bool IsActivating (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)
 
int Priority (void)
 
virtual bool ProvidesCa (const int *CaSystemIds)
 
virtual void AddPid (int ProgramNumber, int Pid, int StreamType)
 
virtual void SetPid (int Pid, bool Active)
 
virtual void AddChannel (const cChannel *Channel)
 
virtual bool CanDecrypt (const cChannel *Channel)
 
virtual void StartDecrypting (void)
 
virtual void StopDecrypting (void)
 
virtual bool IsDecrypting (void)
 
virtual ucharDecrypt (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
 

Private Member Functions

const int * GetCaSystemIds (void)
 
void SendCaPmt (uint8_t CmdId)
 
void NewConnection (void)
 
void DeleteAllConnections (void)
 
void Process (cTPDU *TPDU=NULL)
 
void Write (cTPDU *TPDU)
 
cCiSessionGetSessionByResourceId (uint32_t ResourceId)
 

Private Attributes

cMutex mutex
 
cCondVar processed
 
cCiAdapterciAdapter
 
cDeviceassignedDevice
 
cCaPidReceivercaPidReceiver
 
cCaActivationReceivercaActivationReceiver
 
int slotIndex
 
int slotNumber
 
cCiTransportConnectiontc [MAX_CONNECTIONS_PER_CAM_SLOT+1]
 
eModuleStatus lastModuleStatus
 
time_t resetTime
 
cTimeMs moduleCheckTimer
 
bool resendPmt
 
int source
 
int transponder
 
cList< cCiCaProgramDatacaProgramList
 

Friends

class cCiAdapter
 
class cCiTransportConnection
 

Detailed Description

Definition at line 128 of file ci.h.

Constructor & Destructor Documentation

cCamSlot::cCamSlot ( cCiAdapter CiAdapter,
bool  WantsTsData = false 
)

Creates a new CAM slot for the given CiAdapter.

The CiAdapter will take care of deleting the CAM slot, so the caller must not delete it! If WantsTsData is true, the device this CAM slot is assigned to will call the Decrypt() function of this CAM slot, presenting it the complete TS data stream of the encrypted programme, including the CA pids.

Definition at line 1742 of file ci.c.

References cListBase::Add(), CamSlots, MAX_CONNECTIONS_PER_CAM_SLOT, msReset, and cCiAdapter::Reset().

cCamSlot::~cCamSlot ( )
virtual

Definition at line 1762 of file ci.c.

References CamSlots, and cListBase::Del().

Member Function Documentation

void cCamSlot::AddChannel ( const cChannel Channel)
virtual

Adds all PIDs if the given Channel to the current list of PIDs.

If the source or transponder of the channel are different than what was given in a previous call to AddChannel(), any previously added PIDs will be cleared.

Definition at line 2143 of file ci.c.

References cChannel::Apids(), cChannel::Ca(), CA_ENCRYPTED_MIN, cChannel::Dpids(), cThread::mutex, Setup, cChannel::Sid(), cChannel::Source(), cChannel::Spids(), STREAM_TYPE_AUDIO, STREAM_TYPE_PRIVATE, STREAM_TYPE_VIDEO, cSetup::SupportTeletext, cChannel::Tpid(), cChannel::Transponder(), and cChannel::Vpid().

Referenced by cDevice::SetChannel().

void cCamSlot::AddPid ( int  ProgramNumber,
int  Pid,
int  StreamType 
)
virtual

Adds the given PID information to the list of PIDs.

A later call to SetPid() will (de)activate one of these entries.

Definition at line 2104 of file ci.c.

References cListBase::Add(), cThread::mutex, cListObject::Next(), and cCiCaProgramData::pidList.

bool cCamSlot::Assign ( cDevice Device,
bool  Query = false 
)

Assigns this CAM slot to the given Device, if this is possible.

If Query is 'true', the CI adapter of this slot only checks whether it can be assigned to the Device, but doesn't actually assign itself to it. Returns true if this slot can be assigned to the Device. If Device is NULL, the slot will be unassigned from any device it was previously assigned to. The value of Query is ignored in that case, and this function always returns 'true'.

Definition at line 1772 of file ci.c.

References cDevice::DeviceNumber(), dsyslog, cThread::mutex, and cDevice::SetCamSlot().

Referenced by cMenuSetupCAM::Activate(), cDevice::Detach(), and cDevice::GetDevice().

bool cCamSlot::CanActivate ( void  )
virtual

Returns true if there is a CAM in this slot that can be put into activation mode.

Definition at line 1914 of file ci.c.

References cCiAdapter::ModuleStatus(), and msReady.

Referenced by cMenuSetupCAM::Activate(), and cMenuSetupCAM::SetHelpKeys().

void cCamSlot::CancelActivation ( void  )
virtual

Cancels a previously started activation (if any).

Definition at line 1933 of file ci.c.

References cThread::mutex.

Referenced by cMenuSetupCAM::Activate().

bool cCamSlot::CanDecrypt ( const cChannel Channel)
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.

Definition at line 2165 of file ci.c.

References cChannel::Apids(), cChannel::Ca(), CA_ENCRYPTED_MIN, cCiConditionalAccessSupport::CanDecrypt(), CPCI_QUERY, CPLM_ADD, cChannel::Dpids(), dsyslog, cThread::mutex, QUERY_REPLY_TIMEOUT, QUERY_REPLY_WAIT, cCiConditionalAccessSupport::ReceivedReply(), cCiConditionalAccessSupport::RepliesToQuery(), RI_CONDITIONAL_ACCESS_SUPPORT, cCiConditionalAccessSupport::SendPMT(), cCiCaPmt::SetListManagement(), Setup, cChannel::Sid(), cChannel::Source(), cChannel::Spids(), STREAM_TYPE_AUDIO, STREAM_TYPE_PRIVATE, STREAM_TYPE_VIDEO, cSetup::SupportTeletext, cTimeMs::TimedOut(), cChannel::Tpid(), cChannel::Transponder(), and cChannel::Vpid().

uchar * cCamSlot::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. 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(). 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.

Definition at line 2232 of file ci.c.

References TS_SIZE.

void cCamSlot::DeleteAllConnections ( void  )
private

Definition at line 1815 of file ci.c.

References MAX_CONNECTIONS_PER_CAM_SLOT, and cThread::mutex.

cDevice* cCamSlot::Device ( void  )
inline

Returns the device this CAM slot is currently assigned to.

Definition at line 173 of file ci.h.

Referenced by cDevice::GetDevice(), and cMenuSetupCAM::Reset().

bool cCamSlot::EnterMenu ( void  )
virtual

Requests the CAM in this slot to start its menu.

Definition at line 1982 of file ci.c.

References cCiApplicationInformation::EnterMenu(), cThread::mutex, and RI_APPLICATION_INFORMATION.

Referenced by cMenuSetupCAM::Menu().

const char * cCamSlot::GetCamName ( void  )
virtual

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

Definition at line 1959 of file ci.c.

References cThread::mutex.

Referenced by cMenuCam::GenerateTitle().

const int * cCamSlot::GetCaSystemIds ( void  )
private
cCiEnquiry * cCamSlot::GetEnquiry ( void  )
virtual

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

Definition at line 2002 of file ci.c.

References cCiMMI::Enquiry(), cCiEnquiry::mutex, cThread::mutex, and RI_MMI.

Referenced by cMenuCam::QueryCam().

cCiMenu * cCamSlot::GetMenu ( void  )
virtual

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

Definition at line 1989 of file ci.c.

References cCiMMI::Menu(), cCiMenu::mutex, cThread::mutex, and RI_MMI.

Referenced by cMenuCam::QueryCam().

cCiSession * cCamSlot::GetSessionByResourceId ( uint32_t  ResourceId)
private

Definition at line 1881 of file ci.c.

References cThread::mutex.

bool cCamSlot::HasMMI ( void  )
virtual

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

Definition at line 1971 of file ci.c.

References RI_MMI.

Referenced by cMenuCam::ProcessKey().

bool cCamSlot::HasUserIO ( void  )
virtual

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

Definition at line 1976 of file ci.c.

References cThread::mutex.

Referenced by cMenuSetupCAM::Menu(), and cMenuCam::QueryCam().

bool cCamSlot::IsActivating ( void  )
virtual

Returns true if this CAM slot is currently activating a smart card.

Definition at line 1940 of file ci.c.

Referenced by cDevice::Action(), cMenuSetupCAM::Activate(), cDevice::Detach(), and cMenuSetupCAM::SetHelpKeys().

bool cCamSlot::IsDecrypting ( void  )
virtual

Returns true if the CAM in this slot is currently used for decrypting.

Definition at line 2216 of file ci.c.

References cThread::mutex, and cListObject::Next().

Referenced by cDevice::Detach(), and cDevice::GetDevice().

eModuleStatus cCamSlot::ModuleStatus ( void  )
virtual

Returns the status of the CAM in this slot.

Definition at line 1945 of file ci.c.

References MODULE_RESET_TIMEOUT, msNone, msReset, and cThread::mutex.

Referenced by cDevice::GetDevice().

void cCamSlot::NewConnection ( void  )
private

Definition at line 1802 of file ci.c.

References esyslog, MAX_CONNECTIONS_PER_CAM_SLOT, and cThread::mutex.

int cCamSlot::Priority ( void  )

Returns the priority of the device this slot is currently assigned to, or IDLEPRIORITY if it is not assigned to any device.

Definition at line 2083 of file ci.c.

References IDLEPRIORITY, and cDevice::Priority().

Referenced by cMenuSetupCAM::Activate(), and cDevice::GetDevice().

void cCamSlot::Process ( cTPDU TPDU = NULL)
private
bool cCamSlot::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.

Definition at line 2089 of file ci.c.

References cCiConditionalAccessSupport::GetCaSystemIds(), cThread::mutex, and RI_CONDITIONAL_ACCESS_SUPPORT.

Referenced by cDevice::GetDevice().

bool cCamSlot::Ready ( void  )
virtual

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

Definition at line 1965 of file ci.c.

References cCiAdapter::ModuleStatus(), msNone, and cThread::mutex.

bool cCamSlot::Reset ( void  )
virtual

Resets the CAM in this slot.

Returns true if the operation was successful.

Definition at line 1896 of file ci.c.

References ChannelCamRelations, dbgprotocol, msReset, cThread::mutex, and cChannelCamRelations::Reset().

Referenced by cMenuSetupCAM::Reset().

void cCamSlot::SendCaPmt ( uint8_t  CmdId)
private
void cCamSlot::SetPid ( int  Pid,
bool  Active 
)
virtual

Sets the given Pid (which has previously been added through a call to AddPid()) to Active.

A later call to StartDecrypting() will send the full list of currently active CA_PMT entries to the CAM.

Definition at line 2122 of file ci.c.

References cThread::Active(), cThread::mutex, and cListObject::Next().

Referenced by cDevice::AddPid(), cDevice::DelPid(), cDvbHdFfDevice::SetAudioTrackDevice(), and cDvbSdFfDevice::SetAudioTrackDevice().

int cCamSlot::SlotIndex ( void  )
inline

Returns the index of this CAM slot within its CI adapter.

The first slot has an index of 0.

Definition at line 178 of file ci.h.

Referenced by cCiTransportConnection::cCiTransportConnection().

int cCamSlot::SlotNumber ( void  )
inline
void cCamSlot::StartActivation ( void  )
virtual

Puts the CAM in this slot into a mode where an inserted smart card can be activated.

The default action is to make IsActivating() return true, which causes the device this CAM slot is attached to to never automatically detach any receivers with negative priority if the PIDs they want to receive are not decrypted by the CAM. StartActivation() must be called after the CAM slot has been assigned to a device. The CAM slot will stay in activation mode until the CAM begins to decrypt, a call to CancelActivation() is made, or the device is needed for a recording.

Definition at line 1919 of file ci.c.

References Channels, cDevice::CurrentChannel(), dsyslog, cChannels::GetByNumber(), and cThread::mutex.

Referenced by cMenuSetupCAM::Activate().

void cCamSlot::StartDecrypting ( void  )
virtual

Triggers sending all currently active CA_PMT entries to the CAM, so that it will start decrypting.

Definition at line 2202 of file ci.c.

References CPCI_OK_DESCRAMBLING.

Referenced by cDevice::AttachReceiver(), cDevice::Detach(), cDvbHdFfDevice::SetAudioTrackDevice(), cDvbSdFfDevice::SetAudioTrackDevice(), and cDevice::SetChannel().

void cCamSlot::StopDecrypting ( void  )
virtual

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

Definition at line 2207 of file ci.c.

References CPCI_NOT_SELECTED, and cThread::mutex.

bool cCamSlot::WantsTsData ( void  ) const
inline

Returns true if this CAM slot wants to receive the TS data through its Decrypt() function.

Definition at line 175 of file ci.h.

void cCamSlot::Write ( cTPDU TPDU)
private

Definition at line 1887 of file ci.c.

References cTPDU::Buffer(), cTPDU::Dump(), cThread::mutex, and cTPDU::Size().

Friends And Related Function Documentation

friend class cCiAdapter
friend

Definition at line 129 of file ci.h.

Referenced by cCiAdapter::Assign().

friend class cCiTransportConnection
friend

Definition at line 130 of file ci.h.

Member Data Documentation

cDevice* cCamSlot::assignedDevice
private

Definition at line 135 of file ci.h.

cCaActivationReceiver* cCamSlot::caActivationReceiver
private

Definition at line 137 of file ci.h.

cCaPidReceiver* cCamSlot::caPidReceiver
private

Definition at line 136 of file ci.h.

cList<cCiCaProgramData> cCamSlot::caProgramList
private

Definition at line 147 of file ci.h.

cCiAdapter* cCamSlot::ciAdapter
private

Definition at line 134 of file ci.h.

eModuleStatus cCamSlot::lastModuleStatus
private

Definition at line 141 of file ci.h.

cTimeMs cCamSlot::moduleCheckTimer
private

Definition at line 143 of file ci.h.

cMutex cCamSlot::mutex
private

Definition at line 132 of file ci.h.

cCondVar cCamSlot::processed
private

Definition at line 133 of file ci.h.

bool cCamSlot::resendPmt
private

Definition at line 144 of file ci.h.

time_t cCamSlot::resetTime
private

Definition at line 142 of file ci.h.

int cCamSlot::slotIndex
private

Definition at line 138 of file ci.h.

Referenced by cCiAdapter::AddCamSlot().

int cCamSlot::slotNumber
private

Definition at line 139 of file ci.h.

int cCamSlot::source
private

Definition at line 145 of file ci.h.

Definition at line 140 of file ci.h.

int cCamSlot::transponder
private

Definition at line 146 of file ci.h.


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