summaryrefslogtreecommitdiff
path: root/filter.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2003-12-22 13:29:24 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2003-12-22 13:29:24 +0100
commit7ff59171e3f907a5584b72f0f8588ed65f22c0bd (patch)
tree801b1b65840c50a4f1d8abea806fa5c180051df1 /filter.c
parent84b99ea81095f421ec049dd6b5bd5f0f2fe679c1 (diff)
downloadvdr-7ff59171e3f907a5584b72f0f8588ed65f22c0bd.tar.gz
vdr-7ff59171e3f907a5584b72f0f8588ed65f22c0bd.tar.bz2
Changed section handling; replaced 'libdtv' with 'libsi'
Diffstat (limited to 'filter.c')
-rw-r--r--filter.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/filter.c b/filter.c
new file mode 100644
index 00000000..668b7d3a
--- /dev/null
+++ b/filter.c
@@ -0,0 +1,126 @@
+/*
+ * filter.c: Section filter
+ *
+ * See the main source file 'vdr.c' for copyright information and
+ * how to reach the author.
+ *
+ * $Id: filter.c 1.1 2003/12/21 15:26:16 kls Exp $
+ */
+
+#include "filter.h"
+#include "sections.h"
+
+// --- cFilterData -----------------------------------------------------------
+
+cFilterData::cFilterData(void)
+{
+ pid = 0;
+ tid = 0;
+ mask = 0;
+ sticky = false;
+}
+
+cFilterData::cFilterData(u_short Pid, u_char Tid, u_char Mask, bool Sticky)
+{
+ pid = Pid;
+ tid = Tid;
+ mask = Mask;
+ sticky = Sticky;
+}
+
+bool cFilterData::Is(u_short Pid, u_char Tid, u_char Mask)
+{
+ return pid == Pid && tid == Tid && mask == Mask;
+}
+
+bool cFilterData::Matches(u_short Pid, u_char Tid)
+{
+ return pid == Pid && tid == (Tid & mask);
+}
+
+// --- cFilter ---------------------------------------------------------------
+
+cFilter::cFilter(void)
+{
+ sectionHandler = NULL;
+ on = false;
+}
+
+cFilter::cFilter(u_short Pid, u_char Tid, u_char Mask)
+{
+ sectionHandler = NULL;
+ on = false;
+ Set(Pid, Tid, Mask);
+}
+
+cFilter::~cFilter()
+{
+ if (sectionHandler)
+ sectionHandler->Detach(this);
+}
+
+int cFilter::Source(void)
+{
+ return sectionHandler ? sectionHandler->Source() : 0;
+}
+
+int cFilter::Transponder(void)
+{
+ return sectionHandler ? sectionHandler->Transponder() : 0;
+}
+
+void cFilter::SetStatus(bool On)
+{
+ if (sectionHandler && on != On) {
+ cFilterData *fd = data.First();
+ while (fd) {
+ if (On)
+ sectionHandler->Add(fd);
+ else {
+ sectionHandler->Del(fd);
+ if (!fd->sticky) {
+ cFilterData *next = data.Next(fd);
+ data.Del(fd);
+ fd = next;
+ continue;
+ }
+ }
+ fd = data.Next(fd);
+ }
+ on = On;
+ }
+}
+
+bool cFilter::Matches(u_short Pid, u_char Tid)
+{
+ for (cFilterData *fd = data.First(); fd; fd = data.Next(fd)) {
+ if (fd->Matches(Pid, Tid))
+ return true;
+ }
+ return false;
+}
+
+void cFilter::Set(u_short Pid, u_char Tid, u_char Mask)
+{
+ Add(Pid, Tid, Mask, true);
+}
+
+void cFilter::Add(u_short Pid, u_char Tid, u_char Mask, bool Sticky)
+{
+ cFilterData *fd = new cFilterData(Pid, Tid, Mask, Sticky);
+ data.Add(fd);
+ if (sectionHandler && on)
+ sectionHandler->Add(fd);
+}
+
+void cFilter::Del(u_short Pid, u_char Tid, u_char Mask)
+{
+ for (cFilterData *fd = data.First(); fd; fd = data.Next(fd)) {
+ if (fd->Is(Pid, Tid, Mask)) {
+ if (sectionHandler && on)
+ sectionHandler->Del(fd);
+ data.Del(fd);
+ return;
+ }
+ }
+}