2014-03-08 12:07:47 +01:00
|
|
|
/*
|
|
|
|
* sectionfilter.h: SAT>IP plugin for the Video Disk Recorder
|
|
|
|
*
|
|
|
|
* See the README file for copyright information and how to reach the author.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SATIP_SECTIONFILTER_H
|
|
|
|
#define __SATIP_SECTIONFILTER_H
|
|
|
|
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif // __FreeBSD__
|
|
|
|
#include <vdr/device.h>
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "statistics.h"
|
|
|
|
|
2014-03-30 21:20:56 +02:00
|
|
|
#define USE_THREADED_SECTIONFILTER
|
|
|
|
|
2014-03-08 12:07:47 +01:00
|
|
|
class cSatipSectionFilter : public cSatipSectionStatistics {
|
|
|
|
private:
|
2014-03-30 21:20:56 +02:00
|
|
|
enum {
|
|
|
|
eWriteMaxRetries = 20,
|
|
|
|
eDmxMaxFilterSize = 18,
|
|
|
|
eDmxMaxSectionSize = 4096,
|
2014-03-13 17:23:55 +01:00
|
|
|
eDmxMaxSectionFeedSize = (eDmxMaxSectionSize + TS_SIZE)
|
2014-03-08 12:07:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int pusiSeenM;
|
|
|
|
int feedCcM;
|
|
|
|
int doneqM;
|
|
|
|
|
|
|
|
uint8_t *secBufM;
|
2014-03-13 17:23:55 +01:00
|
|
|
uint8_t secBufBaseM[eDmxMaxSectionFeedSize];
|
2014-03-08 12:07:47 +01:00
|
|
|
uint16_t secBufpM;
|
|
|
|
uint16_t secLenM;
|
|
|
|
uint16_t tsFeedpM;
|
|
|
|
uint16_t pidM;
|
|
|
|
|
|
|
|
int deviceIndexM;
|
|
|
|
int socketM[2];
|
|
|
|
|
2014-03-13 17:23:55 +01:00
|
|
|
uint8_t filterValueM[eDmxMaxFilterSize];
|
|
|
|
uint8_t filterMaskM[eDmxMaxFilterSize];
|
|
|
|
uint8_t filterModeM[eDmxMaxFilterSize];
|
2014-03-08 12:07:47 +01:00
|
|
|
|
2014-03-13 17:23:55 +01:00
|
|
|
uint8_t maskAndModeM[eDmxMaxFilterSize];
|
|
|
|
uint8_t maskAndNotModeM[eDmxMaxFilterSize];
|
2014-03-08 12:07:47 +01:00
|
|
|
|
|
|
|
inline uint16_t GetLength(const uint8_t *dataP);
|
|
|
|
void New(void);
|
|
|
|
int Filter(void);
|
|
|
|
inline int Feed(void);
|
|
|
|
int CopyDump(const uint8_t *bufP, uint8_t lenP);
|
|
|
|
|
|
|
|
public:
|
|
|
|
// constructor & destructor
|
|
|
|
cSatipSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP);
|
|
|
|
virtual ~cSatipSectionFilter();
|
|
|
|
void Process(const uint8_t* dataP);
|
|
|
|
int GetFd(void) { return socketM[0]; }
|
|
|
|
uint16_t GetPid(void) const { return pidM; }
|
|
|
|
};
|
|
|
|
|
2014-03-30 21:20:56 +02:00
|
|
|
#ifdef USE_THREADED_SECTIONFILTER
|
2014-03-08 12:07:47 +01:00
|
|
|
class cSatipSectionFilterHandler : public cThread {
|
2014-03-30 21:20:56 +02:00
|
|
|
protected:
|
|
|
|
virtual void Action(void);
|
|
|
|
private:
|
|
|
|
cRingBufferLinear *ringBufferM;
|
|
|
|
#else
|
|
|
|
class cSatipSectionFilterHandler {
|
|
|
|
#endif
|
2014-03-08 12:07:47 +01:00
|
|
|
private:
|
|
|
|
enum {
|
|
|
|
eMaxSecFilterCount = 32
|
|
|
|
};
|
|
|
|
cMutex mutexM;
|
|
|
|
int deviceIndexM;
|
|
|
|
cSatipSectionFilter *filtersM[eMaxSecFilterCount];
|
|
|
|
|
|
|
|
bool Delete(unsigned int indexP);
|
|
|
|
bool IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
cSatipSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP);
|
|
|
|
virtual ~cSatipSectionFilterHandler();
|
|
|
|
cString GetInformation(void);
|
|
|
|
int Open(u_short pidP, u_char tidP, u_char maskP);
|
|
|
|
void Close(int handleP);
|
|
|
|
int GetPid(int handleP);
|
|
|
|
void Write(u_char *bufferP, int lengthP);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SATIP_SECTIONFILTER_H
|