vdr 2.6.9
receiver.c
Go to the documentation of this file.
1/*
2 * receiver.c: The basic receiver interface
3 *
4 * See the main source file 'vdr.c' for copyright information and
5 * how to reach the author.
6 *
7 * $Id: receiver.c 4.4 2017/05/01 08:49:20 kls Exp $
8 */
9
10#include "receiver.h"
11#include <stdio.h>
12#include "tools.h"
13
14cReceiver::cReceiver(const cChannel *Channel, int Priority)
15{
16 device = NULL;
18 numPids = 0;
24 SetPids(Channel);
25}
26
28{
29 if (device) {
30 const char *msg = "ERROR: cReceiver has not been detached yet! This is a design fault and VDR will abort now!";
31 esyslog("%s", msg);
32 fprintf(stderr, "%s\n", msg);
33 abort();
34 }
35}
36
41
42bool cReceiver::AddPid(int Pid)
43{
44 if (Pid) {
45 if (numPids < MAXRECEIVEPIDS) {
46 if (!WantsPid(Pid)) {
47 pids[numPids++] = Pid;
48 if (device)
49 device->AddPid(Pid);
50 }
51 }
52 else {
53 dsyslog("too many PIDs in cReceiver (Pid = %d)", Pid);
54 return false;
55 }
56 }
57 return true;
58}
59
60bool cReceiver::AddPids(const int *Pids)
61{
62 if (Pids) {
63 while (*Pids) {
64 if (!AddPid(*Pids++))
65 return false;
66 }
67 }
68 return true;
69}
70
71bool cReceiver::AddPids(int Pid1, int Pid2, int Pid3, int Pid4, int Pid5, int Pid6, int Pid7, int Pid8, int Pid9)
72{
73 return AddPid(Pid1) && AddPid(Pid2) && AddPid(Pid3) && AddPid(Pid4) && AddPid(Pid5) && AddPid(Pid6) && AddPid(Pid7) && AddPid(Pid8) && AddPid(Pid9);
74}
75
76bool cReceiver::SetPids(const cChannel *Channel)
77{
78 numPids = 0;
79 if (Channel) {
80 channelID = Channel->GetChannelID();
81 return AddPid(Channel->Vpid()) &&
82 (Channel->Ppid() == Channel->Vpid() || AddPid(Channel->Ppid())) &&
83 AddPids(Channel->Apids()) &&
84 AddPids(Channel->Dpids()) &&
85 AddPids(Channel->Spids());
86 }
87 return true;
88}
89
90void cReceiver::DelPid(int Pid)
91{
92 if (Pid) {
93 for (int i = 0; i < numPids; i++) {
94 if (pids[i] == Pid) {
95 for ( ; i < numPids; i++) // we also copy the terminating 0!
96 pids[i] = pids[i + 1];
97 numPids--;
98 if (device)
99 device->DelPid(Pid);
100 return;
101 }
102 }
103 }
104}
105
106void cReceiver::DelPids(const int *Pids)
107{
108 if (Pids) {
109 while (*Pids)
110 DelPid(*Pids++);
111 }
112}
113
115{
116 if (Pid) {
117 for (int i = 0; i < numPids; i++) {
118 if (pids[i] == Pid)
119 return true;
120 }
121 }
122 return false;
123}
124
126{
127 if (device)
128 device->Detach(this);
129}
const int * Dpids(void) const
Definition channels.h:158
int Vpid(void) const
Definition channels.h:154
tChannelID GetChannelID(void) const
Definition channels.h:191
int Ppid(void) const
Definition channels.h:155
const int * Apids(void) const
Definition channels.h:157
const int * Spids(void) const
Definition channels.h:159
void DelPid(int Pid, ePidType PidType=ptOther)
Deletes a PID from the set of PIDs this device shall receive.
Definition device.c:625
void Detach(cFilter *Filter)
Detaches the given filter from this device.
Definition device.c:718
bool AddPid(int Pid, ePidType PidType=ptOther, int StreamType=0)
Adds a PID to the set of PIDs this device shall receive.
Definition device.c:560
void SetPriority(int Priority)
Definition receiver.c:37
time_t lastEitInjection
Definition receiver.h:29
int Priority(void)
Definition receiver.h:57
bool WantsPid(int Pid)
Definition receiver.c:114
bool AddPids(const int *Pids)
Adds the given zero terminated list of Pids to the list of PIDs of this receiver.
Definition receiver.c:60
time_t startEitInjection
Definition receiver.h:28
int pids[MAXRECEIVEPIDS]
Definition receiver.h:23
void Detach(void)
Definition receiver.c:125
cDevice * device
Definition receiver.h:20
int priority
Definition receiver.h:22
int numPids
Definition receiver.h:24
bool AddPid(int Pid)
Adds the given Pid to the list of PIDs of this receiver.
Definition receiver.c:42
bool SetPids(const cChannel *Channel)
Sets the PIDs of this receiver to those of the given Channel, replacing any previously stored PIDs.
Definition receiver.c:76
void DelPids(const int *Pids)
Deletes the given zero terminated list of Pids from the list of PIDs of this receiver.
Definition receiver.c:106
time_t startScrambleDetection
Definition receiver.h:26
tChannelID channelID
Definition receiver.h:21
time_t lastScrambledPacket
Definition receiver.h:25
int scramblingTimeout
Definition receiver.h:27
cReceiver(const cChannel *Channel=NULL, int Priority=MINPRIORITY)
Creates a new receiver for the given Channel with the given Priority.
Definition receiver.c:14
virtual ~cReceiver()
Definition receiver.c:27
void DelPid(int Pid)
Deletes the given Pid from the list of PIDs of this receiver.
Definition receiver.c:90
#define MINPRIORITY
Definition config.h:44
#define MAXPRIORITY
Definition config.h:43
#define MAXRECEIVEPIDS
Definition receiver.h:15
T constrain(T v, T l, T h)
Definition tools.h:70
#define dsyslog(a...)
Definition tools.h:37
#define esyslog(a...)
Definition tools.h:35