SASC-NG
DVBSoftCAM

cDeCsaTSBuffer Class Reference

#include <device.h>

Inheritance diagram for cDeCsaTSBuffer:

List of all members.

Public Member Functions

 cDeCsaTSBuffer (int File, int Size, int CardIndex, cDeCSA *DeCsa, bool ScActive)
 SASC.
 ~cDeCsaTSBuffer ()
uchar * Get (void)
void SetActive (bool ScActive)

Detailed Description

Definition at line 48 of file device.h.


Constructor & Destructor Documentation

cDeCsaTSBuffer::cDeCsaTSBuffer ( int  File,
int  Size,
int  CardIndex,
cDeCSA *  DeCsa,
bool  ScActive 
)

SASC.

Definition at line 50 of file device.c.

References SetActive(), cDeCSA::SetActive(), cThread::SetDescription(), cThread::Start(), and TS_SIZE.

{
  SetDescription("TS buffer on device %d", CardIndex);
  f=File; size=Size; cardIndex=CardIndex; decsa=DeCsa;
  delivered=false;
  ringBuffer=new cRingBufferLinear(Size,TS_SIZE,true,"FFdecsa-TS");
  ringBuffer->SetTimeouts(100,100);
  if(decsa) decsa->SetActive(true);
  SetActive(ScActive);
  Start();
}
cDeCsaTSBuffer::~cDeCsaTSBuffer ( )

Definition at line 62 of file device.c.

References cThread::Cancel(), and cDeCSA::SetActive().

{
  Cancel(3);
  if(decsa) decsa->SetActive(false);
  delete ringBuffer;
}

Member Function Documentation

uchar * cDeCsaTSBuffer::Get ( void  )

Definition at line 93 of file device.c.

References cDeCSA::Decrypt(), esyslog, i, NULL, cCondWait::SleepMs(), TS_SIZE, and TS_SYNC_BYTE.

Referenced by SCDEVICE::GetTSPacket().

{
  int Count=0;
  if(delivered) { ringBuffer->Del(TS_SIZE); delivered=false; }
  uchar *p=ringBuffer->Get(Count);
  if(p && Count>=TS_SIZE) {
    if(*p!=TS_SYNC_BYTE) {
      for(int i=1; i<Count; i++)
        if(p[i]==TS_SYNC_BYTE &&
           (i+TS_SIZE==Count || (i+TS_SIZE>Count && p[i+TS_SIZE]==TS_SYNC_BYTE)) ) { Count=i; break; }
      ringBuffer->Del(Count);
      esyslog("ERROR: skipped %d bytes to sync on TS packet on device %d",Count,cardIndex);
      return NULL;
      }

    if(scActive && (p[3]&0xC0)) {
      if(decsa) {
        if(!decsa->Decrypt(p,Count,false)) {
          cCondWait::SleepMs(20);
          return NULL;
          }
        }
      else p[3]&=~0xC0; // FF hack
      }

    delivered=true;
    return p;
    }
  return NULL;
}
void cDeCsaTSBuffer::SetActive ( bool  ScActive)

Definition at line 69 of file device.c.

Referenced by cDeCsaTSBuffer(), and SCDEVICE::SetPid().

{
  scActive=ScActive;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines