vdr  2.6.1
filter.h
Go to the documentation of this file.
1 /*
2  * filter.h: Section filter
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: filter.h 5.1 2021/03/16 15:10:54 kls Exp $
8  */
9 
10 #ifndef __FILTER_H
11 #define __FILTER_H
12 
13 #include <sys/types.h>
14 #include "tools.h"
15 
16 #define DEPRECATED_SECTIONSYNCER_SYNC_REPEAT 1
17 
19 private:
22  bool random;
23  bool synced;
24  bool complete;
25  uint32_t segments; // bit flags for the 32 segments
26  uchar sections[32]; // holds 32 * 8 = 256 bits, as flags for the sections
27  void SetSectionFlag(uchar Section, bool On) { if (On) sections[Section / 8] |= (1 << (Section % 8)); else sections[Section / 8] &= ~(1 << (Section % 8)); }
28  bool GetSectionFlag(uchar Section) { return sections[Section / 8] & (1 << (Section % 8)); }
29 public:
30  cSectionSyncer(bool Random = false);
39  void Reset(void);
40  bool Check(uchar Version, int SectionNumber);
44  bool Processed(int SectionNumber, int LastSectionNumber, int SegmentLastSectionNumber = -1);
50  bool Complete(void) { return complete; }
52 #if DEPRECATED_SECTIONSYNCER_SYNC_REPEAT
53  void Repeat(void);
54  bool Sync(uchar Version, int Number, int LastNumber);
55 #endif
56  };
57 
60 public:
62  };
63 
64 class cFilterData : public cListObject {
65 public:
66  u_short pid;
69  bool sticky;
70  cFilterData(void);
71  cFilterData(u_short Pid, u_char Tid, u_char Mask, bool Sticky);
72  cFilterData& operator= (const cFilterData &FilterData);
73  bool Is(u_short Pid, u_char Tid, u_char Mask);
74  bool Matches(u_short Pid, u_char Tid);
75  };
76 
77 class cChannel;
78 class cSectionHandler;
79 
80 class cFilter : public cListObject {
81  friend class cSectionHandler;
82 private:
85  bool on;
86 protected:
87  cFilter(void);
88  cFilter(u_short Pid, u_char Tid, u_char Mask = 0xFF);
89  virtual ~cFilter();
90  virtual void SetStatus(bool On);
97  virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length) = 0;
108  int Source(void);
110  int Transponder(void);
112  const cChannel *Channel(void);
114  bool Matches(u_short Pid, u_char Tid);
116  void Set(u_short Pid, u_char Tid, u_char Mask = 0xFF);
118  void Add(u_short Pid, u_char Tid, u_char Mask = 0xFF, bool Sticky = false);
122  void Del(u_short Pid, u_char Tid, u_char Mask = 0xFF);
124  };
125 
126 #endif //__FILTER_H
cFilter::SetStatus
virtual void SetStatus(bool On)
Turns this filter on or off, depending on the value of On.
Definition: filter.c:178
cFilter
Definition: filter.h:80
cFilter::Transponder
int Transponder(void)
Returns the transponder of the data delivered to this filter.
Definition: filter.c:168
cSectionSyncer::complete
bool complete
Definition: filter.h:24
cFilter::Set
void Set(u_short Pid, u_char Tid, u_char Mask=0xFF)
Sets the given filter data by calling Add() with Sticky = true.
Definition: filter.c:211
cFilter::Process
virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length)=0
Processes the data delivered to this filter.
cSectionSyncer::GetSectionFlag
bool GetSectionFlag(uchar Section)
Definition: filter.h:28
cFilterData::cFilterData
cFilterData(void)
Definition: filter.c:107
cFilterData::Matches
bool Matches(u_short Pid, u_char Tid)
Definition: filter.c:137
cFilterData::operator=
cFilterData & operator=(const cFilterData &FilterData)
Definition: filter.c:123
cFilterData
Definition: filter.h:64
cSectionSyncer
Definition: filter.h:18
cFilter::Del
void Del(u_short Pid, u_char Tid, u_char Mask=0xFF)
Deletes the given filter data from this filter.
Definition: filter.c:224
cSectionHandler
Definition: sections.h:23
SI::u_char
unsigned char u_char
Definition: headers.h:24
cSectionSyncer::cSectionSyncer
cSectionSyncer(bool Random=false)
Sets up a new section syncer.
Definition: filter.c:15
cSectionSyncer::Repeat
void Repeat(void)
Definition: filter.c:77
cSectionSyncerRandom
Definition: filter.h:58
cListObject
Definition: tools.h:540
cFilterData::pid
u_short pid
Definition: filter.h:66
cFilter::~cFilter
virtual ~cFilter()
Definition: filter.c:157
uchar
unsigned char uchar
Definition: tools.h:31
cFilter::Channel
const cChannel * Channel(void)
Returns the channel of the data delivered to this filter.
Definition: filter.c:173
cSectionSyncer::Processed
bool Processed(int SectionNumber, int LastSectionNumber, int SegmentLastSectionNumber=-1)
Marks the given SectionNumber as processed.
Definition: filter.c:54
cSectionSyncer::SetSectionFlag
void SetSectionFlag(uchar Section, bool On)
Definition: filter.h:27
cList< cFilterData >
cSectionSyncer::sections
uchar sections[32]
Definition: filter.h:26
cSectionSyncer::Reset
void Reset(void)
Definition: filter.c:21
cSectionSyncer::segments
uint32_t segments
Definition: filter.h:25
cFilter::Add
void Add(u_short Pid, u_char Tid, u_char Mask=0xFF, bool Sticky=false)
Adds the given filter data to this filter.
Definition: filter.c:216
cChannel
Definition: channels.h:87
cFilterData::mask
u_char mask
Definition: filter.h:68
cSectionSyncer::currentSection
int currentSection
Definition: filter.h:21
cSectionSyncer::synced
bool synced
Definition: filter.h:23
cSectionSyncer::currentVersion
int currentVersion
Definition: filter.h:20
cSectionSyncer::Sync
bool Sync(uchar Version, int Number, int LastNumber)
Definition: filter.c:84
cFilterData::tid
u_char tid
Definition: filter.h:67
cSectionSyncer::Check
bool Check(uchar Version, int SectionNumber)
Returns true if Version is not the current version, or the given SectionNumber has not been marked as...
Definition: filter.c:31
cFilterData::Is
bool Is(u_short Pid, u_char Tid, u_char Mask)
Definition: filter.c:132
cFilter::on
bool on
Definition: filter.h:85
cFilter::cFilter
cFilter(void)
Definition: filter.c:144
cFilter::Source
int Source(void)
Returns the source of the data delivered to this filter.
Definition: filter.c:163
tools.h
cSectionSyncer::Complete
bool Complete(void)
Returns true if all sections have been processed.
Definition: filter.h:50
cFilter::sectionHandler
cSectionHandler * sectionHandler
Definition: filter.h:83
cSectionSyncer::random
bool random
Definition: filter.h:22
cFilter::Matches
bool Matches(u_short Pid, u_char Tid)
Indicates whether this filter wants to receive data from the given Pid/Tid.
Definition: filter.c:200
cFilter::data
cList< cFilterData > data
Definition: filter.h:84
cFilterData::sticky
bool sticky
Definition: filter.h:69
cSectionSyncerRandom::cSectionSyncerRandom
cSectionSyncerRandom(void)
< Helper class for having an array of random section syncers.
Definition: filter.h:61