vdr  2.7.6
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.6 2025/03/02 11:03:35 kls Exp $
8  */
9 
10 #ifndef __FILTER_H
11 #define __FILTER_H
12 
13 #include <sys/types.h>
14 #include "tools.h"
15 
17 private:
20  bool random;
21  bool synced;
22  bool complete;
23  uint32_t segments; // bit flags for the 32 segments
24  uchar sections[32]; // holds 32 * 8 = 256 bits, as flags for the sections
25  void SetSectionFlag(uchar Section, bool On) { if (On) sections[Section / 8] |= (1 << (Section % 8)); else sections[Section / 8] &= ~(1 << (Section % 8)); }
26  bool GetSectionFlag(uchar Section) { return sections[Section / 8] & (1 << (Section % 8)); }
27 public:
28  cSectionSyncer(bool Random = false);
37  void Reset(void);
38  bool Check(uchar Version, int SectionNumber);
42  bool Processed(int SectionNumber, int LastSectionNumber, int SegmentLastSectionNumber = -1);
48  bool Complete(void) { return complete; }
50  };
51 
54 public:
56  };
57 
58 class cFilterData : public cListObject {
59 public:
60  u_short pid;
63  bool sticky;
64  cFilterData(void);
65  cFilterData(u_short Pid, u_char Tid, u_char Mask, bool Sticky);
66  cFilterData& operator= (const cFilterData &FilterData);
67  bool Is(u_short Pid, u_char Tid, u_char Mask);
68  bool Matches(u_short Pid, u_char Tid);
69  };
70 
71 class cChannel;
72 class cSectionHandler;
73 
74 class cFilter : public cListObject {
75  friend class cSectionHandler;
76 private:
79  bool on;
80 protected:
81  cFilter(void);
82  cFilter(u_short Pid, u_char Tid, u_char Mask = 0xFF);
83  virtual ~cFilter() override;
84  virtual void SetStatus(bool On);
91  virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length) = 0;
102  int Source(void);
104  int Transponder(void);
106  const cChannel *Channel(void);
108  bool Matches(u_short Pid, u_char Tid);
110  void Set(u_short Pid, u_char Tid, u_char Mask = 0xFF);
112  void Add(u_short Pid, u_char Tid, u_char Mask = 0xFF, bool Sticky = false);
116  void Del(u_short Pid, u_char Tid, u_char Mask = 0xFF);
118  };
119 
120 #endif //__FILTER_H
cFilterData & operator=(const cFilterData &FilterData)
Definition: filter.c:94
bool Matches(u_short Pid, u_char Tid)
Definition: filter.c:108
bool Is(u_short Pid, u_char Tid, u_char Mask)
Definition: filter.c:103
u_short pid
Definition: filter.h:60
bool sticky
Definition: filter.h:63
u_char tid
Definition: filter.h:61
cFilterData(void)
Definition: filter.c:78
u_char mask
Definition: filter.h:62
Definition: filter.h:74
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:182
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:77
int Transponder(void)
Returns the transponder of the data delivered to this filter.
Definition: filter.c:139
virtual void SetStatus(bool On)
Turns this filter on or off, depending on the value of On.
Definition: filter.c:149
int Source(void)
Returns the source of the data delivered to this filter.
Definition: filter.c:134
const cChannel * Channel(void)
Returns the channel of the data delivered to this filter.
Definition: filter.c:144
bool on
Definition: filter.h:79
cList< cFilterData > data
Definition: filter.h:78
void Del(u_short Pid, u_char Tid, u_char Mask=0xFF)
Deletes the given filter data from this filter.
Definition: filter.c:195
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:187
cFilter(void)
Definition: filter.c:115
virtual ~cFilter() override
Definition: filter.c:128
bool Matches(u_short Pid, u_char Tid)
Indicates whether this filter wants to receive data from the given Pid/Tid.
Definition: filter.c:171
cSectionSyncerRandom(void)
< Helper class for having an array of random section syncers.
Definition: filter.h:55
void SetSectionFlag(uchar Section, bool On)
Definition: filter.h:25
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:19
cSectionSyncer(bool Random=false)
Sets up a new section syncer.
Definition: filter.c:15
int currentVersion
Definition: filter.h:18
bool complete
Definition: filter.h:22
bool Processed(int SectionNumber, int LastSectionNumber, int SegmentLastSectionNumber=-1)
Marks the given SectionNumber as processed.
Definition: filter.c:54
bool Complete(void)
Returns true if all sections have been processed.
Definition: filter.h:48
uchar sections[32]
Definition: filter.h:24
uint32_t segments
Definition: filter.h:23
void Reset(void)
Definition: filter.c:21
bool random
Definition: filter.h:20
bool GetSectionFlag(uchar Section)
Definition: filter.h:26
bool synced
Definition: filter.h:21
unsigned char u_char
Definition: headers.h:24
unsigned char uchar
Definition: tools.h:31