|
SASC
DVBSoftCAM
|
#include <cam.h>
Inheritance diagram for cCam:Public Member Functions | |
| cCam (cDevice *Device, int Adapter, int Frontend, const char *DevId, cScDevicePlugin *DevPlugin, bool SoftCSA, bool FullTS) | |
| virtual | ~cCam () |
| int | GetCaids (int slot, unsigned short *Caids, int max) |
| void | CaidsChanged (void) |
| SASC. | |
| virtual bool | SetCaDescr (ca_descr_t *ca_descr, bool initial) |
| virtual bool | SetCaPid (ca_pid_t *ca_pid) |
| void | Stop (void) |
| void | AddPrg (cPrg *prg) |
| bool | HasPrg (int prg) |
| void | WriteCW (int index, unsigned char *cw, bool force) |
| void | SetCWIndex (int pid, int index) |
| void | DumpAV7110 (void) |
| bool | IsSoftCSA (bool live) |
| SASC. | |
| int | Adapter (void) |
| int | Frontend (void) |
| void | LogEcmStatus (const cEcmInfo *ecm, bool on) |
| void | AddHook (cLogHook *hook) |
| bool | TriggerHook (int id) |
| bool | Active (bool log) |
| void | HouseKeeping (void) |
| void | Tune (const cChannel *channel) |
| void | PostTune (void) |
| void | SetPid (int type, int pid, bool on) |
| char * | CurrentKeyStr (int num, const char **id) |
| bool | OwnSlot (const cCamSlot *slot) const |
| cDeCSA * | DeCSA (void) const |
| cCam (cDevice *Device, int Adapter, int Frontend, const char *DevId, cScDevicePlugin *DevPlugin, bool SoftCSA, bool FullTS) | |
| virtual | ~cCam () |
| int | GetCaids (int slot, unsigned short *Caids, int max) |
| void | CaidsChanged (void) |
| virtual bool | SetCaDescr (ca_descr_t *ca_descr, bool initial) |
| virtual bool | SetCaPid (ca_pid_t *ca_pid) |
| void | Stop (void) |
| void | AddPrg (cPrg *prg) |
| bool | HasPrg (int prg) |
| void | WriteCW (int index, unsigned char *cw, bool force) |
| void | SetCWIndex (int pid, int index) |
| void | DumpAV7110 (void) |
| bool | IsSoftCSA (bool live) |
| int | Adapter (void) |
| int | Frontend (void) |
| void | LogEcmStatus (const cEcmInfo *ecm, bool on) |
| void | AddHook (cLogHook *hook) |
| bool | TriggerHook (int id) |
| bool | Active (bool log) |
| void | HouseKeeping (void) |
| void | Tune (const cChannel *channel) |
| void | PostTune (void) |
| void | SetPid (int type, int pid, bool on) |
| char * | CurrentKeyStr (int num, const char **id) |
| bool | OwnSlot (const cCamSlot *slot) const |
| cDeCSA * | DeCSA (void) const |
Protected Member Functions | |
| virtual int | Read (unsigned char *Buffer, int MaxLength) |
| virtual void | Write (const unsigned char *Buffer, int Length) |
| virtual bool | Reset (int Slot) |
| virtual eModuleStatus | ModuleStatus (int Slot) |
| Returns the status of the CAM in the given Slot. | |
| virtual bool | Assign (cDevice *Device, bool Query=false) |
| virtual int | Read (unsigned char *Buffer, int MaxLength) |
| virtual void | Write (const unsigned char *Buffer, int Length) |
| virtual bool | Reset (int Slot) |
| virtual eModuleStatus | ModuleStatus (int Slot) |
| Returns the status of the CAM in the given Slot. | |
| virtual bool | Assign (cDevice *Device, bool Query=false) |
| cCam::cCam | ( | cDevice * | Device, |
| int | Adapter, | ||
| int | Frontend, | ||
| const char * | DevId, | ||
| cScDevicePlugin * | DevPlugin, | ||
| bool | SoftCSA, | ||
| bool | FullTS | ||
| ) |
SASC
Definition at line 2038 of file cam.c.
References Adapter(), CAM_READ_TIMEOUT, Frontend(), KILOBYTE, L_GEN_ERROR, LEN_OFF, PRINTF, cCams::Register(), cThread::SetDescription(), cCiFrame::SetRb(), and cThread::Start().
{
device=Device; devplugin=DevPlugin; adapter=Adapter; frontend=Frontend; devId=DevId;
softcsa=SoftCSA; fullts=FullTS;
tcid=0; rebuildcaids=false;
memset(version,0,sizeof(version));
#ifndef SASC
memset(slots,0,sizeof(slots));
SetDescription("SC-CI adapter on device %s",devId);
rb=new cRingBufferLinear(KILOBYTE(8),6+LEN_OFF,false,"SC-CI adapter read");
if(rb) {
rb->SetTimeouts(0,CAM_READ_TIMEOUT);
frame.SetRb(rb);
BuildCaids(true);
slots[0]=new cScCamSlot(this,devId,0);
Start();
}
else PRINTF(L_GEN_ERROR,"failed to create ringbuffer for SC-CI adapter %s.",devId);
decsa=softcsa ? new cDeCSA(devId) : 0;
#endif //!SASC
source=transponder=-1; liveVpid=liveApid=0; logger=0; hookman=0;
memset(lastCW,0,sizeof(lastCW));
memset(indexMap,0,sizeof(indexMap));
memset(splitSid,0,sizeof(splitSid));
cams.Register(this);
}
| cCam::~cCam | ( | ) | [virtual] |
SASC
Definition at line 2067 of file cam.c.
References cThread::Cancel(), cSimpleListBase::Clear(), cMutex::Lock(), cMutex::Unlock(), and cCams::Unregister().
| cCam::cCam | ( | cDevice * | Device, |
| int | Adapter, | ||
| int | Frontend, | ||
| const char * | DevId, | ||
| cScDevicePlugin * | DevPlugin, | ||
| bool | SoftCSA, | ||
| bool | FullTS | ||
| ) |
| virtual cCam::~cCam | ( | ) | [virtual] |
| bool cCam::Active | ( | bool | log | ) |
Definition at line 2467 of file cam.c.
References cSimpleList< T >::First(), L_GEN_INFO, cSimpleList< T >::Next(), and PRINTF.
{
cMutexLock lock(&camMutex);
for(cEcmHandler *handler=handlerList.First(); handler; handler=handlerList.Next(handler))
if(!handler->IsIdle()) {
if(log) PRINTF(L_GEN_INFO,"handler %s on card %s is not idle",handler->Id(),devId);
return true;
}
return false;
}
| bool cCam::Active | ( | bool | log | ) |
| int cCam::Adapter | ( | void | ) | [inline] |
| void cCam::AddHook | ( | cLogHook * | hook | ) |
Definition at line 2508 of file cam.c.
References cHookManager::AddHook().
Referenced by cSystem::AddHook().
{
cMutexLock lock(&camMutex);
if(!hookman) hookman=new cHookManager(device,devId);
if(hookman) hookman->AddHook(hook);
}
| void cCam::AddHook | ( | cLogHook * | hook | ) |
| void cCam::AddPrg | ( | cPrg * | prg | ) |
| void cCam::AddPrg | ( | cPrg * | prg | ) |
Definition at line 2319 of file cam.c.
References cSimpleListBase::Add(), cPrgPid::caDescr, cPrg::caDescr, cSimpleListBase::Clear(), cCaDescr::Clear(), cScSetup::ConcurrentFF, cSimpleListBase::Count(), cEcmHandler::CwIndex(), cSimpleListBase::Del(), cSimpleList< T >::First(), i, cEcmHandler::Id(), cEcmHandler::IsIdle(), IsSoftCSA(), cPrg::IsUpdate(), L_CORE_PIDS, LBEND, LBPUT, LBSTART, LBSTARTF, MAX_SPLIT_SID, cSimpleList< T >::Next(), cPrgPid::pid, pid::pid, cPrg::pids, PRINTF, ScSetup, cCaDescr::Set(), cEcmHandler::SetPrg(), cEcmHandler::Sid(), cPrg::sid, SIDGRP_SHIFT, cPrg::SimplifyCaDescr(), cPrg::source, cPrg::transponder, and TYPENAME.
Referenced by sascCam::AddPrg(), and cScCamSlot::Process().
{
cMutexLock lock(&camMutex);
bool islive=false;
for(cPrgPid *pid=prg->pids.First(); pid; pid=prg->pids.Next(pid))
if(pid->pid==liveVpid || pid->pid==liveApid) {
islive=true;
break;
}
bool needZero=!IsSoftCSA(islive) && (islive || !ScSetup.ConcurrentFF);
bool noshift=IsSoftCSA(true) || (prg->IsUpdate() && prg->pids.Count()==0);
PRINTF(L_CORE_PIDS,"%s: %s SID %d (zero=%d noshift=%d)",devId,prg->IsUpdate()?"update":"add",prg->sid,needZero,noshift);
if(prg->pids.Count()>0) {
LBSTART(L_CORE_PIDS);
LBPUT("%s: pids",devId);
for(cPrgPid *pid=prg->pids.First(); pid; pid=prg->pids.Next(pid))
LBPUT(" %s=%04x",TYPENAME(pid->type),pid->pid);
LBEND();
}
bool isSplit=false;
if(prg->pids.Count()>0 && prg->SimplifyCaDescr()) isSplit=true;
else {
for(int i=0; splitSid[i]; i++)
if(splitSid[i]==prg->sid) { isSplit=true; break; }
}
if(!isSplit) {
cEcmHandler *handler=GetHandler(prg->sid,needZero,noshift);
if(handler) {
PRINTF(L_CORE_PIDS,"%s: found handler for SID %d (%s idle=%d idx=%d)",devId,prg->sid,handler->Id(),handler->IsIdle(),handler->CwIndex());
prg->source=source;
prg->transponder=transponder;
handler->SetPrg(prg);
}
}
else {
PRINTF(L_CORE_PIDS,"%s: SID %d is handled as splitted",devId,prg->sid);
// first update the splitSid list
if(prg->pids.Count()==0) { // delete
for(int i=0; splitSid[i]; i++)
if(splitSid[i]==prg->sid) {
memmove(&splitSid[i],&splitSid[i+1],sizeof(splitSid[0])*(MAX_SPLIT_SID-i));
break;
}
PRINTF(L_CORE_PIDS,"%s: deleted from list",devId);
}
else { // add
bool has=false;
int i;
for(i=0; splitSid[i]; i++) if(splitSid[i]==prg->sid) has=true;
if(!has) {
if(i<MAX_SPLIT_SID) {
splitSid[i]=prg->sid;
splitSid[i+1]=0;
PRINTF(L_CORE_PIDS,"%s: added to list",devId);
}
else PRINTF(L_CORE_PIDS,"%s: split SID list overflow",devId);
}
}
LBSTART(L_CORE_PIDS);
LBPUT("%s: split SID list now:",devId);
for(int i=0; i<=MAX_SPLIT_SID; i++) LBPUT(" %d",splitSid[i]);
LBEND();
// prepare an empty prg head
cPrg work;
work.source=source;
work.transponder=transponder;
// loop through pids
int group=1;
cPrgPid *first;
while((first=prg->pids.First())) {
LBSTARTF(L_CORE_PIDS);
LBPUT("%s: group %d pids",devId,group);
prg->pids.Del(first,false);
work.caDescr.Set(&first->caDescr);
first->caDescr.Clear();
work.pids.Add(first);
LBPUT(" %04x",first->pid);
for(cPrgPid *pid=prg->pids.First(); pid;) {
cPrgPid *next=prg->pids.Next(pid);
if(work.caDescr==pid->caDescr) { // same group
prg->pids.Del(pid,false);
pid->caDescr.Clear();
work.pids.Add(pid);
LBPUT(" %04x",pid->pid);
}
pid=next;
}
LBEND();
// get a handler for the group
int grsid=group*SIDGRP_SHIFT+prg->sid;
cEcmHandler *handler=0;
if(group==1) {
// in the first group check if we have a non-split handler
// for the sid
for(handler=handlerList.First(); handler; handler=handlerList.Next(handler))
if(handler->Sid()==prg->sid) {
// let GetHandler() take care of needZero/noshift stuff
handler=GetHandler(prg->sid,needZero,noshift);
break;
}
}
// otherwise get the group-sid handler
if(!handler) handler=GetHandler(grsid,needZero,noshift);
if(handler) {
PRINTF(L_CORE_PIDS,"%s: found handler for group-SID %d (%s idle=%d idx=%d)",devId,grsid,handler->Id(),handler->IsIdle(),handler->CwIndex());
work.sid=grsid;
handler->SetPrg(&work);
}
// prepare for next group
work.pids.Clear();
needZero=false; // only one group can have this
group++;
}
// now we scan the handler list for leftover group handlers
for(cEcmHandler *handler=handlerList.First(); handler; handler=handlerList.Next(handler)) {
int sid=handler->Sid();
if(!handler->IsIdle() && sid>SIDGRP_SHIFT) {
int gr=sid/SIDGRP_SHIFT;
sid%=SIDGRP_SHIFT;
if(sid==prg->sid && gr>=group) {
PRINTF(L_CORE_PIDS,"%s: idle group handler %s idx=%d",devId,handler->Id(),handler->CwIndex());
work.sid=handler->Sid();
handler->SetPrg(&work);
}
}
}
}
}
| bool cCam::Assign | ( | cDevice * | Device, |
| bool | Query = false |
||
| ) | [protected, virtual] |
Assigns this adapter to the given Device, if this is possible. If Query is 'true', the adapter only checks whether it can be assigned to the Device, but doesn't actually assign itself to it. Returns true if the adapter can be assigned to the Device. If Device is NULL, the adapter 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'.
Implements cCiAdapter.
Definition at line 2267 of file cam.c.
{
return Device ? (Device==device) : true;
}
| virtual bool cCam::Assign | ( | cDevice * | Device, |
| bool | Query = false |
||
| ) | [protected, virtual] |
Assigns this adapter to the given Device, if this is possible. If Query is 'true', the adapter only checks whether it can be assigned to the Device, but doesn't actually assign itself to it. Returns true if the adapter can be assigned to the Device. If Device is NULL, the adapter 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'.
Implements cCiAdapter.
| void cCam::CaidsChanged | ( | void | ) |
| void cCam::CaidsChanged | ( | void | ) |
| char * cCam::CurrentKeyStr | ( | int | num, |
| const char ** | id | ||
| ) |
Definition at line 2457 of file cam.c.
References cEcmHandler::CurrentKeyStr(), cSimpleList< T >::First(), and cSimpleList< T >::Next().
Referenced by cGlobal::CurrKeyStr().
{
cMutexLock lock(&camMutex);
if(id) *id=devId;
cEcmHandler *handler;
for(handler=handlerList.First(); handler; handler=handlerList.Next(handler))
if(--num<0) return handler->CurrentKeyStr();
return 0;
}
| char* cCam::CurrentKeyStr | ( | int | num, |
| const char ** | id | ||
| ) |
| cDeCSA* cCam::DeCSA | ( | void | ) | const [inline] |
| void cCam::DumpAV7110 | ( | void | ) |
| void cCam::DumpAV7110 | ( | void | ) |
Definition at line 2584 of file cam.c.
References cScDevicePlugin::DumpAV().
Referenced by cEcmHandler::Process().
{
devplugin->DumpAV(device);
}
| int cCam::Frontend | ( | void | ) | [inline] |
| int cCam::GetCaids | ( | int | slot, |
| unsigned short * | Caids, | ||
| int | max | ||
| ) |
| int cCam::GetCaids | ( | int | slot, |
| unsigned short * | Caids, | ||
| int | max | ||
| ) |
Definition at line 2090 of file cam.c.
References i, and MAX_CI_SLOT_CAIDS.
{
BuildCaids(false);
cMutexLock lock(&ciMutex);
if(Caids) {
int i;
for(i=0; i<MAX_CI_SLOT_CAIDS && i<max && caids[i]; i++) Caids[i]=caids[slot][i];
Caids[i]=0;
}
return version[slot];
}
| bool cCam::HasPrg | ( | int | prg | ) |
| bool cCam::HasPrg | ( | int | prg | ) |
Definition at line 2448 of file cam.c.
References cSimpleList< T >::First(), and cSimpleList< T >::Next().
{
cMutexLock lock(&camMutex);
for(cEcmHandler *handler=handlerList.First(); handler; handler=handlerList.Next(handler))
if(!handler->IsIdle() && handler->Sid()==prg)
return true;
return false;
}
| void cCam::HouseKeeping | ( | void | ) |
Definition at line 2478 of file cam.c.
References cSimpleListBase::Count(), cSimpleList< T >::First(), cSimpleList< T >::Next(), cScSetup::PrestartAU, and ScSetup.
{
cMutexLock lock(&camMutex);
for(cEcmHandler *handler=handlerList.First(); handler;) {
cEcmHandler *next=handlerList.Next(handler);
if(handler->IsRemoveable()) RemHandler(handler);
handler=next;
}
if(handlerList.Count()<1 && !ScSetup.PrestartAU) {
delete hookman; hookman=0;
delete logger; logger=0;
}
}
| void cCam::HouseKeeping | ( | void | ) |
| bool cCam::IsSoftCSA | ( | bool | live | ) |
SASC.
Definition at line 2273 of file cam.c.
Referenced by AddPrg(), and cEcmHandler::Process().
{
return softcsa && (!fullts || !live);
}
| bool cCam::IsSoftCSA | ( | bool | live | ) |
| void cCam::LogEcmStatus | ( | const cEcmInfo * | ecm, |
| bool | on | ||
| ) |
Definition at line 2501 of file cam.c.
References cLogger::EcmStatus().
Referenced by cSystem::StartLog(), and cSystem::~cSystem().
{
cMutexLock lock(&camMutex);
if(on) LogStartup();
if(logger) logger->EcmStatus(ecm,on);
}
| void cCam::LogEcmStatus | ( | const cEcmInfo * | ecm, |
| bool | on | ||
| ) |
| virtual eModuleStatus cCam::ModuleStatus | ( | int | Slot | ) | [protected, virtual] |
Returns the status of the CAM in the given Slot.
Implements cCiAdapter.
| eModuleStatus cCam::ModuleStatus | ( | int | Slot | ) | [protected, virtual] |
Returns the status of the CAM in the given Slot.
Implements cCiAdapter.
Definition at line 2259 of file cam.c.
References cScSetup::CapCheck(), cDevice::CardIndex(), msNone, ScSetup, cScCamSlot::Status(), and Stop().
| bool cCam::OwnSlot | ( | const cCamSlot * | slot | ) | const |
| bool cCam::OwnSlot | ( | const cCamSlot * | slot | ) | const |
| void cCam::PostTune | ( | void | ) |
Definition at line 2289 of file cam.c.
References cLogger::PreScan(), cScSetup::PrestartAU, and ScSetup.
Referenced by SCDEVICE::SetChannelDevice().
{
if(ScSetup.PrestartAU) {
LogStartup();
if(logger) logger->PreScan(source,transponder);
}
}
| void cCam::PostTune | ( | void | ) |
| int cCam::Read | ( | unsigned char * | Buffer, |
| int | MaxLength | ||
| ) | [protected, virtual] |
Definition at line 2160 of file cam.c.
References CAM_READ_TIMEOUT, cCiFrame::Del(), cTimeMs::Elapsed(), cCiFrame::Get(), L_CORE_CI, L_CORE_CIFULL, L_GEN_DEBUG, LDUMP, LOG, PRINTF, cTimeMs::Set(), and cCondWait::SleepMs().
{
cMutexLock lock(&ciMutex);
if(rb && Buffer && MaxLength>0) {
int s;
unsigned char *data=frame.Get(s);
if(data) {
if(s<=MaxLength) memcpy(Buffer,data,s);
else PRINTF(L_GEN_DEBUG,"internal: sc-ci %s rb frame size exceeded %d",devId,s);
frame.Del();
if(Buffer[2]!=0x80 || LOG(L_CORE_CIFULL)) {
LDUMP(L_CORE_CI,Buffer,s,"%s.%d <-",devId,Buffer[0]);
readTimer.Set();
}
return s;
}
}
else cCondWait::SleepMs(CAM_READ_TIMEOUT);
if(LOG(L_CORE_CIFULL) && readTimer.Elapsed()>2000) {
PRINTF(L_CORE_CIFULL,"%s: read heartbeat",devId);
readTimer.Set();
}
return 0;
}
| virtual int cCam::Read | ( | unsigned char * | Buffer, |
| int | MaxLength | ||
| ) | [protected, virtual] |
| virtual bool cCam::Reset | ( | int | Slot | ) | [protected, virtual] |
Resets the CAM in the given Slot. Returns true if the operation was successful.
Implements cCiAdapter.
| bool cCam::Reset | ( | int | Slot | ) | [protected, virtual] |
Resets the CAM in the given Slot. Returns true if the operation was successful.
Implements cCiAdapter.
Definition at line 2252 of file cam.c.
References L_CORE_CI, PRINTF, and cScCamSlot::Reset().
{
cMutexLock lock(&ciMutex);
PRINTF(L_CORE_CI,"%s: reset of slot %d requested",devId,Slot);
return slots[Slot] ? slots[Slot]->Reset():false;
}
| bool cCam::SetCaDescr | ( | ca_descr_t * | ca_descr, |
| bool | initial | ||
| ) | [virtual] |
SASC
Definition at line 2562 of file cam.c.
References cScDevicePlugin::SetCaDescr(), and cDeCSA::SetDescr().
Referenced by WriteCW().
{
if(!softcsa || (fullts && ca_descr->index==0))
return devplugin->SetCaDescr(device,ca_descr,initial);
#ifndef SASC
else if(decsa)
return decsa->SetDescr(ca_descr,initial);
#endif //!SASC
return false;
}
| virtual bool cCam::SetCaDescr | ( | ca_descr_t * | ca_descr, |
| bool | initial | ||
| ) | [virtual] |
| virtual bool cCam::SetCaPid | ( | ca_pid_t * | ca_pid | ) | [virtual] |
| bool cCam::SetCaPid | ( | ca_pid_t * | ca_pid | ) | [virtual] |
SASC
Definition at line 2573 of file cam.c.
References cDeCSA::SetCaPid(), and cScDevicePlugin::SetCaPid().
Referenced by SetCWIndex().
| void cCam::SetCWIndex | ( | int | pid, |
| int | index | ||
| ) |
| void cCam::SetCWIndex | ( | int | pid, |
| int | index | ||
| ) |
Definition at line 2520 of file cam.c.
References cScSetup::ConcurrentFF, L_CORE_PIDS, L_GEN_ERROR, L_GEN_WARN, MAX_CW_IDX, PRINTF, ScSetup, SetCaPid(), and cScSetup::Store().
Referenced by cEcmHandler::SetPrg(), and cEcmHandler::ShiftCwIndex().
{
if(index<MAX_CW_IDX) {
ca_pid_t ca_pid;
ca_pid.pid=pid;
ca_pid.index=index;
PRINTF(L_CORE_PIDS,"%s: descrambling pid %04x on index %x",devId,pid,index);
if(!SetCaPid(&ca_pid))
if(index>0) {
PRINTF(L_GEN_ERROR,"CA_SET_PID failed (%s). Expect a black screen/bad recording. Do you use the patched DVB driver?",strerror(errno));
PRINTF(L_GEN_WARN,"Adjusting 'Concurrent FF streams' to NO");
ScSetup.ConcurrentFF=0;
ScSetup.Store(true);
}
}
}
| void cCam::SetPid | ( | int | type, |
| int | pid, | ||
| bool | on | ||
| ) |
Definition at line 2297 of file cam.c.
References L_CORE_PIDS, and PRINTF.
Referenced by SCDEVICE::SetPid().
{
cMutexLock lock(&camMutex);
int oldA=liveApid, oldV=liveVpid;
if(type==1) liveVpid=on ? pid:0;
else if(type==0) liveApid=on ? pid:0;
else if(liveVpid==pid && on) liveVpid=0;
else if(liveApid==pid && on) liveApid=0;
if(oldA!=liveApid || oldV!=liveVpid)
PRINTF(L_CORE_PIDS,"%s: livepids video=%04x audio=%04x",devId,liveVpid,liveApid);
}
| void cCam::SetPid | ( | int | type, |
| int | pid, | ||
| bool | on | ||
| ) |
| void cCam::Stop | ( | void | ) |
Definition at line 2309 of file cam.c.
References cHookManager::Down(), cLogger::Down(), cSimpleList< T >::First(), and cSimpleList< T >::Next().
Referenced by ModuleStatus(), cScCamSlot::Process(), sascCam::Stop(), and Tune().
{
cMutexLock lock(&camMutex);
for(cEcmHandler *handler=handlerList.First(); handler; handler=handlerList.Next(handler))
handler->Stop();
if(logger) logger->Down();
if(hookman) hookman->Down();
memset(splitSid,0,sizeof(splitSid));
}
| void cCam::Stop | ( | void | ) |
| bool cCam::TriggerHook | ( | int | id | ) |
| bool cCam::TriggerHook | ( | int | id | ) |
Definition at line 2515 of file cam.c.
References cHookManager::TriggerHook().
Referenced by cSystem::TriggerHook().
{
return hookman && hookman->TriggerHook(id);
}
| void cCam::Tune | ( | const cChannel * | channel | ) |
Definition at line 2278 of file cam.c.
References L_CORE_PIDS, PRINTF, cChannel::Source(), Stop(), cSource::ToString(), and cChannel::Transponder().
Referenced by SCDEVICE::SetChannelDevice(), and sascCam::Tune().
{
cMutexLock lock(&camMutex);
if(source!=channel->Source() || transponder!=channel->Transponder()) {
source=channel->Source(); transponder=channel->Transponder();
PRINTF(L_CORE_PIDS,"%s: now tuned to source %x(%s) transponder %x",devId,source,*cSource::ToString(source),transponder);
Stop();
}
else PRINTF(L_CORE_PIDS,"%s: tune to same source/transponder",devId);
}
| void cCam::Tune | ( | const cChannel * | channel | ) |
| void cCam::Write | ( | const unsigned char * | Buffer, |
| int | Length | ||
| ) | [protected, virtual] |
Definition at line 2189 of file cam.c.
References cCiFrame::Avail(), b, TPDU::data, cCiFrame::Del(), cScCamSlot::Frame(), cCiFrame::Get(), cCiFrame::GetBuff(), L_CORE_CI, L_CORE_CIFULL, LDUMP, LOG, PRINTF, cScCamSlot::Process(), cCiFrame::Put(), SB_TAG, TPDU::slot, TAG, TPDU::tag, TPDU::tcid, and TPDU.
{
cMutexLock lock(&ciMutex);
if(buff && len>=5) {
struct TPDU *tpdu=(struct TPDU *)buff;
int slot=tpdu->slot;
cCiFrame *slotframe=slots[slot]->Frame();
if(buff[2]!=0xA0 || buff[3]>0x01 || LOG(L_CORE_CIFULL))
LDUMP(L_CORE_CI,buff,len,"%s.%d ->",devId,slot);
if(slots[slot]) {
switch(tpdu->tag) {
case 0x81: // T_RCV
{
int s;
unsigned char *d=slotframe->Get(s);
if(d) {
unsigned char *b;
if((b=frame.GetBuff(s+6))) {
TPDU(b,slot);
memcpy(b+2,d,s);
slotframe->Del(); // delete from rb before Avail()
SB_TAG(b+2+s,slotframe->Avail()>0 ? 0x80:0x00);
frame.Put();
}
else slotframe->Del();
}
break;
}
case 0x82: // T_CREATE_TC
{
tcid=tpdu->data[0];
unsigned char *b;
static const unsigned char reqCAS[] = { 0xA0,0x07,0x01,0x91,0x04,0x00,0x03,0x00,0x41 };
if((b=slotframe->GetBuff(sizeof(reqCAS)))) {
memcpy(b,reqCAS,sizeof(reqCAS));
b[2]=tcid;
slotframe->Put();
}
if((b=frame.GetBuff(9))) {
TPDU(b,slot);
TAG(&b[2],0x83,0x01); b[4]=tcid;
SB_TAG(&b[5],slotframe->Avail()>0 ? 0x80:0x00);
frame.Put();
}
break;
}
case 0xA0: // T_DATA_LAST
{
slots[slot]->Process(buff,len);
unsigned char *b;
if((b=frame.GetBuff(6))) {
TPDU(b,slot);
SB_TAG(&b[2],slotframe->Avail()>0 ? 0x80:0x00);
frame.Put();
}
break;
}
}
}
}
else PRINTF(L_CORE_CIFULL,"%s: short write (buff=%d len=%d)",devId,buff!=0,len);
}
| virtual void cCam::Write | ( | const unsigned char * | Buffer, |
| int | Length | ||
| ) | [protected, virtual] |
| void cCam::WriteCW | ( | int | index, |
| unsigned char * | cw, | ||
| bool | force | ||
| ) |
Definition at line 2537 of file cam.c.
References L_GEN_ERROR, MAX_CW_IDX, PRINTF, and SetCaDescr().
Referenced by cEcmHandler::Process().
{
if(index<MAX_CW_IDX) {
for(int i=0; i<16; i+=4) cw[i+3]=cw[i]+cw[i+1]+cw[i+2];
ca_descr_t ca_descr;
ca_descr.index=index;
unsigned char *last=lastCW[index];
if(force || memcmp(&cw[0],&last[0],8)) {
memcpy(&last[0],&cw[0],8);
ca_descr.parity=0;
memcpy(ca_descr.cw,&cw[0],8);
if(!SetCaDescr(&ca_descr,force))
PRINTF(L_GEN_ERROR,"CA_SET_DESCR failed (%s). Expect a black screen.",strerror(errno));
}
if(force || memcmp(&cw[8],&last[8],8)) {
memcpy(&last[8],&cw[8],8);
ca_descr.parity=1;
memcpy(ca_descr.cw,&cw[8],8);
if(!SetCaDescr(&ca_descr,force))
PRINTF(L_GEN_ERROR,"CA_SET_DESCR failed (%s). Expect a black screen.",strerror(errno));
}
}
}
| void cCam::WriteCW | ( | int | index, |
| unsigned char * | cw, | ||
| bool | force | ||
| ) |