2002-05-20 11:18:09 +02:00
|
|
|
/*
|
|
|
|
* eitscan.c: EIT scanner
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2003-05-24 13:38:28 +02:00
|
|
|
* $Id: eitscan.c 1.13 2003/05/24 13:34:59 kls Exp $
|
2002-05-20 11:18:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "eitscan.h"
|
2002-08-04 14:57:29 +02:00
|
|
|
#include <stdlib.h>
|
2002-10-06 10:25:42 +02:00
|
|
|
#include "channels.h"
|
2002-09-04 17:26:02 +02:00
|
|
|
#include "dvbdevice.h"
|
2002-05-20 11:18:09 +02:00
|
|
|
|
2003-05-24 13:38:28 +02:00
|
|
|
cEITScanner EITScanner;
|
|
|
|
|
2002-05-20 11:18:09 +02:00
|
|
|
cEITScanner::cEITScanner(void)
|
|
|
|
{
|
|
|
|
lastScan = lastActivity = time(NULL);
|
|
|
|
currentChannel = 0;
|
2003-03-16 13:29:55 +01:00
|
|
|
memset(lastChannel, 0, sizeof(lastChannel));
|
2002-05-20 11:18:09 +02:00
|
|
|
numTransponders = 0;
|
|
|
|
transponders = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cEITScanner::~cEITScanner()
|
|
|
|
{
|
2002-08-11 13:32:23 +02:00
|
|
|
free(transponders);
|
2002-05-20 11:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cEITScanner::TransponderScanned(cChannel *Channel)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < numTransponders; i++) {
|
2002-10-06 10:25:42 +02:00
|
|
|
if (transponders[i] == Channel->Frequency())
|
2002-05-20 11:18:09 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
transponders = (int *)realloc(transponders, ++numTransponders * sizeof(int));
|
2002-10-06 10:25:42 +02:00
|
|
|
transponders[numTransponders - 1] = Channel->Frequency();
|
2002-05-20 11:18:09 +02:00
|
|
|
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) {
|
2003-03-16 13:29:55 +01:00
|
|
|
for (int i = 0; i < cDevice::NumDevices(); i++) {
|
|
|
|
cDevice *Device = cDevice::GetDevice(i);
|
|
|
|
if (Device && Device->CardIndex() < MAXDVBDEVICES) {
|
|
|
|
if (Device != cDevice::PrimaryDevice() || (cDevice::NumDevices() == 1 && Setup.EPGScanTimeout && now - lastActivity > Setup.EPGScanTimeout * 3600)) {
|
|
|
|
if (!(Device->Receiving(true) || Device->Replaying())) {
|
|
|
|
for (;;) {
|
|
|
|
cChannel *Channel = Channels.GetByNumber(lastChannel[Device->DeviceNumber()] + 1, 1);
|
|
|
|
if (Channel) {
|
|
|
|
lastChannel[Device->DeviceNumber()] = Channel->Number();
|
|
|
|
if (Channel->Sid() && Device->ProvidesChannel(Channel) && !TransponderScanned(Channel)) {
|
2003-05-24 13:38:28 +02:00
|
|
|
if (Device == cDevice::PrimaryDevice() && !currentChannel) {
|
2003-03-16 13:29:55 +01:00
|
|
|
currentChannel = Device->CurrentChannel();
|
2003-05-24 13:38:28 +02:00
|
|
|
}
|
2003-03-16 13:29:55 +01:00
|
|
|
Device->SwitchChannel(Channel, false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (lastChannel[Device->DeviceNumber()])
|
|
|
|
numTransponders = 0;
|
|
|
|
lastChannel[Device->DeviceNumber()] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-05-20 11:18:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-03-16 13:29:55 +01:00
|
|
|
}
|
2002-05-20 11:18:09 +02:00
|
|
|
lastScan = time(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|