Home

Dokumentation

Impressum

Dokumentation VDR
 

Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

eitscan.c

Go to the documentation of this file.
00001 /*
00002  * eitscan.c: EIT scanner
00003  *
00004  * See the main source file 'vdr.c' for copyright information and
00005  * how to reach the author.
00006  *
00007  * $Id: eitscan.c 1.10 2002/11/01 11:04:49 kls Exp $
00008  */
00009 
00010 #include "eitscan.h"
00011 #include <stdlib.h>
00012 #include "channels.h"
00013 #include "dvbdevice.h"
00014 
00015 cEITScanner::cEITScanner(void)
00016 {
00017   lastScan = lastActivity = time(NULL);
00018   currentChannel = 0;
00019   lastChannel = 0;
00020   numTransponders = 0;
00021   transponders = NULL;
00022 }
00023 
00024 cEITScanner::~cEITScanner()
00025 {
00026   free(transponders);
00027 }
00028 
00029 bool cEITScanner::TransponderScanned(cChannel *Channel)
00030 {
00031   for (int i = 0; i < numTransponders; i++) {
00032       if (transponders[i] == Channel->Frequency())
00033          return true;
00034       }
00035   transponders = (int *)realloc(transponders, ++numTransponders * sizeof(int));
00036   transponders[numTransponders - 1] = Channel->Frequency();
00037   return false;
00038 }
00039 
00040 void cEITScanner::Activity(void)
00041 {
00042   if (currentChannel) {
00043      Channels.SwitchTo(currentChannel);
00044      currentChannel = 0;
00045      }
00046   lastActivity = time(NULL);
00047 }
00048 
00049 void cEITScanner::Process(void)
00050 {
00051   if (Setup.EPGScanTimeout && Channels.MaxNumber() > 1) {
00052      time_t now = time(NULL);
00053      if (now - lastScan > ScanTimeout && now - lastActivity > ActivityTimeout) {
00054         for (int i = 0; i < cDevice::NumDevices(); i++) {
00055             cDevice *Device = cDevice::GetDevice(i);
00056             if (Device && Device->CardIndex() < MAXDVBDEVICES) {
00057                if (Device != cDevice::PrimaryDevice() || (cDevice::NumDevices() == 1 && Setup.EPGScanTimeout && now - lastActivity > Setup.EPGScanTimeout * 3600)) {
00058                   if (!(Device->Receiving(true) || Device->Replaying())) {
00059                      int oldCh = lastChannel;
00060                      int ch = oldCh + 1;
00061                      while (ch != oldCh) {
00062                            if (ch > Channels.MaxNumber()) {
00063                               ch = 1;
00064                               numTransponders = 0;
00065                               }
00066                            cChannel *Channel = Channels.GetByNumber(ch, 1);
00067                            if (Channel) {
00068                               if (!Device->ProvidesChannel(Channel))
00069                                  break;
00070                               if (Channel->Sid() && !TransponderScanned(Channel)) {
00071                                  if (Device == cDevice::PrimaryDevice() && !currentChannel)
00072                                     currentChannel = Device->CurrentChannel();
00073                                  Device->SwitchChannel(Channel, false);
00074                                  lastChannel = ch;
00075                                  break;
00076                                  }
00077                               }
00078                            ch = Channel->Number() + 1;
00079                            }
00080                      }
00081                   }
00082                }
00083             else
00084                lastChannel++; // avoid hangup in case the last channel in the list is not provided by a DVB card
00085             }
00086         lastScan = time(NULL);
00087         }
00088      }
00089 }

Generated on Wed Feb 5 23:30:08 2003 for VDR by doxygen1.3-rc2