vdr 2.8.3
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 5.2 2026/09/02 09:20:35 kls Exp $
8 */
9
10#include "transfer.h"
11
12// --- cTransfer -------------------------------------------------------------
13
16{
17 activated = false;
21}
22
28
30{
31 if (On) {
32 if (cPlayer::IsAttached()) {
34 int Index = 0;
35 while (uchar *pmt = patPmtGenerator.GetPmt(Index))
36 PlayTs(pmt, TS_SIZE);
37 activated = true;
38 }
39 }
40 else {
41 activated = false;
43 }
44}
45
46#define MAXRETRIES 20 // max. number of retries for a single TS packet
47#define RETRYWAIT 5 // time (in ms) between two retries
48#define ERRORDELTA 60 // seconds before reporting lost TS packets again
49
50void cTransfer::Receive(const uchar *Data, int Length)
51{
52 if (activated) {
53 // Transfer Mode means "live tv", so there's no point in doing any additional
54 // buffering here. The TS packets *must* get through here! However, every
55 // now and then there may be conditions where the packet just can't be
56 // handled when offered the first time, so that's why we try several times:
57 for (int i = 0; i < MAXRETRIES; i++) {
58 if (PlayTs(Data, Length) > 0)
59 return;
61 }
64 if (time(NULL) - lastErrorReport > ERRORDELTA) {
65 esyslog("ERROR: %d TS packet(s) not accepted in Transfer Mode", numLostPackets);
67 lastErrorReport = time(NULL);
68 }
69 }
70}
71
72// --- cTransferControl ------------------------------------------------------
73
74std::atomic<cDevice *> cTransferControl::receiverDevice(NULL);
75
84
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
Definition thread.c:73
void SetPlayer(cPlayer *Player)
Definition player.h:115
cControl(cPlayer *Player, bool Hidden=false)
Definition player.c:45
bool AttachReceiver(cReceiver *Receiver)
Attaches the given receiver to this device.
Definition device.c:1927
uchar * GetPmt(int &Index)
Returns a pointer to the Index'th TS packet of the PMT section.
Definition remux.c:599
void SetChannel(const cChannel *Channel)
Sets the Channel for which the PAT/PMT shall be generated.
Definition remux.c:587
uchar * GetPat(void)
Returns a pointer to the PAT section, which consists of exactly one TS packet.
Definition remux.c:593
void Detach(void)
Definition player.c:34
int PlayTs(const uchar *Data, int Length, bool VideoOnly=false)
Definition player.h:50
bool IsAttached(void)
Definition player.h:57
void DeviceClear(void)
Definition player.h:33
void Detach(void)
Definition receiver.c:125
cReceiver(const cChannel *Channel=NULL, int Priority=MINPRIORITY)
Creates a new receiver for the given Channel with the given Priority.
Definition receiver.c:14
static cDevice * ReceiverDevice(void)
Definition transfer.h:40
cTransfer * transfer
Definition transfer.h:34
cTransferControl(cDevice *ReceiverDevice, const cChannel *Channel)
Definition transfer.c:76
static std::atomic< cDevice * > receiverDevice
Definition transfer.h:35
time_t lastErrorReport
Definition transfer.h:21
virtual void Receive(const uchar *Data, int Length) override
This function is called from the cDevice we are attached to, and delivers one TS packet from the set ...
Definition transfer.c:50
cTransfer(const cChannel *Channel)
Definition transfer.c:14
virtual ~cTransfer() override
Definition transfer.c:23
virtual void Activate(bool On) override
This function is called just before the cReceiver gets attached to (On == true) and right after it ge...
Definition transfer.c:29
int numLostPackets
Definition transfer.h:22
std::atomic< bool > activated
Definition transfer.h:20
cPatPmtGenerator patPmtGenerator
Definition transfer.h:23
#define TRANSFERPRIORITY
Definition config.h:44
#define TS_SIZE
Definition remux.h:34
unsigned char uchar
Definition tools.h:31
#define esyslog(a...)
Definition tools.h:35
#define MAXRETRIES
Definition transfer.c:46
#define RETRYWAIT
Definition transfer.c:47
#define ERRORDELTA
Definition transfer.c:48