vdr 2.6.1
transfer.c
Go to the documentation of this file.
1/*
2 * transfer.c: Transfer mode
3 *
4 * See the main source file 'vdr.c' for copyright information and
5 * how to reach the author.
6 *
7 * $Id: transfer.c 4.2 2017/12/07 15:00:33 kls Exp $
8 */
9
10#include "transfer.h"
11
12// --- cTransfer -------------------------------------------------------------
13
16{
20}
21
23{
26}
27
29{
30 if (On) {
32 int Index = 0;
33 while (uchar *pmt = patPmtGenerator.GetPmt(Index))
34 PlayTs(pmt, TS_SIZE);
35 }
36 else
38}
39
40#define MAXRETRIES 20 // max. number of retries for a single TS packet
41#define RETRYWAIT 5 // time (in ms) between two retries
42#define ERRORDELTA 60 // seconds before reporting lost TS packets again
43
44void cTransfer::Receive(const uchar *Data, int Length)
45{
46 if (cPlayer::IsAttached()) {
47 // Transfer Mode means "live tv", so there's no point in doing any additional
48 // buffering here. The TS packets *must* get through here! However, every
49 // now and then there may be conditions where the packet just can't be
50 // handled when offered the first time, so that's why we try several times:
51 for (int i = 0; i < MAXRETRIES; i++) {
52 if (PlayTs(Data, Length) > 0)
53 return;
55 }
58 if (time(NULL) - lastErrorReport > ERRORDELTA) {
59 esyslog("ERROR: %d TS packet(s) not accepted in Transfer Mode", numLostPackets);
61 lastErrorReport = time(NULL);
62 }
63 }
64}
65
66// --- cTransferControl ------------------------------------------------------
67
69
70cTransferControl::cTransferControl(cDevice *ReceiverDevice, const cChannel *Channel)
71:cControl(transfer = new cTransfer(Channel), true)
72{
75}
76
78{
79 receiverDevice = NULL;
80 delete transfer;
81}
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
Definition: thread.c:72
bool AttachReceiver(cReceiver *Receiver)
Attaches the given receiver to this device.
Definition: device.c:1778
uchar * GetPmt(int &Index)
Returns a pointer to the Index'th TS packet of the PMT section.
Definition: remux.c:600
void SetChannel(const cChannel *Channel)
Sets the Channel for which the PAT/PMT shall be generated.
Definition: remux.c:585
uchar * GetPat(void)
Returns a pointer to the PAT section, which consists of exactly one TS packet.
Definition: remux.c:594
void Detach(void)
Definition: player.c:34
int PlayTs(const uchar *Data, int Length, bool VideoOnly=false)
bool IsAttached(void)
void DeviceClear(void)
void Detach(void)
Definition: receiver.c:125
static cDevice * receiverDevice
static cDevice * ReceiverDevice(void)
cTransferControl(cDevice *ReceiverDevice, const cChannel *Channel)
Definition: transfer.c:70
virtual void Receive(const uchar *Data, int Length)
This function is called from the cDevice we are attached to, and delivers one TS packet from the set ...
Definition: transfer.c:44
time_t lastErrorReport
virtual ~cTransfer()
Definition: transfer.c:22
cTransfer(const cChannel *Channel)
Definition: transfer.c:14
virtual void Activate(bool On)
Definition: transfer.c:28
cPatPmtGenerator patPmtGenerator
#define TRANSFERPRIORITY
Definition: config.h:46
#define TS_SIZE
unsigned char uchar
#define esyslog(a...)
#define MAXRETRIES
Definition: transfer.c:40
#define RETRYWAIT
Definition: transfer.c:41
#define ERRORDELTA
Definition: transfer.c:42