vdr 2.6.1
include/vdr/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
18class cSectionSyncer {
19private:
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)); }
29public:
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
60public:
62 };
63
64class cFilterData : public cListObject {
65public:
66 u_short pid;
67 u_char tid;
69 bool sticky;
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
77class cChannel;
78class cSectionHandler;
79
80class cFilter : public cListObject {
81 friend class cSectionHandler;
82private:
85 bool on;
86protected:
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)
bool Is(u_short Pid, u_char Tid, u_char Mask)
u_short pid
Definition: filter.h:66
bool sticky
Definition: filter.h:69
cFilterData(u_short Pid, u_char Tid, u_char Mask, bool Sticky)
u_char tid
Definition: filter.h:67
cFilterData(void)
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.
virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length)=0
Processes the data delivered to this filter.
int Transponder(void)
Returns the transponder of the data delivered to this filter.
int Source(void)
Returns the source of the data delivered to this filter.
cSectionHandler * sectionHandler
Definition: filter.h:83
const cChannel * Channel(void)
Returns the channel of the data delivered to this filter.
bool on
Definition: filter.h:85
cFilter(u_short Pid, u_char Tid, u_char Mask=0xFF)
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.
void Add(u_short Pid, u_char Tid, u_char Mask=0xFF, bool Sticky=false)
Adds the given filter data to this filter.
cFilter(void)
virtual void SetStatus(bool On)
Turns this filter on or off, depending on the value of On.
bool Matches(u_short Pid, u_char Tid)
Indicates whether this filter wants to receive data from the given Pid/Tid.
virtual ~cFilter()
cSectionSyncerRandom(void)
< Helper class for having an array of random section syncers.
void SetSectionFlag(uchar Section, bool On)
bool Check(uchar Version, int SectionNumber)
Returns true if Version is not the current version, or the given SectionNumber has not been marked as...
int currentSection
Definition: filter.h:21
cSectionSyncer(bool Random=false)
Sets up a new section syncer.
int currentVersion
Definition: filter.h:20
uchar sections[32]
Definition: filter.h:26
bool complete
Definition: filter.h:24
bool Processed(int SectionNumber, int LastSectionNumber, int SegmentLastSectionNumber=-1)
Marks the given SectionNumber as processed.
bool Sync(uchar Version, int Number, int LastNumber)
bool Complete(void)
Returns true if all sections have been processed.
void Repeat(void)
uint32_t segments
Definition: filter.h:25
void Reset(void)
bool random
Definition: filter.h:22
bool GetSectionFlag(uchar Section)
bool synced
Definition: filter.h:23
unsigned char uchar
unsigned char u_char