vdr  2.6.9
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
cFilterData & operator=(const cFilterData &FilterData)
Definition: filter.c:123
bool Matches(u_short Pid, u_char Tid)
Definition: filter.c:137
bool Is(u_short Pid, u_char Tid, u_char Mask)
Definition: filter.c:132
u_short pid
Definition: filter.h:66
bool sticky
Definition: filter.h:69
u_char tid
Definition: filter.h:67
cFilterData(void)
Definition: filter.c:107
u_char mask
Definition: filter.h:68
Definition: filter.h:80
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
virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length)=0
Processes the data delivered to this filter.
cSectionHandler * sectionHandler
Definition: filter.h:83
int Transponder(void)
Returns the transponder of the data delivered to this filter.
Definition: filter.c:168
virtual void SetStatus(bool On)
Turns this filter on or off, depending on the value of On.
Definition: filter.c:178
int Source(void)
Returns the source of the data delivered to this filter.
Definition: filter.c:163
const cChannel * Channel(void)
Returns the channel of the data delivered to this filter.
Definition: filter.c:173
bool on
Definition: filter.h:85
cList< cFilterData > data
Definition: filter.h:84
void Del(u_short Pid, u_char Tid, u_char Mask=0xFF)
Deletes the given filter data from this filter.
Definition: filter.c:224
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
virtual ~cFilter()
Definition: filter.c:157
cFilter(void)
Definition: filter.c:144
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
cSectionSyncerRandom(void)
< Helper class for having an array of random section syncers.
Definition: filter.h:61
void SetSectionFlag(uchar Section, bool On)
Definition: filter.h:27
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
int currentSection
Definition: filter.h:21
cSectionSyncer(bool Random=false)
Sets up a new section syncer.
Definition: filter.c:15
int currentVersion
Definition: filter.h:20
bool complete
Definition: filter.h:24
bool Processed(int SectionNumber, int LastSectionNumber, int SegmentLastSectionNumber=-1)
Marks the given SectionNumber as processed.
Definition: filter.c:54
bool Sync(uchar Version, int Number, int LastNumber)
Definition: filter.c:84
bool Complete(void)
Returns true if all sections have been processed.
Definition: filter.h:50
uchar sections[32]
Definition: filter.h:26
void Repeat(void)
Definition: filter.c:77
uint32_t segments
Definition: filter.h:25
void Reset(void)
Definition: filter.c:21
bool random
Definition: filter.h:22
bool GetSectionFlag(uchar Section)
Definition: filter.h:28
bool synced
Definition: filter.h:23
unsigned char u_char
Definition: headers.h:24
unsigned char uchar
Definition: tools.h:31