15#define DBGMTD(a...) dsyslog(a)
22#define MAX_REAL_PIDS MAXPID
24#define MAX_UNIQ_PIDS MAXPID
25#define UNIQ_PID_MASK 0x1FFF
27#define MAX_UNIQ_PIDS 256
28#define UNIQ_PID_MASK 0x00FF
29#define UNIQ_PID_SHIFT 8
40 for (
int i = 0; i <
camSlots.Size(); i++) {
41 dsyslog(
"CAM %d/%d: deleting MTD CAM slot",
camSlots[i]->MasterSlot()->SlotNumber(), i + 1);
48 for (
int i = 0; i <
camSlots.Size(); i++) {
64 if (
int Skipped =
TS_SYNC(Data, Count))
65 return Used + Skipped;
66 int Pid =
TsPid(Data);
72 if (Index >= 0 && Index <
camSlots.Size()) {
77 esyslog(
"ERROR: incomplete MTD packet written (%d) in PID %d (%04X)", Index + 1, Pid, Pid);
80 esyslog(
"ERROR: invalid MTD number (%d) in PID %d (%04X)", Index + 1, Pid, Pid);
91 for (
int i = 0; i <
camSlots.Size(); i++)
98 for (
int i = 0; i <
camSlots.Size(); i++) {
107 for (
int i = 0; i <
camSlots.Size(); i++) {
117 for (
int i = 0; i <
camSlots.Size(); i++) {
125 for (
int i = 0; i <
camSlots.Size(); i++)
131 for (
int i = 0; i <
camSlots.Size(); i++) {
140 for (
int i = 0; i <
camSlots.Size(); i++)
142 return DeviceNumbers.
Size() > 0;
147 for (
int i = 0; i <
camSlots.Size(); i++)
153#define MTD_INVALID_PID 0xFFFF
165 cMtdMapper(
int Number,
int MasterCamSlotNumber);
205 esyslog(
"ERROR: MTD %d: mapper ran out of unique PIDs",
number);
214 int UniqSid =
uniqSids.IndexOf(RealSid);
235 uint16_t RealSid = p[0] << 8 | p[1];
238 p[1] = UniqSid & 0xff;
248#define MTD_BUFFER_SIZE MEGABYTE(1)
314 int Pid =
TsPid(Data);
332 if (
int Skipped =
TS_SYNC(d, c)) {
virtual bool RepliesToQuery(void)
Returns true if the CAM in this slot replies to queries and thus supports MCD ("Multi Channel 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 ...
cCamSlot * MasterSlot(void)
Returns this CAM slot's master slot, or a pointer to itself if it is a master slot.
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...
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 const int * GetCaSystemIds(void)
virtual bool Assign(cDevice *Device, bool Query=false)
Assigns this CAM slot to the given Device, if this is possible.
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 TsPostProcess(uchar *Data)
If there is a cCiSession that needs to do additional processing on TS packets (after the CAM has done...
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.
cCamSlot(cCiAdapter *CiAdapter, bool WantsTsData=false, cCamSlot *MasterSlot=NULL)
Creates a new CAM slot for the given CiAdapter.
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.
virtual bool ProvidesCa(const int *CaSystemIds)
Returns true if the CAM in this slot provides one of the given CaSystemIds.
virtual void StartDecrypting(void)
Sends all CA_PMT entries to the CAM that have been modified since the last call to this function.
virtual void StopDecrypting(void)
Clears the list of CA_PMT entries and tells the CAM to stop decrypting.
virtual bool TsPostProcess(uchar *Data)
If there is a cCiSession that needs to do additional processing on TS packets (after the CAM has done...
virtual void SendCaPmt(uint8_t CmdId)
cRingBufferLinear * mtdBuffer
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...
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 bool ProvidesCa(const int *CaSystemIds)
Returns true if the CAM in this slot provides one of the given CaSystemIds.
cMtdMapper * MtdMapper(void)
virtual bool RepliesToQuery(void)
Returns true if the CAM in this slot replies to queries and thus supports MCD ("Multi Channel Decrypt...
virtual const int * GetCaSystemIds(void)
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...
int PutCat(const uchar *Data, int Count)
int PutData(const uchar *Data, int Count)
int Put(const uchar *Data, int Count)
Puts at most Count bytes of Data into the CAM slot which's index is derived from the PID of the TS pa...
bool IsActivating(void)
Returns true if any of the active MTD CAM slots is currently activating.
cVector< cMtdCamSlot * > camSlots
void StartDecrypting(void)
Tells all active MTD CAM slots to start decrypting.
cMtdHandler(void)
Creates a new MTD handler that distributes TS data received through calls to the Put() function to th...
bool IsDecrypting(void)
Returns true if any of the active MTD CAM slots is currently decrypting.
void CancelActivation(void)
Tells all active MTD CAM slots to cancel activation.
cMtdCamSlot * GetMtdCamSlot(cCamSlot *MasterSlot)
Creates a new MTD CAM slot, or reuses an existing one that is currently unused.
void StopDecrypting(void)
Tells all active MTD CAM slots to stop decrypting.
int Priority(void)
Returns the maximum priority of any of the active MTD CAM slots.
void UnAssignAll(void)
Unassigns all MTD CAM slots from their devices.
bool Devices(cVector< int > &DeviceNumbers)
Adds the numbers of the devices of any active MTD CAM slots to the given DeviceNumbers.
cVector< uint16_t > uniqSids
uint16_t MakeUniqPid(uint16_t RealPid)
uint16_t uniqPids[MAX_REAL_PIDS]
uint16_t realPids[MAX_UNIQ_PIDS]
uint16_t RealToUniqPid(uint16_t RealPid)
uint16_t RealToUniqSid(uint16_t RealSid)
uint16_t UniqToRealPid(uint16_t UniqPid)
cMtdMapper(int Number, int MasterCamSlotNumber)
void MtdMapPid(uchar *p, cMtdMapper *MtdMapper)
void MtdMapSid(uchar *p, cMtdMapper *MtdMapper)
int TsPid(const uchar *p)
void TsSetPid(uchar *p, int Pid)
#define TS_SYNC(Data, Length)