vdr/eitscan.c
Klaus Schmidinger a616d4b859 Version 1.3.26
- Updated the Estonian OSD texts (thanks to Arthur Konovalov).
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg).
- Fixed handling 'summary.vdr' files with more than two empty lines (thanks to
  Christian Jacobsen for reporting this one).
- Improved resetting CAM connections (thanks to Marco Schlüßler).
- Implemented cVideoRepacker in remux.c to make sure every PES packet contains
  only data from one frame (thanks to Reinhard Nissl).
  NOTE: currently this doesn't work with MPEG1, so if you use MPEG1 you may want
  to change line 1158 in remux.c to

  ts2pes[numTracks++] = new cTS2PES(VPid, resultBuffer, IPACKS);

  as it was before.
- EPG events without a title now display "No title" instead of "(null)" (thanks
  to Rolf Ahrenberg).
- A device can now detach all receivers for a given PID, as is necessary, e.g.,
  for the bitstreamout plugin (thanks to Werner Fink).
- Added the year (two digits) to recording dates in LSTR, and thus also in menus
  (suggested by Jan Ekholm).
- Fixed the call to Channels.Unlock() in cEITScanner::Process() (thanks to
  Reinhard Nissl).
- Fixed handling timers with a day given as MTWTF--@6, i.e. a repeating timer with
  first day not as full date, but just day of month (thanks to Henrik Niehaus for
  reporting this one).
- Removed an unnecessary #include from osd.c (thanks to Wolfgang Rohdewald).
- Fixed dropping EPG events that have a zero start time or duration, in case it's
  an NVOD event (thanks to Chris Warren).
- Fixed handling page up/down in menu lists in case there are several non selectable
  items in a row (thanks to Udo Richter for reporting this one).
- Added cOsdMenu::SetCols() to allow adjusting the menu columns.
- Modified cEITScanner::Process() so that it works on systems with only budget cards
  or a mix of DVB-S, DVB-C or DVB-T cards.
2005-06-12 18:00:00 +02:00

187 lines
5.9 KiB
C

/*
* eitscan.c: EIT scanner
*
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: eitscan.c 1.26 2005/06/12 14:09:45 kls Exp $
*/
#include "eitscan.h"
#include <stdlib.h>
#include "channels.h"
#include "dvbdevice.h"
#include "skins.h"
#include "transfer.h"
// --- cScanData -------------------------------------------------------------
class cScanData : public cListObject {
private:
cChannel channel;
public:
cScanData(const cChannel *Channel);
virtual int Compare(const cListObject &ListObject) const;
int Source(void) const { return channel.Source(); }
int Transponder(void) const { return channel.Transponder(); }
const cChannel *GetChannel(void) const { return &channel; }
};
cScanData::cScanData(const cChannel *Channel)
{
channel = *Channel;
}
int cScanData::Compare(const cListObject &ListObject) const
{
const cScanData *sd = (const cScanData *)&ListObject;
int r = Source() - sd->Source();
if (r == 0)
r = Transponder() - sd->Transponder();
return r;
}
// --- cScanList -------------------------------------------------------------
class cScanList : public cList<cScanData> {
public:
void AddTransponders(cList<cChannel> *Channels);
void AddTransponder(const cChannel *Channel);
};
void cScanList::AddTransponders(cList<cChannel> *Channels)
{
for (cChannel *ch = Channels->First(); ch; ch = Channels->Next(ch))
AddTransponder(ch);
Sort();
}
void cScanList::AddTransponder(const cChannel *Channel)
{
if (Channel->Source() && Channel->Transponder()) {
for (cScanData *sd = First(); sd; sd = Next(sd)) {
if (sd->Source() == Channel->Source() && ISTRANSPONDER(sd->Transponder(), Channel->Transponder()))
return;
}
Add(new cScanData(Channel));
}
}
// --- cTransponderList ------------------------------------------------------
class cTransponderList : public cList<cChannel> {
public:
void AddTransponder(cChannel *Channel);
};
void cTransponderList::AddTransponder(cChannel *Channel)
{
for (cChannel *ch = First(); ch; ch = Next(ch)) {
if (ch->Source() == Channel->Source() && ch->Transponder() == Channel->Transponder()) {
delete Channel;
return;
}
}
Add(Channel);
}
// --- cEITScanner -----------------------------------------------------------
cEITScanner EITScanner;
cEITScanner::cEITScanner(void)
{
lastScan = lastActivity = time(NULL);
currentDevice = NULL;
currentChannel = 0;
scanList = NULL;
transponderList = NULL;
}
cEITScanner::~cEITScanner()
{
delete scanList;
delete transponderList;
}
void cEITScanner::AddTransponder(cChannel *Channel)
{
if (!transponderList)
transponderList = new cTransponderList;
transponderList->AddTransponder(Channel);
}
void cEITScanner::ForceScan(void)
{
lastActivity = 0;
}
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) {
if (Channels.Lock(false, 10)) {
if (!scanList) {
scanList = new cScanList;
scanList->AddTransponders(&Channels);
if (transponderList) {
scanList->AddTransponders(transponderList);
delete transponderList;
transponderList = NULL;
}
}
bool AnyDeviceSwitched = false;
for (int i = 0; i < cDevice::NumDevices(); i++) {
cDevice *Device = cDevice::GetDevice(i);
if (Device) {
for (cScanData *ScanData = scanList->First(); ScanData; ScanData = scanList->Next(ScanData)) {
const cChannel *Channel = ScanData->GetChannel();
if (Channel) {
if (!Channel->Ca() || Channel->Ca() == Device->DeviceNumber() + 1 || Channel->Ca() >= 0x0100) {
if (Device->ProvidesTransponder(Channel)) {
if (!Device->Receiving()) {
if (Device != cDevice::ActualDevice() || (Device->ProvidesTransponderExclusively(Channel) && Setup.EPGScanTimeout && now - lastActivity > Setup.EPGScanTimeout * 3600)) {
if (Device == cDevice::ActualDevice() && !currentChannel) {
if (cTransferControl::ReceiverDevice())
cDevice::PrimaryDevice()->StopReplay(); // stop transfer mode
currentChannel = Device->CurrentChannel();
Skins.Message(mtInfo, tr("Starting EPG scan"));
}
currentDevice = Device;//XXX see also dvbdevice.c!!!
//dsyslog("EIT scan: device %d source %-8s tp %5d", Device->DeviceNumber() + 1, *cSource::ToString(Channel->Source()), Channel->Transponder());
Device->SwitchChannel(Channel, false);
currentDevice = NULL;
scanList->Del(ScanData);
AnyDeviceSwitched = true;
break;
}
}
}
}
}
}
}
}
if (!scanList->Count() || !AnyDeviceSwitched) {
delete scanList;
scanList = NULL;
if (lastActivity == 0) // this was a triggered scan
Activity();
}
Channels.Unlock();
}
lastScan = time(NULL);
}
}
}