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.
|
|
|
|
*
|
2014-02-08 16:00:13 +01:00
|
|
|
* $Id: receiver.c 3.2 2014/02/08 15:57:30 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 <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
|
|
|
cReceiver::cReceiver(const cChannel *Channel, int Priority)
|
|
|
|
{
|
|
|
|
device = NULL;
|
2012-03-02 10:19:00 +01:00
|
|
|
priority = constrain(Priority, MINPRIORITY, MAXPRIORITY);
|
2010-01-30 11:10:25 +01:00
|
|
|
numPids = 0;
|
|
|
|
SetPids(Channel);
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cReceiver::~cReceiver()
|
|
|
|
{
|
2007-08-12 12:30:00 +02:00
|
|
|
if (device) {
|
2014-02-08 16:00:13 +01:00
|
|
|
const char *msg = "ERROR: cReceiver has not been detached yet! This is a design fault and VDR will abort 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);
|
2014-02-08 16:00:13 +01:00
|
|
|
abort();
|
2007-08-12 12:30:00 +02:00
|
|
|
}
|
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()) &&
|
2010-02-28 14:42:07 +01:00
|
|
|
AddPids(Channel->Dpids()) &&
|
2010-01-30 11:10:25 +01:00
|
|
|
AddPids(Channel->Spids());
|
|
|
|
}
|
2012-03-31 10:15:26 +02:00
|
|
|
return true;
|
2010-01-30 11:10:25 +01:00
|
|
|
}
|
|
|
|
|
2014-01-01 12:37:22 +01:00
|
|
|
void cReceiver::DelPid(int Pid)
|
|
|
|
{
|
|
|
|
if (Pid) {
|
|
|
|
for (int i = 0; i < numPids; i++) {
|
|
|
|
if (pids[i] == Pid) {
|
|
|
|
for ( ; i < numPids; i++) // we also copy the terminating 0!
|
|
|
|
pids[i] = pids[i + 1];
|
|
|
|
numPids--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cReceiver::DelPids(const int *Pids)
|
|
|
|
{
|
|
|
|
if (Pids) {
|
|
|
|
while (*Pids)
|
|
|
|
DelPid(*Pids++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|