2002-06-16 12:57:31 +02:00
|
|
|
/*
|
|
|
|
* receiver.c: The basic receiver interface
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2010-01-30 11:10:25 +01:00
|
|
|
* $Id: receiver.c 2.2 2010/01/30 10:25:38 kls Exp $
|
2002-06-16 12:57:31 +02:00
|
|
|
*/
|
|
|
|
|
2006-03-26 14:12:08 +02:00
|
|
|
#include "receiver.h"
|
2002-06-16 12:57:31 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
2002-08-04 14:57:29 +02:00
|
|
|
#include "tools.h"
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2010-01-30 11:10:25 +01:00
|
|
|
#ifdef LEGACY_CRECEIVER
|
2007-01-07 14:46:14 +01:00
|
|
|
cReceiver::cReceiver(tChannelID ChannelID, int Priority, int Pid, const int *Pids1, const int *Pids2, const int *Pids3)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
|
|
|
device = NULL;
|
2007-01-07 14:46:14 +01:00
|
|
|
channelID = ChannelID;
|
2002-06-16 12:57:31 +02:00
|
|
|
priority = Priority;
|
2005-01-16 14:40:47 +01:00
|
|
|
numPids = 0;
|
2010-01-30 11:10:25 +01:00
|
|
|
AddPid(Pid);
|
|
|
|
AddPids(Pids1);
|
|
|
|
AddPids(Pids2);
|
|
|
|
AddPids(Pids3);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cReceiver::cReceiver(const cChannel *Channel, int Priority)
|
|
|
|
{
|
|
|
|
device = NULL;
|
|
|
|
priority = Priority;
|
|
|
|
numPids = 0;
|
|
|
|
SetPids(Channel);
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cReceiver::~cReceiver()
|
|
|
|
{
|
2007-08-12 12:30:00 +02:00
|
|
|
if (device) {
|
|
|
|
const char *msg = "ERROR: cReceiver has not been detached yet! This is a design fault and VDR will segfault now!";
|
2010-01-01 15:44:52 +01:00
|
|
|
esyslog("%s", msg);
|
2007-08-12 12:30:00 +02:00
|
|
|
fprintf(stderr, "%s\n", msg);
|
|
|
|
*(char *)0 = 0; // cause a segfault
|
|
|
|
}
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
2010-01-30 11:10:25 +01:00
|
|
|
bool cReceiver::AddPid(int Pid)
|
|
|
|
{
|
|
|
|
if (Pid) {
|
|
|
|
if (numPids < MAXRECEIVEPIDS)
|
|
|
|
pids[numPids++] = Pid;
|
|
|
|
else {
|
|
|
|
dsyslog("too many PIDs in cReceiver (Pid = %d)", Pid);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cReceiver::AddPids(const int *Pids)
|
|
|
|
{
|
|
|
|
if (Pids) {
|
|
|
|
while (*Pids) {
|
|
|
|
if (!AddPid(*Pids++))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cReceiver::AddPids(int Pid1, int Pid2, int Pid3, int Pid4, int Pid5, int Pid6, int Pid7, int Pid8, int Pid9)
|
|
|
|
{
|
|
|
|
return AddPid(Pid1) && AddPid(Pid2) && AddPid(Pid3) && AddPid(Pid4) && AddPid(Pid5) && AddPid(Pid6) && AddPid(Pid7) && AddPid(Pid8) && AddPid(Pid9);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cReceiver::SetPids(const cChannel *Channel)
|
|
|
|
{
|
|
|
|
numPids = 0;
|
|
|
|
if (Channel) {
|
|
|
|
channelID = Channel->GetChannelID();
|
|
|
|
return AddPid(Channel->Vpid()) &&
|
|
|
|
(Channel->Ppid() == Channel->Vpid() || AddPid(Channel->Ppid())) &&
|
|
|
|
AddPids(Channel->Apids()) &&
|
|
|
|
(!Setup.UseDolbyDigital || AddPids(Channel->Dpids())) &&
|
|
|
|
AddPids(Channel->Spids());
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
bool cReceiver::WantsPid(int Pid)
|
|
|
|
{
|
|
|
|
if (Pid) {
|
2005-01-16 14:40:47 +01:00
|
|
|
for (int i = 0; i < numPids; i++) {
|
2002-06-16 12:57:31 +02:00
|
|
|
if (pids[i] == Pid)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cReceiver::Detach(void)
|
|
|
|
{
|
|
|
|
if (device)
|
|
|
|
device->Detach(this);
|
|
|
|
}
|