2007-09-24 15:03:38 +02:00
|
|
|
/*
|
|
|
|
* sectionfilter.h: IPTV plugin for the Video Disk Recorder
|
|
|
|
*
|
|
|
|
* See the README file for copyright information and how to reach the author.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IPTV_SECTIONFILTER_H
|
|
|
|
#define __IPTV_SECTIONFILTER_H
|
|
|
|
|
2012-07-10 21:12:29 +02:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif // __FreeBSD__
|
2009-02-27 15:05:19 +01:00
|
|
|
#include <vdr/device.h>
|
2007-09-24 15:03:38 +02:00
|
|
|
|
|
|
|
#include "common.h"
|
2007-10-05 21:00:44 +02:00
|
|
|
#include "statistics.h"
|
2007-09-24 15:03:38 +02:00
|
|
|
|
2007-10-05 21:00:44 +02:00
|
|
|
class cIptvSectionFilter : public cIptvSectionStatistics {
|
2007-09-24 15:03:38 +02:00
|
|
|
private:
|
2014-04-05 17:43:23 +02:00
|
|
|
enum {
|
|
|
|
eDmxMaxFilterSize = 18,
|
|
|
|
eDmxMaxSectionCount = 64,
|
|
|
|
eDmxMaxSectionSize = 4096,
|
|
|
|
eDmxMaxSectionFeedSize = (eDmxMaxSectionSize + TS_SIZE)
|
2007-10-05 23:52:16 +02:00
|
|
|
};
|
|
|
|
|
2013-02-23 14:31:11 +01:00
|
|
|
int pusiSeenM;
|
|
|
|
int feedCcM;
|
|
|
|
int doneqM;
|
2007-09-24 19:20:58 +02:00
|
|
|
|
2013-02-23 14:31:11 +01:00
|
|
|
uint8_t *secBufM;
|
2014-04-05 17:43:23 +02:00
|
|
|
uint8_t secBufBaseM[eDmxMaxSectionFeedSize];
|
2013-02-23 14:31:11 +01:00
|
|
|
uint16_t secBufpM;
|
|
|
|
uint16_t secLenM;
|
|
|
|
uint16_t tsFeedpM;
|
|
|
|
uint16_t pidM;
|
2009-02-27 15:05:19 +01:00
|
|
|
|
2014-04-05 17:43:23 +02:00
|
|
|
cRingBufferFrame *ringBufferM;
|
2013-03-27 21:13:15 +01:00
|
|
|
int deviceIndexM;
|
|
|
|
int socketM[2];
|
2007-09-24 19:20:58 +02:00
|
|
|
|
2014-04-05 17:43:23 +02:00
|
|
|
uint8_t filterValueM[eDmxMaxFilterSize];
|
|
|
|
uint8_t filterMaskM[eDmxMaxFilterSize];
|
|
|
|
uint8_t filterModeM[eDmxMaxFilterSize];
|
2009-02-27 15:05:19 +01:00
|
|
|
|
2014-04-05 17:43:23 +02:00
|
|
|
uint8_t maskAndModeM[eDmxMaxFilterSize];
|
|
|
|
uint8_t maskAndNotModeM[eDmxMaxFilterSize];
|
2007-09-24 15:03:38 +02:00
|
|
|
|
2013-02-23 14:31:11 +01:00
|
|
|
inline uint16_t GetLength(const uint8_t *dataP);
|
2009-02-27 15:05:19 +01:00
|
|
|
void New(void);
|
|
|
|
int Filter(void);
|
|
|
|
inline int Feed(void);
|
2013-02-23 14:31:11 +01:00
|
|
|
int CopyDump(const uint8_t *bufP, uint8_t lenP);
|
2007-09-24 15:03:38 +02:00
|
|
|
|
|
|
|
public:
|
2007-09-24 19:20:58 +02:00
|
|
|
// constructor & destructor
|
2013-02-23 14:31:11 +01:00
|
|
|
cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP);
|
2007-09-24 19:20:58 +02:00
|
|
|
virtual ~cIptvSectionFilter();
|
2013-02-23 14:31:11 +01:00
|
|
|
void Process(const uint8_t* dataP);
|
2014-04-05 17:43:23 +02:00
|
|
|
bool Send(void);
|
2013-03-27 21:13:15 +01:00
|
|
|
int GetFd(void) { return socketM[0]; }
|
2013-02-23 14:31:11 +01:00
|
|
|
uint16_t GetPid(void) const { return pidM; }
|
2007-09-24 15:03:38 +02:00
|
|
|
};
|
|
|
|
|
2013-03-27 21:13:15 +01:00
|
|
|
class cIptvSectionFilterHandler : public cThread {
|
|
|
|
private:
|
|
|
|
enum {
|
|
|
|
eMaxSecFilterCount = 32
|
|
|
|
};
|
2014-04-05 17:43:23 +02:00
|
|
|
cRingBufferLinear *ringBufferM;
|
2013-03-27 21:13:15 +01:00
|
|
|
cMutex mutexM;
|
|
|
|
int deviceIndexM;
|
|
|
|
cIptvSectionFilter *filtersM[eMaxSecFilterCount];
|
|
|
|
|
|
|
|
bool Delete(unsigned int indexP);
|
|
|
|
bool IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void Action(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
cIptvSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP);
|
|
|
|
virtual ~cIptvSectionFilterHandler();
|
|
|
|
cString GetInformation(void);
|
|
|
|
int Open(u_short pidP, u_char tidP, u_char maskP);
|
|
|
|
void Close(int handleP);
|
2014-02-09 18:22:02 +01:00
|
|
|
int GetPid(int handleP);
|
2013-03-27 21:13:15 +01:00
|
|
|
void Write(u_char *bufferP, int lengthP);
|
|
|
|
};
|
|
|
|
|
2007-09-24 15:03:38 +02:00
|
|
|
#endif // __IPTV_SECTIONFILTER_H
|