simplyfi-c* (thx DboxOldie)

This commit is contained in:
max10
2016-07-11 16:42:18 +02:00
parent bef98c2e91
commit 37c20923ce
2 changed files with 51 additions and 59 deletions

View File

@@ -650,7 +650,7 @@ bool cCA::StopRecordCI( u64 tpid, u8 source, u32 calen)
return false; return false;
} }
SlotIt cCA::FindFreeSlot(u64 tpid, u8 source, ca_map_t camap, unsigned char scrambled) SlotIt cCA::FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned char scrambled)
{ {
printf("%s -> %s\n", FILENAME, __func__); printf("%s -> %s\n", FILENAME, __func__);
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
@@ -672,7 +672,7 @@ SlotIt cCA::FindFreeSlot(u64 tpid, u8 source, ca_map_t camap, unsigned char scra
if ((*it)->bsids.size()) if ((*it)->bsids.size())
{ {
for (i = 0; i < (*it)->bsids.size(); i++) for (i = 0; i < (*it)->bsids.size(); i++)
if ((*it)->bsids[i] == (u16)(tpid & 0xFFFF)) {goto OUT;} if ((*it)->bsids[i] == sid) {goto OUT;}
if (i == (*it)->bsids.size()) {(*it)->SidBlackListed = false;} if (i == (*it)->bsids.size()) {(*it)->SidBlackListed = false;}
} }
@@ -687,25 +687,19 @@ SlotIt cCA::FindFreeSlot(u64 tpid, u8 source, ca_map_t camap, unsigned char scra
printf("\n"); printf("\n");
#endif #endif
(*it)->scrambled = scrambled; (*it)->scrambled = scrambled;
if (scrambled)
for (i = 0; i < (*it)->cam_caids.size(); i++)
{ {
for (i = 0; i < (*it)->cam_caids.size(); i++) caIt = camap.find((*it)->cam_caids[i]);
if (caIt != camap.end())
{ {
caIt = camap.find((*it)->cam_caids[i]); printf("Found: %04x\n", *caIt);
if (caIt != camap.end()) return it;
{ }
printf("Found: %04x\n", *caIt); else
return it; {
} (*it)->scrambled = 0;
else
{
(*it)->scrambled = 0;
}
} }
}
else
{
return it;
} }
} }
} }
@@ -718,7 +712,7 @@ OUT:
/* erstmal den capmt wie er von Neutrino kommt in den Slot puffern */ /* erstmal den capmt wie er von Neutrino kommt in den Slot puffern */
bool cCA::SendCAPMT(u64 tpid, u8 source_demux, u8 camask, const unsigned char * cabuf, u32 calen, const unsigned char * /*rawpmt*/, u32 /*rawlen*/, enum CA_SLOT_TYPE /*SlotType*/, unsigned char scrambled, ca_map_t cm, int mode, bool enabled) bool cCA::SendCAPMT(u64 tpid, u8 source_demux, u8 camask, const unsigned char * cabuf, u32 calen, const unsigned char * /*rawpmt*/, u32 /*rawlen*/, enum CA_SLOT_TYPE /*SlotType*/, unsigned char scrambled, ca_map_t cm, int mode, bool enabled)
{ {
u16 SID = (u16)(tpid & 0x000000000000FFFF); u16 SID = (u16)(tpid & 0xFFFF);
unsigned int i = 0; unsigned int i = 0;
printf("%s -> %s\n", FILENAME, __func__); printf("%s -> %s\n", FILENAME, __func__);
if (!num_slots) return true; /* stb's without ci-slots */ if (!num_slots) return true; /* stb's without ci-slots */
@@ -748,53 +742,51 @@ bool cCA::SendCAPMT(u64 tpid, u8 source_demux, u8 camask, const unsigned char *
if (calen == 0) if (calen == 0)
return true; return true;
SlotIt It = FindFreeSlot(tpid, source_demux, cm, scrambled); SlotIt It = FindFreeSlot(tpid, source_demux, SID, cm, scrambled);
if ((*It)) if ((*It))
{ {
printf("Slot: %d\n", (*It)->slot); printf("Slot: %d\n", (*It)->slot);
if (scrambled || (!scrambled && (*It)->source == source_demux))
if (enabled)
{ {
if (mode)
if (scrambled && enabled && !(*It)->SidBlackListed)
{ {
if (mode) if(!checkLiveSlot)
{ (*It)->liveUse = false;
if(!checkLiveSlot) (*It)->recordUse = true;
(*It)->liveUse = false;
(*It)->recordUse = true;
}
else
(*It)->liveUse = true;
} }
else if (!(*It)->recordUse)
SlotIt It2 = GetSlot(!(*It)->slot); (*It)->liveUse = true;
if ((*It2))
{
if (source_demux == (*It2)->source)
{
if ((*It2)->recordUse)
(*It)->SidBlackListed = true;
else
{
SendNullPMT((tSlot*)(*It2));
(*It2)->tpid = 0;
(*It2)->scrambled = 0;
}
}
}
if ((*It)->tpid != tpid || (*It)->source != source_demux)
{
(*It)->tpid = tpid;
(*It)->source = source_demux;
(*It)->pmtlen = calen;
for (i = 0; i < calen; i++)
(*It)->pmtdata[i] = cabuf[i];
(*It)->newCapmt = true;
} else if ((*It)->ccmgr_ready && (*It)->hasCCManager && (*It)->scrambled && !(*It)->SidBlackListed)
(*It)->ccmgrSession->resendKey((tSlot*)(*It));
} }
SlotIt It2 = GetSlot(!(*It)->slot);
if ((*It2) && ((*It)->hasCCManager || (*It2)->hasCCManager))
{
if (source_demux == (*It2)->source)
{
if ((*It2)->recordUse)
(*It)->SidBlackListed = true;
else
{
SendNullPMT((tSlot*)(*It2));
(*It2)->tpid = 0;
(*It2)->scrambled = 0;
}
}
}
if ((*It)->tpid != tpid || (*It)->source != source_demux)
{
(*It)->tpid = tpid;
(*It)->source = source_demux;
(*It)->pmtlen = calen;
for (i = 0; i < calen; i++)
(*It)->pmtdata[i] = cabuf[i];
(*It)->newCapmt = true;
} else if ((*It)->ccmgr_ready && (*It)->hasCCManager && (*It)->scrambled && !(*It)->SidBlackListed)
(*It)->ccmgrSession->resendKey((tSlot*)(*It));
} }
else else
{ {

View File

@@ -287,7 +287,7 @@ public:
bool StopRecordCI( u64 tpid, u8 source, u32 calen); bool StopRecordCI( u64 tpid, u8 source, u32 calen);
bool StopLiveCI( u64 tpid, u8 source, u32 calen); bool StopLiveCI( u64 tpid, u8 source, u32 calen);
SlotIt FindFreeSlot(u64 tpid, u8 source, ca_map_t camap, unsigned char scrambled); SlotIt FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned char scrambled);
SlotIt GetSlot(unsigned int slot); SlotIt GetSlot(unsigned int slot);
bool SendDateTime(void); bool SendDateTime(void);
bool SendCaPMT(tSlot* slot); bool SendCaPMT(tSlot* slot);