summaryrefslogtreecommitdiff
path: root/eitscan.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-05-20 11:18:09 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2002-05-20 11:18:09 +0200
commit0161197360fb2090dd189daa672871695bc2fef2 (patch)
treeef4c8d1da99e0a896886f28c93e70d0756f53a95 /eitscan.c
parent9f9d6a8a9354960eb9c42f9c45ed507f05804ff4 (diff)
downloadvdr-0161197360fb2090dd189daa672871695bc2fef2.tar.gz
vdr-0161197360fb2090dd189daa672871695bc2fef2.tar.bz2
Moved the cEITScanner out of dvbapi.h/.c, into the new eitscan.h/.c
Diffstat (limited to 'eitscan.c')
-rw-r--r--eitscan.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/eitscan.c b/eitscan.c
new file mode 100644
index 00000000..88271822
--- /dev/null
+++ b/eitscan.c
@@ -0,0 +1,84 @@
+/*
+ * eitscan.c: EIT scanner
+ *
+ * See the main source file 'vdr.c' for copyright information and
+ * how to reach the author.
+ *
+ * $Id: eitscan.c 1.1 2002/05/20 10:58:10 kls Exp $
+ */
+
+#include "eitscan.h"
+
+cEITScanner::cEITScanner(void)
+{
+ lastScan = lastActivity = time(NULL);
+ currentChannel = 0;
+ lastChannel = 0;
+ numTransponders = 0;
+ transponders = NULL;
+}
+
+cEITScanner::~cEITScanner()
+{
+ delete transponders;
+}
+
+bool cEITScanner::TransponderScanned(cChannel *Channel)
+{
+ for (int i = 0; i < numTransponders; i++) {
+ if (transponders[i] == Channel->frequency)
+ return true;
+ }
+ transponders = (int *)realloc(transponders, ++numTransponders * sizeof(int));
+ transponders[numTransponders - 1] = Channel->frequency;
+ return false;
+}
+
+void cEITScanner::Activity(void)
+{
+ if (currentChannel) {
+ Channels.SwitchTo(currentChannel);
+ currentChannel = 0;
+ }
+ lastActivity = time(NULL);
+}
+
+void cEITScanner::Process(void)
+{
+ if (Setup.EPGScanTimeout && Channels.MaxNumber() > 1) {
+ time_t now = time(NULL);
+ if (now - lastScan > ScanTimeout && now - lastActivity > ActivityTimeout) {
+ for (int i = 0; i < MAXDVBAPI; i++) {
+ cDvbApi *DvbApi = cDvbApi::GetDvbApi(i + 1, MAXPRIORITY + 1);
+ if (DvbApi) {
+ if (DvbApi != cDvbApi::PrimaryDvbApi || (cDvbApi::NumDvbApis == 1 && Setup.EPGScanTimeout && now - lastActivity > Setup.EPGScanTimeout * 3600)) {
+ if (!(DvbApi->Recording() || DvbApi->Replaying() || DvbApi->Transferring())) {
+ int oldCh = lastChannel;
+ int ch = oldCh + 1;
+ while (ch != oldCh) {
+ if (ch > Channels.MaxNumber()) {
+ ch = 1;
+ numTransponders = 0;
+ }
+ cChannel *Channel = Channels.GetByNumber(ch);
+ if (Channel) {
+ if (Channel->ca <= MAXDVBAPI && !DvbApi->ProvidesCa(Channel->ca))
+ break; // the channel says it explicitly needs a different card
+ if (Channel->pnr && !TransponderScanned(Channel)) {
+ if (DvbApi == cDvbApi::PrimaryDvbApi && !currentChannel)
+ currentChannel = DvbApi->Channel();
+ Channel->Switch(DvbApi, false);
+ lastChannel = ch;
+ break;
+ }
+ }
+ ch++;
+ }
+ }
+ }
+ }
+ }
+ lastScan = time(NULL);
+ }
+ }
+}