vdr  2.2.0
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 3.1 2013/08/22 12:33:02 kls Exp $
8  */
9 
10 #include "transfer.h"
11 
12 // --- cTransfer -------------------------------------------------------------
13 
15 :cReceiver(Channel, TRANSFERPRIORITY)
16 {
17  patPmtGenerator.SetChannel(Channel);
18 }
19 
21 {
24 }
25 
26 void cTransfer::Activate(bool On)
27 {
28  if (On) {
30  int Index = 0;
31  while (uchar *pmt = patPmtGenerator.GetPmt(Index))
32  PlayTs(pmt, TS_SIZE);
33  }
34  else
36 }
37 
38 #define MAXRETRIES 20 // max. number of retries for a single TS packet
39 #define RETRYWAIT 5 // time (in ms) between two retries
40 
41 void cTransfer::Receive(uchar *Data, int Length)
42 {
43  if (cPlayer::IsAttached()) {
44  // Transfer Mode means "live tv", so there's no point in doing any additional
45  // buffering here. The TS packets *must* get through here! However, every
46  // now and then there may be conditions where the packet just can't be
47  // handled when offered the first time, so that's why we try several times:
48  for (int i = 0; i < MAXRETRIES; i++) {
49  if (PlayTs(Data, Length) > 0)
50  return;
52  }
53  DeviceClear();
54  esyslog("ERROR: TS packet not accepted in Transfer Mode");
55  }
56 }
57 
58 // --- cTransferControl ------------------------------------------------------
59 
61 
62 cTransferControl::cTransferControl(cDevice *ReceiverDevice, const cChannel *Channel)
63 :cControl(transfer = new cTransfer(Channel), true)
64 {
65  ReceiverDevice->AttachReceiver(transfer);
67 }
68 
70 {
71  receiverDevice = NULL;
72  delete transfer;
73 }
unsigned char uchar
Definition: tools.h:30
static cDevice * receiverDevice
Definition: transfer.h:31
void DeviceClear(void)
Definition: player.h:31
virtual void Activate(bool On)
Definition: transfer.c:26
bool IsAttached(void)
Definition: player.h:54
static cDevice * ReceiverDevice(void)
Definition: transfer.h:36
#define TRANSFERPRIORITY
Definition: config.h:42
#define esyslog(a...)
Definition: tools.h:34
bool AttachReceiver(cReceiver *Receiver)
Attaches the given receiver to this device.
Definition: device.c:1663
void SetChannel(const cChannel *Channel)
Sets the Channel for which the PAT/PMT shall be generated.
Definition: remux.c:636
virtual ~cTransfer()
Definition: transfer.c:20
cTransfer * transfer
Definition: transfer.h:30
void Detach(void)
Definition: player.c:34
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
Definition: thread.c:57
uchar * GetPmt(int &Index)
Returns a pointer to the Index&#39;th TS packet of the PMT section.
Definition: remux.c:651
virtual void Receive(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:41
#define MAXRETRIES
Definition: transfer.c:38
cPatPmtGenerator patPmtGenerator
Definition: transfer.h:19
cTransferControl(cDevice *ReceiverDevice, const cChannel *Channel)
Definition: transfer.c:62
int PlayTs(const uchar *Data, int Length, bool VideoOnly=false)
Definition: player.h:47
#define TS_SIZE
Definition: remux.h:34
cTransfer(const cChannel *Channel)
Definition: transfer.c:14
void Detach(void)
Definition: receiver.c:114
The cDevice class is the base from which actual devices can be derived.
Definition: device.h:109
#define RETRYWAIT
Definition: transfer.c:39
uchar * GetPat(void)
Returns a pointer to the PAT section, which consists of exactly one TS packet.
Definition: remux.c:645